Beispiel #1
0
 // the panel hosting the search progress bar is owner drawn - this is handled here
 void statusBar_DrawItem(object sender, System.Windows.Forms.StatusBarDrawItemEventArgs sbdevent)
 {
     if (sbdevent.Panel == this.progressPanel)
     {                                                    // is it us?
         this.progressBarSearch.Bounds = sbdevent.Bounds; // yep - simply adapt size and location
     }
 }
Beispiel #2
0
        private void statusBar_DrawItem(object sender, System.Windows.Forms.StatusBarDrawItemEventArgs sbdevent)
        {
            Graphics  g  = sbdevent.Graphics;
            StatusBar sb = (StatusBar)sender;

            g.DrawString("Clear Log", sb.Font, statusBrush, sbdevent.Bounds.X, sbdevent.Bounds.Y);
        }
Beispiel #3
0
 protected virtual void OnDrawItem(StatusBarDrawItemEventArgs e)
 {
     if (DrawItem != null)
     {
         DrawItem(this, e);
     }
 }
		protected override void OnDrawItem(StatusBarDrawItemEventArgs sbdievent)
		{
			if (sbdievent.Panel is AxStatusBarPanel) {
				((AxStatusBarPanel)sbdievent.Panel).DrawPanel(sbdievent);
			} else {
				base.OnDrawItem(sbdievent);
			}
		}
		//绘制面板的边框.
		protected virtual void DrawBorder(StatusBarDrawItemEventArgs drawEventArgs)
		{
			drawEventArgs.Graphics.DrawRectangle(SystemPens.ControlDark, 
			                                     new Rectangle(drawEventArgs.Bounds.X,
			                                                   drawEventArgs.Bounds.Y,
			                                                   drawEventArgs.Bounds.Width - 1,
			                                                   drawEventArgs.Bounds.Height - 1));
		}
Beispiel #6
0
        protected virtual void OnDrawItem(StatusBarDrawItemEventArgs sbdievent)
        {
            StatusBarDrawItemEventHandler eh = (StatusBarDrawItemEventHandler)(Events [DrawItemEvent]);

            if (eh != null)
            {
                eh(this, sbdievent);
            }
        }
Beispiel #7
0
 protected override void OnDrawItem(StatusBarDrawItemEventArgs e)
 {
     MxStatusBarPanel panel = e.Panel as MxStatusBarPanel;
     if (panel != null)
     {
         panel.DrawPanel(e);
     }
     else
     {
         base.OnDrawItem(e);
     }
 }
Beispiel #8
0
		public void statBar_DrawItem(object sender, StatusBarDrawItemEventArgs sbdevent)
		{
			Graphics g = sbdevent.Graphics;
			StatusBar sb = (StatusBar)sender;
			RectangleF rectf = new RectangleF(sbdevent.Bounds.X, sbdevent.Bounds.Y, sbdevent.Bounds.Width, sbdevent.Bounds.Height);
			bgBrush.Color = sb.BackColor;
			statusPen.Color = sb.BackColor ;
			g.DrawRectangle(this.statusPen, sbdevent.Bounds);
			sbdevent.Graphics.FillRectangle(this.bgBrush , sbdevent.Bounds);
			statusBrushFontBrush.Color = sb.ForeColor;
			g.DrawString( sb.Text , sb.Font, this.statusBrushFontBrush, rectf);
		}
        public void ParentDrawItemHandler(object sender, StatusBarDrawItemEventArgs sbdevent)
        {
            // Only add this once to the parent's control container
            if (isAdded == false)
            {
                this.Parent.Controls.Add(this.progressBar);
                this.isAdded = true;
            }

            // Get the bounds of this panel and copy to the progress bar's bounds
            if (sbdevent.Panel == this)
                progressBar.Bounds = sbdevent.Bounds;
        }
Beispiel #10
0
 private void OnDrawItem(object sender, System.Windows.Forms.StatusBarDrawItemEventArgs e)
 {
     if (e.Panel == iconPanel)
     {
         if (currentLevel == MpeLogLevel.Debug)
         {
             e.Graphics.DrawImage(debugIcon.Image, e.Bounds.Left, e.Bounds.Top, 16, 16);
         }
         else if (currentLevel == MpeLogLevel.Info)
         {
             e.Graphics.DrawImage(infoIcon.Image, e.Bounds.Left, e.Bounds.Top, 16, 16);
         }
     }
 }
Beispiel #11
0
        //<Snippet1>
        private void DrawMyPanel(object sender, System.Windows.Forms.StatusBarDrawItemEventArgs sbdevent)
        {
            // Create a StringFormat object to align text in the panel.
            StringFormat sf = new StringFormat();

            // Format the String of the StatusBarPanel to be centered.
            sf.Alignment     = StringAlignment.Center;
            sf.LineAlignment = StringAlignment.Center;

            // Draw a black background in owner-drawn panel.
            sbdevent.Graphics.FillRectangle(Brushes.Black, sbdevent.Bounds);
            // Draw the current date (short date format) with white text in the control's font.
            sbdevent.Graphics.DrawString(DateTime.Today.ToShortDateString(),
                                         statusBar1.Font, Brushes.White, sbdevent.Bounds, sf);
        }
		public virtual void DrawPanel(StatusBarDrawItemEventArgs drawEventArgs)
		{
			Graphics g = drawEventArgs.Graphics;
			switch (Alignment) {//判断文本的对其方式.
				case HorizontalAlignment.Left:
					sFormat.Alignment = StringAlignment.Near;
					break;
				case HorizontalAlignment.Center:
					sFormat.Alignment = StringAlignment.Center;
					break;
				case HorizontalAlignment.Right:
					sFormat.Alignment = StringAlignment.Far;
					break;
			}
			g.DrawString(Text,
			             drawEventArgs.Font,
			             SystemBrushes.ControlText, 
			             drawEventArgs.Bounds,
			             sFormat);
			DrawBorder(drawEventArgs);
		}
Beispiel #13
0
 internal void OnDrawItemInternal(StatusBarDrawItemEventArgs e)
 {
     OnDrawItem(e);
 }
Beispiel #14
0
 private void statusBar1_DrawItem(object sender, System.Windows.Forms.StatusBarDrawItemEventArgs sbdevent)
 {
     if (sbdevent.Panel.Equals(statusProgressPane))
     {
     }
 }
Beispiel #15
0
 private void Reposition(object sender, StatusBarDrawItemEventArgs sbdevent)
 {
     progressBar.Location =
        new System.Drawing.Point(sbdevent.Bounds.X, sbdevent.Bounds.Y);
     progressBar.Size =
        new System.Drawing.Size(sbdevent.Bounds.Width, sbdevent.Bounds.Height);
     if (this.showProgressBar)
     {
         progressBar.Show();
     }
 }
Beispiel #16
0
		protected virtual void DrawStatusBarPanel (Graphics dc, Rectangle area, int index,
			Brush br_forecolor, StatusBarPanel panel) {
			int border_size = 3; // this is actually const, even if the border style is none
			int icon_width = 16;
			
			area.Height -= border_size;

			DrawStatusBarPanelBackground (dc, area, panel);

			if (panel.Style == StatusBarPanelStyle.OwnerDraw) {
				StatusBarDrawItemEventArgs e = new StatusBarDrawItemEventArgs (
					dc, panel.Parent.Font, area, index, DrawItemState.Default,
					panel, panel.Parent.ForeColor, panel.Parent.BackColor);
				panel.Parent.OnDrawItemInternal (e);
				return;
			}

			string text = panel.Text;
			StringFormat string_format = new StringFormat ();
			string_format.Trimming = StringTrimming.Character;
			string_format.FormatFlags = StringFormatFlags.NoWrap;

			
			if (text != null && text.Length > 0 && text [0] == '\t') {
				string_format.Alignment = StringAlignment.Center;
				text = text.Substring (1);
				if (text [0] == '\t') {
					string_format.Alignment = StringAlignment.Far;
					text = text.Substring (1);
				}
			}

			Rectangle string_rect = Rectangle.Empty;
			int x;
			int len;
			int icon_x = 0;
			int y = (area.Height / 2 - (int) panel.Parent.Font.Size / 2) - 1;

			switch (panel.Alignment) {
			case HorizontalAlignment.Right:
				len = (int) dc.MeasureString (text, panel.Parent.Font).Width;
				x = area.Right - len - 4;
				string_rect = new Rectangle (x, y, 
						area.Right - x - border_size,
						area.Bottom - y - border_size);
				if (panel.Icon != null) {
					icon_x = x - icon_width - 2;
				}
				break;
			case HorizontalAlignment.Center:
				len = (int) dc.MeasureString (text, panel.Parent.Font).Width;
				x = area.Left + ((panel.Width - len) / 2);
				
				string_rect = new Rectangle (x, y, 
						area.Right - x - border_size,
						area.Bottom - y - border_size);

				if (panel.Icon != null) {
					icon_x = x - icon_width - 2;
				}
				break;

				
			default:
				int left = area.Left + border_size;;
				if (panel.Icon != null) {
					icon_x = area.Left + 2;
					left = icon_x + icon_width + 2;
				}

				x = left;
				string_rect = new Rectangle (x, y, 
						area.Right - x - border_size,
						area.Bottom - y - border_size);
				break;
			}

			RectangleF clip_bounds = dc.ClipBounds;
			dc.SetClip (area);
			dc.DrawString (text, panel.Parent.Font, br_forecolor, string_rect, string_format);			
			dc.SetClip (clip_bounds);

			if (panel.Icon != null) {
				dc.DrawIcon (panel.Icon, new Rectangle (icon_x, y, icon_width, icon_width));
			}
		}
Beispiel #17
0
 /// <include file='doc\StatusBar.uex' path='docs/doc[@for="StatusBar.OnDrawItem"]/*' />
 /// <devdoc>
 ///    <para>
 ///       Raises the <see cref='System.Windows.Forms.StatusBar.OnDrawItem'/>
 ///       event.
 ///    </para>
 /// </devdoc>
 protected virtual void OnDrawItem(StatusBarDrawItemEventArgs sbdievent) {
     StatusBarDrawItemEventHandler handler = (StatusBarDrawItemEventHandler)Events[EVENT_SBDRAWITEM];
     if (handler != null) handler(this,sbdievent);
 }
Beispiel #18
0
		protected virtual void OnDrawItem (StatusBarDrawItemEventArgs sbdievent) {
			StatusBarDrawItemEventHandler eh = (StatusBarDrawItemEventHandler)(Events [DrawItemEvent]);
			if (eh != null)
				eh (this, sbdievent);
		}
Beispiel #19
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            if (showPanels == false)
            {
                DrawSimpleText(e, 0, 0, Width, Height, Text);
            }
            else
            {
                int           left  = 0;
                Border3DStyle style = Border3DStyle.Sunken;
                if (panels.Count < 1)
                {
                    int panelWidth;
                    if (sizingGrip == true)
                    {
                        panelWidth = Width - 16;
                    }
                    else
                    {
                        panelWidth = Width;
                    }
                    ControlPaint.DrawBorder3D(g, 0, 2, panelWidth, Height - 2, Border3DStyle.SunkenOuter, Border3DSide.All);
                }
                else
                {
                    for (int i = 0; i < panels.Count; i++)
                    {
                        StatusBarPanel panel    = panels[i];
                        Icon           icon     = panel.Icon;
                        int            textLeft = left;

                        switch (panel.BorderStyle)
                        {
                        case StatusBarPanelBorderStyle.None:
                            style = Border3DStyle.Flat;
                            break;

                        case StatusBarPanelBorderStyle.Raised:
                            style = Border3DStyle.Raised;
                            break;

                        case StatusBarPanelBorderStyle.Sunken:
                            style = Border3DStyle.SunkenOuter;
                            break;
                        }
                        ControlPaint.DrawBorder3D(g, left, 4, panel.Width, Height - 4, style, Border3DSide.All);
                        if (icon != null)
                        {
                            g.DrawIcon(icon, left, (Height - icon.Height) / 2);
                            textLeft += icon.Width;
                        }
                        if (panel.Style == StatusBarPanelStyle.Text)
                        {
                            StringAlignment align = 0;
                            switch (panel.Alignment)
                            {
                            case HorizontalAlignment.Center:
                                align = StringAlignment.Center;
                                break;

                            case HorizontalAlignment.Left:
                                align = StringAlignment.Near;
                                break;

                            case HorizontalAlignment.Right:
                                align = StringAlignment.Far;
                                break;
                            }
                            DrawSimpleText(e, textLeft, 4, left + panel.Width, Height, panel.Text, align);
                        }
                        else
                        {
                            // Owner drawn
                            StatusBarDrawItemEventArgs args = new StatusBarDrawItemEventArgs(g, this.Font, new Rectangle(0, 0, panel.Width, Height), i, DrawItemState.None, panel);
                            OnDrawItem(args);
                        }
                        left += panel.Width + 2;
                    }
                }
            }

            if (sizingGrip == true)
            {
                ControlPaint.DrawSizeGrip(g, BackColor, new Rectangle(Width - 16, Height - 16, Width, Height));
            }
            base.OnPaint(e);
        }
		protected virtual void OnDrawItem(StatusBarDrawItemEventArgs e)
		{
			if (DrawItem != null)
			{
				DrawItem(this, e);
			}
		}
Beispiel #21
0
 protected virtual void OnDrawItem(StatusBarDrawItemEventArgs sbdievent)
 {
     throw null;
 }
        /// <summary>
        /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// statusbardrawitemeventhandler.BeginInvoke(sender, sbdevent, callback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginInvoke(this StatusBarDrawItemEventHandler statusbardrawitemeventhandler, Object sender, StatusBarDrawItemEventArgs sbdevent, AsyncCallback callback)
        {
            if(statusbardrawitemeventhandler == null) throw new ArgumentNullException("statusbardrawitemeventhandler");

            return statusbardrawitemeventhandler.BeginInvoke(sender, sbdevent, callback, null);
        }
Beispiel #23
0
        private void Parent_DrawItem(object sender, StatusBarDrawItemEventArgs sbdevent)
        {
            if (sbdevent.Panel == this)
            {
                sbdevent.DrawBackground();
                if ((this._currentPosition != this._startPoint) && ((this._currentPosition <= this._endPoint) || (this.AnimationStyle == ProgressDisplayStyle.Infinite)))
                {
                    Rectangle bounds = sbdevent.Bounds;
                    float num = ((float) this._currentPosition) / (this._endPoint - this._startPoint);
                    switch (this.AnimationStyle)
                    {
                        case ProgressDisplayStyle.Infinite:
                            bounds.Height = (int) (num * sbdevent.Bounds.Height);
                            bounds.Y += (sbdevent.Bounds.Height - bounds.Height) / 2;
                            bounds.Width = (int) (num * sbdevent.Bounds.Width);
                            bounds.X += (sbdevent.Bounds.Width - bounds.Width) / 2;
                            break;

                        case ProgressDisplayStyle.LeftToRight:
                            bounds.Width = (int) (num * sbdevent.Bounds.Width);
                            break;

                        case ProgressDisplayStyle.RightToLeft:
                            bounds.Width = (int) (num * sbdevent.Bounds.Width);
                            bounds.X += sbdevent.Bounds.Width - bounds.Width;
                            break;

                        case ProgressDisplayStyle.BottomToTop:
                            bounds.Height = (int) (num * sbdevent.Bounds.Height);
                            bounds.Y += sbdevent.Bounds.Height - bounds.Height;
                            break;

                        case ProgressDisplayStyle.TopToBottom:
                            bounds.Height = (int) (num * sbdevent.Bounds.Height);
                            break;
                    }
                    sbdevent.Graphics.FillRectangle(this._progressBrush, bounds);
                    if (this.ShowText)
                    {
                        float num2 = num * 100f;
                        sbdevent.Graphics.DrawString(num2.ToString(), this._textFont, this._textBrush, sbdevent.Bounds);
                    }
                }
            }
        }
Beispiel #24
0
        protected override void OnDrawItem(StatusBarDrawItemEventArgs sbdevent)
        {
            try
            {
                base.OnDrawItem (sbdevent);

                // Create a StringFormat object to align text in the panel.
                StringFormat sf = new StringFormat();

                // Format the String of the StatusBarPanel to be centered.
                sf.LineAlignment = StringAlignment.Center;
                sf.FormatFlags = StringFormatFlags.NoWrap;

                StatusBarPanel panel = (StatusBarPanel)sbdevent.Panel;
                if( panel.Alignment == HorizontalAlignment.Center )
                    sf.Alignment = StringAlignment.Center;
                else if( panel.Alignment == HorizontalAlignment.Left )
                    sf.Alignment = StringAlignment.Near;
                else
                    sf.Alignment = StringAlignment.Far;

                if(panel==_CenterImagePanel)
                {
                    Rectangle rect = sbdevent.Bounds;

                    Graphics g = sbdevent.Graphics;
                    lock(this)
                    {

                        g.FillRectangle(this.backBrush,sbdevent.Bounds.X -2,sbdevent.Bounds.Y,sbdevent.Bounds.Width+2,sbdevent.Bounds.Height);
                        //g.DrawRectangle(SystemPens.ControlDark,rect);

                        g.DrawString("F L E X C O L L A B",this.textFont,textBrush,sbdevent.Bounds,sf);
                    }
                }
                else if(panel==_RightMessagePanel)
                {
                    Rectangle rect = sbdevent.Bounds;

                    Graphics g = sbdevent.Graphics;
                    lock(this)
                    {

                        g.FillRectangle(this.backBrush,sbdevent.Bounds.X -2,sbdevent.Bounds.Y,sbdevent.Bounds.Width+2,sbdevent.Bounds.Height);
                        g.DrawString(_RightMessagePanel.Text,this.textFont,textBrush,sbdevent.Bounds,sf);
                    }
                    comboMood.Left = sbdevent.Bounds.Left  +100;
                    Brush _pen;
                    int cor=100;
                    if(_RightMessagePanel.Text.Trim()=="Connected")
                    {
                        _pen=new SolidBrush(Color.Green);
                        //WebMeeting.Client.ClientUI.getInstance().NetworkStatus(false);
                    }
                    else
                    {
                        _pen=new SolidBrush(Color.Red);
                        //WebMeeting.Client.ClientUI.getInstance().NetworkStatus(true);
                        cor=120;
                    }

                    lock(this)
                    {

                        g.FillEllipse(_pen,this.Right-cor,3,14,14);
                        g.DrawString("",this.textFont,textBrush,comboMood.Left-5, comboMood.Top +10,sf);
                    }

                }
                else if(panel==_RightImagePanel)
                {
                    Rectangle rect = sbdevent.Bounds;

                    Graphics g = sbdevent.Graphics;
                    //g.FillRectangle(this.backBrush,sbdevent.Bounds.X -2,sbdevent.Bounds.Y,sbdevent.Bounds.Width+2,sbdevent.Bounds.Height);
                    //g.DrawRectangle(SystemPens.ControlDark,rect);
                    //System.Drawing.Pen _pen=new Pen(Color.Red);
                    //g.DrawEllipse(_pen,0,0,10,10);
                }
                else
                {

                    //synchButton.Left = sbdevent.Bounds.Right - (synchButton.Width);
                    Rectangle rect = sbdevent.Bounds;
                    Graphics g = sbdevent.Graphics;
                    lock(this)
                    {

                        g.DrawString(panel.Text,this.textFont,this.textBrush,sbdevent.Bounds,sf);
                    }
                }

            }
            catch(Exception ex)
            {
                Trace.WriteLine("Exception at the place of status bar ondraw:"+ex.ToString());
                ex=ex;
            }
        }
Beispiel #25
0
 private void OnDrawItem(object sender, StatusBarDrawItemEventArgs e)
 {
   if (e.Panel == iconPanel)
   {
     e.Graphics.DrawImage(GetIconImage(currentLevel), e.Bounds.Left + 2, e.Bounds.Top, 16, 16);
   }
   else if (e.Panel == progressPanel && progressPanel.Width > 1)
   {
     e.Graphics.DrawRectangle(panelBorderPen, e.Bounds.Left, e.Bounds.Top, e.Bounds.Width - 1, e.Bounds.Height - 1);
     e.Graphics.FillRectangle(progressBrush, e.Bounds.Left + 3, e.Bounds.Top + 3,
                              GetProgressWidth(e.Bounds.Width) - 6, e.Bounds.Height - 6);
   }
   else if (e.Panel == locationPanel && locationPanel.Text.Length > 0)
   {
     e.Graphics.DrawRectangle(panelBorderPen, e.Bounds.Left, e.Bounds.Top, e.Bounds.Width - 1, e.Bounds.Height - 1);
     e.Graphics.DrawString(locationPanel.Text, Font, panelFontBrush, e.Bounds.Left + 2, e.Bounds.Top + 2);
   }
   else if (e.Panel == sizePanel && sizePanel.Text.Length > 0)
   {
     e.Graphics.DrawRectangle(panelBorderPen, e.Bounds.Left, e.Bounds.Top, e.Bounds.Width - 1, e.Bounds.Height - 1);
     e.Graphics.DrawString(sizePanel.Text, Font, panelFontBrush, e.Bounds.Left + 2, e.Bounds.Top + 2);
   }
 }
Beispiel #26
0
        //
        //add the Progress to the StatueBar
        //
        private void statusBar1_DrawItem(object sender, StatusBarDrawItemEventArgs sbdevent)
        {
            barFilePass.Parent = this.statusBar1;
            labelPrecent.Parent = this.statusBar1;
            labelPrecent.BringToFront();
            labelPrecent.AutoSize = true;
            labelPrecent.BackColor = Color.Yellow;

            barFilePass.SetBounds(statusBarPanelWelcome.Width, 2, statusBarPanelFileProgress.Width, this.statusBar1.ClientRectangle.Height - 2);
            labelPrecent.SetBounds(statusBarPanelWelcome.Width + statusBarPanelFileProgress.Width/3, 5, 40, this.statusBar1.ClientRectangle.Height - 3);
        }
Beispiel #27
0
		internal void OnDrawItemInternal (StatusBarDrawItemEventArgs e)
		{
			OnDrawItem (e);
		}
Beispiel #28
0
		protected override void DrawStatusBarPanel( Graphics dc, Rectangle area, int index,
							   Brush br_forecolor, StatusBarPanel panel )
		{
			int border_size = 3; // this is actually const, even if the border style is none
			
			area.Height -= border_size;
			if ( panel.BorderStyle != StatusBarPanelBorderStyle.None )
			{
				Internal_DrawButton( dc, area, BorderColor );
			}
			
			if ( panel.Style == StatusBarPanelStyle.OwnerDraw )
			{
				StatusBarDrawItemEventArgs e = new StatusBarDrawItemEventArgs(
					dc, panel.Parent.Font, area, index, DrawItemState.Default,
					panel, panel.Parent.ForeColor, panel.Parent.BackColor );
				panel.Parent.OnDrawItemInternal( e );
				return;
			}
			
			int left = area.Left;
			if ( panel.Icon != null )
			{
				left += 2;
				dc.DrawIcon( panel.Icon, left, area.Top );
				left += panel.Icon.Width;
			}
			
			if ( panel.Text == String.Empty )
				return;
			
			string text = panel.Text;
			StringFormat string_format = new StringFormat( );
			string_format.Trimming = StringTrimming.Character;
			string_format.FormatFlags = StringFormatFlags.NoWrap;
			
			if ( text[ 0 ] == '\t' )
			{
				string_format.Alignment = StringAlignment.Center;
				text = text.Substring( 1 );
				if ( text[ 0 ] == '\t' )
				{
					string_format.Alignment = StringAlignment.Far;
					text = text.Substring( 1 );
				}
			}
			
			int x = left + border_size;
			int y = border_size + 2;
			Rectangle r = new Rectangle( x, y,
						    area.Right - x - border_size,
						    area.Bottom - y - border_size );
			
			dc.DrawString( text, panel.Parent.Font, br_forecolor, r, string_format );
		}
		/// <summary>
		///
		/// </summary>
		/// <remarks>Getting things set up to actually draw in any custom status panel is surprisingly
		/// difficult. The first problem is, until some magical point, we cannot even figure out who are parent is.
		/// Apart from that, we cannot even find out what our boundary rectangle is. we can find out
		/// the boundary rectangle only when our parent tells us to draw.
		/// kept the nature of this progress bar is that it actually wants to draw on its own agenda, not on the parent's.
		/// Thus, it is up to some other code to somehow get this event to fire so that we can figure out our boundary.
		/// </remarks>
		/// <param name="sender"></param>
		/// <param name="sbdevent"></param>
		public void OnDrawItem(object sender, StatusBarDrawItemEventArgs sbdevent)
		{
			CheckDisposed();

			if (sbdevent.Panel == this)
			{
				m_bounds = sbdevent.Bounds;
				// if we are using visual styles, the progress bar will sometimes overlap the border, so we reduce
				// the size of the progress bar a little
				if (Application.RenderWithVisualStyles)
					m_bounds.Width = m_bounds.Width - SystemInformation.Border3DSize.Width;
				//				System.Diagnostics.Debug.WriteLine("");
				//				System.Diagnostics.Debug.WriteLine("SetBounds");

			}
		}
Beispiel #30
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Handle the DrawItem Event from the parent bar
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="sbdevent"></param>
		/// ------------------------------------------------------------------------------------
		private void HandleDrawItem(object sender, StatusBarDrawItemEventArgs sbdevent)
		{
			if (sbdevent.Panel != this)
				return;

			Rectangle rect = sbdevent.Bounds;
			if (Application.RenderWithVisualStyles)
				rect.Width = rect.Width - SystemInformation.Border3DSize.Width;

			if (m_text.Trim() != string.Empty)
				sbdevent.Graphics.FillRectangle(m_backBrush, rect);

			using (StringFormat sf = new StringFormat())
			{
				sf.Alignment = StringAlignment.Center;
				Rectangle centered = rect;
				centered.Offset(0, (int)(rect.Height - sbdevent.Graphics.MeasureString(m_text, sbdevent.Font).Height) / 2);
				using (SolidBrush brush = new SolidBrush(sbdevent.ForeColor))
				{
					sbdevent.Graphics.DrawString(m_text, sbdevent.Font, brush, centered, sf);
				}
			}
		}
Beispiel #31
0
        private void sbr_DrawItem(object sender, StatusBarDrawItemEventArgs sbdevent)
        {
            var r = sbdevent.Bounds;

            if ( sbdevent.Panel==sbpMain )
            {
                if ( _nStatusProgress!=0 )
                {
                    int nX = (r.Width*_nStatusProgress)/100;
                    sbdevent.Graphics.FillRectangle( SystemBrushes.ControlDark, r.Left, r.Top, r.Left+nX, r.Height );
                    r = new Rectangle( r.Left+nX, r.Top, r.Width-nX, r.Height );
                }

                using ( Brush brBack = new SolidBrush(sbdevent.BackColor) )
                    sbdevent.Graphics.FillRectangle( brBack, r );
                using ( Brush brFore = new SolidBrush(sbdevent.ForeColor) )
                    sbdevent.Graphics.DrawString( sbdevent.Panel.Text, sbdevent.Font, brFore, sbdevent.Bounds );
            }
            else if ( sbdevent.Panel==sbpSpeaker )
            {
                r = vdUsr.ImgHelper.adaptProportionalRect( r, _bmpSpeaker.Width, _bmpSpeaker.Height );
                sbdevent.Graphics.DrawImage( _bmpSpeaker, r, new Rectangle( Point.Empty, r.Size ), GraphicsUnit.Pixel );
            }
        }
Beispiel #32
0
		void bar_DrawItem(object sender, StatusBarDrawItemEventArgs sbdevent)
		{
			if (sbdevent.Panel == this)
			{
				if (Application.RenderWithVisualStyles)
				{
					VisualStyleRenderer renderer = new VisualStyleRenderer(VisualStyleElement.Status.Gripper.Normal);
					Size partSz = renderer.GetPartSize(sbdevent.Graphics, ThemeSizeType.True);
					Rectangle rect = new Rectangle(sbdevent.Bounds.X + (sbdevent.Bounds.Width - partSz.Width),
						sbdevent.Bounds.Y + (sbdevent.Bounds.Height - partSz.Height), partSz.Width, partSz.Height);
					renderer.DrawBackground(sbdevent.Graphics, rect);
				}
				else
				{
					Rectangle rect = new Rectangle(sbdevent.Bounds.X + (sbdevent.Bounds.Width - 16),
						sbdevent.Bounds.Y + (sbdevent.Bounds.Height - 16), 16, 16);
					ControlPaint.DrawSizeGrip(sbdevent.Graphics, sbdevent.BackColor, rect);
				}
			}
		}
 /// <summary>
 /// Draws the status bar
 /// </summary>
 /// <param name="sender">The control that caused it to draw again</param>
 /// <param name="sbdevent">The draw event</param>
 private void sb_DrawItem(object sender, StatusBarDrawItemEventArgs sbdevent)
 {
     //Find the appropriate panel
     if (sbdevent.Panel == this)
     {
         //Now use GDI to draw the progress bar
         int barWidth =
             (int)(value *
             (double)(sbdevent.Bounds.Width - 2) /
             (double)(maximum - minimum));
         sbdevent.Graphics.FillRectangle(brush,
             sbdevent.Bounds.X + 1, sbdevent.Bounds.Y + 1,
             barWidth, sbdevent.Bounds.Height - 2);
     }
 }
		protected override void OnPaint(PaintEventArgs e)
		{
			if (showPanels == false)
			{
				DrawSimpleText(e, 0, 0, Width, Height, Text);
			}
			else
			{
				int left = 0;
				Border3DStyle style = Border3DStyle.Sunken;
				if (panels.Count <1)
				{
					int panelWidth;
					if (sizingGrip == true)
					{
						panelWidth = Width - 16;
					}
					else
					{
						panelWidth = Width;
					}
					ControlPaint.DrawBorder3D(e.Graphics, 0, 2, panelWidth, Height - 2, Border3DStyle.SunkenOuter, Border3DSide.All);
				}
				else
				{
					for (int i=0;i<panels.Count;i++)
					{
						switch (panels[i].BorderStyle)
						{
							case StatusBarPanelBorderStyle.None:
								style = Border3DStyle.Flat;
								break;
							case StatusBarPanelBorderStyle.Raised:
								style = Border3DStyle.Raised;
								break;
							case StatusBarPanelBorderStyle.Sunken:
								style = Border3DStyle.SunkenOuter;
								break;
						}
						ControlPaint.DrawBorder3D(e.Graphics, left, 4, panels[i].Width, Height -4, style, Border3DSide.All);
						if (panels[i].Style == StatusBarPanelStyle.Text)
						{
							StringAlignment align = 0;
							switch (panels[i].Alignment)
							{
								case HorizontalAlignment.Center:
									align = StringAlignment.Center;
									break;
								case HorizontalAlignment.Left:
									align = StringAlignment.Near;
									break;
								case HorizontalAlignment.Right:
									align = StringAlignment.Far;
									break;
							}							
							DrawSimpleText(e, left, 4, left + panels[i].Width, Height,  panels[i].Text, align);
						}
						else
						{
							// Owner drawn
							StatusBarDrawItemEventArgs args = new StatusBarDrawItemEventArgs(e.Graphics, this.Font, new Rectangle(0, 0, panels[i].Width, Height), i, DrawItemState.None, panels[i]);
							OnDrawItem(args);
						}
						left += panels[i].Width +2;
					}
				}
			}

			if (sizingGrip == true)
			{
				ControlPaint.DrawSizeGrip(e.Graphics, BackColor, new Rectangle(Width - 16, Height - 16, Width, Height));
			}
			base.OnPaint(e);
		}