示例#1
0
        //non affecting appearance inits
        private void Form1_Shown(object sender, EventArgs e)
        {
            this.WindowState = (FormWindowState)FormWindowState.Parse(this.WindowState.GetType(), ini.GetValue("Form", "WindowState", "Normal"));
              this.Form1_Resize(this, null); //trigger tray icon
              if (this.WindowState == FormWindowState.Normal && !ini.defaults) {
            this.Top = Int32.Parse(ini.GetValue("Form", "Top", "100"));
            this.Left = Int32.Parse(ini.GetValue("Form", "Left", "100"));
            this.Width = Int32.Parse(ini.GetValue("Form", "Width", "500"));
            this.Height = Int32.Parse(ini.GetValue("Form", "Height", "400"));
              }

              ui = TaskScheduler.FromCurrentSynchronizationContext();
              //delay inits after form drawn
              Task.Factory.StartNew(() => {
            // read sync acc
            using (SQLiteCommand cmd = new SQLiteCommand("SELECT value FROM config WHERE name='email'", sql)) {
              var res = cmd.ExecuteScalar();
              if (res != null) Sync.Email = (string)res;
              cmd.CommandText = "SELECT value FROM config WHERE name='password'";
              res = cmd.ExecuteScalar();
              if (res != null) Sync.Password = (string)res;
              cmd.CommandText = "SELECT value FROM config WHERE name='freq'";
              res = cmd.ExecuteScalar();
              if (res != null) Sync.Freq = int.Parse((string)res);
              cmd.CommandText = "SELECT value FROM config WHERE name='lastSync'";
              res = cmd.ExecuteScalar();
              if (res != null) Sync.LastSync = int.Parse((string)res);
            }
            //init auto-sync timer
            if (syncTimer == null) {
              syncTimer = new System.Timers.Timer();
              syncTimer.Elapsed += timer_sync;
            }
            if (Sync.Freq != 0) {
              syncTimer.Interval = Sync.Freq * 60 * 1000;
              syncTimer.Start();
              SnSync(0); // start full sync on start
            }
              }).ContinueWith(t => {
            // send mouse wheel event to control under cursor
            Application.AddMessageFilter(new MouseWheelMessageFilter());

            // hotkeys
            hook = new KeyHook();
            hook.KeyPressed += new EventHandler<KeyPressedEventArgs>(HotkeyPressed);
            hook.SetHotkey(1, ini.GetValue("Keys", "HotkeyShow", ""));
            string s = ini.GetValue("Keys", "HotkeySearch", "Win+`");
            tbSearch.AccessibleDescription = "Search Notes (" + s + ")"; //used for placeholder in search bar
            hook.SetHotkey(2, s);
            ToolTip tt = new ToolTip();
            tt.SetToolTip(tbFind, "Enter/F3: FindNext, Shift-F3: FindPrevious");
            panelFind.Height = tbFind.Height + 3;
              }, ui);
        }
示例#2
0
文件: Form.cs 项目: fureya/SynNotes
        //non affecting appearance inits
        private void Form1_Shown(object sender, EventArgs e)
        {
            ui = TaskScheduler.FromCurrentSynchronizationContext();
              //delay inits after form drawn
              Task.Factory.StartNew(() => {
            // read sync acc
            using (SQLiteCommand cmd = new SQLiteCommand("SELECT value FROM config WHERE name='email'", sql)) {
              var res = cmd.ExecuteScalar();
              if (res != null) Sync.Email = (string)res;
              cmd.CommandText = "SELECT value FROM config WHERE name='password'";
              res = cmd.ExecuteScalar();
              if (res != null) Sync.Password = (string)res;
              cmd.CommandText = "SELECT value FROM config WHERE name='freq'";
              res = cmd.ExecuteScalar();
              if (res != null) Sync.Freq = int.Parse((string)res);
              cmd.CommandText = "SELECT value FROM config WHERE name='lastSync'";
              res = cmd.ExecuteScalar();
              if (res != null) Sync.LastSync = int.Parse((string)res);
            }
            //init auto-sync timer
            if (syncTimer == null) {
              syncTimer = new System.Timers.Timer();
              syncTimer.Elapsed += timer_sync;
            }
            if (Sync.Freq != 0) {
              syncTimer.Interval = Sync.Freq * 60 * 1000;
              syncTimer.Start();
              SnSync(0); // start full sync on start
            }
              }).ContinueWith(t => {
            // send mouse wheel event to control under cursor
            Application.AddMessageFilter(new MouseWheelMessageFilter());

            // hotkeys
            hook = new KeyHook();
            hook.KeyPressed += new EventHandler<KeyPressedEventArgs>(HotkeyPressed);
            hook.SetHotkey(1, ini.GetValue("Keys", "HotkeyShow", ""));
            string s = ini.GetValue("Keys", "HotkeySearch", "Win+`");
            tbSearch.AccessibleDescription = "Search Notes (" + s + ")"; //used for placeholder in search bar
            hook.SetHotkey(2, s);
              }, ui);
        }