Наследование: IInterTabClient
Пример #1
0
        public WindowViewModel(IObjectProvider objectProvider, IWindowFactory windowFactory)
        {
            _objectProvider = objectProvider;
            InterTabClient = new InterTabClient(windowFactory);
            OpenFileCommand =  new Command(OpenFile);
            ShowInGitHubCommand = new Command(()=>   Process.Start("https://github.com/RolandPheasant"));

            Version = $"v{Assembly.GetEntryAssembly().GetName().Version.ToString(3)}";

            var fileDropped = DropMonitor.Dropped.Subscribe(OpenFile);
            var isEmptyChecker = Views.ToObservableChangeSet()
                                    .Count()
                                    .StartWith(0)
                                    .Select(count=>count==0)
                                    .Subscribe(isEmpty=> IsEmpty = isEmpty);

            _cleanUp = Disposable.Create(() =>
                                         {
                                             isEmptyChecker.Dispose();
                                             fileDropped.Dispose();
                                             DropMonitor.Dispose();
                                             foreach (var disposable in  Views.Select(vc=>vc.Content).OfType<IDisposable>())
                                                 disposable.Dispose();
                                         });
        }
Пример #2
0
        public WindowViewModel(IObjectProvider objectProvider, 
            IWindowFactory windowFactory, 
            ILogger logger,
            IWindowsController windowsController,
            RecentFilesViewModel recentFilesViewModel,
            GeneralOptionsViewModel generalOptionsViewModel,
            ISchedulerProvider schedulerProvider)
        {
            _logger = logger;
            _windowsController = windowsController;
            RecentFiles = recentFilesViewModel;
            GeneralOptions = generalOptionsViewModel;
            _schedulerProvider = schedulerProvider;
            _objectProvider = objectProvider;
            InterTabClient = new InterTabClient(windowFactory);
            OpenFileCommand =  new Command(OpenFile);
            ShowInGitHubCommand = new Command(()=>   Process.Start("https://github.com/RolandPheasant"));

            ZoomOutCommand= new Command(()=> { GeneralOptions.Scale = GeneralOptions.Scale + 5; });
            ZoomInCommand = new Command(() => { GeneralOptions.Scale = GeneralOptions.Scale - 5; });
            SaveLayoutCommand = new Command(WalkTheLayout);
            ExitCommmand = new Command(() => Application.Current.Shutdown());

            Version = $"v{Assembly.GetEntryAssembly().GetName().Version.ToString(3)}";

            var fileDropped = DropMonitor.Dropped.Subscribe(OpenFile);
            var isEmptyChecker = Views.ToObservableChangeSet()
                                    .ToCollection()
                                    .Select(items=>items.Count)
                                    .StartWith(0)
                                    .Select(count=>count==0)
                                    .Subscribe(isEmpty=> IsEmpty = isEmpty);

            var openRecent = recentFilesViewModel.OpenFileRequest
                                .Subscribe(file =>
                                {
                                    MenuIsOpen = false;
                                    OpenFile(file);
                                });

            _cleanUp = new CompositeDisposable(recentFilesViewModel,
                isEmptyChecker,
                fileDropped,
                DropMonitor,
                openRecent,
                Disposable.Create(() =>
                {
                     Views.Select(vc => vc.Content)
                            .OfType<IDisposable>()
                            .ForEach(d=>d.Dispose());
                }));
        }
Пример #3
0
        public WindowViewModel(IObjectProvider objectProvider, 
            IWindowFactory windowFactory, 
            ILogger logger,
            IWindowsController windowsController,
            RecentFilesViewModel recentFilesViewModel,
            GeneralOptionsViewModel generalOptionsViewModel,
            ISchedulerProvider schedulerProvider,
            IApplicationStatePublisher applicationStatePublisher)
        {
            _logger = logger;
            _windowsController = windowsController;
            RecentFiles = recentFilesViewModel;
            GeneralOptions = generalOptionsViewModel;
            _schedulerProvider = schedulerProvider;
            _objectProvider = objectProvider;
            InterTabClient = new InterTabClient(windowFactory);
            OpenFileCommand =  new Command(OpenFile);

            ShowInGitHubCommand = new Command(()=>   Process.Start("https://github.com/RolandPheasant"));
            ZoomOutCommand= new Command(()=> { GeneralOptions.Scale = GeneralOptions.Scale + 5; });
            ZoomInCommand = new Command(() => { GeneralOptions.Scale = GeneralOptions.Scale - 5; });
            CollectMemoryCommand = new Command(() =>
            {
                //Diagnostics [useful for memory testing]
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
            });
            ExitCommmand = new Command(() =>
            {
                applicationStatePublisher.Publish(ApplicationState.ShuttingDown);
                Application.Current.Shutdown();
            });
            WindowExiting = () =>
            {
                applicationStatePublisher.Publish(ApplicationState.ShuttingDown);
            };

            Version = $"v{Assembly.GetEntryAssembly().GetName().Version.ToString(3)}";

            var fileDropped = DropMonitor.Dropped.Subscribe(OpenFile);

            var isEmptyChecker = Views.ToObservableChangeSet()
                                    .ToCollection()
                                    .Select(items=>items.Count)
                                    .StartWith(0)
                                    .Select(count=>count==0)
                                    .LogErrors(logger)
                                    .Subscribe(isEmpty=> IsEmpty = isEmpty);

            var openRecent = recentFilesViewModel.OpenFileRequest
                                .LogErrors(logger)
                                .Subscribe(file =>
                                {
                                    MenuIsOpen = false;
                                    OpenFile(file);
                                });

            var selectedChange = this.WhenValueChanged(vm => vm.Selected)
                .Subscribe(selected =>
                {
                    var currentSelection = selected?.Content as ISelectedAware;

                    Views.Where(hv=> !hv.Equals(selected))
                        .Select(hv => hv.Content)
                        .OfType<ISelectedAware>()
                        .ForEach(selectedAware => selectedAware.IsSelected = false);

                    if (currentSelection != null)
                        currentSelection.IsSelected = true;
                });

            _cleanUp = new CompositeDisposable(recentFilesViewModel,
                isEmptyChecker,
                fileDropped,
                DropMonitor,
                openRecent,
                selectedChange,
                Disposable.Create(() =>
                {
                     Views.Select(vc => vc.Content)
                            .OfType<IDisposable>()
                            .ForEach(d=>d.Dispose());
                }));
        }