Example #1
0
        private void ApplyOverflowMenu()
        {
            Collection <object> overflowItems = new Collection <object>();

            if (OverflowMenuItems.Count > 0)
            {
                foreach (object item in OverflowMenuItems)
                {
                    overflowItems.Add(item);
                }
            }

            bool separatorAdded = false;
            int  visibleButtons = maximizedSections.Count + (IsMaximized ? minimizedSections.Count : 0);

            for (int i = visibleButtons; i < sections.Count; i++)
            {
                if (!separatorAdded)
                {
                    overflowItems.Add(new Separator());
                    separatorAdded = true;
                }
                OutlookSection section = sections[i];
                MenuItem       item    = new MenuItem();
                item.Header = section.Header;
                Image image = new Image();
                image.Source = section.Image;
                item.Icon    = image;
                item.Tag     = section;
                item.Click  += new RoutedEventHandler(item_Click);
                overflowItems.Add(item);
            }

            SetValue(OutlookBar.OverflowMenuItemsPropertyKey, overflowItems);
        }
Example #2
0
        void item_Click(object sender, RoutedEventArgs e)
        {
            MenuItem       item    = e.OriginalSource as MenuItem;
            OutlookSection section = item.Tag as OutlookSection;

            this.SelectedSection = section;
        }
Example #3
0
 /// <summary>
 /// Occurs when the SelectedSection has changed.
 /// </summary>
 protected virtual void OnSelectedSectionChanged(OutlookSection oldSection, OutlookSection newSection)
 {
     for (int index = 0; index < sections.Count; index++)
     {
         OutlookSection section  = sections[index];
         bool           selected = newSection == section;
         section.IsSelected = newSection == section;
         if (selected)
         {
             SelectedSectionIndex    = index;
             SectionContent          = IsMaximized ? section.Content : null;
             CollapsedSectionContent = IsMaximized ? null : section.Content;
         }
     }
     RaiseEvent(new RoutedPropertyChangedEventArgs <OutlookSection>(oldSection, newSection, SelectedSectionChangedEvent));
 }
Example #4
0
        /// <summary>
        /// Determine the collection of MinimizedSections and MaximizedSections depending on the MaxVisibleButtons Property.
        /// </summary>
        protected virtual void ApplySections()
        {
            if (this.IsInitialized)
            {
                maximizedSections = new Collection <OutlookSection>();
                minimizedSections = new Collection <OutlookSection>();
                int            max             = MaxNumberOfButtons;
                int            index           = 0;
                int            selectedIndex   = SelectedSectionIndex;
                OutlookSection selectedContent = null;

                int n = GetNumberOfMinimizedButtons();

                foreach (OutlookSection e in sections)
                {
                    e.OutlookBar = this;
                    e.Height     = ButtonHeight;
                    if (max-- > 0)
                    {
                        e.IsMaximized = true;
                        maximizedSections.Add(e);
                    }
                    else
                    {
                        e.IsMaximized = false;
                        if (minimizedSections.Count < n)
                        {
                            minimizedSections.Add(e);
                        }
                    }
                    bool selected = index++ == selectedIndex;
                    e.IsSelected = selected;
                    if (selected)
                    {
                        selectedContent = e;
                    }
                }
                SetValue(OutlookBar.MaximizedSectionsPropertyKey, maximizedSections);
                SetValue(OutlookBar.MinimizedSectionsPropertyKey, minimizedSections);
                SelectedSection = selectedContent;
            }
        }