Beispiel #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            this.Text = Properties.Resources.softwareName;
            foreach (var pair in _bh.BibTexFields)
            {
                if (pair.Key == "type")
                {
                    var colcombo = new DataGridViewComboBoxColumn();
                    colcombo.HeaderText = pair.Value; colcombo.Name = pair.Key;
                    foreach (var item in Properties.Resources.types.Split(';'))
                    {
                        colcombo.Items.Add(item);
                    }
                    colcombo.DisplayStyle = DataGridViewComboBoxDisplayStyle.DropDownButton;
                    dgv.Columns.Add(colcombo);
                }
                else
                {
                    dgv.Columns.Add(pair.Key, pair.Value);
                }
            }

            if (System.IO.File.Exists(Properties.Settings.Default.RecentLib))
            {
                _sh = new SqliteHelper(Properties.Settings.Default.RecentLib);
                refreshRows();
            }

            if (Program.args.Length > 0)
            {
                if (System.IO.File.Exists(Program.args[0]))
                {
                    if (Program.args[0].EndsWith(".bdb"))
                    {
                        _sh = new SqliteHelper(Program.args[0]); refreshRows();
                    }
                    else
                    {
                        _bh.ParseFile(Program.args[0]);
                    }
                }
            }

            // Hotkey
            W32ApiHelper.Regist(this.Handle, 0, Keys.F10, new W32ApiHelper.HotKeyCallBackHanlder(() =>
            {
                try
                {
                    if (this.Handle == W32ApiHelper.GetForegroundWindow())
                    {
                        addBibTexCodeToolStripMenuItem_Click(null, null); return;
                    }
                    string str = Clipboard.GetText().ToString();
                    if (string.IsNullOrEmpty(str))
                    {
                        return;
                    }
                    if (str[0] == '@' || str[0] == '%')
                    {
                        importRecords(str);
                        W32ApiHelper.SetForegroundWindow(this.Handle);
                    }
                    else
                    {
                        SendKeys.SendWait("^c");
                        System.Threading.Thread.Sleep(750);
                        str = Clipboard.GetText().ToString();
                        if (str[0] == '@' || str[0] == '%')
                        {
                            importRecords(str);
                            W32ApiHelper.SetForegroundWindow(this.Handle);
                        }
                        else
                        {
                            System.Diagnostics.Process.Start(string.Format(Properties.Settings.Default.DefaultSearchEngine, str));
                        }
                    }
                }
                catch (Exception) { }
            }));
        }
Beispiel #2
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     W32ApiHelper.UnregisterHotKey(this.Handle);
 }
Beispiel #3
0
 protected override void WndProc(ref Message m)
 {
     base.WndProc(ref m);
     W32ApiHelper.ProcessHotKey(m);
 }