Autor Beitrag
KainPlan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27

Vista Buisness, Windows 7
C/C++, C#, PHP...
BeitragVerfasst: Mo 16.02.09 22:29 
Hallo ich würde gerne wissen ob es möglich ist eine "Unknown Color" als DefaultValue für eine Property zu deklarieren. Irgendwie will mir das einfach nicht gelingen!

Sachen wie
ausblenden C#-Quelltext
1:
2:
3:
        [DefaultValue(typeof(Color), "Transparent")]
        [DefaultValue(typeof(Color), "White")]
        [DefaultValue(typeof(Color), "150; 150; 150")]


funktionieren überhaupt nicht, auch keine Hexadezimalwerte oder Integerwerte.
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Mo 16.02.09 22:55 
user profile iconKainPlan hat folgendes geschrieben Zum zitierten Posting springen:
funktionieren überhaupt nicht
Was heißt das? Gibt es eine Exception? Wenn nicht: Du musst den gleichen Wert noch einmal im Konstruktor setzen.

_________________
>λ=
KainPlan Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27

Vista Buisness, Windows 7
C/C++, C#, PHP...
BeitragVerfasst: Mo 16.02.09 23:06 
Nein es gibt keine Exception aber wenn ich das Control per ToolBox erstelle ist der Color wert immer gleich null.
Die von mir erstellte definition der DefaultValue wird quasi ignoriert.


EDIT:
aber wenn ich den Wert im Konstruktor setze wird jeder im Designer erstellter Farbwert einfach beim Programmstart ersetzt/überschrieben.
Ralf Jansen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 4708
Erhaltene Danke: 991


VS2010 Pro, VS2012 Pro, VS2013 Pro, VS2015 Pro, Delphi 7 Pro
BeitragVerfasst: Di 17.02.09 00:08 
Zitat:
aber wenn ich den Wert im Konstruktor setze wird jeder im Designer erstellter Farbwert einfach beim Programmstart ersetzt/überschrieben.

Das kann eigentlich nicht sein. Erst wird das Control erzeugt und dann die im Designer eingestellten Werte zugewiesen (Wie sollte es auch anders herum funktionieren?)
JüTho
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2021
Erhaltene Danke: 6

Win XP Prof
C# 2.0 (#D für NET 2.0, dazu Firebird); früher Delphi 5 und Delphi 2005 Pro
BeitragVerfasst: Di 17.02.09 10:36 
Hallo,

vielleicht solltest Du etwas mehr Code zeigen: den Konstruktor und alles andere, soweit es sich auf die Farben eines dieser Controls bezieht. Gibt es Maßnahmen z.B. in FormLoad, die das beeinflussen?

Jürgen
KainPlan Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27

Vista Buisness, Windows 7
C/C++, C#, PHP...
BeitragVerfasst: Di 17.02.09 19:26 
Hm ok scheint doch zu funktionieren. Nur dann nicht wenn man den Member mit new überschreibt, ist das der fall wird die eingegebene Eigenschaft mysteriöserweise überschrieben. Kann ich mir nicht erklären.

ausblenden volle Höhe C#-Quelltext
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:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
    [DefaultEvent("Click")]
    public class SoftButton : UserControl
    {

        private Image image;
        [System.ComponentModel.BrowsableAttribute(false)]
        public Image Image 
        {
            get { return image; }
            set { image = value; }
        }

        private ToolTip toolTip;
        [System.ComponentModel.BrowsableAttribute(false)]
        public ToolTip ToolTip 
        {
            get { return toolTip; }
            set { toolTip = value; }
        }

        private string text;
        [System.ComponentModel.BrowsableAttribute(true)]
        [Category("Darstellung")]
        [DefaultValue("SoftButton")]
        public new string Text           // hier
        {
            get { return text; }
            set { text = value; Redraw(); }
        }

        private Color colorSoftHover02 = Color.FromArgb(150150150);
        [Category("Darstellung")]
        [DefaultValue(typeof(Color), "150; 150; 150")]
        public Color ColorSoftHover02
        {
            get { return colorSoftHover02; }
            set { colorSoftHover02 = value; Redraw(); }
        }

        private Color colorSoftHoverBorder = Color.Transparent;
        [Category("Darstellung")]
        [DefaultValue(typeof(Color), "Transparent")]
        public Color ColorSoftHoverBorder
        {
            get { return colorSoftHoverBorder; }
            set { colorSoftHoverBorder = value; Redraw(); }
        }

        private Color colorSoftDown02 = Color.White;
        [Category("Darstellung")]
        [DefaultValue(typeof(Color), "White")]
        public Color ColorSoftDown02
        {
            get { return colorSoftDown02; }
            set { colorSoftDown02 = value; Redraw(); }
        }

        private Color colorSoftDownBorder = Color.Transparent;
        [Category("Darstellung")]
        [DefaultValue(typeof(Color), "Transparent")]
        public Color ColorSoftDownBorder
        {
            get { return colorSoftDownBorder; }
            set { colorSoftDownBorder = value; Redraw(); }
        }

        private Color textColor = Color.White;
        [Category("Darstellung")]
        [DefaultValue(typeof(Color), "White")]
        public new Color ForeColor          // und hier... 
        {
            get { return textColor; }
            set { textColor = value; Redraw(); }
        }

        public event SoftButtonDrawBetweenEventHandler OnDrawBetween = null;
        public event SoftButtonDrawTooltipEventHandler OnDrawTooltip = null;

        private Bitmap cacheImgNor = null;
        private Bitmap cacheImgHov = null;
        private Bitmap cacheImgDow = null;

  .

  .

  .