Willkommen bei dotnet-snippets.de! Snippet hinzufügen Login Registrieren
Snippets in der Datenbank: 1562 | Anzahl registrierter User: 1893 | Besucher online: 323
Hauptmenü
Home
Top Ten
Zufälliger Snippet
FAQs
.NET Community
dotnet-forum.de
dotnet-kicks.de
Social

RSS Feeds
Rss Alle Snippets
Rss C#
Rss VB.NET
Rss C++
Rss ASP.NET
Partner
Member of Microsoft Community Leader/Insider Program (CLIP)

Font Helper


Autor: Sperneder Patrick
Sprache: C#
Bewertung:
noch nicht bewertet
Anzahl der Aufrufe: 2624
  
Kick it on dotnet-kicks.de  

Beschreibung:

Diese Snippets erleichtern den Umgang mit den
bitflags der FontStyle Enumeration.

Ein übergebener Font wird auf die gesetzten flags hin
( bitweise ) überprüft und je nach dem ein neuer Font erzeugt und zurückgegeben.

Hilfreich im Umgang mit der Richtextbox etc..


Abgelegt unter: Font, FontStyle, Bold, Italic, Underline.



C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
  static public Font BoldFont(Font font)
        {
            if (font != null)
            {
                FontStyle fontStyle = font.Style;
                if ((fontStyle & FontStyle.Bold) == 0)
                {
                    fontStyle |= FontStyle.Bold;
                    font = new Font(font, fontStyle);
                }
                else
                {
                    fontStyle ^= FontStyle.Bold;
                    font = new Font(font, fontStyle);
                }
            }
            return font;
        }
      
        static public Font ItalicFont(Font font)
        {
            if (font != null)
            {
                FontStyle fontStyle = font.Style;
                if ((fontStyle & FontStyle.Italic) == 0)
                {
                    fontStyle |= FontStyle.Italic;
                    font = new Font(font, fontStyle);
                }
                else
                {
                    fontStyle ^= FontStyle.Italic;
                    font = new Font(font, fontStyle);
                }
            }
            return font;
        }

        static public Font UnderlineFont(Font font)
        {
            if (font != null)
            {
                FontStyle fontStyle = font.Style;
                if ((fontStyle & FontStyle.Underline) == 0)
                {
                    fontStyle |= FontStyle.Underline ;
                    font = new Font(font, fontStyle);
                }
                else
                {
                    fontStyle ^= FontStyle.Underline ;
                    font = new Font(font, fontStyle);
                }
            }
            return font;
        }
Sie haben Fragen zu diesem Snippet oder brauchen Hilfe bei der .NET Entwicklung?
Freundliche und kompetente Entwickler helfen Ihnen gern weiter im Forum für .NET Entwicklung.



Kommentare:
(Zum Schreiben von Kommentaren bitte anmelden.)



Diese Snippets könnten für Sie interessant sein:

schlecht sehr gut
1 2 3 4 5 6 7 8 9 10
Nur angemeldete User können Snippets bewerten.