Exemple #1
0
        public ColorStaticData()
        {
            ColorSets = new Dictionary <string, ColorSet>();

            ColorSet newcs;

            newcs = new ColorSet();
            newcs.Add(System.Drawing.Color.FromArgb(255, 0, 0));
            newcs.Add(System.Drawing.Color.FromArgb(0, 255, 0));
            newcs.Add(System.Drawing.Color.FromArgb(0, 0, 255));
            newcs.Add(System.Drawing.Color.FromArgb(255, 255, 255));
            ColorSets.Add("RGBW", newcs);

            newcs = new ColorSet();
            newcs.Add(System.Drawing.Color.FromArgb(255, 0, 0));
            newcs.Add(System.Drawing.Color.FromArgb(0, 255, 0));
            newcs.Add(System.Drawing.Color.FromArgb(0, 0, 255));
            ColorSets.Add("RGB", newcs);
        }
Exemple #2
0
        public void TestChild()
        {
            ColorSet        set   = new ColorSet();
            ColorSet        child = new ColorSet();
            SolidColorBrush clear = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 0, 0, 0));
            SolidColorBrush red   = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0, 0));

            Assert.IsNull(set["foo"]);

            set.Add(child);

            Assert.IsNull(set["foo"]);

            child.Add(red, "foo");

            Assert.IsNotNull(set["foo"]);
            Assert.IsTrue(ReferenceEquals(set["foo"].Color, red));

            set.Add(clear, "foo");

            Assert.IsNotNull(set["foo"]);
            Assert.IsTrue(ReferenceEquals(set["foo"].Color, clear));
        }
Exemple #3
0
        private bool SaveDisplayedColorSet()
        {
            string   name        = textBoxName.Text;
            ColorSet newColorSet = new ColorSet();

            if (name.Length <= 0)
            {
                MessageBox.Show("You must enter a name for the Color Set.", "Name Requred", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            foreach (var control in tableLayoutPanelColors.Controls)
            {
                ColorPanel cp = (ColorPanel)control;
                newColorSet.Add(cp.Color);
            }

            _data.SetColorSet(textBoxName.Text, newColorSet);

            return(true);
        }
Exemple #4
0
		private bool SaveDisplayedColorSet()
		{
			string name = textBoxName.Text;
			ColorSet newColorSet = new ColorSet();

			if (name.Length <= 0) {
				//messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
				MessageBoxForm.msgIcon = SystemIcons.Error; //this is used if you want to add a system icon to the message form.
				var messageBox = new MessageBoxForm("You must enter a name for the Color Set.", "Name Requred", false, false);
				messageBox.ShowDialog();
				return false;
			}

			foreach (var control in tableLayoutPanelColors.Controls) {
				ColorPanel cp = (ColorPanel)control;
				newColorSet.Add(cp.Color);
			}

			_data.SetColorSet(textBoxName.Text, newColorSet);

			return true;
		}
Exemple #5
0
        private bool SaveDisplayedColorSet()
        {
            string name = textBoxName.Text;
            ColorSet newColorSet = new ColorSet();

            if (name.Length <= 0) {
                //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                MessageBoxForm.msgIcon = SystemIcons.Error; //this is used if you want to add a system icon to the message form.
                var messageBox = new MessageBoxForm("You must enter a name for the Color Set.", "Name Requred", false, false);
                messageBox.ShowDialog();
                return false;
            }

            foreach (var control in tableLayoutPanelColors.Controls) {
                ColorPanel cp = (ColorPanel)control;
                newColorSet.Add(cp.Color);
            }

            _data.SetColorSet(textBoxName.Text, newColorSet);

            return true;
        }
Exemple #6
0
        private bool SaveDisplayedColorSet()
        {
            string name = textBoxName.Text;
            ColorSet newColorSet = new ColorSet();

            if (name.Length <= 0) {
                MessageBox.Show("You must enter a name for the Color Set.", "Name Requred", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }

            foreach (var control in tableLayoutPanelColors.Controls) {
                ColorPanel cp = (ColorPanel)control;
                newColorSet.Add(cp.Color);
            }

            _data.SetColorSet(textBoxName.Text, newColorSet);

            return true;
        }
Exemple #7
0
        public void TestCreate()
        {
            ColorSet set = new ColorSet();

            System.Windows.Media.Color c1 = new System.Windows.Media.Color();
            System.Windows.Media.Color c2 = new System.Windows.Media.Color();
            System.Windows.Media.Color c3 = new System.Windows.Media.Color();

            c1.R = 50; c1.G = 100; c1.B = 150; c1.A = 128;
            c2.R = 250; c2.G = 200; c2.B = 150; c2.A = 191;
            c3.R = 200; c3.G = 150; c3.B = 250; c3.A = 64;

            set.Add(new SolidColorBrush(c1), "NoVariant");
            set.Add(new SolidColorBrush(c2), new SolidColorBrush(c3), "Variant");

            set = new ColorSet(set.Data);

            Assert.AreEqual(set.Colors.Count, 2);

            Assert.IsTrue(set["NoVariant"] != null);
            Assert.IsTrue(set["Variant"] != null);

            ColorPair p1 = set["NoVariant"];
            ColorPair p2 = set["Variant"];

            {
                if (p1.Color is SolidColorBrush c)
                {
                    Assert.AreEqual(c.Color.R, 50);
                    Assert.AreEqual(c.Color.G, 100);
                    Assert.AreEqual(c.Color.B, 150);
                    Assert.AreEqual(c.Color.A, 128);
                }
                else
                {
                    Assert.Fail("Color is not defined");
                }
            }

            if (p1.Variant != null)
            {
                Assert.Fail("No variant should be defined");
            }

            {
                if (p2.Color is SolidColorBrush c)
                {
                    Assert.AreEqual(c.Color.R, 250);
                    Assert.AreEqual(c.Color.G, 200);
                    Assert.AreEqual(c.Color.B, 150);
                    Assert.AreEqual(c.Color.A, 191);
                }
                else
                {
                    Assert.Fail("Color is not defined");
                }
            }

            {
                if (p2.Variant is SolidColorBrush c)
                {
                    Assert.AreEqual(c.Color.R, 200);
                    Assert.AreEqual(c.Color.G, 150);
                    Assert.AreEqual(c.Color.B, 250);
                    Assert.AreEqual(c.Color.A, 64);
                }
                else
                {
                    Assert.Fail("Color is not defined");
                }
            }
        }