public UserCommandEditor(UserCommandMapping commmandMapping, List<string> mouseCapableContexts) { InitializeComponent(); this.mapping = commmandMapping; this.mouseCapable = mouseCapableContexts; editButton.Enabled = false; foreach (string cont in mapping.Context) { contextComboBox.Items.Add(cont); } contextComboBox.SelectedIndex = 0; foreach (string key in mapping.Key) { keyComboBox.Items.Add(key); } keyComboBox.SelectedIndex = 0; foreach (string modifier in mapping.Modifiers) { modifierComboBox.Items.Add(modifier); } modifierComboBox.SelectedIndex = 0; foreach (string action in mapping.Activities) { activityComboBox.Items.Add(action); } activityComboBox.SelectedIndex = 0; }
public UserCommandMapping Clone() { UserCommandMapping clone; clone = new UserCommandMapping(events, context, commands, excludedKeys); return(clone); }
public UserCommandEditor(UserCommandMapping commmandMapping, List <string> mouseCapableContexts) { InitializeComponent(); this.mapping = commmandMapping; this.mouseCapable = mouseCapableContexts; editButton.Enabled = false; foreach (string cont in mapping.Context) { contextComboBox.Items.Add(cont); } contextComboBox.SelectedIndex = 0; foreach (string key in mapping.Key) { keyComboBox.Items.Add(key); } keyComboBox.SelectedIndex = 0; foreach (string modifier in mapping.Modifiers) { modifierComboBox.Items.Add(modifier); } modifierComboBox.SelectedIndex = 0; foreach (string action in mapping.Activities) { activityComboBox.Items.Add(action); } activityComboBox.SelectedIndex = 0; }
public UserCommand(EventObject handler, string key, string activity, string modifier, string evstr, UserCommandMapping par) { //if (handler == null) //{ // log.ErrorFormat("handler == null"); //} //if (par == null) //{ // log.ErrorFormat("par == null"); //} ev = handler; parent = par; this.activity = activity; this.modifier = modifier; this.modifiercode = parent.ParseStringToKeyCode(modifier); this.evstring = evstr; this.keystring = key; this.keycode = parent.ParseStringToKeyCode(keystring); this.context = ev.Context; }
private void editMenuControlMappingEditorItem_clicked(object sender, EventArgs e) { UserCommandMapping workingCopy = commandMapping.Clone(); using (UserCommandEditor dialog = new UserCommandEditor(workingCopy, Config.MouseCapableContexts)) { DialogResult dlgres = dialog.ShowDialog(); if (dlgres == DialogResult.OK) { commandMapping.Dispose(); commandMapping = workingCopy; XmlWriter w = XmlWriter.Create(this.Config.AltCommandBindingsFilePath, xmlWriterSettings); commandMapping.ToXml(w); w.Close(); } } createKeybindings(); }
public void createKeybindings() { // int i = 0; (unused) List<EventObject> evlist = new List<EventObject>(); if (File.Exists(config.CommandBindingEventsFilePath)) { try { XmlReader r = XmlReader.Create(Config.CommandBindingEventsFilePath, xmlReaderSettings); while (r.Read()) { if (r.NodeType == XmlNodeType.Whitespace) { continue; } if (r.NodeType == XmlNodeType.XmlDeclaration) { continue; } if (r.NodeType == XmlNodeType.EndElement) { break; } switch (r.Name) { case "EventObjects": while (r.Read()) { if (r.NodeType == XmlNodeType.Whitespace) { continue; } if (r.NodeType == XmlNodeType.EndElement) { break; } switch (r.Name) { case "Event": evlist.Add(new EventObject(r)); break; } } break; } } } catch (Exception e) { string filePath = String.Format("{0}\\{1}", Application.ExecutablePath.Substring(0, Application.ExecutablePath.LastIndexOf("\\")), this.Config.CommandBindingEventsFilePath.Substring(this.Config.CommandBindingEventsFilePath.IndexOf(".") + 2, this.Config.CommandBindingEventsFilePath.Length - this.Config.CommandBindingEventsFilePath.IndexOf(".") - 2)); log.ErrorFormat("Exception Reading CommandEvents.xml at {1}: {0}", e, filePath); MessageBox.Show(String.Format("The CommandEvents.xml file could not be parsed at {0}. The World Editor can not run properly without this file. The World Editor will exit now.", filePath), "Can not parse Key Bindings file", MessageBoxButtons.OK); exitToolStripMenuItem_Click(this, new EventArgs()); log.Error("World Editor Exiting now"); return; } foreach (EventObject obj in evlist) { bool mouseEvent = false; EventHandler hand = null; switch (obj.EvString) { case "worldEditorToggleLockCameraToObject": hand = lockCameraToSelectedObjectToolStipMenuItem_Click; break; case "axiomToggleMoveCameraOnPlane": hand = this.axiomToggleMoveCameraOnPlane; break; case "axiomOnCameraOnPlane": hand = this.axiomOnCameraOnPlane; break; case "axiomOffCameraOnPlane": hand = this.axiomOffCameraOnPlane; break; case "axiomCameraMoveSpeedUp": hand = this.axiomCameraMoveSpeedUp; break; case "axiomCameraMoveSpeedDown": hand = this.axiomCameraMoveSpeedDown; break; case "axiomToggleAccelerate": hand = this.axiomToggleAccelerate; break; case "axiomCameraAccelerateUp": hand = this.axiomCameraAccelerateUp; break; case "axiomCameraAccelerateDown": hand = this.axiomCameraAccelerateDown; break; case "worldEditorMoveCameraForward": case "axiomMoveCameraForward": hand = this.axiomMoveCameraForward; break; case "axiomMoveCameraForwardStop": case "worldEditorMoveCameraForwardStop": hand = this.axiomMoveCameraForwardStop; break; case "axiomMoveCameraBack": case "worldEditorMoveCameraBack": hand = this.axiomMoveCameraBack; break; case "axiomMoveCameraBackStop": case "worldEditorMoveCameraBackStop": hand = this.axiomMoveCameraBackStop; break; case "axiomMoveCameraLeft": case "worldEditorMoveCameraLeft": hand = this.axiomMoveCameraLeft; break; case "axiomMoveCameraLeftStop": case "worldEditorMoveCameraLeftStop": hand = this.axiomMoveCameraLeftStop; break; case "axiomMoveCameraRight": case "worldEditorMoveCameraRight": hand = this.axiomMoveCameraRight; break; case "axiomMoveCameraRightStop": case "worldEditorMoveCameraRightStop": hand = this.axiomMoveCameraRightStop; break; case "worldEditorMoveCameraUp": hand = this.worldEditorMoveCameraUp; break; case "worldEditorMoveCameraUpStop": hand = this.worldEditorMoveCameraUpStop; break; case "worldEditorMoveCameraDown": hand = this.worldEditorMoveCameraDown; break; case "worldEditorMoveCameraDownStop": hand = this.worldEditorMoveCameraDownStop; break; case "axiomMoveCameraStop": hand = this.axiomMoveCameraStop; break; case "axiomTurnCameraLeft": hand = this.axiomTurnCameraLeft; break; case "axiomTurnCameraLeftStop": hand = this.axiomTurnCameraLeftStop; break; case "axiomTurnCameraRight": hand = this.axiomTurnCameraRight; break; case "axiomTurnCameraRightStop": hand = this.axiomTurnCameraRightStop; break; case "axiomTurnCameraDown": hand = this.axiomTurnCameraDown; break; case "axiomTurnCameraDownStop": hand = this.axiomTurnCameraDownStop; break; case "axiomTurnCameraUp": hand = this.axiomTurnCameraUp; break; case "axiomTurnCameraUpStop": hand = this.axiomTurnCameraUpStop; break; case "worldEditorCut": case "axiomCut": case "treeViewCut": hand = this.worldEditorCutObjects; break; case "worldEditorCopy": case "axiomCopy": case "treeViewCopy": hand = this.worldEditorCopyObjects; break; case "worldEditorPaste": case "axiomPaste": case "treeViewPaste": hand = this.worldEditorPasteObjects; break; case "axiomDeleteObject": case "treeViewDeleteObject": hand = deleteToolStripMenuItem_Clicked; break; case "axiomMouseSelectObject": hand = axiomMouseSelectObject; mouseEvent = true; break; case "axiomMouseSelectMultipleObject": hand = axiomMouseSelectMultipleObject; mouseEvent = true; break; case "axiomMouseTurnCamera": hand = axiomMouseTurnCamera; mouseEvent = true; break; case "axiomEditorWarpCamera": hand = axiomWarpCamera; break; case "axiomCameraLookDownSouth": hand = axiomCameraLookDownSouth; break; case "axiomMoveCameraToSelectedMarker": hand = axiomMoveCameraToSelectedMarker; break; case "worldEditorUndo": hand = undoToolStripMenuItem_Click; break; case "worldEditorRedo": hand = redoToolStripMenuItem_Click; break; case "worldEditorNewWorld": hand = newWorldToolStripMenuItem_Click; break; case "worldEditorLoadWorld": hand = loadWorldToolStripMenuItem_Click; break; case "worldEditorExit": hand = exitToolStripMenuItem_Click; break; case "worldEditorSaveWorld": hand = saveWorldToolStripMenuItem_Click; break; case "worldEditorEditPreferences": hand = editMenuPreferencesItem_clicked; break; case "worldEditorTreeViewSearch": hand = editMenuTreeViewSearchItem_clicked; break; case "worldEditorControlMappingEditor": hand = editMenuControlMappingEditorItem_clicked; break; case "worldEditorTakeScreenShotOn": hand = worldEditorTakeScreenShotOn; break; case "worldEditorTakeScreenShotOff": hand = worldEditorTakeScreenShotOff; break; case "worldEditorDisplayPointLightCircles": hand = displayPointLightAttenuationCirclesMenuItem_Click; break; case "treeViewMoveToNextNode": hand = treeViewMoveToNextNode; break; case "treeViewMoveToPrevNode": hand = treeViewMoveToPrevNode; break; case "treeViewExpandSelectedNode": hand = treeViewExpandSelectedNode; break; case "treeViewExpandAllSelectedNode": hand = treeViewExpandAllSelectedNode; break; case "treeViewCollapseSelectedNode": hand = treeViewCollapseSelectedNode; break; case "axiomSetCameraSpeedPreset1": hand = axiomSetSpeedPreset1; break; case "axiomSetCameraSpeedPreset2": hand = axiomSetSpeedPreset2; break; case "axiomSetCameraSpeedPreset3": hand = axiomSetSpeedPreset3; break; case "axiomSetCameraSpeedPreset4": hand = axiomSetSpeedPreset4; break; case "axiomSetPresetMWM1": hand = axiomSetPresetMWM1; break; case "axiomSetPresetMWM2": hand = axiomSetPresetMWM2; break; case "axiomSetPresetMWM3": hand = axiomSetPresetMWM3; break; case "axiomSetPresetMWM4": hand = axiomSetPresetMWM4; break; case "axiomSetAccelPreset1": hand = axiomSetAccelPreset1; break; case "axiomSetAccelPreset2": hand = axiomSetAccelPreset2; break; case "axiomSetAccelPreset3": hand = axiomSetAccelPreset3; break; case "axiomSetAccelPreset4": hand = axiomSetAccelPreset4; break; case "axiomCameraMoveSpeedUpStop": hand = axiomCameraMoveSpeedUpStop; break; case "axiomCameraMoveSpeedDownStop": hand = axiomCameraMoveSpeedDownStop; break; case "axiomCameraAccelerateUpStop": hand = axiomCameraAccelerateUpStop; break; case "axiomCameraAccelerateDownStop": hand = axiomCameraAccelerateDownStop; break; default: break; } if (mouseEvent) { obj.MouseButtonEvent = true; } obj.Handler = hand; } XmlReader xr; string keyBindingsFile = this.Config.AltCommandBindingsFilePath; if (!File.Exists(keyBindingsFile)) { keyBindingsFile = this.Config.CommandBindingsFilePath; if (!File.Exists(keyBindingsFile)) { string filePath1 = String.Format("{0}\\{1}", Application.ExecutablePath.Substring(0, Application.ExecutablePath.LastIndexOf("\\")), this.Config.AltCommandBindingsFilePath.Substring(this.Config.AltCommandBindingsFilePath.IndexOf(".") + 2, this.Config.AltCommandBindingsFilePath.Length - this.Config.AltCommandBindingsFilePath.IndexOf(".") - 2)); string filePath2 = String.Format("{0}\\{1}", Application.ExecutablePath.Substring(0, Application.ExecutablePath.LastIndexOf("\\")), this.Config.CommandBindingsFilePath.Substring(this.Config.CommandBindingsFilePath.IndexOf(".") + 2, this.Config.CommandBindingsFilePath.Length - this.Config.CommandBindingsFilePath.IndexOf(".") - 2)); log.ErrorFormat("Files MyBindings.xml and KeyBindings.xml could not be found at {0} and {1}", filePath1, filePath2); MessageBox.Show(String.Format("The MyBindings.xml and KeyBindings.xml file could not be found at {0} and {1}. The World Editor can not run properly without at least one of these files. The World Editor will exit now.", filePath1, filePath2), "Could not find MyBindings.xml and KeyBindings.xml", MessageBoxButtons.OK); exitToolStripMenuItem_Click(this, new EventArgs()); log.Error("World Editor Exiting now"); return; } } while (true) { try { xr = XmlReader.Create(keyBindingsFile, xmlReaderSettings); commandMapping = new UserCommandMapping(xr, evlist, Config.Context, Config.ExcludedKeys); foreach (UserCommand command in commandMapping.Commands) { if (String.Equals(command.EvString, "axiomMouseSelectObject")) { mouseSelectModifier = command.ModifierCode; switch (command.KeyCode) { case Keys.LButton: mouseSelectButton = MouseButtons.Left; break; case Keys.RButton: mouseSelectButton = MouseButtons.Right; break; case Keys.MButton: mouseSelectButton = MouseButtons.Middle; break; } } } setShortCuts(); } catch (Exception e) { if (String.Equals(keyBindingsFile, this.Config.CommandBindingEventsFilePath)) { string filePath = String.Format("{0}\\{1}", Application.ExecutablePath.Substring(0, Application.ExecutablePath.LastIndexOf("\\")), this.Config.CommandBindingsFilePath.Substring(this.Config.CommandBindingsFilePath.IndexOf(".") + 2, this.Config.CommandBindingsFilePath.Length - this.Config.CommandBindingsFilePath.IndexOf(".") - 2)); log.ErrorFormat("Exception Reading KeyBindings.xml at {1}: {0}", e, filePath); MessageBox.Show(String.Format("The KeyBindings.xml file could not be parsed at {0}. The World Editor can not run properly without this file. The World Editor will exit now.", filePath), "Can not parse Key Bindings file", MessageBoxButtons.OK); exitToolStripMenuItem_Click(this, new EventArgs()); log.Error("World Editor Exiting now"); return; } else { string filePath = String.Format("{0}\\{1}", Application.ExecutablePath.Substring(0, Application.ExecutablePath.LastIndexOf("\\")), this.Config.AltCommandBindingsFilePath.Substring(this.Config.AltCommandBindingsFilePath.IndexOf(".") + 2, this.Config.AltCommandBindingsFilePath.Length - this.Config.AltCommandBindingsFilePath.IndexOf(".") - 2)); log.ErrorFormat("Exception Reading MyBindings.xml at {1}: {0}", e, filePath); MessageBox.Show(String.Format("The MyBindings.xml file could not be parsed at {0}. The World Editor can not run properly without this file. We will try to load the default command bindings from KeyBindings.xml file", filePath), "Can not parse Key Bindings file", MessageBoxButtons.OK); keyBindingsFile = this.Config.CommandBindingsFilePath; continue; } } return; } } else { string dir = Application.ExecutablePath.Substring(0, Application.ExecutablePath.LastIndexOf("\\")); string filename = this.Config.CommandBindingEventsFilePath.Substring(this.Config.CommandBindingEventsFilePath.IndexOf(".") + 2, this.Config.CommandBindingEventsFilePath.Length - this.Config.CommandBindingEventsFilePath.IndexOf(".") - 2); string filePath = String.Format("{0}\\{1}", dir, filename); log.ErrorFormat("CommandEvents.xml was not found at {0}", filePath); MessageBox.Show(String.Format("The CommandEvents.xml file could not be found at {0}. The World Editor can not run properly without this file. The World Editor will exit now.", filePath), "Could not find CommandEvents.xml", MessageBoxButtons.OK); exitToolStripMenuItem_Click(this, new EventArgs()); log.Error("World Editor Exiting now"); return; } }
public UserCommandMapping Clone() { UserCommandMapping clone; clone = new UserCommandMapping(events, context, commands, excludedKeys); return clone; }
public UserCommand Clone(UserCommandMapping par) { UserCommand rv = new UserCommand(ev, keystring, activity, modifier, evstring, par); return rv; }
public UserCommand( XmlReader r, UserCommandMapping par) { parent = par; fromXml(r); }
public UserCommand Clone(UserCommandMapping par) { UserCommand rv = new UserCommand(ev, keystring, activity, modifier, evstring, par); return(rv); }
public UserCommand(XmlReader r, UserCommandMapping par) { parent = par; fromXml(r); }