Esempio n. 1
0
 private void tsmiRemove_Click(object sender, EventArgs e)
 {
     if (m_selectedNode.Name == "commands" || m_selectedNode.Name == "activators" || m_selectedNode.Name == "conditions")
     {
         DialogResult result = MessageBox.Show("Mit \"Löschen\" werden in diesem Kontext alle Unterpunkte des geklicken Punktes gelöscht. Wollen Sie wirklich forfahren?", "Alle Unterpunkte löschen", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
         if (result == DialogResult.Yes)
         {
             ActivatorShortcut.RemoveEvents(m_selectedNode);
             ActivatorTime.CancelTimers(m_selectedNode);
             m_selectedNode.Nodes.Clear();
         }
     }
     else if (m_selectedNode.Name == "folder")
     {
         DialogResult result = MessageBox.Show("Wollen Sie \"" + m_selectedNode.Text + "\" und smit auch alle Unterpunkte wirklich löschen?", "Löschen", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
         if (result == DialogResult.Yes)
         {
             ActivatorShortcut.RemoveEvents(m_selectedNode);
             ActivatorTime.CancelTimers(m_selectedNode);
             tvMakros.Nodes.Remove(m_selectedNode);
             m_selectedNode = null;
         }
     }
     else if (m_selectedNode.Name == "makro")
     {
         DialogResult result = MessageBox.Show("Wollen Sie \"" + m_selectedNode.Text + "\" und smit auch alle Unterpunkte wirklich löschen?", "Löschen", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
         if (result == DialogResult.Yes)
         {
             ActivatorShortcut.RemoveEvents(m_selectedNode);
             ActivatorTime.CancelTimers(m_selectedNode);
             tvMakros.Nodes.Remove(m_selectedNode);
             m_selectedNode = null;
         }
     }
     else
     {
         ActivatorShortcut.RemoveEvents(m_selectedNode);
         ActivatorTime.CancelTimers(m_selectedNode);
         tvMakros.Nodes.Remove(m_selectedNode);
         m_selectedNode = null;
     }
 }
Esempio n. 2
0
        private void Makros_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Delete)
            {
                ActivatorTime.CancelTimers(SelectedNode);
                ActivatorShortcut.RemoveEvents(SelectedNode);

                if (SelectedNode.GetType() == typeof(ActivatorShortcut))
                {
                    SelectedNode.Remove();
                }
                else if (SelectedNode.GetType() == typeof(ActivatorTime))
                {
                    SelectedNode.Remove();
                }
                else if (SelectedNode.Name == "command" || SelectedNode.Name == "activator" || SelectedNode.Name == "condition")
                {
                    SelectedNode.Remove();
                }
                else if (SelectedNode.Name == "makro" || SelectedNode.Name == "folder")
                {
                    DialogResult result = MessageBox.Show("Wollen Sie \"" + SelectedNode.Text + "\" und somit auch alle Unterpunkte wirklich löschen?", "Löschen", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (result == DialogResult.Yes)
                    {
                        Nodes.Remove(SelectedNode);
                    }
                }
            }
            else if (e.KeyCode == Keys.Add)
            {
                if (SelectedNode.GetType() == typeof(CommandWait))
                {
                    CommandWait cw = (CommandWait)SelectedNode;
                    if (cw.Duration + 50 <= 3600000)
                    {
                        cw.Duration += 50;
                    }
                    else
                    {
                        cw.Duration = 3600000;
                    }
                }
            }
            else if (e.KeyCode == Keys.Subtract)
            {
                if (SelectedNode.GetType() == typeof(CommandWait))
                {
                    CommandWait cw = (CommandWait)SelectedNode;
                    if (cw.Duration - 50 >= 20)
                    {
                        cw.Duration -= 50;
                    }
                    else
                    {
                        cw.Duration = 20;
                    }
                }
            }
            else if (e.KeyCode == Keys.NumPad0)
            {
                if (SelectedNode.GetType() == typeof(CommandWait))
                {
                    CommandWait cw = (CommandWait)SelectedNode;
                    cw.Duration = 40;
                }
            }
            else if (e.KeyCode == Keys.NumPad1)
            {
                if (SelectedNode.GetType() == typeof(CommandWait))
                {
                    CommandWait cw = (CommandWait)SelectedNode;
                    cw.Duration = 100;
                }
            }
            else if (e.KeyCode == Keys.NumPad2)
            {
                if (SelectedNode.GetType() == typeof(CommandWait))
                {
                    CommandWait cw = (CommandWait)SelectedNode;
                    cw.Duration = 200;
                }
            }
            else if (e.KeyCode == Keys.Up && m_controlPressed)
            {
                if (SelectedNode.Name == "command" || SelectedNode.Name == "condition" ||
                    SelectedNode.Name == "activator" || SelectedNode.Name == "makro" || SelectedNode.Name == "folder")
                {
                    int tnIndex = SelectedNode.Index;
                    if (tnIndex - 1 >= 0)
                    {
                        TreeNode parentNode = SelectedNode.Parent;
                        TreeNode tn         = SelectedNode;
                        parentNode.Nodes.Remove(tn);
                        parentNode.Nodes.Insert(tnIndex - 1, tn);
                        SelectedNode = tn;
                    }
                }
            }
            else if (e.KeyCode == Keys.Down && m_controlPressed)
            {
                if (SelectedNode.Name == "command" || SelectedNode.Name == "condition" ||
                    SelectedNode.Name == "activator" || SelectedNode.Name == "makro" || SelectedNode.Name == "folder")
                {
                    int      tnIndex    = SelectedNode.Index;
                    TreeNode parentNode = SelectedNode.Parent;
                    if (tnIndex + 1 <= parentNode.Nodes.Count)
                    {
                        TreeNode tn = SelectedNode;
                        parentNode.Nodes.Remove(tn);
                        parentNode.Nodes.Insert(tnIndex + 1, tn);
                        SelectedNode = tn;
                    }
                }
            }
            if (e.KeyCode == Keys.ControlKey)
            {
                m_controlPressed = true;
            }
        }