Пример #1
0
        public MainForm(IFormOpener formManager, IMainFormPresenter presenter, MainFormStyler mainFormStyler, IPubSub pubsub, IPropertiesRepository propertiesRepository)
        {
            InitializeComponent();

            _mainFormStyler = mainFormStyler;
            _pubsub         = pubsub;
            RenderTheme();
            if (propertiesRepository.GetValue <bool>(Constants.AppProperties.UpdateSettings))
            {
                propertiesRepository.Upgrade();
                propertiesRepository.SetValue(Constants.AppProperties.UpdateSettings, false);
                propertiesRepository.Save();
            }

            _formManager = formManager;
            presenter.InitializePresenter(new
            {
                MainForm = this,
                PubSub   = _pubsub
            });

            var selectedPath = propertiesRepository.GetValue <string>(Constants.AppProperties.SelectedPath);

            if (!string.IsNullOrEmpty(selectedPath))
            {
                Presenter.PopulateTreeView(selectedPath);
            }

            _propertiesRepository = propertiesRepository;
        }
Пример #2
0
 private void openFolderToolStripMenuItem_Click(object sender, System.EventArgs e)
 {
     if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
     {
         queryTabControl.TabPages.Clear();
         Presenter.PopulateTreeView(folderBrowserDialog1.SelectedPath);
         _propertiesRepository.SetValue(Constants.AppProperties.SelectedPath, folderBrowserDialog1.SelectedPath);
         _propertiesRepository.Save();
     }
 }
        public void SavePreferences(AppPreferences preferences)
        {
            if (!_propertiesRepository.GetValue <string>(Constants.AppProperties.TransactionCachePath).Equals(preferences.TransactionCacheLocation, System.StringComparison.InvariantCultureIgnoreCase))
            {
                _propertiesRepository.SetValue(Constants.AppProperties.TransactionCachePath, preferences.TransactionCacheLocation);
                _propertiesRepository.Save();
                _mainFormPresenter.InitializeTransactionCache();
            }

            if (_propertiesRepository.GetValue <bool>(Constants.AppProperties.UseDarkTheme) != preferences.UseDarkTheme)
            {
                _propertiesRepository.SetValue(Constants.AppProperties.UseDarkTheme, preferences.UseDarkTheme);
                _propertiesRepository.Save();
                _pubsub.Publish(this, new PubSubEventArgs {
                    Data = preferences.UseDarkTheme
                }, Constants.SubscriptionTypes.THEME_CHANGE);
                _view.RenderTheme();
            }
        }