コード例 #1
0
 private void VisitLink(LinkLabel linkLabel, string?linkUrl = null)
 {
     if (WindowsUtility.ShellExecute(this, linkUrl ?? linkLabel.Text))
     {
         linkLabel.Links[0].Visited = true;
     }
 }
コード例 #2
0
        private IList <MdiTab> AddNewTabs(IList <MdiTab> tabs, HashSet <Form> skipForms)
        {
            // RemoveClosedTabs should have gotten rid of any tabs with null AssociatedForms,
            // but filtering them out again just to be sure is safe and quick.
            Dictionary <Form, MdiTab> formToTabMap = tabs.Where(t => t.AssociatedForm != null).ToDictionary(tab => tab.AssociatedForm !);

            bool addedTabs = false;

            foreach (Form form in this.MdiChildren)
            {
                if (IsAvailable(form) && !skipForms.Contains(form) && !formToTabMap.TryGetValue(form, out MdiTab? tab))
                {
                    tab               = new MdiTab(form);
                    tab.Click        += this.Tab_Click;
                    tab.CloseClicked += this.Tab_CloseClicked;

                    if (this.UseFormIconAsNewTabImage && form.Icon != null)
                    {
                        tab.Image = WindowsUtility.GetSmallIconImage(form.Icon);

                        // Note: I originally set tab.ImageTransparentColor = Color.Transparent here,
                        // but that made some white areas in the icons appear transparent even though
                        // they shouldn't have been.  That seems like a .NET bug since icons already
                        // have explicitly transparent areas.
                    }

                    form.FormClosed  += this.ChildForm_FormClosed;
                    form.TextChanged += this.ChildForm_TextChanged;

                    // Add it to the beginning like VS does.  This keeps new tabs from immediately going
                    // into the overflow area when lots of forms are open.  This is also consistent with
                    // how activating a tab from the overflow area moves it to the beginning of the tab list.
                    this.Items.Insert(0, tab);
                    addedTabs = true;
                }
            }

            // Update the tab list if any were added.
            IList <MdiTab> result = addedTabs ? this.GetTabs() : tabs;

            return(result);
        }