private void toolStripMenuItemSort_click(object sender, System.EventArgs e) { ArtPadForm artPad = (ArtPadForm)FindForm().FindForm(); Configuration config = artPad.Config; config.sort(); artPad.reconfigure(config); }
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); } }
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); }
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); }
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); } }
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); } }
private void setKeyButton_click(object sender, MouseEventArgs e) { KeyDef newKeyDef = keyDefFromDialog(); Configuration config = artPad.Config; 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.KeyDefs[index] = newKeyDef; keyDefOrig = newKeyDef; artPad.reconfigure(config); }
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); } }
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); }