Inheritance: System.Windows.Controls.TabItem
示例#1
0
        private void AddNewTabByUC(string strUC, string tabHeader)
        {
            if (IsTabExist(tabHeader))
            {
                return;
            }

            Type     type     = this.GetType();
            Assembly assembly = type.Assembly;

            try
            {
                UserControl uc    = (UserControl)assembly.CreateInstance(type.Namespace + ".parts." + strUC);
                BitmapImage image = new BitmapImage(new Uri("images\\logoJovian.png", UriKind.Relative));
                Image       img   = new Image()
                {
                    Source = image, Width = 16, Height = 16, Margin = new Thickness(2, 0, 2, 0)
                };

                TextBlock tb = new TextBlock()
                {
                    Text = tabHeader, TextTrimming = TextTrimming.CharacterEllipsis, TextWrapping = TextWrapping.NoWrap
                };

                Wpf.Controls.TabItem ti = new Wpf.Controls.TabItem()
                {
                    Icon = img, Header = tb, Content = uc
                };
                tabControl.Items.Add(ti);
            }
            catch (Exception)
            {
                MessageBox.Show("不能添加!");
            }
        }
        private System.Windows.Forms.WebBrowser GetCurrentWebBrowser()
        {
            Wpf.Controls.TabItem item = tabControl.SelectedItem as Wpf.Controls.TabItem;
            if (item == null)
            {
                return(null);
            }

            WindowsFormsHost host = item.Content as WindowsFormsHost;

            if (host == null)
            {
                return(null);
            }

            System.Windows.Forms.WebBrowser browser = host.Child as System.Windows.Forms.WebBrowser;
            return(browser);
        }
        void Browser_DocumentTitleChanged(object sender, EventArgs e)
        {
            System.Windows.Forms.WebBrowser browser = sender as System.Windows.Forms.WebBrowser;
            if (browser == null)
            {
                return;
            }

            // update the TabItems's Header property
            Wpf.Controls.TabItem item = tabControl.SelectedItem as Wpf.Controls.TabItem;

            // Add an Icon to the tabItem
            BitmapImage image = new BitmapImage(new Uri("pack://application:,,,/Test;component/Images/ie.ico"));
            Image       img   = new Image();

            img.Source = image;
            img.Width  = 16;
            img.Height = 16;
            img.Margin = new Thickness(2, 0, 2, 0);

            if (item != null)
            {
                item.Icon = img;
            }

            // wrap the header in a textblock, this gives us the  character ellipsis (...) when trimmed
            TextBlock tb = new TextBlock();

            tb.Text         = browser.DocumentTitle;
            tb.TextTrimming = TextTrimming.CharacterEllipsis;
            tb.TextWrapping = TextWrapping.NoWrap;

            if (item != null)
            {
                item.Header = tb;
            }
        }
示例#4
0
        /// <summary>
        /// Show the source code designated by the given name. The view is positioned around
        /// the given coordinates.
        /// </summary>
        /// <param name="name">The name of the artifact to show. Note that the name can
        /// be either a simple name (like "MyClass") or a compound name (like "form:MyForm").
        /// If the simple name is used, then it is assumed that it is either a class, interface
        /// or table, since these share the same namespace.</param>
        /// <param name="sl">The source line where the selection starts.</param>
        /// <param name="sc">The source column where the selection starts.</param>
        /// <param name="el">The source line where the selection ends.</param>
        /// <param name="ec">The source column where the selection ends.</param>
        private async void ShowSourceAt(string name, string language, int sl, int sc, int el, int ec)
        {
            if (Properties.Settings.Default.UseDynamicsProtocol)
            {
                var parts = name.Split(':');

                if (parts.Count() == 2)
                {
                    // Only support class for now.
                    // dynamics://Open/Class/SrsReportRunController/Line/1413/Column/74/ToLine/1415/ToColumn/10
                    string path = string.Format(CultureInfo.InvariantCulture, "dynamics://open/{0}/{1}/Line/{2}/Column/{3}/ToLine/{4}/ToColumn/{5}", "class", parts[1], sl, sc, el, ec);
                    System.Diagnostics.ProcessStartInfo info = new ProcessStartInfo()
                    {
                        CreateNoWindow = true,
                        FileName       = path,
                    };
                    Process.Start(info);
                }

                return;
            }

            // Look for a tab with this name.
            TabControl details = this.DetailsTab;

            foreach (Wpf.Controls.TabItem item in details.Items)
            {
                string id = item.Tag as string;
                if (id == name)
                {
                    // Got it. Go there and set the position.
                    details.SelectedItem = item;
                    var existing = item.Content as SourceEditor;
                    existing.SetPosition(sl, sc, el, ec);
                    return;
                }
            }

            // A new tab needs to be created and the source code fetched.
            var tab = new Wpf.Controls.TabItem()
            {
                Tag    = name,
                Header = new TextBlock()
                {
                    Text = name
                },
                Icon = new Image
                {
                    Source = new BitmapImage(new Uri("images/Hourglass_16x.png", UriKind.Relative)),
                    Width  = 16,
                    Height = 16,
                }
            };

            var sourcePromise = this.GetSourceAsync(name, language);

            SourceEditor editor = null;

            if (language == "X++")
            {
                editor = new XppSourceEditor();
            }
            else if (language == "Python")
            {
                editor = new PythonSourceEditor();
            }
            else if (language == "C#")
            {
                editor = new CSharpSourceEditor();
            }
            else
            {
                editor = new SourceEditor();
            }

            tab.Content = editor;
            details.Items.Add(tab);
            details.SelectedItem = tab;

            var text = await sourcePromise;

            editor.Text = text ?? "No source found for " + name + " in " + language;

            await editor.Dispatcher.BeginInvoke(new Action(delegate { editor.SetPosition(sl, sc, el, ec); }), DispatcherPriority.ApplicationIdle);

            tab.Icon = null;
        }
 public TabItemCancelEventArgs(TabItem item)
 {
     TabItem = item;
 }
 public TabItemEventArgs(TabItem item)
 {
     TabItem = item;
 }