Esempio n. 1
0
        private object getHeaderWithCloseButton(TabItem tabitem, string title)
        {
            StackPanel stackPanel      = new StackPanel();
            TextBlock  headerTextblock = new TextBlock();

            headerTextblock.Inlines.Add(title);
            headerTextblock.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            Controls.CloseButton closeButton = getTabItemCloseButton(tabitem);
            stackPanel.Orientation = Orientation.Horizontal;
            stackPanel.Children.Add(headerTextblock);
            stackPanel.Children.Add(closeButton);
            return(stackPanel);
        }
Esempio n. 2
0
        private Controls.CloseButton getTabItemCloseButton(TabItem tabitem)
        {
            Controls.CloseButton closeButton = new Controls.CloseButton();
            Button buttonCloseTabControl     = closeButton.button_close;

            closeButton.Width  = 10.0;
            closeButton.Height = 10.0;
            buttonCloseTabControl.CommandParameter = tabitem;
            buttonCloseTabControl.Click           += buttonCloseTabControl_Click;
            buttonCloseTabControl.ToolTip          = "Close this tab";
            closeButton.Margin            = new Thickness(5, 0, 0, 0);
            closeButton.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            return(closeButton);
        }
Esempio n. 3
0
        public TabItem addTabControlWithListOfItems(string header, string name, System.Collections.ObjectModel.ObservableCollection <Chapper.Model.Item> source, string iconSource = null, bool showCloseButton = false, string tooltip = null)
        {
            Grid    grid    = new Grid();
            TabItem newItem = new TabItem();

            try
            {
                newItem.Name = name;
            }
            catch
            {
                newItem.Name = "tab" + tabCounter.ToString();
                tabCounter++;
            }
            if (tooltip == null)
            {
                tooltip = header;
            }

            StackPanel headerBlock = new StackPanel();

            headerBlock.Orientation = Orientation.Horizontal;
            headerBlock.ToolTip     = header;
            if (header.Length > 16)
            {
                header = header.Substring(0, 13) + "...";
            }

            if (iconSource != null)
            {
                headerBlock.Orientation = Orientation.Horizontal;
                System.Windows.Controls.Image tabitemImage = new System.Windows.Controls.Image();
                //tabitemImage.Source = System.Windows.Application.Current.Resources[iconSource] as ImageSource;
                tabitemImage.SetResourceReference(System.Windows.Controls.Image.SourceProperty, iconSource);

                if (!string.IsNullOrEmpty(header))
                {
                    tabitemImage.Height = 12.0;
                }
                else
                {
                    tabitemImage.Height = 16.0;
                }
                tabitemImage.Margin = new Thickness(0, 0, 4, 0);
                headerBlock.Children.Add(tabitemImage);
            }

            if (!string.IsNullOrEmpty(header))
            {
                TextBlock headerText = new TextBlock();
                headerText.Text = header;
                headerBlock.Children.Add(headerText);
            }

            if (showCloseButton)
            {
                Controls.CloseButton closeButton = getTabItemCloseButton(newItem);

                headerBlock.Children.Add(closeButton);
            }
            newItem.Header = headerBlock;
            Controls.ListBoxItems listbox = new Controls.ListBoxItems();
            listbox.Name = "lb_" + name;
            listbox.listbox_items.ItemsSource = source;
            source.CollectionChanged         += source_CollectionChanged;
            grid.Children.Add(listbox);
            newItem.Content = grid;
            this.tabControl_main.Items.Add(newItem);
            return(newItem);
        }