private void DrawItemBut(Graphics g, ODPanelItem item) { //Copied and pasted from OpenDental.UI.Button this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true); Color colorBorder = Color.FromArgb(28, 81, 128); //150,190,210); Color colorDisabledFore = Color.FromArgb(161, 161, 146); Color colorShadow = Color.FromArgb(180, 180, 180); Color colorDarkest = Color.FromArgb(157, 164, 196); Color colorLightest = Color.FromArgb(255, 255, 255); Color colorMain = Color.FromArgb(223, 224, 235); //218,220,235);//200,202,220); Color colorDarkDefault = Color.FromArgb(50, 70, 230); Color colorHoverDark = Color.FromArgb(255, 190, 100); //(255,165,0) is pure orange Color colorHoverLight = Color.FromArgb(255, 210, 130); //(255,223,163) is a fairly light orange //this.OnPaintBackground(p); //Graphics g=p.Graphics; Rectangle recOutline = new Rectangle(item.Location.X, item.Location.Y, item.ItemWidth - 1, _rowHeight - 1); float radius = 4; DrawItemButBackground(g, recOutline, radius, colorDarkest /*colorDarkDefault*/, colorMain, colorLightest); float diagonalLength = (float)Math.Sqrt(recOutline.Height * recOutline.Height + recOutline.Width * recOutline.Width); ////unit vector representing direction of diagonal //float unitvectorx=recOutline.Width/diagonalLength; //float unitvectory=-recOutline.Height/diagonalLength; ////unit vector rotated 90 degrees: //float unitvector90x=-unitvectory; //float unitvector90y=unitvectorx; //float length90=unitvectorx*recOutline.Height/(unitvectorx*unitvector90y-unitvector90x*unitvectory); DrawRoundedRectangle(g, new Pen(colorBorder), recOutline, radius); DrawItemButTextAndImage(g, item); DrawItemButReflection(g, recOutline, radius); }
private void OnClickButton(ODPanelItem itemClick) { ODButtonPanelEventArgs pArgs = new ODButtonPanelEventArgs(SelectedItem, SelectedRow, MouseButtons.Left); if (ItemClickBut != null) { ItemClickBut(this, pArgs); } }
public static int SortYX(ODPanelItem p1,ODPanelItem p2) { if(p1.YPos!=p2.YPos) { return p1.YPos.CompareTo(p2.YPos); } if(p1.ItemOrder!=p2.ItemOrder) { return p1.ItemOrder.CompareTo(p2.ItemOrder); } return p1.Text.CompareTo(p2.Text);//should never happen, only if two buttons are at the same location. }
///<summary>Returns the panel item clicked on. Returns null if no item found.</summary> public ODPanelItem PointToItem(Point loc) { ODPanelItem retVal = null; retVal = ListODPanelItems.Find(item => item.YPos == (loc.Y / _heightRow) && //item is on the clicked row item.Location.X <loc.X && //point is to to the right of the left side item.Location.X + item.ItemWidth> loc.X); //point is the the left of the right side return(retVal); }
private void DrawItemLabel(Graphics g, ODPanelItem item) { RectangleF itemRect = new RectangleF( item.Location.X, item.Location.Y, item.ItemWidth, _heightRow); g.FillRectangle(_brushLabelBackground, itemRect); g.DrawString(item.Text, Font, _brushLabel, itemRect, new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); }
public static int SortYX(ODPanelItem p1, ODPanelItem p2) { if (p1.YPos != p2.YPos) { return(p1.YPos.CompareTo(p2.YPos)); } if (p1.ItemOrder != p2.ItemOrder) { return(p1.ItemOrder.CompareTo(p2.ItemOrder)); } return(p1.Text.CompareTo(p2.Text)); //should never happen, only if two buttons are at the same location. }
///<summary>Draws the text and image</summary> private void DrawItemButTextAndImage(Graphics g, ODPanelItem item) { g.SmoothingMode = SmoothingMode.HighQuality; SolidBrush brushText = new SolidBrush(ForeColor); SolidBrush brushGlow = new SolidBrush(Color.White); StringFormat sf = DrawItemButGetStringFormat(ContentAlignment.MiddleCenter); RectangleF recGlow1; RectangleF recText; recGlow1 = new RectangleF(item.Location.X + .5f, item.Location.Y + .5f, item.ItemWidth, _rowHeight); recText = new RectangleF(item.Location.X, item.Location.Y, item.ItemWidth, _rowHeight); g.DrawString(item.Text, this.Font, brushGlow, recGlow1, sf); g.DrawString(item.Text, this.Font, brushText, recText, sf); brushText.Dispose(); sf.Dispose(); }
private void DrawItemLabel(Graphics g, ODPanelItem item) { Color cBack = Color.White; //FromArgb(224,223,227); Color cText = Color.Black; if (_useBlueTheme) { //TODO: } RectangleF itemRect = new RectangleF( item.Location.X, item.Location.Y, item.ItemWidth, _rowHeight); g.FillRectangle(new SolidBrush(cBack), itemRect); g.DrawString(item.Text, Font, new SolidBrush(cText), itemRect, new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); //TODO, probably tweek this to draw text int he right spot. }
///<summary></summary> protected override void OnDoubleClick(EventArgs e) { base.OnDoubleClick(e); SelectedItem = PointToItem(_pointMouseClick); SelectedRow = _pointMouseClick.Y / _heightRow; //if(SelectedItem!=null) { // OnDoubleClickItem(SelectedItem); // switch(SelectedItem.ItemType) { // case ODPanelItemType.Button: // OnDoubleClickButton(SelectedItem); // break; // case ODPanelItemType.Label: // OnDoubleClickLabel(SelectedItem); // break; // } //} OnRowDoubleClick(_pointMouseClick.Y / _heightRow); }
protected override void OnClick(EventArgs e) { base.OnClick(e); SelectedItem = PointToItem(_pointMouseClick); SelectedRow = _pointMouseClick.Y / _rowHeight; if (SelectedItem != null) { //OnClickItem(SelectedItem); switch (SelectedItem.ItemType) { case ODPanelItemType.Button: OnClickButton(SelectedItem); break; //case ODPanelItemType.Label: // OnClickLabel(SelectedItem); // break; } } //OnRowClick(SelectedRow); }
private void fillPanelQuickButtons() { panelQuickButtons.BeginUpdate(); panelQuickButtons.Items.Clear(); listProcButtonQuicks=ProcButtonQuicks.GetAll(); listProcButtonQuicks.Sort(ProcButtonQuicks.sortYX); ODPanelItem pItem; for(int i=0;i<listProcButtonQuicks.Count;i++) { pItem=new ODPanelItem(); pItem.Text=listProcButtonQuicks[i].Description; pItem.YPos=listProcButtonQuicks[i].YPos; pItem.ItemOrder=listProcButtonQuicks[i].ItemOrder; pItem.ItemType=(listProcButtonQuicks[i].IsLabel?ODPanelItemType.Label:ODPanelItemType.Button); pItem.Tags.Add(listProcButtonQuicks[i]); panelQuickButtons.Items.Add(pItem); } panelQuickButtons.EndUpdate(); }
///<summary></summary> public ODButtonPanelEventArgs(ODPanelItem item, int row, MouseButtons button) { this.item = item; this.row = row; this.button = button; }
private void DrawItemLabel(Graphics g,ODPanelItem item) { Color cBack=Color.White;//FromArgb(224,223,227); Color cText=Color.Black; if(_useBlueTheme) { //TODO: } RectangleF itemRect=new RectangleF( item.Location.X,item.Location.Y, item.ItemWidth,_rowHeight); g.FillRectangle(new SolidBrush(cBack),itemRect); g.DrawString(item.Text,Font,new SolidBrush(cText),itemRect,new StringFormat { Alignment=StringAlignment.Center,LineAlignment=StringAlignment.Center });//TODO, probably tweek this to draw text int he right spot. }
private void DrawItemBut(Graphics g, ODPanelItem odPanelItem) { Rectangle recOutline = new Rectangle(odPanelItem.Location.X, odPanelItem.Location.Y, odPanelItem.ItemWidth - 1, _heightRow - 1); Button.DrawSimpleButton(g, recOutline, odPanelItem.Text, Font); }
private void DrawItemBut(Graphics g,ODPanelItem item) { //Copied and pasted from OpenDental.UI.Button this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer,true); Color colorBorder =Color.FromArgb(28,81,128);//150,190,210); Color colorDisabledFore=Color.FromArgb(161,161,146); Color colorShadow =Color.FromArgb(180,180,180); Color colorDarkest =Color.FromArgb(157,164,196); Color colorLightest =Color.FromArgb(255,255,255); Color colorMain =Color.FromArgb(223,224,235);//218,220,235);//200,202,220); Color colorDarkDefault =Color.FromArgb(50,70,230); Color colorHoverDark =Color.FromArgb(255,190,100);//(255,165,0) is pure orange Color colorHoverLight =Color.FromArgb(255,210,130);//(255,223,163) is a fairly light orange //this.OnPaintBackground(p); //Graphics g=p.Graphics; Rectangle recOutline=new Rectangle(item.Location.X,item.Location.Y,item.ItemWidth-1,_rowHeight-1); float radius=4; DrawItemButBackground(g,recOutline,radius,colorDarkest/*colorDarkDefault*/,colorMain,colorLightest); float diagonalLength=(float)Math.Sqrt(recOutline.Height*recOutline.Height+recOutline.Width*recOutline.Width); ////unit vector representing direction of diagonal //float unitvectorx=recOutline.Width/diagonalLength; //float unitvectory=-recOutline.Height/diagonalLength; ////unit vector rotated 90 degrees: //float unitvector90x=-unitvectory; //float unitvector90y=unitvectorx; //float length90=unitvectorx*recOutline.Height/(unitvectorx*unitvector90y-unitvector90x*unitvectory); DrawRoundedRectangle(g,new Pen(colorBorder),recOutline,radius); DrawItemButTextAndImage(g,item); DrawItemButReflection(g,recOutline,radius); }
///<summary>Draws the text and image</summary> private void DrawItemButTextAndImage(Graphics g,ODPanelItem item) { g.SmoothingMode = SmoothingMode.HighQuality; SolidBrush brushText=new SolidBrush(ForeColor); SolidBrush brushGlow=new SolidBrush(Color.White); StringFormat sf=DrawItemButGetStringFormat(ContentAlignment.MiddleCenter); RectangleF recGlow1; RectangleF recText; recGlow1=new RectangleF(item.Location.X+.5f,item.Location.Y+.5f,item.ItemWidth,_rowHeight); recText=new RectangleF(item.Location.X,item.Location.Y,item.ItemWidth,_rowHeight); g.DrawString(item.Text,this.Font,brushGlow,recGlow1,sf); g.DrawString(item.Text,this.Font,brushText,recText,sf); brushText.Dispose(); sf.Dispose(); }
private void OnClickButton(ODPanelItem itemClick) { ODButtonPanelEventArgs pArgs=new ODButtonPanelEventArgs(SelectedItem,SelectedRow,MouseButtons.Left); if(ItemClickBut!=null) { ItemClickBut(this,pArgs); } }
///<summary></summary> protected override void OnDoubleClick(EventArgs e) { base.OnDoubleClick(e); SelectedItem=PointToItem(_pointMouseClick); SelectedRow=_pointMouseClick.Y/_rowHeight; //if(SelectedItem!=null) { // OnDoubleClickItem(SelectedItem); // switch(SelectedItem.ItemType) { // case ODPanelItemType.Button: // OnDoubleClickButton(SelectedItem); // break; // case ODPanelItemType.Label: // OnDoubleClickLabel(SelectedItem); // break; // } //} OnRowDoubleClick(_pointMouseClick.Y/_rowHeight); }
///<summary></summary> public ODButtonPanelEventArgs(ODPanelItem item,int row,MouseButtons button) { this.item=item; this.row=row; this.button=button; }