private void InitializeOutlookbar() { #region foreach (string strModule in Frm_Main.m_dicFormText2FormTypeName.Keys) { OutlookBarBand outlookShortcutsBand = new OutlookBarBand(strModule); outlookShortcutsBand.SmallImageList = this.imageList; outlookShortcutsBand.LargeImageList = this.imageList; int nImageIndex = 0; foreach (string strItem in Frm_Main.m_dicFormText2FormTypeName[strModule].Keys) { outlookShortcutsBand.Items.Add(new OutlookBarItem(strItem, nImageIndex++)); outlookShortcutsBand.Background = SystemColors.AppWorkspace; outlookShortcutsBand.TextColor = Color.White; } outlookBar1.Bands.Add(outlookShortcutsBand); } #endregion //#endregion outlookBar1.Dock = DockStyle.Fill; outlookBar1.SetCurrentBand(0); outlookBar1.ItemClicked += new OutlookBarItemClickedHandler(OnOutlookBarItemClicked); outlookBar1.ItemDropped += new OutlookBarItemDroppedHandler(OnOutlookBarItemDropped); //outlookBar1.FlatArrowButtons = true; this.panel1.Controls.AddRange(new Control[] { outlookBar1 }); }
protected void RaiseChangedEvent( OutlookBarBand item ) { if( Changed != null ) { Changed( this, new OutlookBarBandEventArgs( item ) ); } }
private void OnOutlookBarItemClicked(OutlookBarBand band, OutlookBarItem item) { switch (item.Text) { #region 销售管理 case "订单管理": Portal.gc.MainDialog.ShowContent("订单管理", typeof(BaseForm)); break; case "客户管理": Portal.gc.MainDialog.ShowContent("客户管理", typeof(BaseForm)); break; case "水票管理": Portal.gc.MainDialog.ShowContent("水票管理", typeof(BaseForm)); break; case "套餐管理": BaseForm dlg = new BaseForm(); dlg.ShowDialog(); break; case "来电记录": Portal.gc.MainDialog.ShowContent("来电记录", typeof(BaseForm)); break; case "送货记录": Portal.gc.MainDialog.ShowContent("送货记录", typeof(BaseForm)); break; #endregion #region 产品库存管理 case "产品管理": Portal.gc.MainDialog.ShowContent("产品管理", typeof(BaseForm)); break; case "库存管理": Portal.gc.MainDialog.ShowContent("库存管理", typeof(BaseForm)); break; #endregion default: break; } }
private void InitializeOutlookbar() { outlookBar1 = new OutlookBar(); #region 销售管理 OutlookBarBand outlookShortcutsBand = new OutlookBarBand("销售管理"); outlookShortcutsBand.SmallImageList = this.imageList; outlookShortcutsBand.LargeImageList = this.imageList; outlookShortcutsBand.Items.Add(new OutlookBarItem(outlookBar1, "订单管理", 0)); outlookShortcutsBand.Items.Add(new OutlookBarItem(outlookBar1, "客户管理", 1)); outlookShortcutsBand.Items.Add(new OutlookBarItem(outlookBar1, "水票管理", 2)); outlookShortcutsBand.Items.Add(new OutlookBarItem(outlookBar1, "套餐管理", 3)); outlookShortcutsBand.Items.Add(new OutlookBarItem(outlookBar1, "今日盘点", 5)); outlookShortcutsBand.Items.Add(new OutlookBarItem(outlookBar1, "来电记录", 6)); outlookShortcutsBand.Items.Add(new OutlookBarItem(outlookBar1, "送货记录", 7)); outlookShortcutsBand.Background = SystemColors.AppWorkspace; outlookShortcutsBand.TextColor = Color.White; outlookBar1.Bands.Add(outlookShortcutsBand); #endregion #region 产品库存管理 OutlookBarBand mystorageBand = new OutlookBarBand("产品库存管理"); mystorageBand.SmallImageList = this.imageList; mystorageBand.LargeImageList = this.imageList; mystorageBand.Items.Add(new OutlookBarItem(outlookBar1, "产品管理", 2)); mystorageBand.Items.Add(new OutlookBarItem(outlookBar1, "库存管理", 3)); mystorageBand.Background = SystemColors.AppWorkspace; mystorageBand.TextColor = Color.White; outlookBar1.Bands.Add(mystorageBand); #endregion outlookBar1.Dock = DockStyle.Fill; outlookBar1.CurrentBand = 1; outlookBar1.ItemClicked += new OutlookBarItemClickedHandler(OnOutlookBarItemClicked); outlookBar1.ItemDropped += new OutlookBarItemDroppedHandler(OnOutlookBarItemDropped); //outlookBar1.FlatArrowButtons = true; this.panel1.Controls.AddRange(new Control[] { outlookBar1 }); }
/// <summary> /// 根据user_id加载菜单项 /// </summary> /// <param name="user_id">登陆的用户ID</param> public void LoadMenuInfo() { foreach (AuthorManager.User.MenuParent parent in AuthorManager.LoginUser.MenuParentList) { OutlookBarBand outlookShortcutsBand = new OutlookBarBand(parent.MenuName); outlookShortcutsBand.LargeImageList = this.mf.imageList; outlookShortcutsBand.SmallImageList = this.mf.imageList; outlookShortcutsBand.Background = Color.White; foreach (AuthorManager.User.MenuParent.MenuChild child in parent.MenuChildList) { OutlookBarItem item = new OutlookBarItem(); item.Text = child.MenuName; item.Tag = child.MenuWindow; item.ImageIndex = child.MenuBmp; outlookShortcutsBand.Items.Add(item); } this.outlookBar.Bands.Add(outlookShortcutsBand); } }
private void OnOutlookBarItemClicked(OutlookBarBand band, OutlookBarItem item) { switch (item.Text) { //case "备件入库": // Portal.gc.MainDialog.ShowContent("备件入库", typeof(FrmPurchase)); // break; //case "备件出库": // Portal.gc.MainDialog.ShowContent("备件出库", typeof(FrmTakeOut)); // break; //case "库存查询": // Portal.gc.MainDialog.ShowContent("库存查询", typeof(FrmStockSearch)); // break; //case "备件信息": // Portal.gc.MainDialog.ShowContent("备件信息", typeof(FrmItemDetail)); // break; //case "数据字典": // new FrmDictionary().Show(); // break; //case "业务报表": // new FrmReports().ShowDialog(); // break; //case "库房管理": // new FrmWareHouse().ShowDialog(); // break; } }
public int IndexOf( OutlookBarBand band ) { return InnerList.IndexOf(band); }
public int Add( OutlookBarBand band ) { if( Contains( band ) ) return -1; return List.Add(band); }
void outlookBar_ItemClicked(OutlookBarBand band, OutlookBarItem item) { if (item.Tag != null) { TreeNodeInfo tNodeInfo = null; tNodeInfo = item.Tag as TreeNodeInfo; if (tNodeInfo != null) { if (tNodeInfo.Remark == "EXE") { RuningEXE(tNodeInfo.FileName, tNodeInfo.WorkingDirectory); } else { MenuToolForm_ItemClicked(tNodeInfo.Tag); } } } }
private void outlookBar_ItemClicked(OutlookBarBand band, OutlookBarItem item) { this.mf.OpenWindows(item.Tag as string); }
Size GetItemSize( Graphics g, OutlookBarBand band, int itemIndex, ItemSizeType itemSizeType ) { Size iconSize = new Size(0,0); Size labelSize = new Size(0,0); if( itemSizeType == ItemSizeType.Icon || itemSizeType == ItemSizeType.All ) { iconSize = GetIconSize( band ); if( itemSizeType == ItemSizeType.Icon ) return iconSize; } if ( itemSizeType == ItemSizeType.Label || itemSizeType == ItemSizeType.All ) { labelSize = GetLabelSize( g, band, itemIndex ); if ( itemSizeType == ItemSizeType.Label ) return labelSize; } if ( itemSizeType == ItemSizeType.All ) { if ( band.IconView == IconView.Small ) { return new Size(iconSize.Width + labelSize.Width + X_SMALLICON_LABEL_OFFSET, iconSize.Height > labelSize.Height?iconSize.Height:labelSize.Height); } else { return new Size( ( iconSize.Width > labelSize.Width ) ? iconSize.Width : labelSize.Width, iconSize.Height + labelSize.Height + Y_LARGEICON_LABEL_OFFSET + Y_LARGEICON_SPACING ); } } return new Size(0,0); }
public Rectangle GetItemRect( Graphics g, OutlookBarBand band, int index, Rectangle targetRect ) { Rectangle rc = GetViewPortRect(); if ( targetRect != Rectangle.Empty ) rc = targetRect; Size itemSize = new Size(0,0); int top = rc.Top; int y = 0; for( int i = 0; i < index; i++ ) { itemSize = GetItemSize( g, band, i, ItemSizeType.All ); top += itemSize.Height; top += ( band.IconView == IconView.Small ) ? Y_SMALLICON_SPACING : Y_LARGEICON_SPACING; if( i == ( firstItem - 1 ) ) { // Subtract the hidden items height y = top - rc.Top; } } itemSize = GetItemSize( g, band, index, ItemSizeType.All ); int margin = ( band.IconView == IconView.Large ) ? LARGE_TOP_MARGIN : SMALL_TOP_MARGIN; // Work with Windows Rect is easier to change settings RECT rcItem = new RECT(); rcItem.left = rc.Left; rcItem.top = top; rcItem.right = rc.Left + itemSize.Width; rcItem.bottom = top + itemSize.Height; // Adjust rectangle rcItem.top -= y; rcItem.bottom -= y; rcItem.top += margin; rcItem.bottom += margin; if( band.IconView == IconView.Small ) { rcItem.left = rc.Left + LEFT_MARGIN; rcItem.right = rc.Right; } // Construct final rectangle Rectangle actualRect = new Rectangle( rcItem.left, rcItem.top, rcItem.right - rcItem.left, rcItem.bottom - rcItem.top); return actualRect; }
private void OnOutlookBarItemDropped(OutlookBarBand band, OutlookBarItem item) { }
private void OnOutlookBarItemClicked(OutlookBarBand band, OutlookBarItem item) { Frm_Main.GetMainForm().ShowContent(item.Text); }
private void InitializeOutlookbar() { this.outlookBar1 = new OutlookBar(); //if (Portal.gc.HasFunction("WareMis")) //{ OutlookBarBand band = new OutlookBarBand("仓库管理"); band.SmallImageList = this.imageList1; band.LargeImageList = this.imageList1; band.Items.Add(new OutlookBarItem("备件入库", 0)); band.Items.Add(new OutlookBarItem("备件出库", 1)); band.Items.Add(new OutlookBarItem("库存查询", 2)); band.Items.Add(new OutlookBarItem("备件信息", 3)); band.Items.Add(new OutlookBarItem("数据字典", 4)); band.Items.Add(new OutlookBarItem("业务报表", 5)); band.Items.Add(new OutlookBarItem("库房管理", 6)); band.Background = SystemColors.AppWorkspace; band.TextColor = Color.White; this.outlookBar1.Bands.Add(band); this.outlookBar1.Dock = DockStyle.Fill; // this.outlookBar1.SetCurrentBand(0); this.outlookBar1.ItemClicked += new OutlookBarItemClickedHandler(this.OnOutlookBarItemClicked); this.outlookBar1.ItemDropped += new OutlookBarItemDroppedHandler(this.OnOutlookBarItemDropped); this.panel1.Controls.AddRange(new Control[] { this.outlookBar1 }); }
Size GetIconSize(OutlookBarBand band) { if ( band.IconView == IconView.Large && band.LargeImageList != null ) return band.LargeImageList.ImageSize; else if ( band.IconView == IconView.Small && band.SmallImageList != null ) return band.SmallImageList.ImageSize; return new Size(0,0); }
Size GetLabelSize(Graphics g, OutlookBarBand band, int itemIndex) { Size textSize = new Size(0,0); if( band.IconView == IconView.Large ) { // Calculate text rectangle including word breaks if needed Rectangle rect = GetViewPortRect(); Rectangle textRect = Rectangle.FromLTRB( rect.Left, rect.Top, rect.Width, rect.Top ); // The TextUtil function is going to call GDI, but the Graphics object // is already being used by GDI+. Pass a null reference so that the TextUtil // function uses the Screen Device to calculate the text size if ( band.Items[itemIndex].Text != null ) { StringFormat format = new StringFormat(); format.LineAlignment = StringAlignment.Center; format.Alignment = StringAlignment.Center; format.Trimming = StringTrimming.Word; SizeF size = g.MeasureString( band.Items[itemIndex].Text, Font, rect.Width, format ); textSize = new Size( (int)(size.Width + 0.5), (int)(size.Height + 0.5) ); /* textSize = TextUtil.GetTextSize( null, band.Items[itemIndex].Text, Font, ref textRect, DrawTextFormatFlags.DT_CALCRECT | DrawTextFormatFlags.DT_CENTER | DrawTextFormatFlags.DT_WORDBREAK ); //*/ } return textSize; } else { // Same as above // Calculate text rectangle single line if ( band.Items[ itemIndex ].Text != null ) { textSize = TextUtil.GetTextSize( null, band.Items[ itemIndex ].Text, Font ); } return textSize; } }
private void InitializeOutlookbar(Sys_UserMaster_usm_Info userInfo) { this._outlookBar = new OutlookBar(); _outlookBar.AnimationSpeed = 0; TreeNodeInfo rootNodeInfo = _parentNode; if (rootNodeInfo == null || rootNodeInfo.TreeNodeInfos == null || rootNodeInfo.TreeNodeInfos.Length == 0) { return; } OutlookBarBand outlookBarBand; OutlookBarItem outlookBarItem; TreeNodeInfo tNodeInfo; for (int i = 0; i < rootNodeInfo.TreeNodeInfos.Length; i++) { tNodeInfo = rootNodeInfo.TreeNodeInfos[i]; outlookBarBand = new OutlookBarBand(tNodeInfo.Text); outlookBarBand.SmallImageList = this.imgLW; outlookBarBand.LargeImageList = this.imgLW; if (tNodeInfo.TreeNodeInfos != null && tNodeInfo.TreeNodeInfos.Length > 0) { for (int j = 0; j < tNodeInfo.TreeNodeInfos.Length; j++) { outlookBarItem = new OutlookBarItem(); outlookBarItem.Text = tNodeInfo.TreeNodeInfos[j].Text; outlookBarItem.Tag = tNodeInfo.TreeNodeInfos[j]; outlookBarItem.ImageIndex = tNodeInfo.TreeNodeInfos[j].ImageIndex; outlookBarBand.Items.Add(outlookBarItem); } } outlookBarBand.Background = this.BackColor; outlookBarBand.TextColor = this.ForeColor; this._outlookBar.Bands.Add(outlookBarBand); } this._outlookBar.Dock = DockStyle.Fill; this._outlookBar.SetCurrentBand(0); this._outlookBar.ItemClicked += new OutlookBarItemClickedHandler(outlookBar_ItemClicked); this.pnlContainer.Controls.AddRange(new Control[] { this._outlookBar }); }
private void DrawItems(Graphics g, Rectangle targetRect, OutlookBarBand drawBand) { // If we don't have any bands just return if ( bands.Count == 0 ) return; Rectangle rc = GetViewPortRect(); OutlookBarBand band = bands[ currentBandIndex ]; if( drawBand != null ) band = drawBand; Debug.Assert(band != null); for ( int i = firstItem; i < band.Items.Count; i++ ) { Rectangle itemRect = GetItemRect( g, band, i, targetRect ); if( itemRect.Top + itemRect.Height > rc.Bottom ) break; else DrawItem( g, i, itemRect, ( i == lastHighlightedItem ), false, targetRect, drawBand ); } }
public OutlookBarBandEventArgs( OutlookBarBand item ) { m_item = item; }
private void DrawItem( Graphics g, int index, Rectangle itemRect, bool hot, bool pressed, Rectangle targetRect, OutlookBarBand drawingBand ) { OutlookBarBand band = bands[ currentBandIndex ]; if( drawingBand != null ) band = drawingBand; Point pt = new Point(0,0); // Set clip region so that we don't draw outside the viewport Rectangle viewPortRect = GetViewPortRect(); if( targetRect != Rectangle.Empty ) viewPortRect = targetRect; Color textColor = band.TextColor; Color backColor = band.Background; Color highLight = band.Background; if( ColorUtil.UsingCustomColor ) { backColor = ColorUtil.VSNetControlColor; highLight = ColorUtil.VSNetControlColor; } if( hot || band.Items[ index ].Checked ) { backColor = ColorUtil.VSNetCheckedColor; highLight = ColorUtil.VSNetBorderColor; } if( pressed ) backColor = ColorUtil.VSNetPressedColor; ImageList imgList = band.Items[ index ].ImageList; Size imageSize = (imgList == null) ? new Size(48,48) : imgList.ImageSize; if( band.IconView == IconView.Large && band.LargeImageList != null ) pt.X = itemRect.Left + ( viewPortRect.Width - imageSize.Width ) / 2; else if ( band.IconView == IconView.Small && band.SmallImageList != null ) pt.X = itemRect.Left + SMALL_ICON_LEFT; pt.Y = itemRect.Top; Rectangle iconRect = new Rectangle( pt, imageSize ); using( Brush b = new SolidBrush( backColor ) ) { iconRect.Inflate( 2, 2 ); if( backgroundBitmap == null && ( hot || band.Items[ index ].Checked ) ) { g.FillRectangle( b, iconRect.Left, iconRect.Top, iconRect.Width, iconRect.Height ); } else { g.FillRectangle( b, iconRect.Left, iconRect.Top, iconRect.Width, iconRect.Height ); } using ( Pen p = new Pen( highLight ) ) { if( backgroundBitmap == null || ( hot || band.Items[ index ].Checked ) ) { g.DrawRectangle( p, iconRect.Left, iconRect.Top, iconRect.Width-1, iconRect.Height-1 ); } } } int imgIndex = band.Items[ index ].ImageIndex; if( imgIndex != -1 && imgList != null && imgIndex < imgList.Images.Count ) { if( hot || band.Items[ index ].Checked ) pt.Offset( -1, -1 ); g.DrawImage( imgList.Images[ imgIndex ], pt ); } if( band.IconView == IconView.Large && band.LargeImageList != null ) { // Draw the label Size textSize = GetLabelSize( g, band, index ); int top = itemRect.Top + imageSize.Height + Y_LARGEICON_LABEL_OFFSET; int left = itemRect.Left + ( viewPortRect.Width - textSize.Width )/2; using( Brush b = new SolidBrush( textColor ) ) { int iHeight = textSize.Height; StringFormat format = new StringFormat(); format.Alignment = StringAlignment.Center; format.LineAlignment = StringAlignment.Center; format.Trimming = StringTrimming.Word; g.DrawString( band.Items[index].Text, Font, b, new Rectangle( itemRect.Left, top, viewPortRect.Width, iHeight ), format ); } } else if ( band.IconView == IconView.Small && band.SmallImageList != null ) { // Draw the label Size labelSize = GetLabelSize(g, band, index); pt.X = pt.X + imageSize.Width + X_SMALLICON_LABEL_OFFSET; pt.Y = itemRect.Top + (itemRect.Height - labelSize.Height)/2; using( Brush b = new SolidBrush( textColor ) ) { g.DrawString( band.Items[index].Text, Font, b, pt ); } } else // draw if no other drawing we have { Size labelSize = GetLabelSize(g, band, index); using( Brush b = new SolidBrush( textColor ) ) { g.DrawString( band.Items[index].Text, Font, b, pt ); } } }
public bool Contains(OutlookBarBand band) { return InnerList.Contains( band ); }
void DrawBandBitmap(IntPtr hDC, OutlookBarBand band, int bandIndex, Rectangle drawingRect) { // Don't do GDI+ calls since you cannot mix them with GDI calls if( !HasChild( bandIndex ) ) { Color cb = band.Background; IntPtr brush = WindowsAPI.CreateSolidBrush(ColorUtil.RGB(cb.R, cb.G, cb.B)); RECT rect; rect.left = drawingRect.Left; rect.top = drawingRect.Top; rect.right = drawingRect.Left + drawingRect.Width; rect.bottom = drawingRect.Top + drawingRect.Height; WindowsAPI.FillRect(hDC, ref rect, brush); WindowsAPI.DeleteObject(brush); } if( HasChild( bandIndex ) ) { // Paint child control into memory device context Control child = bands[bandIndex].ChildControl; bool visible = child.Visible; child.Visible = true; // Change viewport if needed POINT pt = new POINT(); WindowsAPI.SendMessage( child.Handle, (int)Msg.WM_ERASEBKGND, (int)hDC, 0 ); WindowsAPI.SendMessage( child.Handle, (int)Msg.WM_PAINT, (int)hDC, 0 ); if( !visible ) child.Visible = false; } else { DrawItems(Graphics.FromHdc(hDC), drawingRect, bands[bandIndex]); } }
public void Remove( OutlookBarBand band ) { List.Remove( band ); }
private void OnOutlookBarItemDropped(OutlookBarBand band, OutlookBarItem item) { // string message = "Item : " + item.Text + " was dropped"; // MessageBox.Show(message); }
protected void RaiseOnItemRemovedEvent( OutlookBarBand item ) { if( OnItemRemoved != null ) { OnItemRemoved( this, new OutlookBarBandEventArgs( item ) ); } RaiseChangedEvent( item ); }
private void MainToolWindow_Load(object sender, EventArgs e) { OutlookBarBand band = new OutlookBarBand("仓库管理"); band.SmallImageList = this.imageList1; band.LargeImageList = this.imageList1; band.Items.Add(new OutlookBarItem("备件入库1", 0)); band.Items.Add(new OutlookBarItem("备件出库2", 1)); band.Items.Add(new OutlookBarItem("库存查询3", 2)); band.Items.Add(new OutlookBarItem("备件信息4", 3)); band.Items.Add(new OutlookBarItem("数据字典5", 4)); band.Items.Add(new OutlookBarItem("业务报表6", 5)); band.Items.Add(new OutlookBarItem("库房管理7", 6)); band.Background = SystemColors.AppWorkspace; band.TextColor = Color.White; this.outlookBar1.Bands.Add(band); }