public ToolTabViewModel(Tools tools) { Tools = tools; ButtonDownload = "翻訳ファイルをダウンロード"; ButtonApplyTranslation = "翻訳を適用"; ButtonApplyFont = "フォントを適用"; ButtonRevertToEnglish = "英語に戻す"; IsProgress = Tools.ToReactivePropertyAsSynchronized(x => x.IsProgress, convert: x => x.Inverse(), convertBack: x => x.Inverse()); DownloadCommand.Subscribe(_ => Tools.Download()); ApplyTranslationCommand.Subscribe(_ => Tools.ApplyTranslation()); ApplyFontsCommand.Subscribe(_ => Tools.ApplyFonts()); RevertToEnglishCommand.Subscribe(_ => Tools.ApplyTranslation(true)); }
/// <summary> /// Initialize the view model. /// </summary> public AdcpUtilitiesViewModel() : base("ADCP Utilities") { // Set Event Aggregator _events = IoC.Get <IEventAggregator>(); // Compass Cal command CompassCalCommand = ReactiveCommand.Create(); CompassCalCommand.Subscribe(_ => CompassCal()); // Compass Utility command CompassUtilityCommand = ReactiveCommand.Create(); CompassUtilityCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.CompassUtilityView))); // Terminal command TerminalCommand = ReactiveCommand.Create(); TerminalCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.TerminalView))); // Download command DownloadCommand = ReactiveCommand.Create(); DownloadCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.DownloadDataView))); // Upload Firmware command UploadCommand = ReactiveCommand.Create(); UploadCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.UpdateFirmwareView))); // Screen data command ScreenCommand = ReactiveCommand.Create(); ScreenCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.ScreenDataView))); VmOptionsCommand = ReactiveCommand.Create(); VmOptionsCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.VesselMountOptionsView))); // Predicition Model command PredicitionModelCommand = ReactiveCommand.Create(); PredicitionModelCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.AdcpPredictionModelView))); // RTI Compass Calibration Model command RtiCompassCalCommand = ReactiveCommand.Create(); RtiCompassCalCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.RtiCompassCalView))); // Diagnostics View command DiagnosticsCommand = ReactiveCommand.Create(); DiagnosticsCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.DiagnosticView))); // Data Output View command DataOutputCommand = ReactiveCommand.Create(); DataOutputCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.DataOutputView))); }
//private DxxUrl CreateDxxUrl() { // var driver = Driver.Value; // var uri = new Uri(Url.Value); // return new DxxUrl(uri, driver, driver.GetNameFromUri(uri, "link"), IsMain ? "from main" : "from sub"); //} private void InitializeCommands() { GoBackCommand.Subscribe(() => { GoBack(); }); GoForwardCommand.Subscribe(() => { GoForward(); }); ReloadCommand.Subscribe(() => { Reload(); }); StopCommand.Subscribe(() => { Stop(); }); BookmarkCommand.Subscribe((v) => { if (string.IsNullOrEmpty(v) || !v.StartsWith("http")) { IsBookmarked.Value = false; return; } if (IsBookmarked.Value) { Bookmarks.Value.AddBookmark("", v); } else { Bookmarks.Value.RemoveBookmark(v); Url.Value = v; } }); NavigateCommand.Subscribe((v) => { Navigate(v); }); ClearURLCommand.Subscribe((v) => { Url.Value = ""; }); AnalyzeCommand.Subscribe((v) => { if (v == null) { v = Url.Value; } var aw = new DxxAnalysisWindow(v); //aw.Owner = Owner; aw.Show(); }); CopyCommand.Subscribe((v) => { Clipboard.SetData(DataFormats.Text, v); }); DownloadCommand.Subscribe(() => { if (IsTarget.Value || IsContainer.Value) { DxxDriverManager.Instance.Download(Url.Value, null, ""); } }); ListingCommand.Subscribe(async() => { if (IsContainerList.Value) { var uri = new Uri(Url.Value); var dxxUrl = new DxxUrl(uri, Driver.Value, Driver.Value.GetNameFromUri(uri), ""); var targets = await Driver.Value.LinkExtractor.ExtractTargets(dxxUrl); if (targets != null && targets.Count > 0) { TargetList.Value = new ObservableCollection <DxxTargetInfo>(targets); } else { TargetList.Value?.Clear(); } } }); SetupDriverCommand.Subscribe(() => { DxxDriverManager.Instance.Setup(Driver.Value, Owner); }); FrameSelectCommand.Subscribe((v) => { if (IsMain) { RequestLoadInSubview.OnNext(v); } else { Navigate(v); } }); }