Exemplo n.º 1
0
        private void AutoVerbMenu_Opened(object sender, EventArgs e)
        {
            if ((console == null) || (console.IsInProcess))
            {
                切り取り.Enabled = false;
                コピー.Enabled  = false;
                貼り付け.Enabled = false;
                実行.Enabled   = false;
                削除.Enabled   = false;
                マクロToolStripMenuItem.Enabled = false;
                for (int i = 0; i < macroMenuItems.Length; i++)
                {
                    macroMenuItems[i].Enabled = false;
                }
                return;
            }
            実行.Enabled = true;
            if (Config.UseKeyMacro)
            {
                マクロToolStripMenuItem.Enabled = true;

                for (int i = 0; i < macroMenuItems.Length; i++)
                {
                    macroMenuItems[i].Enabled = KeyMacro.GetMacro(i, macroGroup).Length > 0;
                }
            }
            else
            {
                マクロToolStripMenuItem.Enabled = false;
                for (int i = 0; i < macroMenuItems.Length; i++)
                {
                    macroMenuItems[i].Enabled = false;
                }
            }
            if (richTextBox1.SelectedText.Length > 0)
            {
                切り取り.Enabled = true;
                コピー.Enabled  = true;
                削除.Enabled   = true;
            }
            else
            {
                切り取り.Enabled = false;
                コピー.Enabled  = false;
                削除.Enabled   = false;
            }
            if (Clipboard.ContainsText())
            {
                貼り付け.Enabled = true;
            }
            else
            {
                貼り付け.Enabled = false;
            }
        }
Exemplo n.º 2
0
 private void setNewMacroGroup(int group)
 {
     labelTimerCount               = 0;
     macroGroup                    = group;
     labelMacroGroupChanged.Text   = KeyMacro.GetGroupName(group);
     timerKeyMacroChanged.Interval = 200;
     timerKeyMacroChanged.Enabled  = true;
     timerKeyMacroChanged.Start();
     labelMacroGroupChanged.Location = new Point(4, richTextBox1.Location.Y - labelMacroGroupChanged.Height - 4);
     labelMacroGroupChanged.Visible  = true;
 }
Exemplo n.º 3
0
 private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (Config.UseKeyMacro)
     {
         KeyMacro.SaveMacro();
     }
     if (console != null)
     {
         //ほっとしても勝手に閉じるが、その場合はDebugDialogのClosingイベントが発生しない
         if ((Program.DebugMode) && (console.DebugDialog != null) && (console.DebugDialog.Created))
         {
             console.DebugDialog.Close();
         }
         console.Dispose();
         console = null;
     }
 }
Exemplo n.º 4
0
        private void マクロToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if ((console == null) || (console.IsInProcess))
            {
                return;
            }
            if (!Config.UseKeyMacro)
            {
                return;
            }
            ToolStripMenuItem item = (ToolStripMenuItem)sender;
            int    fkeynum         = (int)item.ShortcutKeys - (int)Keys.F1;
            string macro           = KeyMacro.GetMacro(fkeynum, macroGroup);

            if (macro.Length > 0)
            {
                richTextBox1.Text = macro;
                this.richTextBox1.SelectionStart = this.richTextBox1.Text.Length;
            }
        }
Exemplo n.º 5
0
        private void マクロToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (console == null || console.IsInProcess)
            {
                return;
            }
            if (!Config.UseKeyMacro)
            {
                return;
            }
            var item    = (ToolStripMenuItem)sender;
            var fkeynum = (int)item.ShortcutKeys - (int)Keys.F1;
            var macro   = KeyMacro.GetMacro(fkeynum, macroGroup);

            if (macro.Length > 0)
            {
                TextBox.Text           = macro;
                TextBox.SelectionStart = TextBox.Text.Length;
            }
        }
Exemplo n.º 6
0
 protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
 {
     //1823 INPUTMOUSEKEY Key入力全てを捕まえてERB側で処理する
     //if (console != null && console.IsWaitingPrimitiveKey)
     if (console != null && console.IsWaitingPrimitive)
     {
         return(false);
     }
     if ((keyData & Keys.KeyCode) == Keys.B && ((keyData & Keys.Modifiers) & Keys.Control) == Keys.Control)
     {
         if (WindowState != FormWindowState.Minimized)
         {
             WindowState = FormWindowState.Minimized;
             return(true);
         }
     }
     else if (((keyData & Keys.KeyCode) == Keys.C && ((keyData & Keys.Modifiers) & Keys.Control) == Keys.Control) || (keyData & Keys.KeyCode) == Keys.Insert && ((keyData & Keys.Modifiers) & Keys.Control) == Keys.Control)
     {
         if (this.richTextBox1.SelectedText == "")
         {
             ClipBoardDialog dialog = new ClipBoardDialog();
             dialog.StartPosition = FormStartPosition.CenterParent;
             dialog.Setup(this, console);
             dialog.ShowDialog();
             return(true);
         }
     }
     else if (((keyData & Keys.KeyCode) == Keys.V && ((keyData & Keys.Modifiers) & Keys.Control) == Keys.Control) || (keyData & Keys.KeyCode) == Keys.Insert && ((keyData & Keys.Modifiers) & Keys.Shift) == Keys.Shift)
     {
         if (Clipboard.GetDataObject() == null || !Clipboard.ContainsText())
         {
             return(true);
         }
         else
         {
             if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text) == true)
             {
                 richTextBox1.Paste(DataFormats.GetFormat(DataFormats.UnicodeText));
             }
             return(true);
         }
     }
     //else if (((int)keyData == (int)Keys.Control + (int)Keys.D) && Program.DebugMode)
     //{
     //    console.OpenDebugDialog();
     //    return true;
     //}
     //else if (((int)keyData == (int)Keys.Control + (int)Keys.R) && Program.DebugMode)
     //{
     //    if ((console.DebugDialog != null) && (console.DebugDialog.Created))
     //        console.DebugDialog.UpdateData();
     //}
     else if (Config.UseKeyMacro)
     {
         int  keyCode      = (int)(keyData & Keys.KeyCode);
         bool shiftPressed = (keyData & Keys.Modifiers) == Keys.Shift;
         bool ctrlPressed  = (keyData & Keys.Modifiers) == Keys.Control;
         bool unPressed    = (int)(keyData & Keys.Modifiers) == 0;
         if (keyCode >= (int)Keys.F1 && keyCode <= (int)Keys.F12)
         {
             int macroNum = keyCode - (int)Keys.F1;
             if (shiftPressed)
             {
                 if (this.richTextBox1.Text != "")
                 {
                     KeyMacro.SetMacro(macroNum, macroGroup, this.richTextBox1.Text);
                 }
                 return(true);
             }
             else if (unPressed)
             {
                 this.richTextBox1.Text           = KeyMacro.GetMacro(macroNum, macroGroup);
                 this.richTextBox1.SelectionStart = this.richTextBox1.Text.Length;
                 return(true);
             }
         }
         else if (ctrlPressed)
         {
             int newGroupNum = -1;
             if (keyCode >= (int)Keys.D0 && keyCode <= (int)Keys.D9)
             {
                 newGroupNum = keyCode - (int)Keys.D0;
             }
             else if (keyCode >= (int)Keys.NumPad0 && keyCode <= (int)Keys.NumPad9)
             {
                 newGroupNum = keyCode - (int)Keys.NumPad0;
             }
             if (newGroupNum >= 0)
             {
                 setNewMacroGroup(newGroupNum);
             }
         }
     }
     return(base.ProcessCmdKey(ref msg, keyData));
 }
Exemplo n.º 7
0
 protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
 {
     if ((keyData & Keys.KeyCode) == Keys.B && (keyData & Keys.Modifiers & Keys.Control) == Keys.Control)
     {
         if (WindowState != FormWindowState.Minimized)
         {
             WindowState = FormWindowState.Minimized;
             return(true);
         }
     }
     else if ((keyData & Keys.KeyCode) == Keys.C && (keyData & Keys.Modifiers & Keys.Control) == Keys.Control ||
              (keyData & Keys.KeyCode) == Keys.Insert &&
              (keyData & Keys.Modifiers & Keys.Control) == Keys.Control)
     {
         if (TextBox.SelectedText == "")
         {
             var dialog = new ClipBoardDialog();
             dialog.StartPosition = FormStartPosition.CenterParent;
             dialog.Setup(this, console);
             dialog.ShowDialog();
             return(true);
         }
     }
     else if ((keyData & Keys.KeyCode) == Keys.V && (keyData & Keys.Modifiers & Keys.Control) == Keys.Control ||
              (keyData & Keys.KeyCode) == Keys.Insert && (keyData & Keys.Modifiers & Keys.Shift) == Keys.Shift)
     {
         if (Clipboard.GetDataObject() == null || !Clipboard.ContainsText())
         {
             return(true);
         }
         if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text))
         {
             TextBox.Paste(DataFormats.GetFormat(DataFormats.UnicodeText));
         }
         return(true);
     }
     //else if (((int)keyData == (int)Keys.Control + (int)Keys.D) && Program.DebugMode)
     //{
     //    console.OpenDebugDialog();
     //    return true;
     //}
     //else if (((int)keyData == (int)Keys.Control + (int)Keys.R) && Program.DebugMode)
     //{
     //    if ((console.DebugDialog != null) && (console.DebugDialog.Created))
     //        console.DebugDialog.UpdateData();
     //}
     else if (Config.UseKeyMacro)
     {
         var keyCode      = (int)(keyData & Keys.KeyCode);
         var shiftPressed = (keyData & Keys.Modifiers) == Keys.Shift;
         var ctrlPressed  = (keyData & Keys.Modifiers) == Keys.Control;
         var unPressed    = (int)(keyData & Keys.Modifiers) == 0;
         if (keyCode >= (int)Keys.F1 && keyCode <= (int)Keys.F12)
         {
             var macroNum = keyCode - (int)Keys.F1;
             if (shiftPressed)
             {
                 if (TextBox.Text != "")
                 {
                     KeyMacro.SetMacro(macroNum, macroGroup, TextBox.Text);
                 }
                 return(true);
             }
             if (unPressed)
             {
                 TextBox.Text           = KeyMacro.GetMacro(macroNum, macroGroup);
                 TextBox.SelectionStart = TextBox.Text.Length;
                 return(true);
             }
         }
         else if (ctrlPressed)
         {
             var newGroupNum = -1;
             if (keyCode >= (int)Keys.D0 && keyCode <= (int)Keys.D9)
             {
                 newGroupNum = keyCode - (int)Keys.D0;
             }
             else if (keyCode >= (int)Keys.NumPad0 && keyCode <= (int)Keys.NumPad9)
             {
                 newGroupNum = keyCode - (int)Keys.NumPad0;
             }
             if (newGroupNum >= 0)
             {
                 setNewMacroGroup(newGroupNum);
             }
         }
     }
     return(base.ProcessCmdKey(ref msg, keyData));
 }