static void Main(string[] args) { if (IsRunning.AllRunning()) { MBox.ErrorMessage("An instance of the application is already running."); } else { Mutex mutex = new Mutex(false, Self.LauncherMutex); try { if (mutex.WaitOne(0, false)) { if (args.Length != 0) { MBox.ErrorMessage("Arguments are not supported yet!\n\nPassed Arguments:\n" + String.Join(" ", args)); } //Register all components for launcher, including its settings and configs. Directory.SetCurrentDirectory(Path.GetDirectoryName(Application.ExecutablePath)); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(true); Application.Run(new MainWindow()); } } finally { mutex.Close(); } } }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel() { ////if (IsInDesignMode) ////{ //// // Code runs in Blend --> create design time data. ////} ////else ////{ //// // Code runs "for real" ////} /// RunAutomaticCommand = new ReactiveCommand(); RunAutomaticCommand.Subscribe(_ => { if (IsRunning.Value) { ShouldStop.Value = true; } else { Execute(); } }); TapOnceCommand = new ReactiveCommand(); TapOnceCommand.Subscribe(_ => TapOnce()); StartButtonText = IsRunning.Select(x => (x ? "Stop" : "Start")).ToReactiveProperty(); SearchAdbExec(); AdbInit(); SearchDevices(); }
private static void namespceIsNotRunning() { var name = "001"; Assert.IsNotNull(name); Assert.IsFalse(IsRunning.Namespace(name)); }
public static void LoadDailyRates(Action <string, decimal, DateTime> addRate, bool readFromEcb = false) { var s = IsRunning.Tests(readFromEcb) ? example : WebService.Load(dailyUrl); ReadXml(s, DateTime.MinValue, addRate); }
private static void namespaceIsRunning() { var name = "Open.Aids"; Assert.IsNotNull(name); Assert.IsTrue(IsRunning.Namespace(name)); }
public void Start() { if (!worker.IsBusy) { worker.RunWorkerAsync(); IsRunning?.Invoke(true); } }
public void Stop() { if (worker.IsBusy) { worker.CancelAsync(); IsRunning?.Invoke(false); } }
public void Create() { var obj = new IsRunning(); Assert.IsNotNull(obj); Assert.IsFalse(obj.Running); Assert.IsNull(obj.Filename); }
public static void LoadRatesHistory(Action <string, decimal, DateTime> addRate, bool readFromEcb = false, DateTime?toDate = null) { var date = toDate ?? DateTime.MinValue; var isTesting = IsRunning.Tests(readFromEcb); var s = isTesting ? example : WebService.Load(historyUrl); ReadXml(s, date, addRate); }
/// <summary> /// コンストラクタ /// </summary> /// <param name="modelPool"></param> public StopWatchViewModel(IModelPool modelPool) { // モデルの取得 var model = modelPool.StopWatch; // モデルプロパティを取得 IsRunning = model.IsRunning; FormattedLaps = model.FormattedLaps; IsVisibleMills = model.IsVisibleMillis; // 表示用に20msec毎に間引き FormattedTime = model.FormattedTime .Throttle(TimeSpan.FromMilliseconds(20), Scheduler.Immediate) .ToReadOnlyReactiveProperty(); // アンダースコア:破棄。使用しないということ。 // https://ufcpp.net/study/csharp/datatype/declarationexpressions/#underscore // http://blog.xin9le.net/entry/2017/05/28/020129 // STOPされたら、最速/最遅 ラップを表示して LapActivityへ遷移 IsRunning.Where(x => !x). Subscribe(_ => { // Toastを表示させる Messenger.Send(new ShowToastMessage( $"最速ラップ:{model.FastestLaps}, 最遅ラップ:{model.WorstLaps}")); // LapActivityへ遷移させる Messenger.Send(new StartViewMessage(typeof(LapViewModel))); }) .AddTo(_subscriptions); // 開始 or 停止 CommandStartOrStop = new ReactiveCommand(); // いつでも実行可能 CommandStartOrStop.Subscribe(_ => { model.StartOrStop(); }) .AddTo(_subscriptions); // 経過時間の記録 CommandLap = IsRunning.ToReactiveCommand(); // 実行中(IsRunning = true)のみ記録可能 CommandLap.Subscribe(_ => { model.Lap(); }) .AddTo(_subscriptions); // ミリ秒以下表示切替 CommandToggleVisibleMillis = new ReactiveCommand(); // いつでも実行可能 CommandToggleVisibleMillis.Subscribe(_ => { model.ToggleVisibleMillis(); }) .AddTo(_subscriptions); }
} = new ReactiveCommand(); // いつでも実行可能 public MainViewModel(IModelPool modelPool) { var stopWatch = modelPool.StopWatch; // ■プロパティの実装 // StopWatchModel の各プロパティをそのまま公開してるだけ IsRunning = stopWatch.IsRunning; Laps = stopWatch.Laps; IsVisibleMillis = stopWatch.IsVisibleMillis; // 表示用にthrottleで20ms毎に間引き。View側でやってもよいかも。 Time = stopWatch.Time.Throttle(TimeSpan.FromMilliseconds(20), Scheduler.Immediate).ToReadOnlyReactiveProperty(); // ミリ秒以下表示有無に応じて、format書式文字列を切り替え(これはModelでやるべき?) TimeFormat = stopWatch.IsVisibleMillis.Select(x => x ? @"mm\:ss\.fff" : @"mm\:ss").ToReadOnlyReactiveProperty(); // STOP されたら、最速/最遅ラップを表示して、LapActivity へ遷移 IsRunning.Where(x => !x) .Subscribe(_ => { // Toast を表示させる Messenger.Send(new ShowToastMessage( $"最速ラップ:{stopWatch.FastestLap}, 最遅ラップ:{stopWatch.WorstLap}")); // FIXME 時間がformatされてない // LapActivity へ遷移させる Messenger.Send(new StartViewMessage(typeof(LapViewModel))); // ホントは LapViewModel を指定して画面遷移すべき }) .AddTo(_subscriptions); // ■コマンドの実装 // 開始 or 終了 CommandStartOrStop = new ReactiveCommand(); // いつでも実行可能 CommandStartOrStop.Subscribe(_ => { stopWatch.StartOrStop(); }) .AddTo(_subscriptions); // 経過時間の記録 CommandLap = IsRunning.ToReactiveCommand(); // 実行中のみ記録可能 CommandLap.Subscribe(_ => { stopWatch.Lap(); }) .AddTo(_subscriptions); // ミリ秒以下表示の切り替え CommandToggleVisibleMillis = new ReactiveCommand(); // いつでも実行可能 CommandToggleVisibleMillis.Subscribe(_ => { stopWatch.ToggleVisibleMillis(); }) .AddTo(_subscriptions); }
} = new ReactiveCommand(); // いつでも実行可能 public MainViewModel(INavigationService navigationService, IPageDialogService dialogService, IStopWatchModel stopWatch) { // ■プロパティの実装 // StopWatchModel の各プロパティをそのまま公開してるだけ IsRunning = stopWatch.IsRunning; FormattedLaps = stopWatch.FormattedLaps; IsVisibleMillis = stopWatch.IsVisibleMillis; // 表示用にthrottleで20ms毎に間引き。View側でやってもよいかも。 FormattedTime = stopWatch.FormattedTime //.Do(x=> Debug.WriteLine($"Throttled:{x}")) .ToReadOnlyReactiveProperty(); //// STOP されたら、最速/最遅ラップを表示して、LapActivity へ遷移 IsRunning.Buffer(2, 1).Where(x => x[0] && !x[1]) .Subscribe(async _ => { // Alert を表示させる await dialogService.DisplayAlertAsync( "Fastest/Worst Lap", $"Fastest:{stopWatch.FormattedFastestLap.Value}\n" + $"Worst:{stopWatch.FormattedWorstLap.Value}", "Close"); // LapActivity へ遷移させる await navigationService.NavigateAsync("LapPage"); }) .AddTo(_subscriptions); // ■コマンドの実装 // 開始 or 終了 StartOrStopCommand = new ReactiveCommand(); // いつでも実行可能 StartOrStopCommand.Subscribe(_ => { stopWatch.StartOrStop(); }); // 経過時間の記録 LapCommand = IsRunning.ToReactiveCommand(); // 実行中のみ記録可能 LapCommand.Subscribe(_ => { stopWatch.Lap(); }); // ミリ秒以下表示の切り替え ToggleVisibleMillisCommand = new ReactiveCommand(); // いつでも実行可能 ToggleVisibleMillisCommand.Subscribe(_ => { stopWatch.ToggleVisibleMillis(); }); }
public override async Task StopAsync() { lock (this) { IsRunning.CheckIfFulfills("Server", "running", true); IsRunning = false; } socketServer.Stop(); await camera.StopPreviewAsync(); camera.Dispose(); }
public void TestResetOnNew() { Advance(1); Reset(); IsRunning.Should().BeFalse(); Advance(2); Elapsed.ShouldBeEquivalentTo(TimeSpan.Zero); Start(); Advance(3); Elapsed.Ticks.Should().Be(3); }
public override async Task StartAsync() { lock (this) { IsRunning.CheckIfFulfills("Server", "running", false); IsRunning = true; } camera.Dispose(); socketServer.Start(); await camera.InitializeAsync(); await camera.StartPreviewAsync(captureElement); }
public override int GetHashCode() { int hash = 1; if (IsRunning != false) { hash ^= IsRunning.GetHashCode(); } if (IsWaitingForStart != false) { hash ^= IsWaitingForStart.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override int GetHashCode() { int hash = 1; if (RoomName.Length != 0) { hash ^= RoomName.GetHashCode(); } if (RoomId != 0L) { hash ^= RoomId.GetHashCode(); } if (CreateTime != 0L) { hash ^= CreateTime.GetHashCode(); } if (CurPlayerCount != 0) { hash ^= CurPlayerCount.GetHashCode(); } if (MaxPlayerCount != 0) { hash ^= MaxPlayerCount.GetHashCode(); } if (Creator != 0L) { hash ^= Creator.GetHashCode(); } if (IsRunning != false) { hash ^= IsRunning.GetHashCode(); } if (IsRemove != false) { hash ^= IsRemove.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override int GetHashCode() { var hashCode = 1442701761; hashCode = hashCode * -1521134295 + IsRunning.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Error); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Version); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(ApiVersion); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(GoVersion); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(GitCommit); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Built); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(OsArch); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Experimental); return(hashCode); }
static void Main(string[] args) { Self.isDebugMode = Debugger.IsAttached; if (IsRunning.AllRunning()) { MBox.ErrorMessage("An instance of the application is already running."); } else { Mutex mutex = new Mutex(false, Self.LauncherMutex); try { if (mutex.WaitOne(0, false)) { if (args.Length != 0) { MBox.ErrorMessage("Arguments are not supported yet!\n\nPassed Arguments:\n" + String.Join(" ", args)); } Directory.SetCurrentDirectory(Path.GetDirectoryName(Application.ExecutablePath)); ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; Application.ThreadException += (sender, exception) => { ExceptionCapture((Exception)exception.Exception, "ThreadExceptionEventHandler"); }; AppDomain.CurrentDomain.UnhandledException += (sender, exception) => { ExceptionCapture((Exception)exception.ExceptionObject, "UnhandledExceptionEventHandler"); }; Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(true); Application.Run(new MainWindow(args)); } } finally { mutex.Close(); } } }
[TestMethod] public void TestsTest() { Assert.IsTrue(IsRunning.Tests()); Assert.IsFalse(IsRunning.Tests(true)); }
public PlanExecutionEvents OnIsRunning(bool isRunning) { IsRunning?.Invoke(this, new PlanIsRunningUpdatedEventArgs(backupPlan, isRunning)); return(this); }
public override void FixedFrequencyUpdate(float deltaTime) { // if there is enough input, do the processing and store item to output // - remove items from input // - add param to reflect factory can provide output (has output inside) // - as output will be produced after time, it is possible that output spot can be ocupied meanwhile // - process for specified time // - if output slot is free, provide output (if not, keep output 'inside' factory) if (ParentFurniture.IsBeingDestroyed) { return; } if (RunConditions != null && AreParameterConditionsFulfilled(RunConditions.ParamConditions) == false) { IsRunning.SetValue(false); return; } float efficiency = 1f; if (Efficiency != null) { efficiency = RetrieveFloatFor(Efficiency, ParentFurniture); } string curSetupChainName = CurrentProductionChainName.ToString(); if (!string.IsNullOrEmpty(curSetupChainName)) { ProductionChain prodChain = GetProductionChainByName(curSetupChainName); // if there is no processing in progress if (InputProcessed.ToInt() == 0) { // check input slots for input inventory List <KeyValuePair <Tile, int> > flaggedForTaking = CheckForInventoryAtInput(prodChain); // if all the input requirements are ok, you can start processing: if (flaggedForTaking.Count == prodChain.Input.Count) { // consume input inventory ConsumeInventories(flaggedForTaking); InputProcessed.SetValue(1); // check if it can be bool IsRunning.SetValue(true); // reset processing timer and set max time for processing for this prod. chain CurrentProcessingTime.SetValue(0f); MaxProcessingTime.SetValue(prodChain.ProcessingTime); HasAllNeededInputInventory.SetValue(true); } else { HasAllNeededInputInventory.SetValue(false); } } else { // processing is in progress CurrentProcessingTime.ChangeFloatValue(deltaTime * efficiency); IsRunning.SetValue(true); if (CurrentProcessingTime.ToFloat() >= MaxProcessingTime.ToFloat()) { List <TileObjectTypeAmount> outPlacement = CheckForInventoryAtOutput(prodChain); // if output placement was found for all products, place them if (outPlacement.Count == 0 || outPlacement.Count == prodChain.Output.Count) { PlaceInventories(outPlacement); //// processing done, can fetch input for another processing InputProcessed.SetValue(0); IsRunning.SetValue(false); CurrentProcessingTime.SetValue(0f); } } } } }
public string Get(string propertyName) { switch (propertyName) { //ELEMENT case nameof(ClassId): return(ClassId.ToString()); case nameof(AutomationId): return(AutomationId.ToString()); case nameof(Id): return(Id.ToString()); case nameof(StyleId): return(StyleId.ToString()); //VISUAL ELEMENT case nameof(AnchorX): return(AnchorX.ToString()); case nameof(AnchorY): return(AnchorY.ToString()); case nameof(BackgroundColor): return(BackgroundColor.ToHex()); case nameof(Width): return(this.Width.ToString()); case nameof(Height): return(this.Height.ToString()); case nameof(IsEnabled): return(IsEnabled.ToString()); case nameof(WidthRequest): return(this.WidthRequest.ToString()); case nameof(HeightRequest): return(this.HeightRequest.ToString()); case nameof(IsFocused): return(IsFocused.ToString()); case nameof(IsVisible): return(IsVisible.ToString()); case nameof(InputTransparent): return(InputTransparent.ToString()); case nameof(X): return(this.X.ToString()); case nameof(Y): return(this.Y.ToString()); case nameof(Opacity): return(this.Opacity.ToString()); case nameof(TranslationX): return(this.TranslationX.ToString()); case nameof(TranslationY): return(this.TranslationY.ToString()); case nameof(Rotation): return(this.Rotation.ToString()); case nameof(RotationX): return(this.RotationX.ToString()); case nameof(RotationY): return(this.RotationY.ToString()); case nameof(Scale): return(this.Scale.ToString()); //VIEW case nameof(Margin): return(this.Margin.ToString()); case nameof(VerticalOptions): return(this.VerticalOptions.ToString()); case nameof(HorizontalOptions): return(this.HorizontalOptions.ToString()); //ACTIVITY_INDICATOR case nameof(Color): return(Color.ToHex()); case nameof(IsRunning): return(IsRunning.ToString()); default: return(string.Empty); } }
public void TestStop() { Start(); Stop().Should().BeSameAs(stopwatch); IsRunning.Should().BeFalse(); }
public MainViewModel(INavigationService navigationService, IPageDialogService dialogService, LocationUseCase locationUseCase) { // ■プロパティの実装 // LocationUseCase の各プロパティを必要なら加工して公開 IsRunning = locationUseCase.IsRunning.ToReadOnlyReactiveProperty(); // Location の時刻をフォーマットして公開 FormattedTime = locationUseCase.Location .Select(l => l.Time.ToString("HH:mm:ss")) .ToReadOnlyReactiveProperty(); // Location の緯度を度分秒または度にフォーマットして公開 FormattedLatitude = IsDmsFormat.CombineLatest( locationUseCase.Location.Select(l => l.Latitude), (isDms, lat) => lat.Format(isDms)) .ToReadOnlyReactiveProperty(); // Location の経度を度分秒または度にフォーマットして公開 FormattedLongitude = IsDmsFormat.CombineLatest( locationUseCase.Location.Select(l => l.Longitude), (isDms, lon) => lon.Format(isDms)) .ToReadOnlyReactiveProperty(); // 記録されたレコード群を件数として公開 RecordCount = locationUseCase.Records .ToCollectionChanged() .Select(_ => locationUseCase.Records.Count) .ToReadOnlyReactiveProperty(); //// STOP されたら、最も精度のよい位置情報を表示して、RecordsPage へ遷移 IsRunning .Buffer(2, 1) .Where(x => x[0] && !x[1]) .Subscribe(async _ => { // 最も精度のよい緯度経度を得る // 返値がメソッドは、その時点の情報でしかない(Reactiveではない)ので注意すること var bestLocation = locationUseCase.GetBestLocation(); var message = bestLocation.HasValue ? $"{bestLocation.Value.Latitude.Format(IsDmsFormat.Value)}/" + $"{bestLocation.Value.Longitude.Format(IsDmsFormat.Value)} です。" : "記録されてません"; //// Alert を表示させる await dialogService.DisplayAlertAsync("最も精度の良い位置は", message, "Close"); // RecordPage へ遷移させる await navigationService.NavigateAsync("RecordsPage"); }); // ■コマンドの実装 // 開始 or 終了 StartOrStopCommand = new ReactiveCommand(); // いつでも実行可能 StartOrStopCommand.Subscribe(_ => { locationUseCase.StartOrStop(); }); // 位置情報の記録 RecordCommand = IsRunning.ToReactiveCommand(); // 実行中のみ記録可能 RecordCommand.Subscribe(_ => { locationUseCase.Record(); }); }
public void TestStopOnNew() { Stop().Elapsed.ShouldBeEquivalentTo(TimeSpan.Zero); IsRunning.Should().BeFalse(); }
public AppModel() { SwitchDevice = ObservableProperty.CreateSettable <object>(null, true); ReverseBitmap = ObservableProperty.CreateSettable <object>(null, true); VideoBitmap = ObservableProperty.CreateSettable <BitmapFrame>(null); IsRunning = ObservableProperty.CreateSettable(false); var oldNewIndexes = SwitchDevice .Select(_ => new { OldValue = SelectedDeviceIndex.Value, NewValue = (SelectedDeviceIndex.Value + 1) % _devices.Length }) .ToGetOnly(null); SelectedDeviceIndex = oldNewIndexes .Select(_ => _.NewValue) .ToGetOnly(0); BitmapScaleX = ReverseBitmap .Select(_ => - 1 * BitmapScaleX.Value) .ToGetOnly(-1); _devices = new FilterInfoCollection(FilterCategory.VideoInputDevice) .Cast <FilterInfo>() .Select(f => new VideoCaptureDevice(f.MonikerString)) .Do(d => d.VideoResolution = GetResolution(d.VideoCapabilities)) .ToArray(); if (_devices.Length == 0) { return; } IsRunning //.Throttle(TimeSpan.FromMilliseconds(200)) .ObserveOn(Scheduler.Default) .Subscribe(b => { if (b) { StartDevice(SelectedDeviceIndex.Value); } else { StopDevice(SelectedDeviceIndex.Value); } }); oldNewIndexes .Where(_ => IsRunning.Value) //.Throttle(TimeSpan.FromMilliseconds(200)) .ObserveOn(Scheduler.Default) .Subscribe(_ => { StopDevice(_.OldValue); // 連続してデバイスを操作すると失敗することがあるため、待機します。 Thread.Sleep(200); StartDevice(_.NewValue); }); }
[TestMethod] public void NamespaceTest() { Assert.IsFalse(IsRunning.Namespace(null)); namespaceIsRunning(); namespceIsNotRunning(); }
public void TestInitialState() { IsRunning.Should().BeFalse(); Elapsed.Ticks.Should().Be(0); }
public MainViewModel() { // ファイルから読む体で userDict.Add("111", new UserModel("111", "社会人P") { Color = Colors.LightGreen }); userDict.Add("222", new UserModel("222", "八百屋")); Comments = model.Comments.ToReadOnlyReactiveCollection(comment => { if (!userDict.TryGetValue(comment.ID, out var user)) { user = new UserModel(comment.ID); userDict.Add(user.ID, user); } return(new CommentViewModel(comment, user)); }).AddTo(disposable); #region Command NameChangeCommand.Subscribe(obj => { var menuItem = obj as MenuItem; var comment = menuItem.DataContext as CommentViewModel; var ib = new InputBox { DataContext = comment, Text = comment.Name.Value, }; if (ib.ShowDialog() == true) { comment.Name.Value = ib.Text; } }); ColorChangeCommand.Subscribe(obj => { var menuItem = obj as MenuItem; var comment = menuItem.DataContext as CommentViewModel; comment.Color.Value = (Color)menuItem.Tag; }); ConnectCommand = IsRunning.Select(x => !x).ToAsyncReactiveCommand(); ConnectCommand.Subscribe(async _ => { await model.ConnectAsync("lv1234567"); IsRunning.Value = true; }).AddTo(disposable); DisconnectCommand = IsRunning.ToReactiveCommand(); DisconnectCommand.Subscribe(_ => { model.Disconnect(); IsRunning.Value = false; }).AddTo(disposable); #endregion ConnectCommand.Execute(); }