internal WindowControlsHeader(DualTabbedLayoutItem item, Window window)
        {
            this.item   = item;
            this.window = window;

            InitializeComponent();

            ImageMinimize.VerticalAlignment      =
                ImageMaximize.VerticalAlignment  =
                    ImageClose.VerticalAlignment =
                        VerticalAlignment.Center;

            ImageMinimize.Width = ImageMaximize.Width = ImageClose.Width = 24;

            ImageMinimize.Cursor = ImageMaximize.Cursor = ImageClose.Cursor = Cursors.Hand;

            ImageMinimize.Source = Icons.GetAppIcon(Icons.DualTabbed_Minimize);
            ImageMaximize.Source = Icons.GetAppIcon(Icons.DualTabbed_Maximize);
            ImageClose.Source    = Icons.GetAppIcon(Icons.DualTabbed_Close);

            RenderOptions.SetBitmapScalingMode(this.ImageMinimize, BitmapScalingMode.HighQuality);
            RenderOptions.SetBitmapScalingMode(this.ImageMaximize, BitmapScalingMode.HighQuality);
            RenderOptions.SetBitmapScalingMode(this.ImageClose, BitmapScalingMode.HighQuality);

            ImageClose.Visibility = item.can_close ? Visibility.Visible : Visibility.Collapsed;

            ImageMinimize.ToolTip = "Minimize window";
            ImageMaximize.ToolTip = "Maximize window";
            ImageClose.ToolTip    = "Close window";

            ImageMinimize.MouseDown += ImageMinimize_MouseDown;
            ImageMaximize.MouseDown += ImageMaximize_MouseDown;
            ImageClose.MouseDown    += ImageClose_MouseDown;
        }
Example #2
0
        private void tab_control_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // This hack is to let the combobox autocomplete not select the Tab...
            if (e.OriginalSource.GetType() != typeof(TabControl))
            {
                return;
            }

            TabControl tab_control = sender as TabControl;

            if (null != tab_control)
            {
                TabItem tab_item = tab_control.SelectedItem as TabItem;
                if (null != tab_item)
                {
                    DualTabbedLayoutItem item = (DualTabbedLayoutItem)tab_item.Tag;
                    //Logging.Info("Newly selected DualTabbedLayoutItem is {0}", item);

                    tab_item.Focus();

                    item.MarkAsRecentlyUsed();

                    if (OnActiveItemChanged != null)
                    {
                        OnActiveItemChanged(item.Content);
                    }
                }
            }

            e.Handled = true;
        }
Example #3
0
        internal void WantsBottom(DualTabbedLayoutItem item)
        {
            last_location = DualTabbedLayoutItem.Location.Bottom;

            ClearTabItem(item, tab_control_left);
            ClearTabItem(item, tab_control_right);
            ClearFloating(item);
            BuildTabItem(item, tab_control_bottom);
        }
Example #4
0
        void owner_window_Closing(object sender, CancelEventArgs e)
        {
            List <Window> windows = new List <Window>(floating_windows);

            foreach (Window owner_window in windows)
            {
                DualTabbedLayoutItem item = (DualTabbedLayoutItem)owner_window.Tag;
                item.WantsLeft();
            }
        }
Example #5
0
        public FrameworkElement MakeActive(string reference_key)
        {
            DualTabbedLayoutItem item = Find(reference_key, true);

            if (null != item)
            {
                return(item.content);
            }
            else
            {
                return(null);
            }
        }
Example #6
0
        DualTabbedLayoutItem Find(string reference_key, bool make_visible)
        {
            DualTabbedLayoutItem item = null;

            if (null == item)
            {
                item = FindTabItem(reference_key, make_visible);
            }
            if (null == item)
            {
                item = FindFloating(reference_key, make_visible);
            }
            return(item);
        }
Example #7
0
        internal void WantsClose(DualTabbedLayoutItem item)
        {
            // Find the last recently used item the point of focus
            DualTabbedLayoutItem recent_item = null;

            for (int i = recently_used_items.Count - 1; i >= 0; --i)
            {
                if (recently_used_items[i] != item)
                {
                    recent_item = recently_used_items[i];
                    break;
                }
            }

            ClearTabItem(item, tab_control_left);
            ClearTabItem(item, tab_control_right);
            ClearTabItem(item, tab_control_bottom);
            ClearFloating(item);

            // Remove the closing tab item from the recently used list
            for (int i = recently_used_items.Count - 1; i >= 0; --i)
            {
                if (recently_used_items[i] == item)
                {
                    recently_used_items.RemoveAt(i);
                }
            }

            // Dispose the TabItem
            IDisposable disposable = item.content as IDisposable;

            if (null != disposable)
            {
                Logging.Info("Tabbed manager is disposing of window {0}", item.header);
                disposable.Dispose();
            }
            item.content = null;


            // Make the last recently used the current focus
            if (0 < recently_used_items.Count)
            {
                recently_used_items.RemoveAt(recently_used_items.Count - 1);
            }
            if (null != recent_item)
            {
                Find(recent_item.header, true);
            }
        }
Example #8
0
        internal void WantsFloating(DualTabbedLayoutItem item, bool set_last_location)
        {
            if (set_last_location)
            {
                last_location = DualTabbedLayoutItem.Location.Floating;
            }

            ClearTabItem(item, tab_control_left);
            ClearTabItem(item, tab_control_right);
            ClearTabItem(item, tab_control_bottom);

            Window window = BuildFloating(item);

            floating_windows.Add(window);
            window.Show();
        }
        internal ItemHeader(DualTabbedLayoutItem item)
        {
            this.item = item;

            InitializeComponent();

            ImageIcon.VerticalAlignment          =
                TextHeader.VerticalAlignment     =
                    ImageClose.VerticalAlignment =
                        VerticalAlignment.Center;

            ImageIcon.Width      = 20;
            ImageIcon.Source     = item.icon;
            ImageIcon.Visibility = (null != item.icon) ? Visibility.Visible : Visibility.Collapsed;

            RenderOptions.SetBitmapScalingMode(ImageIcon, BitmapScalingMode.HighQuality);

            ImageClose.Width              = 20;
            ImageClose.Source             = Icons.GetAppIcon(Icons.DualTabbed_Close);
            ImageClose.Visibility         = item.can_close ? Visibility.Visible : Visibility.Collapsed;
            ImageClose.ToolTip            = "Close window";
            ImageClose.Cursor             = Cursors.Hand;
            ImageClose.MouseLeftButtonUp += ImageClose_MouseLeftButtonUp;
            ImageClose.MouseEnter        += ImageClose_MouseEnter;
            ImageClose.MouseLeave        += ImageClose_MouseLeave;

            MouseRightButtonUp += ItemHeader_MouseRightButtonUp;

            TextHeader.Text         = item.header;
            TextHeader.ToolTip      = item.header;;
            TextHeader.TextTrimming = TextTrimming.WordEllipsis;
            TextHeader.MaxWidth     = 250;

            if (item.background_color.HasValue && Colors.Transparent != item.background_color.Value)
            {
                Background = new SolidColorBrush(ColorTools.MakeTransparentColor(item.background_color.Value, 64));
            }
        }
Example #10
0
        void BuildTabItem(DualTabbedLayoutItem item, TabControl tab_control)
        {
            TabItem tab_item = new TabItem();

            tab_item.Tag        = item;
            tab_item.Header     = new ItemHeader(item);
            tab_item.Content    = item.content;
            tab_item.Background = ThemeColours.Background_Brush_Blue_Light;
            tab_item.KeyDown   += tab_item_KeyDown;

            tab_item.AllowDrop  = true;
            tab_item.DragEnter += tab_item_DragEnter;
            tab_item.DragOver  += tab_item_DragOver;
            tab_item.Drop      += tab_item_Drop;

            tab_control.Items.Add(tab_item);
            if (1 == tab_control.Items.Count)
            {
                ReevaluateLayout();
            }

            tab_item.IsSelected = true;
        }
Example #11
0
 internal void WantsFloating(DualTabbedLayoutItem item)
 {
     WantsFloating(item, true);
 }
Example #12
0
        public bool Contains(string reference_key)
        {
            DualTabbedLayoutItem item = Find(reference_key, false);

            return(null != item);
        }
Example #13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reference_key">Is used as a unique id for when you want to bring the window to the front, check for uniqueness, etc</param>
        /// <param name="header">The title on the tab header or window</param>
        /// <param name="icon"></param>
        /// <param name="can_close"></param>
        /// <param name="can_floating"></param>
        /// <param name="content"></param>
        public void AddContent(string reference_key, string header, BitmapSource icon, bool can_close, bool can_floating, FrameworkElement content, Color?background_color = null)
        {
            DualTabbedLayoutItem item = new DualTabbedLayoutItem(reference_key, header, icon, can_close, can_floating, content, this, background_color);

            item.WantsLocation(last_location);
        }