Пример #1
0
        protected void cmnDisplay_Opening(object sender, System.ComponentModel.CancelEventArgs e)
        {
            cmnDisplay.Items.Clear();

            if (IsBusyInputting)
            {
                cmnDisplay.Items.Add(new ToolStripMenuItem
                                         ($"Input To {(IsBusyInputtingBy as IIdeComponent)?.ParentIDE.Machine ?? IsBusyInputtingBy}", null, (_s, _e) =>
                {
                    ParentConsoleDevice.ParentWorkplace.MainFormActivate();
                    ParentConsoleDevice.ParentWorkplace.MainFormSelectIDE((IsBusyInputtingBy as IIdeComponent)?.ParentIDE);
                })
                {
                    ToolTipText = $"The Console Device is busy inputting {InputtingForLength} bytes {(IsBusyInputtingBy is IInputPort ? $"for {(IsBusyInputtingBy as IInputPort).InputConverting}" : "")} by {IsBusyInputtingBy}"
                });
                cmnDisplay.Items.Add("-");
            }

            cmnDisplay.Items.Add("Scroll To Begin", null, (_s, _e) =>
            {
                this.BeginInvoke(new Action(() =>
                {
                    rtbDisplay.SelectionStart = 0;
                    rtbDisplay.ScrollToCaret();
                }));
            });
            cmnDisplay.Items.Add("Scroll To The End", null, (_s, _e) =>
            {
                this.BeginInvoke(new Action(() =>
                {
                    rtbDisplay.SelectionStart = rtbDisplay.TextLength;
                    rtbDisplay.ScrollToCaret();
                }));
            });
            cmnDisplay.Items.Add(new ToolStripMenuItem
                                     ("Auto Scroll To The End", null, (_s, _e) =>
            {
                bool isAutoScroll = (_s as ToolStripMenuItem).Checked;
                (_s as ToolStripMenuItem).Checked          = !isAutoScroll;
                ParentConsoleDevice.AutoScrollDisplayToEnd = !isAutoScroll;
            })
            {
                Checked = ParentConsoleDevice.AutoScrollDisplayToEnd
            });
            cmnDisplay.Items.Add("Clear Display", null, (_s, _e) =>
            {
                this.BeginInvoke(new Action(() =>
                {
                    rtbDisplay.Clear();
                }));
            });

            cmnDisplay.Items.Add("-");
            cmnDisplay.Items.Add(new ToolStripMenuItem
                                     ("Color Data Clients", null, (_s, _e) =>
            {
                bool colored = (_s as ToolStripMenuItem).Checked;
                (_s as ToolStripMenuItem).Checked    = !colored;
                ParentConsoleDevice.ColorDataClients = !colored;
            })
            {
                Checked = ParentConsoleDevice.ColorDataClients
            });

            cmnDisplay.Items.Add("-");
            cmnDisplay.Items.Add(new ToolStripMenuItem("Initialized By:")
            {
                Enabled = false
            });
            cmnDisplay.Items.Add(new ToolStripMenuItem
                                     (ParentConsoleDevice.InitializedBy.ToString(), null, (_s, _e) =>
            {
                ParentConsoleDevice.ParentWorkplace.MainFormActivate();
                ParentConsoleDevice.ParentWorkplace.MainFormSelectIDE((ParentConsoleDevice.InitializedBy as IIdeComponent)?.ParentIDE);
            })
            {
                BackColor = System.Drawing.Color.FromArgb(255, 10, 10, 10),
                ForeColor = System.Drawing.Color.White
            });

            if ((DataClients?.Count ?? -1) > 0)
            {
                cmnDisplay.Items.Add("-");
                cmnDisplay.Items.Add(new ToolStripMenuItem("Data Clients:")
                {
                    Enabled = false
                });
                foreach (object key in DataClients.Keys)
                {
                    cmnDisplay.Items.Add(new ToolStripMenuItem
                                             (key.ToString(), null, (_s, _e) =>
                    {
                        ParentConsoleDevice.ParentWorkplace.MainFormActivate();
                        ParentConsoleDevice.ParentWorkplace.MainFormSelectIDE(((_s as ToolStripMenuItem)?.Tag as IIdeComponent)?.ParentIDE);
                    })
                    {
                        Tag       = key,
                        BackColor = System.Drawing.Color.FromArgb(255, 10, 10, 10),
                        ForeColor = DataClientsColors[(int)DataClients[key]]
                    });
                }
                cmnDisplay.Items.Add("Clear Data Clients List", null, (_s, _e) =>
                {
                    this.BeginInvoke(new Action(() =>
                    {
                        ParentConsoleDevice.ClearDataClientsList();
                    }));
                });
            }
        }