private void RunApp() { var vm = new MainWindowModel(); var view = new MainWindow {ViewModel = vm}; view.ShowDialog(); }
public App() { var vm = new MainWindowModel(); var view = new MainWindow {ViewModel = vm}; view.ShowDialog(); }
public MainWindowViewModel() { Model = new MainWindowModel { console = new ConsoleViewModel(this), rover = new RoverViewModel(this) }; }
/// <summary> /// Initializes a new instance of the <see cref="MainWindowViewModel"/> class. /// </summary> public MainWindowViewModel() : base() { MainWindowModel = new MainWindowModel(); CalculateVarianceCommand = new Command(OnCalculateVarianceCommandExecute, OnCalculateVarianceCommandCanExecute); ResetCommand = new Command(OnResetCommandExecute); }
public void Test_MainWindowModel_Initialization_CreatesWhitePawns() { //Arrange MainWindowModel mainWindowModel = new MainWindowModel(); var resultList = mainWindowModel.BoardViewModel.BoardTiles .FindAll(tile => tile.Figure != null && tile.Figure.Type == FigureType.Pawn && tile.Figure.Color == FigureColor.White); var actualCount = resultList.Count; var expectedCount = 8; //Assert Assert.AreEqual(expectedCount, actualCount); }
void App_Startup(object sender, StartupEventArgs e) { AppConfig.Load(); var mainWindow = new MainWindow(); mainWindow.Show(); var mainModel = new MainWindowModel(mainWindow); mainWindow.SetDataContext(mainModel); Logger.MainModel = mainModel; Logger.Log(LogLevel.Info, "App started"); }
public void Start_WhenConnectingStateChanges_StateChangedHandlerInvoked() { IDeviceEventReceiver eventReceiverFake = CreateDeviceEventReceiverFake(null); IDeviceEventReceiverFactory eventReceiverFactoryFake = CreateDeviceEventReceiverFactoryFake(eventReceiverFake); var autoResetEvent = new AutoResetEvent(false); var model = new MainWindowModel(eventReceiverFactoryFake); model.ConnectionStateChanged += (sender, @event) => autoResetEvent.Set(); model.Start(CreateConnectionParametersFake()); Assert.IsTrue(autoResetEvent.WaitOne(TestWaitTimeoutMs)); }
/// <summary>Change the theme of the app</summary> /// <param name="sender">The object that raised the event</param> /// <param name="e">The object that is being handled</param> private void ChangeTheme(object sender, RoutedEventArgs e) { MainWindowModel context = DataContext as MainWindowModel; if (context.CurrentTheme.Equals("Rust")) { LoadTheme("Citrus"); } else { LoadTheme("Rust"); } }
public virtual void Open() { if (IsVisible) { return; } if (IsWindowCommandsRelated) { MainWindowModel.SetShowMainWindowCommands(false); } IsVisible = true; this.Messenger.RaiseSafe(() => new GoToStateMessage("Open")); }
public MainWindow() { InitializeComponent(); userButton.LogoutBtn.Click += LogOut_Click; WindowModel = new MainWindowModel(Settings.UserName); wind.DataContext = WindowModel; ServerList = new ServerList(); content.Content = ServerList; wind.Loaded += Wind_Loaded; }
public void CreateNewTab() { var creating = TabModel.Create(String.Empty, null); MainWindowModel.ShowTabConfigure(creating) .Subscribe(_ => { if (String.IsNullOrEmpty(creating.Name) && creating.FilterQuery == null) { return; } this.Model.CreateTab(creating); }); }
public MainWindow() { Globals.graphManager = new GraphManager(this); viewModel = new MainWindowModel(Globals.graphManager.axes, Globals.graphManager.series); DataContext = viewModel; InitializeComponent(); this.Title = PROGRAM_TITLE; txtMinY.Text = GraphManager.DEFAULT_MIN_Y.ToString(); txtMaxY.Text = GraphManager.DEFAULT_MAX_Y.ToString(); checkDynamicYScaling.IsChecked = false; txtRangeX.Text = GraphManager.DEFAULT_RANGE_X.ToString(); btnConnect.Click += btnConnect_Click; btnClearLog.Click += btnClearLog_Click; btnDefaultConfig.Click += btnDefaultConfig_Click; btnSetRangeY.Click += btnSetRangeY_Click; btnSetRangeX.Click += btnSetRangeX_Click; this.Closed += MainWindow_Closed; checkShowDataInDebug.Checked += checkShowDataInLog_Checked; checkShowDataInDebug.Unchecked += checkShowDataInLog_Checked; checkShowGraph.Checked += checkShowGraph_Checked; checkShowGraph.Unchecked += checkShowGraph_Checked; checkDynamicYScaling.Checked += checkDynamicYScaling_Checked; checkDynamicYScaling.Unchecked += checkDynamicYScaling_Checked; checkX.Tag = 0; checkY.Tag = 1; checkZ.Tag = 2; checkX.Checked += checkSensorData_Checked; checkX.Unchecked += checkSensorData_Checked; checkY.Checked += checkSensorData_Checked; checkY.Unchecked += checkSensorData_Checked; checkZ.Checked += checkSensorData_Checked; checkZ.Unchecked += checkSensorData_Checked; Globals.phoneListener = new PhoneListener(this); mouseControlWindow = null; quadControlWindow = null; LoadConfiguration(); }
public virtual void Close() { if (!IsVisible) { return; } IsVisible = false; this.Messenger.RaiseSafe(() => new GoToStateMessage("Close")); if (IsWindowCommandsRelated) { MainWindowModel.SetShowMainWindowCommands(true); } this.Closed.SafeInvoke(); }
private void PrintCheckList_Executed(object sender, ExecutedRoutedEventArgs e) { MainWindowModel context = this.DataContext as MainWindowModel; string pdfPath; SaveFileDialog dialog = new SaveFileDialog(); dialog.FileName = "List Inventories"; dialog.Filter = "PDF (*.pdf)|*.pdf"; dialog.InitialDirectory = AppContext.BaseDirectory; if (dialog.ShowDialog(this) == true) { CreateInventoryPDFList(context.PrintList, dialog.FileName); } }
public MainWindow() { this.InitializeComponent(); this.DataContext = this.model; if (System.IO.File.Exists("_tasks.json")) { this.model = JsonConvert.DeserializeObject <MainWindowModel>(System.IO.File.ReadAllText("_tasks.json")); this.DataContext = this.model; } else { AddNewTask(); } }
public MainWindowViewModel(MainWindowModel model, IClearFocus clearFocus) { TextList = model.TextListItems.ToReadOnlyReactiveCollection(m => m); TextListSelectedItem = model.ToReactivePropertyAsSynchronized(m => m.TextListSelectedItem); CanRemove = model.ObserveProperty(m => m.CanRemove).ToReactiveProperty(); AddElementCommand = new DelegateCommand(model.AddPathElement); RemoveElementCommand = new DelegateCommand(model.RemovePathElement); TextListMouseDownCommand = new DelegateCommand(() => { clearFocus.ClearFocus(); model.TextListSelectedItem = null; }); }
public MainWindow() { InitializeComponent(); model = new MainWindowModel(); connectedUsersViewHolder.ItemsSource = model.getClients(); serverMessagesViewHolder.ItemsSource = model.getMessages(); startButton.IsEnabled = true; stopButton.IsEnabled = false; setListenIPButton.IsEnabled = true; setListenIPInput.IsEnabled = true; }
private async Task LoadColumnVisibility(MainWindowModel context) { using (var con = new SQLiteConnection(SqlHelpers.ConnectionString)) { con.Open(); using (var command = con.CreateCommand()) { command.CommandText = "SELECT [ColName], [Boolean] FROM [ListViewColVisible]"; using (var reader = command.ExecuteReader()) { while (await reader.ReadAsync()) { var text = Convert.ToString(reader["ColName"]); int.TryParse(Convert.ToString(reader["Boolean"]), out int result); var isVisible = result == 1 ? true : false; switch (text) { case "Id": context.ColumnIdVisible = isVisible; break; case "Number": context.ColumnNumberVisible = isVisible; break; case "Object": context.ColumnObjectVisible = isVisible; break; case "Income Date": context.ColumnInDateVisible = isVisible; break; case "Price": context.ColumnPriceVisible = isVisible; break; case "Repack": context.ColumnRepackVisible = isVisible; break; default: break; } } } } con.Close(); } }
/// <summary>Display the controls based on the option selected</summary> /// <param name="sender">The object that raised the event</param> /// <param name="e">The object that is being handled</param> private void SelectChooseMethod(object sender, RoutedEventArgs e) { RadioButton radioButton = sender as RadioButton; MainWindowModel context = DataContext as MainWindowModel; if (radioButton.Name.Equals("ManualRadio")) { context.Options.IsManual = true; } else { context.Options.IsManual = false; } }
public MainWindow() { Tools.Utils.Touch();// We need to do that before any plugin is loaded so we "own" Current. Tools.Utils.MainWindow = this; _model = new Models.MainWindowModel(); this.DataContext = _model; Tools.Utils.MainWindowModel = _model; this.InitializeComponent(); PropertyChangedEventHandler mapPropertyChanged = delegate(object s2, PropertyChangedEventArgs e2) { if (e2.PropertyName == nameof(IMap.UseAntiAliasing)) { RenderOptions.SetEdgeMode(this, Current.Map.UseAntiAliasing ? EdgeMode.Unspecified : EdgeMode.Aliased); this.SnapsToDevicePixels = Current.Map.UseAntiAliasing; } }; Current.MapChanged += delegate(CurrentPropertyChangedEventArgs <IMap> e) { if (e.OldValue != null) { e.NewValue.PropertyChanged -= mapPropertyChanged; } if (e.NewValue != null) { e.NewValue.PropertyChanged += mapPropertyChanged; } mapPropertyChanged(null, new PropertyChangedEventArgs(nameof(MapModel.UseAntiAliasing))); }; PluginManager.Instance.Reload(); rebuild(); #if DEBUG var newMap = new NewMapModel() { Datum = Datum.WGS84, Projection = PluginManager.Instance.ProjectionProviders.First(), Name = "test" }; var map = newMap.CreateMap(); Tools.Utils.Current.SetMap(map); map.ActiveObject = map; map.Layers.Add(PluginManager.Instance.LayerProviders.First().Create(map)); #endif }
public void Stop_ConnectionEstablishedThenAborted_StoppedEventHandlerInvoked() { IDeviceEventReceiver eventReceiverFake = CreateDeviceEventReceiverFake(null); IDeviceEventReceiverFactory eventReceiverFactoryFake = CreateDeviceEventReceiverFactoryFake(eventReceiverFake); var autoResetEvent = new AutoResetEvent(false); var model = new MainWindowModel(eventReceiverFactoryFake); model.Stopped += (sender, args) => autoResetEvent.Set(); model.Start(CreateConnectionParametersFake()); Thread.Sleep(500); model.Stop(); Assert.IsTrue(autoResetEvent.WaitOne(TestWaitTimeoutMs)); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); // Initialize Main Window and View Model //var mainWindow = new MainWindow(); var mainWindow = new MainWindow(); var mvm = new MainWindowModel(); mainWindow.DataContext = mvm; mainWindow.Show(); //mainWindow.DataContext = viewModel; //mainWindow.Show(); }
public LoadImage(ObservableCollection <ImageModel> PImageList, MainWindowModel parent) { ParentWindow = parent; this.PImageList = PImageList; /*TimerFileLoad = new DispatcherTimer(); * TimerFileLoad.Interval = new TimeSpan(0, 0, 0, 3, 0); * TimerFileLoad.Tick += FileLoad_Tick; * TimerFileLoad.Start();*/ if (this.PImageList != null) { FileLoad_Tick(null, null); } }
/// <summary>Load the specified theme</summary> /// <param name="name">The name of the theme to load</param> private void LoadTheme(string name) { Window window = this.VisualRoot as Window; MainWindowModel context = DataContext as MainWindowModel; if (window.Styles.Count == 0) { window.Styles.Add(CreateStyle("avares://Citrus.Avalonia/" + name + ".xaml")); } else { window.Styles[0] = CreateStyle("avares://Citrus.Avalonia/" + name + ".xaml"); } context.CurrentTheme = name; }
// 只有当isWindowShow为True时,才进行数据绑定 public MainWindow(bool isWindowShow, string key) { InitializeComponent(); this.MouseDown += (sender, e) => { if (e.LeftButton == MouseButtonState.Pressed) { this.DragMove(); } }; if (isWindowShow) { MainWindowModel mainWindowModel = new MainWindowModel(key); this.DataContext = mainWindowModel; } }
public void CloseInput() { if (!IsOpening) { return; } if (InputCoreViewModel.CheckClearInput()) { // reset tab-account synchronization AccountSelectorViewModel.SynchronizeWithTab(); // close IsOpening = false; } // move focus to timeline MainWindowModel.SetFocusTo(FocusRequest.Timeline); }
/// <summary>Validate the options and create the new image</summary> /// <param name="sender">The object that raised the event</param> /// <param name="e">The object that is being handled</param> private void GenerateNewImage(object sender, RoutedEventArgs e) { MainWindowModel context = DataContext as MainWindowModel; context.Output.ShowResult = false; context.Output.ShowError = false; if (HasValidOptions()) { ApplyKernel(); } else { context.Output.ShowError = true; } }
public MainWindowViewModel(WindowService windowService, MainWindowModel model) : base(windowService, model) { this.model = model; StatusLabel = model.ToReactivePropertyAsSynchronized(m => m.StatusLabel); ProgressValue = model.ToReactivePropertyAsSynchronized(m => m.ProgressValue); ProgressMaximum = model.ToReactivePropertyAsSynchronized(m => m.ProgressMaximum); ProgressIndeterminate = model.ToReactivePropertyAsSynchronized(m => m.ProgressIndeterminate); ProgressLabel = model.ToReactivePropertyAsSynchronized(m => m.ProgressLabel); CloseBtEnabled = model.ToReactivePropertyAsSynchronized(m => m.CanClose); Loaded = new DelegateCommand(MainWindow_Loaded); Closed = new DelegateCommand(MainWindow_Closed); DoLoaded(); }
public MainWindow() { InitializeComponent(); CloseModifyDataGrid(); Constant.mainWindowPointer = this; Loaded += MainWindow_Loaded; Closed += MainWindow_Closed; mainModel = new MainWindowModel(this); DataContext = mainModel; System.Timers.Timer SuspendStudentCheckTimer = new System.Timers.Timer(30000); //One second, (use less to add precision, use more to consume less processor time lastHour = DateTime.Now.Hour; lastSec = DateTime.Now.Second; SuspendStudentCheckTimer.Elapsed += SuspendStudentCheckTimer_Elapsed; SuspendStudentCheckTimer.Start(); }
public void GetStartupShortcutsTest() { var mockSelectExecuteFileService = new Mock <ISelectExecuteFileService>(); var mockShortcutService = new Mock <IShortcutService>(); var mockDialogService = new Mock <IDialogService>(); var model = new MainWindowModel( mockSelectExecuteFileService.Object, mockShortcutService.Object, mockDialogService.Object); mockShortcutService .Setup(m => m.GetShortcuts(MainWindowModel.StartupPath)) .Returns(_samples); Assert.Equal(_samples, model.GetStartupShortcuts()); }
internal static void StartSchedule(bool initial = true) { var rand = new Random(Environment.TickCount); // first startup -> 36 seconds later var next = initial ? 0.01 : 3 + 6 * rand.NextDouble(); Observable .Timer(TimeSpan.FromHours(next)) .Subscribe(async _ => { if (await CheckPrepareUpdate(App.Version)) { if (_isUpdateNotified) { return; } _isUpdateNotified = true; var option = new TaskDialogOptions { Title = SubsystemResources.UpdateAvailableTitle, MainIcon = VistaTaskDialogIcon.Information, MainInstruction = SubsystemResources.UpdateAvailableInst, Content = SubsystemResources.UpdateAvailableContent, CustomButtons = new[] { SubsystemResources.UpdateAvailableButtonImmediate, SubsystemResources.UpdateAvailableButtonLater }, Callback = (dialog, args, data) => { if (args.Notification == VistaTaskDialogNotification.ButtonClicked && args.ButtonIndex == 0) { // update immediately StartUpdate(App.Version); } return(false); } }; MainWindowModel.ShowTaskDialog(option); } else { StartSchedule(false); } }); }
protected override async void OnStartup(StartupEventArgs e) { base.OnStartup(e); AppCenter.SetCountryCode(RegionInfo.CurrentRegion.TwoLetterISORegionName); AppCenter.Start("e9b510a9-904c-475b-8055-7a0f931beb8d", typeof(Microsoft.AppCenter.Analytics.Analytics), typeof(Crashes)); var sessionStart = m_analyticsClient.SubmitSessionStartAsync(); foreach (var arg in e.Args) { Log.Info("Command-line arg: {0}", arg); } MainWindowModel mainWindowModel = m_app.MainWindow; BlamePositionModel?position = null; string?filePath = e.Args.Length >= 1 ? e.Args[0] : null; if (filePath == "/restart" && e.Args.Length == 5) { position = new BlamePositionModel(e.Args[1], e.Args[2]) { CommitId = e.Args[3] == "null" ? null : e.Args[3], LineNumber = int.Parse(e.Args[4]), }; } else if (!string.IsNullOrEmpty(filePath) && File.Exists(filePath)) { position = new BlamePositionModel(filePath); int lineNumber; if (e.Args.Length >= 2 && int.TryParse(e.Args[1], NumberStyles.Integer, CultureInfo.InvariantCulture, out lineNumber)) { position.LineNumber = lineNumber; } } mainWindowModel.NavigateTo(position); Window window = new MainWindow(mainWindowModel); window.Show(); await sessionStart.ConfigureAwait(true); await m_analyticsClient.SubmitAppViewAsync("MainWindow").ConfigureAwait(true); }
public void Load() { Directory.CreateDirectory(SettingsFolderPath); if (File.Exists(SettingsFilePath)) { Data = ReadInSettings(); } else { var defaultSettings = GetDefaultSettings(); WriteOutSettings(SettingsFilePath, defaultSettings); Data = defaultSettings; } }
public MainWindow() { InitializeComponent(); Model = new MainWindowModel(); _pluginEngine = new PluginEngine(); _queryHistory = new QueryHistory(10); _settingsWindow = new SettingsWindow(this, _pluginEngine); _pluginEngine.Listeners.Add(_settingsWindow); RegisterHotkey(AppConstants.HotkeyToggleVisibilityId, _settingsWindow.Model.HotkeyToggleVisibility, OnToggleVisibility); RegisterHotkey(AppConstants.HotkeyPasteId, _settingsWindow.Model.HotkeyPasteClipboard, OnSystemClipboardPaste); _clipboard.ClipboardChanged += ClipboardOnClipboardChanged; }
public MainWindow() { ViewModel = new MainWindowModel(); InitializeComponent(); }
public MouseMoveAction(MainWindowViewModel viewModel) { this.viewModel = viewModel; model = this.viewModel.MainWindowModel; }