private void GameCanvas_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (_grabbing) { stopDragObject(); return; } if (MOUSE_PRESSED_LEFT) { EndPointF = e.Location; ActionTemplates.launch( _physicsSystem, ObjectTemplates.CreateSmallBall(StartPointF.X, StartPointF.Y), StartPointF, EndPointF); MOUSE_PRESSED_LEFT = false; } } if (e.Button == MouseButtons.Right) { MOUSE_PRESSED_RIGHT = false; } }
//Methods //Commands private void AddItemToList(object param) { var item = param as string; switch (param) { case "Scenario": Scenarios.Add(new Scenario()); SelectedScenario = Scenarios.Last(); CommandEditItem.Execute(SelectedScenario); break; case "Macro": MacroList.Add(new Macro()); SelectedMacro = MacroList.Last(); CommandEditItem.Execute(SelectedMacro); break; case "ActionTemplate": ActionTemplate newTemplate = new ActionTemplate(); ActionTemplates.Insert(ActionTemplates.Count - 1, newTemplate); SelectedTemplate = newTemplate; CommandEditItem.Execute(SelectedTemplate); break; default: Logger.GetLogger().CatchException("ViewModel", "AddItemToList", $"Unknown param{{{item}}}"); throw new Exception(); } }
private void RemoveItemFromList(object param) { if (param is Scenario scenario) { var index = Scenarios.IndexOf(scenario); Scenarios.Remove(scenario); if (Scenarios.Count > 0) { if (index < Scenarios.Count) { SelectedScenario = Scenarios[index]; } else { SelectedScenario = Scenarios[index - 1]; } } } else if (param is Macro macro) { var index = MacroList.IndexOf(macro); MacroList.Remove(macro); if (MacroList.Count > 0) { if (index < MacroList.Count) { SelectedMacro = MacroList[index]; } else { SelectedMacro = MacroList[index - 1]; } } } else if (param is ActionTemplate template) { if (template.PlaceHolder == true) { return; } var index = ActionTemplates.IndexOf(template); ActionTemplates.Remove(template); template.HotKey = null; } else { Logger.GetLogger().CatchException("ViewModel", "RemoveItemFromList", "Unknown param"); throw new Exception(); } }
private void FormMainWindow_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Space) { _physicsSystem.FreezeStaticObjects(); } //Change to info Shader if (e.KeyCode == Keys.I) { ActionTemplates.changeShader(_physicsSystem, new ShaderInfo()); } //Change to PoolBall if (e.KeyCode == Keys.P) { ActionTemplates.changeShader(_physicsSystem, new ShaderBall()); } //Change to Water if (e.KeyCode == Keys.W) { ActionTemplates.changeShader(_physicsSystem, new ShaderWater()); } //Change to Velocity Shader if (e.KeyCode == Keys.V) { ActionTemplates.changeShader(_physicsSystem, new ShaderBallVelocity()); } //Create Gravity Ball if (e.KeyCode == Keys.G) { ObjectTemplates.CreateAttractor(_mousePos.X, _mousePos.Y); } //Pop if (e.KeyCode == Keys.OemSemicolon) { ActionTemplates.PopAndMultiply(_physicsSystem); } }
public void ReadFile(string strFilePath) { Dictionary <string, string> tmpKeys = ConfigHandler.ReadAllKeys(strFilePath); foreach (KeyValuePair <string, string> item in tmpKeys) { if (item.Key.StartsWith("RuleTemplate_")) { RuleTemplates.Add(new dmRuleTemplate(item.Key.Replace("RuleTemplate_", ""), item.Value)); } else if (item.Key.StartsWith("ActionTemplate_")) { ActionTemplates.Add(new dmActionTemplate(item.Key.Replace("ActionTemplate_", ""), item.Value)); } else if (item.Key.StartsWith("AutoComplete_")) { AutoCompleteStrings.Add(item.Key.Replace("AutoComplete_", ""), new List <string>(item.Value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))); } else { AddToKeyStorage(item.Key, item.Value); } } }