/// <include file='doc\ToolStripItemTextRenderEventArgs.uex' path='docs/doc[@for="ToolStripItemTextRenderEventArgs.ToolStripItemTextRenderEventArgs"]/*' />
 /// <devdoc>
 /// This class represents all the information to render the winbar
 /// </devdoc>
 public ToolStripItemTextRenderEventArgs(Graphics g, ToolStripItem item, string text, Rectangle textRectangle, Color textColor, Font textFont, TextFormatFlags format) : base(g, item)
 {
     this.text             = text;
     this.textRectangle    = textRectangle;
     this.defaultTextColor = textColor;
     this.textFont         = textFont;
     this.textAlignment    = item.TextAlign;
     this.textFormat       = format;
     textDirection         = item.TextDirection;
 }
 public ToolStripItemTextRenderEventArgs(Graphics g, ToolStripItem item, string text, Rectangle textRectangle, Color textColor, Font textFont, TextFormatFlags format)
     : base(g, item)
 {
     this.text           = text;
     this.text_rectangle = textRectangle;
     this.text_color     = textColor;
     this.text_font      = textFont;
     this.text_format    = format;
     this.text_direction = ToolStripTextDirection.Horizontal;
 }
        /// <include file='doc\ToolStripItemTextRenderEventArgs.uex' path='docs/doc[@for="ToolStripItemTextRenderEventArgs.ToolStripItemTextRenderEventArgs"]/*' />
        /// <devdoc>
        /// This class represents all the information to render the winbar
        /// </devdoc>
        public ToolStripItemTextRenderEventArgs(Graphics g, ToolStripItem item, string text, Rectangle textRectangle, Color textColor, Font textFont, TextFormatFlags format) : base(g, item) {
            this.text = text;
            this.textRectangle = textRectangle;
            this.defaultTextColor = textColor;
            this.textFont = textFont;
            this.textAlignment = item.TextAlign;
            this.textFormat = format;
            textDirection = item.TextDirection;

        }
        public ToolStripItemTextRenderEventArgs(Graphics g, ToolStripItem item, string text, Rectangle textRectangle, Color textColor, Font textFont, ContentAlignment textAlign)
            : base(g, item)
        {
            this.text           = text;
            this.text_rectangle = textRectangle;
            this.text_color     = textColor;
            this.text_font      = textFont;
            this.text_direction = item.TextDirection;

            switch (textAlign)
            {
            case ContentAlignment.BottomCenter:
                this.text_format = TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter;
                break;

            case ContentAlignment.BottomLeft:
                this.text_format = TextFormatFlags.Bottom | TextFormatFlags.Left;
                break;

            case ContentAlignment.BottomRight:
                this.text_format = TextFormatFlags.Bottom | TextFormatFlags.Right;
                break;

            case ContentAlignment.MiddleCenter:
                this.text_format = TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter;
                break;

            case ContentAlignment.MiddleLeft:
            default:
                this.text_format = (TextFormatFlags.VerticalCenter | TextFormatFlags.Left);
                break;

            case ContentAlignment.MiddleRight:
                this.text_format = TextFormatFlags.VerticalCenter | TextFormatFlags.Right;
                break;

            case ContentAlignment.TopCenter:
                this.text_format = TextFormatFlags.Top | TextFormatFlags.HorizontalCenter;
                break;

            case ContentAlignment.TopLeft:
                this.text_format = TextFormatFlags.Top | TextFormatFlags.Left;
                break;

            case ContentAlignment.TopRight:
                this.text_format = TextFormatFlags.Top | TextFormatFlags.Right;
                break;
            }

            if ((Application.KeyboardCapture == null || !ToolStripManager.ActivatedByKeyboard) && !SystemInformation.MenuAccessKeysUnderlined)
            {
                this.text_format |= TextFormatFlags.HidePrefix;
            }
        }
 /// <include file='doc\ToolStripItemTextRenderEventArgs.uex' path='docs/doc[@for="ToolStripItemTextRenderEventArgs.ToolStripItemTextRenderEventArgs"]/*' />
 /// <devdoc>
 /// This class represents all the information to render the winbar
 /// </devdoc>
 public ToolStripItemTextRenderEventArgs(Graphics g, ToolStripItem item, string text, Rectangle textRectangle, Color textColor, Font textFont, ContentAlignment textAlign) : base(g, item) {
     this.text = text;
     this.textRectangle = textRectangle;
     this.defaultTextColor = textColor;
     this.textFont = textFont;
     this.textFormat = ToolStripItemInternalLayout.ContentAlignToTextFormat(textAlign, item.RightToLeft == RightToLeft.Yes); 
     
     // in 2K and XP++ hide underlined &File unless ALT is pressed
     this.textFormat = (item.ShowKeyboardCues) ? textFormat : textFormat | TextFormatFlags.HidePrefix;
     textDirection = item.TextDirection;
 }
        /// <include file='doc\ToolStripItemTextRenderEventArgs.uex' path='docs/doc[@for="ToolStripItemTextRenderEventArgs.ToolStripItemTextRenderEventArgs"]/*' />
        /// <devdoc>
        /// This class represents all the information to render the winbar
        /// </devdoc>
        public ToolStripItemTextRenderEventArgs(Graphics g, ToolStripItem item, string text, Rectangle textRectangle, Color textColor, Font textFont, ContentAlignment textAlign) : base(g, item)
        {
            this.text             = text;
            this.textRectangle    = textRectangle;
            this.defaultTextColor = textColor;
            this.textFont         = textFont;
            this.textFormat       = ToolStripItemInternalLayout.ContentAlignToTextFormat(textAlign, item.RightToLeft == RightToLeft.Yes);

            // in 2K and XP++ hide underlined &File unless ALT is pressed
            this.textFormat = (item.ShowKeyboardCues) ? textFormat : textFormat | TextFormatFlags.HidePrefix;
            textDirection   = item.TextDirection;
        }
示例#7
0
 /// <summary>
 /// Sets the text direction.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="value">The value.</param>
 public static void SetTextDirection(this ToolStrip control, ToolStripTextDirection value)
 {
     if (control.InvokeRequired)
     {
         control.BeginInvoke(new MethodInvoker(() => control.SetTextDirection(value)));
     }
     else
     {
         control.TextDirection = value;
         control.Refresh();
     }
 }
 public ToolStripItemTextRenderEventArgs(Graphics g, ToolStripItem item, string text, Rectangle textRectangle, Color textColor, Font textFont, ContentAlignment textAlign) : base(g, item)
 {
     this.textRectangle    = Rectangle.Empty;
     this.textColor        = SystemColors.ControlText;
     this.textDirection    = ToolStripTextDirection.Horizontal;
     this.defaultTextColor = SystemColors.ControlText;
     this.text             = text;
     this.textRectangle    = textRectangle;
     this.defaultTextColor = textColor;
     this.textFont         = textFont;
     this.textFormat       = ToolStripItemInternalLayout.ContentAlignToTextFormat(textAlign, item.RightToLeft == RightToLeft.Yes);
     this.textFormat       = item.ShowKeyboardCues ? this.textFormat : (this.textFormat | TextFormatFlags.HidePrefix);
     this.textDirection    = item.TextDirection;
 }
 public ToolStripItemTextRenderEventArgs(Graphics g, ToolStripItem item, string text, Rectangle textRectangle, Color textColor, Font textFont, ContentAlignment textAlign) : base(g, item)
 {
     this.textRectangle = Rectangle.Empty;
     this.textColor = SystemColors.ControlText;
     this.textDirection = ToolStripTextDirection.Horizontal;
     this.defaultTextColor = SystemColors.ControlText;
     this.text = text;
     this.textRectangle = textRectangle;
     this.defaultTextColor = textColor;
     this.textFont = textFont;
     this.textFormat = ToolStripItemInternalLayout.ContentAlignToTextFormat(textAlign, item.RightToLeft == RightToLeft.Yes);
     this.textFormat = item.ShowKeyboardCues ? this.textFormat : (this.textFormat | TextFormatFlags.HidePrefix);
     this.textDirection = item.TextDirection;
 }
		public ToolStripItemTextRenderEventArgs (Graphics g, ToolStripItem item, string text, Rectangle textRectangle, Color textColor, Font textFont, ContentAlignment textAlign)
			: base (g, item)
		{
			this.text = text;
			this.text_rectangle = textRectangle;
			this.text_color = textColor;
			this.text_font = textFont;
			this.text_direction = item.TextDirection;

			switch (textAlign) {
				case ContentAlignment.BottomCenter:
					this.text_format = TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter;
					break;
				case ContentAlignment.BottomLeft:
					this.text_format = TextFormatFlags.Bottom | TextFormatFlags.Left;
					break;
				case ContentAlignment.BottomRight:
					this.text_format = TextFormatFlags.Bottom | TextFormatFlags.Right;
					break;
				case ContentAlignment.MiddleCenter:
					this.text_format = TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter;
					break;
				case ContentAlignment.MiddleLeft:
				default:
					this.text_format = (TextFormatFlags.VerticalCenter | TextFormatFlags.Left);
					break;
				case ContentAlignment.MiddleRight:
					this.text_format = TextFormatFlags.VerticalCenter | TextFormatFlags.Right;
					break;
				case ContentAlignment.TopCenter:
					this.text_format = TextFormatFlags.Top | TextFormatFlags.HorizontalCenter;
					break;
				case ContentAlignment.TopLeft:
					this.text_format = TextFormatFlags.Top | TextFormatFlags.Left;
					break;
				case ContentAlignment.TopRight:
					this.text_format = TextFormatFlags.Top | TextFormatFlags.Right;
					break;
			}

			//if ((Application.KeyboardCapture == null || !ToolStripManager.ActivatedByKeyboard) && !SystemInformation.MenuAccessKeysUnderlined)
			//	this.text_format |= TextFormatFlags.HidePrefix;
		}
		protected ToolStripItem (string text, Image image, EventHandler onClick, string name)
		{
			this.alignment = ToolStripItemAlignment.Left;
			this.anchor = AnchorStyles.Left | AnchorStyles.Top;
			this.auto_size = true;
			this.auto_tool_tip = this.DefaultAutoToolTip;
			this.available = true;
			this.back_color = Color.Empty;
			this.background_image_layout = ImageLayout.Tile;
			this.can_select = true;
			this.display_style = this.DefaultDisplayStyle;
			this.dock = DockStyle.None;
			this.enabled = true;
			this.fore_color = Color.Empty;
			this.image = image;
			this.image_align = ContentAlignment.MiddleCenter;
			this.image_index = -1;
			this.image_key = string.Empty;
			this.image_scaling = ToolStripItemImageScaling.SizeToFit;
			this.image_transparent_color = Color.Empty;
			this.margin = this.DefaultMargin;
			this.merge_action = MergeAction.Append;
			this.merge_index = -1;
			this.name = name;
			this.overflow = ToolStripItemOverflow.AsNeeded;
			this.padding = this.DefaultPadding;
			this.placement = ToolStripItemPlacement.None;
			this.right_to_left = RightToLeft.Inherit;
			this.bounds.Size = this.DefaultSize;
			this.text = text;
			this.text_align = ContentAlignment.MiddleCenter;
			this.text_direction = DefaultTextDirection;
			this.text_image_relation = TextImageRelation.ImageBeforeText;
			this.visible = true;

			this.Click += onClick;
			OnLayout (new LayoutEventArgs (null, string.Empty));
		}
示例#12
0
文件: ToolStrip.cs 项目: nekresh/mono
		public ToolStrip (params ToolStripItem[] items) : base ()
		{
			SetStyle (ControlStyles.AllPaintingInWmPaint, true);
			SetStyle (ControlStyles.OptimizedDoubleBuffer, true);
			SetStyle (ControlStyles.Selectable, false);
			SetStyle (ControlStyles.SupportsTransparentBackColor, true);

			this.SuspendLayout ();
			
			this.items = new ToolStripItemCollection (this, items, true);
			this.allow_merge = true;
			base.AutoSize = true;
			this.SetAutoSizeMode (AutoSizeMode.GrowAndShrink);
			this.back_color = Control.DefaultBackColor;
			this.can_overflow = true;
			base.CausesValidation = false;
			this.default_drop_down_direction = ToolStripDropDownDirection.BelowRight;
			this.displayed_items = new ToolStripItemCollection (this, null, true);
			this.Dock = this.DefaultDock;
			base.Font = new Font ("Tahoma", 8.25f);
			this.fore_color = Control.DefaultForeColor;
			this.grip_margin = this.DefaultGripMargin;
			this.grip_style = ToolStripGripStyle.Visible;
			this.image_scaling_size = new Size (16, 16);
			this.layout_style = ToolStripLayoutStyle.HorizontalStackWithOverflow;
			this.orientation = Orientation.Horizontal;
			if (!(this is ToolStripDropDown))
				this.overflow_button = new ToolStripOverflowButton (this);
			this.renderer = null;
			this.render_mode = ToolStripRenderMode.ManagerRenderMode;
			this.show_item_tool_tips = this.DefaultShowItemToolTips;
			base.TabStop = false;
			this.text_direction = ToolStripTextDirection.Horizontal;
			this.ResumeLayout ();
			
			// Register with the ToolStripManager
			ToolStripManager.AddToolStrip (this);
		}
		public ToolStripItemTextRenderEventArgs (Graphics g, ToolStripItem item, string text, Rectangle textRectangle, Color textColor, Font textFont, TextFormatFlags format)
			: base (g, item)
		{
			this.text = text;
			this.text_rectangle = textRectangle;
			this.text_color = textColor;
			this.text_font = textFont;
			this.text_format = format;
			this.text_direction = ToolStripTextDirection.Horizontal;
		}