public static void EditeMacro(CMacro macro) { CFormEditionMacro form = new CFormEditionMacro(); form.m_panelMacro.Init(macro); form.ShowDialog(); }
public bool CopyFrom(CMacro src) { //this.MacroNumber = src.MacroNumber; // NEVER COPY THIS if (this.m_Line == null) { this.m_Line = new String[6]; } if (src == null) { this.m_Name = String.Empty; this.m_Line[0] = String.Empty; this.m_Line[1] = String.Empty; this.m_Line[2] = String.Empty; this.m_Line[3] = String.Empty; this.m_Line[4] = String.Empty; this.m_Line[5] = String.Empty; } else { this.m_Name = (src.Name == null) ? String.Empty : src.Name; // this is some of the major processing on file copies // remove once you have added a notification screen.... if (src._thisNode != null) { if (this._thisNode == null) { this._thisNode = new TreeNode(src._thisNode.Text); } else { this._thisNode.Text = src._thisNode.Text; } } //this._thisNode = src._thisNode; // NEVER COPY THIS if (src.Line != null) { this.m_Line[0] = src.Line[0]; this.m_Line[1] = src.Line[1]; this.m_Line[2] = src.Line[2]; this.m_Line[3] = src.Line[3]; this.m_Line[4] = src.Line[4]; this.m_Line[5] = src.Line[5]; } else { this.m_Line[0] = String.Empty; this.m_Line[1] = String.Empty; this.m_Line[2] = String.Empty; this.m_Line[3] = String.Empty; this.m_Line[4] = String.Empty; this.m_Line[5] = String.Empty; } } return(true); }
public void RegistReregister() { foreach (int index in HotKeys) { CMacro c = k_model.macros[index]; WinLib.RegisterHotKey((int)this.Handle, index, c.regist.modify, (int)c.regist.key); } }
public void Init(CMacro macro) { m_macro = macro; m_txtNomMacro.Text = m_macro.Libelle; FillArbre(); RefillListeVariables(); m_panelFormulaire.Init(typeof(CMacro), m_macro, m_macro.Formulaire, m_macro); }
public override string ToString() { if (this.Name == String.Empty) { return(CMacro.DisplayName(this.MacroNumber)); } return(this.Name); // return base.ToString(); }
/// <summary> /// Provides the name or default string for "this" Macro. /// </summary> /// <returns>Formatted string containing either the name or a default name.</returns> public string DisplayName() { if (this.Name == String.Empty) { return(CMacro.DisplayName(this.m_MacroNumber)); } return(this.Name); }
public KeyOption(object cm, MacpMain form) { InitializeComponent(); this.Location = new Point(form.Location.X + form.Width - 15, form.Location.Y); Ectr = EventController.GetInstance(); this.cm = cm as CMacro; this.main = form; init(); }
private void m_lnkEdit_LinkClicked(object sender, EventArgs e) { if (m_wndListeMacros.SelectedItems.Count == 1) { ListViewItem item = m_wndListeMacros.SelectedItems[0]; CMacro macro = item.Tag as CMacro; if (macro != null) { CFormEditionMacro.EditeMacro(macro); FillListe(); } } }
/// <summary> /// Provides the name of a Macro or default string if none found. /// </summary> /// <param name="cm">Macro file to get the displayable name for.</param> /// <returns>Formatted string containing either the name or a default name.</returns> public string DisplayName(CMacro cm) { if (cm == null) { return("<ERROR>"); } if (cm.Name == String.Empty) { return(CMacro.DisplayName(cm.MacroNumber)); } return(cm.Name); }
public Keyboard(object obj, bool mulSel, KeyOption kopt) { InitializeComponent(); lKey = obj as CMacro; Ectr = EventController.GetInstance(); this.kopt = kopt; this.mulSel = mulSel; init(); OnLoad(); }
private void AddMacro(object sender, EventArgs e) { CMacro cm = new CMacro(""); MaCrt cf = new MaCrt(cm, this); if (cf.ShowDialog() != DialogResult.OK) { return; } k_model.macros.Add(cm); AMD.AddMacro(cm); }
private void m_lnkRemove_LinkClicked(object sender, EventArgs e) { if (m_wndListeMacros.SelectedItems.Count == 1) { CMacro macro = m_wndListeMacros.SelectedItems[0].Tag as CMacro; if (macro != null && MessageBox.Show(I.T("#Supprimer la macro @1?", macro.Libelle), "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { CListeMacros.RemoveMacro(macro); FillListe(); } } }
private void OnEntry(object sender, DataGridViewCellEventArgs e) { int index = e.RowIndex; CMacro c = k_model.macros[index]; if (((ToggleButtonCell)((DataGridViewRow)sender).Cells[0]).toggle) { WinLib.RegisterHotKey((int)this.Handle, e.RowIndex, c.regist.modify, (int)c.regist.key); HotKeys.Add(e.RowIndex); } else { WinLib.UnregisterHotKey((int)this.Handle, e.RowIndex); HotKeys.Remove(e.RowIndex); } }
private void m_btnLoad_Click(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "#Macro|*.FutMacro|All files|*.*"; if (dlg.ShowDialog() == DialogResult.OK) { CMacro macro = new CMacro(); macro.ContexteDonnee = CSc2iWin32DataClient.ContexteCourant; CResultAErreur result = CSerializerObjetInFile.ReadFromFile(macro, "MACRO", dlg.FileName); if (!result) { CFormAlerte.Afficher(result.Erreur); } else { Init(macro); } } }
public bool Swap(ref CMacroFile src) { CMacro tmp = new CMacro(); String text = String.Empty; if ((this.Macros != null) && (src.Macros != null)) { for (int i = 0; i < this.Macros.Length; i++) { this.Macros[i].Swap(ref src.Macros[i]); } } uint version = src.version; src.version = this.version; this.version = version; this.Changed = true; src.Changed = true; return(true); }
public bool Swap(ref CMacro src) { CMacro tmp = new CMacro(); //this.MacroNumber = src.MacroNumber; // NEVER COPY THIS if (this.m_Line == null) { this.m_Line = new String[6]; } if (src == null) { this.m_Name = String.Empty; this.m_Line[0] = String.Empty; this.m_Line[1] = String.Empty; this.m_Line[2] = String.Empty; this.m_Line[3] = String.Empty; this.m_Line[4] = String.Empty; this.m_Line[5] = String.Empty; } else { tmp.Name = this.m_Name; this.m_Name = src.Name; src.Name = tmp.Name; if (src._thisNode != null) { if (this._thisNode != null) { String text = src._thisNode.Text; src._thisNode.Text = this._thisNode.Text; this._thisNode.Text = text; } } tmp.Line = this.Line; this.Line = src.Line; src.Line = tmp.Line; } return(true); }
private int GetMacroKey(KeyValuePair <Keys, int> key) { foreach (DataGridViewRow row in MacroViewer.Rows) { var cell = row.Cells[0] as ToggleButtonCell; if (!cell.toggle) { continue; } int index = row.Index; CMacro c = k_model.macros[index]; if (key.Key == c.regist.key && key.Value == c.regist.modify) { return(index); } } return(-1); }
void item_Click(object sender, EventArgs e) { ToolStripMenuItem item = sender as ToolStripMenuItem; CVersionDonnees version = item != null ? item.Tag as CVersionDonnees : null; if (version != null) { CResultAErreurType <CMacro> res = CMacro.FromVersion(version); bool bAdd = res; if (!res) { if (CFormAlerte.Afficher(res.Erreur) == DialogResult.Ignore) { bAdd = true; } } if (bAdd) { CListeMacros.AddMacro(res.DataType); FillListe(); } } }
/// <summary> /// Provides the name of a Macro or default string if none found. /// </summary> /// <param name="cm">Macro file to get the displayable name for.</param> /// <returns>Formatted string containing either the name or a default name.</returns> public string DisplayName(CMacro cm) { if (cm == null) return "<ERROR>"; if (cm.Name == String.Empty) return CMacro.DisplayName(cm.MacroNumber); return cm.Name; }
public bool CopyFrom(CMacro src) { //this.MacroNumber = src.MacroNumber; // NEVER COPY THIS if (this.m_Line == null) this.m_Line = new String[6]; if (src == null) { this.m_Name = String.Empty; this.m_Line[0] = String.Empty; this.m_Line[1] = String.Empty; this.m_Line[2] = String.Empty; this.m_Line[3] = String.Empty; this.m_Line[4] = String.Empty; this.m_Line[5] = String.Empty; } else { this.m_Name = (src.Name == null) ? String.Empty : src.Name; // this is some of the major processing on file copies // remove once you have added a notification screen.... if (src._thisNode != null) { if (this._thisNode == null) this._thisNode = new TreeNode(src._thisNode.Text); else this._thisNode.Text = src._thisNode.Text; } //this._thisNode = src._thisNode; // NEVER COPY THIS if (src.Line != null) { this.m_Line[0] = src.Line[0]; this.m_Line[1] = src.Line[1]; this.m_Line[2] = src.Line[2]; this.m_Line[3] = src.Line[3]; this.m_Line[4] = src.Line[4]; this.m_Line[5] = src.Line[5]; } else { this.m_Line[0] = String.Empty; this.m_Line[1] = String.Empty; this.m_Line[2] = String.Empty; this.m_Line[3] = String.Empty; this.m_Line[4] = String.Empty; this.m_Line[5] = String.Empty; } } return true; }
private void BuildMacroNode(ref CMacro cm, TreeNode parent) { string cmName = cm.DisplayName(); cm.thisNode = parent.Nodes.Add(CMacro.DisplayName(cm.MacroNumber) + "<" + cmName + ">", cmName, "Macro", "EditMacro"); TagInfo xTag = new TagInfo("macro"); cm.thisNode.Tag = xTag; }
private bool Swap(ref CMacro cm_drop, ref CMacro cm_drag) { if ((cm_drop == null) || (cm_drag == null)) return false; CMacro tmp = new CMacro(); tmp.CopyFrom(cm_drop); cm_drop.CopyFrom(cm_drag); cm_drag.CopyFrom(tmp); CMacroFile cmf_drop = FindMacroFileByNode(cm_drop.thisNode), cmf_drag = FindMacroFileByNode(cm_drag.thisNode); if (cmf_drop != null) { cmf_drop.Changed = true; } if (cmf_drag != null) { cmf_drag.Changed = true; } return true; }
private void Modify(ref CMacro cm_drag, ref CMacro cm_drop, DragEventArgs e) { if (cm_drag == cm_drop) // No effect, but just in case return; #region Swap/Copy Drag & Drop Macros and update if ((cm_drag != null) && (cm_drop != null)) { LogMessage.Log("..DragDrop START:{0} Macro src:{1} dest:{2}", e.Effect, cm_drag.Name, cm_drop.Name); if (e.Effect == DragDropEffects.Link) { if (Swap(ref cm_drop, ref cm_drag)) { // if Swap is successful // update node names cm_drag.thisNode.Text = cm_drag.DisplayName(); cm_drop.thisNode.Text = cm_drop.DisplayName(); } } else if (e.Effect == DragDropEffects.Copy) { if (cm_drop.CopyFrom(cm_drag)) { // if Copy is successful // Update node name // and set Changed true on the Drops macrofile (not handled by copy) cm_drop.thisNode.Text = cm_drop.DisplayName(); CMacroFile cmf_drop = FindMacroFileByNode(cm_drop.thisNode); if (cmf_drop != null) cmf_drop.Changed = true; } } LogMessage.Log("..DragDrop END:{0} Macro src:{1} dest:{2}", e.Effect, cm_drag.Name, cm_drop.Name); } else LogMessage.Log("....Modify(): Swap Macro, one of the two is null"); #endregion }
private void FillForm(CMacro cm) { this.SuspendLayout(); if (cm == null) { //Log("FillForm(CMacro): parameter cm = null, error"); DisableTextBoxes(); ChangeButtonNames((CMacroFile)null); this.ResumeLayout(); return; } /* for (int i = 0; i < 20; i++) if (radiobuttons[i].Checked == true) { if (cm.MacroNumber != i) { radiobuttons[i].Checked = false; } break; } */ for (int i = 0; i < buttons.Length; i++) { if (buttons[i].Enabled == false) { if (cm.MacroNumber != i) { buttons[i].Enabled = true; } break; } } /* if (radiobuttons[cm.MacroNumber].Checked == false) radiobuttons[cm.MacroNumber].Checked = true; */ if (buttons[cm.MacroNumber].Enabled == true) buttons[cm.MacroNumber].Enabled = false; this.labelCurrentEditing.Text = String.Format("Currently Editing Macro Set ~~ {0}{1} : Name : <{2}>", (cm.MacroNumber < 10) ? "Ctrl-" : "Alt-", (cm.MacroNumber + 1) % 10, (cm.Name.Trim() == String.Empty) ? "<Empty>" : cm.Name); SuppressNodeUpdates = true; textBoxName.Text = cm.Name; textBoxLine1.Text = cm.Line[0]; textBoxLine2.Text = cm.Line[1]; textBoxLine3.Text = cm.Line[2]; textBoxLine4.Text = cm.Line[3]; textBoxLine5.Text = cm.Line[4]; textBoxLine6.Text = cm.Line[5]; SuppressNodeUpdates = false; // genius, finding the macro file by the macro's node ChangeButtonNames(FindMacroFileByNode(cm.thisNode)); EnableTextBoxes(); this.ResumeLayout(); }
/* * DisplayName(CMacro): Provides a displayable string given a CMacro */ private string DisplayName(CMacro cm) { if (cm == null) return DisplayName(-1); if (cm.Name == String.Empty) return DisplayName(cm.MacroNumber); return cm.Name; }
/// <summary> /// Saves the given Macro to memory with very little error checking. /// </summary> /// <param name="cm">Macro to save to memory.</param> private void SaveToMemory(CMacro cm) { if (cm == null) { LogMessage.Log("SaveToMemory(CMacro): cm == null, error"); return; } if (cm.Line == null) { LogMessage.Log("SaveToMemory(CMacro): cm.Line == null, error"); return; } if ((textBoxName.Enabled == false) || (textBoxLine1.Enabled == false) || (textBoxLine2.Enabled == false) || (textBoxLine3.Enabled == false) || (textBoxLine4.Enabled == false) || (textBoxLine5.Enabled == false) || (textBoxLine6.Enabled == false)) { LogMessage.Log("SaveToMemory(CMacro) cancelled: Status of TextBoxes:\r\n" + "Name: {0}\r\n" + "Line1: {1}\r\n" + "Line2: {2}\r\n" + "Line3: {3}\r\n" + "Line4: {4}\r\n" + "Line5: {5}\r\n" + "Line6: {6}", textBoxName.Enabled, textBoxLine1.Enabled, textBoxLine2.Enabled, textBoxLine3.Enabled, textBoxLine4.Enabled, textBoxLine5.Enabled, textBoxLine6.Enabled); return; } LogMessage.Log("SaveToMemory(CMacro) saved successfully: '{0}'", textBoxName.Text); cm.Name = textBoxName.Text; cm.Line[0] = textBoxLine1.Text; cm.Line[1] = textBoxLine2.Text; cm.Line[2] = textBoxLine3.Text; cm.Line[3] = textBoxLine4.Text; cm.Line[4] = textBoxLine5.Text; cm.Line[5] = textBoxLine6.Text; }
private void HandleBarsToBarsOrFile(TreeNode dragNode, TreeNode dropNode, int SwapOrCopy) { #region Swap/Copy Drag & Drop Ctrl/Alt Macro Bars and update CMacroFile cmf_drop = FindMacroFileByNode(dropNode), cmf_drag = FindMacroFileByNode(dragNode); TagInfo tIdrag = dragNode.Tag as TagInfo, tIdrop = dropNode.Tag as TagInfo; int destcnt = 0, srccnt = 0, cnt; CMacro tmp = new CMacro(), tmp2 = new CMacro(); if (is_altnode(dragNode, cmf_drag) || (tIdrag.Text == "altmacro")) srccnt = 10; if (tIdrop.Text == "macrofile") // this covers it if dropping to macrofile destcnt = srccnt; else if (is_altnode(dropNode, cmf_drop) || (tIdrop.Text == "altmacro")) destcnt = 10; if (SwapOrCopy == 1) { for (cnt = 0; cnt < 10; cnt++) { Swap(ref cmf_drop.Macros[cnt + destcnt], ref cmf_drag.Macros[cnt + srccnt]); } //if (cmf_drag != null) //{ //cmf_drag.Changed = true; //} } else if (SwapOrCopy == 2) { for (cnt = 0; cnt < 10; cnt++) { cmf_drop.Macros[cnt + destcnt].CopyFrom(cmf_drag.Macros[cnt + srccnt]); } } if (cmf_drop != null) { cmf_drop.Changed = true; } #endregion }
public MaCrt(object cm, MacpMain form) { InitializeComponent(); this.Location = new Point(form.Location.X + form.Width - 15, form.Location.Y); this.cm = cm as CMacro; }
public static void RemoveMacro(CMacro macro) { m_listeMacros.Remove(macro); }
public static void AddMacro(CMacro macro) { m_listeMacros.Add(macro); }
private void OnCancel(object sender, EventArgs e) { cm = null; this.DialogResult = DialogResult.Cancel; this.Close(); }
public bool Swap(ref CMacro src) { CMacro tmp = new CMacro(); //this.MacroNumber = src.MacroNumber; // NEVER COPY THIS if (this.m_Line == null) this.m_Line = new String[6]; if (src == null) { this.m_Name = String.Empty; this.m_Line[0] = String.Empty; this.m_Line[1] = String.Empty; this.m_Line[2] = String.Empty; this.m_Line[3] = String.Empty; this.m_Line[4] = String.Empty; this.m_Line[5] = String.Empty; } else { tmp.Name = this.m_Name; this.m_Name = src.Name; src.Name = tmp.Name; if (src._thisNode != null) { if (this._thisNode != null) { String text = src._thisNode.Text; src._thisNode.Text = this._thisNode.Text; this._thisNode.Text = text; } } tmp.Line = this.Line; this.Line = src.Line; src.Line = tmp.Line; } return true; }
private void copyToolStripMenuItem_Click(object sender, EventArgs e) { if (this.treeView.SelectedNode == null) return; CMacroFile cmf = FindMacroFileByNode(this.treeView.SelectedNode); if (cmf == null) return; CMacro cm = GetCurrentMacro(cmf); if (cm == null) return; if (clipboard_macro == null) clipboard_macro = new CMacro(); if (this.pasteToolStripMenuItem.Enabled == false) this.pasteToolStripMenuItem.Enabled = true; clipboard_macro.CopyFrom(cm); // Copy doesn't require a Changed flag... //cmf.Changed = true; }
public bool Swap(ref CMacroFile src) { CMacro tmp = new CMacro(); String text = String.Empty; if ((this.Macros != null) && (src.Macros != null)) { for (int i = 0; i < this.Macros.Length; i++) { this.Macros[i].Swap(ref src.Macros[i]); } } uint version = src.version; src.version = this.version; this.version = version; this.Changed = true; src.Changed = true; return true; }
private void cutToolStripMenuItem_Click(object sender, EventArgs e) { if (this.treeView.SelectedNode == null) return; CMacroFile cmf = FindMacroFileByNode(this.treeView.SelectedNode); if (cmf == null) return; CMacro cm = GetCurrentMacro(cmf); if (cm == null) return; if (clipboard_macro == null) clipboard_macro = new CMacro(); if (this.pasteToolStripMenuItem.Enabled == false) this.pasteToolStripMenuItem.Enabled = true; clipboard_macro.CopyFrom(cm); cm.Clear(); //TreeNode tn = cm.thisNode; //int mn = cm.MacroNumber; //cm = new CMacro(); //cm.thisNode = tn; //cm.MacroNumber = mn; cmf.Changed = true; FillForm(cm); }