本文整理汇总了C#中Timer类的典型用法代码示例。如果您正苦于以下问题:C# Timer类的具体用法?C# Timer怎么用?C# Timer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Timer类属于命名空间,在下文中一共展示了Timer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Deserialize
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 1:
{
TimeSpan duration = reader.ReadTimeSpan();
m_Timer = new InternalTimer(this, duration);
m_Timer.Start();
m_End = DateTime.Now + duration;
break;
}
case 0:
{
TimeSpan duration = TimeSpan.FromSeconds(10.0);
m_Timer = new InternalTimer(this, duration);
m_Timer.Start();
m_End = DateTime.Now + duration;
break;
}
}
}
开发者ID:evildude807,项目名称:kaltar,代码行数:32,代码来源:NaturalFire.cs
示例2: Main
private static void Main()
{
DefaultMediaDevice = new MMDeviceEnumerator().GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
DefaultMediaDevice.AudioEndpointVolume.OnVolumeNotification += new AudioEndpointVolumeNotificationDelegate(AudioEndpointVolume_OnVolumeNotification);
TrayIcon = new NotifyIcon();
TrayIcon.Icon = IconFromVolume();
TrayIcon.Text = ToolTipFromVolume();
TrayIcon.MouseClick += new MouseEventHandler(TrayIcon_MouseClick);
TrayIcon.MouseDoubleClick += new MouseEventHandler(TrayIcon_MouseDoubleClick);
TrayIcon.Visible = true;
TrayIcon.ContextMenu = new ContextMenu();
TrayIcon.ContextMenu.MenuItems.Add(new MenuItem("Open Volume Mixer", (o, e) => { Process.Start(SystemDir + "sndvol.exe"); }));
TrayIcon.ContextMenu.MenuItems.Add(new MenuItem("-"));
TrayIcon.ContextMenu.MenuItems.Add(new MenuItem("Playback devices", (o, e) => { Process.Start(SystemDir + "rundll32.exe", @"Shell32.dll,Control_RunDLL mmsys.cpl,,playback"); }));
TrayIcon.ContextMenu.MenuItems.Add(new MenuItem("Recording devices", (o, e) => { Process.Start(SystemDir + "rundll32.exe", @"Shell32.dll,Control_RunDLL mmsys.cpl,,recording"); }));
TrayIcon.ContextMenu.MenuItems.Add(new MenuItem("Sounds", (o, e) => { Process.Start(SystemDir + "rundll32.exe", @"Shell32.dll,Control_RunDLL mmsys.cpl,,sounds"); }));
TrayIcon.ContextMenu.MenuItems.Add(new MenuItem("-"));
TrayIcon.ContextMenu.MenuItems.Add(new MenuItem("Volume control options", (o, e) => { Process.Start(SystemDir + "sndvol.exe", "-p"); }));
SingleClickWindow = new Timer();
SingleClickWindow.Interval = SystemInformation.DoubleClickTime;
SingleClickWindow.Tick += (o, e) =>
{
SingleClickWindow.Stop();
StartVolControl();
};
Application.Run();
}
开发者ID:factormystic,项目名称:SndVolPlus,代码行数:31,代码来源:Program.cs
示例3: RectangleTransparent
public RectangleTransparent()
{
clearPen = new Pen(Color.FromArgb(1, 0, 0, 0));
borderDotPen = new Pen(Color.Black, 1);
borderDotPen2 = new Pen(Color.White, 1);
borderDotPen2.DashPattern = new float[] { 5, 5 };
penTimer = Stopwatch.StartNew();
ScreenRectangle = CaptureHelpers.GetScreenBounds();
surface = new Bitmap(ScreenRectangle.Width, ScreenRectangle.Height);
gSurface = Graphics.FromImage(surface);
gSurface.InterpolationMode = InterpolationMode.NearestNeighbor;
gSurface.SmoothingMode = SmoothingMode.HighSpeed;
gSurface.CompositingMode = CompositingMode.SourceCopy;
gSurface.CompositingQuality = CompositingQuality.HighSpeed;
gSurface.Clear(Color.FromArgb(1, 0, 0, 0));
StartPosition = FormStartPosition.Manual;
Bounds = ScreenRectangle;
Text = "ShareX - " + Resources.RectangleTransparent_RectangleTransparent_Rectangle_capture_transparent;
Shown += RectangleLight_Shown;
KeyUp += RectangleLight_KeyUp;
MouseDown += RectangleLight_MouseDown;
MouseUp += RectangleLight_MouseUp;
using (MemoryStream cursorStream = new MemoryStream(Resources.Crosshair))
{
Cursor = new Cursor(cursorStream);
}
timer = new Timer { Interval = 10 };
timer.Tick += timer_Tick;
timer.Start();
}
开发者ID:KamilKZ,项目名称:ShareX,代码行数:35,代码来源:RectangleTransparent.cs
示例4: frmSplash
public frmSplash()
{
InitializeComponent();
label1.Parent = pictureBox1;
label1.BackColor = Color.Transparent;
label2.Parent = pictureBox1;
label2.BackColor = Color.Transparent;
label3.Parent = pictureBox1;
label3.BackColor = Color.Transparent;
label4.Parent = pictureBox1;
label4.BackColor = Color.Transparent;
label5.Parent = pictureBox1;
label5.BackColor = Color.Transparent;
version.Parent = pictureBox1;
version.BackColor = Color.Transparent;
lblbuilddate.Parent = pictureBox1;
lblbuilddate.BackColor = Color.Transparent;
version.Text = "Version " + Application.ProductVersion;
lblbuilddate.Text = "Build Date: " + Utility.RetrieveLinkerTimestamp().ToString();
LoadPluginSplash();
m_timer = new Timer();
m_timer.Interval = 20;
m_timer.Tick += new EventHandler(m_timer_Tick);
m_timer.Start();
Opacity = 0.0;
}
开发者ID:tojoevan,项目名称:BGC-CW,代码行数:30,代码来源:frmSplash.cs
示例5: StartTimer
/// <summary>
/// Starts the timer.
/// </summary>
public void StartTimer()
{
timer = new Timer();
timer.Interval = 250;
timer.Tick += new EventHandler(Timer_Tick);
timer.Start();
}
开发者ID:tea,项目名称:MOSA-Project,代码行数:10,代码来源:DisplayForm.cs
示例6: OnInitialise
protected override void OnInitialise()
{
base.OnInitialise();
_tickTimer = _timeTrigger;
r_singleShot = _singleShot;
_hasTicked = false;
}
开发者ID:Barabicus,项目名称:ATOMFIACHRA,代码行数:7,代码来源:ObjectTransitionStandard.cs
示例7: MapViewControl
public MapViewControl(frmMain Owner)
{
_Owner = Owner;
InitializeComponent();
ListSelect = new ContextMenuStrip();
ListSelect.ItemClicked += ListSelect_Click;
ListSelect.Closed += ListSelect_Close;
UndoMessageTimer = new Timer();
UndoMessageTimer.Tick += RemoveUndoMessage;
OpenGLControl = Program.OpenGL1;
pnlDraw.Controls.Add(OpenGLControl);
GLInitializeDelayTimer = new Timer();
GLInitializeDelayTimer.Interval = 50;
GLInitializeDelayTimer.Tick += GLInitialize;
GLInitializeDelayTimer.Enabled = true;
tmrDraw = new Timer();
tmrDraw.Tick += tmrDraw_Tick;
tmrDraw.Interval = 1;
tmrDrawDelay = new Timer();
tmrDrawDelay.Tick += tmrDrawDelay_Tick;
tmrDrawDelay.Interval = 30;
UndoMessageTimer.Interval = 4000;
}
开发者ID:Zabanya,项目名称:SharpFlame,代码行数:30,代码来源:MapViewControl.cs
示例8: ChocHelper
public ChocHelper(MediaBrowser.Library.Item Item)
{
this.OverviewTimer = new Timer();
this.CurrentItem = Item;
this.setupHelper();
Instance = this;
}
开发者ID:softworkz,项目名称:MediaBrowser.Themes.Chocolate,代码行数:7,代码来源:ChocHelper.cs
示例9: OnDoubleClick
public override void OnDoubleClick( Mobile from )
{
if ( !IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
return;
}
if ( Core.AOS && (from.Paralyzed || from.Frozen || (from.Spell != null && from.Spell.IsCasting)) )
{
//to prevent exploiting for pvp
from.SendLocalizedMessage( 1075857 ); // You can not use that while paralyzed.
return;
}
if ( m_Timer == null )
{
m_Timer = Timer.DelayCall( TimeSpan.FromSeconds( 1 ), TimeSpan.FromSeconds( 1 ), new TimerCallback( OnFirebombTimerTick ) );
m_LitBy = from;
from.SendLocalizedMessage( 1060581 ); //You light the firebomb! Throw it now!
}
else
from.SendLocalizedMessage( 1060582 ); //You've already lit it! Better throw it now!
from.BeginTarget( 12, true, TargetFlags.None, new TargetCallback( OnFirebombTarget ) );
}
开发者ID:PepeBiondi,项目名称:runsa,代码行数:26,代码来源:Firebomb.cs
示例10: RotatingColor
public RotatingColor()
{
timer = new Timer();
timer.Tick += new EventHandler(this.Tick);
timer.Interval = 50;
hslcolor = new HSLColor(0.0, 240.0, 120.0);
}
开发者ID:colin-harms,项目名称:FTDI-LED-Controller,代码行数:7,代码来源:ColorGenerator.cs
示例11: RouletteTable
public RouletteTable(int maxChipsOnTable, RandomNumberGenerator generator, Timer timer, WalletService walletService)
{
this.maxChipsOnTable = maxChipsOnTable;
this.rng = generator;
this.timer = timer;
this.walletService = walletService;
}
开发者ID:8pointers,项目名称:tdd-exercises-csharp,代码行数:7,代码来源:RouletteTable.cs
示例12: TreeStump
public TreeStump(int itemID)
: base()
{
this.AddComponent(new AddonComponent(itemID), 0, 0, 0);
this.m_Timer = Timer.DelayCall(TimeSpan.FromDays(1), TimeSpan.FromDays(1), new TimerCallback(GiveLogs));
}
开发者ID:FreeReign,项目名称:forkuo,代码行数:7,代码来源:TreeStump.cs
示例13: Form1
public Form1()
{
InitializeComponent();
ControlledProcess = new Process();
Temperature = new TemperatureWorker(1000); //refresh time = 1000ms
TimerInt = new Timer();
TimerInt.Interval = 1000;
TimerInt.Tick += new EventHandler(timer_tick);
TimerInt.Start();
statusStrip1.Text = "statusStrip1";
statusStrip1.Items.Add("Core 1:");
statusStrip1.Items[0].AutoSize = false;
statusStrip1.Items[0].Size = new Size(statusStrip1.Width / 5, 1);
statusStrip1.Items.Add("Core 2:");
statusStrip1.Items[1].AutoSize = false;
statusStrip1.Items[1].Size = new Size(statusStrip1.Width / 5, 1);
statusStrip1.Items.Add("Core 3:");
statusStrip1.Items[2].AutoSize = false;
statusStrip1.Items[2].Size = new Size(statusStrip1.Width / 5, 1);
statusStrip1.Items.Add("Core 4:");
statusStrip1.Items[3].AutoSize = false;
statusStrip1.Items[3].Size = new Size(statusStrip1.Width / 5, 1);
}
开发者ID:MohiuddinM,项目名称:TemperatureMonitor,代码行数:27,代码来源:Form1.cs
示例14: MainForm_Load
/// <summary>
/// フォームのロード時
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MainForm_Load(object sender, EventArgs e)
{
m_timer = new Timer();
m_timer.Tick += this.timerTickHandler;
m_timer.Interval = this.calcInterval();
m_timer.Start();
}
开发者ID:kurose,项目名称:BreakAlert,代码行数:12,代码来源:MainForm.cs
示例15: QuickFillScreen2_Opened
void QuickFillScreen2_Opened(System.Object sender, System.EventArgs e)
{
tmrPressMonitor = new Timer();
tmrPressMonitor.Interval = 500;
tmrPressMonitor.Enabled = true;
tmrPressMonitor.Tick += MONITOR_TICK;
}
开发者ID:xukangmin,项目名称:Graftel_LRM_1402,代码行数:7,代码来源:QuickFillScreen2.Script.cs
示例16: GraphicsDeviceControl
public GraphicsDeviceControl()
{
// Don't initialize the graphics device if we are running in the designer.
if (!DesignMode)
{
graphicsDeviceService = GraphicsDeviceService.AddRef(Handle,
ClientSize.Width,
ClientSize.Height);
// Register the service, so components like ContentManager can find it.
services.AddService<IGraphicsDeviceService>(graphicsDeviceService);
// We used to just invalidate on idle, which ate up the CPU.
// Instead, I'm going to put it on a 30 fps timer
//Application.Idle += delegate { Invalidate(); };
mTimer = new Timer();
// If the user hasn't set DesiredFramesPerSecond
// this will just set it to 30 and it will set the
// interval. If the user has, then this will use the
// custom value set.
DesiredFramesPerSecond = mDesiredFramesPerSecond;
mTimer.Tick += delegate { Invalidate(); };
mTimer.Start();
// Give derived classes a chance to initialize themselves.
Initialize();
}
}
开发者ID:jiailiuyan,项目名称:Gum,代码行数:28,代码来源:GraphicsDeviceControl.cs
示例17: FountainOfLife
public FountainOfLife(int charges)
: base(0x2AC0)
{
this.m_Charges = charges;
this.m_Timer = Timer.DelayCall(this.RechargeTime, this.RechargeTime, new TimerCallback(Recharge));
}
开发者ID:zerodowned,项目名称:JustUO-merged-with-EC-Support,代码行数:7,代码来源:FountainOfLife.cs
示例18: DasmPanel
public DasmPanel()
{
TabStop = true;
// BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.Font = new Font("Courier", 13, System.Drawing.FontStyle.Regular, GraphicsUnit.Pixel);
Size = new System.Drawing.Size(424, 148);
ControlStyles styles = ControlStyles.Selectable |
ControlStyles.UserPaint |
ControlStyles.ResizeRedraw |
ControlStyles.StandardClick | // csClickEvents
ControlStyles.UserMouse | // csCaptureMouse
ControlStyles.ContainerControl | // csAcceptsControls?
ControlStyles.StandardDoubleClick | // csDoubleClicks
// ControlStyles.Opaque | // csOpaque
0;
base.SetStyle(styles, true);
mouseTimer = new Timer();
mouseTimer.Enabled = false;
mouseTimer.Interval = 50;
mouseTimer.Tick += OnMouseTimer;
fLineHeight = 1;
fVisibleLineCount = 0;
fTopAddress = 0;
fActiveLine = 0;
fBreakColor = Color.Red;
fBreakForeColor = Color.Black;
UpdateLines();
}
开发者ID:bobsummerwill,项目名称:ZXMAK2,代码行数:30,代码来源:DebugPanels.cs
示例19: PlayerListBox
public PlayerListBox()
{
DrawMode = DrawMode.OwnerDrawVariable;
this.BackColor = Color.DimGray;
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.UserPaint, true);
realItems = new ObservableCollection<PlayerListItem>();
realItems.CollectionChanged += RealItemsOnCollectionChanged;
timer = new Timer() { Interval = stagingMs, };
timer.Tick += (sender, args) =>
{
try {
BeginUpdate();
int currentScroll = base.TopIndex;
base.Items.Clear();
base.Items.AddRange(realItems.ToArray());
base.TopIndex = currentScroll;
EndUpdate();
timer.Stop();
} catch (Exception ex) {
Trace.TraceError("Error updating list: {0}",ex);
}
};
IntegralHeight = false; //so that the playerlistBox completely fill the edge (not snap to some item size)
}
开发者ID:DeinFreund,项目名称:Zero-K-Infrastructure,代码行数:28,代码来源:PlayerListBox.cs
示例20: Main
public Main()
{
InitializeComponent();
_random = new Random();
Icon = Resources.Clock;
Opacity = 0.90;
_timer = new Timer();
_timer.Tick += new EventHandler(Timer_Tick);
Icon = Resources.Clock;
NotifyIcon.Icon = Resources.Clock;
NotifyIcon.Text = Resources.StoppedLabel;
_notification = new Notification
{
StartPosition = FormStartPosition.Manual
};
_notification.Location = new Point(Screen.PrimaryScreen.WorkingArea.Right - _notification.Width - 10,
Screen.PrimaryScreen.WorkingArea.Bottom - _notification.Height - 10);
_notification.ResetButton.Click += NotificationResetButton_Click;
}
开发者ID:avanderbilt,项目名称:RandomTimer,代码行数:27,代码来源:Main.cs
注:本文中的Timer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论