Пример #1
0
        public void Init(EShapeType type, int thickness, PaintColor color)
        {
            _newshape           = _shape.CreateShape(type);
            _newshape.Thickness = thickness;
            _newshape.Color     = color;

            _storage.Add(_newshape);
        }
        public override void Load(ISceneDataNode sceneDataNode)
        {
            var scale            = new Vector3(1, 1, 1);
            var position         = new Vector3();
            var orientationAxis  = new Vector3(0, 0, 1);
            var orientationAngle = 0.0f;

            if (sceneDataNode.HasParameter("scale"))
            {
                scale = sceneDataNode.ReadVectorParameter("scale");
            }
            if (sceneDataNode.HasParameter("position"))
            {
                position = sceneDataNode.ReadVectorParameter("position");
            }
            if (sceneDataNode.HasParameter("orientationAxis"))
            {
                orientationAxis  = sceneDataNode.ReadVectorParameter("orientationAxis");
                orientationAngle = sceneDataNode.ReadFloatParameter("angle");
            }
            Init(scale, position, orientationAxis, orientationAngle);

            var name = sceneDataNode.ReadParameter("shapeName");

            if (sceneDataNode.HasParameter("filePath"))
            {
                var shapeTypeString = sceneDataNode.ReadParameter("shapeType");
                var shapeType       = (ShapeType)Enum.Parse(typeof(ShapeType), shapeTypeString);
                var filePath        = sceneDataNode.ReadParameter("filePath");
                var fileTypeString  = Path.GetExtension(filePath).TrimStart('.');

                var fileType = (FileType)Enum.Parse(typeof(FileType), fileTypeString);
                _shape = _shapeFactory.CreateShape(shapeType, fileType, name);
                _shape.Load(filePath);
            }
            else
            {
                var primitveTypeString = sceneDataNode.ReadParameter("primitiveType");
                var primitveType       = (PrimitiveType)Enum.Parse(typeof(PrimitiveType), primitveTypeString);
                _shape = _shapeFactory.CreateShape(primitveType, name);
            }

            var materialKey = sceneDataNode.ReadParameter("material");

            if (_resourceManager.HasMaterial(materialKey))
            {
                _shape.Material = _resourceManager.GetMaterial(materialKey);
            }
        }
        public void Execute(IList <string> arguments)
        {
            if (string.IsNullOrEmpty(_shapeParser.CurrentFile))
            {
                _writer.WriteLine("No file loaded!");
                return;
            }

            if (arguments.Count == 1)
            {
                _writer.WriteLine("Specify figure type!");
                return;
            }

            var shapeTypeArgument = arguments[1];

            if (ShapeMappings.ShapeNameToTypeMap.TryGetValue(shapeTypeArgument, out ShapeType reslovedShapeType))
            {
                var shapeAttributes = TextProcessingUtils.SplitAttributes(arguments);

                Shape newShape = _shapeFactory.CreateShape(reslovedShapeType, shapeAttributes);
                _shapeContainer.Shapes.Add(newShape);
                _writer.WriteLine("Successfully created shape!");
            }
            else
            {
                _writer.WriteLine("No such shape supported!");
            }
        }
        public void Execute(IList <string> arguments)
        {
            if (arguments.Count == 1)
            {
                _writer.WriteLine("Specify shape!");
                return;
            }

            var containableShape = arguments[1];

            if (ShapeMappings.ShapeNameToTypeMap.TryGetValue(containableShape, out ShapeType type))
            {
                var   shapeAttributes = TextProcessingUtils.SplitAttributes(arguments);
                Shape newShape        = _shapeFactory.CreateShape(type, shapeAttributes);
                if (newShape is IContainable)
                {
                    var parsedShape = newShape as IContainable;
                    _shapeContainer.CheckWithin(parsedShape);
                }
                else
                {
                    _writer.WriteLine("Can't use this shape!");
                }
            }
            else
            {
                _writer.WriteLine("Shape not supported!");
            }
        }
Пример #5
0
 private void DrawPanel_MouseDown(object sender, MouseEventArgs e)
 {
     _currentShape = _currentFactory.CreateShape(e.X, e.Y);
     _pen          = new Pen(ColorButt.BackColor, PenWidthBar.Value);
     _startPaint   = true;
     _bitmap_save  = new Bitmap(_map);
     _undo.Push(_bitmap_save);
     _redo.Clear();
 }
Пример #6
0
        public void AddTestCase(EShapeType type)
        {
            IShape exp = _factory.CreateShape(type);

            _storage.Add(exp);

            var act = _storage.GetShapeForIndex(0);

            Assert.AreSame(exp, act);
        }
Пример #7
0
        public IShape CreateShape(string ShapeName, params object[] parameters)
        {
            Console.Write("Proxy create shape start: {0}, shape name {1}, params ", DateTime.Now, ShapeName);
            foreach (var param in parameters)
            {
                Console.Write("{0} ", param.ToString());
            }
            Console.Write("\n");

            IShape toReturn = realFactory.CreateShape(ShapeName, parameters);

            Console.WriteLine("Proxy create shape end: {0}, returns {1}", DateTime.Now, toReturn.ToString());
            return(toReturn);
        }
Пример #8
0
        public IShape CreateShape(string ShapeName, params object[] parameters)
        {
            Console.Write("Start: {0}, Nazwa: {1}, Parametry: ", DateTime.Now, ShapeName);
            foreach (var param in parameters)
            {
                Console.Write("{0} ", param.ToString());
            }
            Console.Write("\n");

            //System.Threading.Thread.Sleep(5000);

            IShape shape = sf.CreateShape(ShapeName, parameters);

            Console.WriteLine("Koniec: {0}, Zwraca: {1}", DateTime.Now, shape.ToString());
            return(shape);
        }
Пример #9
0
        /// <summary>
        /// This function updates the Symbol property with a bitmap generated by using the shape type, size, fillcolor, bordercolor etc.
        /// </summary>
        private void UpdateSymbols()
        {
            var shape = ShapeFactory.CreateShape();

            shape.Width          = shapeSize;
            shape.Height         = shapeSize;
            shape.ColorFillSolid = (fill is SolidBrush) ? ((SolidBrush)fill).Color : Color.Transparent;
            shape.BorderWidth    = outline.Width;
            shape.BorderColor    = outline.Color;
            shape.ShapeType      = Shape;

            Bitmap   bitmap = new Bitmap(shapeSize, shapeSize);
            Graphics g      = Graphics.FromImage(bitmap);

            g.Clear(Color.Transparent);
            shape.Paint(g);
            symbol = bitmap;

            //update LegendSymbol
            Bitmap legendSymbolBitmap = new Bitmap(16, 16);

            g = Graphics.FromImage(legendSymbolBitmap);
            g.Clear(Color.Transparent);
            if (GeometryType == typeof(IPoint))
            {
                g.CompositingMode = CompositingMode.SourceOver;
                g.DrawImage(Symbol, 0, 0, legendSymbolBitmap.Width, legendSymbolBitmap.Height);
            }
            else if ((GeometryType == typeof(IPolygon)) || (GeometryType == typeof(IMultiPolygon)))
            {
                g.FillRectangle(Fill, 2, 3, 12, 10);
                g.DrawRectangle(Outline, 2, 3, 12, 10);
            }
            else if ((GeometryType == typeof(ILineString)) || (GeometryType == typeof(IMultiLineString)))
            {
                g.DrawLine(Outline, 2, 8, 14, 8);
                g.DrawLine(Line, 2, 8, 14, 8);
            }
            else
            {
                g.FillRectangle(Fill, 2, 3, 12, 10);
                g.DrawRectangle(Outline, 2, 3, 12, 10);
            }

            legendSymbol = legendSymbolBitmap;
            customSymbol = false;
        }
Пример #10
0
        public PictureDraft CreateDraft(TextReader inputData)
        {
            PictureDraft draft = new PictureDraft();
            string       line;

            while ((line = inputData.ReadLine()) != null && line != "exit")
            {
                try
                {
                    draft.AddShape(_factory.CreateShape(line));
                }
                catch (Exception e)
                {
                    Console.WriteLine($"{e.Message}");
                }
            }
            return(draft);
        }
        private IList <Shape> ParseTagsToObjects(IList <string> tags)
        {
            IList <Shape> parsedShapes = new List <Shape>();

            foreach (var tag in tags)
            {
                IList <string> tagArguments = TextProcessingUtils.SplitTokens(tag);
                IDictionary <string, string> shapeAttributes = TextProcessingUtils.SplitAttributes(tagArguments);

                if (ShapeMappings.TagToShapeTypeMap.TryGetValue(tagArguments[0], out ShapeType type))
                {
                    Shape parsed = _shapeFactory.CreateShape(type, shapeAttributes);
                    parsedShapes.Add(parsed);
                }
            }

            return(parsedShapes);
        }
Пример #12
0
        public PictureDraft CreateDraft(List <string> shapeDescriptions)
        {
            var shapes = new List <BaseShape>();

            foreach (string shapeDescription in shapeDescriptions)
            {
                try
                {
                    BaseShape shape = _shapeFactory.CreateShape(shapeDescription);
                    shapes.Add(shape);
                }
                catch (ApplicationException)
                {
                    Console.WriteLine($"Incorrect shape decription: {shapeDescription}");
                }
            }

            return(new PictureDraft(shapes));
        }
Пример #13
0
 public IShape CreateShape(string ShapeName, params object[] parameters)
 {
     Time();
     return(sf.CreateShape(ShapeName, parameters));
 }
Пример #14
0
 public IShape CreateShape(string ShapeName, params object[] parameters)
 {
     AssertTime();
     return(realFactory.CreateShape(ShapeName, parameters));
 }
Пример #15
0
        public void OnPost()
        {
            var dimensions = DimensionKeys.ToDictionary(k => k, k => double.Parse(Request.Form[k]));

            Area = _shapeFactory.CreateShape(SelectedShapeKey, dimensions).Area();
        }