Esempio n. 1
0
        void item_Click(object sender, RoutedEventArgs e)
        {
            MenuItem       item    = e.OriginalSource as MenuItem;
            OutlookSection section = item.Tag as OutlookSection;

            this.SelectedSection = section;
        }
Esempio n. 2
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);
        }
Esempio n. 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));
 }
Esempio n. 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;
            }
        }
Esempio n. 5
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));
		}
Esempio n. 6
0
    	public WPF_GUI_Section add_Section(WPF_GUI_Section section)
    	{
    		section.Wpf_Gui = this;
			return (WPF_GUI_Section)this.invokeOnThread(
    			()=>{
    					var outlookSection = new  OutlookSection();    				
    					
    					section.SectionInGui = outlookSection;
						outlookSection.Header = section.Name;
						var stackPanel = outlookSection.add_StackPanel();						
						if (section.IntroText.valid())
						{
							var textBlock = stackPanel.add_TextBlock();
							textBlock.set_Text_Wpf(section.IntroText);
						}
						//section.ContentPanel = stackPanel.add_WrapPanel();						
						section.ContentPanel = stackPanel.add_StackPanel();						
						
						
						if (section.WinFormsCtor.notNull())
						{
							section.WinFormsControl = section.WinFormsCtor();							
						}						
						
						outlookSection.Click+=
							(sender,e)=>{
											if (section.WinFormsControl.notNull())
											{
												WinFormPanel.clear();
												WinFormPanel.add_Control(section.WinFormsControl);												
											}
										};
						
						GUI_OutlookBar.Sections.Add(outlookSection);												
						GuiSections.Add(section);
						return section;
					});
		}