private void pd_PrintPage(object sender, PrintPageEventArgs ev)
        {
            float linesPerPage = 0;
            float yPos = 0;
            int count = 0;
            float leftMargin = ev.MarginBounds.Left;
            float topMargin = ev.MarginBounds.Top;
            String line = null;
            StringFormat stringFormat = new StringFormat();
            stringFormat.SetTabStops(firstTabOffset, tabStops);

            // Calculate the number of lines per page.
            linesPerPage = ev.MarginBounds.Height /
               printFont.GetHeight(ev.Graphics);

            // Iterate over the file, printing each line.
            while (count < linesPerPage &&
               ((line = streamToPrint.ReadLine()) != null))
            {
                yPos = topMargin + (count * printFont.GetHeight(ev.Graphics));
                ev.Graphics.DrawString(line, printFont, Brushes.Black,
                   leftMargin, yPos, stringFormat);
                count++;
            }

            // If more lines exist, print another page.
            if (line != null)
                ev.HasMorePages = true;
            else
                ev.HasMorePages = false;
        }
        void BeginPrint(object sender, PrintEventArgs ev)
        {
            _currentLine = 0;
              _printingStringFormat = (StringFormat) StringFormat.GenericTypographic.Clone();

              // 100 should be enough for everyone ...err ?
              float[] tabStops = new float[100];
              for (int i = 0; i < tabStops.Length; ++i)
            tabStops[i] = TabIndent * _primaryTextArea.TextArea.TextView.ColumnWidth;

              _printingStringFormat.SetTabStops(0, tabStops);
        }
        private EMFStringFormat(byte[] RecordData)        
        {
            ObjectType = EmfObjectType.stringformat;
            myStringFormat = new System.Drawing.StringFormat();
            //put the Data into a stream and use a binary reader to read the data
            MemoryStream _ms = new MemoryStream(RecordData);
            BinaryReader _br = new BinaryReader(_ms);           
            _br.ReadUInt32(); //Who cares about version..not me!            
            myStringFormat.FormatFlags = (StringFormatFlags)_br.ReadUInt32();
            _br.ReadBytes(4);//Language...Ignore for now!
            myStringFormat.LineAlignment = (StringAlignment)_br.ReadUInt32();
            myStringFormat.Alignment = (StringAlignment)_br.ReadUInt32();
            UInt32 DigitSubstitutionMethod = _br.ReadUInt32();
            UInt32 DigitSubstitutionLanguage = _br.ReadUInt32();
            myStringFormat.SetDigitSubstitution((int)DigitSubstitutionLanguage, (StringDigitSubstitute)DigitSubstitutionMethod);
            
            Single FirstTabOffSet = _br.ReadSingle();

            myStringFormat.HotkeyPrefix = (System.Drawing.Text.HotkeyPrefix) _br.ReadInt32();

             _br.ReadSingle();//leading Margin
             _br.ReadSingle();//trailingMargin           
             _br.ReadSingle();//tracking
            myStringFormat.Trimming = (StringTrimming)_br.ReadUInt32();           
            Int32 TabStopCount = _br.ReadInt32();
            Int32 RangeCount = _br.ReadInt32();
            //Next is stringformatdata...
            Single[] TabStopArray;           
            System.Drawing.CharacterRange[] RangeArray;

            if (TabStopCount > 0)
            {
                TabStopArray = new Single[TabStopCount];
                for (int i = 0; i < TabStopCount; i++)
                {
                    TabStopArray[i] = _br.ReadSingle();
                }
                myStringFormat.SetTabStops(FirstTabOffSet, TabStopArray);
            }

            if (RangeCount > 0)
            {
                RangeArray = new System.Drawing.CharacterRange[RangeCount];
                for (int i = 0; i < RangeCount; i++)
                {
                    RangeArray[i].First = _br.ReadInt32();
                    RangeArray[i].Length = _br.ReadInt32();
                }
                myStringFormat.SetMeasurableCharacterRanges(RangeArray);
            }
        }
Beispiel #4
0
		public override void ResetDefaults() {
			defaultWindowBackColor = this.ColorWindow;
			defaultWindowForeColor = this.ColorControlText;
			window_border_font = new Font(FontFamily.GenericSansSerif, 8.25f, FontStyle.Bold);
			
			/* Menu string formats */
			string_format_menu_text = new StringFormat ();
			string_format_menu_text.LineAlignment = StringAlignment.Center;
			string_format_menu_text.Alignment = StringAlignment.Near;
			string_format_menu_text.HotkeyPrefix = HotkeyPrefix.Show;
			string_format_menu_text.SetTabStops (0f, new float [] { 50f });
			string_format_menu_text.FormatFlags |= StringFormatFlags.NoWrap;

			string_format_menu_shortcut = new StringFormat ();	
			string_format_menu_shortcut.LineAlignment = StringAlignment.Center;
			string_format_menu_shortcut.Alignment = StringAlignment.Far;

			string_format_menu_menubar_text = new StringFormat ();
			string_format_menu_menubar_text.LineAlignment = StringAlignment.Center;
			string_format_menu_menubar_text.Alignment = StringAlignment.Center;
			string_format_menu_menubar_text.HotkeyPrefix = HotkeyPrefix.Show;
		}
        /// <include file='doc\CheckedListBox.uex' path='docs/doc[@for="CheckedListBox.OnDrawItem"]/*' />
        /// <devdoc>
        ///     Actually goes and fires the drawItem event.  Inheriting controls
        ///     should use this to know when the event is fired [this is preferable to
        ///     adding an event handler yourself for this event].  They should,
        ///     however, remember to call base.OnDrawItem(e); to ensure the event is
        ///     still fired to external listeners
        /// </devdoc>
        protected override void OnDrawItem(DrawItemEventArgs e) {
            object item;

            if (Font.Height < 0)
            {
                this.Font = Control.DefaultFont;
            }

            if (e.Index >= 0) {
                if (e.Index < Items.Count) {
                    item = Items[e.Index];
                }
                else {
                    // If the item is not part of our collection, we will just
                    // get the string for it and display it.
                    //
                    item = NativeGetItemText(e.Index);
                }

                Rectangle bounds = e.Bounds;
                int border = 1;
                int height = Font.Height + 2 * border;

                // set up the appearance of the checkbox
                //
                ButtonState state = ButtonState.Normal;
                if (flat) {
                    state |= ButtonState.Flat;
                }
                if (e.Index < Items.Count) {
                    switch (CheckedItems.GetCheckedState(e.Index)) {
                        case CheckState.Checked:
                            state |= ButtonState.Checked;
                            break;
                        case CheckState.Indeterminate:
                            state |= ButtonState.Checked | ButtonState.Inactive;
                            break;
                    }
                }

                // If we are drawing themed CheckBox .. get the size from renderer..
                // the Renderer might return a different size in different DPI modes..
                if (Application.RenderWithVisualStyles) {
                   VisualStyles.CheckBoxState cbState = CheckBoxRenderer.ConvertFromButtonState(state, false, ((e.State & DrawItemState.HotLight) == DrawItemState.HotLight));
                   idealCheckSize = (int)(CheckBoxRenderer.GetGlyphSize(e.Graphics, cbState)).Width;
                }

                // Determine bounds for the checkbox
                //
                int centeringFactor = Math.Max((height - idealCheckSize) / 2, 0);

                // Keep the checkbox within the item's upper and lower bounds
                if (centeringFactor + idealCheckSize > bounds.Height) {
                    centeringFactor = bounds.Height - idealCheckSize;
                }

                Rectangle box = new Rectangle(bounds.X + border,
                                              bounds.Y + centeringFactor,
                                              idealCheckSize,
                                              idealCheckSize);

                if (RightToLeft == RightToLeft.Yes) {
                    // For a RightToLeft checked list box, we want the checkbox
                    // to be drawn at the right.
                    // So we override the X position.
                    box.X = bounds.X + bounds.Width - idealCheckSize - border;
                }

                

                // Draw the checkbox.
                //
                if (Application.RenderWithVisualStyles) {
                    VisualStyles.CheckBoxState cbState = CheckBoxRenderer.ConvertFromButtonState(state, false, ((e.State & DrawItemState.HotLight) == DrawItemState.HotLight));
                    CheckBoxRenderer.DrawCheckBox(e.Graphics, new Point(box.X, box.Y), cbState);
                }
                else {
                    ControlPaint.DrawCheckBox(e.Graphics, box, state);
                }

                // Determine bounds for the text portion of the item
                //
                Rectangle textBounds = new Rectangle(
                                                    bounds.X + idealCheckSize + (border * 2),
                                                    bounds.Y,
                                                    bounds.Width - (idealCheckSize + (border * 2)) ,
                                                    bounds.Height);
                if (RightToLeft == RightToLeft.Yes) {
                    // For a RightToLeft checked list box, we want the text
                    // to be drawn at the left.
                    // So we override the X position.
                    textBounds.X = bounds.X;
                }

                // Setup text font, color, and text
                //
                string text = "";
                Color backColor = (SelectionMode != SelectionMode.None) ? e.BackColor : BackColor;
                Color foreColor = (SelectionMode != SelectionMode.None) ? e.ForeColor : ForeColor;
                if (!Enabled) {
                    foreColor = SystemColors.GrayText;
				}
                Font font = Font;

                text = GetItemText(item);

                if (SelectionMode != SelectionMode.None && (e.State & DrawItemState.Selected) == DrawItemState.Selected) {
                    if (Enabled)
                    {
                        backColor = SystemColors.Highlight;
                        foreColor = SystemColors.HighlightText;
                    }
                    else
                    {
                        backColor = SystemColors.InactiveBorder;
                        foreColor = SystemColors.GrayText;
                    }
                }

                // Draw the text
                //

                // Due to some sort of unpredictable painting optimization in the Windows ListBox control,
                // we need to always paint the background rectangle for the current line.
                using (Brush b = new SolidBrush(backColor)) {
                    e.Graphics.FillRectangle(b, textBounds);
                }

                Rectangle stringBounds = new Rectangle(
                                                      textBounds.X + 1,
                                                      textBounds.Y,
                                                      textBounds.Width - 1,
                                                      textBounds.Height - border * 2);

                if( UseCompatibleTextRendering ){
                    using (StringFormat format = new StringFormat()) {
                        if (UseTabStops) {
                            //  Set tab stops so it looks similar to a ListBox, at least with the default font size.
                            float tabDistance = 3.6f * Font.Height; // about 7 characters
                            float[] tabStops = new float[15];
                            float tabOffset = -(idealCheckSize + (border * 2));
                            for (int i = 1; i < tabStops.Length; i++)
                                tabStops[i] = tabDistance;

                            //(bug 111825)
                            if (Math.Abs(tabOffset) < tabDistance) {
                                tabStops[0] =  tabDistance +tabOffset;
                            }
                            else {
                                tabStops[0] =  tabDistance;
                            }
                            format.SetTabStops(0, tabStops);
                        }
                        else if (UseCustomTabOffsets) {
                            //Set TabStops to userDefined values
                            int wpar = CustomTabOffsets.Count;
                            float[] tabStops = new float[wpar];
                            CustomTabOffsets.CopyTo(tabStops, 0);
                            format.SetTabStops(0, tabStops);
                        }

                        // Adjust string format for Rtl controls
                        if (RightToLeft == RightToLeft.Yes) {
                            format.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
                        }

                        // ListBox doesn't word-wrap its items, so neither should CheckedListBox
                        //
                        format.FormatFlags |= StringFormatFlags.NoWrap;

                        // VSWhidbey 95774: Set Trimming to None to prevent DrawString() from whacking the entire
                        // string when there is only one character per tab included in the string.
                        format.Trimming = StringTrimming.None;

                        // Do actual drawing
                        using (SolidBrush brush = new SolidBrush(foreColor)) {
                            e.Graphics.DrawString(text, font, brush, stringBounds, format);
                        }
                    }
                }
                else{
                    TextFormatFlags flags = TextFormatFlags.Default;
                    flags |= TextFormatFlags.NoPrefix;

                    if (UseTabStops || UseCustomTabOffsets) {
                        flags |= TextFormatFlags.ExpandTabs;
                    }

                    // Adjust string format for Rtl controls
                    if (RightToLeft == RightToLeft.Yes) {
                        flags |= TextFormatFlags.RightToLeft;
                        flags |= TextFormatFlags.Right;
                    }

                    // Do actual drawing
                    TextRenderer.DrawText(e.Graphics, text, font, stringBounds, foreColor, flags );
                }

                // Draw the focus rect if required
                //
                if ((e.State & DrawItemState.Focus) == DrawItemState.Focus &&
                    (e.State & DrawItemState.NoFocusRect) != DrawItemState.NoFocusRect) {
                    ControlPaint.DrawFocusRectangle(e.Graphics, textBounds, foreColor, backColor);
                }
            }
        }
Beispiel #6
0
        protected override void OnMeasureItem(MeasureItemEventArgs e)
        {
            StringFormat format = new StringFormat();
            format.SetTabStops(0, new Single[] {0});
            format.HotkeyPrefix = HotkeyPrefix.Show;
            float textWidth = e.Graphics.MeasureString(GetFormattedText(), font, 50000, format).Width;

            if (Parent.GetType().Equals(typeof(MainMenu))) {
                e.ItemWidth = (int) (textWidth) - 2;
                e.ItemHeight = SystemInformation.MenuHeight + 2;
            } else {
                e.ItemWidth = e.ItemHeight + (int)Math.Ceiling(textWidth) + sideBarWidth + 10;

                if (IsSeparator()) {
                    e.ItemHeight = menuSeperaterWidth + 2;
                } else {
                    e.ItemHeight = SystemInformation.MenuHeight + 2;
                }
            }
        }
		void BeginPrint(object sender, PrintEventArgs ev)
		{
			curLineNr = 0;
			printingStringFormat = (StringFormat)System.Drawing.StringFormat.GenericTypographic.Clone();
			
			// 100 should be enough for everyone ...err ?
			float[] tabStops = new float[100];
			for (int i = 0; i < tabStops.Length; ++i) {
				tabStops[i] = TabIndent * primaryTextArea.TextArea.TextView.WideSpaceWidth;
			}
			
			printingStringFormat.SetTabStops(0, tabStops);
		}
 /// <summary>
 /// 绘制列表项
 /// </summary>
 /// <param name="g">绘图表面</param>
 /// <param name="item">要绘制的列表项</param>
 /// <param name="rectItem">该列表项的区域</param>
 /// <param name="sb">画刷</param>
 protected virtual void DrawItem(Graphics g, ChatListItem item, Rectangle rectItem, SolidBrush sb)
 {
     StringFormat sf = new StringFormat();
     sf.LineAlignment = StringAlignment.Center;
     sf.SetTabStops(0.0F, new float[] { 20.0F });
     if (item.Equals(m_mouseOnItem))           //根据列表项现在的状态绘制相应的背景色
         sb.Color = this.itemMouseOnColor;
     else
         sb.Color = this.itemColor;
     g.FillRectangle(sb, rectItem);
     if (item.IsOpen) {                      //如果展开的画绘制 展开的三角形
         sb.Color = this.arrowColor;
         g.FillPolygon(sb, new Point[] {
                 new Point(2, rectItem.Top + 11),
                 new Point(12, rectItem.Top + 11),
                 new Point(7, rectItem.Top + 16) });
     } else {                                    //如果没有展开判断该列表项下面的子项闪动的个数
         if (item.TwinkleSubItemNumber > 0) {    //如果列表项下面有子项闪动 那么判断闪动状态 是否绘制或者不绘制
             if (item.IsTwinkleHide)             //该布尔值 在线程中不停 取反赋值
                 return;
         }
         sb.Color = this.arrowColor;
         g.FillPolygon(sb, new Point[] {
                 new Point(5, rectItem.Top + 8),
                 new Point(5, rectItem.Top + 18),
                 new Point(10, rectItem.Top + 13) });
     }
     string strItem = "\t" + item.Text;
     sb.Color = this.ForeColor;
     sf.Alignment = StringAlignment.Near;
     g.DrawString(strItem, this.Font, sb, rectItem, sf);
     sf.Alignment = StringAlignment.Far;
     g.DrawString("[" + item.SubItems.GetOnLineNumber() + "/" + item.SubItems.Count + "]", this.Font, sb,
         new Rectangle(rectItem.X, rectItem.Y, rectItem.Width - 15, rectItem.Height), sf);
 }
Beispiel #9
0
		///<summary></summary>
		public ODGrid() {
			//InitializeComponent();// Required for Windows.Forms Class Composition Designer support
			//Add any constructor code after InitializeComponent call
			columns=new ODGridColumnCollection();
			rows=new ODGridRowCollection();
			vScroll=new VScrollBar();
			vScroll.Scroll+=new ScrollEventHandler(vScroll_Scroll);
			vScroll.MouseEnter+=new EventHandler(vScroll_MouseEnter);
			vScroll.MouseLeave+=new EventHandler(vScroll_MouseLeave);
			vScroll.MouseMove+=new MouseEventHandler(vScroll_MouseMove);
			hScroll=new HScrollBar();
			hScroll.Scroll+=new ScrollEventHandler(hScroll_Scroll);
			hScroll.MouseEnter+=new EventHandler(hScroll_MouseEnter);
			hScroll.MouseLeave+=new EventHandler(hScroll_MouseLeave);
			hScroll.MouseMove+=new MouseEventHandler(hScroll_MouseMove);
			this.Controls.Add(vScroll);
			this.Controls.Add(hScroll);
			selectedIndices=new ArrayList();
			selectedCell=new Point(-1,-1);
			selectionMode=GridSelectionMode.One;
			selectedRowColor=Color.Silver;
			allowSelection=true;
			wrapText=true;
			noteSpanStart=0;
			noteSpanStop=0;
			sortedByColumnIdx=-1;
			float[] arrayTabStops={50.0f};
			_format=new StringFormat();
			_format.SetTabStops(0.0f,arrayTabStops);
		}
Beispiel #10
0
		internal StringFormat loadStringFormat()
		{
			int nullMrk = reader.ReadInt32();
			if (nullMrk == 0)
				return null;

			StringAlignment al;
			int dsl;
			StringDigitSubstitute dsm;
			StringFormatFlags sff;
			System.Drawing.Text.HotkeyPrefix hp;
			StringAlignment lal;
			StringTrimming tr;
			float fto;
			float[] ts;

			al = (StringAlignment)reader.ReadInt32();
			dsl = reader.ReadInt32();
			dsm = (StringDigitSubstitute)reader.ReadInt32();
			sff = (StringFormatFlags)reader.ReadInt32();
			hp = (System.Drawing.Text.HotkeyPrefix)reader.ReadInt32();
			lal = (StringAlignment)reader.ReadInt32();
			tr = (StringTrimming)reader.ReadInt32();
			fto = (float)reader.ReadDouble();
			int len = reader.ReadInt32();
			ts = new float[len];
			for (int i = 0; i < len; ++i)
				ts[i] = (float)reader.ReadDouble();

			StringFormat res = new StringFormat(sff);
			res.Alignment = al;
			res.LineAlignment = lal;
			res.SetDigitSubstitution(dsl, dsm);
			res.HotkeyPrefix = hp;
			res.Trimming = tr;
			res.SetTabStops(fto, ts);
			return res;
		}
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            object obj2;
            if (this.Font.Height < 0)
            {
                this.Font = Control.DefaultFont;
            }
            if (e.Index < 0)
            {
                return;
            }
            if (e.Index < this.Items.Count)
            {
                obj2 = this.Items[e.Index];
            }
            else
            {
                obj2 = base.NativeGetItemText(e.Index);
            }
            Rectangle bounds = e.Bounds;
            int num = 1;
            int num2 = this.Font.Height + (2 * num);
            ButtonState normal = ButtonState.Normal;
            if (this.flat)
            {
                normal |= ButtonState.Flat;
            }
            if (e.Index < this.Items.Count)
            {
                switch (this.CheckedItems.GetCheckedState(e.Index))
                {
                    case CheckState.Checked:
                        normal |= ButtonState.Checked;
                        break;

                    case CheckState.Indeterminate:
                        normal |= ButtonState.Checked | ButtonState.Inactive;
                        break;
                }
            }
            if (Application.RenderWithVisualStyles)
            {
                CheckBoxState state = CheckBoxRenderer.ConvertFromButtonState(normal, false, (e.State & DrawItemState.HotLight) == DrawItemState.HotLight);
                this.idealCheckSize = CheckBoxRenderer.GetGlyphSize(e.Graphics, state).Width;
            }
            int num3 = Math.Max((num2 - this.idealCheckSize) / 2, 0);
            if ((num3 + this.idealCheckSize) > bounds.Height)
            {
                num3 = bounds.Height - this.idealCheckSize;
            }
            Rectangle rectangle = new Rectangle(bounds.X + num, bounds.Y + num3, this.idealCheckSize, this.idealCheckSize);
            if (this.RightToLeft == RightToLeft.Yes)
            {
                rectangle.X = ((bounds.X + bounds.Width) - this.idealCheckSize) - num;
            }
            if (Application.RenderWithVisualStyles)
            {
                CheckBoxState state3 = CheckBoxRenderer.ConvertFromButtonState(normal, false, (e.State & DrawItemState.HotLight) == DrawItemState.HotLight);
                CheckBoxRenderer.DrawCheckBox(e.Graphics, new Point(rectangle.X, rectangle.Y), state3);
            }
            else
            {
                ControlPaint.DrawCheckBox(e.Graphics, rectangle, normal);
            }
            Rectangle rect = new Rectangle((bounds.X + this.idealCheckSize) + (num * 2), bounds.Y, bounds.Width - (this.idealCheckSize + (num * 2)), bounds.Height);
            if (this.RightToLeft == RightToLeft.Yes)
            {
                rect.X = bounds.X;
            }
            string s = "";
            Color highlight = (this.SelectionMode != System.Windows.Forms.SelectionMode.None) ? e.BackColor : this.BackColor;
            Color grayText = (this.SelectionMode != System.Windows.Forms.SelectionMode.None) ? e.ForeColor : this.ForeColor;
            if (!base.Enabled)
            {
                grayText = SystemColors.GrayText;
            }
            Font font = this.Font;
            s = base.GetItemText(obj2);
            if ((this.SelectionMode != System.Windows.Forms.SelectionMode.None) && ((e.State & DrawItemState.Selected) == DrawItemState.Selected))
            {
                if (base.Enabled)
                {
                    highlight = SystemColors.Highlight;
                    grayText = SystemColors.HighlightText;
                }
                else
                {
                    highlight = SystemColors.InactiveBorder;
                    grayText = SystemColors.GrayText;
                }
            }
            using (Brush brush = new SolidBrush(highlight))
            {
                e.Graphics.FillRectangle(brush, rect);
            }
            Rectangle layoutRectangle = new Rectangle(rect.X + 1, rect.Y, rect.Width - 1, rect.Height - (num * 2));
            if (this.UseCompatibleTextRendering)
            {
                using (StringFormat format = new StringFormat())
                {
                    if (base.UseTabStops)
                    {
                        float num4 = 3.6f * this.Font.Height;
                        float[] tabStops = new float[15];
                        float num5 = -(this.idealCheckSize + (num * 2));
                        for (int i = 1; i < tabStops.Length; i++)
                        {
                            tabStops[i] = num4;
                        }
                        if (Math.Abs(num5) < num4)
                        {
                            tabStops[0] = num4 + num5;
                        }
                        else
                        {
                            tabStops[0] = num4;
                        }
                        format.SetTabStops(0f, tabStops);
                    }
                    else if (base.UseCustomTabOffsets)
                    {
                        float[] destination = new float[base.CustomTabOffsets.Count];
                        base.CustomTabOffsets.CopyTo(destination, 0);
                        format.SetTabStops(0f, destination);
                    }
                    if (this.RightToLeft == RightToLeft.Yes)
                    {
                        format.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
                    }
                    format.FormatFlags |= StringFormatFlags.NoWrap;
                    format.Trimming = StringTrimming.None;
                    using (SolidBrush brush2 = new SolidBrush(grayText))
                    {
                        e.Graphics.DrawString(s, font, brush2, layoutRectangle, format);
                    }
                    goto Label_049B;
                }
            }
            TextFormatFlags flags = TextFormatFlags.Default;
            flags |= TextFormatFlags.NoPrefix;
            if (base.UseTabStops || base.UseCustomTabOffsets)
            {
                flags |= TextFormatFlags.ExpandTabs;
            }
            if (this.RightToLeft == RightToLeft.Yes)
            {
                flags |= TextFormatFlags.RightToLeft;
                flags |= TextFormatFlags.Right;
            }
            TextRenderer.DrawText(e.Graphics, s, font, layoutRectangle, grayText, flags);
        Label_049B:
            if (((e.State & DrawItemState.Focus) == DrawItemState.Focus) && ((e.State & DrawItemState.NoFocusRect) != DrawItemState.NoFocusRect))
            {
                ControlPaint.DrawFocusRectangle(e.Graphics, rect, grayText, highlight);
            }
        }
Beispiel #12
0
        /// <summary>
        /// Paint handler. Calculates the scaled tabstops based
        /// on the scale factor. Displays text. The base class
        /// scales the size of the font
        /// </summary>
        /// <param name="sender">event sender</param>
        /// <param name="e">event args</param>
        protected override void UIControl_Paint(object sender, PaintEventArgs e)
        {
            if (isDisposing)
            {
                return;
            }

            try
            {
                if (_originalTabStops == null || _scaledTabStops == null)
                {
                    return;
                }

                _scaledFirstTab = _originalFirstTab * _scaleFactor;
                _scaledTabStops = new float[_originalTabStops.Length];

                for (int ii = 0; ii < _originalTabStops.Length; ii++)
                {
                    _scaledTabStops[ii] = _originalTabStops[ii] * _scaleFactor;
                }

                Size s = measureDisplayStringSize(e.Graphics, GetText(), UIControl.Font);

                // vertically center the text
                var rect = new Rectangle(0, (Height - s.Height) / 2, Width, Height);
                var stringFormat = new StringFormat();
                var solidBrush = new SolidBrush(UIControl.ForeColor);

                if (_scaledTabStops != null)
                {
                    stringFormat.SetTabStops(_scaledFirstTab, _scaledTabStops);
                }

                e.Graphics.DrawString(GetText(), UIControl.Font, solidBrush, rect, stringFormat);

                var pen = Pens.Transparent;
                e.Graphics.DrawRectangle(pen, rect);
            }
            catch (Exception ex)
            {
                Log.Debug(ex.ToString());
            }
        }
Beispiel #13
0
        private void BeginPrint(object sender, PrintEventArgs ev)
        {
            curLineNr = 0;
            printingStringFormat = (StringFormat)System.Drawing.StringFormat.GenericTypographic.Clone();

            // 100 should be enough for everyone ...err ?
            float[] tabStops = new float[100];
            for (int i = 0; i < tabStops.Length; ++i)
            {
                tabStops[i] = scriptEditor.TabIndent * scriptEditor.ActiveTextAreaControl.TextArea.TextView.GetWidth(" ");
            }

            printingStringFormat.SetTabStops(0, tabStops);
        }
Beispiel #14
0
        private void DrawText(Graphics graphics, Rectangle dest)
        {
            Brush br;

            StringFormat format = new StringFormat();
            format.SetTabStops(60, new Single[] {0});
            format.HotkeyPrefix = HotkeyPrefix.Show;

            // Alligned Right, looks messy. Because the letter widths are not equal
            float scTextWidth = graphics.MeasureString(GetShortcutText(), font, 50000, format).Width;

            int tabStopWidth = dest.Width - sideBarWidth - 5 - (int) Math.Ceiling(scTextWidth);
            if (tabStopWidth > 0) {
                format.SetTabStops(tabStopWidth, new Single[] {0});
            }

            if (Enabled) {
                br = new SolidBrush(Color.Black);
            } else {
                br = new SolidBrush(Color.Gray);
            }

            graphics.DrawString(GetFormattedText(), font, br, dest.Left + sideBarWidth + 5, dest.Top + 4, format);
        }
Beispiel #15
0
        private void DrawMainMenu(Graphics graphics, Rectangle dest, DrawItemState state)
        {
            if ((state & DrawItemState.HotLight) == DrawItemState.HotLight) {
                graphics.FillRectangle(new SolidBrush(selectedGradientLeft), dest.X + 1, dest.Y, dest.Width - 1, dest.Height - 1);
                graphics.DrawRectangle(new Pen(selectedBorder), dest.X + 1, dest.Y, dest.Width - 1, dest.Height - 1);
            } else if ((state & DrawItemState.Selected) == DrawItemState.Selected) {
                graphics.FillRectangle(new SolidBrush(sideBarColor), dest.X + 1, dest.Y + 1, dest.Width - 1, dest.Height - 1);
                graphics.DrawLine(new Pen(selectedBorder), dest.Left + 1, dest.Top, dest.Left + 1, dest.Bottom - 1);
                graphics.DrawLine(new Pen(selectedBorder), dest.Left + 1 + (dest.Width - 1), dest.Top + 1, dest.Left + 1 + (dest.Width - 1), dest.Bottom - 1);
                graphics.DrawLine(new Pen(selectedBorder), dest.Left + 1, dest.Top, dest.Left + 1 + (dest.Width - 1), dest.Top);
            } else {
                graphics.FillRectangle(SystemBrushes.Control, dest.X, dest.Y, dest.Width + 1, dest.Height);
            }

            StringFormat format = new StringFormat();
            format.HotkeyPrefix = HotkeyPrefix.Show;
            format.SetTabStops(60, new Single[] {0});

            graphics.DrawString(Text, font, Brushes.Black, dest.Left + 6, dest.Top + 3, format);
        }
Beispiel #16
0
        private void DrawHeader(System.Drawing.Printing.PrintPageEventArgs e)
        {
            int marginLeft = e.MarginBounds.Left;
            int marginRight = e.MarginBounds.Right;
            int marginTop = e.MarginBounds.Top;
            System.Drawing.Brush brush = System.Drawing.Brushes.Black;
            SizeF stringSize = new SizeF();

            System.Drawing.Font font = new Font("Arial", 18, System.Drawing.FontStyle.Bold);
            string text = "Kvitto";
            stringSize = e.Graphics.MeasureString(text, font);
            y = marginTop;
            e.Graphics.DrawString(text, font, brush, marginLeft, y);

            font = new Font("Arial", 12);
            text = "Vård med ersättning från landstinget";
            stringSize = e.Graphics.MeasureString(text, font);
            y += stringSize.Height+10;
            e.Graphics.DrawString(text, font, brush, marginLeft, y);

            font = new Font("Arial", 12);
            text = "Vårdgivare:";
            stringSize = e.Graphics.MeasureString(text, font);
            y += stringSize.Height+10;
            e.Graphics.DrawString(text, font, brush, marginLeft, y);

            font = new Font("Arial", 14);
            text = "Leg. sjukgymnast\nDoris Ruberg\nRepslagaregatan 12\n602 32 Norrköping\nTelefon: 070-6617957";
            y += stringSize.Height+15;
            stringSize = e.Graphics.MeasureString(text, font);
            e.Graphics.DrawString(text, font, brush, marginLeft, y);

            y += stringSize.Height+10;
            e.Graphics.DrawLine(new System.Drawing.Pen(brush, 1), marginLeft, y, marginRight, y);

            font = new Font("Arial", 12);
            text = "Patient:";
            stringSize = e.Graphics.MeasureString(text, font);
            y += 10;
            e.Graphics.DrawString(text, font, brush, marginLeft, y);

            font = new Font("Arial", 14);
            text = "Personnummer: " + personnumber + "\nNamn: " + name;
            y += stringSize.Height+15;
            stringSize = e.Graphics.MeasureString(text, font);
            e.Graphics.DrawString(text, font, brush, marginLeft, y);

            font = new Font("Arial", 14, System.Drawing.FontStyle.Bold);
            text = "Besöksdatum\tPatientavgift\tKommentar\n\n";
            y += stringSize.Height+20;
            stringSize = e.Graphics.MeasureString(text, font);
            StringFormat stringFormat = new StringFormat();
            stringFormat.SetTabStops(0.0f, new float[] {200.0f});
            e.Graphics.DrawString(text, font, brush, marginLeft, y, stringFormat);
        }
Beispiel #17
0
        private void printDocument_BeginPrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            firstPage = true;
            y = 0;
            nrofPages = 0;
            currentPageNr = 0;

            fontPageNr = new Font("Times New Roman", 8);
            fontContent = new Font("Times New Roman", 12);
            stringFormat = new StringFormat();
            stringFormat.Trimming = StringTrimming.Word;
            stringFormat.SetTabStops(0.0f, new float[] {200.0f});
        }
        /////
        void BeginPrint(object sender, PrintEventArgs ev)
        {
            _curLineNumber = 0;
            _printingStringFormat = (StringFormat)System.Drawing.StringFormat.GenericTypographic.Clone();
            _printingStringFormat.Trimming = StringTrimming.None;
            _printingStringFormat.FormatFlags = StringFormatFlags.MeasureTrailingSpaces;

            // 100 should be enough for everyone ...err ?
            float[] tabStops = new float[100];
            for (int i = 0; i < tabStops.Length; ++i)
            {
                tabStops[i] = _editor.TabIndent * _editor.ActiveTextAreaControl.TextArea.TextView.WideSpaceWidth;
            }

            _printingStringFormat.SetTabStops(0, tabStops);
        }
Beispiel #19
0
 /// <summary>
 /// 绘制小图标模式的个人信息
 /// </summary>
 /// <param name="g">绘图表面</param>
 /// <param name="subItem">要绘制信息的子项</param>
 /// <param name="rectSubItem">该子项的区域</param>
 protected virtual void DrawSmallSubItem(Graphics g, ChatListSubItem subItem, Rectangle rectSubItem)
 {
     rectSubItem.Height = (int)ChatListItemIcon.Small;               //重新赋值一个高度
     StringFormat sf = new StringFormat();
     sf.LineAlignment = StringAlignment.Center;
     sf.FormatFlags = StringFormatFlags.NoWrap;
     string strDraw = subItem.DisplayName;
     if (string.IsNullOrEmpty(strDraw)) strDraw = subItem.NicName;   //如果没有备注绘制昵称
     Size szFont = TextRenderer.MeasureText(strDraw, this.Font);
     sf.SetTabStops(0.0F, new float[] { rectSubItem.Height });
     g.DrawString("\t" + strDraw, this.Font, Brushes.Black, rectSubItem, sf);
     sf.SetTabStops(0.0F, new float[] { rectSubItem.Height + 5 + szFont.Width });
     g.DrawString("\t" + subItem.PersonalMsg, this.Font, Brushes.Gray, rectSubItem, sf);
 }
Beispiel #20
0
		public void Clone_Complex ()
		{
			using (StringFormat sf = new StringFormat ()) {
				CharacterRange[] ranges = new CharacterRange [2];
				ranges[0].First = 1;
				ranges[0].Length = 2;
				ranges[1].First = 3;
				ranges[1].Length = 4;
				sf.SetMeasurableCharacterRanges (ranges);

				float[] stops = new float [2];
				stops [0] = 6.0f;
				stops [1] = 7.0f;
				sf.SetTabStops (5.0f, stops);

				using (StringFormat clone = (StringFormat) sf.Clone ()) {
					CheckDefaults (clone);

					float first;
					float[] cloned_stops = clone.GetTabStops (out first);
					Assert.AreEqual (5.0f, first, "first");
					Assert.AreEqual (6.0f, cloned_stops[0], "cloned_stops[0]");
					Assert.AreEqual (7.0f, cloned_stops[1], "cloned_stops[1]");
				}
			}
		}
Beispiel #21
0
		public static void Main( ) 
		{						
			float width = 750.0F;
			float height = 1000.0F;
			string str;
			int chars = 0;
			int lines = 0;
			SizeF sz;
            
			Font f1 = new Font("Arial",12);				
			Font f2  = new Font("Verdana", 8);			
			Font f3  = new Font("Courier New", 14);
			Font f4  = new Font(FontFamily.GenericSansSerif, 14);
			Font f5  = new Font(FontFamily.GenericMonospace, 14);
			Font f6  = new Font(FontFamily.GenericSerif, 16);
			Font fonttxt= new Font("Verdana", 8);
			SolidBrush brushtxt = new SolidBrush(Color.Pink);
					
			StringFormat strfmt1 = new StringFormat();
			StringFormat strfmt2 = new StringFormat();
			StringFormat strfmt3 = new StringFormat();
			StringFormat strfmt4 = new StringFormat();
			StringFormat strfmt5 = new StringFormat();
			StringFormat strfmt6 = new StringFormat();			
			StringFormat strfmttxt = new StringFormat();			
			
			Bitmap bmp = new Bitmap((int)width, (int)height);
			Graphics gr = Graphics.FromImage(bmp);
			SolidBrush br = new SolidBrush(Color.White);
   			SolidBrush colorRed = new SolidBrush(Color.Red);
   			
			strfmttxt.Alignment = StringAlignment.Near;
			strfmttxt.LineAlignment = StringAlignment.Near;
			strfmttxt.Trimming = StringTrimming.Character;
			
			strfmt1.Alignment = StringAlignment.Center;
			strfmt1.LineAlignment = StringAlignment.Near;
			strfmt1.Trimming = StringTrimming.Character;
			strfmt1.HotkeyPrefix = HotkeyPrefix.Show;
			
			strfmt2.Alignment = StringAlignment.Far;
			strfmt2.LineAlignment = StringAlignment.Center;
			strfmt2.Trimming = StringTrimming.Character;
			
			strfmt3.Alignment = StringAlignment.Far;
			strfmt3.LineAlignment = StringAlignment.Near;
			strfmt3.Trimming = StringTrimming.None;
			
			strfmt4.Alignment = StringAlignment.Far;
			strfmt4.LineAlignment = StringAlignment.Far;
			strfmt4.Trimming = StringTrimming.EllipsisCharacter;
			
			strfmt5.Alignment = StringAlignment.Far;
			strfmt5.LineAlignment = StringAlignment.Near;
			strfmt5.Trimming = StringTrimming.None;
			strfmt5.FormatFlags = StringFormatFlags.DirectionVertical;
			
			strfmt6.Alignment = StringAlignment.Far;
			strfmt6.LineAlignment = StringAlignment.Far;
			strfmt6.Trimming = StringTrimming.EllipsisCharacter;
			strfmt6.FormatFlags = StringFormatFlags.NoWrap;			
			
			Rectangle rect1 = new Rectangle (10,50,100,150);
			Rectangle rect2 = new Rectangle (10,300,150,150);
			
			Rectangle rect3 = new Rectangle (200,50,175,175);
			Rectangle rect4 = new Rectangle (200,300,150,150);
			
			Rectangle rect5 = new Rectangle (400,50,175,175);
			Rectangle rect6 = new Rectangle (400,300,150,150);			
			Rectangle rect7 = new Rectangle (550,300, 140,120);			
			
			gr.DrawRectangle( new Pen(Color.Yellow), rect3);			
			gr.DrawRectangle( new Pen(Color.Blue), rect4);			
			
			gr.DrawRectangle( new Pen(Color.Yellow), rect5);			
			gr.DrawRectangle( new Pen(Color.Blue), rect6);				

			SolidBrush solid  =  new SolidBrush(Color.Blue);

			gr.DrawString("Samples of text with different fonts and formatting", 
				new Font("Verdana",16), new SolidBrush(Color.White), new Rectangle (5,5,600,100), strfmttxt);											

		
			gr.FillEllipse(solid, rect1);

			gr.DrawRectangle( new Pen(Color.Green), rect2);			
			gr.DrawRectangle( new Pen(Color.Green), rect7);			
			
			str = "Ara que tinc &vint anys, ara que encara tinc força,que no tinc l'ànima morta, i em sento bullir la sang. (" + f1.Name + ")";			
			gr.DrawString( str,	f1, new SolidBrush(Color.White), rect1, strfmt1);						
			gr.DrawString(flagProcessing(strfmt1), fonttxt, brushtxt, calcRect(rect1), strfmttxt);						                                    
            		sz =  gr.MeasureString (str, f1, new SizeF (rect1.Width, rect1.Height), strfmt1, out chars, out lines);                             			                                
			Console.WriteLine("MeasureString str1 [" + str + "] " + sz + ";chars:" + chars + " lines:" + lines);
			
			str = "Ara que em sento capaç de cantar si un altre canta. Avui que encara tinc veu i encara puc creure en déus (" + f2.Name + ")";
			gr.DrawString(str, f2, new SolidBrush(Color.Red),rect2, strfmt2);														
			gr.DrawString(flagProcessing(strfmt2), fonttxt, brushtxt, calcRect(rect2), strfmttxt);						
			sz =  gr.MeasureString (str, f2, new SizeF (rect2.Width, rect2.Height), strfmt2, out chars, out lines);                             			                                			
			Console.WriteLine("MeasureString str2 [" + str + "] " + sz + ";chars:" + chars + " lines:" + lines);
			
			str = "Vull cantar a les pedres, la terra, l'aigua, al blat i al camí, que vaig trepitjant. (" + f3.Name + ")";
			gr.DrawString(str,f3, new SolidBrush(Color.White), rect3, strfmt3);				
			gr.DrawString(flagProcessing(strfmt3), fonttxt, brushtxt, calcRect(rect3), strfmttxt);			
			sz =  gr.MeasureString (str, f3, new SizeF (rect3.Width, rect3.Height), strfmt3, out chars, out lines);                             			                                			
			Console.WriteLine("MeasureString str3 [" + str + "] " + sz + ";chars:" + chars + " lines:" + lines);
			
			str = "A la nit, al cel i a aquet mar tan nostre i al vent que al matí ve a besar-me el rostre (" + f4.Name + ")";				
			gr.DrawString(str, f4, new SolidBrush(Color.Red),rect4, strfmt4);
			gr.DrawString(flagProcessing(strfmt4), fonttxt, brushtxt, calcRect(rect4), strfmttxt);			
			sz =  gr.MeasureString (str, f4, new SizeF (rect4.Width, rect4.Height), strfmt4, out chars, out lines);                             			                                			
			Console.WriteLine("MeasureString str4 [" + str + "] " + sz + ";chars:" + chars + " lines:" + lines);			
			
			str = "Vull cantar a les pedres, la terra, l'aigua, al blat i al camí, que vaig trepitjant. (" + f5.Name + ")";
			gr.DrawString(str, f5, new SolidBrush(Color.White), rect5, strfmt5);
			gr.DrawString(flagProcessing(strfmt5), fonttxt, brushtxt, calcRect(rect5), strfmttxt);			
			sz =  gr.MeasureString (str, f5, new SizeF (rect5.Width, rect5.Height), strfmt5, out chars, out lines);                             			                                			
			Console.WriteLine("MeasureString str4 [" + str + "] " + sz + ";chars:" + chars + " lines:" + lines);			
				
			str = "Ve a besar-me el rostre (" + f6.Name + ")";
			gr.DrawString(str, 	f6, new SolidBrush(Color.Red),rect6, strfmt6);
			gr.DrawString(flagProcessing(strfmt6), fonttxt, brushtxt, calcRect(rect6), strfmttxt);						
			sz =  gr.MeasureString (str, f6, new SizeF (rect6.Width, rect6.Height), strfmt6, out chars, out lines);                             			                                			
			Console.WriteLine("MeasureString str6 [" + str + "] " + sz + ";chars:" + chars + " lines:" + lines);				
			
			str = "Vull plorar amb aquells que es troben tots sols, sense cap amor van passant pel món.. (" + f5.Name + ")";
			gr.DrawString(str, f5, new SolidBrush(Color.White), rect7, strfmt4);
			gr.DrawString(flagProcessing(strfmt4), fonttxt, brushtxt, calcRect(rect7), strfmttxt);			
			sz =  gr.MeasureString (str, f5, new SizeF (rect7.Width, rect7.Height), strfmt5, out chars, out lines);                             			                                			
			Console.WriteLine("MeasureString str7 [" + str + "] " + sz + ";chars:" + chars + " lines:" + lines);			
			
			/* 3rd row */			
			
			Font f8  = new Font("Verdana", 10);			
			Font f9  = new Font("Verdana", 6);		
			Font f10  = new Font("Verdana", 12);		
			Font f11  = new Font("Verdana", 14);		
			
			Rectangle rect8 = new Rectangle (10, 550,100,100);			
			Rectangle rect9 = new Rectangle (150,550, 100,100);			
			Rectangle rect10 = new Rectangle (300,550, 100,100);			
			Rectangle rect11 = new Rectangle (420,550, 100,100);			
			Rectangle rect12 = new Rectangle (530,550, 200,100);			
			Rectangle rect13 = new Rectangle (530,600, 200,100);			
			Rectangle rect14 = new Rectangle (530,650, 200,100);			
			
			gr.DrawRectangle( new Pen(Color.Yellow), rect8);			
			gr.DrawRectangle( new Pen(Color.Yellow), rect9);			
			gr.DrawRectangle( new Pen(Color.Yellow), rect10);			
			
			StringFormat strfmt8 = new StringFormat();						
			strfmt8.Alignment = StringAlignment.Center;
			strfmt8.LineAlignment = StringAlignment.Near;
			strfmt8.Trimming = StringTrimming.EllipsisCharacter;
			strfmt8.HotkeyPrefix = HotkeyPrefix.Show;			
			
			StringFormat strfmt9 = new StringFormat();						
			strfmt9.Alignment = StringAlignment.Center;
			strfmt9.LineAlignment = StringAlignment.Center;
			strfmt9.Trimming = StringTrimming.EllipsisCharacter;
			strfmt9.HotkeyPrefix = HotkeyPrefix.None;			
			
			StringFormat strfmt10 = new StringFormat();						
			strfmt10.Alignment = StringAlignment.Center;
			strfmt10.LineAlignment = StringAlignment.Near;
			strfmt10.Trimming = StringTrimming.Word;
			strfmt10.HotkeyPrefix = HotkeyPrefix.Show;					
			
			StringFormat strfmt11 = new StringFormat();						
			strfmt11.Alignment = StringAlignment.Center;
			strfmt11.LineAlignment = StringAlignment.Near;
			strfmt11.Trimming = StringTrimming.Word;
			strfmt11.HotkeyPrefix = HotkeyPrefix.Show;					
			strfmt11.FormatFlags = StringFormatFlags.DirectionRightToLeft;
			
			StringFormat strfmt12 = new StringFormat();						
			float[] tabs = {10, 20, 30};
			strfmt12.Alignment = StringAlignment.Center;
			strfmt12.LineAlignment = StringAlignment.Near;
			strfmt12.Trimming = StringTrimming.Word;
			strfmt12.HotkeyPrefix = HotkeyPrefix.Show;								
			strfmt12.SetTabStops(20, tabs);
			
			StringFormat strfmt13 = new StringFormat();						
			float[] tabs2 = {5, 50, 60};
			strfmt13.Alignment = StringAlignment.Center;
			strfmt13.LineAlignment = StringAlignment.Near;
			strfmt13.Trimming = StringTrimming.Word;
			strfmt13.HotkeyPrefix = HotkeyPrefix.Show;											
			strfmt13.SetTabStops(0, tabs2);
			
			StringFormat strfmt14 = new StringFormat();						
			strfmt14.Alignment = StringAlignment.Center;
			strfmt14.LineAlignment = StringAlignment.Near;
			strfmt14.Trimming = StringTrimming.Word;
			strfmt14.HotkeyPrefix = HotkeyPrefix.Show;								
			strfmt14.FormatFlags = StringFormatFlags.DirectionRightToLeft;
			
			str = "Vull alçar la veu,per cantar als homes que han nascut dempeus (" + f8.Name + ")";
			gr.DrawString(str, f8, new SolidBrush(Color.White), rect8, strfmt8);
			gr.DrawString(flagProcessing(strfmt8), fonttxt, brushtxt, calcRect(rect8), strfmttxt);			
			sz =  gr.MeasureString (str, f8, new SizeF (rect8.Width, rect8.Height), strfmt8, out chars, out lines);                             			                                			
			gr.DrawRectangle(new Pen(Color.Red), new Rectangle (rect8.X, rect8.Y, (int)sz.Width, (int)sz.Height));			
			
			str = "I no tinc l'ànima morta i  em sento bollir la sang (" + f9.Name + ")";
			gr.DrawString(str, f9, new SolidBrush(Color.White), rect9, strfmt9);
			gr.DrawString(flagProcessing(strfmt9), fonttxt, brushtxt, calcRect(rect9), strfmttxt);			
			sz =  gr.MeasureString (str, f9, new SizeF (rect9.Width, rect9.Height), strfmt9, out chars, out lines);                             			                                			
			gr.DrawRectangle(new Pen(Color.Red), new Rectangle (rect9.X, rect9.Y, (int)sz.Width, (int)sz.Height));			
			
			str = "I no tinc l'ànima morta i  em sento bollir la sang (" + f10.Name + ")";
			gr.DrawString(str, f10, new SolidBrush(Color.White), rect10, strfmt10);
			gr.DrawString(flagProcessing(strfmt10), fonttxt, brushtxt, calcRect(rect10), strfmttxt);			
			sz =  gr.MeasureString (str, f10, new SizeF (rect10.Width, rect10.Height), strfmt10, out chars, out lines);                             			                                			
			gr.DrawRectangle(new Pen(Color.Red), new Rectangle (rect10.X, rect10.Y, (int)sz.Width, (int)sz.Height));			
			
			str = "I no tinc l'ànima morta i  em sento bollir la sang (" + f11.Name + ")";
			gr.DrawString(str, f11, new SolidBrush(Color.White), rect11, strfmt11);
			gr.DrawString(flagProcessing(strfmt11), fonttxt, brushtxt, calcRect(rect11), strfmttxt);			
			sz =  gr.MeasureString (str, f11, new SizeF (rect11.Width, rect11.Height), strfmt11, out chars, out lines);                             			                                			
			gr.DrawRectangle(new Pen(Color.Red), new Rectangle (rect11.X, rect11.Y, (int)sz.Width, (int)sz.Height));			
			
			str = "Tab1\tTab2\tTab3";
			gr.DrawString(str, f8, new SolidBrush(Color.White), rect12, strfmt12);
			sz =  gr.MeasureString (str, f8, new SizeF (rect12.Width, rect12.Height), strfmt12, out chars, out lines);                             			                                						
			gr.DrawRectangle(new Pen(Color.Red), new Rectangle (rect12.X, rect12.Y, (int)sz.Width, (int)sz.Height));			
			
			str = "Nom\tCognom\tAdreça";
			gr.DrawString(str, f8, new SolidBrush(Color.White), rect13, strfmt13);
			sz =  gr.MeasureString (str, f8, new SizeF (rect13.Width, rect13.Height), strfmt13, out chars, out lines);                             			                                						
			gr.DrawRectangle(new Pen(Color.Red), new Rectangle (rect13.X, rect13.Y, (int)sz.Width, (int)sz.Height));			
			
			str = "Nom Cognom Adreça";
			gr.DrawString(str, f8, new SolidBrush(Color.White), rect14, strfmt14);
			sz =  gr.MeasureString (str, f8, new SizeF (rect14.Width, rect13.Height), strfmt14, out chars, out lines);                             			                                						
			gr.DrawRectangle(new Pen(Color.Red), new Rectangle (rect14.X, rect14.Y, (int)sz.Width, (int)sz.Height));			
			
			bmp.Save("fontDrawingAdv.bmp", ImageFormat.Bmp);
			
		}
Beispiel #22
0
		public void TabsStops() 
		{
			using (StringFormat smf = new StringFormat ()) {
				float firstTabOffset;
				float[] tabsSrc = { 100, 200, 300, 400 };
				float[] tabStops;

				smf.SetTabStops (200, tabsSrc);
				tabStops = smf.GetTabStops (out firstTabOffset);

				Assert.AreEqual (200, firstTabOffset);
				Assert.AreEqual (tabsSrc.Length, tabStops.Length);
				Assert.AreEqual (tabsSrc[0], tabStops[0]);
				Assert.AreEqual (tabsSrc[1], tabStops[1]);
				Assert.AreEqual (tabsSrc[2], tabStops[2]);
				Assert.AreEqual (tabsSrc[3], tabStops[3]);
			}
		}
        private void ListBox1_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            // Draw the background of the ListBox control for each item.
            e.DrawBackground();
            int i = e.Index;
            if (i < 0) return;

            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                //some code when the item is selected
                //if (i % 2 == 0)
                //{
                    //e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(255,204,204)), e.Bounds);
                    //e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(204, 255, 204)), e.Bounds);
                    e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(255, 102, 102)), e.Bounds);
                    //e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(255, 102, 102)),
                    //                            e.Bounds.X,e.Bounds.Y,e.Bounds.Width, e.Bounds.Height+20);
                    //e.Graphics.FillRectangle(new SolidBrush(Color.Blue), e.Bounds);
                    //e.BackColor = Color.Aqua;
                //}
                //else
                //{
                    //e.Graphics.FillRectangle(new SolidBrush(Color.White), e.Bounds);
                    //e.BackColor = Color.White;
                //}
                    //Brush brush = new Brush();
                StringFormat sf = new StringFormat();
                float[] ts = { 100.0f, 150.0f, 170.0f };
                sf.SetTabStops(0.0f, ts);

                e.Graphics.DrawString(lbxItems.Items[e.Index].ToString(),
                e.Font,  Brushes.White, e.Bounds, sf);
            }
            else
            {
                //some code when the item is unselected
                if (i % 2 == 0)
                {
                    e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(204, 255, 204)), e.Bounds);
                    //e.Graphics.FillRectangle(new SolidBrush(Color.White), e.Bounds);
                    //e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(204,204, 255)), e.Bounds);
                    //e.BackColor = Color.Aqua;
                }
                else
                {
                    e.Graphics.FillRectangle(new SolidBrush(Color.White), e.Bounds);
                    //e.BackColor = Color.White;
                }
                e.Graphics.DrawString(lbxItems.Items[e.Index].ToString(),
                e.Font, Brushes.Black, e.Bounds, StringFormat.GenericDefault);
            }

            // If the ListBox has focus, draw a focus rectangle around the selected item.
            e.DrawFocusRectangle();
        }
Beispiel #24
0
		public void SetTabStops_Null ()
		{
			using (StringFormat sf = new StringFormat ()) {
				sf.SetTabStops (Single.NaN, null);
			}
		}
Beispiel #25
0
        private void PrintBody(PrintPageEventArgs e, string body, ref int yOffset, int xOffset)
        {
            var stringFormat = new StringFormat();
            stringFormat.SetTabStops(xOffset, new float[1]);

            var font = new Font(FontFamily.GenericSansSerif, 12);
            e.Graphics.DrawString(body, font, Brushes.Black,
                new Rectangle(e.MarginBounds.X + xOffset, yOffset, e.MarginBounds.Width, e.MarginBounds.Height), stringFormat);

            yOffset += (int) e.Graphics.MeasureString(body, font, e.MarginBounds.Width, stringFormat).Height;
        }
		/// Display the details of the current spiro
		public void DrawInfo(Graphics g, Point pt, Color col)
		{
			string msg = string.Format(
					"Fixed Radius\t{0}\n"+
					"Moving Radius\t{1}\n"+
					"Pen Distance\t{2}\n"+
					"Number of Orbits\t{3}\n"+
					"GCD of Radii\t{4}\n"+
					"Resolution\t{5}", 
				Pad(R), Pad(r), Pad(f), Pad(revolutions), Pad(GCD(R, r)), Pad(resolution));
	
			Font fnt = new Font("Arial", 8);

			StringFormat fmt=new StringFormat();
			fmt.SetTabStops(0, new float[] {100});
			g.DrawString(msg, fnt, new SolidBrush(col), pt, fmt);
		}