Ejemplo n.º 1
0
        private void toolStripAsMenuItemApplicationTopmost_Click(object sender,
                                                                 EventArgs e)
        {
            ArtPadForm artPad = (ArtPadForm)FindForm().FindForm();

            if (Tools.HForegroundWindow == IntPtr.Zero)
            {
                Utils.errMsg("The current foreground window is undefined");
                return;
            }
            if (artPad.Handle.Equals(Tools.HForegroundWindow))
            {
                Utils.errMsg("The current foreground window is ArtPad");
                return;
            }
            try {
                NativeMethods.SetWindowPos(Tools.HForegroundWindow,
                                           NativeMethods.HWND_TOPMOST, 0, 0, 0, 0,
                                           NativeMethods.SWP_NOMOVE | NativeMethods.SWP_NOSIZE |
                                           NativeMethods.SWP_SHOWWINDOW);
                Utils.infoMsg("Set window to be Topmost\n"
                              + String.Format("HWND=0x{0}\n",
                                              Tools.HForegroundWindow.ToString("X8"))
                              + "Title: " + Tools.getWindowTitle(Tools.HForegroundWindow));
            } catch (Exception ex) {
                Utils.excMsg("Failed to set foreground window to be topmost", ex);
                return;
            }
        }
Ejemplo n.º 2
0
        private void toolStripMenuItemSort_click(object sender, System.EventArgs e)
        {
            ArtPadForm    artPad = (ArtPadForm)FindForm().FindForm();
            Configuration config = artPad.Config;

            config.sort();
            artPad.reconfigure(config);
        }
Ejemplo n.º 3
0
        private void toolStripMenuItemAppearance_click(object sender, System.EventArgs e)
        {
            ArtPadForm       artPad = (ArtPadForm)FindForm().FindForm();
            Configuration    config = artPad.Config;
            AppearanceDialog dlg    = new AppearanceDialog();

            dlg.Text = "Appearance";
            dlg.LabelFontName.Text = "Font Name";
            dlg.LabelFontSize.Text = "Font Size (pt)";
            System.Drawing.Text.InstalledFontCollection installedFontCollection =
                new System.Drawing.Text.InstalledFontCollection();
            FontFamily[] fontFamilies  = installedFontCollection.Families;
            int          count         = fontFamilies.Length;
            int          selectedIndex = -1;
            string       name;

            for (int i = 0; i < count; i++)
            {
                name = fontFamilies[i].Name;
                dlg.ComboBoxFontName.Items.Add(name);
                if (name.Equals(config.FontName))
                {
                    selectedIndex = i;
                }
            }
            dlg.ComboBoxFontName.SelectedIndex = selectedIndex;

            dlg.CheckBoxBold.Checked      = config.FontFlags.Bold;
            dlg.CheckBoxItalic.Checked    = config.FontFlags.Italic;
            dlg.CheckBoxUnderline.Checked = config.FontFlags.Underline;
            dlg.CheckBoxStrikeout.Checked = config.FontFlags.Strikeout;

            dlg.NumericUpDownFontSize.DecimalPlaces = 1;
            dlg.NumericUpDownFontSize.Value         = (Decimal)config.FontSize;

            dlg.TextBoxFg.Text = config.FgColorString;
            dlg.TextBoxBg.Text = config.BgColorString;

            dlg.LabelWidth.Text           = "Key Width";
            dlg.LabelHeight.Text          = "Key Height";
            dlg.NumericUpDownWidth.Value  = Width;
            dlg.NumericUpDownHeight.Value = Height;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                config.FontName = dlg.ComboBoxFontName.Text;
                config.FontSize = (float)dlg.NumericUpDownFontSize.Value;
                config.setFontStyle(dlg.CheckBoxBold.Checked,
                                    dlg.CheckBoxItalic.Checked,
                                    dlg.CheckBoxUnderline.Checked,
                                    dlg.CheckBoxStrikeout.Checked);
                config.FgColorString = dlg.TextBoxFg.Text;
                config.BgColorString = dlg.TextBoxBg.Text;
                config.setSizeForKeySize((int)dlg.NumericUpDownWidth.Value,
                                         (int)dlg.NumericUpDownHeight.Value);
                artPad.reconfigure(config);
            }
        }
Ejemplo n.º 4
0
        private void toolStripMenuItemAddColAfter_click(object sender, System.EventArgs e)
        {
            ArtPadForm    artPad = (ArtPadForm)FindForm().FindForm();
            Configuration config = artPad.Config;

            config.insertColAfter(keyDef.Col);
            config.setSizeForKeySize(Width, Height);
            artPad.reconfigure(config);
        }
Ejemplo n.º 5
0
        private void toolStripMenuItemDeleteRow_click(object sender, System.EventArgs e)
        {
            ArtPadForm    artPad = (ArtPadForm)FindForm().FindForm();
            Configuration config = artPad.Config;

            config.deleteRow(keyDef.Row);
            config.setSizeForKeySize(Width, Height);
            artPad.reconfigure(config);
        }
Ejemplo n.º 6
0
 private void toolStripMenuItemHoldKeysUp_click(object sender, System.EventArgs e)
 {
     try {
         ArtPadForm    artPad = (ArtPadForm)FindForm().FindForm();
         Configuration config = artPad.Config;
         Tools.sendUpEventsForPressedKeys(config.KeyDefs);
         artPad.reconfigure(config);
     } catch (System.Exception ex) {
         Utils.excMsg("Error sending key up events", ex);
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Handles a NORMAL key
        /// </summary>
        /// <param name="e"></param>
        protected void handleNormalKey(System.EventArgs e)
        {
            ArtPadForm artPad = (ArtPadForm)FindForm().FindForm();

            if (!artPad.Handle.Equals(Tools.HForegroundWindow))
            {
                try {
                    SendKeys.Send(keyDef.KeyString);
                } catch (Exception ex) {
                    Utils.excMsg("Error invoking COMMAND for key "
                                 + keyDef.Name, ex);
                }
            }
        }
Ejemplo n.º 8
0
        void toolStripMenuItemLoad_Click(object sender, System.EventArgs e)
        {
            // Displays an OpenFileDialog so the user can select a
            // KeyConfiguration
            ArtPadForm     artPad = (ArtPadForm)FindForm().FindForm();
            OpenFileDialog dlg    = new OpenFileDialog();

            dlg.Filter = "Configuration Files|*.config";
            dlg.Title  = "Select a Configuration File";
            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                artPad.reconfigure(dlg.FileName);
            }
        }
Ejemplo n.º 9
0
 private void toolStripMenuItemOverview_click(object sender, System.EventArgs e)
 {
     // Create, show, or set visible the overviewDialog as appropriate
     if (overviewDlg == null)
     {
         ArtPadForm artPad = (ArtPadForm)FindForm().FindForm();
         overviewDlg = new ScrolledHTMLDialog(
             Utils.getDpiAdjustedSize(artPad, new Size(800, 600)));
         overviewDlg.Show();
     }
     else
     {
         overviewDlg.Visible = true;
     }
 }
Ejemplo n.º 10
0
        private void toolStripMenuItemEdit_Click(object sender, System.EventArgs e)
        {
            ArtPadForm artPad = (ArtPadForm)FindForm().FindForm();

            // Create, show, or set visible the EditKeyDialog as appropriate
            if (editKeyDlg == null)
            {
                editKeyDlg = new EditKeyDialog(keyDef, artPad);
                editKeyDlg.Show();
            }
            else
            {
                editKeyDlg.Visible = true;
                editKeyDlg.resetContents(keyDef, artPad);
            }
        }
Ejemplo n.º 11
0
        private void toolStripAsMenuItemSaveAs_Click(object sender, System.EventArgs e)
        {
            // Displays an OpenFileDialog so the user can select a
            // KeyConfiguration
            ArtPadForm artPad = (ArtPadForm)FindForm().FindForm();

            artPad.Config.setSizeForKeySize(Width, Height);
            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Filter = "Configuration Files|*.config";
            dlg.Title  = "Select a Configuration File";
            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Configuration.writeConfig(artPad.Config, dlg.FileName);
            }
        }
Ejemplo n.º 12
0
        private void toolStripMenuItemCreateNew_click(object sender, System.EventArgs e)
        {
            ArtPadForm          artPad = (ArtPadForm)FindForm().FindForm();
            NumericEntry2Dialog dlg    = new NumericEntry2Dialog();

            dlg.Text                 = "Contents";
            dlg.Label1.Text          = "Rows";
            dlg.Label2.Text          = "Columns";
            dlg.NumericUpDown1.Value = artPad.Config.Rows;
            dlg.NumericUpDown2.Value = artPad.Config.Cols;
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                Configuration config =
                    Configuration.generateNewConfiguration((int)dlg.NumericUpDown1.Value,
                                                           (int)dlg.NumericUpDown2.Value);
                config.setSizeForKeySize(Width, Height);
                artPad.reconfigure(config);
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Handles a HOLD key
        /// </summary>
        /// <param name="e"></param>
        protected void handleHoldKey(System.EventArgs e)
        {
            VirtualKeyCode keyCode;

            try {
                keyCode = Tools.getKeyCode(keyDef);
            } catch (System.ArgumentException) {
                Utils.errMsg("Cannot handle HOLD for " + keyDef.KeyString
                             + LF + "Must be ^ (Ctrl), % (Alt), or + (Shift)");
                return;
            }

            var sim = new InputSimulator();

            try {
                if (keyDef.Pressed)
                {
                    keyDef.Pressed = false;
                    sim.Keyboard.KeyUp(keyCode);
                    // Use this instead of
                    // BackColor = Color.FromKnownColor(KnownColor.Control);
                    ArtPadForm    artPad = (ArtPadForm)FindForm().FindForm();
                    Configuration config = artPad.Config;
                    if (config.isValidBGColorString())
                    {
                        BackColor = config.getBgColor();
                    }
                    else
                    {
                        UseVisualStyleBackColor = true;
                    }
                }
                else
                {
                    sim.Keyboard.KeyDown(keyCode);
                    keyDef.Pressed = true;
                    BackColor      = Color.FromKnownColor(KnownColor.Highlight);
                }
            } catch (Exception ex) {
                Utils.excMsg("Error invoking COMMAND for key "
                             + keyDef.Name, ex);
            }
        }
Ejemplo n.º 14
0
        private void toolStripAsMenuItemShowForegroundWin_Click(object sender,
                                                                EventArgs e)
        {
            ArtPadForm artPad = (ArtPadForm)FindForm().FindForm();

            try {
                Utils.infoMsg("ArtPad Window\n"
                              + String.Format("HWND=0x{0}\n", artPad.Handle.ToString("X8"))
                              + "Topmost=" + Tools.getWindowIsTopmost(artPad.Handle) + "\n"
                              + "Title: " + Tools.getWindowTitle(artPad.Handle)
                              + "\n\nForeground Window\n"
                              + String.Format("HWND=0x{0}\n",
                                              Tools.HForegroundWindow.ToString("X8"))
                              + "Topmost="
                              + Tools.getWindowIsTopmost(Tools.HForegroundWindow) + "\n"
                              + "Title: " + Tools.getWindowTitle(Tools.HForegroundWindow));
            } catch (Exception ex) {
                Utils.excMsg("Failed to show foreground window", ex);
                return;
            }
        }
Ejemplo n.º 15
0
        private void toolStripMenuItemPasteKey_click(object sender, System.EventArgs e)
        {
            IDataObject ClipData = Clipboard.GetDataObject();

            if (!ClipData.GetDataPresent(DataFormats.Text))
            {
                Utils.errMsg("Clipboard does not contain a key definition");
                return;
            }
            string json = Clipboard.GetData(DataFormats.Text).ToString();
            KeyDef newKeyDef;

            try {
                newKeyDef = JsonConvert.DeserializeObject <KeyDef>(json);
            } catch (Exception ex) {
                Utils.excMsg(
                    "Error converting clipboard contents to a "
                    + "key definition", ex);
                return;
            }
            ArtPadForm    artPad = (ArtPadForm)FindForm().FindForm();
            Configuration config = artPad.Config;

            newKeyDef.Row = keyDef.Row;
            newKeyDef.Col = keyDef.Col;
            int index = config.KeyDefs.FindIndex(
                keyDef =>
                keyDef.Row == newKeyDef.Row && keyDef.Col == newKeyDef.Col);

            if (index == -1)
            {
                Utils.errMsg("Error finding key definition to set");
                return;
            }
            config.setSizeForKeySize(Width, Height);
            config.KeyDefs[index] = newKeyDef;
            artPad.reconfigure(config);
        }
Ejemplo n.º 16
0
 public EditKeyDialog(KeyDef keyDef, ArtPadForm artPad)
 {
     InitializeComponent();
     resetContents(keyDef, artPad);
 }
Ejemplo n.º 17
0
 public void resetContents(KeyDef keyDef, ArtPadForm artPad)
 {
     keyDefOrig  = new KeyDef(keyDef);
     this.artPad = artPad;
     populateControls(keyDef);
 }
Ejemplo n.º 18
0
        private void toolStripMenuItemArtPadTopmost_click(object sender, EventArgs e)
        {
            ArtPadForm artPad = (ArtPadForm)FindForm().FindForm();

            artPad.TopMost = true;
        }