Exemple #1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            bool expired = TimeBomb();

            if (expired)
            {
                throw new Exception("tm");
            }

            //Configuro la directory dove sarà salvato il DB
            SetupDataDirectory();

            MainWindow window = new MainWindow();

            // Create the ViewModel to which
            // the main window binds.
            var viewModel = new ShellWindowViewModel();

            // When the ViewModel asks to be closed,
            // close the window.
            viewModel.RequestClose += delegate
            {
                window.Close();
            };

            // Allow all controls in the window to
            // bind to the ViewModel by setting the
            // DataContext, which propagates down
            // the element tree.
            window.DataContext = viewModel;

            window.Show();
        }
        public TabViewModel(ShellWindowViewModel mainViewModel)
        {
            this.mainViewModel = mainViewModel;
            this.mainViewModel.Tabs.CollectionChanged += this.Tabs_CollectionChanged;

            this.AddItemCommand = new DelegateCommand(
                delegate
            {
                this.mainViewModel.AddItem(this);
            },
                delegate
            {
                return(this.mainViewModel.Tabs.Count < 5);
            });

            this.RemoveItemCommand = new DelegateCommand(
                delegate
            {
                this.mainViewModel.RemoveItem(this);
            },
                delegate
            {
                return(this.mainViewModel.Tabs.Count > 1);
            });
        }
Exemple #3
0
 public ShellWindow()
 {
     Logger.InfoLog("ShellWindow:: Constructor");
     this.InitializeComponent();
     objMainWindowViewModel = new ShellWindowViewModel();
     this.DataContext       = objMainWindowViewModel;
 }
Exemple #4
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            DataContext = new ShellWindowViewModel();

            var vm = (DataContext as ShellWindowViewModel);

            vm.PropertyChanged += (s, e1) =>
            {
                if (e1.PropertyName == "CurrentScreen")
                {
                    if (win == null || !win.IsActive)
                    {
                        OpenWindow(vm.CurrentScreen);
                    }
                }
            };

            //   vm.OpenRoles();
        }
Exemple #5
0
        protected override async void OnStartup(StartupEventArgs e)
        {
            _applicationInstance = new WhisperApplication();

            // Initialise the application instance.
            using (var splash = new SplashWindow(_applicationInstance.InitialisationProgress))
            {
                splash.Show();

                var timer = System.Diagnostics.Stopwatch.StartNew();
                await _applicationInstance.InitialiseApplication();

                timer.Stop();

                var delayDelta = (int)(1000 - timer.ElapsedMilliseconds);

                if (delayDelta > 0)
                {
                    await Task.Delay(delayDelta);
                }


                Locator.CurrentMutable.Register(() => new CreateItemView(), typeof(IViewFor <CreateItemViewModel>));
                Locator.CurrentMutable.Register(() => new HistoryListItemView(), typeof(IViewFor <HistoryListItemViewModel>));
                Locator.CurrentMutable.Register(() => new HistoryListView(), typeof(IViewFor <HistoryListViewModel>));

                Locator.CurrentMutable.Register(() => new SettingsPageAboutView(), typeof(IViewFor <SettingsPageAboutViewModel>));
                Locator.CurrentMutable.Register(() => new SettingsPageApplicationView(), typeof(IViewFor <SettingsPageApplicationViewModel>));
                Locator.CurrentMutable.Register(() => new SettingsPageGeneralView(), typeof(IViewFor <SettingsPageGeneralViewModel>));
                Locator.CurrentMutable.Register(() => new SettingsPageGenerationView(), typeof(IViewFor <SettingsPageGenerationViewModel>));
                Locator.CurrentMutable.Register(() => new SettingsPageGenerationItemView(), typeof(IViewFor <SettingsPageGenerationItemViewModel>));

                Func <SettingsWindow> settingsWindowFactory = () =>
                {
                    var settingsWindow = new SettingsWindow();

                    var settingsVm = new SettingsWindowViewModel(new List <SettingsPageViewModelBase>
                    {
                        new SettingsPageAboutViewModel(_applicationInstance.AppInfoService),
                        new SettingsPageGeneralViewModel(_applicationInstance.ConfigService),
                        //new SettingsPageApplicationViewModel(),
                        new SettingsPageGenerationViewModel(_applicationInstance.ConfigService, _applicationInstance.GeneratorService)
                    });

                    settingsWindow.ViewModel = settingsVm;

                    return(settingsWindow);
                };

                var settingsManager = new SettingsWindowManager(settingsWindowFactory);

                var shellWindowViewModel = new ShellWindowViewModel(_applicationInstance.ConfigService, new CreateItemViewModel(_applicationInstance.ConfigService, _applicationInstance.GeneratorService, _applicationInstance.ClipboardService), new HistoryListViewModel(_applicationInstance.GeneratorService, _applicationInstance.ClipboardService), settingsManager);

                // Fix this bat-shit nonsense.
                Locator.CurrentMutable.UnregisterAll <IPropertyBindingHook>();
                Locator.CurrentMutable.Register <IPropertyBindingHook>(() => new BindingHookFixerer());

                var shell = new ShellWindow
                {
                    ViewModel = shellWindowViewModel
                };

                var trayIcon = new WhisperTrayAgent(shell, settingsManager);
                _applicationDisposables.Add(trayIcon);

                splash.Hide();
                splash.Close();

                shell.Show();
            }

            base.OnStartup(e);
        }