コード例 #1
0
    private static void DemoEnums()
    {
        Console.WriteLine("\n\nDemo start: Demo of enumerated types.");
        Color c = Color.Red;

        // What type is this enum & what is it derived from
        Console.WriteLine("   The " + c.GetType() + " type is derived from " + c.GetType().BaseType);

        // What is the underlying type used for the Enum's value
        Console.WriteLine("   Underlying type: " + Enum.GetUnderlyingType(typeof(Color)));

        // Display the set of legal enum values
        Color[] o = (Color[])Enum.GetValues(c.GetType());
        Console.WriteLine("\n   Number of valid enum values: " + o.Length);
        for (int x = 0; x < o.Length; x++)
        {
            Color cc = ((Color)(o[x]));
            Console.WriteLine("   {0}: Name={1,7}\t\tNumber={2}", x,
                              cc.ToString("G"), cc.ToString("D"));
        }

        // Check if a value is legal for this enum
        Console.WriteLine("\n   111 is a valid enum value: " + Enum.IsDefined(c.GetType(), 111)); // True
        Console.WriteLine("   112 is a valid enum value: " + Enum.IsDefined(c.GetType(), 112));   // False

        // Check if two enums are equal
        Console.WriteLine("\n   Is c equal to Red: " + (Color.Red == c));  // True
        Console.WriteLine("   Is c equal to Blue: " + (Color.Blue == c));  // False

        // Display the enum's value as a string using different format specifiers
        Console.WriteLine("\n   c's value as a string: " + c.ToString("G")); // Red
        Console.WriteLine("   c's value as a number: " + c.ToString("D"));   // 111

        // Convert a string to an enum's value
        c = (Color)(Enum.Parse(typeof(Color), "Blue"));
        try {
            c = (Color)(Enum.Parse(typeof(Color), "NotAColor"));  // Not valid, raises exception
        }
        catch (ArgumentException) {
            Console.WriteLine("   'NotAColor' is not a valid value for this enum.");
        }

        // Display the enum's value as a string
        Console.WriteLine("\n   c's value as a string: " + c.ToString("G")); // Blue
        Console.WriteLine("   c's value as a number: " + c.ToString("D"));   // 333

        Console.WriteLine("Demo stop: Demo of enumerated types.");
    }
コード例 #2
0
    public Texture2D GetEmptySprite(string emptyString)
    {
        //Split up the string and get the parameters
        string[] parts  = emptyString.Split(':');
        int      width  = int.Parse(parts[1]);
        int      height = int.Parse(parts[2]);
        int      size   = int.Parse(parts[3]);

        //Use Reflection to get the specified Color Property.
        Color color = Color.Black;

        color = (Color)color.GetType().GetProperty(parts[4]).GetValue(null);

        //New empty texture
        Texture2D emptyTexture = new Texture2D(graphicsDevice, width, height);

        Color[] pixels = new Color[width * height];
        for (int y1 = 0; y1 < height; y1++)
        {
            //Whether or not to start with a colored square.
            bool pinkStart = y1 % (2 * size) < size;
            for (int x1 = 0; x1 < width; x1++)
            {
                //Whether or not this square is colored or black.
                bool pink = x1 % (2 * size) < size ? pinkStart : !pinkStart;
                pixels[y1 * width + x1] = pink ? color : Color.Black;
            }
        }
        emptyTexture.SetData(pixels);

        textures.Add(emptyString, emptyTexture);
        return(emptyTexture);
    }
コード例 #3
0
ファイル: ColorControl.xeto.cs プロジェクト: vavavr00m/NCM
        public void SetValues(Color color)
        {
            if (color == null)
            {
                throw new ArgumentNullException(nameof(color));
            }
            if (color.GetType() != CurrentColor)
            {
                throw new ArgumentException("Color is not the same as selected type", nameof(color));
            }

            if (ReadOnly)
            {
                for (int i = 0; i < ValueTextBoxes.Count; i++)
                {
                    ValueTextBoxes[i].Text = color[i].ToString("F6");
                }
            }
            else
            {
                for (int i = 0; i < ValueTextBoxes.Count; i++)
                {
                    ValueNumBoxes[i].Value = color[i];
                }
            }
        }
コード例 #4
0
ファイル: Color.cs プロジェクト: MonliH/zircon
 public static string ToS(this Color val)
 {
     DescriptionAttribute[]? attributes = (DescriptionAttribute[]?)val
                                          .GetType()
                                          .GetField(val.ToString())
                                          ?.GetCustomAttributes(typeof(DescriptionAttribute), false);
     return(attributes == null ? "" : attributes.Length > 0 ? attributes[0].Description : string.Empty);
 }
コード例 #5
0
        public void Save(String PropertyName, Color Value)
        {
            var Result = _GameSaver.CreateChildElement(_Element, PropertyName, Value.GetType());

            _AppendProperty(Result, "red", Convert.ToSingle(Value.R) / 255.0f);
            _AppendProperty(Result, "green", Convert.ToSingle(Value.G) / 255.0f);
            _AppendProperty(Result, "blue", Convert.ToSingle(Value.B) / 255.0f);
            _AppendProperty(Result, "opacity", Convert.ToSingle(Value.A) / 255.0f);
        }
コード例 #6
0
ファイル: EntityReader.cs プロジェクト: whztt07/DeltaEngine
		private void RefreshColorControls(Color component)
		{
			List<Control> controls;
			componentControls.TryGetValue(component.GetType(), out controls);
			((Slider)controls[1]).Value = component.R;
			((Slider)controls[3]).Value = component.G;
			((Slider)controls[5]).Value = component.B;
			((Slider)controls[7]).Value = component.A;
		}
コード例 #7
0
        private static string TranslateFromColor(Color c)
        {
            if (c.IsEmpty || c.GetType().GetProperty(c.Name, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static) == null)
            {
                throw (new ArgumentException("A preset color can not be set to empty or be an unnamed color"));
            }
            var s = c.Name.ToString();

            return(s.Substring(0, 1).ToLower() + s.Substring(1));
        }
コード例 #8
0
        private void RefreshColorControls(Color component)
        {
            List <Control> controls;

            componentControls.TryGetValue(component.GetType(), out controls);
            ((Slider)controls[1]).Value = component.R;
            ((Slider)controls[3]).Value = component.G;
            ((Slider)controls[5]).Value = component.B;
            ((Slider)controls[7]).Value = component.A;
        }
コード例 #9
0
        //根据一个<KeyWords name = "ValueTypes" bold="true" italic="false" color="Red"></KeyWords>
        //这种节点来得到一个HighlightColor对象.
        public HighlightColor(XmlElement el)
        {
            Debug.Assert(el != null, "NetFocus.DataStructure.TextEditor.Document.SyntaxColor(XmlElement el) : el == null");
            if (el.Attributes["bold"] != null)
            {
                bold = Boolean.Parse(el.Attributes["bold"].InnerText);
            }

            if (el.Attributes["italic"] != null)
            {
                italic = Boolean.Parse(el.Attributes["italic"].InnerText);
            }

            if (el.Attributes["color"] != null)
            {
                string c = el.Attributes["color"].InnerText;
                if (c[0] == '#')
                {
                    color = ParseColor(c);
                }
                else if (c.StartsWith("SystemColors."))
                {
                    systemColor     = true;
                    systemColorName = c.Substring("SystemColors.".Length);
                }
                else
                {
                    color = (Color)(Color.GetType()).InvokeMember(c, BindingFlags.GetProperty, null, Color, new object[0]);
                }
                hasForgeground = true;
            }
            else
            {
                color = Color.Transparent;                 // to set it to the default value.
            }

            if (el.Attributes["bgcolor"] != null)
            {
                string c = el.Attributes["bgcolor"].InnerText;
                if (c[0] == '#')
                {
                    backgroundcolor = ParseColor(c);
                }
                else if (c.StartsWith("SystemColors."))
                {
                    systemBgColor     = true;
                    systemBgColorName = c.Substring("SystemColors.".Length);
                }
                else
                {
                    backgroundcolor = (Color)(Color.GetType()).InvokeMember(c, BindingFlags.GetProperty, null, Color, new object[0]);
                }
                hasBackground = true;
            }
        }
コード例 #10
0
        /// <summary>
        ///     Creates a new instance of <see cref="HighlightColor" />
        /// </summary>
        public HighlightColor(XmlElement el)
        {
            Debug.Assert(el != null, "ICSharpCode.TextEditor.Document.SyntaxColor(XmlElement el) : el == null");
            if (el.Attributes["bold"] != null)
            {
                Bold = bool.Parse(el.Attributes["bold"].InnerText);
            }

            if (el.Attributes["italic"] != null)
            {
                Italic = bool.Parse(el.Attributes["italic"].InnerText);
            }

            if (el.Attributes["color"] != null)
            {
                var c = el.Attributes["color"].InnerText;
                if (c[0] == '#')
                {
                    Color = ParseColor(c);
                }
                else if (c.StartsWith("SystemColors."))
                {
                    Color = ParseColorString(c.Substring("SystemColors.".Length));
                }
                else
                {
                    Color = (Color)Color.GetType()
                            .InvokeMember(c, BindingFlags.GetProperty, null, Color, new object[0]);
                }
                HasForeground = true;
            }
            else
            {
                Color = Color.Transparent; // to set it to the default value.
            }

            if (el.Attributes["bgcolor"] != null)
            {
                var c = el.Attributes["bgcolor"].InnerText;
                if (c[0] == '#')
                {
                    BackgroundColor = ParseColor(c);
                }
                else if (c.StartsWith("SystemColors."))
                {
                    BackgroundColor = ParseColorString(c.Substring("SystemColors.".Length));
                }
                else
                {
                    BackgroundColor = (Color)Color.GetType()
                                      .InvokeMember(c, BindingFlags.GetProperty, null, Color, new object[0]);
                }
                HasBackground = true;
            }
        }
コード例 #11
0
        internal static ColorInfoAttribute GetColorInfo(this Color color)
        {
            MemberInfo memberInfo = color.GetType().GetMember(color.ToString()).FirstOrDefault();

            if (memberInfo != null)
            {
                return(memberInfo.GetCustomAttribute <ColorInfoAttribute>());
            }

            throw new InvalidOperationException("It is not possible to read ColorInfoAttribute from enumeration.");
        }
コード例 #12
0
        /// <summary>
        /// Get Systemcolors and fill the combobox
        /// </summary>
        private void GetComboBoxColors()
        {
            var colorProperties = _colors.GetType().GetProperties(BindingFlags.Static | BindingFlags.Public);
            var colors          = colorProperties.Select(prop => (Color)prop.GetValue(null, null));

            foreach (Color myColor in colors)
            {
                _colorList.Add(myColor);
                cmbWatercolor.Items.Add(myColor.Name);
            }
        }
コード例 #13
0
        public void getFontColor()
        {
            this.tscbFontColor.ComboBox.DrawMode  = DrawMode.OwnerDrawFixed;
            this.tscbFontColor.ComboBox.DrawItem += new DrawItemEventHandler(tscbFontColor_DrawItem);
            Color clr = new Color();

            PropertyInfo[] colors = clr.GetType().GetProperties();
            foreach (PropertyInfo c in colors)
            {
                this.tscbFontColor.Items.Add(c.Name);
            }
        }
コード例 #14
0
ファイル: Shape.cs プロジェクト: HongHanh2104/Paint
        public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            info.AddValue("ForeColor", ForeColor, ForeColor.GetType());
            info.AddValue("DashStyle", dashStyle);
            info.AddValue("Width", width);

            float[] matrix = transformationMatrix.Elements;
            info.AddValue("TransformationMatrix", matrix, typeof(float[]));

            matrix = previousMatrix.Elements;
            info.AddValue("PreviousMatrix", matrix, typeof(float[]));
        }
コード例 #15
0
    public static Type ObjectGetType()
    {
        Type  tmp   = null;
        Color black = Color.Black;

        foreach (var iteration in Benchmark.Iterations)
        {
            using (iteration.StartMeasurement())
                tmp = black.GetType();
        }

        return(tmp);
    }
コード例 #16
0
        protected override void CreateRenderBitmap( )
        {
            using (Graphics gr = CreateNewRenderBitmap( ))
            {
                gr.FillRectangle(new SolidBrush(color), thumb_location.X, thumb_location.Y, thumb_size.Width, thumb_size.Height);

                gr.DrawString("Name: " + resource_name, smallFont, solidBrushBlack, content_text_x_pos, content_name_y_pos);

                gr.DrawString("Type: " + color.GetType( ), smallFont, solidBrushBlack, content_text_x_pos, content_type_y_pos);

                gr.DrawString("Color: " + ContentString( ), smallFont, solidBrushBlack, content_text_x_pos, content_content_y_pos);
            }
        }
コード例 #17
0
ファイル: Color.cs プロジェクト: ogazitt/zaplify
        public void Copy(Color obj)
        {
            if (obj == null)
                return;

            // copy all of the properties
            foreach (PropertyInfo pi in obj.GetType().GetProperties())
            {
                // get the value of the property
                var val = pi.GetValue(obj, null);
                pi.SetValue(this, val, null);
            }
        }
コード例 #18
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Color clr = new Color();

            PropertyInfo[] colors = clr.GetType().GetProperties();
            for (int i = 8; i <= 72; i++)
            {
                tscbFontSize.Items.Add(i);
            }

            InstalledFontCollection fontsCollection = new InstalledFontCollection();

            FontFamily[] fontFamilies = fontsCollection.Families;
            foreach (FontFamily font in fontFamilies)
            {
                tscbFontFamily.Items.Add(font.Name);
            }

            this.tscbBackColor.ComboBox.DrawMode = DrawMode.OwnerDrawFixed;
            this.tscbFontColor.ComboBox.DrawMode = DrawMode.OwnerDrawFixed;

            foreach (PropertyInfo color in colors)
            {
                if (color.PropertyType == typeof(System.Drawing.Color))
                {
                    tscbBackColor.Items.Add(color.Name);
                    tscbFontColor.Items.Add(color.Name);
                }
            }

            //inisiasi
            tscbFontSize.SelectedIndex = 3;
            tscbFontFamily.Text        = "Calibri";
            tscbFontColor.Text         = "Black";
            tscbBackColor.Text         = "White";
            changeText();
            //event
            this.tscbBackColor.ComboBox.DrawItem += new DrawItemEventHandler(tscbFontColor_DrawItem);
            this.tscbFontColor.ComboBox.DrawItem += new DrawItemEventHandler(tscbFontColor_DrawItem);

            MdiClient client = Controls.OfType <MdiClient>().First();

            client.GotFocus += (s, ev) =>
            {
                if (!MdiChildren.Any(x => x.Visible))
                {
                    client.SendToBack();
                    rtbNote.BringToFront();
                }
            };
        }
コード例 #19
0
        public void ReadXml(XmlReader reader)
        {
            if (reader.IsEmptyElement)
            {
                return;
            }
            reader.Read();

            var pathSerializer = new XmlSerializer(typeof(SerializableDictionary <int, int>));

            reader.ReadStartElement();
            Path = pathSerializer.Deserialize(reader) as SerializableDictionary <int, int>;
            reader.ReadEndElement();

            id = reader.ReadElementContentAsInt();

            Text = reader.ReadElementContentAsString();

            reader.ReadStartElement();
            var x = reader.ReadElementContentAsDouble();
            var y = reader.ReadElementContentAsDouble();

            pos = new Point(x, y);
            reader.ReadEndElement();

            reader.ReadStartElement();
            x     = reader.ReadElementContentAsDouble();
            y     = reader.ReadElementContentAsDouble();
            centr = new Point(x, y);
            reader.ReadEndElement();

            var serclr = new XmlSerializer(borderColor.GetType());

            borderColor = (Color)serclr.Deserialize(reader);
            fillColor   = (Color)serclr.Deserialize(reader);

            reader.ReadEndElement();
        }
コード例 #20
0
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            int   resultado = 0;
            Color color     = new Color();

            color = (Color)value;

            if (color.GetType().Name == "LightGray")
            {
                resultado = 0;
            }

            return(resultado);
        }
コード例 #21
0
        /// <summary>
        /// Returns an array of every color that this image contains.
        /// </summary>
        /// <returns></returns>
        public Color[] GetColors()
        {
            ArrayList colors = new ArrayList();

            int   start_index;
            Color to_add = Color.Black;

            if (bytesPixel == 4)
            {
                for (int column = 0; column < width; column++)
                {
                    for (int row = 0; row < height; row++)
                    {
                        start_index = bytesPixel * column + row * bytesLine;

                        to_add = Color.FromArgb(pixels[start_index + 3],
                                                pixels[start_index + 2],
                                                pixels[start_index + 1],
                                                pixels[start_index]);

                        if (!colors.Contains(to_add))
                        {
                            colors.Add(to_add);
                        }
                    }
                }
            }
            else
            {
                for (int column = 0; column < width; column++)
                {
                    for (int row = 0; row < height; row++)
                    {
                        start_index = bytesPixel * column + row * bytesLine;

                        to_add = Color.FromArgb(pixels[start_index + 2],
                                                pixels[start_index + 1],
                                                pixels[start_index]);
                        if (!colors.Contains(to_add))
                        {
                            colors.Add(to_add);
                        }
                    }
                }
            }

            return((Color[])colors.ToArray(to_add.GetType()));
        }
コード例 #22
0
    public static Type ObjectGetType()
    {
        Type  tmp   = null;
        Color black = Color.Black;

        foreach (var iteration in Benchmark.Iterations)
        {
            using (iteration.StartMeasurement())
                for (int i = 0; i < Benchmark.InnerIterationCount; i++)
                {
                    tmp = black.GetType();
                }
        }

        return(tmp);
    }
コード例 #23
0
        public void Writes_error_for_anything_else()
        {
            // Arrange
            var formatter = BuildFormatter();
            var stream    = new MemoryStream();

            // Act
            var resource = new Color {
                Id = "1", Name = "Blue"
            };

            formatter.WriteToStreamAsync(resource.GetType(), resource, stream, null, null).Wait();

            // Assert
            TestHelpers.StreamContentsMatchFixtureContents(stream, "Json/Fixtures/JsonApiFormatter/Writes_error_for_anything_else.json");
        }
コード例 #24
0
        private void Setting_Load(object sender, EventArgs e)
        {
            Form1 frm = (Form1)MdiParent;
            Color clr = new Color();

            PropertyInfo[] colors = clr.GetType().GetProperties();
            foreach (PropertyInfo color in colors)
            {
                if (color.PropertyType == typeof(System.Drawing.Color))
                {
                    bgColor.Items.Add(color.Name);
                }
            }
            this.bgColor.DrawMode  = DrawMode.OwnerDrawFixed;
            this.bgColor.DrawItem += new DrawItemEventHandler(bgColor_DrawItem);
            this.bgColor.Text      = frm.getBackgroundColor();
        }
コード例 #25
0
ファイル: DVXmlSerializer.cs プロジェクト: north0808/haina
 internal string ColorToName(Color color)
 {
     string str = color.ToArgb().ToString("x");
     if (color.IsSystemColor)
     {
         try
         {
             object obj2 = color.GetType().GetField("m_clr", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(color);
             int index = (int) obj2.GetType().GetField("m_nVal", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(obj2);
             str = this.SystemColorNames[index];
         }
         catch
         {
         }
     }
     return str;
 }
コード例 #26
0
        public void Test_EntityWithOneMatchingComponentAndNonMatchingComponent_MatchFalse()
        {
            // Arrange
            var entity = new Entity(new World());

            var transform = new Transform(10f, 10f, 32f, 32f);
            var color     = new Color(1f, 0f, 0f);

            entity.AddComponent(transform);

            var filter = new Filter(new[] { transform.GetType(), color.GetType() });

            // Act
            var match = filter.Match(entity);

            // Assert
            Assert.False(match);
        }
コード例 #27
0
        internal string ColorToName(Color color)
        {
            string str = color.ToArgb().ToString("x");

            if (color.IsSystemColor)
            {
                try
                {
                    object obj2  = color.GetType().GetField("m_clr", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(color);
                    int    index = (int)obj2.GetType().GetField("m_nVal", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(obj2);
                    str = this.SystemColorNames[index];
                }
                catch
                {
                }
            }
            return(str);
        }
コード例 #28
0
    public string GetUIIdentifier(bool inRGBA = false)
    {
        if (inRGBA)
        {
            return(ColorUtility.ToHtmlStringRGBA(playerColor));
        }
        else
        {
            var props = playerColor.GetType().GetProperties(BindingFlags.Public | BindingFlags.Static);

            foreach (var prop in props)
            {
                if ((Color)prop.GetValue(null) == playerColor)
                {
                    return(prop.Name);
                }
            }
            return(playerColor.ToString());
        }
    }
コード例 #29
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Color clr = new Color();

            PropertyInfo[] colors = clr.GetType().GetProperties();
            for (int i = 8; i <= 72; i++)
            {
                tscbFontSize.Items.Add(i);
            }

            InstalledFontCollection fontsCollection = new InstalledFontCollection();

            FontFamily[] fontFamilies = fontsCollection.Families;
            foreach (FontFamily font in fontFamilies)
            {
                tscbFontFamily.Items.Add(font.Name);
            }

            this.tscbBackColor.ComboBox.DrawMode = DrawMode.OwnerDrawFixed;
            this.tscbFontColor.ComboBox.DrawMode = DrawMode.OwnerDrawFixed;

            foreach (PropertyInfo color in colors)
            {
                if (color.PropertyType == typeof(System.Drawing.Color))
                {
                    tscbBackColor.Items.Add(color.Name);
                    tscbFontColor.Items.Add(color.Name);
                }
            }

            //inisiasi
            tscbFontSize.SelectedIndex = 3;
            tscbFontFamily.Text        = "Calibri";
            tscbFontColor.Text         = "Black";
            tscbBackColor.Text         = "White";
            changeText();
            //event
            this.tscbBackColor.ComboBox.DrawItem += new DrawItemEventHandler(tscbFontColor_DrawItem);
            this.tscbFontColor.ComboBox.DrawItem += new DrawItemEventHandler(tscbFontColor_DrawItem);
        }
コード例 #30
0
ファイル: ColorConverter.cs プロジェクト: TRushton95/Frames
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            JToken jToken = JToken.Load(reader);

            // If ui specification used a preset colour string
            if (jToken.Type == JTokenType.String)
            {
                Color result = Color.Transparent;

                Color color     = new Color();
                Type  colorType = color.GetType();

                string[] colorDetails = jToken.Value <string>().Split('-');
                string   presetColor  = colorDetails[0];

                PropertyInfo propertyInfo = colorType.GetProperty(presetColor);

                if (propertyInfo != null)
                {
                    result = (Color)propertyInfo.GetValue(color, null);

                    // If second value given for color, try to get an alpha value from it
                    if (colorDetails.Length == 2 && byte.TryParse(colorDetails[1], out byte alpha))
                    {
                        result.A = alpha;
                    }
                }

                return(result);
            }

            // If an RGBA object in supplied, exctract an build a color from the values
            byte r = jToken["R"].Value <byte>();
            byte g = jToken["G"].Value <byte>();
            byte b = jToken["B"].Value <byte>();
            byte a = jToken["A"].Value <byte>();

            return(new Color(r, g, b, a));
        }
コード例 #31
0
ファイル: TestScreen.cs プロジェクト: wtfcolt/game
        /// <summary>
        /// Handles initialization of the GameScreen. This will be invoked after the GameScreen has been
        /// completely and successfully added to the ScreenManager. It is highly recommended that you
        /// use this instead of the constructor. This is invoked only once.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            topForm = new Form(GUIManager, new Vector2(5, 5), new Vector2(700, 550))
            {
                Text = "Primary form"
            };

            var tb = new TextBox(topForm, new Vector2(10, 10), new Vector2(150, 300));

            _textBox = new TextBox(topForm, new Vector2(350, 10), new Vector2(200, 200))
            {
                Font = GUIManager.Font, Text = "abcdef\nghi\r\njklj\n"
            };

            for (var i = 0; i < 150; i++)
            {
                var c = new Color((byte)rnd.Next(0, 256), (byte)rnd.Next(256), (byte)rnd.Next(256), 255);
                _textBox.Append(new StyledText(i + " ", c));
            }

            var styledTexts = new List <StyledText>
            {
                new StyledText("Black ", Color.Black),
                new StyledText("Red ", Color.Red),
                new StyledText("Green ", Color.Green),
                new StyledText("Yellow ", Color.Yellow),
                new StyledText("Voilet ", Color.Violet),
                new StyledText("Orange ", Color.Orange),
                new StyledText("Tomato ", Color.Tomato),
                new StyledText("DarkRed ", Color.DarkRed),
            };

            tb.Append(styledTexts);

            var form = new Form(topForm, new Vector2(50, 50), new Vector2(200, 200))
            {
                Text = "My form"
            };

            var b = new Button(form, new Vector2(20, 20), new Vector2(80, 30))
            {
                Text = "Press me"
            };

            b.Clicked += b_Clicked;

            new CheckBox(form, new Vector2(20, 200))
            {
                Text = "Checkbox"
            };

            var f2 = new Form(topForm, new Vector2(200, 250), new Vector2(275, 270))
            {
                Text = "My form 2"
            };
            var f3 = new Form(f2, Vector2.Zero, new Vector2(200, 200))
            {
                Text = "form 3"
            };
            var f4 = new Form(f3, Vector2.Zero, new Vector2(100, 100))
            {
                Text = "form 4"
            };

            var testLabelF4 = new Label(f4, Vector2.Zero)
            {
                Text = "Click me"
            };

            testLabelF4.Clicked += testLabelF4_Clicked;

            _dragLbl = new Label(topForm, topForm.Size - new Vector2(75, 30));

            topForm.BeginDrag += DragControl;
            topForm.EndDrag   += DragControl;
            form.BeginDrag    += DragControl;
            form.EndDrag      += DragControl;
            f2.BeginDrag      += DragControl;
            f2.EndDrag        += DragControl;
            f3.BeginDrag      += DragControl;
            f3.EndDrag        += DragControl;
            f4.BeginDrag      += DragControl;
            f4.EndDrag        += DragControl;

            // Set up the tooltips
            foreach (var c in GUIManager.GetAllControls())
            {
                if (c.GetType() == typeof(Button))
                {
                    c.Tooltip = Tooltip_Button;
                }
                else if (c.GetType() == typeof(Label))
                {
                    c.Tooltip += Tooltip_Label;
                }
            }

            // Paged list
            var items = new List <string>();

            for (var i = 0; i < 100; i++)
            {
                items.Add(i.ToString());
            }

            new ListBox <string>(topForm, new Vector2(500, 250), new Vector2(100, 100))
            {
                Items = items, ShowPaging = true, CanSelect = true
            };
        }
コード例 #32
0
ファイル: Shape.cs プロジェクト: HongHanh2104/Paint
 public override void GetObjectData(SerializationInfo info, StreamingContext context)
 {
     base.GetObjectData(info, context);
     info.AddValue("BackColor", BackColor, BackColor.GetType());
     info.AddValue("Pattern", pattern, typeof(Bitmap));
 }
コード例 #33
0
 private void Write139_Color(string n, string ns, Color o, bool needType)
 {
     if (!needType && (o.GetType() != typeof(Color)))
     {
         throw base.CreateUnknownTypeException(o);
     }
     base.WriteStartElement(n, ns, o, false, null);
     if (needType)
     {
         base.WriteXsiType("Color", "");
     }
     base.WriteEndElement(o);
 }
コード例 #34
0
        public static void OnSceneReflectUnityEngineMaterial(SceneExplorerState state, ReferenceChain refChain, Material material)
        {
            if (!SceneExplorerCommon.SceneTreeCheckDepth(refChain))
            {
                return;
            }

            if (material == null)
            {
                SceneExplorerCommon.OnSceneTreeMessage(refChain, "null");
                return;
            }

            ReferenceChain oldRefChain = refChain;

            foreach (var prop in textureProps)
            {
                if (!material.HasProperty(prop))
                {
                    continue;
                }

                var value = material.GetTexture(prop);
                if (value == null)
                {
                    continue;
                }

                refChain = oldRefChain.Add(prop);

                var type = value.GetType();

                GUILayout.BeginHorizontal();
                GUILayout.Space(ModTools.Instance.config.sceneExplorerTreeIdentSpacing * (refChain.Ident + 1));

                GUIExpander.ExpanderControls(state, refChain, type);

                GUI.contentColor = ModTools.Instance.config.typeColor;

                GUILayout.Label(type.ToString() + " ");

                GUI.contentColor = ModTools.Instance.config.nameColor;

                GUILayout.Label(prop);

                GUI.contentColor = Color.white;

                GUILayout.Label(" = ");

                GUI.contentColor = ModTools.Instance.config.valueColor;
                GUILayout.Label(value.ToString());
                GUI.contentColor = Color.white;

                GUILayout.FlexibleSpace();
                GUIButtons.SetupButtons(type, value, refChain);
                object paste;
                var    doPaste = GUIButtons.SetupPasteButon(type, out paste);
                GUILayout.EndHorizontal();

                if (!TypeUtil.IsSpecialType(type) && state.expandedObjects.ContainsKey(refChain))
                {
                    GUIReflect.OnSceneTreeReflect(state, refChain, value);
                }

                if (doPaste)
                {
                    material.SetTexture(prop, (Texture)paste);
                }
            }

            foreach (string prop in colorProps)
            {
                if (!material.HasProperty(prop))
                {
                    continue;
                }

                Color value = material.GetColor(prop);
                refChain = oldRefChain.Add(prop);

                var type = value.GetType();

                GUILayout.BeginHorizontal();
                GUILayout.Space(ModTools.Instance.config.sceneExplorerTreeIdentSpacing * (refChain.Ident + 1));

                GUIExpander.ExpanderControls(state, refChain, type);

                GUI.contentColor = ModTools.Instance.config.typeColor;

                GUILayout.Label(type.ToString() + " ");

                GUI.contentColor = ModTools.Instance.config.nameColor;

                GUILayout.Label(prop);

                GUI.contentColor = Color.white;

                GUILayout.Label(" = ");
                var f = value;

                GUI.contentColor = ModTools.Instance.config.valueColor;

                var propertyCopy = prop;
                GUIControls.ColorField(refChain.ToString(), "", ref f, 0.0f, null, true, true, color => { material.SetColor(propertyCopy, color); });
                if (f != value)
                {
                    material.SetColor(prop, f);
                }

                GUI.contentColor = Color.white;
                GUILayout.FlexibleSpace();
                GUIButtons.SetupButtons(type, value, refChain);
                object paste;
                var    doPaste = GUIButtons.SetupPasteButon(type, out paste);
                GUILayout.EndHorizontal();

                if (!TypeUtil.IsSpecialType(type) && state.expandedObjects.ContainsKey(refChain))
                {
                    GUIReflect.OnSceneTreeReflect(state, refChain, value);
                }
                if (doPaste)
                {
                    material.SetColor(prop, (Color)paste);
                }
            }

            GUIReflect.OnSceneTreeReflect(state, refChain, material, true);
        }
コード例 #35
0
ファイル: Color.cs プロジェクト: ogazitt/TaskStore
 public void Copy(Color value)
 {
     // copy all of the properties
     foreach (PropertyInfo pi in value.GetType().GetProperties())
     {
         // get the value of the property
         var val = pi.GetValue(value, null);
         pi.SetValue(this, val, null);
     }
 }