示例#1
0
 public UserCommandMapping(List <EventObject> events, List <string> context, List <UserCommand> com, List <ExcludedKey> exKeys)
 {
     this.events       = events;
     this.context      = context;
     this.excludedKeys = exKeys;
     foreach (UserCommand comm in com)
     {
         UserCommand uc = comm.Clone(this);
         this.commands.Add(uc);
     }
     foreach (ExcludedKey eKey in exKeys)
     {
         eKey.KeyCode      = ParseStringToKeyCode(eKey.Key);
         eKey.ModifierCode = ParseModifierToCode(eKey.Modifier);
     }
 }
 public void editButton_clicked(object sender, EventArgs ea)
 {
     if (eventsTreeView.SelectedNode.Tag is UserCommand)
     {
         if (!(eventsTreeView.SelectedNode.Tag as UserCommand).Event.MouseButtonEvent && (Keys.LButton == mapping.ParseStringToKeyCode(keyComboBox.SelectedItem as string) || Keys.RButton == mapping.ParseStringToKeyCode(keyComboBox.SelectedItem as string) ||
                                                                                          Keys.MButton == mapping.ParseStringToKeyCode(keyComboBox.SelectedItem as string)))
         {
             MessageBox.Show("Mouse related events must be mapped to mouse buttons", "Problem with mapping event", MessageBoxButtons.OK);
             return;
         }
         UserCommand com = (eventsTreeView.SelectedNode.Tag as UserCommand);
         com.Key      = keyComboBox.SelectedItem as string;
         com.Modifier = modifierComboBox.SelectedItem as string;
         com.Activity = activityComboBox.SelectedItem as string;
         eventsTreeView.SelectedNode.Text = parseCommandForString(com);
     }
 }
        public void addButton_clicked(object sender, EventArgs ea)
        {
            if (eventsTreeView.SelectedNode.Tag is EventObject)
            {
                if ((eventsTreeView.SelectedNode.Tag as EventObject).MouseButtonEvent && !(Keys.LButton == mapping.ParseStringToKeyCode(keyComboBox.SelectedItem as string) || Keys.RButton == mapping.ParseStringToKeyCode(keyComboBox.SelectedItem as string) ||
                    Keys.MButton == mapping.ParseStringToKeyCode(keyComboBox.SelectedItem as string)))
                {
                    MessageBox.Show("Mouse related events must be mapped to mouse buttons", "Problem with mapping event", MessageBoxButtons.OK);
                    return;
                }

                UserCommand newCommand = new UserCommand(eventsTreeView.SelectedNode.Tag as EventObject, keyComboBox.SelectedItem as string, activityComboBox.SelectedItem as string, modifierComboBox.SelectedItem as string, (eventsTreeView.SelectedNode.Tag as EventObject).EvString, mapping);
                TreeNode newNode = new TreeNode(parseCommandForString(newCommand));
                mapping.Commands.Add(newCommand);
                newNode.Tag = newCommand;
                eventsTreeView.SelectedNode.Nodes.Add(newNode);
                eventsTreeView.ExpandAll();
            }
        }
        public void addButton_clicked(object sender, EventArgs ea)
        {
            if (eventsTreeView.SelectedNode.Tag is EventObject)
            {
                if ((eventsTreeView.SelectedNode.Tag as EventObject).MouseButtonEvent && !(Keys.LButton == mapping.ParseStringToKeyCode(keyComboBox.SelectedItem as string) || Keys.RButton == mapping.ParseStringToKeyCode(keyComboBox.SelectedItem as string) ||
                                                                                           Keys.MButton == mapping.ParseStringToKeyCode(keyComboBox.SelectedItem as string)))
                {
                    MessageBox.Show("Mouse related events must be mapped to mouse buttons", "Problem with mapping event", MessageBoxButtons.OK);
                    return;
                }

                UserCommand newCommand = new UserCommand(eventsTreeView.SelectedNode.Tag as EventObject, keyComboBox.SelectedItem as string, activityComboBox.SelectedItem as string, modifierComboBox.SelectedItem as string, (eventsTreeView.SelectedNode.Tag as EventObject).EvString, mapping);
                TreeNode    newNode    = new TreeNode(parseCommandForString(newCommand));
                mapping.Commands.Add(newCommand);
                newNode.Tag = newCommand;
                eventsTreeView.SelectedNode.Nodes.Add(newNode);
                eventsTreeView.ExpandAll();
            }
        }
 private string parseCommandForString(UserCommand command)
 {
     string text = "";
     if (!String.Equals(command.Modifier, "none"))
     {
         text = String.Format("{0}+{1}", command.Modifier, command.Key);
     }
     else
     {
         text = command.Key;
     }
     return text;
 }
 private void fromXml(XmlReader r)
 {
     while (r.Read())
     {
         switch(r.Name)
         {
             case "CommandBinding":
                 UserCommand uc = new UserCommand(r, this);
                 this.commands.Add(uc);
                 break;
         }
     }
 }
 public UserCommand Clone(UserCommandMapping par)
 {
     UserCommand rv = new UserCommand(ev, keystring, activity, modifier, evstring, par);
     return rv;
 }
示例#8
0
        public UserCommand Clone(UserCommandMapping par)
        {
            UserCommand rv = new UserCommand(ev, keystring, activity, modifier, evstring, par);

            return(rv);
        }