コード例 #1
0
        protected override void Execute()
        {
            settings.SourceDirectoryPath                  = viewModel.SourceDirectoryPath;
            settings.PreferedApplicationPath              = viewModel.PreferedApplication?.Path;
            settings.FileSearchMode                       = Converts.To <FileSearchMode, string>(viewModel.FileSearchMode);
            settings.FileSearchCount                      = viewModel.FileSearchCount;
            settings.IsFileSearchPatternSaved             = viewModel.IsFileSearchPatternSaved;
            settings.IsLastUsedApplicationSavedAsPrefered = viewModel.IsLastUsedApplicationSavedAsPrefered;
            settings.IsDismissedWhenLostFocus             = viewModel.IsDismissedWhenLostFocus;
            settings.IsHiddentOnStartup                   = viewModel.IsHiddentOnStartup;
            settings.IsAutoSelectApplicationVersion       = viewModel.IsAutoSelectApplicationVersion;
            settings.SetAutoSelectApplicationMinimalVersion(viewModel.AutoSelectApplicationMinimalVersion.Model);
            settings.IsFileNameRemovedFromDisplayedPath     = viewModel.IsFileNameRemovedFromDisplayedPath;
            settings.IsDisplayedPathTrimmedToLastFolderName = viewModel.IsDisplayedPathTrimmedToLastFolderName;
            settings.IsTrayIcon             = viewModel.IsTrayIcon;
            settings.IsStatisticsCounted    = viewModel.IsStatisticsCounted;
            settings.IsProjectCountEnabled  = viewModel.IsProjectCountEnabled;
            settings.AdditionalApplications = Converts
                                              .To <AdditionalApplicationCollection, string>(new AdditionalApplicationCollection(viewModel.AdditionalApplications.Select(a => a.Model)));

            if (viewModel.IsAutoStartup)
            {
                shortcutService.Create(Environment.SpecialFolder.Startup);
            }
            else
            {
                shortcutService.Delete(Environment.SpecialFolder.Startup);
            }

            string runKeyValue;

            if (Converts.Try(viewModel.RunKey, out runKeyValue))
            {
                settings.RunKey = runKeyValue;
            }

            if (viewModel.RunKey == null)
            {
                runHotKey.UnBind();
            }
            else
            {
                runHotKey.Bind(viewModel.RunKey.Key, viewModel.RunKey.Modifier);
            }

            settings.PositionMode = viewModel.PositionMode;
            settings.PositionLeft = viewModel.PositionLeft ?? 0;
            settings.PositionTop  = viewModel.PositionTop ?? 0;

            settings.HiddenMainApplications = String.Join(
                Path.PathSeparator.ToString(),
                viewModel.MainApplications.Where(a => !a.IsEnabled).Select(a => a.Path)
                );

            settings.ThemeMode = viewModel.ThemeMode;

            settings.Save();
            EventManager.RaiseConfigurationSaved(viewModel);
        }
コード例 #2
0
        public void Map(ConfigurationViewModel viewModel, ISettings settings)
        {
            settings.SourceDirectoryPath                    = viewModel.SourceDirectoryPath;
            settings.PreferedApplicationPath                = viewModel.PreferedApplication?.Path;
            settings.FileSearchMode                         = viewModel.FileSearchMode;
            settings.FileSearchCount                        = viewModel.FileSearchCount;
            settings.IsFileSearchPatternSaved               = viewModel.IsFileSearchPatternSaved;
            settings.IsLastUsedApplicationSavedAsPrefered   = viewModel.IsLastUsedApplicationSavedAsPrefered;
            settings.IsDismissedWhenLostFocus               = viewModel.IsDismissedWhenLostFocus;
            settings.IsHiddentOnStartup                     = viewModel.IsHiddentOnStartup;
            settings.IsAutoSelectApplicationVersion         = viewModel.IsAutoSelectApplicationVersion;
            settings.AutoSelectApplicationMinimalVersion    = viewModel.AutoSelectApplicationMinimalVersion.Model;
            settings.IsFileNameRemovedFromDisplayedPath     = viewModel.IsFileNameRemovedFromDisplayedPath;
            settings.IsDisplayedPathTrimmedToLastFolderName = viewModel.IsDisplayedPathTrimmedToLastFolderName;
            settings.IsTrayIcon             = viewModel.IsTrayIcon;
            settings.IsStatisticsCounted    = viewModel.IsStatisticsCounted;
            settings.IsProjectCountEnabled  = viewModel.IsProjectCountEnabled;
            settings.AdditionalApplications = new AdditionalApplicationCollection(viewModel.AdditionalApplications.Select(a => a.Model));

            if (viewModel.IsAutoStartup)
            {
                shortcutService.Create(Environment.SpecialFolder.Startup);
            }
            else
            {
                shortcutService.Delete(Environment.SpecialFolder.Startup);
            }

            string runKeyValue;

            if (Converts.Try(viewModel.RunKey, out runKeyValue))
            {
                settings.RunKey = runKeyValue;
            }

            if (viewModel.RunKey == null)
            {
                runHotKey.UnBind();
            }
            else
            {
                runHotKey.Bind(viewModel.RunKey.Key, viewModel.RunKey.Modifier);
            }

            settings.PositionMode = viewModel.PositionMode;
            settings.PositionLeft = viewModel.PositionLeft ?? 0;
            settings.PositionTop  = viewModel.PositionTop ?? 0;

            settings.HiddenMainApplications = viewModel.MainApplications.Where(a => !a.IsEnabled).Select(a => a.Path).ToArray();

            settings.ThemeMode = viewModel.ThemeMode;
            settings.LogLevel  = viewModel.LogLevel;
        }