Пример #1
0
    public MainViewModel()
    {
        _windowState  = (WindowState)Enum.Parse(typeof(WindowState), Services.UiConfig.WindowState);
        _windowWidth  = Services.UiConfig.WindowWidth ?? 1280;
        _windowHeight = Services.UiConfig.WindowHeight ?? 960;

        var(x, y) = (Services.UiConfig.WindowX, Services.UiConfig.WindowY);
        if (x != null && y != null)
        {
            _windowPosition = new PixelPoint(x.Value, y.Value);
        }

        _dialogScreen = new DialogScreenViewModel();

        _fullScreen = new DialogScreenViewModel(NavigationTarget.FullScreen);

        _compactDialogScreen = new DialogScreenViewModel(NavigationTarget.CompactDialogScreen);

        MainScreen = new TargettedNavigationStack(NavigationTarget.HomeScreen);

        NavigationState.Register(MainScreen, DialogScreen, FullScreen, CompactDialogScreen);

        _isMainContentEnabled  = true;
        _isDialogScreenEnabled = true;
        _isFullScreenEnabled   = true;

        _statusBar = new StatusBarViewModel();

        UiServices.Initialize();

        _addWalletPage = new AddWalletPageViewModel();
        _settingsPage  = new SettingsPageViewModel();
        _privacyMode   = new PrivacyModeViewModel();
        _navBar        = new NavBarViewModel(MainScreen);

        MusicControls = new MusicControlsViewModel();

        NavigationManager.RegisterType(_navBar);
        RegisterViewModels();

        RxApp.MainThreadScheduler.Schedule(async() => await _navBar.InitialiseAsync());

        this.WhenAnyValue(x => x.WindowState, x => x.WindowPosition, x => x.WindowWidth, x => x.WindowHeight)
        .Where(x => x.Item1 != WindowState.Minimized)
        .Where(x => x.Item2 != new PixelPoint(-32000, -32000))                 // value when minimized
        .ObserveOn(RxApp.MainThreadScheduler)
        .Subscribe(t =>
        {
            var(state, position, width, height) = t;

            Services.UiConfig.WindowState = state.ToString();
            if (position is { })
            {
                Services.UiConfig.WindowX = position.Value.X;
                Services.UiConfig.WindowY = position.Value.Y;
            }

            Services.UiConfig.WindowWidth  = width;
            Services.UiConfig.WindowHeight = height;
        });
Пример #2
0
        private MainViewModel GetVm()
        {
            MainViewModel.IsUnitTesting = true;
            _ibClient                = new IBClient(new EReaderMonitorSignal());
            _connectionService       = Substitute.For <IConnectionService>();
            _orderManager            = Substitute.For <IOrderManager>();
            _accountManager          = Substitute.For <IAccountManager>();
            _contractManager         = Substitute.For <IContractManager>();
            _marketDataManager       = Substitute.For <IMarketDataManager>();
            _historicalDataManager   = Substitute.For <IHistoricalDataManager>();
            _orderCalculationService = Substitute.For <IOrderCalculationService>();
            _exchangeRateService     = Substitute.For <IExchangeRateService>();
            _tradeRepository         = Substitute.For <ITradeRepository>();
            var orderManager = Substitute.For <IOrderManager>();

            _ordersViewModel    = new OrdersViewModel(_contractManager, _marketDataManager, _historicalDataManager, _orderCalculationService, orderManager, _tradeRepository);
            _statusBarViewModel = Substitute.For <StatusBarViewModel>();

            var positionsManager   = Substitute.For <IPositionManager>();
            var contractManager    = Substitute.For <IContractManager>();
            var positionsViewModel = new PositionsViewModel(_marketDataManager, _accountManager, positionsManager, contractManager);
            var detailsViewModel   = new DetailsViewModel();

            _settingsViewModel = new SettingsViewModel();

            return(new MainViewModel(_ibClient, _connectionService, _orderManager, _accountManager, _ordersViewModel, _statusBarViewModel, _historicalDataManager, _exchangeRateService, _orderCalculationService, positionsViewModel, detailsViewModel, _settingsViewModel));
        }
        public MainWindowViewModel(WindowSettingsViewModel windowSettingsViewModel, InputTextBoxViewModel inputTextBoxViewModel, StatusBarViewModel statusBarViewModel, IFontDialog fontDialog,
                                   IFindDialog findDialog, IColorDialog colorDialog, IAboutDialog aboutDialog, IMessageDialog messageDialog, IReplaceDialog replaceDialog, IOpenFileDialog openFileDialog,
                                   ISaveFileDialog saveFileDialog, IGoToLineDialog goToLineDialog, ITextFileWriter textFileWriter, ITextFileReader textFileReader, IDocInfoService docInfoService,
                                   IFindNextAndReplaceConditionsService findNextSearchConditionsService)
        {
            _fontDialog     = fontDialog;
            _findDialog     = findDialog;
            _colorDialog    = colorDialog;
            _aboutDialog    = aboutDialog;
            _messageDialog  = messageDialog;
            _replaceDialog  = replaceDialog;
            _openFileDialog = openFileDialog;
            _saveFileDialog = saveFileDialog;
            _goToLineDialog = goToLineDialog;
            _textFileWriter = textFileWriter;
            _textFileReader = textFileReader;
            _docInfoService = docInfoService;
            _findNextSearchConditionsService = findNextSearchConditionsService;

            StatusBarViewModel      = statusBarViewModel;
            InputTextBoxViewModel   = inputTextBoxViewModel;
            WindowSettingsViewModel = windowSettingsViewModel;

            InitMessengerRegistrations();
        }
Пример #4
0
        public MainWindow()
        {
            InitializeComponent();

            // Binding Settings and SettingsViewModel
            settingViewModel         = SettingsViewModel.Instance;
            SettingPanel.DataContext = settingViewModel;

            // Binding SearchedList and SearchListViewModel
            searchedListView.ItemsSource = SearchedListViewModel.GetInstance();

            // Binding performance and PerformanceViewModel
            performanceViewModel        = PerformanceViewModel.Instance;
            gridPerformance.DataContext = performanceViewModel;

            // Binding sbStatusBar and StatusBarViewModel
            statusBarViewModel      = StatusBarViewModel.Instance;
            sbStatusBar.DataContext = statusBarViewModel;

            // Binding sbStatusBar and SearchProcViewModel
            searchProcViewModel      = SearchProcViewModel.Instance;
            gdSearchProc.DataContext = searchProcViewModel;

            // Create searchManager
            if (settingViewModel.AdvancedSearch == true)
            {
                searchManager = new AdvancedSearchManager();
            }
            else
            {
                searchManager = new BasedSearchManager();
            }
            searchManager.IndexProc();
        }
Пример #5
0
 public ShellViewModel(IHighlightingDefinition highlighting, IScriptManager scriptManager)
 {
     _highlighting  = highlighting;
     _scriptManager = scriptManager;
     DisplayName    = "ScriptCsPad";
     StatusBar      = new StatusBarViewModel();
 }
Пример #6
0
        public ShellViewModel(
            IFileService fileService,
            ILogLoader logLoader,
            PanelsViewModel plugins,
            IEventAggregator eventAggregator,
            SnackbarService snackbarService,
            IDialogService dialogService,
            Func <SaveRuleMessage, SaveRuleViewModel> saveRuleFactory,
            Func <LoadRuleMessage, LoadRuleViewModel> loadRuleFactory,
            LibraryPanelViewModel libraryPanel,
            Func <LogStateViewModel> logStateFactory,
            DropService dropService,
            StatusBarViewModel statusBar)
        {
            _fileService = fileService;
            _logLoader   = logLoader;

            _eventAggregator = eventAggregator;
            _snackbarService = snackbarService;
            _dialogService   = dialogService;
            _saveRuleFactory = saveRuleFactory;
            _loadRuleFactory = loadRuleFactory;
            _dropService     = dropService;

            Plugins = plugins;

            Snackbar     = snackbarService;
            LibraryPanel = libraryPanel;
            StatusBar    = statusBar;
            _eventAggregator.Subscribe(this);

            LogState = logStateFactory();
            Items.AddRange(new Screen[] { plugins, statusBar });
            DisplayName = "ANALOG";
        }
Пример #7
0
        public MainViewModel(Global global)
        {
            _global = global;

            _dialogScreen = new DialogScreenViewModel();

            var navigationState = new NavigationStateViewModel(() => this, () => _dialogScreen, () => this);

            Network = global.Network;

            _currentDialog = null;

            _isMainContentEnabled  = true;
            _isDialogScreenEnabled = true;

            _statusBar = new StatusBarViewModel(global.DataDir, global.Network, global.Config, global.HostedServices, global.BitcoinStore.SmartHeaderChain, global.Synchronizer, global.LegalDocuments);

            var walletManager = new WalletManagerViewModel(navigationState, global.WalletManager, global.UiConfig);

            var addWalletPage = new AddWalletPageViewModel(navigationState, global.LegalDocuments, global.WalletManager, global.BitcoinStore, global.Network);

            _navBar = new NavBarViewModel(navigationState, Router, walletManager, addWalletPage);

            this.WhenAnyValue(x => x.DialogScreen !.IsDialogOpen)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(x => IsMainContentEnabled = !x);

            this.WhenAnyValue(x => x.CurrentDialog !.IsDialogOpen)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(x => IsDialogScreenEnabled = !x);
        }
Пример #8
0
        private static async void AppMainAsync(string[] args)
        {
            try
            {
                SetTheme();
                var statusBarViewModel = new StatusBarViewModel(Global.DataDir, Global.Network, Global.Config, Global.HostedServices, Global.BitcoinStore.SmartHeaderChain, Global.Synchronizer, Global.LegalDocuments);
                MainWindowViewModel.Instance = new MainWindowViewModel(Global.Network, Global.UiConfig, Global.WalletManager, statusBarViewModel, IoC.Get <IShell>());

                await Global.InitializeNoWalletAsync();

                MainWindowViewModel.Instance.Initialize(Global.Nodes.ConnectedNodes);

                Dispatcher.UIThread.Post(GC.Collect);
            }
            catch (Exception ex)
            {
                if (!(ex is OperationCanceledException))
                {
                    Logger.LogCritical(ex);
                    Global.CrashReporter.SetException(ex);
                }

                await DisposeAsync();

                // There is no other way to stop the creation of the WasabiWindow.
                Environment.Exit(1);
            }
        }
        private static StatusBarViewModel GetVm(IConfiguration configuration = null)
        {
            var config = configuration ?? Substitute.For <IConfiguration>();
            var vm     = new StatusBarViewModel(config);

            return(vm);
        }
Пример #10
0
        public void ShouldBeChangedIfServiceChangeTheState()
        {
            var communicationService = new TestHartCommunicationService();
            var viewModel            = new StatusBarViewModel(communicationService);

            communicationService.PortState = Services.PortState.Opening;
            viewModel.PortState.Should().Be(Services.PortState.Opening);
        }
Пример #11
0
 public StatusBarView(StatusBarViewModel viewModel)
 {
     InitializeComponent();
     if (!DesignerProperties.GetIsInDesignMode(this))
     {
         DataContext = viewModel;
     }
 }
Пример #12
0
#pragma warning disable IDE1006 // Naming Styles

        private static async Task Main(string[] args)
#pragma warning restore IDE1006 // Naming Styles
        {
            Logger.InitializeDefaults(Path.Combine(Global.DataDir, "Logs.txt"));
            StatusBarViewModel statusBar = null;

            try
            {
                Platform.BaseDirectory = Path.Combine(Global.DataDir, "Gui");
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
                TaskScheduler.UnobservedTaskException      += TaskScheduler_UnobservedTaskException;
                BuildAvaloniaApp()
                .BeforeStarting(async builder =>
                {
                    MainWindowViewModel.Instance = new MainWindowViewModel();

                    var configFilePath = Path.Combine(Global.DataDir, "Config.json");
                    var config         = new Config(configFilePath);
                    await config.LoadOrCreateDefaultFileAsync();
                    Logger.LogInfo <Config>("Config is successfully initialized.");

                    Global.InitializeConfig(config);

                    if (!File.Exists(Global.IndexFilePath))                             // Load the index file from working folder if we have it.
                    {
                        var cachedIndexFilePath = Path.Combine("Assets", Path.GetFileName(Global.IndexFilePath));
                        if (File.Exists(cachedIndexFilePath))
                        {
                            File.Copy(cachedIndexFilePath, Global.IndexFilePath, overwrite: false);
                        }
                    }

                    Global.InitializeNoWallet();
                    statusBar = new StatusBarViewModel(Global.Nodes.ConnectedNodes, Global.Synchronizer, Global.UpdateChecker);

                    MainWindowViewModel.Instance.StatusBar = statusBar;

                    if (Global.Synchronizer.Network != Network.Main)
                    {
                        MainWindowViewModel.Instance.Title += $" - {Global.Synchronizer.Network}";
                    }
                }).StartShellApp <AppBuilder, MainWindow>("Wasabi Wallet", null, () => MainWindowViewModel.Instance);
            }
            catch (Exception ex)
            {
                Logger.LogCritical <Program>(ex);
                throw;
            }
            finally
            {
                MainWindowViewModel.Instance?.Dispose();
                statusBar?.Dispose();
                await Global.DisposeAsync();

                AppDomain.CurrentDomain.UnhandledException -= CurrentDomain_UnhandledException;
                TaskScheduler.UnobservedTaskException      -= TaskScheduler_UnobservedTaskException;
            }
        }
        public StatusBarController(StatusBarViewModel ViewModel, IMessenger Messenger, IMapper Mapper)
        {
            viewModel = ViewModel;

            messenger = Messenger;
            mapper    = Mapper;

            timer = new DispatcherTimer();
        }
Пример #14
0
        public StatusBarView(StatusBarViewModel viewModel)
        {
            InitializeComponent();

            this.Loaded += (s, e) =>
            {
                this.DataContext = viewModel;
            };
        }
Пример #15
0
        public MainViewModel()
        {
            _windowState  = (WindowState)Enum.Parse(typeof(WindowState), Services.UiConfig.WindowState);
            _dialogScreen = new DialogScreenViewModel();

            _fullScreen = new DialogScreenViewModel(NavigationTarget.FullScreen);

            _compactDialogScreen = new DialogScreenViewModel(NavigationTarget.CompactDialogScreen);

            MainScreen = new TargettedNavigationStack(NavigationTarget.HomeScreen);

            NavigationState.Register(MainScreen, DialogScreen, FullScreen, CompactDialogScreen);

            _isMainContentEnabled  = true;
            _isDialogScreenEnabled = true;
            _isFullScreenEnabled   = true;

            _statusBar = new StatusBarViewModel();

            UiServices.Initialize();

            _addWalletPage = new AddWalletPageViewModel();
            _settingsPage  = new SettingsPageViewModel();
            _privacyMode   = new PrivacyModeViewModel();
            _searchPage    = new SearchPageViewModel();
            _navBar        = new NavBarViewModel(MainScreen);

            NavigationManager.RegisterType(_navBar);

            RegisterCategories(_searchPage);
            RegisterViewModels();

            RxApp.MainThreadScheduler.Schedule(async() => await _navBar.InitialiseAsync());

            _searchPage.Initialise();

            this.WhenAnyValue(x => x.WindowState)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(windowState => Services.UiConfig.WindowState = windowState.ToString());

            this.WhenAnyValue(x => x.DialogScreen !.IsDialogOpen)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(x => IsMainContentEnabled = !x);

            this.WhenAnyValue(x => x.FullScreen !.IsDialogOpen)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(x => IsMainContentEnabled = !x);

            this.WhenAnyValue(x => x.CompactDialogScreen !.IsDialogOpen)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(x => IsMainContentEnabled = !x);

            if (!Services.WalletManager.HasWallet())
            {
                _dialogScreen.To(_addWalletPage, NavigationMode.Clear);
            }
        }
Пример #16
0
 public StatusBarController(StatusBarViewModel statusBarViewModel, IGeneralService generalService, IShellService shellService, IConnectionService connectionService)
 {
     this.statusBarViewModel = statusBarViewModel;
     this.generalService     = generalService;
     this.shellService       = shellService;
     this.connectionService  = connectionService;
     connectionService.ConnectionChangedEvent += ConnectionUpdated;
     generalService.PropertyChanged           += GeneralServicePropertyChanged;
 }
Пример #17
0
        public void ShouldBeSetTooIfStateIsNotOpened(Services.PortState portState)
        {
            var communicationService = new TestHartCommunicationService {
                PortState = portState
            };
            var viewModel = new StatusBarViewModel(communicationService);

            viewModel.PortName.Should().Be("COM1");
        }
        public DistrictEditViewModel(IDataService <District> ds, IDataService <Region> rs, ILocalStorageService ls, MainViewModel vm, StatusBarViewModel svm)
        {
            _svm = svm;
            _vm  = vm;
            _ds  = ds;
            _rs  = rs;
            _ls  = ls;


            this.isInitializing = true;
            _vm.ActiveViewModels.Add(this.GetType(), "District");

            Messenger.Default.Register <DistrictNameChangedMessage>(this, this.HandleDistrictNameChangedMessage);
            Messenger.Default.Register <ContentPresenterChangedMessage>(this, this.HandleContentPresenterChangedMessage);
            Messenger.Default.Register <ListItemChangedMessage>(this, this.HandleListItemChangedMessage);
            Messenger.Default.Register <RegionComboChangedMessage>(this, this.HandleRegionComboChangedMessage);
            Messenger.Default.Register <AdminDataCloseMessage>(this, this.HandleAdminDataCloseMessage);
            Messenger.Default.Register <NotifyResultMessage>(this, this.HandleNotifyResultMessage);


            this.AddDistrictCommand               = new RelayCommand(this.ExecuteAddDistrictCommand, this.CanExecuteAddDistrictCommand);
            this.EditDistrictCommand              = new RelayCommand(this.ExecuteEditDistrictCommand, this.CanExecuteEditDistrictCommand);
            this.DeleteDistrictCommand            = new RelayCommand(this.ExecuteDeleteDistrictCommand, this.CanExecuteDeleteDistrictCommand);
            this.SaveDistrictCommand              = new RelayCommand(this.ExecuteSaveDistrictCommand, this.CanExecuteSaveDistrictCommand);
            this.CancelDistrictCommand            = new RelayCommand(this.ExecuteCancelDistrictCommand, this.CanExecuteCancelDistrictCommand);
            this.NotificationMessageViewedCommand = new RelayCommand(this.ExecuteNotificationMessageViewedCommand, thisCanExecuteNotificationMessageViewedCommand);

            this.ShowEditButtons(true);
            this.GetDataListsAsync();

            #region CreateManualLists
            //var dist = new District() { PK_District=1, DistrictName = "Gap District", FK_Region = 2 };
            //this.DistrictList = new ObservableCollection<District>
            //{
            //	dist
            //};

            //if (this.DistrictList.Count > 0)
            //{
            //	this.SelectedListItem = this.DistrictList[0];
            //}

            //var reg = new Region() { PK_Region=2, RegionName = "Pennsylvania Region" };
            //this.RegionList = new ObservableCollection<Region> { reg };
            //reg = new Region() { PK_Region=1, RegionName = "Alabama Region" };
            //this.RegionList.Add(reg);
            //if (this.RegionList.Count > 0)
            //{
            //	var item = this.RegionList.Where(w => w.PK_Region == dist.FK_Region).FirstOrDefault();
            //	if(item != null)
            //	{
            //		this.SelectedRegionItem = item;
            //	}
            //}
            #endregion
        }
Пример #19
0
#pragma warning disable IDE1006 // Naming Styles

        private static async Task Main(string[] args)
#pragma warning restore IDE1006 // Naming Styles
        {
            StatusBarViewModel statusBar = null;

            try
            {
                MainWindowViewModel.Instance = new MainWindowViewModel();
                BuildAvaloniaApp().AfterSetup(async builder =>
                {
                    try
                    {
                        Logger.InitializeDefaults(Path.Combine(Global.DataDir, "Logs.txt"));

                        var configFilePath = Path.Combine(Global.DataDir, "Config.json");
                        var config         = new Config(configFilePath);
                        await config.LoadOrCreateDefaultFileAsync();
                        Logger.LogInfo <Config>("Config is successfully initialized.");

                        Global.InitializeConfig(config);

                        if (!File.Exists(Global.IndexFilePath))                         // Load the index file from working folder if we have it.
                        {
                            var cachedIndexFilePath = Path.Combine("Assets", Path.GetFileName(Global.IndexFilePath));
                            if (File.Exists(cachedIndexFilePath))
                            {
                                File.Copy(cachedIndexFilePath, Global.IndexFilePath, overwrite: false);
                            }
                        }

                        Global.InitializeNoWallet();
                        statusBar = new StatusBarViewModel(Global.Nodes.ConnectedNodes, Global.MemPoolService, Global.IndexDownloader, Global.UpdateChecker);

                        MainWindowViewModel.Instance.StatusBar = statusBar;

                        if (Global.IndexDownloader.Network != Network.Main)
                        {
                            MainWindowViewModel.Instance.Title += $" - {Global.IndexDownloader.Network}";
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.LogCritical <Program>(ex);
                    }
                }).StartShellApp <AppBuilder, MainWindow>("Wasabi Wallet", new DefaultLayoutFactory(), () => MainWindowViewModel.Instance);
            }
            catch (Exception ex)
            {
                Logger.LogCritical <Program>(ex);
            }
            finally
            {
                statusBar?.Dispose();
                await Global.DisposeAsync();
            }
        }
Пример #20
0
        public MainViewModel()
        {
            // init the chess board
            Board  = new ChessBoardViewModel(onChessFieldClicked);
            Menu   = new MenuViewModel(this);
            Status = new StatusBarViewModel();

            // try to restore the last game
            ReloadLastGame();
        }
Пример #21
0
        public void ShouldReturnDefaultValueOfService(Services.PortState expectedPortState)
        {
            var communicationMock = new Mock <IHartCommunicationService>();

            communicationMock.SetupGet(item => item.PortState).Returns(expectedPortState);

            var viewModel = new StatusBarViewModel(communicationMock.Object);

            viewModel.PortState.Should().Be(expectedPortState);
        }
Пример #22
0
        public MainViewModel(Global global)
        {
            _global = global;

            Network = global.Network;

            StatusBar = new StatusBarViewModel(global.DataDir, global.Network, global.Config, global.HostedServices, global.BitcoinStore.SmartHeaderChain, global.Synchronizer, global.LegalDocuments);

            NavBar = new NavBarViewModel(this, Router, global.WalletManager, global.UiConfig);
        }
Пример #23
0
        public StatusBarController(StatusBarViewModel ViewModel, IMessenger Messenger)
        {
            messenger = Messenger;

            viewModel = ViewModel;

            timer = new DispatcherTimer();

            viewModel.JobProgressText = "Idle";
        }
Пример #24
0
        public void OnImportsSatisfied()
        {
            editViewModel        = new EditPaneViewModel(Workspace);
            editPane.DataContext = editViewModel;

            Workspace.CommandExecuted  += Workspace_CommandExecuted;
            Workspace.WorkspaceChanged += Workspace_WorkspaceChanged;
            Workspace.SettingsService.SettingChanged += SettingsManager_PropertyChanged;

            // prepare status bar bindings
            var vm = new StatusBarViewModel(Workspace.SettingsService);

            foreach (var x in new[] { new { TextBlock = this.orthoStatus, Path = nameof(WpfSettingsProvider.Ortho) },
                                      new { TextBlock = this.pointSnapStatus, Path = nameof(WpfSettingsProvider.PointSnap) },
                                      new { TextBlock = this.angleSnapStatus, Path = nameof(WpfSettingsProvider.AngleSnap) },
                                      new { TextBlock = this.debugStatus, Path = nameof(DefaultSettingsProvider.Debug) } })
            {
                var binding = new Binding(x.Path);
                binding.Source    = vm;
                binding.Converter = new BoolToBrushConverter();
                binding.Mode      = BindingMode.TwoWay;
                x.TextBlock.SetBinding(TextBlock.ForegroundProperty, binding);
            }

            // add keyboard shortcuts for command bindings
            foreach (var command in from c in Commands
                     let metadata = c.Metadata
                                    where metadata.Key != BCad.Commands.Key.None ||
                                    metadata.Modifier != BCad.Commands.ModifierKeys.None
                                    select metadata)
            {
                this.InputBindings.Add(new InputBinding(
                                           new UserCommand(this.Workspace, command.Name),
                                           new KeyGesture((System.Windows.Input.Key)command.Key, (System.Windows.Input.ModifierKeys)command.Modifier)));
            }

            // add keyboard shortcuts for toggled settings
            foreach (var setting in new[] {
                new { Name = nameof(WpfSettingsProvider.AngleSnap), Shortcut = Workspace.SettingsService.GetValue <KeyboardShortcut>(WpfSettingsProvider.AngleSnapShortcut) },
                new { Name = nameof(WpfSettingsProvider.PointSnap), Shortcut = Workspace.SettingsService.GetValue <KeyboardShortcut>(WpfSettingsProvider.PointSnapShortcut) },
                new { Name = nameof(WpfSettingsProvider.Ortho), Shortcut = Workspace.SettingsService.GetValue <KeyboardShortcut>(WpfSettingsProvider.OrthoShortcut) },
                new { Name = nameof(DefaultSettingsProvider.Debug), Shortcut = Workspace.SettingsService.GetValue <KeyboardShortcut>(WpfSettingsProvider.DebugShortcut) }
            })
            {
                if (setting.Shortcut.HasValue)
                {
                    this.InputBindings.Add(new InputBinding(
                                               new ToggleSettingsCommand(Workspace.SettingsService, setting.Name),
                                               new KeyGesture(setting.Shortcut.Key, setting.Shortcut.Modifier)));
                }
            }

            Workspace_WorkspaceChanged(this, WorkspaceChangeEventArgs.Reset());
        }
Пример #25
0
        // Constructor
        public SetupPage()
        {
            InitializeComponent();

            feedsSubscribedPreviewVM = new FeedsSubscribedPreviewViewModel();
            FeedsSubscribedViewOnPage.DataContext = feedsSubscribedPreviewVM.FeedSubscribedPreviewCollection;
            statusBarVM = new StatusBarViewModel();
            StatusBarViewOnPage.DataContext = statusBarVM;

            // Sample code to localize the ApplicationBar
            //BuildLocalizedApplicationBar();
        }
Пример #26
0
        public MainPage()
        {
            InitializeComponent();

            feedsDashboardVM = new FeedsDashboardViewModel();
            FeedsDashboardViewOnPage.DataContext = feedsDashboardVM.FeedDashboardCollection;
            statusBarVM = new StatusBarViewModel();
            StatusBarViewOnPage.DataContext = statusBarVM;

            refreshDashboardTimer.Interval = TimeSpan.FromSeconds(GetRefreshRate());
            refreshDashboardTimer.Tick    += OnRefreshDashboardTimerTick;
        }
Пример #27
0
#pragma warning disable IDE1006 // Naming Styles

        private static async Task Main(string[] args)
#pragma warning restore IDE1006 // Naming Styles
        {
            StatusBarViewModel statusBar = null;

            try
            {
                Platform.BaseDirectory = Path.Combine(Global.DataDir, "Gui");
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
                TaskScheduler.UnobservedTaskException      += TaskScheduler_UnobservedTaskException;

                if (!await Daemon.RunAsyncReturnTrueIfContinueWithGuiAsync(args))
                {
                    return;
                }
                BuildAvaloniaApp()
                .BeforeStarting(async builder =>
                {
                    MainWindowViewModel.Instance = new MainWindowViewModel();

                    await Global.InitializeNoWalletAsync();

                    statusBar = new StatusBarViewModel(Global.Nodes.ConnectedNodes, Global.Synchronizer, Global.UpdateChecker);

                    MainWindowViewModel.Instance.StatusBar = statusBar;

                    if (Global.Network != Network.Main)
                    {
                        MainWindowViewModel.Instance.Title += $" - {Global.Network}";
                    }

                    Dispatcher.UIThread.Post(() =>
                    {
                        GC.Collect();
                    });
                }).StartShellApp <AppBuilder, MainWindow>("Wasabi Wallet", null, () => MainWindowViewModel.Instance);
            }
            catch (Exception ex)
            {
                Logger.LogCritical <Program>(ex);
                throw;
            }
            finally
            {
                statusBar?.Dispose();
                await Global.DisposeAsync();

                AppDomain.CurrentDomain.UnhandledException -= CurrentDomain_UnhandledException;
                TaskScheduler.UnobservedTaskException      -= TaskScheduler_UnobservedTaskException;

                Logger.LogInfo($"Wasabi stopped gracefully.", Logger.InstanceGuid.ToString());
            }
        }
Пример #28
0
        public MainViewModel(IDialogService dialogService, IFeedbackService feedbackService, IWindowManager windowManager, FramePanelViewModel framePanel, ControlPanelViewModel controlPanel, StatusBarViewModel statusBar)
        {
            DisplayName = "WebcamMouseController";

            DialogService = dialogService;
            FeedbackService = feedbackService;
            WindowManager = windowManager;

            FramePanel = framePanel;
            ControlPanel = controlPanel;
            StatusBar = statusBar;
        }
Пример #29
0
 public MainViewModel()
 {
     MenuVM      = new MenuViewModel();
     StatusBarVM = new StatusBarViewModel();
     StatusBarVM.PropertyChanged += (s, e) =>
     {
         if (e.PropertyName == "Property2" && MenuVM != null)
         {
             MenuVM.RaisePropertyChanged("Property1");
         }
     };
 }
Пример #30
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            Model      = new FlightSimulatorModel(new MySimulatorConnector());
            JoystickVM = new MyJoystickViewModel();
            DashVM     = new DashBaordViewModel();
            SBVM       = new StatusBarViewModel();
            SVM        = new SettingsViewModel();
            // Create main application window
            MainWindow mainWindow = new MainWindow();

            mainWindow.Show();
        }
Пример #31
0
        public MainViewModel()
        {
            var configHelper = new ConfigurationHelper();

            var configuration = configHelper.LoadConfiguration();

            Status     = new StatusBarViewModel();
            Weather    = new WeatherViewModel(configuration.GetFeature("weather"));
            Departures = new DeparturesViewModel(configuration.GetFeature("departures"));
            Agenda     = new AgendaWorker(configuration.GetFeature("agenda"));
            CarInfo    = new CarInfoViewModel(configuration.GetFeature("carInfo"));
        }
        public override void InitViewModels()
        {
            SceneTab = new SceneTabViewModel();
            EntitiesTab = new EntitiesTabViewModel();
            FilesTab = new FilesTabViewModel();
            ConsoleTab = new ConsoleTabViewModel();

            NodesTab = new NodesTabViewModel();
            NodesTab.InitViewModels();

            AssetsTab = new AssetsTabViewModel();
            AssetsTab.InitViewModels();

            SettingsTab = new SettingsTabViewModel();
            SettingsTab.InitViewModels();

            StatusBar = new StatusBarViewModel();
        }
Пример #33
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="viewModel"></param>
        public StatusBarView(StatusBarViewModel viewModel)
        {
            DataContext = viewModel;

            InitializeComponent();
        }