Пример #1
0
        private void DisplayTab(UserControl userControl, TabPage tabPage)
        {
            try
            {
                tabPage.Invoke((MethodInvoker) delegate
                {
                    if (!tabPage.Controls.Contains(userControl))
                    {
                        tabPage.Controls.Add(userControl);
                        ResizeTabControl(userControl, tabPage);
                    }
                });
            }
            catch
            {
                if (!tabPage.Controls.Contains(userControl))
                {
                    tabPage.Controls.Add(userControl);
                    ResizeTabControl(userControl, tabPage);
                }
            }

            userControl.Enabled = true;
            userControl.Visible = true;
            userControl.BringToFront();
        }
        private void RemoveProcess(Process p)
        {
            _processes.Remove(p);

            TabPage t = _tabs.Pluck(p.Id);

            t.Invoke((Action <TabPage>)((tab) => tab.Parent.Controls.Remove(tab)), t);
        }
Пример #3
0
 void enableNews()
 {
     if (tabNews.InvokeRequired)
     {
         tabNews.Invoke(new MethodInvoker(() => { enableNews(); }));
     }
     else
     {
     }
 }
Пример #4
0
        public void AddRoom(RoomObjExt room)
        {
            foreach (TabPage tmp in this.tabControl1.TabPages)
            {
                if (tmp.Tag == room)
                {
                    return;
                }
            }
            TabPage tp = new TabPage(room.Name);

            tp.Tag = room;

            ExtendedMessageView emv = new ExtendedMessageView(room);

            emv.Dock = DockStyle.Fill;
            tp.Controls.Add(emv);

            tabControl1.SelectedTab = tp;

            room.Bind();
            room.SetActive();
            this.tabControl1.TabPages.Add(tp);
            selectedTab = tp;
            tp.Select();

            room.NotificationUpdated += (x) =>
            {
                if (!(tp.Tag as RoomObjExt).active)
                {
                    if (x > 0)
                    {
                        string label = room.Name + "(" + x + ")";
                        tp.Invoke(new Action(() => tp.Text = label));
                    }
                }
                else
                {
                    tp.Invoke(new Action(() => tp.Text = room.Name));
                }
            };
        }
Пример #5
0
        public void ReportPluginSetStatus(object callingPluginObj, MinaryLib.Plugin.Status newPluginStatus)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new PluginSetStatusDelegate(this.ReportPluginSetStatus), new object[] { callingPluginObj, newPluginStatus });
                return;
            }

            IPlugin plugin  = null;
            TabPage tabPage = null;

            if (callingPluginObj == null)
            {
                return;
            }

            try
            {
                plugin  = (IPlugin)callingPluginObj;
                tabPage = this.FindTabPageInCatalog(plugin.Config.PluginName);
            }
            catch (Exception ex)
            {
                LogCons.Inst.Write(LogLevel.Error, $"ReportPluginSetStatus(): {ex.ToString()}");
            }

            if (tabPage == null)
            {
                return;
            }
            else if (tabPage.IsHandleCreated == false)
            {
                return;
            }

            var tmpNewPluginStatus = (int)newPluginStatus;
            int oldPluginStatus    = tabPage.ImageIndex;

            // Use method invoker because of cross thread access
            // by startallplugins.
            tabPage.Invoke((MethodInvoker) delegate
            {
                tmpNewPluginStatus = (newPluginStatus >= 0) ? (int)newPluginStatus : (int)MinaryLib.Plugin.Status.NotRunning;
                tabPage.ImageIndex = tmpNewPluginStatus;

                if (oldPluginStatus == tmpNewPluginStatus)
                {
                    return;
                }
            });


            LogCons.Inst.Write(LogLevel.Info, $"{plugin.Config.PluginName} : CurrentState:{oldPluginStatus}, NewState:{tmpNewPluginStatus}");
        }
Пример #6
0
 /// <summary>
 /// Set TabPage text, if required invoke
 /// </summary>
 /// <param name="tabPage">TextBox to set the text</param>
 /// <param name="text">Text to set to TextBox.Text</param>
 public static void Text(TabPage tabPage, string text)
 {
     if (tabPage.InvokeRequired)
     {
         tabPage.Invoke(new Action <TabPage, string>(Text), new object[] { tabPage, text });
     }
     else
     {
         tabPage.Text = text;
     }
 }
Пример #7
0
 /// <summary>
 /// Set TabPage text, if required invoke
 /// </summary>
 /// <param name="tabPage">TextBox to set the text</param>
 /// <param name="imageIndex">ImageIndex to set to TabPage.ImageIndex</param>
 public static void ImageIndex(TabPage tabPage, int imageIndex)
 {
     if (tabPage.InvokeRequired)
     {
         tabPage.Invoke(new Action <TabPage, int>(ImageIndex), new object[] { tabPage, imageIndex });
     }
     else
     {
         tabPage.ImageIndex = imageIndex;
     }
 }
Пример #8
0
        private BlinkBrowser CreateNewTab()
        {
            var tabPage = new TabPage()
            {
                Text = ""
            };
            string _title = "空白页";

            MiniBlinkPinvoke.BlinkBrowser browser = new MiniBlinkPinvoke.BlinkBrowser();
            tabPage.Controls.Add(browser);
            browser.OnCreateViewEvent += BlinkBrowser1_OnCreateViewEvent;

            browser.OnTitleChangeCall += (title) =>
            {
                tabPage.Invoke((EventHandler) delegate
                {
                    _title       = title ?? "空白页";
                    tabPage.Text = title ?? "空白页";
                });
            };
            browser.OnUrlChange2Call += (nowUrl) =>
            {
                tabPage.Invoke((EventHandler) delegate
                {
                    if (tabControl1.SelectedTab == tabPage)
                    {
                        textBox1.Invoke((EventHandler) delegate
                        {
                            textBox1.Text = nowUrl;
                        });
                    }
                });
            };
            browser.Dock = DockStyle.Fill;
            tabPage.Text = _title;
            tabControl1.TabPages.Add(tabPage);
            tabControl1.SelectTab(tabPage);
            return(browser);
        }
Пример #9
0
 private void createFeed()
 {
     this.Invoke(new Action(() => ButtonBuildFeedFeedGroup.Enabled = false));
     if (ListBoxFeedGroup.Items.Count > 0)
     {
         TabPage feedTab = new TabPage();
         feedTab.Text = this.TextBoxFeedGroup.Text + " Feed";
         this.m_Form.Invoke(new Action(() => this.m_Form.TabControl.TabPages.Add(feedTab)));
         FilteredNewsFeedForm.s_FeedGroupsCount = this.m_Number;// TODO:
         this.m_FeedComposer.Build(this.m_FeedBuilder, this.m_Form);
         Feed feed = this.m_FeedBuilder.Control as Feed;
         feed.Dock = DockStyle.Fill;
         feedTab.Invoke(new Action(() => feedTab.Controls.Add(feed)));
         this.m_Form.Invoke(new Action(() => this.m_Form.TabControl.SelectedTab = feedTab));
     }
 }