TabItem CreateTab(string title, string query, bool switchToNewTab)
        {
            TabItem newTab      = new TabItem();
            Button  closeButton = new Button {
                Style = Resources["CloseButton"] as Style
            };
            TextBlock header = new TextBlock {
                Margin = new Thickness(0, 0, 4, 0), MaxWidth = 120, MinWidth = 40
            };

            newTab.Header = new StackPanel {
                Orientation = Orientation.Horizontal, Children = { header, closeButton }
            };

            closeButton.Click += new RoutedEventHandler(CloseButtonClick);
            closeButton.Tag    = newTab;

            QueryView view;

            newTab.Content = view = new QueryView();

            view.Provider = provider;
            view.Reporter = new ErrorReporter(UpdateErrorList);
            view.SetRange(timeLine.SelectedStartIndex, timeLine.SelectedEndIndex);

            view.CurrentQuery        = query;
            view.ShowQueryItems      = true;
            view.ContextMenuOpening += delegate(object sender, ContextMenuEventArgs e) {
                object source = (e.OriginalSource is Shape) ? e.OriginalSource : view;
                MenuService.ShowContextMenu(view, source, "/AddIns/Profiler/QueryView/ContextMenu");
            };
            view.CurrentQueryChanged += delegate { ViewCurrentQueryChanged(header, view); };

            header.Text         = title;
            header.TextTrimming = TextTrimming.CharacterEllipsis;
            header.TextWrapping = TextWrapping.NoWrap;
            header.ToolTip      = title;
            tabView.Items.Insert(tabView.Items.Count - 1, newTab);
            if (switchToNewTab)
            {
                tabView.SelectedItem = newTab;
            }

            return(newTab);
        }
예제 #2
0
        public ProfilerView(ProfilingDataProvider provider)
        {
            InitializeComponent();
            this.provider = provider;

            this.timeLine.IsEnabled = true;
            this.timeLine.ValuesList.Clear();
            this.timeLine.ValuesList.AddRange(this.provider.DataSets.Select(i => new TimeLineInfo()
            {
                value = i.CpuUsage / 100, displayMarker = i.IsFirst
            }));
            this.timeLine.SelectedStartIndex = 0;
            this.timeLine.SelectedEndIndex   = this.timeLine.ValuesList.Count;

            var translation = new SharpDevelopTranslation();

            foreach (TabItem item in this.tabView.Items)
            {
                if (item.Content != null)
                {
                    QueryView view = item.Content as QueryView;
                    view.Reporter    = new ErrorReporter(UpdateErrorList);
                    view.Provider    = provider;
                    view.Translation = translation;
                    view.SetRange(this.timeLine.SelectedStartIndex, this.timeLine.SelectedEndIndex);
                    view.ContextMenuOpening += delegate(object sender, ContextMenuEventArgs e) {
                        object source = (e.OriginalSource is Shape) ? e.OriginalSource : view;
                        MenuService.CreateContextMenu(source, "/AddIns/Profiler/QueryView/ContextMenu").IsOpen = true;
                    };
                }
            }

            this.dummyTab.Header = new Image {
                Source = PresentationResourceService.GetImage("Icons.16x16.NewDocumentIcon").Source, Height = 16, Width = 16
            };

            this.CommandBindings.Add(new CommandBinding(ApplicationCommands.SelectAll, ExecuteSelectAll, CanExecuteSelectAll));

            InitializeLastItems();
            InitializeOldTabs();
        }