Example #1
0
        public GlobalSearchTextBox()
        {
            _invSearch = DelayedCombiningInvoker.CreateHighspeed(() => Application.Current.Dispatcher.BeginInvoke(new Action(ApplyInternalSearchText)), 500, 60_000);

            InitializeComponent();
            LayoutRoot.DataContext = this;
        }
Example #2
0
        private ScrollCache(string fp)
        {
            _cache    = new Dictionary <string, Tuple <int, int?> >();
            _filepath = fp;

            invSave = DelayedCombiningInvoker.Create(SaveDirect, 15 * 1000, 2 * 60 * 1000);
        }
Example #3
0
        private HierarchyConfigCache(string fp, string xml)
        {
            _filepath = fp;
            _xml      = xml;

            invSave = DelayedCombiningInvoker.Create(SaveDirect, 15 * 1000, 2 * 60 * 1000);
        }
Example #4
0
        public MainWindowViewmodel(AppSettings settings, MainWindow parent)
        {
            Owner = parent;

            _settings        = settings;
            _invSaveSettings = DelayedCombiningInvoker.Create(() => Application.Current.Dispatcher.BeginInvoke(new Action(SaveSettings)), 8 * 1000, 60 * 1000);

            _repository = new NoteRepository(AppSettings.PATH_LOCALDB, this, settings, settings.ActiveAccount, dispatcher);
            Repository.Init();

            _scrollCache = Settings.RememberScroll ? ScrollCache.LoadFromFile(AppSettings.PATH_SCROLLCACHE) : ScrollCache.CreateEmpty(AppSettings.PATH_SCROLLCACHE);

            Owner.TrayIcon.Visibility = (Settings.CloseToTray || Settings.MinimizeToTray) ? Visibility.Visible : Visibility.Collapsed;


            var initialNote   = _settings.LastSelectedNote;
            var initialFolder = _settings.LastSelectedFolder;

            if (initialNote != null && _settings.RememberLastSelectedNote)
            {
                if (initialFolder != null)
                {
                    SelectedFolderPath = initialFolder;
                }
                SelectedNote = Repository.Notes.FirstOrDefault(n => n.UniqueName == initialNote);
            }
            if (SelectedNote == null)
            {
                SelectedNote = Repository.Notes.FirstOrDefault();
            }


            OverviewListWidth = new GridLength(settings.OverviewListWidth);

            if (settings.CheckForUpdates)
            {
                var t = new Thread(CheckForUpdatesAsync)
                {
                    Name = "UPDATE_CHECK"
                };
                t.Start();
            }

#if !DEBUG
            if (settings.SendAnonStatistics)
            {
                var t = new Thread(UploadUsageStatsAsync)
                {
                    Name = "STATISTICS_UPLOAD"
                };
                t.Start();
            }
#endif

            MenuIsVisible = !_settings.AutoHideMainMenu;

            SettingsChanged();

            ThemeManager.Inst.RegisterSlave(this);
        }
        public RawFolderRepository(NoteRepository r, IAlephDispatcher disp, AppSettings s)
        {
            _repo           = r;
            _dispatcher     = disp;
            _invSyncRequest = DelayedCombiningInvoker.Create(() => disp.BeginInvoke(SyncNow), 5 * 1000, 30 * 1000);

            _enabled = s.UseRawFolderRepo;
            _path    = s.RawFolderRepoPath;

            _filewatcherEnabled = s.RawFolderRepoUseFileWatcher;
            _encoding           = EncodingEnumHelper.ToEncoding(s.RawFolderRepoEncoding);
            _searchDepth        = s.RawFolderRepoMaxDirectoryDepth;

            _syncModifications = s.RawFolderRepoAllowModification;
            _syncCreation      = s.RawFolderRepoAllowCreation;
            _syncDeletion      = s.RawFolderRepoAllowDeletion;
        }
Example #6
0
        public NoteRepository(string path, ISynchronizationFeedback fb, AppSettings cfg, RemoteStorageAccount acc, IAlephDispatcher disp)
        {
            _pathLocalBase   = path;
            _pathLocalFolder = Path.Combine(path, acc.ID.ToString("B"));
            _pathLocalData   = Path.Combine(path, acc.ID.ToString("B") + ".xml");
            _conn            = acc.Plugin.CreateRemoteStorageConnection(cfg.CreateProxy(), acc.Config, cfg.GetHierachicalConfig());
            _account         = acc;
            _appconfig       = cfg;
            _listener        = fb;
            _dispatcher      = disp;
            _thread          = new SynchronizationThread(this, new[] { this, fb }, cfg, _dispatcher);

            _invSaveNotesLocal     = DelayedCombiningInvoker.Create(() => _dispatcher.BeginInvoke(SaveAllDirtyNotes), 10 * 1000, 1 * 60 * 1000);
            _invSaveNotesRemote    = DelayedCombiningInvoker.Create(() => _dispatcher.BeginInvoke(SyncNow), 45 * 1000, 15 * 60 * 1000);
            _invSaveNotesGitBackup = DelayedCombiningInvoker.Create(() => _dispatcher.BeginInvoke(CommitToLocalGitBackup), 10 * 1000, 15 * 60 * 1000);

            _rawFilesystemRepo = new RawFolderRepository(this, disp, cfg);

            _notes.CollectionChanged += NoteCollectionChanged;
        }