Inheritance: System.MarshalByRefObject, ICloneable, ISerializable, IDisposable
        void EDSToolTip_Draw(object sender, DrawToolTipEventArgs e)
        {
            if (e.ToolTipText.Trim() != "")
            {
                //e.DrawBackground();
                Graphics g = e.Graphics;

                //draw background
                LinearGradientBrush lgb = new LinearGradientBrush(new Rectangle(Point.Empty, e.Bounds.Size), Color.FromArgb(250, 252, 253), Color.FromArgb(206, 220, 240), LinearGradientMode.Vertical);
                g.FillRectangle(lgb, new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height));
                lgb.Dispose();

                //Console.WriteLine(e.ToolTipText);

                //draw border
                ControlPaint.DrawBorder(g, e.Bounds, SystemColors.GrayText, ButtonBorderStyle.Dashed);
                //draw Image
                g.DrawImage(image, new Point(5, 5));

                // Draw the custom text.
                // The using block will dispose the StringFormat automatically.
                using (StringFormat sf = new StringFormat())
                {
                    using (Font f = new Font("Tahoma", 8))
                    {
                        e.Graphics.DrawString(e.ToolTipText, f,
                            Brushes.Black, e.Bounds.X + 25, e.Bounds.Y + 30, StringFormat.GenericTypographic);
                    }
                }
            }
        }
Ejemplo n.º 2
1
 public void Text(string text, Font font, uint argb, Rectangle rect, StringFormat format)
 {
     graphics.DrawString(
         text, font,
         new SolidBrush(argb.ToColor()),
         rect, format);
 }
Ejemplo n.º 3
1
        public virtual Size GetCharacterSize( Graphics g, Font font, CharacterCasing casing )
        {
            const int MeasureCharCount = 10;

             Size charSize = new Size( 0, 0 );

             for ( char c = '0'; c <= '9'; ++c )
             {
            Size newSize = TextRenderer.MeasureText( g, new string( c, MeasureCharCount ), font, new Size( 0, 0 ),
               _textFormatFlags );

            newSize.Width = (int)Math.Ceiling( (double)newSize.Width / (double)MeasureCharCount );

            if ( newSize.Width > charSize.Width )
            {
               charSize.Width = newSize.Width;
            }

            if ( newSize.Height > charSize.Height )
            {
               charSize.Height = newSize.Height;
            }
             }

             return charSize;
        }
Ejemplo n.º 4
1
        public void PaintJunk(Graphics g)
        {
            g.FillRectangle(Brushes.Transparent, 0, 0, 1000, 1000);

            using (Font font = new Font("Courier New", 20, FontStyle.Bold))
            {
                if (bounceCounter == -1) return;
                const string str = "DEVELOPER BUILD";
                float x = 0;
                int timefactor = bounceCounter;
                for (int i = 0; i < str.Length; i++)
                {
                    string slice = str.Substring(i, 1);
                    g.PageUnit = GraphicsUnit.Pixel;
                    x += g.MeasureString(slice, font).Width - 1;

                    int offset = -i * 3 + timefactor*3;
                    int yofs = 0;
                    if (offset < 0)
                    { continue; }
                    else
                        if (offset < DigitTable.Length)
                            yofs = DigitTable[offset];
                    g.DrawString(slice, font, Brushes.Black, 5 + x, 15 - yofs);
                }
            }
        }
Ejemplo n.º 5
1
 private static void DrawStringML(this Graphics G, string Text, Font font, Brush brush, float x, ref float y, float mX)
 {
     string[] words = Text.Split(' ');
     float tempX = x;
     float totalSpace = mX - x;
     SizeF measureWord = new SizeF(0, font.GetHeight());
     float tempWordWidth = 0;
     foreach (string word in words)
     {
         //measure word width (based in font size)
         tempWordWidth = G.MeasureString(word + " ", font).Width;
         measureWord.Width += tempWordWidth;
         //check if the word fits in free line space
         //if not then change line
         if (measureWord.Width > totalSpace)
         {
             y += font.GetHeight();
             tempX = x;
             measureWord.Width = tempWordWidth;
         }
         G.DrawString(word + " ", font, brush, tempX, y);
         tempX += tempWordWidth;
     }
     y += font.GetHeight();
 }
Ejemplo n.º 6
0
        public BitmapFont(Font font, FontBuilderConfiguration config)
        {
            if (config == null)
                config = new FontBuilderConfiguration();

            fontData = BuildFont(font, config, null);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Draw a preview of the <see cref="ColorPair"/>
        /// </summary>
        /// <param name="e">The paint event args providing the <see cref="Graphics"/> and bounding
        /// rectangle</param>
        public override void PaintValue(PaintValueEventArgs e)
        {
            ColorPair colorPair = (ColorPair)e.Value ;

            using ( SolidBrush b = new SolidBrush(colorPair.Background)) {
                e.Graphics.FillRectangle(b, e.Bounds);
            }

            // Draw the text "ab" using the Foreground/Background values from the ColorPair
            using(SolidBrush b = new SolidBrush(colorPair.Foreground)) {
                using(Font f = new Font("Arial",6)) {
                    RectangleF temp = new RectangleF(e.Bounds.Left,e.Bounds.Top,e.Bounds.Height,e.Bounds.Width) ;
                    temp.Inflate(-2,-2) ;

                    // Set up how we want the text drawn
                    StringFormat format = new StringFormat(StringFormatFlags.FitBlackBox | StringFormatFlags.NoWrap) ;
                    format.Trimming = StringTrimming.EllipsisCharacter ;
                    format.Alignment = StringAlignment.Center ;
                    format.LineAlignment = StringAlignment.Center ;

                    // save the Smoothing mode of the Graphics object so we can restore it
                    SmoothingMode saveMode = e.Graphics.SmoothingMode ;
                    e.Graphics.SmoothingMode = SmoothingMode.AntiAlias ;
                    e.Graphics.DrawString("ab",f,b,temp,format) ;
                    e.Graphics.SmoothingMode = saveMode ;
                }
            }
        }
Ejemplo n.º 8
0
    private void italicToolStripButton_CheckedChanged(object sender, EventArgs e)
    {
      Font oldFont, newFont;

      bool checkState = ((ToolStripButton)sender).Checked;
      oldFont = this.richTextBoxText.SelectionFont;

      if (!checkState)
        newFont = new Font(oldFont, oldFont.Style & ~FontStyle.Italic);
      else
        newFont = new Font(oldFont, oldFont.Style | FontStyle.Italic);

      richTextBoxText.SelectionFont = newFont;
      richTextBoxText.Focus();

      italicToolStripMenuItem.CheckedChanged -= new
EventHandler(italicToolStripMenuItem_CheckedChanged);
      italicToolStripMenuItem.Checked = checkState;
      italicToolStripMenuItem.CheckedChanged += new
EventHandler(italicToolStripMenuItem_CheckedChanged);
//StatusBar
         if (!checkState)
            toolStripStatusLabelItalic.Font = new Font(toolStripStatusLabelItalic.Font, toolStripStatusLabelItalic.Font.Style & ~FontStyle.Italic);
         else
            toolStripStatusLabelItalic.Font = new Font(toolStripStatusLabelItalic.Font, toolStripStatusLabelItalic.Font.Style | FontStyle.Italic);

    }
Ejemplo n.º 9
0
        public QFont(string fileName, float size, FontStyle style, QFontBuilderConfiguration config)
        {
            PrivateFontCollection pfc = new PrivateFontCollection();
            pfc.AddFontFile(fileName);
            var fontFamily = pfc.Families[0];

            if (!fontFamily.IsStyleAvailable(style))
                throw new ArgumentException("Font file: " + fileName + " does not support style: " +  style );

            if (config == null)
                config = new QFontBuilderConfiguration();

            TransformViewport? transToVp = null;
            float fontScale = 1f;
            if (config.TransformToCurrentOrthogProjection)
                transToVp = OrthogonalTransform(out fontScale);

            using(var font = new Font(fontFamily, size * fontScale * config.SuperSampleLevels, style)){
                fontData = BuildFont(font, config, null);
            }

            if (config.ShadowConfig != null)
                Options.DropShadowActive = true;
            if (transToVp != null)
                Options.TransformToViewport = transToVp;

            if(config.UseVertexBuffer)
                InitVBOs();
        }
Ejemplo n.º 10
0
		/// <summary>
		/// Initializes a new instance of the RowStyle class with default settings
		/// </summary>
		public RowStyle()
		{
			this.backColor = Color.Empty;
			this.foreColor = Color.Empty;
			this.font = null;
			this.alignment = RowAlignment.Center;
		}
Ejemplo n.º 11
0
 public Engine_Font(string typeFace, float size, FontStyle fontStyle)
 {
     using (GDIFont gdiFont = new GDIFont(typeFace, size, fontStyle))
     {
         m_Font = new D3DFont(Engine_Game.DGDevice, gdiFont);
     }
 }
Ejemplo n.º 12
0
        protected void SetReactions(HXReaction curReaction, HXReaction newReaction)
        {
            ChangeGeneric(true);
            Font BoldFont = new Font(txtCurReactants.Font, FontStyle.Bold);

            txtCurGeneric.Text = curReaction.ToString();
            txtNewGeneric.Text = newReaction.ToString();

            Match curMatch = HXReaction.s_HXRegex.Match(txtCurGeneric.Text);
            Match newMatch = HXReaction.s_HXRegex.Match(txtNewGeneric.Text);
            string[] groups = new string[] { "Type", "Value", "Value2" };
            foreach (string s in groups)
            {
                Group curGroup = curMatch.Groups[s];
                Group newGroup = newMatch.Groups[s];
                if (curGroup.Value != newGroup.Value)
                {
                    if (curGroup.Success)
                    {
                        txtCurGeneric.Select(curGroup.Index, curGroup.Length);
                        HighlightText(txtCurGeneric);
                    }
                    if (newGroup.Success)
                    {
                        txtNewGeneric.Select(newGroup.Index, newGroup.Length);
                        HighlightText(txtNewGeneric);
                    }
                }
            }
        }
 /// <summary>
 /// Creates an instance of Watermarker class.
 /// </summary>
 public ApplyWatermark ()
 {
     Color = Color.Aquamarine;
     Font = new Font(FontFamily.GenericSansSerif, 16);
     WatermarkText = "(c) ESRI Inc.";
     TextAlignment = ContentAlignment.BottomLeft;
 }
 public void AddString(string s,	FontFamily family,	int style, float emSize, PointF origin, StringFormat format)
 {
     var font = new Font (family.Name, emSize, (FontStyle)style);
     var layoutRect = RectangleF.Empty;
     layoutRect.Location = origin;
     NativeDrawString (s, font, Color.Red, layoutRect, format);
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Gets a width of the string with specified font and font-size.
 /// </summary>
 /// <param name="text">Input string.</param>
 /// <param name="fontName">Font name.</param>
 /// <param name="fontSize">Font size.</param>
 /// <param name="styleFlags">Integer value representing System.Drawing.FontStyle instance.</param>
 /// <returns>Returns a width of specified string in pixels.</returns>
 public static float Get_StringWidth(string text, string fontName, float fontSize, int styleFlags)
 {
     var bitmap	= Graphics.FromImage(new Bitmap(1, 1));
     var font	= new Font(fontName, fontSize / 2, (FontStyle)styleFlags);
     var stringSize	= bitmap.MeasureString(text, font);
     return stringSize.Width;
 }
Ejemplo n.º 16
0
        static unsafe ChatPreview()
        {
            Fonts = new PrivateFontCollection();
            fixed( byte* fontPointer = Resources.MinecraftFont ) {
                Fonts.AddMemoryFont( (IntPtr)fontPointer, Resources.MinecraftFont.Length );
            }
            MinecraftFont = new Font( Fonts.Families[0], 12, FontStyle.Regular );
            ColorPairs = new[]{
                new ColorPair(0,0,0,0,0,0),
                new ColorPair(0,0,191,0,0,47),
                new ColorPair(0,191,0,0,47,0),
                new ColorPair(0,191,191,0,47,47),
                new ColorPair(191,0,0,47,0,0),
                new ColorPair(191,0,191,47,0,47),
                new ColorPair(191,191,0,47,47,0),
                new ColorPair(191,191,191,47,47,47),

                new ColorPair(64,64,64,16,16,16),
                new ColorPair(64,64,255,16,16,63),
                new ColorPair(64,255,64,16,63,16),
                new ColorPair(64,255,255,16,63,63),
                new ColorPair(255,64,64,63,16,16),
                new ColorPair(255,64,255,63,16,63),
                new ColorPair(255,255,64,63,63,16),
                new ColorPair(255,255,255,63,63,63)
            };
        }
Ejemplo n.º 17
0
        public ConsoleLog()
        {
            InitializeComponent();

            _textBox = textBox;

            ConsoleBackColor = Color.FromArgb(51, 51, 51);
            ConsoleFont = new Font("Consolas", 12F, FontStyle.Regular, GraphicsUnit.Point, 0);
            StandardForeColor = Color.FromArgb(225, 213, 112);
            StandardBackColor = Color.FromArgb(51, 51, 51);
            InfoForeColor = Color.FromArgb(99, 211, 234);
            InfoBackColor = Color.FromArgb(51, 51, 51);
            WarningForeColor = Color.FromArgb(51, 51, 51);
            WarningBackColor = Color.FromArgb(255, 252, 0);
            ErrorForeColor = Color.White;
            ErrorBackColor = Color.Tomato;
            SuccessForeColor = Color.FromArgb(163, 233, 45);
            SuccessBackColor = Color.FromArgb(51, 51, 51);
            StandoutForeColor = Color.FromArgb(250, 1, 194);
            StandoutBackColor = Color.FromArgb(51, 51, 51);
            SubtleForeColor = Color.FromArgb(156, 156, 156);
            SubtleBackColor = Color.FromArgb(51, 51, 51);
            EventForeColor = Color.FromArgb(78, 201, 176);
            EventBackColor = Color.FromArgb(51, 51, 51);
            EventWarningForeColor = Color.White;
            EventWarningBackColor = Color.FromArgb(78, 201, 176);

        }
Ejemplo n.º 18
0
        /// <summary>
        /// Load system fonts and create previews of them
        /// </summary>
        /// <returns>Total number of fonts loaded</returns>
        public int LoadSystemFonts()
        {
            FontCollection fc = new InstalledFontCollection();
            int fontCount = 0;

            foreach (FontFamily f in fc.Families)
            {
                fontCount++;

                try
                {
                    FontStyle fs = FontStyle.Strikeout;
                    foreach (FontStyle fos in Enum.GetValues(typeof(FontStyle)))
                    {

                        if (fs == FontStyle.Strikeout && fos != FontStyle.Strikeout)
                        {
                            if (f.IsStyleAvailable(fos))
                            {
                                fs = fos;
                            }
                        }
                    }
                    Font fo = new Font(f, 38f, fs);
                    FamilyViewer fv = new FamilyViewer();
                    fv.PreviewFont = fo;
                    this.AddItem(fv);
                }
                catch (Exception ex)
                {
                    System.Console.WriteLine("Problem displaying " + f.Name);
                }
            }
            return fontCount;
        }
Ejemplo n.º 19
0
        public Settings_Page4(Color c, Language lang)
        {
            InitializeComponent();

            themeColor = c;
            LANG = lang;

            SlideOutButtonVisible = false;

            settings4_1_filelocation_button.Click += settings4_1_filelocation_button_Click;
            settings4_4_language.Items.AddRange(new object[] {"简体中文", "English"});
            settings4_4_language.DrawItem += settings4_4_language_DrawItem;
            settings4_4_language.SelectionChangeCommitted += settings4_4_language_SelectionChangeCommitted;

            settings4_1_filelocation_label.Text = LANG.getString("settings4_1_filelocation_label");
            settings4_1_filelocation_button.Text = LANG.getString("settings4_1_filelocation_button");
            settings4_2_deletetempfiles_label.Text = LANG.getString("settings4_2_deletetempfiles_label");
            settings4_4_chkupd_label.Text = LANG.getString("settings4_4_chkupd_label");
            settings4_4_chkupd_button.Text = LANG.getString("settings4_4_chkupd_button");
            settings4_3_reset_button.Text = LANG.getString("settings4_3_reset_button");
            settings4_1_filelocation_dialog.Description = LANG.getString("settings4_1_filelocation_dialog");
            settings4_4_language_label.Text = LANG.getString("settings4_4_language_label");

            // DPI settings
            AutoScaleDimensions = new SizeF(96F, 96F);
            AutoScaleMode = AutoScaleMode.Dpi;

            // Set UI Font according to language
            LANG.setFont(this.Controls);
            Font = new Font(LANG.getFont(), Font.Size, Font.Style);
        }
Ejemplo n.º 20
0
        private void settings4_4_language_DrawItem(object sender, DrawItemEventArgs e)
        {
            Font objFonts = new Font(this.Font.Name, 14, FontStyle.Bold);
            e.DrawBackground();

            e.Graphics.DrawString(settings4_4_language.Items[e.Index].ToString(), objFonts, new SolidBrush(e.ForeColor), new Point(e.Bounds.Left, e.Bounds.Top));
        }
		public DefaultTextEditorProperties()
		{
			if (DefaultFont == null) {
				DefaultFont = new Font("Courier New", 10);
			}
			this.fontContainer = new FontContainer(DefaultFont);
		}
Ejemplo n.º 22
0
        public TextArea() {

            base.RefreshAllow = false;

            gFont = new Font("宋体", 9);
            gFM = new Fonts.Manager(gFont);
            gColor = Color.Black;
            gnLineHeight = 18;

            base.ShadowsSize = 2;
            base.BorderSize = 1;
            base.SetPadding(0);

            base.BackgroundColor = Color.FromArgb(0, 0, 0, 0);
            base.ShadowsColor = Color.FromArgb(0x22, 0x22, 0x22);
            base.BorderColor = Color.FromArgb(0x88, 0x88, 0x88);

            gItems = new List<TextAreaClass.LineText>();
            SetNullText();

            SetSelectPos(0, 0);

            gVScroll = new VerticalScroll();
            gVScroll.Absolute = true;
            gVScroll.Name = "VerticalScroll";
            gVScroll.BackgroundColor = Color.FromArgb(200, 0x22, 0x22, 0x22);
            gVScroll.SetBounds(base.DisplayRectangle.Width - SCROLL_SIZE, 0, SCROLL_SIZE, base.DisplayRectangle.Height);
            gVScroll.MaxValue = 100;
            gVScroll.Visible = true;
            gVScroll.zIndex = 1;
            gVScroll.ValueChanged += GVScroll_ValueChanged;
            base.Controls.Add(gVScroll);

            base.RefreshAllow = true;
        }
Ejemplo n.º 23
0
        //int mCircsize;
        public ctlMCXY()
        {
            InitializeComponent();
            mArches = new Image[4];
            mArchesSel = new Image[4];
            mOffsets = new Rectangle[4];
            mArchTxtPos = new PointF[4];
            mLevelVals = new float[] { 0.1f, 1, 10, 100 };
            DoubleBuffered = true;
            mSelAxis = 0;
            mSelLevel = 0;
            mCircWidth = 256;
            Height = mCircWidth;
            Width = mCircWidth;
            mInRad = 35;
            mButtRad = mCircWidth / 2;
            mArchWidth = 20;
            mCenter = mCircWidth / 2;
            mButMin = mCenter - 60;
            mButMax = mCenter - 10;
            mButHomePos = 25;
            mArrowPos = (int)(mCenter + mInRad) / 2;

            Font = new Font("Arial", (float)(mArchWidth * 0.75), System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel, ((byte)(0)));
            UpdateOffsets(mCircWidth);
            FrameColor = Color.RoyalBlue;
            mUnit = "mm";
            //UpdateBitmaps();
        }
Ejemplo n.º 24
0
 public FontMetrics(Graphics g, Font f)
 {
     _f = f;
     _ffm = f.FontFamily;
     _fs = f.Style;
     _g = g;
 }
Ejemplo n.º 25
0
        public AccountGridButton()
        {
            InitializeComponent();

            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);

            fontLarge = FONT_LARGE;
            fontSmall = FONT_SMALL;

            brush = new SolidBrush(Color.LightGray);
            pen = new Pen(brush);

            _AccountName = "Example";
            _DisplayName = "*****@*****.**";
            _LastUsed = DateTime.MinValue;
            _ShowAccount = true;

            using (var g = this.CreateGraphics())
            {
                ResizeLabels(g);
            }

            this.Disposed += AccountGridButton_Disposed;
        }
        protected override void OnPaint(PaintEventArgs pea)
        {
            base.OnPaint(pea);

            Graphics grfx = pea.Graphics;

            LinearGradientBrush lgbrush = null;
            Font font = new Font(this.Font.FontFamily, this.Font.Size, this.Font.Style);
            SolidBrush brush = new SolidBrush(this.ForeColor);

            int cw = (this.Width - 20)/7;
            int ch = this.Height - 20;

            for(int i = 0 ; i < 7; i++)
            {
                Rectangle temp = new Rectangle(10+(i*cw), 10, cw, ch );

                if(i < 6)
                    lgbrush = new LinearGradientBrush(temp, colors[i], colors[i+1], LinearGradientMode.Horizontal);
                else
                    lgbrush = new LinearGradientBrush(temp, colors[i], colors[0], LinearGradientMode.Horizontal);

                lgbrush.WrapMode = WrapMode.Tile;
                grfx.FillRectangle(lgbrush, 10+(i*cw), 10, cw, ch );
            }

            grfx.DrawString(this.Text, font, brush, this.Width/3, this.Height/2);
        }
Ejemplo n.º 27
0
		private void FileSubMenu_DropDownOpened(object sender, EventArgs e)
		{
			SaveStateSubMenu.Enabled =
				LoadStateSubMenu.Enabled =
				SaveSlotSubMenu.Enabled =
				Global.Emulator.HasSavestates();

			OpenRomMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Open ROM"].Bindings;
			CloseRomMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Close ROM"].Bindings;

			MovieSubMenu.Enabled =
				CloseRomMenuItem.Enabled =
				!Global.Emulator.IsNull();

			var hasSaveRam = Global.Emulator.HasSaveRam();
			bool needBold = hasSaveRam && Global.Emulator.AsSaveRam().SaveRamModified;

			SaveRAMSubMenu.Enabled = hasSaveRam;
			if (SaveRAMSubMenu.Font.Bold != needBold)
			{
				var font = new System.Drawing.Font(SaveRAMSubMenu.Font, needBold ? FontStyle.Bold : FontStyle.Regular);
				SaveRAMSubMenu.Font.Dispose();
				SaveRAMSubMenu.Font = font;
			}
		}
Ejemplo n.º 28
0
		/// <summary>
		/// Updates the width of the word as it would be
		/// when drawn with the specified font in the specified graphics.
		/// </summary>
		public virtual void UpdateMeasures(Graphics graphics, Font font)
		{
			string word = _value;
			int rangePos = 0;
			int rangeLen = word.Length;

			if (IsWhitespace)
			{
				// Enclose the word in printable characters for
				// Graphics.MeasureText to work correctly.
				// Furthermore tabs are not measured, so replace
				// tabs with, say, 4 spaces
				word = "W" + word + "W";
				word = word.Replace("\t", "    ");
				rangePos = 1;
				rangeLen = word.Length - 2;
			}

			_sformat.SetMeasurableCharacterRanges(new CharacterRange[]
				{
					new CharacterRange(rangePos, rangeLen)
				});
			Region[] r = graphics.MeasureCharacterRanges(
				word, font, _srect, _sformat);
			RectangleF bounds = r[0].GetBounds(graphics);
			r[0].Dispose();

			_width = bounds.Width;
		}
Ejemplo n.º 29
0
		public static void Main( string[] args ) {
			Font f = new Font( "Tahoma", 70 );
			Point drawPos;
			string saveDir = AppDomain.CurrentDomain.BaseDirectory + @"\Minimap\";

			System.IO.Directory.CreateDirectory( saveDir );
			for( int i = 0; i < 200; i++ ) {
				Console.WriteLine( "build Image " + i + ".." );
				using( Bitmap bmp = new Bitmap( 512, 512 ) ) {
					using( Graphics g = Graphics.FromImage( bmp ) ) {
						SizeF stringSize = g.MeasureString( i.ToString(), f );

						drawPos = new Point( 256 - (int)stringSize.Width / 2, 256 - (int)stringSize.Height / 2 );
						g.DrawString( i.ToString(), f, Brushes.White, drawPos );

					}

					DevIL.DevIL.SaveBitmap( saveDir + i + ".tga", bmp );
				}
			}


			Console.WriteLine( "\nfinished" );
			Console.ReadKey();
		}
Ejemplo n.º 30
0
        private void FontCollection()
        {
            // Create the byte array and get its length

            byte[] fontArray = Resources.gill_sans_ultra_bold_condensed;
            int dataLength = Resources.gill_sans_ultra_bold_condensed.Length;

            // ASSIGN MEMORY AND COPY  BYTE[] ON THAT MEMORY ADDRESS
            IntPtr ptrData = Marshal.AllocCoTaskMem(dataLength);
            Marshal.Copy(fontArray, 0, ptrData, dataLength);

            uint cFonts = 0;
            AddFontMemResourceEx(ptrData, (uint)fontArray.Length, IntPtr.Zero, ref cFonts);

            PrivateFontCollection pfc = new PrivateFontCollection();
            //PASS THE FONT TO THE  PRIVATEFONTCOLLECTION OBJECT
            pfc.AddMemoryFont(ptrData, dataLength);

            //FREE THE  "UNSAFE" MEMORY
            Marshal.FreeCoTaskMem(ptrData);

            ff = pfc.Families[0];
            font = new Font(ff, 15f, FontStyle.Bold);
            fontButtonRegular = new Font(ff, 25f, FontStyle.Bold);
            fontButtonSelected = new Font(ff, 30f, FontStyle.Bold);
            fontRankings = new Font(ff, 25f, FontStyle.Bold);

            MyButton._normalFont = fontButtonRegular;
            MyButton._hoverFont = fontButtonSelected;
        }
Ejemplo n.º 31
0
        public ChooseForm(List <string> head, List <string> variants)
        {
            var s    = new Size(ClientSize.Width, ClientSize.Height / (head.Count + variants.Count));
            var font = new System.Drawing.Font("Microsoft Sans Serif", ClientSize.Height / (head.Count + variants.Count) / 2);

            var labels = new List <Label>();

            foreach (var lb in head)
            {
                labels.Add(new Label()
                {
                    Location = new System.Drawing.Point(0, s.Height * labels.Count),
                    Size     = s,
                    Text     = head[labels.Count],
                    Font     = font,
                });
            }
            foreach (var l in labels)
            {
                Controls.Add(l);
            }

            var buttons = new List <Button>();

            foreach (var cmd in variants)
            {
                buttons.Add(new Button()
                {
                    Location = new System.Drawing.Point(0, s.Height * (buttons.Count + head.Count)),
                    Size     = s,
                    Text     = cmd,
                    Font     = font,
                });
            }

            for (int i = 0; i < buttons.Count; ++i)
            {
                var cyka = i;
                Controls.Add(buttons[i]);
                buttons[cyka].Click += (sender, args) => {
                    Answer = cyka;
                    Close();
                };
            }

            SizeChanged += (sender, args) =>
            {
                s    = new Size(ClientSize.Width, ClientSize.Height / (head.Count + variants.Count));
                font = new System.Drawing.Font("Microsoft Sans Serif", ClientSize.Height / (head.Count + variants.Count) / 2);
                for (var v = 0; v < labels.Count; ++v)
                {
                    labels[v].Size     = s;
                    labels[v].Font     = font;
                    labels[v].Location = new System.Drawing.Point(0, s.Height * v);
                }
                for (var v = 0; v < buttons.Count; ++v)
                {
                    buttons[v].Size     = s;
                    buttons[v].Font     = font;
                    buttons[v].Location = new System.Drawing.Point(0, s.Height * (v + labels.Count));
                }
            };
        }
Ejemplo n.º 32
0
        /// <summary>
        /// 计算垂直文字的高度
        /// </summary>
        /// <param name="strOutputContent">文本内容</param>
        /// <param name="bfChinese">itextsharp字体对象</param>
        /// <param name="witchBox">TextBox对象</param>
        /// <returns></returns>
        public static float CalculateVerticalTextWidth(string strOutputContent, TextBox witchBox, string fontPath)
        {
            //这里引用itextsharp的字体,是为了计算空格的大小,因为GDI+对空格的宽度统一为0
            FontFactory.Register(fontPath);
            BaseFont bfChinese = BaseFont.CreateFont(fontPath, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);

            System.Drawing.Text.PrivateFontCollection privateFonts = new System.Drawing.Text.PrivateFontCollection();
            privateFonts.AddFontFile(fontPath);

            System.Drawing.Font font = new System.Drawing.Font(privateFonts.Families[0], witchBox.pt, FontStyle.Regular, GraphicsUnit.Pixel);

            float kongGe     = bfChinese.GetWidthPointKerned("r", witchBox.pt);                        //设置空格的宽度=字符"r"的宽度
            float marginLeft = kongGe / 2;                                                             //绘制英文的偏移量,因为旋转后的英文会向左边移动一点距离,这里设置为空格宽度的一半距离
            float cellHeight = 0;                                                                      //两行之间的空隙距离

            if (witchBox.leading != null && witchBox.leading > 0.1f && witchBox.leading > witchBox.pt) //如果存在间距就计算两行之间的距离
            {
                cellHeight = witchBox.leading - witchBox.pt;
            }
            float defaultCellHeight = 0;     //旋转字符之间的字间距,给一个默认值
            bool  isRotate          = false; //如果是旋转字符,那个就没有行距

            float startY = 0;

            for (int i = 0; i < strOutputContent.Length; i++)
            {
                //解决字母间距过大的问题
                if (IsRotateChar(strOutputContent[i]))
                {
                    //竖向绘制字母
                    float Cut           = 0;
                    float standardWidth = bfChinese.GetWidthPointKerned("e", witchBox.pt);
                    if (i < strOutputContent.Length - 1)
                    {
                        if (!IsRotateChar(strOutputContent[i + 1]))
                        {
                            Cut      = standardWidth;
                            isRotate = false; //如果下一个字符是非旋转字符,就有行距
                        }
                        else
                        {
                            isRotate = true; //如果下一个字符是旋转字符,那个就没有行距
                        }
                        //defaultCellHeight = GetRotateSpecialSpace(strOutputContent[i], strOutputContent[i + 1]); //旋转字符根据特殊情况,返回特殊间距
                    }
                    float width     = bfChinese.GetWidthPointKerned(strOutputContent[i].ToString(), witchBox.pt);
                    float lessWidth = kongGe + 0.9f; //设置最小宽度标准,如果字符的宽度小于这个标准值就特殊处理
                    if (strOutputContent[i] == ' ')  //如果是空格就采用空格的宽度绘制
                    {
                        width = kongGe;
                    }
                    else if (width < bfChinese.GetWidthPointKerned(" ", witchBox.pt)) //如果小于空格大小,就两倍的宽度
                    {
                        width += width;
                    }
                    else if (width < lessWidth)   //字符宽度大于空格,但小于标准值的,就用一个“e”字母的宽度来计算
                    {
                        width = standardWidth;
                    }
                    startY += width + Cut + (isRotate ? defaultCellHeight : cellHeight);
                }
                else
                {
                    float cutY = 0;
                    if (i < strOutputContent.Length - 1)
                    {
                        if (IsRotateChar(strOutputContent[i + 1]))
                        {
                            cutY = kongGe;
                        }
                    }
                    startY += font.GetHeight() + cutY + cellHeight;
                }
            }
            return(startY);
        }
Ejemplo n.º 33
0
        private Image Label_Generic(Image img)
        {
            try
            {
                System.Drawing.Font font = this.LabelFont;

                using (Graphics g = Graphics.FromImage(img))
                {
                    g.DrawImage(img, (float)0, (float)0);

                    g.SmoothingMode      = SmoothingMode.HighQuality;
                    g.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                    g.PixelOffsetMode    = PixelOffsetMode.HighQuality;
                    g.CompositingQuality = CompositingQuality.HighQuality;

                    StringFormat f = new StringFormat();
                    f.Alignment     = StringAlignment.Near;
                    f.LineAlignment = StringAlignment.Near;
                    int LabelX = 0;
                    int LabelY = 0;

                    switch (LabelPosition)
                    {
                    case LabelPositions.BOTTOMCENTER:
                        LabelX      = img.Width / 2;
                        LabelY      = img.Height - (font.Height);
                        f.Alignment = StringAlignment.Center;
                        break;

                    case LabelPositions.BOTTOMLEFT:
                        LabelX      = 0;
                        LabelY      = img.Height - (font.Height);
                        f.Alignment = StringAlignment.Near;
                        break;

                    case LabelPositions.BOTTOMRIGHT:
                        LabelX      = img.Width;
                        LabelY      = img.Height - (font.Height);
                        f.Alignment = StringAlignment.Far;
                        break;

                    case LabelPositions.TOPCENTER:
                        LabelX      = img.Width / 2;
                        LabelY      = 0;
                        f.Alignment = StringAlignment.Center;
                        break;

                    case LabelPositions.TOPLEFT:
                        LabelX      = img.Width;
                        LabelY      = 0;
                        f.Alignment = StringAlignment.Near;
                        break;

                    case LabelPositions.TOPRIGHT:
                        LabelX      = img.Width;
                        LabelY      = 0;
                        f.Alignment = StringAlignment.Far;
                        break;
                    }//switch

                    //color a background color box at the bottom of the barcode to hold the string of data
                    g.FillRectangle(new SolidBrush(BackColor), new RectangleF((float)0, (float)LabelY, (float)img.Width, (float)font.Height));

                    //draw datastring under the barcode image
                    g.DrawString(AlternateLabel == null ? RawData : AlternateLabel, font, new SolidBrush(ForeColor), new RectangleF((float)0, (float)LabelY, (float)img.Width, (float)font.Height), f);

                    g.Save();
                } //using
                return(img);
            }     //try
            catch (Exception ex)
            {
                throw new Exception("ELABEL_GENERIC-1: " + ex.Message);
            } //catch
        }     //Label_Generic
Ejemplo n.º 34
0
        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            //System.Drawing.Font tabelTextFont = new System.Drawing.Font("宋体", 10);
            if (dg_userlog.DataBindings != null)
            {
                System.Drawing.Font TitleFont   = new System.Drawing.Font("隶书", 25, FontStyle.Bold);
                System.Drawing.Font HeaderFont  = new System.Drawing.Font("宋体", 12);
                System.Drawing.Font ContentFont = new System.Drawing.Font("宋体", 12);

                System.Drawing.Point currentPoint  = new System.Drawing.Point();
                System.Drawing.Point currentPoint2 = new System.Drawing.Point();

                //int[] columnsWidth = new int[dg_userlog.Columns.Count];//得到所有列的个数
                //int[] columnsLeft = new int[dg_userlog.Columns.Count]; //
                if (iCurrentLine == 0)
                {
                    for (int c = 0; c < iColCount; c++)//得到列标题的宽度
                    {
                        columnsWidth[c] = (int)e.Graphics.MeasureString(dg_userlog.Columns[c].HeaderText, HeaderFont).Width;
                    }

                    for (int rowIndex = 0; rowIndex < nCount; rowIndex++)                 //rowindex当前行
                    {
                        for (int columnIndex = 0; columnIndex < iColCount; columnIndex++) //当前列
                        {
                            int w = (int)e.Graphics.MeasureString(dg_userlog.Rows[rowIndex].Cells[columnIndex].Value.ToString(), ContentFont
                                                                  ).Width;
                            columnsWidth[columnIndex] = w > columnsWidth[columnIndex] ? w : columnsWidth[columnIndex];
                        }
                    }
                }

                int rowHidth  = 23;
                int tableLeft = 30;
                int tableTop  = 70;

                columnsLeft[0] = tableLeft;
                for (int i = 1; i <= iColCount - 1; i++)
                {
                    columnsLeft[i] = columnsLeft[i - 1] + columnsWidth[i - 1] + 20;
                }
                StringFormat sf = new StringFormat();
                sf.Alignment = StringAlignment.Center;                                                                                                                                      //居中打印

                e.Graphics.DrawString(gAppData.SHName[gAppData.iCurrentSH] + TitleName, TitleFont, System.Drawing.Brushes.Black, new System.Drawing.Point(e.PageBounds.Width / 2, 25), sf); //打印标题

                for (int c = 0; c < iColCount; c++)                                                                                                                                         //打印表中的列名
                {
                    currentPoint.X = columnsLeft[c];
                    currentPoint.Y = tableTop;
                    e.Graphics.DrawString(dg_userlog.Columns[c].HeaderText, HeaderFont, Brushes.Black, currentPoint);


                    currentPoint2.X = columnsLeft[c] + columnsWidth[c];
                    for (int d = 0; d < 3; d++)//
                    {
                        currentPoint.Y  = tableTop + 25 + d;
                        currentPoint2.Y = tableTop + 25 + d;
                        //Pen pen = new Pen(Brushes.Black);
                        e.Graphics.DrawLine(Pens.Black, currentPoint, currentPoint2);
                    }
                }
                //打印表中的内容
                int iTempCount = 0;
                if (nCount - iCurrentLine > iLinePerPage)
                {
                    e.HasMorePages = true;
                    iTempCount     = iLinePerPage;
                }
                else
                {
                    e.HasMorePages = false;
                    iTempCount     = nCount - iCurrentLine;
                }

                //打印内容
                for (int rowIndex = 0; rowIndex < iTempCount; rowIndex++)
                {
                    for (int columnIndex = 0; columnIndex < dg_userlog.Columns.Count; columnIndex++)
                    {
                        currentPoint.X = columnsLeft[columnIndex];
                        currentPoint.Y = tableTop + (int)(rowHidth * (rowIndex + 2));
                        string str = dg_userlog.Rows[iCurrentLine].Cells[columnIndex].Value.ToString();
                        e.Graphics.DrawString(str, ContentFont, System.Drawing.Brushes.Black, currentPoint);
                    }
                    iCurrentLine++;
                }
                //打印结束分割线
                currentPoint.X  = columnsLeft[0];
                currentPoint2.X = columnsLeft[0] + e.PageBounds.Width - 100;
                for (int d = 0; d < 3; d++)
                {
                    currentPoint.Y  = e.PageBounds.Height - 120 + d;
                    currentPoint2.Y = e.PageBounds.Height - 120 + d;
                    //Pen pen = new Pen(Brushes.Black);
                    e.Graphics.DrawLine(Pens.Black, currentPoint, currentPoint2);
                }
                e.Graphics.DrawString("打印时间:" + DateTime.Now.ToString(), HeaderFont, Brushes.Black, columnsLeft[0] + 10, currentPoint2.Y + 16);
                int iPagenum = (iCurrentLine / iLinePerPage);
                if (iCurrentLine % iLinePerPage > 0)
                {
                    iPagenum++;
                }
                e.Graphics.DrawString("页号:" + iPagenum.ToString(), HeaderFont, Brushes.Black, e.PageBounds.Width - 150, currentPoint2.Y + 16);
            }
        }
 public override void m_mthPrintNextLine(ref int p_intPosY, System.Drawing.Graphics p_objGrp, System.Drawing.Font p_fntNormalText)
 {
     if (m_hasItems != null)
     {
         if (m_hasItems.Contains("体格检查>>诊断"))
         {
             objItemContent = m_hasItems["体格检查>>诊断"] as clsInpatMedRec_Item;
         }
     }
     if (objItemContent == null || objItemContent.m_strItemContent == "" || objItemContent.m_strItemContent == null)
     {
         m_blnHaveMoreLine = false;
         return;
     }
     if (m_blnIsFirstPrint)
     {
         p_objGrp.DrawString("诊断:", p_fntNormalText, Brushes.Black, m_intRecBaseX + 10, p_intPosY);
         p_intPosY += 20;
         m_objPrintContext.m_mthSetContextWithCorrectBefore((objItemContent == null ? "" : objItemContent.m_strItemContent), (objItemContent == null ? "<root />" : objItemContent.m_strItemContentXml), m_dtmFirstPrintTime, objItemContent != null);
         m_mthAddSign2("体格检查>>诊断:", m_objPrintContext.m_ObjModifyUserArr);
         m_blnIsFirstPrint = false;
     }
     if (m_objPrintContext.m_BlnHaveNextLine())
     {
         m_objPrintContext.m_mthPrintLine((int)enmRectangleInfoInPatientCaseInfo.PrintWidth, m_intRecBaseX + 50, p_intPosY, p_objGrp);
         p_intPosY += 20;
         m_intTimes++;
     }
     if (m_objPrintContext.m_BlnHaveNextLine())
     {
         m_blnHaveMoreLine = true;
     }
     else
     {
         m_blnHaveMoreLine = false;
     }
 }
Ejemplo n.º 36
0
 /// <summary>Initializes a new <see cref="T:System.Drawing.Font" /> that uses the specified existing <see cref="T:System.Drawing.Font" /> and <see cref="T:System.Drawing.FontStyle" /> enumeration.</summary>
 /// <param name="prototype">The existing <see cref="T:System.Drawing.Font" /> from which to create the new <see cref="T:System.Drawing.Font" />.</param>
 /// <param name="newStyle">The <see cref="T:System.Drawing.FontStyle" /> to apply to the new <see cref="T:System.Drawing.Font" />. Multiple values of the <see cref="T:System.Drawing.FontStyle" /> enumeration can be combined with the <see langword="OR" /> operator.</param>
 public Font(Font prototype, FontStyle newStyle)
 {
     Initialize(prototype.FontFamily, prototype.Size, newStyle, prototype.Unit, 1, gdiVerticalFont: false);
 }
Ejemplo n.º 37
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (ShowMarkup == false)
            {
                return;
            }

            Point zeroPoint = new Point(0, 0);
            int   start     = GetCharIndexFromPosition(zeroPoint);
            int   end       = GetCharIndexFromPosition(new Point(this.ClientSize.Width, this.ClientSize.Height));

            if (start >= end)
            {
                return;                           // don't paint if there's no size here
            }
            if (showPartsOfSpeechMode == true)
            {
                // paint the parts of speech if in his mode (slow)
                try
                {
                    string   currentword        = "";
                    Point    startofcurrentword = zeroPoint;
                    Graphics g;

                    g = CreateGraphics();
                    System.Drawing.Font       drawFont  = new System.Drawing.Font("Courier", 8);
                    System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Red);


                    for (int i = start; i <= (end - start); i++)
                    {
                        // iterate/
                        // when we find a word break we stop building that word?
                        if (Text[i] != ' ' && Text[i] != '-' && Text[i] != '.' && Text[i] != '?' && Text[i] != '!' &&
                            Text[i] != ';' && Text[i] != ':' && Text[i] != ',')
                        {
                            currentword = currentword + Text[i];
                        }
                        else
                        {
                            // try to avoid blank words clogging things
                            if (currentword != null && currentword != " " && currentword != "")
                            {
                                //   Graphics g;

                                //  g = CreateGraphics();
                                if (g != null)
                                {
                                    startofcurrentword = CoreUtilities.General.BuildLocationForOverlayText(startofcurrentword, DockStyle.Fill, currentword);
                                    int x_modifier = 5;
                                    if (Char.IsUpper(currentword[0]) == false)
                                    {
                                        x_modifier = 15;                                         // middle words need more spacing
                                    }

                                    startofcurrentword = new Point(startofcurrentword.X + x_modifier, startofcurrentword.Y + 10);
                                    //g.DrawString("FINISH PORTING THIS", drawFont, drawBrush, startofcurrentword);
                                    g.DrawString(LayoutDetails.Instance.WordSystemInUse.GetPartOfSpeech(currentword.Trim()), drawFont, drawBrush, startofcurrentword);
                                }
                                // clear
                                currentword        = "";
                                startofcurrentword = GetPositionFromCharIndex(i);
                            }
                        }
                    }
                    drawFont.Dispose();
                    drawBrush.Dispose();
                    g.Dispose();
                }
                catch (Exception ex)
                {
                    NewMessage.Show(String.Format("Failed in parts of speech Start {0} End {1}", start, end) + ex.ToString());
                }
            }


            // May 2013 - Optimization
            // only markup the active text box
            //if (LayoutDetails.Instance.CurrentLayout != null && LayoutDetails.Instance.CurrentLayout.CurrentTextNote != null &&
            if (this.Focused == true)
            {
                if (null != markupOverride)
                {
                    markupOverride.DoPaint(e, start, end, this);
                }
                else
                {
                    LayoutDetails.Instance.GetCurrentMarkup().DoPaint(e, start, end, this);
                }
            }
        }
Ejemplo n.º 38
0
        const string KeyPrefix = "tk:";  // "typeface key"

#if CORE || GDI
        XGlyphTypeface(string key, XFontFamily fontFamily, XFontSource fontSource, XStyleSimulations styleSimulations, GdiFont gdiFont)
        {
            _key        = key;
            _fontFamily = fontFamily;
            _fontSource = fontSource;

            _fontface = OpenTypeFontface.CetOrCreateFrom(fontSource);
            Debug.Assert(ReferenceEquals(_fontSource.Fontface, _fontface));

            _gdiFont = gdiFont;

            _styleSimulations = styleSimulations;
            Initialize();
        }
Ejemplo n.º 39
0
        public static XGlyphTypeface GetOrCreateFrom(string familyName, FontResolvingOptions fontResolvingOptions)
        {
            // Check cache for requested type face.
            string         typefaceKey = ComputeKey(familyName, fontResolvingOptions);
            XGlyphTypeface glyphTypeface;

            if (GlyphTypefaceCache.TryGetGlyphTypeface(typefaceKey, out glyphTypeface))
            {
                // Just return existing one.
                return(glyphTypeface);
            }

            // Resolve typeface by FontFactory.
            FontResolverInfo fontResolverInfo = FontFactory.ResolveTypeface(familyName, fontResolvingOptions, typefaceKey);

            if (fontResolverInfo == null)
            {
                // No fallback - just stop.
                throw new InvalidOperationException("No appropriate font found.");
            }

#if CORE || GDI
            GdiFont gdiFont = null;
#endif
#if WPF
            WpfFontFamily    wpfFontFamily    = null;
            WpfTypeface      wpfTypeface      = null;
            WpfGlyphTypeface wpfGlyphTypeface = null;
#endif
#if UWP
            // Nothing to do.
#endif
            // Now create the font family at the first.
            XFontFamily fontFamily;
            PlatformFontResolverInfo platformFontResolverInfo = fontResolverInfo as PlatformFontResolverInfo;
            if (platformFontResolverInfo != null)
            {
#if CORE || GDI
                // $TODO THHO Lock???
                // Reuse GDI+ font from platform font resolver.
                gdiFont    = platformFontResolverInfo.GdiFont;
                fontFamily = XFontFamily.GetOrCreateFromGdi(gdiFont);
#endif
#if WPF
#if !SILVERLIGHT
                // Reuse WPF font family created from platform font resolver.
                wpfFontFamily    = platformFontResolverInfo.WpfFontFamily;
                wpfTypeface      = platformFontResolverInfo.WpfTypeface;
                wpfGlyphTypeface = platformFontResolverInfo.WpfGlyphTypeface;
                fontFamily       = XFontFamily.GetOrCreateFromWpf(wpfFontFamily);
#else
                fontFamily = XFontFamily.GetOrCreateFromWpf(new WpfFontFamily(familyName));
#endif
#endif
#if NETFX_CORE || UWP
                fontFamily = null;
#endif
            }
            else
            {
                // Create new and exclusively used font family for custom font resolver retrieved font source.
                fontFamily = XFontFamily.CreateSolitary(fontResolverInfo.FaceName);
            }

            // We have a valid font resolver info. That means we also have an XFontSource object loaded in the cache.
            ////XFontSource fontSource = FontFactory.GetFontSourceByTypefaceKey(fontResolverInfo.FaceName);
            XFontSource fontSource = FontFactory.GetFontSourceByFontName(fontResolverInfo.FaceName);
            Debug.Assert(fontSource != null);

            // Each font source already contains its OpenTypeFontface.
#if CORE || GDI
            glyphTypeface = new XGlyphTypeface(typefaceKey, fontFamily, fontSource, fontResolverInfo.StyleSimulations, gdiFont);
#endif
#if WPF
            glyphTypeface = new XGlyphTypeface(typefaceKey, fontFamily, fontSource, fontResolverInfo.StyleSimulations, wpfTypeface, wpfGlyphTypeface);
#endif
#if NETFX_CORE || UWP
            glyphTypeface = new XGlyphTypeface(typefaceKey, fontFamily, fontSource, fontResolverInfo.StyleSimulations);
#endif
            GlyphTypefaceCache.AddGlyphTypeface(glyphTypeface);

            return(glyphTypeface);
        }
Ejemplo n.º 40
0
        /// <summary>
        /// Draws the specified string to the backing store.
        /// </summary>
        /// <param name="text">The <see cref="System.String"/> to draw.</param>
        /// <param name="font">The <see cref="System.Drawing.Font"/> that will be used.</param>
        /// <param name="brush">The <see cref="System.Drawing.Brush"/> that will be used.</param>
        /// <param name="point">The location of the text on the backing store, in 2d pixel coordinates.
        /// The origin (0, 0) lies at the top-left corner of the backing store.</param>
        public void DrawString(string text, System.Drawing.Font font, Brush brush, Point point, StringFormat format)
        {
            graphics.DrawString(text, font, brush, new System.Drawing.Point(point.X, point.Y), format); // render text on the bitmap

            OpenTKRendererBase.LoadTextureInternal(texture, bitmap);                                    // copy bitmap to gl texture
        }
            public override void m_mthPrintNextLine(ref int p_intPosY, System.Drawing.Graphics p_objGrp, System.Drawing.Font p_fntNormalText)
            {
                if (m_objContent == null || m_objContent.m_objItemContents == null)
                {
                    m_blnHaveMoreLine = false;
                    return;
                }
                //				if(m_blnHavePrintInfo(m_strKeysArr1) == false )
                //				{
                //					m_blnHaveMoreLine = false;
                //					return;
                //				}
                if (m_blnIsFirstPrint)
                {
                    p_intPosY += 20;
                    p_objGrp.DrawString("体 格 检 查", m_fotItemHead, Brushes.Black, m_intRecBaseX + 310, p_intPosY);
                    p_intPosY += 40;

                    string strAllText   = "";
                    string strXml       = "";
                    string strFirstName = new clsEmployee(m_objContent.m_strCreateUserID).m_StrFirstName;
                    if (m_objContent != null)
                    {
                        if (m_blnHavePrintInfo(m_strKeysArr01) != false)
                        {
                            m_mthMakeText(m_strKeysArr101, m_strKeysArr01, ref strAllText, ref strXml);
                        }
                        if (m_blnHavePrintInfo(m_strKeysArr02) != false)
                        {
                            m_mthMakeText(m_strKeysArr102, m_strKeysArr02, ref strAllText, ref strXml);
                        }
                        if (m_blnHavePrintInfo(m_strKeysArr03) != false)
                        {
                            m_mthMakeText(m_strKeysArr103, m_strKeysArr03, ref strAllText, ref strXml);
                        }
                        if (m_blnHavePrintInfo(m_strKeysArr04) != false)
                        {
                            m_mthMakeText(m_strKeysArr104, m_strKeysArr04, ref strAllText, ref strXml);
                        }
                        if (m_blnHavePrintInfo(m_strKeysArr05) != false)
                        {
                            m_mthMakeText(m_strKeysArr105, m_strKeysArr05, ref strAllText, ref strXml);
                        }
                        if (m_blnHavePrintInfo(m_strKeysArr06) != false)
                        {
                            m_mthMakeText(m_strKeysArr106, m_strKeysArr06, ref strAllText, ref strXml);
                        }
                        if (m_blnHavePrintInfo(m_strKeysArr07) != false)
                        {
                            m_mthMakeText(m_strKeysArr107, m_strKeysArr07, ref strAllText, ref strXml);
                        }
                        if (m_blnHavePrintInfo(m_strKeysArr08) != false)
                        {
                            m_mthMakeText(m_strKeysArr108, m_strKeysArr08, ref strAllText, ref strXml);
                        }
                        if (m_blnHavePrintInfo(m_strKeysArr09) != false)
                        {
                            m_mthMakeText(m_strKeysArr109, m_strKeysArr09, ref strAllText, ref strXml);
                        }
                        if (m_blnHavePrintInfo(m_strKeysArr10) != false)
                        {
                            m_mthMakeText(m_strKeysArr110, m_strKeysArr10, ref strAllText, ref strXml);
                        }
                    }
                    else
                    {
                        m_blnHaveMoreLine = false;
                        return;
                    }
                    m_objPrintContext.m_mthSetContextWithCorrectBefore(strAllText, strXml, m_dtmFirstPrintTime, m_objContent.m_objItemContents != null);
                    m_mthAddSign2("体格检查:", m_objPrintContext.m_ObjModifyUserArr);
                    m_blnIsFirstPrint = false;
                }

                if (m_objPrintContext.m_BlnHaveNextLine())
                {
                    m_objPrintContext.m_mthPrintLine((int)enmRectangleInfoInPatientCaseInfo.PrintWidth2, m_intRecBaseX + 10, p_intPosY, p_objGrp);
                    p_intPosY += 20;
                }
                if (m_objPrintContext.m_BlnHaveNextLine())
                {
                    m_blnHaveMoreLine = true;
                }
                else
                {
                    m_blnHaveMoreLine = false;
                }
            }
Ejemplo n.º 42
0
 internal void DrawString(string s, Font font, Brush brush, RectangleF layoutRectangle)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 43
0
        public void m_mthPrintNextLine(int p_intX, int p_intPosY, System.Drawing.Graphics p_objGrp, System.Drawing.Font p_fntNormalText)
        {
            if (m_intCurrentPrintIndex < m_arlSignInfo.Count)
            {
                clsSignInfo2 objSignInfo = (clsSignInfo2)m_arlSignInfo[m_intCurrentPrintIndex];

                //还没有打印完一处内容的修改者
                if (m_intSignIndex < objSignInfo.m_objModifyUserArr.Length)
                {
                    if (m_intSignIndex == 1)
                    {
                        p_objGrp.DrawString(objSignInfo.m_strPartDesc, p_fntNormalText, Brushes.Black, p_intX, p_intPosY);
                        m_fltDescWidth = p_objGrp.MeasureString(objSignInfo.m_strPartDesc, p_fntNormalText).Width;
                    }

                    p_objGrp.DrawString(m_intSignIndex + " " + objSignInfo.m_objModifyUserArr[m_intSignIndex].m_strUserName + " " + objSignInfo.m_objModifyUserArr[m_intSignIndex].m_dtmModifyDate.ToString(), p_fntNormalText, Brushes.Black, p_intX + m_fltDescWidth, p_intPosY);

                    m_intSignIndex++;
                }

                if (m_intSignIndex >= objSignInfo.m_objModifyUserArr.Length)
                {
                    m_intCurrentPrintIndex++;
                    m_intSignIndex = 1;
                    m_fltDescWidth = 0;
                }

                if (m_intCurrentPrintIndex < m_arlSignInfo.Count)
                {
                    m_blnHaveMoreLine = true;
                }
                else
                {
                    m_blnHaveMoreLine = false;
                }
            }
            else
            {
                m_blnHaveMoreLine = false;
            }
        }
Ejemplo n.º 44
0
 private void InitializeComponent()
 {
     components   = new System.ComponentModel.Container();
     p            = new System.Windows.Forms.Panel();
     Button1      = new System.Windows.Forms.Button();
     Label2       = new System.Windows.Forms.Label();
     lCUName      = new System.Windows.Forms.Label();
     lLicensed    = new System.Windows.Forms.Label();
     lCopyright   = new System.Windows.Forms.Label();
     lVer         = new System.Windows.Forms.Label();
     lMember      = new System.Windows.Forms.Label();
     lLicenseType = new System.Windows.Forms.Label();
     Label1       = new System.Windows.Forms.Label();
     pbCompLogo   = new System.Windows.Forms.PictureBox();
     pbProdLogo   = new System.Windows.Forms.PictureBox();
     tt           = new System.Windows.Forms.ToolTip(components);
     p.SuspendLayout();
     ((System.ComponentModel.ISupportInitialize)pbCompLogo).BeginInit();
     ((System.ComponentModel.ISupportInitialize)pbProdLogo).BeginInit();
     SuspendLayout();
     p.BackColor   = System.Drawing.Color.White;
     p.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
     p.Controls.Add(Button1);
     p.Controls.Add(Label2);
     p.Controls.Add(lCUName);
     p.Controls.Add(lLicensed);
     p.Controls.Add(lCopyright);
     p.Controls.Add(lVer);
     p.Controls.Add(lMember);
     p.Controls.Add(lLicenseType);
     p.Controls.Add(Label1);
     p.Controls.Add(pbCompLogo);
     p.Controls.Add(pbProdLogo);
     p.Location                      = new System.Drawing.Point(9, 9);
     p.Margin                        = new System.Windows.Forms.Padding(3, 4, 3, 4);
     p.Name                          = "p";
     p.Size                          = new System.Drawing.Size(587, 203);
     p.TabIndex                      = 2;
     Button1.DialogResult            = System.Windows.Forms.DialogResult.Cancel;
     Button1.Location                = new System.Drawing.Point(170, 938);
     Button1.Name                    = "Button1";
     Button1.Size                    = new System.Drawing.Size(75, 22);
     Button1.TabIndex                = 10;
     Button1.Text                    = "Button1";
     Button1.UseVisualStyleBackColor = true;
     Label2.BackColor                = System.Drawing.Color.Gray;
     Label2.Location                 = new System.Drawing.Point(-1, 145);
     Label2.Name                     = "Label2";
     Label2.Size                     = new System.Drawing.Size(700, 1);
     Label2.TabIndex                 = 9;
     lCUName.AutoSize                = true;
     lCUName.ForeColor               = System.Drawing.Color.Blue;
     lCUName.Location                = new System.Drawing.Point(9, 179);
     lCUName.Name                    = "lCUName";
     lCUName.Size                    = new System.Drawing.Size(76, 15);
     lCUName.TabIndex                = 7;
     lCUName.Text                    = "Licensed to...";
     lLicensed.AutoSize              = true;
     lLicensed.Location              = new System.Drawing.Point(9, 155);
     lLicensed.Name                  = "lLicensed";
     lLicensed.Size                  = new System.Drawing.Size(145, 15);
     lLicensed.TabIndex              = 4;
     lLicensed.Text                  = "This product is licensed to";
     lCopyright.AutoSize             = true;
     lCopyright.Location             = new System.Drawing.Point(137, 121);
     lCopyright.Name                 = "lCopyright";
     lCopyright.Size                 = new System.Drawing.Size(69, 15);
     lCopyright.TabIndex             = 5;
     lCopyright.Text                 = "Copyright...";
     lVer.AutoSize                   = true;
     lVer.Location                   = new System.Drawing.Point(137, 97);
     lVer.Name                       = "lVer";
     lVer.Size                       = new System.Drawing.Size(55, 15);
     lVer.TabIndex                   = 4;
     lVer.Text                       = "Version...";
     lMember.AutoSize                = true;
     lMember.Location                = new System.Drawing.Point(137, 73);
     lMember.Name                    = "lMember";
     lMember.Size                    = new System.Drawing.Size(295, 15);
     lMember.TabIndex                = 4;
     lMember.Text                    = "Member of TriSun Software Windows Explorer solution";
     lLicenseType.AutoSize           = true;
     lLicenseType.Font               = new System.Drawing.Font("Segoe UI", 17f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
     lLicenseType.ForeColor          = System.Drawing.Color.FromArgb(0, 174, 29);
     lLicenseType.Location           = new System.Drawing.Point(137, 41);
     lLicenseType.Name               = "lLicenseType";
     lLicenseType.Size               = new System.Drawing.Size(118, 23);
     lLicenseType.TabIndex           = 3;
     lLicenseType.Text               = "License Type...";
     Label1.AutoSize                 = true;
     Label1.Font                     = new System.Drawing.Font("Segoe UI", 17f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
     Label1.Location                 = new System.Drawing.Point(137, 9);
     Label1.Name                     = "Label1";
     Label1.Size                     = new System.Drawing.Size(221, 23);
     Label1.TabIndex                 = 3;
     Label1.Text                     = "Duplicate Photo Finder Plus";
     pbCompLogo.Cursor               = System.Windows.Forms.Cursors.Hand;
     pbCompLogo.Image                = My.Resources.Resources.tsslogo;
     pbCompLogo.Location             = new System.Drawing.Point(435, 2);
     pbCompLogo.Margin               = new System.Windows.Forms.Padding(3, 5, 3, 5);
     pbCompLogo.Name                 = "pbCompLogo";
     pbCompLogo.Size                 = new System.Drawing.Size(142, 60);
     pbCompLogo.SizeMode             = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
     pbCompLogo.TabIndex             = 1;
     pbCompLogo.TabStop              = false;
     tt.SetToolTip(pbCompLogo, "Company Homepage");
     pbProdLogo.Cursor   = System.Windows.Forms.Cursors.Hand;
     pbProdLogo.Image    = My.Resources.Resources.logo128;
     pbProdLogo.Location = new System.Drawing.Point(0, 0);
     pbProdLogo.Margin   = new System.Windows.Forms.Padding(3, 5, 3, 5);
     pbProdLogo.Name     = "pbProdLogo";
     pbProdLogo.Size     = new System.Drawing.Size(128, 128);
     pbProdLogo.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
     pbProdLogo.TabIndex = 0;
     pbProdLogo.TabStop  = false;
     tt.SetToolTip(pbProdLogo, "Product Homepage");
     tt.IsBalloon             = true;
     base.AutoScaleDimensions = new System.Drawing.SizeF(7f, 15f);
     base.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
     BackColor         = System.Drawing.Color.FromArgb(103, 103, 103);
     base.CancelButton = Button1;
     base.ClientSize   = new System.Drawing.Size(605, 222);
     base.Controls.Add(p);
     Font                 = new System.Drawing.Font("Segoe UI", 11.9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
     ForeColor            = System.Drawing.Color.FromArgb(72, 72, 72);
     base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
     base.Margin          = new System.Windows.Forms.Padding(3, 5, 3, 5);
     base.MaximizeBox     = false;
     base.MinimizeBox     = false;
     base.Name            = "About";
     base.ShowInTaskbar   = false;
     base.StartPosition   = System.Windows.Forms.FormStartPosition.CenterParent;
     Text                 = "About Duplicate Photo Finder Plus";
     p.ResumeLayout(false);
     p.PerformLayout();
     ((System.ComponentModel.ISupportInitialize)pbCompLogo).EndInit();
     ((System.ComponentModel.ISupportInitialize)pbProdLogo).EndInit();
     ResumeLayout(false);
 }
            public override void m_mthPrintNextLine(ref int p_intPosY, System.Drawing.Graphics p_objGrp, System.Drawing.Font p_fntNormalText)
            {
                objItemContent = m_objGetContentFromItemArr(m_strKeysArr);
                if (objItemContent == null)
                {
                    m_blnHaveMoreLine = false;
                    return;
                }
                if (objItemContent[0] == null)
                {
                    m_blnHaveMoreLine = false;
                    return;
                }
                p_objGrp.DrawString("月经生育史:", p_fntNormalText, Brushes.Black, m_intRecBaseX + 10, p_intPosY);
                p_intPosY += 30;

                string strLastTime = "";

                try
                {
                    if (objItemContent[5] != null && objItemContent[4] != null)
                    {
                        if (objItemContent[5].m_strItemContent.Trim() != "已绝经")
                        {
                            strLastTime = DateTime.Parse(objItemContent[4].m_strItemContent.Trim()).ToString("yyyy年M月d日") + ",";
                        }
                    }
                }
                catch {}
                string strPrintText = "";

                if (objItemContent[1] != null)
                {
                    strPrintText += objItemContent[1].m_strItemContent + "              " + strLastTime;
                }
//				if(objItemContent[2] != null)
//					strPrintText += objItemContent[2].m_strItemContent;
                if (objItemContent[5] != null)
                {
                    strPrintText += objItemContent[5].m_strItemContent + "。";
                }
                p_objGrp.DrawString(strPrintText, p_fntNormalText, Brushes.Black, m_intRecBaseX + 30, p_intPosY);

                p_objGrp.DrawLine(new Pen(Brushes.Black), m_intRecBaseX + 90, p_intPosY + 10, m_intRecBaseX + 150, p_intPosY + 10);

                if (objItemContent[2] != null)
                {
                    p_objGrp.DrawString(objItemContent[2].m_strItemContent, new Font("", 8), Brushes.Black, m_intRecBaseX + 100, p_intPosY - 5);
                }
                if (objItemContent[3] != null)
                {
                    p_objGrp.DrawString(objItemContent[3].m_strItemContent, new Font("", 8), Brushes.Black, m_intRecBaseX + 100, p_intPosY + 13);
                }

                p_intPosY += 25;
                if (objItemContent[6] != null)
                {
                    p_objGrp.DrawString(objItemContent[6].m_strItemContent, p_fntNormalText, Brushes.Black, new RectangleF(m_intRecBaseX + 30, p_intPosY, 700, 40));
                }

                p_intPosY += 40;

                m_blnHaveMoreLine = false;
            }
Ejemplo n.º 46
0
        private void setGrfVs()
        {
            Cursor cursor = Cursor.Current;

            Cursor.Current = Cursors.WaitCursor;

            //pB1.Visible = true;
            String sql = "", datestart = "", dateend = "";

            datestart = bc.datetoDB(txtDateStart.Text);
            dateend   = bc.datetoDB(txtDateEnd.Text);
            System.Drawing.Font font = new System.Drawing.Font("Microsoft Sans Serif", 12);
            DataTable           dt   = new DataTable();

            grfVs.Cols.Count = 15;
            //grfVs.Rows.cl
            grfVs.Rows.Count = 1;

            grfVs.Cols[colHn].Width    = 80;
            grfVs.Cols[colName].Width  = 300;
            grfVs.Cols[colDate].Width  = 110;
            grfVs.Cols[colVn].Width    = 65;
            grfVs.Cols[colPreno].Width = 50;
            grfVs.Cols[colAn].Width    = 80;

            grfVs.Cols[colHn].Caption       = "HN";
            grfVs.Cols[colName].Caption     = "Name";
            grfVs.Cols[colDate].Caption     = "Date";
            grfVs.Cols[colDateDisc].Caption = "Date Disc";
            grfVs.Cols[colVn].Caption       = "Vn";
            grfVs.Cols[colPreno].Caption    = "preno";
            grfVs.Cols[colAn].Caption       = "An";
            grfVs.Cols[colID].Caption       = "ID";
            grfVs.Cols[colWeight].Caption   = "Wright";

            if (txtAn.Text.Trim().Length > 0)
            {
                dt = bc.bcDB.vsDB.selectNHSOPrint3(txtAn.Text.Trim());
            }
            else
            {
                dt = bc.bcDB.vsDB.selectNHSOPrint(datestart, dateend, "");
            }


            //pB1.Maximum = dt.Rows.Count;
            //dgvPE.Columns[colPEId].HeaderText = "id";
            if (dt.Rows.Count > 0)
            {
                if (txtAn.Text.Length > 0)
                {
                    String where = "";
                    int len = txtAn.Text.Trim().Length;
                    //if (txtAn.Text.IndexOf(",") <= 0)
                    //{
                    //    where = " mnc_an_no = '" + txtAn.Text + "' ";
                    //    DataRow[] dr = dt.Select(where);

                    //    int i = 0;
                    //    if (dr.Length == 0)
                    //    {
                    //        MessageBox.Show("ไม่พบ AN " + txtAn.Text + " ที่ต้องการค้นหา", "1.");
                    //        return;
                    //    }
                    //    grfVs.Rows.Count = dr.Length + 1;

                    //    foreach (DataRow row in dr)
                    //    {
                    //        if (dr[i]["mnc_an_no"].ToString().Equals("21364"))
                    //        {
                    //            sql = "";
                    //        }
                    //        grfVs[i+1,0] = (i + 1);
                    //        grfVs[i + 1, colHn] = dr[i]["mnc_hn_no"].ToString();
                    //        grfVs[i + 1, colName] = dr[i]["MNC_PFIX_DSC"].ToString() + " " + dr[i]["MNC_FNAME_T"].ToString() + " " + dr[i]["MNC_LNAME_T"].ToString() + " [" + dr[i]["MNC_id_no"].ToString() + "]";
                    //        grfVs[i + 1, colVn] = dr[i]["mnc_vn_no"].ToString() + "." + dr[i]["MNC_VN_SEQ"].ToString() + "." + dr[i]["MNC_VN_SUM"].ToString();
                    //        grfVs[i + 1, colPreno] = dr[i]["MNC_PRE_NO"].ToString();
                    //        grfVs[i + 1, colPaid] = bc.shortPaidName(dr[i]["MNC_FN_TYP_DSC"].ToString());
                    //        grfVs[i + 1, colDate] = bc.dateDBtoShowShort1(bc.datetoDB(dr[i]["MNC_DATE"].ToString())) + " " + bc.FormatTime(dr[i]["MNC_time"].ToString());
                    //        grfVs[i + 1, colDoctor] = dr[i]["prefix"].ToString() + " " + dr[i]["Fname"].ToString() + " " + dr[i]["Lname"].ToString() + " [" + dr[i]["mnc_dot_cd"].ToString() + "] ";
                    //        grfVs[i + 1, colPdf] = "PDF";
                    //        grfVs[i + 1, colDob] = bc.dateDBtoShowShort1(bc.datetoDB(dr[i]["MNC_BDAY"].ToString()));
                    //        grfVs[i + 1, colDateDisc] = bc.dateDBtoShowShort1(bc.datetoDB(dr[i]["mnc_ds_date"].ToString()));
                    //        grfVs[i + 1, colID] = dr[i]["mnc_id_no"].ToString();
                    //        grfVs[i + 1, colWeight] = dr[i]["mnc_weight"].ToString();
                    //        grfVs[i + 1, colAn] = dr[i]["mnc_an_no"].ToString() + "/" + dr[i]["mnc_an_yr"].ToString();
                    //        int cnt = bc.bcDB.vsDB.selectNHSOPrintHN2("", grfVs[i + 1, colHn].ToString(), grfVs[i + 1, colPreno].ToString(), grfVs[i + 1, colVn].ToString());
                    //        //if ((i % 2) != 0)
                    //        grfVs[i, colChk] = cnt > 0 ? "1" : "0";
                    //        //dgvView.Rows[i].DefaultCellStyle.BackColor = cnt > 0 ? Color.LightSalmon : Color.White;
                    //        i++;
                    //        //pB1.Value = i;

                    //    }
                    //}
                    //else
                    //{
                    String[] an      = txtAn.Text.Split(',');
                    String   wherean = "";
                    for (int j = 0; j < an.Length; j++)
                    {
                        wherean += "'" + an[j].Trim() + "',";
                    }
                    if (wherean.Length > 0)
                    {
                        if (wherean.IndexOf(',', wherean.Length - 1) > 0)
                        {
                            wherean = wherean.Substring(0, wherean.Length - 1);
                        }
                    }
                    where = " mnc_an_no in (" + wherean + ") ";
                    DataRow[] dr = dt.Select(where);
                    //pB1.Maximum = dr.Length;
                    int i = 0;
                    if (dr.Length == 0)
                    {
                        MessageBox.Show("ไม่พบ AN " + txtAn.Text + " ที่ต้องการค้นหา", "2.");
                        return;
                    }
                    grfVs.Rows.Count = dr.Length + 1;
                    foreach (DataRow row in dr)
                    {
                        String hn = "", preno = "", vn = "";
                        hn                        = dr[i]["mnc_hn_no"].ToString();
                        preno                     = dr[i]["MNC_PRE_NO"].ToString();
                        vn                        = dr[i]["mnc_vn_no"].ToString() + "." + dr[i]["MNC_VN_SEQ"].ToString() + "." + dr[i]["MNC_VN_SUM"].ToString();
                        grfVs[i + 1, 0]           = (i + 1);
                        grfVs[i + 1, colHn]       = hn;
                        grfVs[i + 1, colName]     = dr[i]["MNC_PFIX_DSC"].ToString() + " " + dr[i]["MNC_FNAME_T"].ToString() + " " + dr[i]["MNC_LNAME_T"].ToString() + " [" + dr[i]["MNC_id_no"].ToString() + "]";
                        grfVs[i + 1, colVn]       = vn;
                        grfVs[i + 1, colPreno]    = preno;
                        grfVs[i + 1, colPaid]     = bc.shortPaidName(dr[i]["MNC_FN_TYP_DSC"].ToString());
                        grfVs[i + 1, colDate]     = bc.dateDBtoShowShort(bc.datetoDB(dr[i]["MNC_DATE"].ToString())) + " " + bc.FormatTime(dr[i]["MNC_time"].ToString());
                        grfVs[i + 1, colDoctor]   = dr[i]["prefix"].ToString() + " " + dr[i]["Fname"].ToString() + " " + dr[i]["Lname"].ToString() + " [" + dr[i]["mnc_dot_cd"].ToString() + "] ";
                        grfVs[i + 1, colPdf]      = "PDF";
                        grfVs[i + 1, colDob]      = bc.dateDBtoShowShort(bc.datetoDB(dr[i]["MNC_BDAY"].ToString()));
                        grfVs[i + 1, colDateDisc] = bc.dateDBtoShowShort(bc.datetoDB(dr[i]["mnc_ds_date"].ToString()));
                        grfVs[i + 1, colID]       = dr[i]["mnc_id_no"].ToString();
                        grfVs[i + 1, colWeight]   = dr[i]["mnc_weight"].ToString();
                        grfVs[i + 1, colAn]       = dr[i]["mnc_an_no"].ToString() + "/" + dr[i]["mnc_an_yr"].ToString();
                        int cnt = bc.bcDB.vsDB.selectNHSOPrintHN2("", hn, preno, vn);
                        //if ((i % 2) != 0)
                        grfVs[i + 1, colChk] = cnt > 0 ? "1" : "0";
                        //dgvView.Rows[i].DefaultCellStyle.BackColor = cnt > 0 ? Color.LightSalmon : Color.White;
                        i++;
                        //pB1.Value = i;
                    }
                    //}
                }
                else
                {
                    grfVs.Rows.Count = dt.Rows.Count + 1;
                    for (int i = 1; i < dt.Rows.Count; i++)
                    {
                        if (dt.Rows[i]["mnc_an_no"].ToString().Equals("21364"))
                        {
                            sql = "";
                        }
                        grfVs[i, 0]           = (i + 1);
                        grfVs[i, colHn]       = dt.Rows[i]["mnc_hn_no"].ToString();
                        grfVs[i, colName]     = dt.Rows[i]["MNC_PFIX_DSC"].ToString() + " " + dt.Rows[i]["MNC_FNAME_T"].ToString() + " " + dt.Rows[i]["MNC_LNAME_T"].ToString() + " [" + dt.Rows[i]["MNC_id_no"].ToString() + "]";
                        grfVs[i, colVn]       = dt.Rows[i]["mnc_vn_no"].ToString() + "." + dt.Rows[i]["MNC_VN_SEQ"].ToString() + "." + dt.Rows[i]["MNC_VN_SUM"].ToString();
                        grfVs[i, colPreno]    = dt.Rows[i]["MNC_PRE_NO"].ToString();
                        grfVs[i, colPaid]     = bc.shortPaidName(dt.Rows[i]["MNC_FN_TYP_DSC"].ToString());
                        grfVs[i, colDate]     = bc.dateDBtoShowShort(bc.datetoDB(dt.Rows[i]["MNC_DATE"].ToString())) + " " + bc.FormatTime(dt.Rows[i]["MNC_time"].ToString());
                        grfVs[i, colDoctor]   = dt.Rows[i]["prefix"].ToString() + " " + dt.Rows[i]["Fname"].ToString() + " " + dt.Rows[i]["Lname"].ToString() + " [" + dt.Rows[i]["mnc_dot_cd"].ToString() + "] ";
                        grfVs[i, colPdf]      = "PDF";
                        grfVs[i, colDob]      = bc.dateDBtoShowShort(bc.datetoDB(dt.Rows[i]["MNC_BDAY"].ToString()));
                        grfVs[i, colDateDisc] = bc.dateDBtoShowShort(bc.datetoDB(dt.Rows[i]["mnc_ds_date"].ToString()));
                        grfVs[i, colID]       = dt.Rows[i]["mnc_id_no"].ToString();
                        grfVs[i, colWeight]   = dt.Rows[i]["mnc_weight"].ToString();
                        grfVs[i, colAn]       = dt.Rows[i]["mnc_an_no"].ToString() + "/" + dt.Rows[i]["mnc_an_yr"].ToString();
                        int cnt = bc.bcDB.vsDB.selectNHSOPrintHN2("", grfVs[i, colHn].ToString(), grfVs[i, colPreno].ToString(), grfVs[i, colVn].ToString());
                        //if ((i % 2) != 0)
                        grfVs[i, colChk] = cnt > 0 ? "1" : "0";
                        //dgvView.Rows[i].DefaultCellStyle.BackColor = cnt > 0 ? Color.LightSalmon : Color.White;

                        //pB1.Value = i;
                    }
                }
            }

            for (int i = 0; i < grfVs.Rows.Count; i++)
            {
                if (grfVs.Rows.Count <= 1)
                {
                    break;
                }
                if (grfVs[i, colChk] == null)
                {
                    continue;
                }
                if (grfVs[i, colChk].ToString().Equals("0"))
                {
                    grfVs.Rows.Remove(i);
                    i--;
                }
            }
            for (int i = 0; i < grfVs.Rows.Count; i++)
            {
                grfVs[i, 0] = (i + 1);
            }

            grfVs.Font = font;
            grfVs.Cols[colPreno].Visible  = false;
            grfVs.Cols[colChk].Visible    = false;
            grfVs.Cols[colWeight].Visible = false;
            //dgvView.Columns[colAn].Visible = false;
            grfVs.Cols[colID].Visible  = false;
            grfVs.Cols[colDob].Visible = false;

            grfVs.Cols[colHn].AllowEditing       = false;
            grfVs.Cols[colName].AllowEditing     = false;
            grfVs.Cols[colVn].AllowEditing       = false;
            grfVs.Cols[colPreno].AllowEditing    = false;
            grfVs.Cols[colPaid].AllowEditing     = false;
            grfVs.Cols[colDate].AllowEditing     = false;
            grfVs.Cols[colDoctor].AllowEditing   = false;
            grfVs.Cols[colPdf].AllowEditing      = false;
            grfVs.Cols[colDob].AllowEditing      = false;
            grfVs.Cols[colDateDisc].AllowEditing = false;
            grfVs.Cols[colID].AllowEditing       = false;
            grfVs.Cols[colWeight].AllowEditing   = false;
            grfVs.Cols[colAn].AllowEditing       = false;
            //pB1.Visible = false;
            Cursor.Current = cursor;
        }
Ejemplo n.º 47
0
 public Microsoft.DirectX.Direct3D.Font CreateFont(System.Drawing.Font font)
 {
     return(new Microsoft.DirectX.Direct3D.Font(_Device_, font));
 }
Ejemplo n.º 48
0
        /// <summary>
        /// 文字水印
        /// </summary>
        /// <param name="ImgFile">原图文件地址</param>
        /// <param name="TextFont">水印文字</param>
        /// <param name="sImgPath">文字水印图片保存地址</param>
        /// <param name="hScale">高度位置</param>
        /// <param name="widthFont">文字块在图片中所占宽度比例</param>
        /// <param name="Alpha">文字透明度 其数值的范围在0到255</param>

        public void zzsTextWater(
            string ImgFile
            , string TextFont
            , string sImgPath
            , float hScale
            , float widthFont
            , int Alpha
            )
        {
            try
            {
                FileStream   fs    = new FileStream(ImgFile, FileMode.Open);
                BinaryReader br    = new BinaryReader(fs);
                byte[]       bytes = br.ReadBytes((int)fs.Length);
                br.Close();
                fs.Close();
                MemoryStream ms = new MemoryStream(bytes);

                System.Drawing.Image imgPhoto = System.Drawing.Image.FromStream(ms);



                //System.Drawing.Image imgPhoto = System.Drawing.Image.FromFile(ImgFile);

                int imgPhotoWidth  = imgPhoto.Width;
                int imgPhotoHeight = imgPhoto.Height;

                Bitmap bmPhoto = new Bitmap(imgPhotoWidth, imgPhotoHeight, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
                bmPhoto.SetResolution(72, 72);
                Graphics gbmPhoto = Graphics.FromImage(bmPhoto);

                gbmPhoto.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
                gbmPhoto.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

                gbmPhoto.DrawImage(
                    imgPhoto
                    , new Rectangle(0, 0, imgPhotoWidth, imgPhotoHeight)
                    , 0
                    , 0
                    , imgPhotoWidth
                    , imgPhotoHeight
                    , GraphicsUnit.Pixel
                    );

                //建立字体大小的数组,循环找出适合图片的水印字体

                int[] sizes = new int[] { 1000, 800, 700, 650, 600, 560, 540, 500, 450, 400, 380, 360, 340, 320, 300, 280, 260, 240, 220, 200, 180, 160, 140, 120, 100, 80, 72, 64, 48, 32, 28, 26, 24, 20, 28, 16, 14, 12, 10, 8, 6, 4, 2 };
                System.Drawing.Font  crFont = null;
                System.Drawing.SizeF crSize = new SizeF();
                for (int i = 0; i < 43; i++)
                {
                    crFont = new Font("arial", sizes[i], FontStyle.Bold);
                    crSize = gbmPhoto.MeasureString(TextFont, crFont);

                    if ((ushort)crSize.Width < (ushort)imgPhotoWidth * widthFont)
                    {
                        break;
                    }
                }

                //设置水印字体的位置
                int   yPixlesFromBottom = (int)(imgPhotoHeight * hScale);
                float yPosFromBottom    = ((imgPhotoHeight - yPixlesFromBottom) - (crSize.Height / 2));
                float xCenterOfImg      = (imgPhotoWidth * 1 / 2);

                //if (xCenterOfImg<crSize.Height)
                //    xCenterOfImg = (imgPhotoWidth * (1 - (crSize.Height)/ imgPhotoWidth));

                System.Drawing.StringFormat StrFormat = new System.Drawing.StringFormat();
                StrFormat.Alignment = System.Drawing.StringAlignment.Center;

                //
                System.Drawing.SolidBrush semiTransBrush2 = new System.Drawing.SolidBrush(Color.FromArgb(Alpha, 0, 0, 0));

                gbmPhoto.DrawString(
                    TextFont
                    , crFont
                    , semiTransBrush2
                    , new System.Drawing.PointF(xCenterOfImg + 1, yPosFromBottom + 1)
                    , StrFormat
                    );

                System.Drawing.SolidBrush semiTransBrush = new System.Drawing.SolidBrush(Color.FromArgb(Alpha, 255, 255, 255));

                gbmPhoto.DrawString(
                    TextFont
                    , crFont
                    , semiTransBrush
                    , new System.Drawing.PointF(xCenterOfImg, yPosFromBottom)
                    , StrFormat
                    );

                bmPhoto.Save(sImgPath, System.Drawing.Imaging.ImageFormat.Jpeg);

                gbmPhoto.Dispose();
                imgPhoto.Dispose();
                bmPhoto.Dispose();
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 49
0
        /// <summary>
        /// 文字和Logo图片水印
        /// </summary>
        /// <param name="ImgFile">原图文件地址</param>
        /// <param name="WaterImg">水印图片地址</param>
        /// <param name="TextFont">水印文字信息</param>
        /// <param name="sImgPath">生存水印图片后的保存地址</param>
        /// <param name="ImgAlpha">水印图片的透明度</param>
        /// <param name="imgiScale">水印图片在原图上的显示比例</param>
        /// <param name="intimgDistance">水印图片在原图上的边距确定,以图片的右边和下边为准,当设定的边距超过一定大小后参数会自动失效</param>
        /// <param name="texthScale">水印文字高度位置,从图片底部开始计算,0-1</param>
        /// <param name="textwidthFont">文字块在图片中所占宽度比例 0-1</param>
        /// <param name="textAlpha">文字透明度 其数值的范围在0到255</param>
        public void zzsImgTextWater(
            string ImgFile
            , string WaterImg
            , string TextFont
            , string sImgPath
            , float ImgAlpha
            , float imgiScale
            , int intimgDistance
            , float texthScale
            , float textwidthFont
            , int textAlpha
            )
        {
            try
            {
                FileStream   fs    = new FileStream(ImgFile, FileMode.Open);
                BinaryReader br    = new BinaryReader(fs);
                byte[]       bytes = br.ReadBytes((int)fs.Length);
                br.Close();
                fs.Close();
                MemoryStream ms = new MemoryStream(bytes);

                System.Drawing.Image imgPhoto = System.Drawing.Image.FromStream(ms);



                //System.Drawing.Image imgPhoto = System.Drawing.Image.FromFile(ImgFile);


                int imgPhotoWidth  = imgPhoto.Width;
                int imgPhotoHeight = imgPhoto.Height;

                Bitmap bmPhoto = new Bitmap(imgPhotoWidth, imgPhotoHeight, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
                bmPhoto.SetResolution(72, 72);
                Graphics gbmPhoto = Graphics.FromImage(bmPhoto);

                gbmPhoto.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
                gbmPhoto.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

                gbmPhoto.DrawImage(
                    imgPhoto
                    , new Rectangle(0, 0, imgPhotoWidth, imgPhotoHeight)
                    , 0
                    , 0
                    , imgPhotoWidth
                    , imgPhotoHeight
                    , GraphicsUnit.Pixel
                    );


                //建立字体大小的数组,循环找出适合图片的水印字体

                int[] sizes = new int[] { 1000, 800, 700, 650, 600, 560, 540, 500, 450, 400, 380, 360, 340, 320, 300, 280, 260, 240, 220, 200, 180, 160, 140, 120, 100, 80, 72, 64, 48, 32, 28, 26, 24, 20, 28, 16, 14, 12, 10, 8, 6, 4, 2 };
                System.Drawing.Font  crFont = null;
                System.Drawing.SizeF crSize = new SizeF();
                for (int i = 0; i < 43; i++)
                {
                    crFont = new Font("arial", sizes[i], FontStyle.Bold);
                    crSize = gbmPhoto.MeasureString(TextFont, crFont);

                    if ((ushort)crSize.Width < (ushort)imgPhotoWidth * textwidthFont)
                    {
                        break;
                    }
                }

                //设置水印字体的位置
                int   yPixlesFromBottom = (int)(imgPhotoHeight * texthScale);
                float yPosFromBottom    = ((imgPhotoHeight - yPixlesFromBottom) - (crSize.Height / 2));
                float xCenterOfImg      = (imgPhotoWidth * 1 / 2);

                System.Drawing.StringFormat StrFormat = new System.Drawing.StringFormat();
                StrFormat.Alignment = System.Drawing.StringAlignment.Center;

                //
                System.Drawing.SolidBrush semiTransBrush2 = new System.Drawing.SolidBrush(Color.FromArgb(textAlpha, 0, 0, 0));

                gbmPhoto.DrawString(
                    TextFont
                    , crFont
                    , semiTransBrush2
                    , new System.Drawing.PointF(xCenterOfImg + 1, yPosFromBottom + 1)
                    , StrFormat
                    );

                System.Drawing.SolidBrush semiTransBrush = new System.Drawing.SolidBrush(Color.FromArgb(textAlpha, 255, 255, 255));

                gbmPhoto.DrawString(
                    TextFont
                    , crFont
                    , semiTransBrush
                    , new System.Drawing.PointF(xCenterOfImg, yPosFromBottom)
                    , StrFormat
                    );


                System.Drawing.Image imgWatermark = new Bitmap(WaterImg);
                int imgWatermarkWidth             = imgWatermark.Width;
                int imgWatermarkHeight            = imgWatermark.Height;


                //计算水印图片尺寸

                decimal aScale   = Convert.ToDecimal(imgiScale);
                decimal pScale   = 0.05M;
                decimal MinScale = aScale - pScale;
                decimal MaxScale = aScale + pScale;

                int imgWatermarkWidthNew  = imgWatermarkWidth;
                int imgWatermarkHeightNew = imgWatermarkHeight;

                if (imgPhotoWidth >= imgWatermarkWidth && imgPhotoHeight >= imgWatermarkHeight && imgPhotoWidth >= imgPhotoHeight)
                {
                    if (imgWatermarkWidth > imgWatermarkHeight)
                    {
                        if ((MinScale <= Math.Round((Convert.ToDecimal(imgWatermarkWidth) / Convert.ToDecimal(imgPhotoWidth)), 7)) && (Math.Round((Convert.ToDecimal(imgWatermarkWidth) / Convert.ToDecimal(imgPhotoWidth)), 7) <= MaxScale))
                        {
                        }
                        else
                        {
                            imgWatermarkWidthNew  = Convert.ToInt32(imgPhotoWidth * aScale);
                            imgWatermarkHeightNew = Convert.ToInt32((imgPhotoWidth * aScale / imgWatermarkWidth) * imgWatermarkHeight);
                        }
                    }
                    else
                    if ((MinScale <= Math.Round((Convert.ToDecimal(imgWatermarkHeight) / Convert.ToDecimal(imgPhotoHeight)), 7)) && (Math.Round((Convert.ToDecimal(imgWatermarkHeight) / Convert.ToDecimal(imgPhotoHeight)), 7) <= MaxScale))
                    {
                    }
                    else
                    {
                        imgWatermarkHeightNew = Convert.ToInt32(imgPhotoHeight * aScale);
                        imgWatermarkWidthNew  = Convert.ToInt32((imgPhotoHeight * aScale / imgWatermarkHeight) * imgWatermarkWidth);
                    }
                }
                if (imgWatermarkWidth >= imgPhotoWidth && imgWatermarkHeight >= imgPhotoHeight && imgWatermarkWidth >= imgWatermarkHeight)
                {
                    imgWatermarkWidthNew  = Convert.ToInt32(imgPhotoWidth * aScale);
                    imgWatermarkHeightNew = Convert.ToInt32(((imgPhotoWidth * aScale) / imgWatermarkWidth) * imgWatermarkHeight);
                }

                if (imgWatermarkWidth >= imgPhotoWidth && imgWatermarkHeight <= imgPhotoHeight && imgPhotoWidth >= imgPhotoHeight)
                {
                    imgWatermarkWidthNew  = Convert.ToInt32(imgPhotoWidth * aScale);
                    imgWatermarkHeightNew = Convert.ToInt32(((imgPhotoWidth * aScale) / imgWatermarkWidth) * imgWatermarkHeight);
                }

                if (imgWatermarkWidth <= imgPhotoWidth && imgWatermarkHeight >= imgPhotoHeight && imgPhotoWidth >= imgPhotoHeight)
                {
                    imgWatermarkHeightNew = Convert.ToInt32(imgPhotoHeight * aScale);
                    imgWatermarkWidthNew  = Convert.ToInt32(((imgPhotoHeight * aScale) / imgWatermarkHeight) * imgWatermarkWidth);
                }

                if (imgPhotoWidth >= imgWatermarkWidth && imgPhotoHeight >= imgWatermarkHeight && imgPhotoWidth <= imgPhotoHeight)
                {
                    if (imgWatermarkWidth > imgWatermarkHeight)
                    {
                        if ((MinScale <= Math.Round((Convert.ToDecimal(imgWatermarkWidth) / Convert.ToDecimal(imgPhotoWidth)), 7)) && (Math.Round((Convert.ToDecimal(imgWatermarkWidth) / Convert.ToDecimal(imgPhotoWidth)), 7) <= MaxScale))
                        {
                        }
                        else
                        {
                            imgWatermarkWidthNew  = Convert.ToInt32(imgPhotoWidth * aScale);
                            imgWatermarkHeightNew = Convert.ToInt32(((imgPhotoWidth * aScale) / imgWatermarkWidth) * imgWatermarkHeight);
                        }
                    }
                    else
                    if ((MinScale <= Math.Round((Convert.ToDecimal(imgWatermarkHeight) / Convert.ToDecimal(imgPhotoHeight)), 7)) && (Math.Round((Convert.ToDecimal(imgWatermarkHeight) / Convert.ToDecimal(imgPhotoHeight)), 7) <= MaxScale))
                    {
                    }
                    else
                    {
                        imgWatermarkHeightNew = Convert.ToInt32(imgPhotoHeight * aScale);
                        imgWatermarkWidthNew  = Convert.ToInt32(((imgPhotoHeight * aScale) / imgWatermarkHeight) * imgWatermarkWidth);
                    }
                }

                if (imgWatermarkWidth >= imgPhotoWidth && imgWatermarkHeight >= imgPhotoHeight && imgWatermarkWidth <= imgWatermarkHeight)
                {
                    imgWatermarkHeightNew = Convert.ToInt32(imgPhotoHeight * aScale);
                    imgWatermarkWidthNew  = Convert.ToInt32(((imgPhotoHeight * aScale) / imgWatermarkHeight) * imgWatermarkWidth);
                }

                if (imgWatermarkWidth >= imgPhotoWidth && imgWatermarkHeight <= imgPhotoHeight && imgPhotoWidth <= imgPhotoHeight)
                {
                    imgWatermarkWidthNew  = Convert.ToInt32(imgPhotoWidth * aScale);
                    imgWatermarkHeightNew = Convert.ToInt32(((imgPhotoWidth * aScale) / imgWatermarkWidth) * imgWatermarkHeight);
                }

                if (imgWatermarkWidth <= imgPhotoWidth && imgWatermarkHeight >= imgPhotoHeight && imgPhotoWidth <= imgPhotoHeight)
                {
                    imgWatermarkHeightNew = Convert.ToInt32(imgPhotoHeight * aScale);
                    imgWatermarkWidthNew  = Convert.ToInt32(((imgPhotoHeight * aScale) / imgWatermarkHeight) * imgWatermarkWidth);
                }


                //将原图画出来


                Bitmap bmWatermark = new Bitmap(bmPhoto);
                bmWatermark.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution);

                Graphics gWatermark = Graphics.FromImage(bmWatermark);

                //指定高质量显示水印图片质量
                gWatermark.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
                gWatermark.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.HighQuality;


                System.Drawing.Imaging.ImageAttributes imageAttributes = new System.Drawing.Imaging.ImageAttributes();

                //设置两种颜色,达到合成效果

                System.Drawing.Imaging.ColorMap colorMap = new System.Drawing.Imaging.ColorMap();
                colorMap.OldColor = Color.FromArgb(255, 0, 255, 0);
                colorMap.NewColor = Color.FromArgb(0, 0, 0, 0);

                System.Drawing.Imaging.ColorMap[] remapTable = { colorMap };

                imageAttributes.SetRemapTable(remapTable, System.Drawing.Imaging.ColorAdjustType.Bitmap);

                //用矩阵设置水印图片透明度
                float[][] colorMatrixElements =
                {
                    new float[] { 1.0f, 0.0f, 0.0f,     0.0f, 0.0f },
                    new float[] { 0.0f, 1.0f, 0.0f,     0.0f, 0.0f },
                    new float[] { 0.0f, 0.0f, 1.0f,     0.0f, 0.0f },
                    new float[] { 0.0f, 0.0f, 0.0f, ImgAlpha, 0.0f },
                    new float[] { 0.0f, 0.0f, 0.0f,     0.0f, 1.0f }
                };


                System.Drawing.Imaging.ColorMatrix wmColorMatrix = new System.Drawing.Imaging.ColorMatrix(colorMatrixElements);

                imageAttributes.SetColorMatrix(wmColorMatrix, System.Drawing.Imaging.ColorMatrixFlag.Default, System.Drawing.Imaging.ColorAdjustType.Bitmap);

                //确定水印边距
                int xPos     = imgPhotoWidth - imgWatermarkWidthNew;
                int yPos     = imgPhotoHeight - imgWatermarkHeightNew;
                int xPosOfWm = 0;
                int yPosOfWm = 0;

                if (xPos > intimgDistance)
                {
                    xPosOfWm = xPos - intimgDistance;
                }
                else
                {
                    xPosOfWm = xPos;
                }

                if (yPos > intimgDistance)
                {
                    yPosOfWm = yPos - intimgDistance;
                }
                else
                {
                    yPosOfWm = yPos;
                }

                gWatermark.DrawImage(
                    imgWatermark
                    , new Rectangle(xPosOfWm, yPosOfWm, imgWatermarkWidthNew, imgWatermarkHeightNew)
                    , 0
                    , 0
                    , imgWatermarkWidth
                    , imgWatermarkHeight
                    , GraphicsUnit.Pixel
                    , imageAttributes
                    );

                imgPhoto = bmWatermark;

                //以jpg格式保存图片
                imgPhoto.Save(sImgPath, System.Drawing.Imaging.ImageFormat.Jpeg);

                //销毁对象
                gbmPhoto.Dispose();
                gWatermark.Dispose();
                bmPhoto.Dispose();
                imgPhoto.Dispose();
                imgWatermark.Dispose();
            }
            catch (Exception ex)
            {
            }
        }
        /// <summary>
        /// 生成校验码图片
        /// </summary>
        /// <returns>FileContentResult</returns>
        public FileContentResult CreateImageCode()
        {
            string code = CreateVerifyCode(4);

            Session["PictureCode"] = code.ToUpper();
            int fSize       = FontSize;
            int fWidth      = fSize + Padding;
            int imageWidth  = (int)(code.Length * fWidth) + 4 + Padding * 2;
            int imageHeight = fSize * 2 + Padding;

            System.Drawing.Bitmap image = new System.Drawing.Bitmap(imageWidth, imageHeight);
            Graphics g = Graphics.FromImage(image);

            g.Clear(BackgroundColor);
            Random rand = new Random();

            //给背景添加随机生成的燥点
            if (this.Chaos)
            {
                Pen pen = new Pen(ChaosColor, 0);
                int c   = Length * 10;
                for (int i = 0; i < c; i++)
                {
                    int x = rand.Next(image.Width);
                    int y = rand.Next(image.Height);
                    g.DrawRectangle(pen, x, y, 1, 1);
                }
            }
            int left = 0, top = 0, top1 = 1, top2 = 1;
            int n1 = (imageHeight - FontSize - Padding * 2);
            int n2 = n1 / 4;

            top1 = n2;
            top2 = n2 * 2;
            Font  f;
            Brush b;
            int   cindex, findex;

            //随机字体和颜色的验证码字符
            for (int i = 0; i < code.Length; i++)
            {
                cindex = rand.Next(Colors.Length - 1);
                findex = rand.Next(Fonts.Length - 1);
                f      = new System.Drawing.Font(Fonts[findex], fSize, System.Drawing.FontStyle.Bold);
                b      = new System.Drawing.SolidBrush(Colors[cindex]);
                if (i % 2 == 1)
                {
                    top = top2;
                }
                else
                {
                    top = top1;
                }
                left = i * fWidth;
                g.DrawString(code.Substring(i, 1), f, b, left, top);
            }
            //画一个边框 边框颜色为Color.Gainsboro
            g.DrawRectangle(new Pen(Color.Gainsboro, 0), 0, 0, image.Width - 1, image.Height - 1);
            g.Dispose();
            //产生波形
            image = TwistImage(image, true, 0, 4);
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            //将图像保存到指定的流
            image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
            return(File(ms.GetBuffer(), "image/JPEG"));
        }
Ejemplo n.º 51
0
        /// <summary>
        /// 更新访问统计图
        /// </summary>
        public void UpdateRefStatPicture()
        {
            int yaxis_max = 0;                                                                                   //纵坐标最大值

            int[] yaxis;                                                                                         //纵坐标最大值的允许值
            yaxis = new int[] { 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 500000, 1000000 }; //设置纵坐标可能的最大值

            //读取数据
            IList <int> data = _logRepository.GetVisitStat(30);
            int         len  = data.Count;

            //得到纵坐标最大值
            for (int i = 0; i < yaxis.Length; i++)
            {
                if (data.Max() <= yaxis[i])
                {
                    yaxis_max = yaxis[i];
                    break;
                }
            }

            //设置背景图片
            System.Drawing.Image image = System.Drawing.Image.FromFile(HttpContext.Current.Server.MapPath(RefstatPicturePrePath));
            //载入背景图片
            Graphics g = Graphics.FromImage(image);

            //设置抗锯齿方式
            g.SmoothingMode = SmoothingMode.HighQuality;
            //定义文字
            Font font = new Font(RefstatPictureFontFamily, 10);
            //定义笔刷
            SolidBrush sb     = new SolidBrush(Color.Black);
            SolidBrush sbRed  = new SolidBrush(Color.Red);
            SolidBrush sbGray = new SolidBrush(Color.Gray);
            //定义一个新Pen
            Pen pen = new Pen(new SolidBrush(Color.Blue));
            //定义一个文字显示格式
            StringFormat sf = new StringFormat();

            sf.Alignment = StringAlignment.Center;
            //生成标题
            g.DrawString(RefstatPictureTitle, font, sb, new PointF(50, 0), sf);

            //生成纵坐标:循环6次生成日访问量坐标,每循环一次:日访问量-20%,纵坐标-40
            for (int i = 0; i < 6; i++)
            {
                g.DrawString((yaxis_max / 5 * i).ToString(), font, sb, new PointF(8, 222 - i * 40), sf);
            }
            //生成横坐标:循环14次(最后一个日期单独生成)生成日期,每循环一次:日期-2,横坐标-40
            for (int i = 1; i < 15; i++)
            {
                g.DrawString(DateTime.Now.AddDays(-i * 2).ToString(RefstatPictureDateFormatMd), font, sb, new PointF(610 - i * 40, 232), sf);
            }
            //当前日期使用红色显示
            g.DrawString(DateTime.Now.ToString(RefstatPictureDateFormatMd), font, sbRed, new PointF(610, 232), sf);
            //生成柱状
            for (int i = 0; i < (data.Count > 30 ? 30 : data.Count); i++)
            {
                //循环30次生成柱状图顶部,每循环一次:横坐标-20,纵坐标根据日访问量变化
                g.DrawLine(pen, new PointF(621 - i * 20, 230 - data[i] * 200 / yaxis_max), new PointF(601 - i * 20, 230 - data[i] * 200 / yaxis_max));
                //循环30次生成柱状图右侧部分,每循环一次:横坐标-20,纵坐标根据日访问量变化
                g.DrawLine(pen, new PointF(621 - i * 20, 230), new PointF(621 - i * 20, 230 - data[i] * 200 / yaxis_max));
                //循环30次生成柱状图左侧部分,每循环一次:横坐标-20,纵坐标根据日访问量变化
                g.DrawLine(pen, new PointF(601 - i * 20, 230), new PointF(601 - i * 20, 230 - data[i] * 200 / yaxis_max));
                //循环30次填充柱状图内部颜色,每循环一次:横坐标-20,纵坐标根据日访问量变化
                g.FillRectangle(new SolidBrush(Color.LightBlue), 601 - i * 20, 230 - data[i] * 200 / yaxis_max, 20, data[i] * 200 / yaxis_max);
                //循环30次生成柱状图顶部数字提示,每循环一次:横坐标-20,纵坐标根据日访问量变化
                g.DrawString(data[i].ToString(), font, sbGray, new PointF(611 - i * 20, 230 - (data[i] * 200 / yaxis_max) - 13), sf);
            }

            //保存图片
            //若不使用try,可能发生2个用户同时保存图片,导致以下错误:
            //A generic error occurred in GDI+.
            try
            {
                image.Save(HttpContext.Current.Server.MapPath(RefstatPicturePath), ImageFormat.Jpeg);
            }
            catch (Exception e)
            {
            }
            //释放资源
            g.Dispose();
            image.Dispose();
        }
Ejemplo n.º 52
0
        private void m_clbUtilities_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            System.Drawing.Font currentFont = m_rtbDescription.SelectionFont;
#if __MonoCS__
            // Creating the bold equivalent of the current font doesn't seem to work in Mono,
            // as we crash shortly due to failures in GDIPlus.GdipMeasureString() using that
            // font.
            var boldFont = currentFont;
#else
            System.Drawing.FontStyle boldFontStyle = FontStyle.Bold;
            using (System.Drawing.Font boldFont = new Font(currentFont.FontFamily, currentFont.Size, boldFontStyle))
#endif
            {
                ((IUtility)m_clbUtilities.SelectedItem).OnSelection();
                m_rtbDescription.Clear();
                // What
                m_rtbDescription.SelectionFont = boldFont;
                m_rtbDescription.AppendText(FwCoreDlgs.ksWhatItDoes);
                m_rtbDescription.AppendText(Environment.NewLine);
                m_rtbDescription.SelectionFont = currentFont;
                if (string.IsNullOrEmpty(m_whatDescription))
                {
                    m_rtbDescription.AppendText(FwCoreDlgs.ksQuestions);
                }
                else
                {
                    m_rtbDescription.AppendText(m_whatDescription);
                }
                m_rtbDescription.AppendText(string.Format("{0}{0}", Environment.NewLine));

                // When
                m_rtbDescription.SelectionFont = boldFont;
                m_rtbDescription.AppendText(FwCoreDlgs.ksWhenToUse);
                m_rtbDescription.AppendText(Environment.NewLine);
                m_rtbDescription.SelectionFont = currentFont;
                if (string.IsNullOrEmpty(m_whenDescription))
                {
                    m_rtbDescription.AppendText(FwCoreDlgs.ksQuestions);
                }
                else
                {
                    m_rtbDescription.AppendText(m_whenDescription);
                }
                m_rtbDescription.AppendText(string.Format("{0}{0}", Environment.NewLine));

                // Cautions
                m_rtbDescription.SelectionFont = boldFont;
                m_rtbDescription.AppendText(FwCoreDlgs.ksCautions);
                m_rtbDescription.AppendText(Environment.NewLine);
                m_rtbDescription.SelectionFont = currentFont;
                if (string.IsNullOrEmpty(m_redoDescription))
                {
                    m_rtbDescription.AppendText(FwCoreDlgs.ksQuestions);
                }
                else
                {
                    m_rtbDescription.AppendText(m_redoDescription);
                }
#if __MonoCS__
                // If we don't have a selection explicitly set, we will crash deep in the Mono
                // code (RichTextBox.cs:618, property SelectionFont:get) shortly.
                m_rtbDescription.Focus();
                m_rtbDescription.SelectionStart  = 0;
                m_rtbDescription.SelectionLength = 0;
                m_clbUtilities.Focus();
#endif
            }
        }
Ejemplo n.º 53
0
        private void initStyleFromXml()
        {
            FontConverter  fontConverter = new FontConverter();
            ColorConverter colorCovert   = new ColorConverter();

            string headerFontColorStr = Common.GetPropertiesFromXmlByName(Const.XML_HEADER_FONT_COLOR);
            string headerFontStr      = Common.GetPropertiesFromXmlByName(Const.XML_HEADER_FONT);
            string headerColorStr     = Common.GetPropertiesFromXmlByName(Const.XML_HEADER_COLOR);

            if (headerFontStr != "")
            {
                headerFont      = fontConverter.ConvertFromString(headerFontStr) as System.Drawing.Font;
                headerFontColor = (Color)colorCovert.ConvertFromString(headerFontColorStr);
            }
            else
            {
                headerFont      = SystemFonts.DefaultFont;
                headerFontColor = Color.Black;
            }

            if (headerColorStr != "")
            {
                headerColor = (Color)colorCovert.ConvertFromString(headerColorStr);
            }
            else
            {
                headerColor = Color.LightBlue;
            }


            string cellFontColorStr = Common.GetPropertiesFromXmlByName(Const.XML_CEll_FONT_COLOR);
            string cellFontStr      = Common.GetPropertiesFromXmlByName(Const.XML_CEll_FONT);
            string cellColorStr     = Common.GetPropertiesFromXmlByName(Const.XML_CEll_COLOR);

            if (cellFontStr != "")
            {
                cellFont      = fontConverter.ConvertFromString(cellFontStr) as System.Drawing.Font;
                cellFontColor = (Color)colorCovert.ConvertFromString(cellFontColorStr);
            }
            else
            {
                cellFont      = SystemFonts.DefaultFont;
                cellFontColor = Color.Black;
            }

            if (cellColorStr != "")
            {
                cellColor = (Color)colorCovert.ConvertFromString(cellColorStr);
            }
            else
            {
                cellColor = Color.LightBlue;
            }

            isDataBoxVisible    = bool.Parse(Common.GetPropertiesFromXmlByName(Const.XML_CB_DATA_BOX));
            isHeaderBoxVisible  = bool.Parse(Common.GetPropertiesFromXmlByName(Const.XML_CB_HEADER_BOX));
            isNullableVisible   = bool.Parse(Common.GetPropertiesFromXmlByName(Const.XML_CB_NULLABLE));
            isPrimaryKeyVisible = bool.Parse(Common.GetPropertiesFromXmlByName(Const.XML_CB_PRIMARY_KEY));
            isDataTypeVisible   = bool.Parse(Common.GetPropertiesFromXmlByName(Const.XML_CB_DATA_TYPE));
            isFeldNameVisible   = bool.Parse(Common.GetPropertiesFromXmlByName(Const.XML_CB_FIELD_NAME));
            noDataStr           = Common.GetPropertiesFromXmlByName(Const.XML_NO_DATA);
        }
Ejemplo n.º 54
0
        // ---------------------------------------------------------------

        public TDLHtmlEditorControl(System.Drawing.Font font, Translator trans) : base(font, trans)
        {
            m_TextChangeTimer = new Timer();

            InitializeComponent();
        }
            public override void m_mthPrintNextLine(ref int p_intPosY, System.Drawing.Graphics p_objGrp, System.Drawing.Font p_fntNormalText)
            {
                if (m_objContent == null || m_objContent.m_objItemContents == null)
                {
                    m_blnHaveMoreLine = false;
                    return;
                }
                if (m_blnHavePrintInfo(m_strKeysArr1) == false && m_blnHavePrintInfo(m_strKeysArr2) == false)
                {
                    m_blnHaveMoreLine = false;
                    return;
                }
                //				if(blnNextPage)
                //				{
                //					//另起一页打印,利用打印时检测p_intPosY是否大于最底边的值的判断来实现
                //					m_blnHaveMoreLine = true;
                //					blnNextPage = false;
                //					p_intPosY += 1500;
                //					return;
                //				}
                if (m_blnIsFirstPrint)
                {
                    //					p_objGrp.DrawString("神经系统检查",m_fotItemHead,Brushes.Black,m_intRecBaseX+310,p_intPosY);
                    //					p_intPosY += 20;
                    //					p_objGrp.DrawString("一般情况",m_fontItemMidHead,Brushes.Black,m_intRecBaseX,p_intPosY);
                    //					p_intPosY += 20;
                    string strAllText   = "";
                    string strXml       = "";
                    string strFirstName = new clsEmployee(m_objContent.m_strCreateUserID).m_StrFirstName;
                    if (m_objContent != null)
                    {
                        if (m_blnHavePrintInfo(m_strKeysArr1) != false)
                        {
                            m_mthMakeText(new string[] { "检查医师:" }, m_strKeysArr1, ref strAllText, ref strXml);
                        }
                        if (m_blnHavePrintInfo(m_strKeysArr2) != false)
                        {
                            m_mthMakeText(new string[] { "\n记录日期" }, m_strKeysArr2, ref strAllText, ref strXml);
                        }
                    }
                    else
                    {
                        m_blnHaveMoreLine = false;
                        return;
                    }
                    m_objPrintContext.m_mthSetContextWithCorrectBefore(strAllText, strXml, m_dtmFirstPrintTime, m_objContent.m_objItemContents != null);
                    m_mthAddSign2("医生签字:", m_objPrintContext.m_ObjModifyUserArr);
                    m_blnIsFirstPrint = false;
                }

                int intLine = 0;

                if (m_objPrintContext.m_BlnHaveNextLine())
                {
                    m_objPrintContext.m_mthPrintLine((int)enmRectangleInfoInPatientCaseInfo.PrintWidth2, m_intRecBaseX + 10, p_intPosY, p_objGrp);
                    p_intPosY += 20;
                }
                if (m_objPrintContext.m_BlnHaveNextLine())
                {
                    m_blnHaveMoreLine = true;
                }
                else
                {
                    m_blnHaveMoreLine = false;
                }
            }
Ejemplo n.º 56
0
        private void DrawUpcaBarcode(Graphics g, Point pt)
        {
            float width  = this.Width * this.Scale;
            float height = this.Height * this.Scale;

            // A UPCE Barcode should be a total of 71 modules wide.
            float lineWidth = width / 87f;

            // Save the GraphicsState.
            System.Drawing.Drawing2D.GraphicsState gs = g.Save();

            // Set the PageUnit to Inch because all of our measurements are in inches.
            g.PageUnit = System.Drawing.GraphicsUnit.Inch;

            // Set the PageScale to 1, so an inch will represent a true inch.
            g.PageScale = 1;

            System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);

            float xPosition = 0;

            System.Text.StringBuilder strbUPC = new System.Text.StringBuilder();

            float xStart = pt.X;
            float yStart = pt.Y;
            float xEnd   = 0;

            System.Drawing.Font font = new System.Drawing.Font("Arial", this.FontSize * this.Scale);

            string strEAN = string.Concat(QuiteZone, LeadTail, DigitToPatterns(data.Substring(0, data.Length / 2), _aOddParity),
                                          Separator, DigitToPatterns(data.Substring(data.Length / 2), _aEvenParity), LeadTail, QuiteZone);

            string sTempUPC = strEAN;

            float fTextHeight = g.MeasureString(sTempUPC, font).Height;

            // Draw the barcode lines.
            for (int i = 0; i < strEAN.Length; i++)
            {
                if (sTempUPC.Substring(i, 1) == "1")
                {
                    if (xStart == pt.X)
                    {
                        xStart = xPosition;
                    }

                    // Save room for the UPC number below the bar code.
                    if ((i > 12 && i < 41) | (i > 45 && i < 74))
                    {
                        // Draw space for the number
                        g.FillRectangle(brush, xPosition, yStart, lineWidth, height - fTextHeight);
                    }
                    else
                    {
                        // Draw a full line.
                        g.FillRectangle(brush, xPosition, yStart, lineWidth, height);
                    }
                }

                xPosition += lineWidth;
                xEnd       = xPosition;
            }

            g.SmoothingMode      = SmoothingMode.HighQuality;
            g.InterpolationMode  = InterpolationMode.HighQualityBicubic;
            g.PixelOffsetMode    = PixelOffsetMode.HighQuality;
            g.CompositingQuality = CompositingQuality.HighQuality;
            g.TextRenderingHint  = TextRenderingHint.AntiAliasGridFit;

            xPosition = xStart - g.MeasureString(string.Empty, font).Width;
            float yPosition = yStart + (height - fTextHeight);

            // Draw Product Type.
            g.DrawString(string.Empty, font, brush, new System.Drawing.PointF(xPosition, yPosition));

            // Each digit is 7 modules wide, therefore the MFG_Number is 4 digits wide so
            //    4 * 7 = 28, then add 3 for the LeadTrailer Info and another 7 for good measure,
            //    that is where the 38 comes from.
            xPosition += g.MeasureString(string.Empty, font).Width + 31 * lineWidth -
                         g.MeasureString(data.Substring(0, data.Length / 2), font).Width;

            // Draw MFG Number.
            g.DrawString(data.Substring(0, data.Length / 2), font, brush, new System.Drawing.PointF(xPosition, yPosition));

            // Add the width of the MFG Number and 5 modules for the separator.
            xPosition += g.MeasureString(data.Substring(0, data.Length / 2), font).Width +
                         5 * lineWidth;

            // Draw Product ID.
            g.DrawString(data.Substring(data.Length / 2), font, brush, new System.Drawing.PointF(xPosition, yPosition));

            // Each digit is 7 modules wide, therefore the Product Id is 5 digits wide so
            //    5 * 7 = 35, then add 3 for the LeadTrailer Info, + 8 more just for spacing
            //  that is where the 46 comes from.
            //    xPosition += 46 * lineWidth;

            // Draw Check Digit.
            //   g.DrawString(this.ChecksumDigit, font, brush, new System.Drawing.PointF(xPosition, yPosition));

            // Restore the GraphicsState.
            g.Restore(gs);
        }
            public override void m_mthPrintNextLine(ref int p_intPosY, System.Drawing.Graphics p_objGrp, System.Drawing.Font p_fntNormalText)
            {
                if (m_objContent == null || m_objContent.m_objItemContents == null)
                {
                    m_blnHaveMoreLine = false;
                    return;
                }
                if (m_blnIsFirstPrint)
                {
                    string strAllText   = "";
                    string strXml       = "";
                    string strFirstName = new clsEmployee(m_objContent.m_strCreateUserID).m_StrFirstName;
                    if (m_objContent != null)
                    {
                        if (m_blnHavePrintInfo(m_strKeysArr01) != false)
                        {
                            m_mthMakeText(m_strKeysArr101, m_strKeysArr01, ref strAllText, ref strXml);
                        }
                    }
                    else
                    {
                        m_blnHaveMoreLine = false;
                        return;
                    }
                    m_objPrintContext.m_mthSetContextWithCorrectBefore(strAllText, strXml, m_dtmFirstPrintTime, m_objContent.m_objItemContents != null);
                    //m_mthAddSign2("检查情形:",m_objPrintContext.m_ObjModifyUserArr);
                    m_blnIsFirstPrint = false;
                }

                if (m_objPrintContext.m_BlnHaveNextLine())
                {
                    m_objPrintContext.m_mthPrintLine((int)enmRectangleInfoInPatientCaseInfo.PrintWidth2, m_intRecBaseX + 10, p_intPosY, p_objGrp);
                    p_intPosY += 20;
                }
                if (m_objPrintContext.m_BlnHaveNextLine())
                {
                    m_blnHaveMoreLine = true;
                }
                else
                {
                    m_blnHaveMoreLine = false;
                }
            }
Ejemplo n.º 58
0
        protected override void OnPrintPage(PrintPageEventArgs e)
        {
            var data = (from p in _latticeInfoList
                        group p by p.CountryName into g
                        select
                        new
            {
                Countrys = g.Key,
                Weight = g.Sum(p => p.Weight),
                Items = g.Count()
            }).ToList();

            if (data.Count() <= 2)
            {
                return;
            }
            //条码高度和宽度
            try
            {
                Pen myPen = new Pen(Color.FromArgb(255, Color.Black), 1.0F);
                //画表格竖线
                int height = 25;
                int width1 = 150;
                int width2 = 60;
                int width3 = 60;
                //画横线
                for (int i = 0; i <= data.Count() + 2; i++)
                {
                    e.Graphics.DrawLine(myPen, new Point(10, (i * height + 20)), new Point(width1 + width2 + width3 + 30, (i * height + 20)));
                }
                //画竖线
                e.Graphics.DrawLine(myPen, new Point(10, 20), new Point(10, (data.Count() + 2) * height + 20));
                e.Graphics.DrawLine(myPen, new Point(width1 + 10, 20), new Point(width1 + 10, (data.Count() + 2) * height + 20));
                e.Graphics.DrawLine(myPen, new Point(width1 + width2 + 10, 20), new Point(width1 + width2 + 10, (data.Count() + 2) * height + 20));
                e.Graphics.DrawLine(myPen, new Point(width1 + width2 + width3 + 30, 20), new Point(width1 + width2 + width3 + 30, (data.Count() + 2) * height + 20));


                Font Regularfont  = new System.Drawing.Font("Times New Roman, Times, serif", 8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(50)));
                Font Regularfont1 = new System.Drawing.Font("Times New Roman, Times, serif", 7F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));

                e.Graphics.DrawString("COUNTRY", Regularfont, Brushes.Black, 11, 20);
                e.Graphics.DrawString("WEIGHT\n    KG", Regularfont, Brushes.Black, width1 + 10, 20);
                e.Graphics.DrawString("REGISTERED\n    ITEMS", Regularfont, Brushes.Black, width1 + width2 + 10, 20);
                for (int i = 0; i < data.Count(); i++)
                {
                    var country = data[i].Countrys;
                    //if (country.Length > 8)
                    //{
                    //    country = country.Insert(8, "\n");
                    //}
                    e.Graphics.DrawString(country, Regularfont1, Brushes.Black, 20, height * (i + 1) + 30);
                    e.Graphics.DrawString(data[i].Weight.ToString(), Regularfont1, Brushes.Black, width1 + 20, height * (i + 1) + 30);
                    if (country == "袋子(箱子)")
                    {
                        e.Graphics.DrawString("", Regularfont1, Brushes.Black, width1 + width2 + 20, height * (i + 1) + 30);
                    }
                    else
                    {
                        e.Graphics.DrawString(data[i].Items.ToString(), Regularfont1, Brushes.Black, width1 + width2 + 20, height * (i + 1) + 30);
                    }
                }
                e.Graphics.DrawString("TOTAL", Regularfont1, Brushes.Black, 20, height * (data.Count() + 1) + 30);
                e.Graphics.DrawString(data.Sum(o => o.Weight).ToString(), Regularfont1, Brushes.Black, width1 + 20, height * (data.Count() + 1) + 30);
                e.Graphics.DrawString((data.Sum(o => o.Items) - 1).ToString(), Regularfont1, Brushes.Black, width1 + width2 + 20, height * (data.Count() + 1) + 30);
                this.Dispose();
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Ejemplo n.º 59
0
        /// <summary>
        /// Create resources for rendering glyphs.
        /// </summary>
        /// <param name="ctx"></param>
        private void LinkSharedResources(GraphicsContext ctx)
        {
            CheckCurrentContext(ctx);

            StringFormat stringFormat = StringFormat.GenericTypographic;

            // Font-wide resources
            string resourceClassId = "OpenGL.Objects.FontTextureArray2d";
            string resourceBaseId  = String.Format("{0}.{1}-{2}-{3}", resourceClassId, Family, Size, Style);

            #region Instanced Arrays

            if (ctx.Extensions.InstancedArrays)
            {
                string instanceArrayId = resourceClassId + ".InstanceArray";

                _GlyphInstances = (ArrayBufferInterleaved <GlyphInstance>)ctx.GetSharedResource(instanceArrayId);

                if (_GlyphInstances == null)
                {
                    _GlyphInstances = new ArrayBufferInterleaved <GlyphInstance>(MapBufferUsageMask.MapWriteBit);
                    _GlyphInstances.Create(256);
                    // Share
                    ctx.SetSharedResource(instanceArrayId, _GlyphInstances);
                }
                LinkResource(_GlyphInstances);
            }
            else
            {
                _GlyphInstances = null;
            }

            #endregion

            #region Vertex Array

            string vertexArrayId = resourceClassId + ".VertexArray";

            _VertexArrays = (VertexArrays)ctx.GetSharedResource(vertexArrayId);

            if (_VertexArrays == null)
            {
                _VertexArrays = new VertexArrays();

                ArrayBuffer <Vertex2f> arrayPosition = new ArrayBuffer <Vertex2f>();
                arrayPosition.Create(new Vertex2f[] {
                    new Vertex2f(0.0f, 1.0f),
                    new Vertex2f(0.0f, 0.0f),
                    new Vertex2f(1.0f, 1.0f),
                    new Vertex2f(1.0f, 0.0f),
                });
                _VertexArrays.SetArray(arrayPosition, VertexArraySemantic.Position);
                if (ctx.Extensions.InstancedArrays)
                {
                    _VertexArrays.SetInstancedArray(_GlyphInstances, 0, 1, "glo_GlyphModelViewProjection");
                    _VertexArrays.SetInstancedArray(_GlyphInstances, 1, 1, "glo_GlyphVertexParams");
                    _VertexArrays.SetInstancedArray(_GlyphInstances, 2, 1, "glo_GlyphTexParams");
                }
                _VertexArrays.SetElementArray(PrimitiveType.TriangleStrip);
                // Share
                ctx.SetSharedResource(vertexArrayId, _VertexArrays);
            }
            LinkResource(_VertexArrays);

            #endregion

            #region Glyphs Metadata

            string glyphDbId = resourceBaseId + ".GlyphDb";

            _GlyphMetadata = (Dictionary <char, Glyph>)ctx.GetSharedResource(glyphDbId);

            if (_GlyphMetadata == null)
            {
                _GlyphMetadata = new Dictionary <char, Glyph>();

                char[] fontChars = GetFontCharacters().ToCharArray();
                uint   layer     = 0;

                using (Bitmap bitmap = new Bitmap(1, 1))
                    using (Graphics g = Graphics.FromImage(bitmap))
                        using (System.Drawing.Font font = new System.Drawing.Font(Family, Size, Style))
                        {
                            // Avoid grid fitting
                            g.TextRenderingHint = TextRenderingHint.AntiAlias;

                            float glyphHeight = font.GetHeight();

                            foreach (char c in fontChars)
                            {
                                SizeF glyphSize;

                                switch (c)
                                {
                                case ' ':
                                    glyphSize = g.MeasureString(c.ToString(), font, 0, StringFormat.GenericDefault);
                                    break;

                                default:
                                    glyphSize = g.MeasureString(c.ToString(), font, 0, stringFormat);
                                    break;
                                }

                                Glyph glyph = new Glyph(c, glyphSize, layer++, new SizeF(1.0f, 1.0f));

                                _GlyphMetadata.Add(c, glyph);
                            }
                        }

                // Share
                ctx.SetSharedResource(glyphDbId, _GlyphMetadata);
            }

            #endregion

            #region Glyph Sampler

            string samplerId = resourceBaseId + ".Sampler";

            Sampler sampler = (Sampler)ctx.GetSharedResource(samplerId);

            if (sampler == null)
            {
                sampler = new Sampler();
                sampler.Parameters.MinFilter = TextureMinFilter.Linear;
            }

            #endregion

            #region Glyph Texture

            string textureId = resourceBaseId + ".Texture";

            _FontTexture = (TextureArray2d)ctx.GetSharedResource(textureId);

            if (_FontTexture == null)
            {
                // Get the size required for all glyphs
                float w = 0.0f, h = 0.0f;
                uint  z = 0;

                foreach (Glyph glyph in _GlyphMetadata.Values)
                {
                    w = Math.Max(w, glyph.GlyphSize.Width);
                    h = Math.Max(h, glyph.GlyphSize.Height);
                    z = Math.Max(z, glyph.Layer);
                }

                // Create texture
                _FontTexture         = new TextureArray2d();
                _FontTexture.Sampler = sampler;
                _FontTexture.Create(ctx, (uint)Math.Ceiling(w), (uint)Math.Ceiling(h), z + 1, PixelLayout.R8, 1);

                using (System.Drawing.Font font = new System.Drawing.Font(Family, Size, Style))
                    using (Brush brush = new SolidBrush(Color.White))
                    {
                        foreach (Glyph glyph in _GlyphMetadata.Values)
                        {
                            using (Bitmap bitmap = new Bitmap((int)_FontTexture.Width, (int)_FontTexture.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb))
                                using (Graphics g = Graphics.FromImage(bitmap)) {
                                    // Recompute texture scaling
                                    glyph.TexScale = new SizeF(
                                        glyph.GlyphSize.Width / bitmap.Width,
                                        glyph.GlyphSize.Height / bitmap.Height
                                        );

                                    // Avoid grid fitting
                                    g.TextRenderingHint = TextRenderingHint.AntiAlias;
                                    g.Clear(Color.Black);

                                    g.DrawString(glyph.GlyphChar.ToString(), font, brush, 0.0f, 0.0f, stringFormat);

                                    _FontTexture.Create(ctx, PixelLayout.R8, bitmap, glyph.Layer);
                                }
                        }
                    }

                // Share
                ctx.SetSharedResource(textureId, _FontTexture);
            }
            LinkResource(_FontTexture);

            #endregion
        }
Ejemplo n.º 60
0
 public virtual System.Drawing.Font ScaleFont(System.Drawing.Font font)
 {
     return(new System.Drawing.Font(font.Name, font.Size * 96f / CMain.Graphics.DpiX, font.Style));
 }