本文整理汇总了C#中Clock类的典型用法代码示例。如果您正苦于以下问题:C# Clock类的具体用法?C# Clock怎么用?C# Clock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Clock类属于命名空间,在下文中一共展示了Clock类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnStartup
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
new TaskTrayIcon().AddTo(this);
Clock clock = null;
var detector = new ShortcutKeyDetector().AddTo(this);
detector.KeySetPressedAsObservable()
.Where(_ => Settings.Default.ClockTypeSetting == ClockTypeSetting.Win8)
.Where(_ => clock?.IsDisposed ?? true)
.Where(args => args.ShortcutKey == Settings.Default.ModkeySetting.ToShortcutKey())
.Subscribe(args =>
{
args.Handled = true;
clock = new Clock();
}).AddTo(this);
detector.KeySetPressedAsObservable()
.Where(_ => Settings.Default.ClockTypeSetting == ClockTypeSetting.Calendar)
.Where(args => args.ShortcutKey == Settings.Default.ModkeySetting.ToShortcutKey())
.Subscribe(args =>
{
args.Handled = true;
ShowCalendar.Show();
});
}
示例2: Execute
public virtual void Execute(Clock.Clock clock, MOS6502 cpu, byte pageCrossProlong, byte cycle)
{
byte mem = cpu.Target.Read();
byte a = cpu.State.A.Value;
int tmp = 0, vCheck = 0;
if (cpu.State.P.Decimal)
{
tmp = (a & 0x0f) + (mem & 0x0f) + cpu.State.P.CarryValue;
if (tmp > 0x09)
tmp += 0x06;
tmp += (a & 0xf0) + (mem & 0xf0);
vCheck = tmp;
if ((tmp & 0x1f0) > 0x90)
tmp += 0x60;
cpu.State.P.Carry = (tmp & 0xff0) > 0xf0;
}
else
{
vCheck = tmp = a + mem + cpu.State.P.CarryValue;
cpu.State.P.Carry = (tmp & 0xff00) != 0;
}
cpu.State.A.Value = (byte)tmp;
cpu.State.P.Overflow = ((a ^ mem) & 0x80) == 0 && ((a ^ vCheck) & 0x80) != 0; //(mem & 0x80) == (a & 0x80) && (vCheck & 0x80) != (a & 0x80);
cpu.State.P.Zero = cpu.State.A.IsZero;
cpu.State.P.Negative = cpu.State.A.IsNegative;
if (cpu.Target.IsPageCrossed(cpu.State.PC.Value))
clock.Prolong(pageCrossProlong, cpu.Phase);
}
示例3: Main
public static void Main(string[] args)
{
Console.WriteLine("Input file: ");
var inPath = Console.ReadLine();
inPath = !string.IsNullOrEmpty(inPath) ? inPath : "SampleInput.txt";
var lines = File.ReadAllLines(inPath);
var n = Convert.ToInt32(lines[0]);
var output = new List<string> { n + "" };
for (var i = 1; i < lines.Length; i++)
{
var clock = new Clock(lines[i]);
var hourMinute = AngleUtility.Difference(clock.HourHandDegrees, clock.MinuteHandDegrees);
var hourSecond = AngleUtility.Difference(clock.HourHandDegrees, clock.SecondHandDegrees);
var minuteSecond = AngleUtility.Difference(clock.MinuteHandDegrees, clock.SecondHandDegrees);
output.Add(string.Format("{0}, {1}, {2}", hourMinute, hourSecond, minuteSecond));
}
Console.WriteLine("Output file: ");
var outPath = Console.ReadLine();
outPath = !string.IsNullOrEmpty(outPath) ? outPath : "Output.txt";
File.WriteAllLines(outPath, output);
}
示例4: MainWindow
public MainWindow()
{
InitializeComponent();
ticker = new Clock();
/*
* We could also use the Action type instead of NoArg and save some code.
* But then we'd need to understand Generics...
* so I'll stick with NoArg for now.
*/
NoArg start = ticker.Start;
/*
* .NET prevents us from updating UI elements from another thread.
* Our clock uses Thread.Sleep which would make our app look like it crashed.
* We'll use a separate thread for the clock.Start method, then use the Dispatcher
* to update the UI in its own sweet time on its own sweet thread. Think of
* queing up a message that is then processed by the UI thread when it's able.
*
* Importantly, we don't have to change the Clock class to take advantage of threading.
* All the Dispatch/BeginInvoke magic happens here in the client code.
*
*/
ticker.MillisecondsChanged += Ticker_MillisecondsChangedOnDifferentThread;
ticker.SecondsChanged += Ticker_SecondsChangedOnDifferentThread;
ticker.MinutesChanged += Ticker_MinutesChangedOnDifferentThread;
ticker.HoursChanged += Ticker_HoursChangedOnDifferentThread;
ticker.DaysChanged += Ticker_DaysChangedOnDifferentThread;
start.BeginInvoke(null, null);
}
示例5: TimeTracker
public TimeTracker()
{
_timeline = new ParallelTimeline(null, Duration.Forever);
_timeClock = _timeline.CreateClock();
_timeClock.Controller.Begin();
_lastTime = TimeSpan.FromSeconds(0);
}
示例6: initialize
//man hat 60 sekunden um 10 Items zu sammeln, schafft man es gewinnt man, schafft man es nicht so verliert man
public override void initialize()
{
base.initialize();
//anzahl der eingesammelten Items
numberItemsCollected = new Text[playerList.Count];
int i = 0;
foreach (Player p in playerList)
{
numberItemsCollected[i] = new Text("Items Collected: 0/10", new Vector2(0, 0));
numberItemsCollected[i].setIndividualScale(scale);//mehr geht nicht wegen minimap im multiplayer
numberItemsCollected[i].setPosition(new Vector2(p.getViewport().X + p.getViewport().Width / 2 - numberItemsCollected[i].getWidth() / 2,p.getViewport().Y + p.getViewport().Height - numberItemsCollected[i].getHeight()));
i++;
}
if (playerList.Count == 1)
{//singleplayer ligic
clock = new Clock(new Vector2(0, 0));
clock.setIndividualScale(scale);
clock.setPosition(new Vector2(playerList.First().getViewport().Width / 2 - clock.getWidth() / 2, playerList.First().getViewport().Height - clock.getHeight() - numberItemsCollected[0].getHeight()));
clock.start();
}
currentInGameState = EInGameState.RushHour;
}
示例7: Main
static void Main(string[] args)
{
string input = Console.ReadLine();
int n1 = Int32.Parse(input.Split(' ')[0]);
int n2 = Int32.Parse(input.Split(' ')[1]);
Clock c1 = new Clock();
Clock c2 = new Clock();
int n = 0;
do {
n++;
c1.hours++;
c2.hours++;
c1.mins += n1;
c2.mins += n2;
c1.hours += c1.mins / 60;
c2.hours += c2.mins / 60;
c1.mins %= 60;
c2.mins %= 60;
c1.hours %= 24;
c2.hours %= 24;
}
while(!c1.Equals(c2));
Console.WriteLine((c2.hours > 10 ? "" + c2.hours : "0" + c2.hours) + ":" + (c2.mins > 10 ? "" + c2.mins : "0" + c2.mins));
Console.WriteLine(n);
Console.ReadLine();
}
示例8: TimeMeasuringContext
public TimeMeasuringContext(Clock clock, Action<long> disposeAction)
{
this.clock = clock;
this.start = clock.Nanoseconds;
this.action = disposeAction;
this.disposed = false;
}
示例9: OnTick
void OnTick(Clock clock)
{
if (Input.GetKeyDown(KeyCode.Z)) Played(new Note(clock, NoteNumber.C));
if (Input.GetKeyDown(KeyCode.X)) Played(new Note(clock, NoteNumber.D));
if (Input.GetKeyDown(KeyCode.C)) Played(new Note(clock, NoteNumber.E));
if (Input.GetKeyDown(KeyCode.V)) Played(new Note(clock, NoteNumber.F));
}
示例10: QuickPulseTelemetryProcessor
/// <summary>
/// Initializes a new instance of the <see cref="QuickPulseTelemetryProcessor"/> class. Internal constructor for unit tests only.
/// </summary>
/// <param name="next">The next TelemetryProcessor in the chain.</param>
/// <param name="timeProvider">Time provider.</param>
/// <param name="maxTelemetryQuota">Max telemetry quota.</param>
/// <param name="initialTelemetryQuota">Initial telemetry quota.</param>
/// <exception cref="ArgumentNullException">Thrown if next is null.</exception>
internal QuickPulseTelemetryProcessor(
ITelemetryProcessor next,
Clock timeProvider,
int? maxTelemetryQuota = null,
int? initialTelemetryQuota = null)
{
if (next == null)
{
throw new ArgumentNullException(nameof(next));
}
this.Register();
this.Next = next;
this.requestQuotaTracker = new QuickPulseQuotaTracker(
timeProvider,
maxTelemetryQuota ?? MaxTelemetryQuota,
initialTelemetryQuota ?? InitialTelemetryQuota);
this.dependencyQuotaTracker = new QuickPulseQuotaTracker(
timeProvider,
maxTelemetryQuota ?? MaxTelemetryQuota,
initialTelemetryQuota ?? InitialTelemetryQuota);
this.exceptionQuotaTracker = new QuickPulseQuotaTracker(
timeProvider,
maxTelemetryQuota ?? MaxTelemetryQuota,
initialTelemetryQuota ?? InitialTelemetryQuota);
}
示例11: AddDevice
public void AddDevice(string device = "", string name = "", string fabricator = "")
{
DatabaseMapping databaseMapping = null;
switch (device)
{
case "clock":
Clock clock = new Clock(name);
_deviceContext.Clocks.Add(clock);
databaseMapping = new DatabaseMapping { DeviceTypeId = 1, Clock = clock };
break;
case "microwave":
MicrowaveFabricatorInfo mi = microwaveFabricatorInfo[fabricator];
Microwave microwave = new Microwave(name, mi.Volume, mi.Lamp);
_deviceContext.Microwaves.Add(microwave);
databaseMapping = new DatabaseMapping { DeviceTypeId = 2, Microwave = microwave };
break;
case "oven":
OvenFabricatorInfo oi = ovenFabricatorInfo[fabricator];
Oven oven = new Oven(name, oi.Volume, oi.Lamp);
_deviceContext.Ovens.Add(oven);
databaseMapping = new DatabaseMapping { DeviceTypeId = 3, Oven = oven };
break;
case "fridge":
FridgeFabricatorInfo fi = fridgeFabricatorInfo[fabricator];
Fridge fridge = new Fridge(name, fi.Coldstore, fi.Freezer);
_deviceContext.Fridges.Add(fridge);
databaseMapping = new DatabaseMapping { DeviceTypeId = 4, Fridge = fridge };
break;
default: return;
}
_deviceContext.DatabaseMappings.Add(databaseMapping);
_deviceContext.SaveChanges();
}
示例12: Guess
public Guess()
{
random = new Random();
clock = new Clock(480);
clock.Start();
availableNotes = new List<Pitch>();
availableNotes.Add(Pitch.C3);
availableNotes.Add(Pitch.CSharp3);
availableNotes.Add(Pitch.D3);
availableNotes.Add(Pitch.DSharp3);
availableNotes.Add(Pitch.E3);
availableNotes.Add(Pitch.F3);
availableNotes.Add(Pitch.FSharp3);
availableNotes.Add(Pitch.G3);
availableNotes.Add(Pitch.GSharp3);
availableNotes.Add(Pitch.A3);
availableNotes.Add(Pitch.ASharp3);
availableNotes.Add(Pitch.B4);
availableNotes.Add(Pitch.C4);
availableNotes.Add(Pitch.CSharp4);
availableNotes.Add(Pitch.D4);
availableNotes.Add(Pitch.DSharp4);
availableNotes.Add(Pitch.E4);
availableNotes.Add(Pitch.F4);
availableNotes.Add(Pitch.FSharp4);
availableNotes.Add(Pitch.G4);
availableNotes.Add(Pitch.GSharp4);
availableNotes.Add(Pitch.A4);
availableNotes.Add(Pitch.ASharp4);
availableNotes.Add(Pitch.B4);
}
示例13: Run
public void Run()
{
//initialization
window.SetActive();
Clock clock = new Clock();
clock.Restart();
//loop
while(window.IsOpen)
{
//make sure windows events are handled
window.DispatchEvents();
//handle logic here
Time elapsed = clock.Restart(); //elapsed is the amount of time elapsed since the last loop
GameStates.Peek().Update(elapsed);
//clear the window
window.Clear();
//draw objects here
GameStates.Peek().Draw(window);
//draw the object we placed on our frame
window.Display();
}
//clean up
GameStates.Clear();
}
示例14: AmbientColor
public static Color AmbientColor(Clock c)
{
if (c.Hours() < HourDawn || c.Hours() >= HourDusk)
{
return Night;
}
else if (c.Hours() == HourDawn)
{
return Utils.Mix(c.Minutes() + (c.Seconds() / 60f), Night, Twilight);
}
else if (c.Hours() == HourSunrise)
{
return Utils.Mix(c.Minutes() + (c.Seconds() / 60f), Twilight, Day);
}
else if (c.Hours() == HourDayEnd)
{
return Utils.Mix(c.Minutes() + (c.Seconds() / 60f), Day, TwilightNight);
}
else if (c.Hours() == HourSunset)
{
return Utils.Mix(c.Minutes() + (c.Seconds() / 60f), TwilightNight, Night);
}
else
return Day;
}
示例15: SetupTests
public void SetupTests()
{
reservoir = new ExponentiallyDecayingReservoir();
clock = new TimerTestClock();
this.timer = new Timer(reservoir, clock);
}