private void StartTrigger(int Code) { Editing=Code; Text="Editing trigger "+Code.ToString(); type=MacroFormType.Trigger; //Same as EndMacro() so probably not needed cbFunction.Enabled=false; cbMacroType.Enabled=false; rbDown.Enabled=false; rbTap.Enabled=false; rbUp.Enabled=false; tbCDesc.Enabled=false; tbCLen.Text=""; //Changes bSave.Enabled=true; bCancel.Enabled=true; cbTrigger.Enabled=false; tbTimeDelay.Enabled=true; cbTriggerEnabled.Enabled=true; //Set up initial data Array.Copy(Statics.Triggers[Code].data.KeyStates,Active,Statics.MACROS); tbTimeDelay.Text=Statics.Triggers[Code].TimeInterval.ToString(); cbTriggerEnabled.Checked=Statics.Triggers[Code].Active; //Setup the buttons foreach(Control c in Controls) { if(c is Button&&c.Name.StartsWith("b")&&(c.Name.Length==3||c.Name.Length==4)) { if(GetCode((Button)c)<264) {c.Enabled=true;} else {c.Enabled=false;} if(Active[GetCode((Button)c)]) c.BackColor=Color.Green; else c.BackColor=SystemColors.Control; } } }
/// <summary> /// One seriously complicated function /// </summary> /// <param name="Code">The macro to start editing</param> public void StartMacro(int Code) { Text="Editing macro 0x"+Code.ToString("x"); Editing=Code; Active=new bool[Statics.MACROS]; Array.Copy(Statics.Macros[Code].Press.KeyStates,Active,Statics.MACROS); ConsoleCommand.Clear(); for(int i=0;i<Statics.Macros[Code].Console.Length;i++) { ConsoleCommand.Add(Statics.Macros[Code].Console.KeyCodes[i]); } tbCLen.Text=ConsoleCommand.Count.ToString(); tbCDesc.Text=Statics.Macros[Code].Console.Description; cbFunction.SelectedIndex=(int)Statics.Macros[Code].Graphics.function; cbTriggerEnabled.Enabled=false; tbTimeDelay.Enabled=false; switch(Statics.Macros[Code].Type) { case MacroType.Console1:case MacroType.Console2: type=MacroFormType.Console; break; case MacroType.Press1:case MacroType.Press2:case MacroType.Unpress: case MacroType.Hammer1:case MacroType.Hammer2:case MacroType.Unhammer: case MacroType.AHammer1:case MacroType.AHammer2:case MacroType.AUnhammer: type=MacroFormType.Press; break; case MacroType.BeginTimer:case MacroType.EndTimer: type=MacroFormType.Timer; break; case MacroType.Graphics: type=MacroFormType.Function; break; default: type=MacroFormType.Unknown; break; } //Have to put this down here, or it causes all sorts of problems cbTrigger.SelectedIndex=Statics.Macros[Code].Timer.TimerID+1; bSave.Enabled=true; bCancel.Enabled=true; cbMacroType.Enabled=true; tbTimeDelay.Enabled=false; cbMacroType.SelectedIndex=(int)Statics.Macros[Code].Type; if(type==MacroFormType.Console||type==MacroFormType.Press||type==MacroFormType.Trigger) { foreach(Control c in Controls) { if(c is Button&&c.Name.StartsWith("b")&&(c.Name.Length==3||c.Name.Length==4)) { int i=GetCode((Button)c); if(type==MacroFormType.Console) { c.BackColor=SystemColors.Control; if(i<256) { c.Enabled=true; } else { c.Enabled=false; } } else { if(i<264) { c.Enabled=true; } else { c.Enabled=false; } if(Active[GetCode((Button)c)]) c.BackColor=Color.Green; else c.BackColor=SystemColors.Control; } } } } else { foreach(Control c in Controls) { if(c is Button&&c.Name.StartsWith("b")&&(c.Name.Length==3||c.Name.Length==4)) { c.Enabled=false; c.BackColor=SystemColors.Control; } } } if(type==MacroFormType.Console) { rbDown.Enabled=true; rbTap.Enabled=true; rbUp.Enabled=true; rbTap.Checked=true; tbCDesc.Enabled=true; bClear.Enabled=true; } else { rbDown.Enabled=false; rbTap.Enabled=false; rbUp.Enabled=false; tbCDesc.Enabled=false; bClear.Enabled=false; } if(type==MacroFormType.Function) { cbFunction.Enabled=true; } else { cbFunction.Enabled=false; } if(type==MacroFormType.Timer) { cbTrigger.Enabled=true; } else { cbTrigger.Enabled=false; } }
/// <summary> /// Stops editing a macro and goes back to the macro select screen /// </summary> /// <param name="Partial">true to not change any form properties</param> public void EndMacro() { Text="Macro editor"; type=MacroFormType.Editor; cbFunction.Enabled=false; cbMacroType.Enabled=false; bSave.Enabled=false; bCancel.Enabled=false; rbDown.Enabled=false; rbTap.Enabled=false; rbUp.Enabled=false; tbCDesc.Enabled=false; cbTrigger.Enabled=true; cbFunction.SelectedIndex=0; cbTrigger.SelectedIndex=0; cbTriggerEnabled.Enabled=false; tbTimeDelay.Enabled=false; tbCLen.Text=""; bClear.Enabled=false; ConsoleCommand.Clear(); Editing=-1; foreach(Control c in Controls) { if(c is Button&&c.Name.StartsWith("b")&&(c.Name.Length==3||c.Name.Length==4)) { c.Enabled=true; if(Statics.Macros[GetCode((Button)c)].Type!=MacroType.Unused) c.BackColor=Color.Green; else c.BackColor=SystemColors.Control; } } }