当前位置: 首页>>代码示例>>C#>>正文


C# Panel.Invoke方法代码示例

本文整理汇总了C#中System.Windows.Forms.Panel.Invoke方法的典型用法代码示例。如果您正苦于以下问题:C# Panel.Invoke方法的具体用法?C# Panel.Invoke怎么用?C# Panel.Invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.Panel的用法示例。


在下文中一共展示了Panel.Invoke方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddLoaderToPanel

 public static void AddLoaderToPanel(Panel panel, PictureBox loader)
 {
     panel.Invoke((MethodInvoker)delegate
     {
         panel.Controls.Add(loader);
     });
 }
开发者ID:niobos,项目名称:BBox3SagemTool,代码行数:7,代码来源:ThreadUtils.cs

示例2: RemoveLoaderFromPanel

 public static void RemoveLoaderFromPanel(Panel panel, PictureBox loader)
 {
     panel.Invoke((MethodInvoker)delegate
     {
         panel.Controls.Remove(loader);
     });
 }
开发者ID:niobos,项目名称:BBox3SagemTool,代码行数:7,代码来源:ThreadUtils.cs

示例3: setPanelVisibilityFromThread

 /// <summary>
 /// Set panel visibility from within a thread
 /// </summary>
 /// <param name="panel">Panel</param>
 /// <param name="visible">Visible or not</param>
 public static void setPanelVisibilityFromThread(Panel panel, bool visible)
 {
     panel.Invoke((MethodInvoker)delegate
     {
         panel.Visible = visible;
     });
 }
开发者ID:niobos,项目名称:BBox3SagemTool,代码行数:12,代码来源:ThreadUtils.cs

示例4: ChangeInformationPanelMessage

        /// <summary>
        /// Updates the message of an existing panel
        /// </summary>
        /// <param name="informationPanel">Panel to update</param>
        /// <param name="message">Message to display</param>
        public static void ChangeInformationPanelMessage(Panel informationPanel, string message)
        {
            MethodInvoker mi = delegate
            {
                foreach (var label in informationPanel.Controls.OfType<Label>())
                {
                    if (label.Name == "InfoLabel")
                    {
                        label.Text = message;
                    }
                }
            };

            if (informationPanel.InvokeRequired)
            {
                informationPanel.Invoke(mi);
            }
            else
            {
                mi();
            }
        }
开发者ID:NORENBUCH,项目名称:XrmToolBox,代码行数:27,代码来源:InformationPanel.cs

示例5: Task

        private void Task(Panel p1, int i,int count)
        {
            try
            {
                if (p1.InvokeRequired)
                {
                    SetTextCallback d = new SetTextCallback(Task);
                    p1.Invoke(d, new Object[] { p1, i,count });
                }
                else
                {
                    int w = ((PopupContent)panelContainer.Tag).Width;
                    int h = ((PopupContent)panelContainer.Tag).Height;
                    int left = ((PopupContent)panelContainer.Tag).TargetControl.FindForm().Width - w - 20;
                    int top = ((PopupContent)panelContainer.Tag).TargetControl.FindForm().Height - 40;
                    if (p1.Height >= h)
                    {
                        p1.SetBounds(left, top - h,w, h);
                    }
                    else
                    {
                        p1.SetBounds(left, top - i * (int)Convert.ToDouble(h / count), p1.Width, i * (int)Convert.ToDouble(h / count));
                    }

                    if (!p1.Visible)
                    {
                        p1.Show();
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Task函数执行错误");
            }
        }
开发者ID:keep01,项目名称:efwplus_winformframe,代码行数:35,代码来源:Popup.cs

示例6: Shadow

        private void Shadow(Panel p1, int i,int count)
        {
            try
            {
                if (p1.InvokeRequired)
                {
                    SetTextCallback d = new SetTextCallback(Shadow);
                    p1.Invoke(d, new Object[] { p1, i, count });
                }
                else
                {

                    int w = ((PopupContent)panelContainer.Tag).Width;
                    int h = ((PopupContent)panelContainer.Tag).Height;

                    if (p1.Width >= w)
                        p1.Width = w;
                    else
                        p1.Width = i * (int)Convert.ToDouble(w / count);

                    if (p1.Height >= h)
                        p1.Height = h;
                    else
                        p1.Height = i * (int)Convert.ToDouble(h / count);

                    if (!p1.Visible)
                    {
                        p1.Show();
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("ShowPanel函数执行错误");
            }
        }
开发者ID:keep01,项目名称:efwplus_winformframe,代码行数:36,代码来源:Popup.cs

示例7: updatePanel

 private void updatePanel(Panel pnl, bool value)
 {
     if (pnl.InvokeRequired)
     { pnl.Invoke(new panelDelegate(updatePanel), new object[] { pnl, value }); }
     else
     {
         pnl.Visible = value;
     }
 }
开发者ID:keithloughnane,项目名称:Omnipresent,代码行数:9,代码来源:Client.cs

示例8: ClearPanel

        private void ClearPanel(Panel panel)
        {
            //CREATE TITLE LABEL
            MetroLabel title_label = new MetroLabel();
            title_label.Theme = MetroThemeStyle.Dark;
            title_label.ForeColor = Color.White;
            title_label.AutoSize = true;
            title_label.Font = new System.Drawing.Font("Calibri", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            title_label.Location = new System.Drawing.Point(74, 11);
            title_label.Size = new System.Drawing.Size(205, 19);
            title_label.TabIndex = 3;
            title_label.Text = "FACE COMPARISON ONGOING";

            //CREATE LINE SEPARATOR
            MetroLabel separator_label = new MetroLabel();
            separator_label.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            separator_label.Location = new System.Drawing.Point(19, 39);
            separator_label.Size = new System.Drawing.Size(335, 2);
            separator_label.TabIndex = 2;

            //COZ THIS IS NOT ON THE UI THREAD
            if (panel.InvokeRequired)
            {
                //CLEAR THE PANEL
                Action action = () => panel.Controls.Clear();
                panel.Invoke(action);

                //ADD TITLE AND SEPARATOR LINE TO PANEL
                action = () => panel.Controls.AddRange(new Control[] { title_label, separator_label });
                panel.Invoke(action);
            }

            //IF ON UI THREAD::HIGHLY UNLIKELY
            else
            {
                //CLEAR THE PANEL
                panel.Controls.Clear();

                //ADD TITLE AND SEPARATOR LINE TO PANEL
                panel.Controls.AddRange(new Control[] { title_label, separator_label });
            }
        }
开发者ID:nkasozi,项目名称:Nkujukira,代码行数:42,代码来源:MainWindow.cs

示例9: PopulateMods

        // Populate mods panels
        public void PopulateMods()
        {
            List<string> modTypes = new List<string>() { "cars", "tracks", "skins", "misc" };

            foreach (string type in modTypes)
            {
                List<Mod> modList = new List<Mod>();
                int mods = 0;
                if (type == "cars")
                {
                    modList = modCarList;
                }
                else if (type == "tracks")
                {
                    modList = modTrackList;
                }
                else if (type == "skins")
                {
                    modList = modSkinList;
                }
                else if (type == "misc")
                {
                    modList = modMiscList;
                }

                foreach (Mod mod in modList)
                {
                    Panel modPanel = new Panel();
                    modPanel.Size = new Size(860, 61);
                    modPanel.Location = new Point(0, 1 + (modPanel.Height - 1) * mods);
                    modPanel.BorderStyle = BorderStyle.FixedSingle;
                    if (type == "cars")
                    {
                        carsTabPage.Invoke((MethodInvoker)delegate { carsTabPage.Controls.Add(modPanel); });
                        modPanel.MouseHover += delegate { carsTabPage.Focus(); };
                    }
                    else if (type == "tracks")
                    {
                        tracksTabPage.Invoke((MethodInvoker)delegate { tracksTabPage.Controls.Add(modPanel); });
                        modPanel.MouseHover += delegate { tracksTabPage.Focus(); };
                    }
                    else if (type == "skins")
                    {
                        skinsTabPage.Invoke((MethodInvoker)delegate { skinsTabPage.Controls.Add(modPanel); });
                        modPanel.MouseHover += delegate { skinsTabPage.Focus(); };
                    }
                    else if (type == "misc")
                    {
                        skinsTabPage.Invoke((MethodInvoker)delegate { miscTabPage.Controls.Add(modPanel); });
                        modPanel.MouseHover += delegate { miscTabPage.Focus(); };
                    }

                    Label modNameLabel = new Label();
                    modNameLabel.Text = mod.name.ToUpper();
                    modNameLabel.ForeColor = Color.Black;
                    modNameLabel.Location = new Point(0, 0);
                    modNameLabel.Padding = new Padding(4, 10, 0, 0);
                    modNameLabel.AutoSize = true;
                    modNameLabel.Dock = DockStyle.Left;
                    modNameLabel.Font = new Font("Arimo", 12, FontStyle.Bold);
                    modPanel.Invoke((MethodInvoker)delegate { modPanel.Controls.Add(modNameLabel); });

                    Label modVersionLabel = new Label();
                    modVersionLabel.Text = mod.version;
                    modVersionLabel.ForeColor = Color.FromArgb(64, 64, 64);
                    modVersionLabel.Location = new Point(modNameLabel.Width, 0);
                    modVersionLabel.Padding = new Padding(4, 10, 0, 0);
                    modVersionLabel.AutoSize = true;
                    modVersionLabel.Font = new Font("Arimo", 12, FontStyle.Regular);
                    modPanel.Invoke((MethodInvoker)delegate { modPanel.Controls.Add(modVersionLabel); });

                    Label modAuthorLabel = new Label();
                    modAuthorLabel.Text = mod.author;
                    modAuthorLabel.ForeColor = Color.FromArgb(64, 64, 64);
                    modAuthorLabel.Location = new Point(5, modPanel.Height - 20);
                    modAuthorLabel.AutoSize = true;
                    modAuthorLabel.Font = new Font("DejaVu Sans Condensed", 8, FontStyle.Regular);
                    modPanel.Invoke((MethodInvoker)delegate { modPanel.Controls.Add(modAuthorLabel); });

                    Label modDateLabel = new Label();
                    modDateLabel.Text = mod.date;
                    modDateLabel.ForeColor = Color.FromArgb(64, 64, 64);
                    modDateLabel.Location = new Point(20 + modAuthorLabel.Width, modPanel.Height - 20);
                    modDateLabel.AutoSize = true;
                    modDateLabel.Font = new Font("DejaVu Sans Condensed", 8, FontStyle.Regular);
                    modPanel.Invoke((MethodInvoker)delegate { modPanel.Controls.Add(modDateLabel); });

                    Button modDownloadButton = new Button();
                    modDownloadButton.Size = new Size(100, 61);
                    modDownloadButton.ForeColor = Color.Black;
                    modDownloadButton.BackColor = Color.WhiteSmoke;
                    modDownloadButton.UseVisualStyleBackColor = true;
                    modDownloadButton.FlatStyle = FlatStyle.Flat;
                    //modDownloadButton.Dock = DockStyle.Right;
                    modDownloadButton.Location = new Point(759, -1);
                    modDownloadButton.Text = mod.size + " MB";
                    modDownloadButton.Font = new Font("DejaVu Sans Condensed", 10, FontStyle.Regular);
                    modPanel.Invoke((MethodInvoker)delegate { modPanel.Controls.Add(modDownloadButton); });

//.........这里部分代码省略.........
开发者ID:Rauul,项目名称:Stock-Car-Extreme-Launcher-3,代码行数:101,代码来源:Form1.cs

示例10: PopulateNews

        // Populate news panel 
        public void PopulateNews()
        {
            newsPage.Invoke((MethodInvoker)delegate { newsPage.Controls.Remove(loadingNewsLabel); });

            int news = 0;
            foreach (News n in newsList)
            {
                Panel newsPanel = new Panel();
                newsPanel.Size = new Size(865, 61);
                newsPanel.Location = new Point(-1, -1 + (newsPanel.Height - 1) * news);
                newsPanel.BorderStyle = BorderStyle.FixedSingle;
                newsPage.Invoke((MethodInvoker)delegate { newsPage.Controls.Add(newsPanel); });
                newsPanel.MouseHover += delegate { newsPage.Focus(); };

                Label newsTitleLabel = new Label();
                newsTitleLabel.Text = n.title.ToUpper();
                newsTitleLabel.ForeColor = Color.Black;
                newsTitleLabel.Location = new Point(0, 0);
                newsTitleLabel.Padding = new Padding(4, 10, 0, 0);
                newsTitleLabel.AutoSize = true;
                newsTitleLabel.Dock = DockStyle.Left;
                newsTitleLabel.Font = new Font("Arimo", 12, FontStyle.Bold);
                newsPanel.Invoke((MethodInvoker)delegate { newsPanel.Controls.Add(newsTitleLabel); });

                Label newsAuthorLabel = new Label();
                newsAuthorLabel.Text = n.author;
                newsAuthorLabel.ForeColor = Color.FromArgb(64, 64, 64);
                newsAuthorLabel.Location = new Point(5, newsPanel.Height - 20);
                newsAuthorLabel.AutoSize = true;
                newsAuthorLabel.Font = new Font("DejaVu Sans Condensed", 8, FontStyle.Regular);
                newsPanel.Invoke((MethodInvoker)delegate { newsPanel.Controls.Add(newsAuthorLabel); });

                Label newsDateLabel = new Label();
                newsDateLabel.Text = n.date.ToShortDateString();
                newsDateLabel.ForeColor = Color.FromArgb(64, 64, 64);
                newsDateLabel.Location = new Point(20 + newsAuthorLabel.Width, newsPanel.Height - 20);
                newsDateLabel.AutoSize = true;
                newsDateLabel.Font = new Font("DejaVu Sans Condensed", 8, FontStyle.Regular);
                newsPanel.Invoke((MethodInvoker)delegate { newsPanel.Controls.Add(newsDateLabel); });

                Button newsLinkButton = new Button();
                newsLinkButton.Size = new Size(100, 50);
                newsLinkButton.ForeColor = Color.Black;
                newsLinkButton.BackColor = Color.WhiteSmoke;
                newsLinkButton.UseVisualStyleBackColor = false;
                newsLinkButton.Dock = DockStyle.Right;
                newsLinkButton.Text = "Read more...";
                newsLinkButton.Font = new Font("DejaVu Sans Condensed", 10, FontStyle.Regular);
                newsPanel.Invoke((MethodInvoker)delegate { newsPanel.Controls.Add(newsLinkButton); });

                newsLinkButton.Click += delegate { Process.Start(n.link); };



                news++;
            }
        }
开发者ID:Rauul,项目名称:Stock-Car-Extreme-Launcher-3,代码行数:58,代码来源:Form1.cs

示例11: loadDeckFromFile

        public static void loadDeckFromFile(Action<string> buttonClickedCallBack)
        {
            var deckNames = Directory.GetFiles(".").Where(x => x.EndsWith(".jas")).Select(x => x.Substring(2)).ToArray();
            Panel deckAsker = new Panel();

            deckAsker.Size = new Size(500, 200);
            //deckAsker.Location = new Point(Size.Width / 2, (Size.Height / 3) * 2);
            int Y = 0;
            int X = 0;
            int c = 0;
            var g = GUI.showWindow(deckAsker);
            foreach (string name in deckNames)
            {
                c++;
                var xd = new Button();
                xd.Text = name;
                xd.Location = new Point(X, Y);
                Y += xd.Height;
                if (c%8 == 0)
                {
                    X += 80;
                    Y = 0;
                }
                var name1 = name;
                xd.MouseDown += (_, __) =>
                {
                    buttonClickedCallBack(name1);
                    g.close();
                };

                if (deckAsker.InvokeRequired)
                {
                    deckAsker.Invoke(new Action(() =>
                    {
                        deckAsker.Controls.Add(xd);
                    }));
                }
                else
                {
                    deckAsker.Controls.Add(xd);
                }
            }
        }
开发者ID:shtonki,项目名称:cardstone,代码行数:43,代码来源:DeckEditorPanel.cs


注:本文中的System.Windows.Forms.Panel.Invoke方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。