예제 #1
0
        private void Item_Click(object sender, Interactivity.RoutedEventArgs e)
        {
            MenuItem       item    = e.Source as MenuItem;
            OutlookSection section = item.Tag as OutlookSection;

            this.SelectedSection = section;
        }
예제 #2
0
        private void ApplyOverflowMenu()
        {
            ObservableCollection <object> overflowItems = new ObservableCollection <object>();

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

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

            var items = Items.OfType <OutlookSection>().ToList();

            if (items.Count > 0)
            {
                for (int i = visibleButtons; i < items.Count; i++)
                {
                    OutlookSection section = items[i];

                    if (overflowItems.OfType <MenuItem>().Any(x => x.Tag == section))
                    {
                        continue;
                    }

                    if (!separatorAdded)
                    {
                        overflowItems.Add(new Separator());
                        separatorAdded = true;
                    }

                    MenuItem item = new MenuItem();
                    item.Width      = section.Width;
                    item.Header     = section.Header;
                    item.Foreground = new SolidColorBrush(Colors.Red);
                    Image image = new Image();
                    image.Source = section.Image;
                    item.Icon    = image;
                    item.Tag     = section;
                    item.Click  += Item_Click;
                    overflowItems.Add(item);
                }
            }
            //SetValue(OutlookBar.OverflowMenuItemsProperty, overflowItems);

            OverflowMenuItems = overflowItems;
        }
예제 #3
0
        /// <summary>
        /// Occurs when the SelectedSection has changed.
        /// </summary>
        protected virtual void OnSelectedSectionChanged(OutlookSection oldSection, OutlookSection newSection)
        {
            var items = Items.OfType <OutlookSection>().ToList();

            for (int index = 0; index < items.Count; index++)
            {
                OutlookSection section  = items[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));
            //RaiseEvent(new RoutedEventArgs(SelectedSectionChangedEvent));
        }
예제 #4
0
        /// <summary>
        /// applies the sections
        /// </summary>
        protected virtual void ApplySections()
        {
            if (this.IsInitialized)
            {
                _maximizedSections = new ObservableCollection <OutlookSection>();
                _minimizedSections = new ObservableCollection <OutlookSection>();
                int            max             = MaxNumberOfButtons;
                int            index           = 0;
                int            selectedIndex   = SelectedSectionIndex;
                OutlookSection selectedContent = null;

                int n = GetNumberOfMinimizedButtons();

                foreach (OutlookSection e in Items.OfType <OutlookSection>())
                {
                    ((ISetLogicalParent)e).SetParent(null);
                    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;
                    }
                }

                try
                {
                    SetValue(MaximizedSectionsProperty, _maximizedSections);
                }
                catch
                {
                    //already has parent exception
                    InvalidateVisual();
                    InvalidateMeasure();
                    InvalidateArrange();
                }

                try
                {
                    SetValue(MinimizedSectionsProperty, _minimizedSections);
                }
                catch
                {
                    //already has parent exception
                }

                SetValue(SelectedSectionProperty, selectedContent);
            }
        }
예제 #5
0
 private void IsSelectedPropertyChanged(OutlookSection o, AvaloniaPropertyChangedEventArgs e)
 {
     o.OnSelectedPropertyChanged((bool)e.OldValue, (bool)e.NewValue);
 }