Exemplo n.º 1
0
        int TrySendCommandsFromToolbar(CommandData command, bool saveHistory)
        {
            int sent = 0;
            if (this.DockPanel.DocumentsCount > 0)
            {
                foreach (DockContent content in this.DockPanel.Documents)
                {
                    ctlPuttyPanel puttyPanel = content as ctlPuttyPanel;
                    if (puttyPanel != null && this.sendCommandsDocumentSelector.IsDocumentSelected(puttyPanel))
                    {
                        int handle = puttyPanel.AppPanel.AppWindowHandle.ToInt32();
                        Log.InfoFormat("SendCommand: session={0}, command=[{1}], handle={2}", puttyPanel.Session.SessionId, command, handle);

                        command.SendToTerminal(handle);

                        sent++;
                    }
                }

                if (sent > 0)
                {
                    // success...clear text and save in mru
                    this.tsSendCommandCombo.Text = string.Empty;
                    if (command != null && !string.IsNullOrEmpty(command.Command) && saveHistory)
                    {
                        this.tsSendCommandCombo.Items.Add(command.ToString());
                    }
                }
            }
            return sent;
        }
Exemplo n.º 2
0
        int TrySendCommandsFromToolbar(CommandData command, bool saveHistory)
        {
            int sent = 0;
            //String command = this.tsSendCommandCombo.Text; //this.tbTextCommand.Text;
            if (this.DockPanel.DocumentsCount > 0)
            {
                foreach (DockContent content in this.DockPanel.Documents)
                {
                    ctlPuttyPanel puttyPanel = content as ctlPuttyPanel;
                    if (puttyPanel != null && this.sendCommandsDocumentSelector.IsDocumentSelected(puttyPanel))
                    {
                        int handle = puttyPanel.AppPanel.AppWindowHandle.ToInt32();
                        Log.InfoFormat("SendCommand: session={0}, command=[{1}], handle={2}", puttyPanel.Session.SessionId, command, handle);

                        command.SendToTerminal(handle);
                        /*
                        foreach (Char c in command.Chars)
                        {
                            NativeMethods.SendMessage(handle, NativeMethods.WM_CHAR, (int)c, 0);
                        }

                        NativeMethods.SendMessage(handle, NativeMethods.WM_CHAR, (int)Keys.Enter, 0);*/
                        //NativeMethods.SendMessage(handle, NativeMethods.WM_KEYUP, (int)Keys.Enter, 0);
                        sent++;
                    }
                }
                if (sent > 0)
                {
                    // success...clear text and save in mru
                    this.tsSendCommandCombo.Text = string.Empty;
                    if (command != null && !string.IsNullOrEmpty(command.Command) && saveHistory)
                    {
                        this.tsSendCommandCombo.Items.Add(command.ToString());
                    }
                }
            }
            return sent;
        }
Exemplo n.º 3
0
        /// <summary>Send commands to open sessions</summary>
        /// <param name="command">The <seealso cref="CommandData"/> object containing text and or keyboard commands</param>
        /// <param name="saveHistory">If True, save the history in the command toolbar combobox</param>
        /// <returns>The number terminals commands have been sent to</returns>
        private int TrySendCommandsFromToolbar(CommandData command, bool saveHistory)
        {
            int sent = 0;

            if(this.DockPanel.Contents.Count > 0)
            {
                foreach (IDockContent doc in VisualOrderTabSwitchStrategy.GetDocuments(this.DockPanel))
                {
                    if (doc is ctlPuttyPanel)
                    {
                        ctlPuttyPanel panel = doc as ctlPuttyPanel;
                        if (this.sendCommandsDocumentSelector.IsDocumentSelected(panel))
                        {
                            int handle = panel.AppPanel.AppWindowHandle.ToInt32();
                            //Log.InfoFormat("SendCommand: session={0}, command=[{1}], handle={2}", panel.Session.SessionId, command, handle);

                            command.SendToTerminal(handle);

                            sent++;                 
                        }
                    }
                }                 

                if (sent > 0)
                {
                    // success...clear text and save in mru                    
                    if (command != null && !string.IsNullOrEmpty(command.Command) && saveHistory)
                    {
                        if (this.InvokeRequired)
                        {
                            this.BeginInvoke((MethodInvoker)delegate {
                                tsCommandHistory.Insert(0, new HistoryEntry() { Command = command.Command });
                            });
                        }
                        else
                        {                            
                            tsCommandHistory.Insert(0, new HistoryEntry() { Command = command.Command });
                        }                       
                    }

                    if (this.InvokeRequired)
                    {
                        this.BeginInvoke((MethodInvoker)delegate {
                            this.tsSendCommandCombo.Text = string.Empty;
                        });
                    }
                    else
                    {
                        this.tsSendCommandCombo.Text = string.Empty;
                    }
                }
            }
            return sent;
        }