コード例 #1
0
        private void RunApp()
        {
            var vm = new MainWindowModel();
            var view = new MainWindow {ViewModel = vm};

            view.ShowDialog();
        }
コード例 #2
0
        public App()
        {
            var vm = new MainWindowModel();
            var view = new MainWindow {ViewModel = vm};

            view.ShowDialog();
        }
コード例 #3
0
		public MainWindowViewModel()
		{
			Model = new MainWindowModel
			{
				console = new ConsoleViewModel(this),
				rover = new RoverViewModel(this)
			};
		}
コード例 #4
0
        /// <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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
ファイル: App.xaml.cs プロジェクト: binhcoi/DDSaveBackup
        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");
        }
コード例 #7
0
        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));
        }
コード例 #8
0
ファイル: TopBar.xaml.cs プロジェクト: betoSolares/filters
        /// <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");
            }
        }
コード例 #9
0
 public virtual void Open()
 {
     if (IsVisible)
     {
         return;
     }
     if (IsWindowCommandsRelated)
     {
         MainWindowModel.SetShowMainWindowCommands(false);
     }
     IsVisible = true;
     this.Messenger.RaiseSafe(() => new GoToStateMessage("Open"));
 }
コード例 #10
0
        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;
        }
コード例 #11
0
        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);
            });
        }
コード例 #12
0
        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();
        }
コード例 #13
0
 public virtual void Close()
 {
     if (!IsVisible)
     {
         return;
     }
     IsVisible = false;
     this.Messenger.RaiseSafe(() => new GoToStateMessage("Close"));
     if (IsWindowCommandsRelated)
     {
         MainWindowModel.SetShowMainWindowCommands(true);
     }
     this.Closed.SafeInvoke();
 }
コード例 #14
0

        
コード例 #15
0
        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);
            }
        }
コード例 #16
0
 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();
     }
 }
コード例 #17
0
        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;
            });
        }
コード例 #18
0
ファイル: MainWindow.xaml.cs プロジェクト: idbart/APECA
        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;
        }
コード例 #19
0
        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();
            }
        }
コード例 #20
0
        /// <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;
            }
        }
コード例 #21
0
ファイル: MainWindow.xaml.cs プロジェクト: lverre/CartaMei
        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
        }
コード例 #22
0
        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));
        }
コード例 #23
0
ファイル: App.xaml.cs プロジェクト: vinnypimp/HomeNetwork
        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();
        }
コード例 #24
0
ファイル: LoadImage.cs プロジェクト: mcldays/Gallery
        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);
            }
        }
コード例 #25
0
ファイル: TopBar.xaml.cs プロジェクト: betoSolares/filters
        /// <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;
        }
コード例 #26
0
 // 只有当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;
     }
 }
コード例 #27
0
 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);
 }
コード例 #28
0
ファイル: Output.xaml.cs プロジェクト: betoSolares/filters
        /// <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;
            }
        }
コード例 #29
0
        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();
        }
コード例 #30
0
        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();
        }
コード例 #31
0
        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());
        }
コード例 #32
0
        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);
                }
            });
        }
コード例 #33
0
        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);
        }
コード例 #34
0
        public void Load()
        {
            Directory.CreateDirectory(SettingsFolderPath);

            if (File.Exists(SettingsFilePath))
            {
                Data = ReadInSettings();
            }
            else
            {
                var defaultSettings = GetDefaultSettings();

                WriteOutSettings(SettingsFilePath, defaultSettings);

                Data = defaultSettings;
            }
        }
コード例 #35
0
ファイル: MainWindow.xaml.cs プロジェクト: Operdies/pinpoint
        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;
        }
コード例 #36
0
 public MainWindow()
 {
     ViewModel = new MainWindowModel();
     InitializeComponent();
 }
コード例 #37
0
 public MouseMoveAction(MainWindowViewModel viewModel)
 {
     this.viewModel = viewModel;
     model = this.viewModel.MainWindowModel;
 }