Esempio n. 1
0
        private void OpacityPropertyChangedHandler(object sender, EventArgs e)
        {
            NumberProperty property = sender as NumberProperty;

            _opacity = Math.Min(1f, Math.Max(0f, property.Value));

            OnOpacityChanged(e);
            OnModified(e);
        }
Esempio n. 2
0
        public void CloneNumber()
        {
            Property prop = new NumberProperty("test", 12.5f);
            AttachEvents(prop);

            Property prop2 = prop.Clone() as Property;

            NumberProperty sp1 = prop as NumberProperty;
            NumberProperty sp2 = prop2 as NumberProperty;
            Assert.AreEqual(sp1.Name, sp2.Name);
            Assert.AreEqual(sp1.Value, sp2.Value);

            // Make sure events were not cloned.
            sp2.Name = "test2";
            sp2.Value = 55;
            Assert.AreEqual(EventFlags.None, _eventsFired);
        }
Esempio n. 3
0
        public Property LookupProperty (string name)
        {
            Property prop;

            switch (name) {
                case "Name":
                    prop = new StringProperty("Name", _name);
                    prop.ValueChanged += NamePropertyChangedHandler;
                    return prop;

                case "Opacity":
                    prop = new NumberProperty("Opacity", _opacity);
                    prop.ValueChanged += OpacityPropertyChangedHandler;
                    return prop;

                case "Visible":
                    prop = new BoolProperty("Visible", _visible);
                    prop.ValueChanged += VisiblePropertyChangedHandler;
                    return prop;

                case "RasterMode":
                    prop = new StringProperty("RasterMode", _rasterMode.ToString());
                    prop.ValueChanged += RasterModePropertyChangedHandler;
                    return prop;

                default:
                    return _properties.Contains(name) ? _properties[name] : null;
            }
        }
Esempio n. 4
0
 public NumberProperty(string name, NumberProperty property)
     : base(name, property)
 {
     _value = property._value;
 }
Esempio n. 5
0
        public Property LookupProperty(string name)
        {
            Property prop;

            switch (name) {
                case "X":
                    prop = new NumberProperty("X", X);
                    prop.ValueChanged += PropertyXChanged;
                    return prop;
                case "Y":
                    prop = new NumberProperty("Y", Y);
                    prop.ValueChanged += PropertyYChanged;
                    return prop;
                case "Rotation":
                    prop = new NumberProperty("Rotation", MathEx.RadToDeg(Rotation));
                    prop.ValueChanged += PropertyRotationChanged;
                    return prop;

                default:
                    return _properties.Contains(name) ? _properties[name] : null;
            }
        }
Esempio n. 6
0
        public void ParseNumber()
        {
            Property prop = new NumberProperty("test", 12.5f);
            AttachEvents(prop);

            prop.ValueChanged += (s, e) =>
            {
                Assert.AreSame(prop, s);
                Assert.AreEqual(55.5f, ((NumberProperty)prop).Value);
            };

            prop.Parse("55.5");

            Assert.AreEqual(55.5f, ((NumberProperty)prop).Value);
            Assert.AreEqual(EventFlags.ValueChanged | EventFlags.Modified, _eventsFired);
        }
Esempio n. 7
0
 public void NumberToString()
 {
     Property prop = new NumberProperty("test", 12.5f);
     Assert.AreEqual("12.5", prop.ToString());
 }
Esempio n. 8
0
        public void ModifyNumberSame()
        {
            NumberProperty prop = new NumberProperty("test", 12.5f);
            AttachEvents(prop);

            prop.Value = 12.5f;

            Assert.AreEqual(EventFlags.None, _eventsFired);
        }
Esempio n. 9
0
        public void ModifyNumber()
        {
            NumberProperty prop = new NumberProperty("test", 12.5f);
            AttachEvents(prop);

            prop.ValueChanged += (s, e) =>
            {
                Assert.AreSame(prop, s);
                Assert.AreEqual(55, prop.Value);
            };

            prop.Value = 55;

            Assert.AreEqual(55, prop.Value);
            Assert.AreEqual(EventFlags.ValueChanged | EventFlags.Modified, _eventsFired);
        }
Esempio n. 10
0
 public void CreateNumberProperty()
 {
     NumberProperty prop = new NumberProperty("test", 12.5f);
     Assert.AreEqual(12.5f, prop.Value);
 }
Esempio n. 11
0
        public void CopyConstructNumber()
        {
            NumberProperty prop = new NumberProperty("test", 12.5f);
            AttachEvents(prop);

            NumberProperty prop2 = new NumberProperty("new", prop);

            Assert.AreEqual("new", prop2.Name);
            Assert.AreEqual(prop.Value, prop2.Value);

            // Make sure events were not cloned.
            prop2.Name = "test2";
            prop2.Value = 55f;
            Assert.AreEqual(EventFlags.None, _eventsFired);
        }
Esempio n. 12
0
 public NumberProperty(string name, NumberProperty property)
     : base(name, property)
 {
     _value = property._value;
 }