Exemplo n.º 1
0
		private void RefreshMdiList()
		{
            if (this.Parent == null || m_MdiItems == null) return;

			this.Parent.SuspendLayout=true;
			if(m_MdiItems.Count>0)
			{
				foreach(BaseItem item in m_MdiItems)
				{
					item.Tag=null;
					this.Parent.SubItems.Remove(item);
				}
				m_MdiItems.Clear();
			}
			IOwner owner=this.GetOwner() as IOwner;
            if (owner == null || owner.ParentForm == null && !(owner is RibbonBar && ((RibbonBar)owner).IsOverflowRibbon) || !m_Initialized)
			{
				this.Parent.SuspendLayout=false;
				return;
			}

            System.Windows.Forms.Form parentForm = owner.ParentForm;
            if (owner is RibbonBar && ((RibbonBar)owner).IsOverflowRibbon && parentForm==null)
            {
                if (System.Windows.Forms.Form.ActiveForm != null && System.Windows.Forms.Form.ActiveForm.IsMdiChild)
                    parentForm = System.Windows.Forms.Form.ActiveForm;

                if (parentForm == null)
                    return;
            }

			System.Windows.Forms.MdiClient client=owner.GetMdiClient(parentForm);
			if(client==null)
			{
				this.Parent.SuspendLayout=false;
				return;
			}

			int iInsertPosition=this.Parent.SubItems.IndexOf(this)+1;
			bool bFirst=true;
			int count=1;
			foreach(System.Windows.Forms.Form form in client.MdiChildren)
			{
				string text=GetFormText(form.Text,count);
				ButtonItem btn=new ButtonItem("mdi-"+form.Handle,text);
				btn.ShouldSerialize=false;
				btn.ButtonStyle=eButtonStyle.ImageAndText;
				if(bFirst && this.BeginGroup)
					btn.BeginGroup=true;
				bFirst=false;
				btn.Tag=form;
				if(parentForm.ActiveMdiChild==form)
					btn.Checked=true;
				btn.Click+=new EventHandler(this.MdiWindowItemClick);
				btn.SetSystemItem(true);
				//Bitmap img=null;
				if(m_ShowWindowIcons && form.Icon!=null && form.ControlBox)
				{
//					img=new Bitmap(16,16,System.Drawing.Imaging.PixelFormat.Format32bppArgb);
//					Graphics g=Graphics.FromImage(img);
//					g.DrawImage(form.Icon.ToBitmap(),new Rectangle(0,0,16,16));
//					g.Dispose();
//					btn.Image=img;
					btn.Icon=form.Icon.Clone() as System.Drawing.Icon;
				}
				m_MdiItems.Add(btn);
				this.Parent.SubItems.Add(btn,iInsertPosition);
				btn.Visible=form.Visible;
				iInsertPosition++;

				form.TextChanged+=new EventHandler(this.FormTextChanged);
				//btn.DisplayedChanged+=new EventHandler(this.OnMdiItemDisplayedChanged);
				count++;
			}

			this.Parent.SuspendLayout=false;

			if(m_MdiItems.Count>0 && this.ContainerControl is Bar)
				((Bar)this.ContainerControl).RecalcLayout();
		}
Exemplo n.º 2
0
		public void MdiFormAdded(object sender, System.Windows.Forms.ControlEventArgs e)
		{
			IOwner owner=this.GetOwner() as IOwner;
			if(owner==null || owner.ParentForm==null && !(owner is RibbonBar && ((RibbonBar)owner).IsOverflowRibbon) || !m_Initialized)
				return;

            System.Windows.Forms.Form parentForm = owner.ParentForm;
            if (parentForm == null)
            {
                parentForm = ((System.Windows.Forms.Control)sender).Parent as System.Windows.Forms.Form;
            }
			System.Windows.Forms.Form form=e.Control as System.Windows.Forms.Form;

			if(form==null)
			{
				RefreshMdiList();
				return;
			}
            
			int iInsertPosition=this.Parent.SubItems.IndexOf(this)+1;
			if(m_MdiItems.Count>0)
				iInsertPosition=this.Parent.SubItems.IndexOf((BaseItem)m_MdiItems[m_MdiItems.Count-1])+1;

			string text=GetFormText(form.Text,m_MdiItems.Count+1);
			ButtonItem btn=new ButtonItem("mdi-"+form.GetHashCode(),text);
			btn.ShouldSerialize=false;
			btn.ButtonStyle=eButtonStyle.ImageAndText;
			if(m_MdiItems.Count==0 && this.BeginGroup)
				btn.BeginGroup=true;

			btn.Tag=form;
            if (parentForm.ActiveMdiChild == form)
				btn.Checked=true;

			btn.Click+=new EventHandler(this.MdiWindowItemClick);
			btn.SetSystemItem(true);

			if(m_ShowWindowIcons && form.Icon!=null && form.ControlBox)
			{
				btn.Icon=form.Icon.Clone() as System.Drawing.Icon;
			}

			m_MdiItems.Add(btn);
			this.Parent.SubItems.Add(btn,iInsertPosition);
			btn.Visible=form.Visible;

			if(m_CreateMdiChildAccessKeys)
				RefreshMdiItemsText();

			if(this.ContainerControl is Bar)
				((Bar)this.ContainerControl).RecalcLayout();
            else if (this.ContainerControl is ItemControl)
                ((ItemControl)this.ContainerControl).RecalcLayout();

			form.TextChanged+=new EventHandler(this.FormTextChanged);
            form.VisibleChanged+=new EventHandler(this.FormVisibleChanged);
		}
Exemplo n.º 3
0
		private void AddCustomizeItems()
		{
			BaseItem objTmp;
			BaseItem objParent;

			this.SubItems.Clear();

			// Find the right parent item
			/*System.Windows.Forms.Control objCtrl=this.ContainerControl as System.Windows.Forms.Control;
			if(objCtrl is Bar)
			{
				Bar objTlb=objCtrl as Bar;
				if(objTlb.Parent==null)
					objParent=this.Parent;
				else
					objParent=objTlb.Parent;
			}
			else
			{
				objParent=this.Parent;
			}*/
			objParent=this.Parent;

			while(objParent!=null && objParent.SystemItem && !(objParent.SystemItem && objParent is GenericItemContainer))
				objParent=objParent.Parent;

			if(objParent==null)
				return;

			foreach(BaseItem objItem in objParent.SubItems)
			{
				if(!objItem.SystemItem && objItem.CanCustomize)
				{
					objTmp=objItem.Copy();
					objTmp.GlobalItem=false;
					objTmp.ClearClick();
					objTmp.BeginGroup=false;
					objTmp.Enabled=true;
					objTmp.SubItems.Clear();
					objTmp.Tooltip="";
					objTmp.SetIsOnCustomizeMenu(true);
					if(objItem is ButtonItem)
					{
						((ButtonItem)objTmp).HotTrackingStyle=eHotTrackingStyle.Default;
                        if (m_AutoSizeMenuImages && !m_MenuImageSize.IsEmpty && ((ButtonItem)objTmp).ImageSize != m_MenuImageSize)
                        {
                            ((ButtonItem)objTmp).ImageFixedSize = m_MenuImageSize;
                            ((ButtonItem)objTmp).UseSmallImage = true;
                        }
					}
					objTmp.Click+=new System.EventHandler(ShowHideClick);
					objTmp.Tag=objItem;
					this.SubItems.Add(objTmp);
				}
			}
			if(objParent is GenericItemContainer && ((GenericItemContainer)objParent).MoreItems!=null)
			{
				BaseItem objMore=((GenericItemContainer)objParent).MoreItems;
				foreach(BaseItem objItem in objMore.SubItems)
				{
					if(!objItem.SystemItem)
					{
						objTmp=objItem.Copy();
						objTmp.GlobalItem=false;
						objTmp.ClearClick();
						objTmp.BeginGroup=false;
						objTmp.Enabled=true;
						objTmp.SubItems.Clear();
						objTmp.Tooltip="";
						objTmp.SetIsOnCustomizeMenu(true);
						objTmp.Click+=new System.EventHandler(ShowHideClick);
						objTmp.Tag=objItem;
						this.SubItems.Add(objTmp);
					}
				}
			}

			objTmp=null;

			ButtonItem objBtn=null;
			IOwner owner=this.GetOwner() as IOwner;
			if(owner!=null && owner.ShowResetButton)
			{
				// Reset Bar Item
				objBtn=new ButtonItem();
				objBtn.GlobalItem=false;
				objBtn.BeginGroup=true;
				objBtn.Text=m_ResetStr; // "&Reset Bar";
				objBtn.SetIsOnCustomizeMenu(true);
				objBtn.SetSystemItem(true);
				objBtn.Orientation=eOrientation.Horizontal;
				objBtn.Click+=new System.EventHandler(ResetClick);
				this.SubItems.Add(objBtn);
			}
			if(m_CustomizeItemVisible)
			{
				// Customize
				objBtn=new ButtonItem();
				objBtn.GlobalItem=false;
				if(owner==null || owner!=null && !owner.ShowResetButton)
					objBtn.BeginGroup=true;
				objBtn.Text=m_CustomizeStr; //"&Customize...";
				objBtn.SetIsOnCustomizeMenu(true);
				objBtn.SetSystemItem(true);
				objBtn.Click+=new System.EventHandler(CustomizeClick);
				this.SubItems.Add(objBtn);
			}

			m_NeedRecalcSize=false;
		}
Exemplo n.º 4
0
		void IOwnerBarSupport.BarContextMenu(Control bar, MouseEventArgs e)
		{
			if(!ShowCustomizeContextMenu || m_frmCustomize!=null || this.DesignMode)
				return;

			// Create popup menu that lets users hide/show bars...
			m_ContextMenu=new ButtonItem("sys_customizecontextnmenu");
			ButtonItem btn;
			eDotNetBarStyle style=eDotNetBarStyle.OfficeXP;
			if(m_Bars.Count>0)
				style=m_Bars[0].Style;
			m_ContextMenu.Style=style;
			foreach(Bar b in m_Bars)
			{
                if (b.LayoutType == eLayoutType.DockContainer && b.Items.Count == 0) continue;
				// TODO: Menu Merge implementation
				//if(b.CanHide && (!m_ParentForm.IsMdiChild || !b.MergeEnabled ))
				if(b.CanHide && (b.LayoutType==eLayoutType.DockContainer && b.CanCustomize || b.LayoutType!=eLayoutType.DockContainer) && b.Text!="")
				{
					btn=new ButtonItem();
					btn.Text=b.Text;
					btn.Checked=b.Visible || b.AutoHide;
					btn.SetSystemItem(true);
					btn.Tag=b;
					btn.Click+=new System.EventHandler(this.CustomizeItemClick);
					m_ContextMenu.SubItems.Add(btn);
				}
			}
			btn=new ButtonItem("customize");
			if(m_ContextMenu.SubItems.Count>0)
				btn.BeginGroup=true;
			using(LocalizationManager lm=new LocalizationManager(this))
			{
				btn.Text=lm.GetLocalizedString(LocalizationKeys.CustomizeItemCustomize);
			}
			btn.SetSystemItem(true);
			btn.Style=style;
			btn.Click+=new System.EventHandler(this.CustomizeItemClick);
			m_ContextMenu.SubItems.Add(btn);
            OnCustomizeContextMenu(this, (ButtonItem)m_ContextMenu);
			this.RegisterPopup(m_ContextMenu);
			m_ContextMenu.PopupMenu(bar.PointToScreen(new Point(e.X,e.Y)));
		}
Exemplo n.º 5
0
        private void CreateConfigureButton(int y, int height)
		{
			if(!m_ConfigureItemVisible)
				return;

			if(m_ConfigureItem==null)
			{
				LocalizationManager lm=new LocalizationManager(this.GetOwner() as IOwnerLocalize);

				m_ConfigureItem=new ButtonItem();
				m_ConfigureItem.Image=new System.Drawing.Bitmap(typeof(DevComponents.DotNetBar.DotNetBarManager),"SystemImages.NavBarConfigure.png");
                m_ConfigureItem.ImageFixedSize = m_ConfigureItem.Image.Size;
				m_ConfigureItem.Style=m_Style;
				m_ConfigureItem.ShowSubItems=false;
				m_ConfigureItem.SetSystemItem(true);
                m_ConfigureItem.ContainerState = eContainerState.NavigationPane;
				// Add Sub-Items
				ButtonItem item;
				if(m_ConfigureShowHideVisible)
				{
					item=new ButtonItem("sysShowMoreButtons");
					item.Image=new System.Drawing.Bitmap(typeof(DevComponents.DotNetBar.DotNetBarManager),"SystemImages.NavBarShowMore.png");
					item.Text=lm.GetDefaultLocalizedString(LocalizationKeys.NavBarShowMoreButtons);
					item.SetSystemItem(true);
					item.Click+=new EventHandler(this.OnShowMoreButtonsClick);
					m_ConfigureItem.SubItems.Add(item);

					item=new ButtonItem("sysShowFewerButtons");
					item.Image=new System.Drawing.Bitmap(typeof(DevComponents.DotNetBar.DotNetBarManager),"SystemImages.NavBarShowLess.png");
					item.Text=lm.GetDefaultLocalizedString(LocalizationKeys.NavBarShowFewerButtons);
					item.SetSystemItem(true);
					item.Click+=new EventHandler(this.OnShowFewerButtonsClick);
					m_ConfigureItem.SubItems.Add(item);
				}

				if(m_ConfigureNavOptionsVisible)
				{
					item=new ButtonItem("sysNavPaneOptions");
					item.Text=lm.GetDefaultLocalizedString(LocalizationKeys.NavBarOptions);
					item.Click+=new EventHandler(this.OnNavPaneOptionsClick);
					item.SetSystemItem(true);
					m_ConfigureItem.SubItems.Add(item);
				}

				if(m_ConfigureAddRemoveVisible)
				{
					CustomizeItem customize=new CustomizeItem();
					customize.Name="sysNavPaneAddRemove";
					customize.CustomizeItemVisible=false;
					m_ConfigureItem.SubItems.Add(customize);
				}

				m_ConfigureItem.SetParent(this);
				m_ConfigureItem.Click+=new EventHandler(this.ConfigureItemClick);
				m_ConfigureItem.ExpandChange+=new EventHandler(this.ConfigureExpandedChanged);
				m_ConfigureItem.PopupShowing+=new EventHandler(this.ConfigurePopupShowing);
				m_ConfigureItem.PopupSide=ePopupSide.Right;

				lm.Dispose();

				BarBaseControl ctrl=this.ContainerControl as BarBaseControl;
				if(ctrl!=null && ctrl.Font!=null)
					m_ConfigureItem.PopupFont=new Font(ctrl.Font,FontStyle.Regular);
				else
                    m_ConfigureItem.PopupFont = SystemFonts.MenuFont;
			}
			m_ConfigureItem.PopupType=ePopupType.Menu;
			m_ConfigureItem.Displayed=true;
            m_ConfigureItem.HeightInternal = height;
			m_ConfigureItem.RecalcSize();
			m_ConfigureItem.LeftInternal=m_Rect.Right-m_ConfigureItem.WidthInternal;
			m_ConfigureItem.TopInternal=y;
			m_ConfigureItem.HeightInternal=height;
		}
Exemplo n.º 6
0
 private void CreateBackstageBackButton()
 {
     if (_BackstageTab.Tabs.Contains(SysBackstageBackButtonName))
         return;
     ButtonItem back = new ButtonItem(SysBackstageBackButtonName);
     back.ColorTable = eButtonColor.BlueOrb;
     back.Symbol = "\uf060";
     back.Shape = new EllipticalShapeDescriptor();
     back.Click += new EventHandler(BackButtonClick);
     back.FixedSize = new Size(35, 35);
     back.Margin = new Padding(10, 0, 15, 15);
     back.SetSystemItem(true);
     _BackstageTab.Tabs.Insert(0, back);
     back.SetDesignMode(false);
     // Insert top dock panel which is excluded by region but will move the tab content down
     Panel panel = new Panel();
     panel.Dock = DockStyle.Top;
     panel.Name = SysBackstagePanelName;
     _BackstageTab.Controls.Add(panel);
     panel.BringToFront();
 }