Esempio n. 1
0
        private void CreateUndrawnElement()
        {
            if (undrawnElement != null)
            {
                FieldAggregator.UnbindElement(undrawnElement);
            }
            switch (DrawingMode)
            {
            case DrawingModes.Rect:
                undrawnElement = new RectangleContainer(this);
                break;

            case DrawingModes.Ellipse:
                undrawnElement = new EllipseContainer(this);
                break;

            case DrawingModes.Text:
                undrawnElement = new TextContainer(this);
                break;

            case DrawingModes.Line:
                undrawnElement = new LineContainer(this);
                break;

            case DrawingModes.Arrow:
                undrawnElement = new ArrowContainer(this);
                break;

            case DrawingModes.Highlight:
                undrawnElement = new HighlightContainer(this);
                break;

            case DrawingModes.Obfuscate:
                undrawnElement = new ObfuscateContainer(this);
                break;

            case DrawingModes.Crop:
                cropContainer  = new CropContainer(this);
                undrawnElement = cropContainer;
                break;

            case DrawingModes.Bitmap:
                undrawnElement = new BitmapContainer(this);
                break;

            case DrawingModes.Path:
                undrawnElement = new FreehandContainer(this);
                break;

            case DrawingModes.None:
                undrawnElement = null;
                break;
            }
            if (undrawnElement != null)
            {
                FieldAggregator.BindElement(undrawnElement);
            }
        }
        public void Test()
        {
            FieldType t = FieldType.LINE_THICKNESS;

            Surface         s  = new Surface();
            FieldAggregator ep = new FieldAggregator();
            //ep.SetFieldValue(t,598);

            RectangleContainer rc = new RectangleContainer(s);

            rc.SetFieldValue(t, 597);
            //Assert.AreNotEqual(ep.GetField(t), rc.GetField(t));
            ep.BindElement(rc);
            Assert.AreEqual(597, ep.GetField(t).Value);
            Assert.AreEqual(597, rc.GetField(t).Value);

            RectangleContainer rc2 = new RectangleContainer(s);

            Assert.AreEqual(597, ep.GetField(t).Value);
            rc2.SetFieldValue(t, 595);
            Assert.AreEqual(595, rc2.GetField(t).Value);
            ep.BindElement(rc2);
            Assert.AreEqual(595, ep.GetField(t).Value);
            Assert.AreEqual(597, rc.GetField(t).Value);

            RectangleContainer rc3 = new RectangleContainer(s);

            rc3.SetFieldValue(t, 600);
            ep.BindElement(rc3);

            //Assert.AreEqual(600, ep.GetField(t).Value);
            Assert.AreEqual(600, rc3.GetField(t).Value);
            Assert.AreEqual(597, rc.GetField(t).Value);

            ep.SetFieldValue(t, 599);
            Assert.AreEqual(599, ep.GetField(t).Value);
            Assert.AreEqual(599, rc.GetField(t).Value);
            Assert.AreEqual(599, rc2.GetField(t).Value);
            Assert.AreEqual(599, rc3.GetField(t).Value);
        }