/// <summary>
        /// コンストラクター
        /// </summary>
        public MainWindowViewModel(IAppSettingsService appSettingsService, IOpenFileDialogService openFileDialogService, ITextReadService textReadService, ITalkService talkService, ITalkQueueService talkQueueService)
        {
            AppSettingsService    = appSettingsService;
            OpenFileDialogService = openFileDialogService;
            TextReadService       = textReadService;
            TalkService           = talkService;
            TalkQueueService      = talkQueueService;

            TextReadService.Subscribe(TalkQueueService.Enqueue);

            SelectedCast.Value = TalkService.Cast;
            SelectedCast.Subscribe(x => TalkService.Cast = x);

            Volume.Value = TalkService.Volume;
            Volume.Subscribe(x => TalkService.Volume = x);

            Speed.Value = TalkService.Speed;
            Speed.Subscribe(x => TalkService.Speed = x);

            Tone.Value = TalkService.Tone;
            Tone.Subscribe(x => TalkService.Tone = x);

            Alpha.Value = TalkService.Alpha;
            Alpha.Subscribe(x => TalkService.Alpha = x);

            ToneScale.Value = TalkService.ToneScale;
            ToneScale.Subscribe(x => TalkService.ToneScale = x);

            LoadSettingsCommand.Subscribe(LoadSettings);
            SaveSettingsCommand.Subscribe(SaveSettings);

            OpenCommand.Subscribe(Open);

            ToggleWatchCommand.Subscribe(ToggleWatch);
        }
Exemple #2
0
        public void Reset()
        {
            _defaultSetting = _settingFacade.GetDefaultSettings();

            PdfSetting = CreateNewPdfSetting(_defaultSetting.Pdfsetting);

            if (_workedTimeViewModel == null)
            {
                _workedTimeViewModel = new WorkedTimeSettingViewModel(_defaultSetting.Time, _defaultSetting.Time, _defaultSetting.TimeTickInMinutes);
                _workedTimeViewModel.OnTimeChanged += (object sender, WorkedTimeEventArgs args) =>
                {
                    CancelChangesCommand.RaiseCanExecuteChanged();
                    SaveSettingsCommand.RaiseCanExecuteChanged();
                };
                _workedTimeViewModel.OnTimeTickChanged += (object sender, EventArgs args) =>
                {
                    CancelChangesCommand.RaiseCanExecuteChanged();
                    SaveSettingsCommand.RaiseCanExecuteChanged();
                };
            }
            _workedTimeViewModel.SetTime(_defaultSetting.Time);
            _workedTimeViewModel.SelectedTimeTickInMinutes = _defaultSetting.TimeTickInMinutes;

            ImportDataResultMessage = null;
        }
        public SettingsWindow(ISettings settings, ISettingManager mananger, IPluginManager pluginManager, IDependencyInjector container, IEnvironment environment)
        {
            _settings                  = settings;
            _mananger                  = mananger;
            _pluginManager             = pluginManager;
            _container                 = container;
            _environment               = environment;
            _mananger.PropertyChanged += _mananger_PropertyChanged;

            SaveCommand   = new SaveSettingsCommand(_settings);
            CancelCommand = new CancelSettingsCommand(this, _settings);

            DataContext = this;
            InitializeComponent();

            SettingsTree.SelectedItemChanged += SettingsTree_SelectedItemChanged;

            foreach (var rootSetting in _pluginManager.BuiltInPlugins.Where(x => x.SettingEditWindow != null && !x.IsHidden()))
            {
                var builtinPlugin = new TreeViewItem
                {
                    Header     = rootSetting.Title,
                    IsSelected = SettingsTree.Items.IsEmpty,
                    Tag        = _container.Resolve(rootSetting.SettingEditWindow)
                };

                SettingsTree.Items.Add(builtinPlugin);
            }

            var pluginsTree = new TreeViewItem
            {
                Header = "Plugins",
                Tag    = _container.Resolve(typeof(PluginManagerSettingWindow))
            };

            foreach (var customSettings in _pluginManager.ActivePlugins.Where(x => x.SettingEditWindow != null))
            {
                pluginsTree.Items.Add(new TreeViewItem
                {
                    Header = customSettings.Title,
                    Tag    = _container.Resolve(customSettings.SettingEditWindow)
                });
            }

            SettingsTree.Items.Add(pluginsTree);

            var aboutPage = new TreeViewItem {
                Header = "About"
            };

            SettingsTree.Items.Add(aboutPage);

            UpdateNotificationMessage();

            Loaded           += Settings_Loaded;
            IsVisibleChanged += SettingsWindow_IsVisibleChanged;
        }
 protected async override void OnExecute(object parameter)
 {
     try
     {
         await SaveSettingsCommand.ExecuteAsync(this.shell);
     }
     catch (Exception e)
     {
         await AppMessageBox.ShowErrorAsync(e);
     }
 }
Exemple #5
0
        private DefaultListingPdfReportSetting CreateNewPdfSetting(DefaultListingPdfReportSetting oldSetting)
        {
            DefaultListingPdfReportSetting setting = new DefaultListingPdfReportSetting(oldSetting);

            setting.OnSettingPropertyChanged += (arg) => {
                CancelChangesCommand.RaiseCanExecuteChanged();
                SaveSettingsCommand.RaiseCanExecuteChanged();
            };

            return(setting);
        }
        public SettingsWindowViewModel(
            IDispatcherMessenger messenger,
            SaveSettingsCommand saveCommand,
            CloseWindowCommand cancelCommand)
        {
            if (messenger == null) throw new ArgumentNullException("messenger");
            if (saveCommand == null) throw new ArgumentNullException("saveCommand");
            if (cancelCommand == null) throw new ArgumentNullException("cancelCommand");
            SaveCommand = saveCommand;
            CloseCommand = cancelCommand;

            messenger.Register<ConfigSavedEvent>(this, _ => Close = true);
        }
Exemple #7
0
        public static async Task Run()
        {
            ViewResolver.Instance.ViewInit();
            MangaReader.Core.Client.OtherAppRunning  += ClientOnOtherAppRunning;
            MangaReader.Core.Client.ClientBeenClosed += ClientOnClientBeenClosed;
            MangaReader.Core.Client.ClientUpdated    += ClientOnClientUpdated;

            // Извлечение текущего списка часто используемых элементов
            var jumpList = new JumpList();

            JumpList.SetJumpList(App.Current, jumpList);

            // Добавление нового объекта JumpPath для файла в папке приложения
            var path = System.Reflection.Assembly.GetExecutingAssembly().Location;

            if (File.Exists(path))
            {
                JumpTask jumpTask = new JumpTask
                {
                    CustomCategory   = "Манга",
                    Title            = "Добавить мангу",
                    ApplicationPath  = path,
                    IconResourcePath = path,
                    Arguments        = AddManga
                };
                jumpList.JumpItems.Add(jumpTask);
            }

            // Обновление списка часто используемых элементов
            jumpList.Apply();

            var initialize = new Initialize();
            var args       = Environment.GetCommandLineArgs();

            if (args.Contains("-m") || args.Contains("/min") || ConfigStorage.Instance.AppConfig.StartMinimizedToTray)
            {
                await initialize.InitializeSilent().ConfigureAwait(true);

                WindowModel.Instance.InitializeSilent();
                SaveSettingsCommand.ValidateMangaPaths();
            }
            else
            {
                initialize.Show();
                WindowModel.Instance.Show();
            }
        }
Exemple #8
0
        private void SaveSettings()
        {
            _defaultSetting.Time = new TimeSetting(
                new Time(_workedTimeViewModel.StartTime),
                new Time(_workedTimeViewModel.EndTime),
                new Time(_workedTimeViewModel.LunchStart),
                new Time(_workedTimeViewModel.LunchEnd),
                new Time(_workedTimeViewModel.OtherHours)
                );
            _defaultSetting.TimeTickInMinutes = _workedTimeViewModel.SelectedTimeTickInMinutes;
            _defaultSetting.Pdfsetting.UpdateBy(_pdfSetting);

            _settingFacade.SaveDefaultSetting(_defaultSetting);

            CancelChangesCommand.RaiseCanExecuteChanged();
            SaveSettingsCommand.RaiseCanExecuteChanged();
        }
Exemple #9
0
 protected async override void OnExecute(object parameter)
 {
     try
     {
         if (this.shell.SettingsPath != string.Empty)
         {
             await this.shell.SaveSettingsAsync();
         }
         else
         {
             await SaveSettingsCommand.ExecuteAsync(this.shell);
         }
     }
     catch (Exception e)
     {
         await AppMessageBox.ShowErrorAsync(e);
     }
 }
Exemple #10
0
        private void SaveSettings()
        {
            _defaultSetting.Time = new TimeSetting(
                new Time(_workedTimeViewModel.StartTime),
                new Time(_workedTimeViewModel.EndTime),
                new Time(_workedTimeViewModel.LunchStart),
                new Time(_workedTimeViewModel.LunchEnd),
                new Time(_workedTimeViewModel.OtherHours)
                );
            _defaultSetting.TimeTickInMinutes = _workedTimeViewModel.SelectedTimeTickInMinutes;
            _defaultSetting.Pdfsetting        = new DefaultListingPdfReportSetting(PdfSetting);

            _settingFacade.UpdateDefaultSettings(_defaultSetting);

            CancelChangesCommand.RaiseCanExecuteChanged();
            SaveSettingsCommand.RaiseCanExecuteChanged();

            EventAggregator.PublishOnUIThread(new SettingsSuccessfullySavedMessage());
        }
Exemple #11
0
        public override void Show()
        {
            base.Show();
            var window = ViewService.Instance.TryGet <System.Windows.Window>(this);

            if (window != null)
            {
                window.ContentRendered += async(sender, args) =>
                {
                    try
                    {
                        await Core.Client.Start(this).ConfigureAwait(true);

                        SaveSettingsCommand.ValidateMangaPaths();
                    }
                    catch (Exception e)
                    {
                        Log.Exception(e, "Инициализация не закончилась.");
                    }
                };
                window.ShowDialog();
            }
        }
Exemple #12
0
        public void TestSaveSettings()
        {
            var notify = new Mock <IUserNotify>();

            var repoPipeSize        = new Mock <IMillPipeSizeTypeRepository>();
            var repoPipeTests       = new Mock <IPipeTestRepository>();
            var repoWelders         = new Mock <IWelderRepository>();
            var repoInspectors      = new Mock <IInspectorRepository>();
            var repoManufacturers   = new Mock <IPlateManufacturerRepository>();
            var repoProjectSetting  = new Mock <IProjectRepository>();
            var repoUsers           = new Mock <IUserRepository>();
            var repoRoles           = new Mock <IRoleRepository>();
            var repoPerms           = new Mock <IPermissionRepository>();
            var repoCategory        = new Mock <ICategoryRepository>();
            var repoJointOperation  = new Mock <IJointOperationRepository>();
            var repoCertificateType = new Mock <ICertificateTypeRepository>();
            var repoComponentType   = new Mock <IComponentTypeRepository>();
            var repoSeamType        = new Mock <ISeamTypeRepository>();

            var testProjectSetting = new Project()
            {
                IsNative = true
            };
            var testSizeType     = new PipeMillSizeType();
            var testWelder       = new Welder();
            var testManufacturer = new PlateManufacturer();
            var testInspector    = new Inspector();
            var testUser         = new User();
            var testRole         = new Role();
            var testPerm         = new Permission();
            var modifiableView   = new Mock <IModifiable>();
            var jointOperations  = new JointOperation();
            var ctx = new Mock <ISecurityContext>();

            repoPipeSize.Setup(_ => _.GetAll()).Returns(new List <PipeMillSizeType>()
            {
                testSizeType
            });
            repoWelders.Setup(_ => _.GetAll()).Returns(new List <Welder>()
            {
                testWelder
            });
            repoManufacturers.Setup(_ => _.GetAll()).Returns(new List <PlateManufacturer>()
            {
                testManufacturer
            });
            repoProjectSetting.Setup(_ => _.GetSingle()).Returns(testProjectSetting);
            repoInspectors.Setup(_ => _.GetAll()).Returns(new List <Inspector>()
            {
                testInspector
            });
            repoUsers.Setup(_ => _.GetAll()).Returns(new List <User>()
            {
                testUser
            });
            repoRoles.Setup(_ => _.GetAll()).Returns(new List <Role>()
            {
                testRole
            });
            repoPerms.Setup(_ => _.GetAll()).Returns(new List <Permission>()
            {
                testPerm
            });
            repoJointOperation.Setup(_ => _.GetAll()).Returns(new List <JointOperation>()
            {
                jointOperations
            });
            repoCategory.Setup(x => x.GetAll()).Returns(new List <Category>()
            {
                new Category()
            });
            repoCertificateType.Setup(x => x.GetAll()).Returns(new List <InspectorCertificateType>()
            {
                new InspectorCertificateType()
            });
            repoComponentType.Setup(x => x.GetAll()).Returns(new List <ComponentType>()
            {
                new ComponentType()
            });


            Mock <ISettingsRepositories> settingsRepos = new Mock <ISettingsRepositories>();

            settingsRepos.SetupGet(_ => _.PipeSizeTypeRepo).Returns(repoPipeSize.Object);
            settingsRepos.SetupGet(_ => _.PipeTestRepo).Returns(repoPipeTests.Object);
            settingsRepos.SetupGet(_ => _.WelderRepo).Returns(repoWelders.Object);
            settingsRepos.SetupGet(_ => _.PlateManufacturerRepo).Returns(repoManufacturers.Object);
            settingsRepos.SetupGet(_ => _.ProjectRepo).Returns(repoProjectSetting.Object);
            settingsRepos.SetupGet(_ => _.InspectorRepo).Returns(repoInspectors.Object);
            settingsRepos.SetupGet(_ => _.UserRepo).Returns(repoUsers.Object);
            settingsRepos.SetupGet(_ => _.RoleRepo).Returns(repoRoles.Object);
            settingsRepos.SetupGet(_ => _.PermissionRepo).Returns(repoPerms.Object);
            settingsRepos.SetupGet(_ => _.JointRepo).Returns(repoJointOperation.Object);
            settingsRepos.SetupGet(x => x.СategoryRepo).Returns(repoCategory.Object);
            settingsRepos.SetupGet(x => x.CertificateTypeRepo).Returns(repoCertificateType.Object);
            settingsRepos.SetupGet(x => x.ComponentTypeRepo).Returns(repoComponentType.Object);
            settingsRepos.SetupGet(x => x.SeamTypeRepo).Returns(repoSeamType.Object);

            var viewModel = new SettingsViewModel(settingsRepos.Object, notify.Object, ctx.Object);

            viewModel.ModifiableView = modifiableView.Object;
            viewModel.LoadData();
            viewModel.ModifiableView = modifiableView.Object;
            var validatable = new Mock <IValidatable>();

            validatable.Setup(x => x.Validate()).Returns(true);
            viewModel.validatableView = validatable.Object;

            var command = new SaveSettingsCommand(viewModel, settingsRepos.Object, notify.Object, ctx.Object);

            command.Execute();

            settingsRepos.Verify(_ => _.BeginTransaction(), Times.Once());
            repoPipeSize.Verify(_ => _.SaveOrUpdate(testSizeType), Times.Once());
            settingsRepos.Verify(_ => _.Commit(), Times.Once());
            repoPipeSize.Verify(_ => _.Evict(testSizeType), Times.Once());
            repoWelders.Verify(_ => _.SaveOrUpdate(testWelder), Times.Once());
            repoWelders.Verify(_ => _.Evict(testWelder), Times.Once());
            repoManufacturers.Verify(_ => _.SaveOrUpdate(testManufacturer), Times.Once());
            repoManufacturers.Verify(_ => _.Evict(testManufacturer), Times.Once());
            repoProjectSetting.Verify(_ => _.SaveOrUpdate(testProjectSetting), Times.Once());
            repoProjectSetting.Verify(_ => _.Evict(testProjectSetting), Times.Once());
            repoInspectors.Verify(_ => _.SaveOrUpdate(testInspector), Times.Once());
            repoInspectors.Verify(_ => _.Evict(testInspector), Times.Once());
            repoUsers.Verify(_ => _.SaveOrUpdate(testUser), Times.Once());
            repoUsers.Verify(_ => _.Evict(testUser), Times.Once());
            repoRoles.Verify(_ => _.SaveOrUpdate(testRole), Times.Once());
            repoRoles.Verify(_ => _.Evict(testRole), Times.Once());
        }
Exemple #13
0
 protected override bool OnCanExecute(object parameter)
 {
     return(SaveSettingsCommand.CanExecute(this.shell));
 }