Esempio n. 1
0
        public SettingsWindowViewModel(IClipboardRepository clipboardRepository, IAppSettingsService appSettingsService)
        {
            if (clipboardRepository == null)
            {
                throw new ArgumentNullException(nameof(clipboardRepository));
            }

            if (appSettingsService == null)
            {
                throw new ArgumentNullException(nameof(appSettingsService));
            }

            _clipboardRepository = clipboardRepository;
            _appSettingsService  = appSettingsService;

            HotKey = appSettingsService.HotKey;
            MaxSavedCopiesCount = appSettingsService.MaxSavedCopiesCount;

            RefreshDatabase();

            Submitted += (sender, e) =>
            {
                if (!_appSettingsService.HotKey.Equals(HotKey))
                {
                    _appSettingsService.HotKey = HotKey;

                    HotKeyChanged?.Invoke(this, HotKey);
                }

                _appSettingsService.MaxSavedCopiesCount = MaxSavedCopiesCount;
                _appSettingsService.Culture             = Thread.CurrentThread.CurrentCulture.Name;
                _appSettingsService.Save();
            };
        }
        public MainWindowViewModel(IClipboardRepository clipboardRepository, IAppSettingsService appSettingsService, IDialogService dialogService, SettingsWindowViewModel settingsViewModel)
        {
            if (clipboardRepository == null)
            {
                throw new ArgumentNullException(nameof(clipboardRepository));
            }

            if (appSettingsService == null)
            {
                throw new ArgumentNullException(nameof(appSettingsService));
            }

            if (dialogService == null)
            {
                throw new ArgumentNullException(nameof(dialogService));
            }

            if (settingsViewModel == null)
            {
                throw new ArgumentNullException(nameof(settingsViewModel));
            }

            _dialogService       = dialogService;
            _clipboardRepository = clipboardRepository;
            _appSettingsService  = appSettingsService;
            _settingsViewModel   = settingsViewModel;

            LaunchSettingsCommand = new RelayCommand(OnLaunchSettings);
            AddCommand            = new RelayCommand <ClipViewModel>(OnAdd);
            SelectCommand         = new RelayCommand <ClipViewModel>(OnSelect);
            DeleteCommand         = new RelayCommand <IList>(OnDelete);
        }
Esempio n. 3
0
        public App()
        {
            clipRepository = new ClipboardRespository("clips.db");

            InitializeComponent();

            InitApplication();
        }
Esempio n. 4
0
        public App()
        {
            clipRepository = new ClipboardRespository("clips.db");

            InitializeComponent();

            InitApplication();
        }
Esempio n. 5
0
        public MainWindowView()
        {
            // Hides the window at startup
            Visibility = Visibility.Hidden;

            // Events
            Loaded         += OnLoaded;
            Closed         += OnClosed;
            PreviewKeyDown += new KeyEventHandler(OnPreviewKeyDown);

            _applicationService = RepositoryDependencyResolver.Current.Resolve <IAppSettingsService>();
            _clipboardRepo      = RepositoryDependencyResolver.Current.Resolve <IClipboardRepository>();

            // if we have a hotkey saved, then register it
            var hotkey = Utils.ConvertStringToHotKey(_applicationService.HotKey);

            if (hotkey != null)
            {
                HotkeyManager.Current.AddOrReplace(Properties.Resources.GlobalHotKey, hotkey.Item1, hotkey.Item2, OnHotKey);
            }

            LocalizeDictionary.Instance.PropertyChanged += (sender, e) =>
            {
                // These are properties that are updated using the LocalizationProvider in the code-behind,
                // so they need to be updated when the culture is changed
                if (e.PropertyName.EndsWith(nameof(LocalizeDictionary.Culture)))
                {
                    var viewModel = (MainWindowViewModel)DataContext;

                    _exitMenuItem.Text      = LocalizationProvider.GetLocalizedValue <string>(nameof(Properties.Resources.Trayicon_ExitLabel));
                    _settingsMenuItem.Text  = LocalizationProvider.GetLocalizedValue <string>(nameof(Properties.Resources.Trayicon_SettingsLabel));
                    _compactDbMenuItem.Text = LocalizationProvider.GetLocalizedValue <string>(nameof(Properties.Resources.Trayicon_CompactDbLabel));

                    UpdateLocalizedToggleClipboardResource(viewModel);
                }
            };

            InitializeComponent();

            // Saves original values to later restore
            _height    = Height;
            _width     = Width;
            _glowBrush = GlowBrush;
        }