当前位置: 首页>>代码示例>>C#>>正文


C# Font.Equals方法代码示例

本文整理汇总了C#中System.Drawing.Font.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Font.Equals方法的具体用法?C# Font.Equals怎么用?C# Font.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.Font的用法示例。


在下文中一共展示了Font.Equals方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateFont

        public static void UpdateFont(Control ctl, Font oldFont, Font newFont)
        {
            if (!oldFont.Equals(newFont))
            {
                foreach (Control c in ctl.Controls)
                {
                    UpdateFont(c, oldFont, newFont);
                }

                if (ctl.Font != newFont)
                {
                    if (ctl.Font.FontFamily.Name == oldFont.FontFamily.Name)
                    {
                        ctl.Font = new Font(newFont.FontFamily, ctl.Font.SizeInPoints * (newFont.SizeInPoints / oldFont.SizeInPoints), ctl.Font.Style);
                    }
                }
            }
        }
开发者ID:modulexcite,项目名称:FieldLog,代码行数:18,代码来源:UIPreferences.cs

示例2: UpdateFormFont

        public static void UpdateFormFont(Form form, Font oldFont, Font newFont)
        {
            if (!oldFont.Equals(newFont))
            {
                UpdateFont(form, oldFont, newFont);

                // Minimise and restore the window to correct any layout errors.

                // Temporarily disable minimise/restore animation because it should not be visible anyway.
                bool animationEnabled = WinApi.IsMinimizeRestoreAnimationEnabled();
                if (animationEnabled)
                    WinApi.SetMinimizeRestoreAnimation(false);

                FormWindowState prevState = form.WindowState;
                form.WindowState = FormWindowState.Minimized;
                form.WindowState = prevState;

                if (animationEnabled)
                    WinApi.SetMinimizeRestoreAnimation(true);
            }
        }
开发者ID:modulexcite,项目名称:FieldLog,代码行数:21,代码来源:UIPreferences.cs

示例3: WriteRegistry

 public static void WriteRegistry(Font tabFont, string[] strsTextExts, string[] strsImgExts) {
     InitializeStaticFields();
     using(RegistryKey key = Registry.CurrentUser.CreateSubKey(@"Software\Quizo\QTTabBar")) {
         if(key != null) {
             key.SetValue("Config", QTUtility.ConfigValues);
             key.SetValue("TabWidth", QTUtility.TabWidth);
             key.SetValue("TabHeight", QTUtility.TabHeight);
             key.SetValue("TabWidthMax", QTUtility.MaxTabWidth);
             key.SetValue("TabWidthMin", QTUtility.MinTabWidth);
             key.SetValue("TitleColorActive", QTUtility.TabTextColor_Active.ToArgb());
             key.SetValue("TitleColorInactive", QTUtility.TabTextColor_Inactv.ToArgb());
             key.SetValue("HighlightColorClassic", QTUtility.TabHiliteColor.ToArgb());
             key.SetValue("TitleColorShadowActive", QTUtility.TabTextColor_ActivShdw.ToArgb());
             key.SetValue("TitleColorShadowInActv", QTUtility.TabTextColor_InAtvShdw.ToArgb());
             key.SetValue("ToolbarBGColor", QTUtility.RebarBGColor.ToArgb());
             key.SetValue("AlternateColor_Bk", QTUtility.ShellViewRowCOLORREF_Background);
             key.SetValue("AlternateColor_Text", QTUtility.ShellViewRowCOLORREF_Text);
             key.SetValue("Max_Undo", QTUtility.MaxCount_History);
             key.SetValue("Max_RecentFile", QTUtility.MaxCount_Executed);
             key.SetValue("PreviewMaxWidth", QTUtility.PreviewMaxWidth);
             key.SetValue("PreviewMaxHeight", QTUtility.PreviewMaxHeight);
             key.SetValue("Action_BarDblClick", QTUtility.Action_BarDblClick);
             if((tabFont != null) && !tabFont.Equals(DefaultFont)) {
                 key.SetValue("TabFont", tabFont.Name);
                 key.SetValue("TabFontSize", tabFont.SizeInPoints.ToString());
                 QTUtility.TabFont = tabFont;
             }
             else {
                 key.DeleteValue("TabFont", false);
                 key.DeleteValue("TabFontSize", false);
                 QTUtility.TabFont = null;
             }
             key.SetValue("TabImage", QTUtility.Path_TabImage);
             byte[] buffer = new byte[] { (byte)QTUtility.TabImageSizingMargin.Left, (byte)QTUtility.TabImageSizingMargin.Top, (byte)QTUtility.TabImageSizingMargin.Right, (byte)QTUtility.TabImageSizingMargin.Bottom };
             key.SetValue("TabImageSizingMargin", buffer);
             QTUtility.PreviewExtsList_Txt.Clear();
             QTUtility.PreviewExtsList_Img.Clear();
             string str = string.Empty;
             string str2 = string.Empty;
             if(strsTextExts != null) {
                 foreach(string ext in strsTextExts) {
                     QTUtility.PreviewExtsList_Txt.Add(ext);
                     str = str + ext + ";";
                 }
                 if(str.Length > 0) {
                     str = str.TrimEnd(QTUtility.SEPARATOR_CHAR);
                 }
             }
             if(strsImgExts != null) {
                 foreach(string ext in strsImgExts) {
                     QTUtility.PreviewExtsList_Img.Add(ext);
                     str2 = str2 + ext + ";";
                 }
                 if(str2.Length > 0) {
                     str2 = str2.TrimEnd(QTUtility.SEPARATOR_CHAR);
                 }
             }
             key.SetValue("TextExtensions", str);
             key.SetValue("ImageExtensions", str2);
             if(QTUtility.PreviewFontName != null) {
                 key.SetValue("PreviewFont", QTUtility.PreviewFontName);
                 key.SetValue("PreviewFontSize", QTUtility.PreviewFontSize.ToString());
             }
             else {
                 key.DeleteValue("PreviewFont", false);
                 key.DeleteValue("PreviewFontSize", false);
             }
             key.SetValue("NetworkTimeout", IDLWrapper.iPingTimeOutMS);
             key.SetValue("LanguageFile", QTUtility.Path_LanguageFile);
             using(RegistryKey key2 = key.CreateSubKey("Plugins")) {
                 if(key2 != null) {
                     key2.SetValue("LanguageFile", QTUtility.Path_PluginLangFile);
                 }
             }
             key.SetValue("ToolbarBGImage", QTUtility.Path_RebarImage);
             QTUtility2.WriteRegBinary(QTUtility.ShortcutKeys, "ShortcutKeys", key);
         }
     }
 }
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:79,代码来源:OptionsDialog.cs

示例4: EnsureInterop

        private static TextServiceDirectWriteInterop EnsureInterop(Font font)
        {
            if (interops == null)
            {
                interops = new List<KeyValuePair<Font, TextServiceDirectWriteInterop>>(MaxCachedInterops);
            }

            if (lastWidth != Screen.PrimaryScreen.Bounds.Width)
            {
                ClearCache();
            }
            lastWidth = Screen.PrimaryScreen.Bounds.Width;

            int index = -1;
            for (int i = 0; i < interops.Count; i++)
            {
                if (font.Equals(interops[i].Key))
                {
                    index = i;
                }
            }
            if (index < 0)
            {
                if (interops.Count >= MaxCachedInterops)
                {
                    ClearCache();
                }
                index = interops.Count;
                TextServiceDirectWriteInterop interop = new TextServiceDirectWriteInterop();
                interop.Reset(TextServiceDirectWrite.InteropGlobals, font, lastWidth);
                interops.Add(new KeyValuePair<Font, TextServiceDirectWriteInterop>(font, interop));
            #if DEBUG
                Debugger.Log(
                    1,
                    "TextServiceDirectWrite",
                    String.Concat(
                        DateTime.Now.ToString(),
                        ": Added DirectWrite interop for ",
                        font.ToString(),
                        " ",
                        font.Style.ToString(),
                        Environment.NewLine));
            #endif
            }
            return interops[index].Value;
        }
开发者ID:programmatom,项目名称:TextEditor,代码行数:46,代码来源:TextServiceDirectWrite.cs

示例5: Ini

        /// <summary>
        /// 计算合适的字体大小与偏移,并创建“g”和“bitmap”。
        /// </summary>
        /// <remarks>关联属性更改后调用</remarks>
        private void Ini()
        {
            if (bitmap != null)
            {
                if (latticeSize != bitmap.Size)
                {
                    bitmap.Dispose();
                    bitmap = null;
                    if (g != null)
                    {
                        g.Dispose();
                    }
                }
            }
            if (bitmap == null)
            {
                bitmap = new Bitmap(width, height);
                g = Graphics.FromImage(bitmap);
                g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
            }
            if (autoFontSize)
            {
                float h = height;
                Font fontn = new Font(Font.FontFamily, h, Font.Style, GraphicsUnit.Pixel);
                if (!fontn.Equals(font))
                {
                    font = fontn;
                    base.OnFontChanged(EventArgs.Empty);
                }
            }

            RectangleF re = new Rectangle(0, 0, 10000, 10000);
            StringFormat sf = new StringFormat();
            string testString = "w";
            CharacterRange[] cr = { new CharacterRange(0, 1) };//,new CharacterRange(1,1)};
            sf.SetMeasurableCharacterRanges(cr);
            Region[] charRegions;
            charRegions = g.MeasureCharacterRanges(testString, font, re, sf);
            if (charRegions.Length > 0)
            {
                PointF t2 = charRegions[0].GetBounds(g).Location;
                charOffset = new PointF(charLocation.X - t2.X, charLocation.Y - t2.Y);
            }
            sf.Dispose();
            DrawChar();
        }
开发者ID:h87kg,项目名称:wordmake,代码行数:50,代码来源:WordBoard.cs

示例6: GetValueTextWidth

        internal int GetValueTextWidth(string valueString, Graphics g, Font f) {

            if (cacheItems == null) {
               cacheItems = new CacheItems();
            } 
            else if (cacheItems.lastValueTextWidth != -1 && cacheItems.lastValueString == valueString && f.Equals(cacheItems.lastValueFont)) {
               return cacheItems.lastValueTextWidth;
            }

            // Value text is rendered using GDI directly (No TextRenderer) but measured/adjusted using GDI+ (since previous releases), so don't use MeasureTextHelper.
            cacheItems.lastValueTextWidth = (int) g.MeasureString(valueString, f).Width;
            cacheItems.lastValueString = valueString;
            cacheItems.lastValueFont = f;
            return cacheItems.lastValueTextWidth;
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:15,代码来源:GridEntry.cs

示例7: GetLabelTextWidth

        protected int GetLabelTextWidth(string labelText, Graphics g, Font f) {

            if (cacheItems == null) {
                cacheItems = new CacheItems();
            }
            else if (cacheItems.useCompatTextRendering == ownerGrid.UseCompatibleTextRendering && cacheItems.lastLabel == labelText && f.Equals(cacheItems.lastLabelFont)) {
                return cacheItems.lastLabelWidth;
            }

            SizeF textSize = PropertyGrid.MeasureTextHelper.MeasureText( this.ownerGrid, g, labelText, f);

            cacheItems.lastLabelWidth = (int) textSize.Width;
            cacheItems.lastLabel = labelText;
            cacheItems.lastLabelFont = f;
            cacheItems.useCompatTextRendering = ownerGrid.UseCompatibleTextRendering;

            return cacheItems.lastLabelWidth;
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:18,代码来源:GridEntry.cs

示例8: GetValueTextWidth

 internal int GetValueTextWidth(string valueString, Graphics g, Font f)
 {
     if (this.cacheItems == null)
     {
         this.cacheItems = new CacheItems();
     }
     else if (((this.cacheItems.lastValueTextWidth != -1) && (this.cacheItems.lastValueString == valueString)) && f.Equals(this.cacheItems.lastValueFont))
     {
         return this.cacheItems.lastValueTextWidth;
     }
     this.cacheItems.lastValueTextWidth = (int) g.MeasureString(valueString, f).Width;
     this.cacheItems.lastValueString = valueString;
     this.cacheItems.lastValueFont = f;
     return this.cacheItems.lastValueTextWidth;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:15,代码来源:GridEntry.cs

示例9: GetLabelTextWidth

 protected int GetLabelTextWidth(string labelText, Graphics g, Font f)
 {
     if (this.cacheItems == null)
     {
         this.cacheItems = new CacheItems();
     }
     else if (((this.cacheItems.useCompatTextRendering == this.ownerGrid.UseCompatibleTextRendering) && (this.cacheItems.lastLabel == labelText)) && f.Equals(this.cacheItems.lastLabelFont))
     {
         return this.cacheItems.lastLabelWidth;
     }
     SizeF ef = PropertyGrid.MeasureTextHelper.MeasureText(this.ownerGrid, g, labelText, f);
     this.cacheItems.lastLabelWidth = (int) ef.Width;
     this.cacheItems.lastLabel = labelText;
     this.cacheItems.lastLabelFont = f;
     this.cacheItems.useCompatTextRendering = this.ownerGrid.UseCompatibleTextRendering;
     return this.cacheItems.lastLabelWidth;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:17,代码来源:GridEntry.cs

示例10: Test

        public static bool Test()
        {
            bool ok = true;
            string s = string.Empty;

            // DecodePoint
            Point p1 = new Point(5, 104);
            s = DecodePointInverse(p1);
            Point p2 = DecodePoint(s);

            if (!p1.Equals(p2))
                ok = false;

            // DecodeSize
            Size s1 = new Size(1254, 67);
            s = DecodeSizeInverse(s1);
            Size s2 = DecodeSize(s);

            if (!s1.Equals(s2))
                ok = false;

            // DecodeFont
            Font f1 = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Point);
            s = DecodeFontInverse(f1);
            Font f2 = DecodeFont(s);

            if (!f1.Equals(f2))
                ok = false;

            // DecodeDateTime
            DateTime t1 = DateTime.Today;
            s = DecodeDateTimeInverse(t1);
            DateTime t2 = DecodeDateTime(s);

            if (!t1.Equals(t2))
                ok = false;

            // DecodeAppearance
            Appearance a1 = Appearance.Button;
            s = DecodeAppearanceInverse(a1);
            Appearance a2 = DecodeAppearance(s);

            if (!t1.Equals(t2))
                ok = false;

            // DecodeScrollBars
            ScrollBars sb1 = ScrollBars.Both;
            s = DecodeScrollBarsInverse(sb1);
            ScrollBars sb2 = DecodeScrollBars(s);

            if (!sb1.Equals(sb2))
                ok = false;

            // DecodeSelectionMode
            SelectionMode sm1 = SelectionMode.MultiSimple;
            s = DecodeSelectionModeInverse(sm1);
            SelectionMode sm2 = DecodeSelectionMode(s);

            if (!sm1.Equals(sm2))
                ok = false;

            // DecodeView
            View v1 = View.LargeIcon;
            s = DecodeViewInverse(v1);
            View v2 = DecodeView(s);

            if (!v1.Equals(v2))
                ok = false;

            // DecodeOrientation
            Orientation o1 = Orientation.Vertical;
            s = DecodeOrientationInverse(o1);
            Orientation o2 = DecodeOrientation(s);

            if (!o1.Equals(o2))
                ok = false;

            // DecodeTickStyle
            TickStyle ts1 = TickStyle.BottomRight;
            s = DecodeTickStyleInverse(ts1);
            TickStyle ts2 = DecodeTickStyle(s);

            if (!ts1.Equals(ts2))
                ok = false;

            // DecodeTabAlignment
            TabAlignment ta1 = TabAlignment.Right;
            s = DecodeTabAlignmentInverse(ta1);
            TabAlignment ta2 = DecodeTabAlignment(s);

            if (!ta1.Equals(ta2))
                ok = false;

            // DecodeListViewItem (single)
            ListViewItem lv1 = new ListViewItem("John Doe");
            s = DecodeListViewItemInverse(lv1);
            ListViewItem lv2 = DecodeListViewItem(s);

            /* not comparable (only by reference)
            if (!lv1.Equals(lv2))
//.........这里部分代码省略.........
开发者ID:jozilla,项目名称:Uiml.net,代码行数:101,代码来源:SWFTypeDecoders.cs

示例11: btnOk_Click

 private void btnOk_Click(object sender, EventArgs e)
 {
     try
     {
         this.SaveProxySetting();
         FontStyle style = FontStyle.Regular;
         if (this.cbDefaultFontStyle.Text == "Bold")
         {
             style = FontStyle.Bold;
         }
         Font font = new Font(this.cbDefaultFontName.Text, (float)Convert.ToInt32(this.cbDefaultFontSize.Text), style);
         if (!font.Equals(Settings.Default.Default_Font))
         {
             Settings.Default.Default_Font = font;
             TemplateManager.Instance.CurrentActiveTemplateView.SetFont();
         }
         int num;
         int.TryParse(this.cbMaxViewOrderRows.Text, out num);
         if (num >= 20 && num <= 9999)
         {
             Settings.Default.ViewOrderRows = num;
         }
         Settings.Default.IsWriteErrorLog = this.chkIsWriteLog.Checked;
         this.SetBlinkTP2AllForm();
         if (this.rdbFontColorSoftStyle.Checked)
         {
             ApplicationInfo.IsFrontSoftStyle = true;
         }
         else if (this.rdbFontColorOriginalStyle.Checked)
         {
             ApplicationInfo.IsFrontSoftStyle = false;
         }
         Settings.Default.Save();
     }
     catch (Exception ex)
     {
         this.ShowError("SaveProfileConfig", ex);
     }
     base.Close();
 }
开发者ID:Padungsak,项目名称:efinTradePlus,代码行数:40,代码来源:frmSystemOption.cs


注:本文中的System.Drawing.Font.Equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。