Exemple #1
0
 public static IConnection Connect(this RadDiagram diagram, IShape a, IShape b, string name = null)
 {
     var c = diagram.AddConnection(a, b);
     if (!string.IsNullOrEmpty(name))
         c.Name = name;
     return c;
 }
Exemple #2
0
 public SpatialArgs(SpatialOperation operation, IShape shape)
 {
     if (operation == null || shape == null)
         throw new ArgumentException("operation and shape are required");
     this.Operation = operation;
     this.Shape = shape;
 }
Exemple #3
0
        private static void Main()
        {
            var shapes = new IShape[]
            {
                new Rectangle(1.5, 2),
                new Rhombus(4, 5),
                new Circle(30),
                new Circle(1),
                new Circle(2),
                new Rhombus(2, 3),
                new Rectangle(1.1, 1),
            };

            shapes = shapes.ToList().OrderByDescending(a => a.GetType().Name).ToArray(); // this is optional

            var longestTypePad = shapes.Max(a => a.GetType().Name).Length + 2;
            var longestShapePad = shapes.Max(a => a.ToString()).Length + 2;

            foreach (var shape in shapes)
            {
                Console.WriteLine("{0} -> {1} Area: {2,-8:F2} Perimeter: {3:F2}",
                    shape.GetType().Name.PadRight(longestTypePad),
                    shape.ToString().PadRight(longestShapePad),
                    shape.CalculateArea(),
                    shape.CalculatePerimeter());
            }
        }
 public AbstractPrefixTreeFilter(IShape queryShape, string fieldName, SpatialPrefixTree grid, int detailLevel)
 {
     this.queryShape = queryShape;
     this.fieldName = fieldName;
     this.grid = grid;
     this.detailLevel = detailLevel;
 }
 public void Add(IShape item)
 {
     if (!base.List.Contains(item))
     {
         base.List.Add(item);
     }
 }
 public UpdateEditorContext(IShape model, IContent content, IUpdateModel updater, string groupInfoId, IShapeFactory shapeFactory, ShapeTable shapeTable, string path)
     : base(model, content, groupInfoId, shapeFactory) {
     
     ShapeTable = shapeTable;
     Updater = updater;
     Path = path;
 }
 protected BuildShapeContext(IShape shape, IContent content, string groupId, IShapeFactory shapeFactory) {
     Shape = shape;
     ContentItem = content.ContentItem;
     New = shapeFactory;
     GroupId = groupId;
     FindPlacement = (partType, differentiator, defaultLocation) => new PlacementInfo {Location = defaultLocation, Source = String.Empty};
 }
Exemple #8
0
 void Subject_ChangedForm(IShape subject, ChangeFormState state)
 {
     if (isAttracted || dragged != subject || !state.HasFlag(ChangeFormState.Coords)) return;
     using (StartFinishAction.Create(() => isAttracted = true, () => isAttracted = false))
     {
         RectangleF rect = subject.Rectangle;
         PointF center = subject.GetCenter(), minDist = new PointF(10, 10), dist = new PointF();
         guidlines = subject.GetCenter();
         hit = 0;
         bool lHit = false;
         foreach (var guide in guides.Where(s => s != subject).Select(s => s.GetCenter()))
         {
             if ((dist.X = Math.Abs(center.X - guide.X)) < minDist.X)
             {
                 minDist.X = dist.X;
                 guidlines.X = guide.X;
                 hit |= 1;
             }
             if ((dist.Y = Math.Abs(center.Y - guide.Y)) < minDist.Y)
             {
                 minDist.Y = dist.Y;
                 guidlines.Y = guide.Y;
                 hit |= 2;
             }
             if (hit == 3) break;
             //if (hit = Math.Abs(rect.Left - guide.X) <= 10)
             //    subject.Left = guide.X;
             //if (hit |= Math.Abs(rect.Top - guide.Y) <= 10)
             //    subject.Top = guide.Y;
             //if (hit) break;
         }
         subject.ToCenterPoint(guidlines);
     }
 }
 public void Add(IShape shape)
 {
     if (shape != null)
     {
         _shapeList.Add(shape);
     }
 }
 public void Remove(IShape shape)
 {
     if (_shapeList.Contains(shape))
     {
         _shapeList.Remove(shape);
     }
 }
        public static Vector2 collide(IShape a, IShape b)
        {
            if (a is RectangleShape && b is RectangleShape)
            {
                return intersectRectangles((RectangleShape)a, (RectangleShape)b);
            }

            if (a is Circle && b is RectangleShape)
            {
                if (b is Line) return -circleLineDetect((Line)b, (Circle)a);
                return intersectCircleRectangle((Circle) a, (RectangleShape) b);
            }

            if (a is RectangleShape && b is Circle)
            {
                if (a is Line) return circleLineDetect((Line)a, (Circle)b);
                return -intersectCircleRectangle((Circle) b, (RectangleShape) a);
            }

            if (a is Circle && b is Circle)
            {
                return intersectCircles((Circle)a, (Circle)b);
            }

            return Vector2.Zero;
        }
Exemple #12
0
        private static PlacementInfo FindPlacementImpl(ShapeTable shapeTable, IShape shape, string differentiator, string displayType)
        {
            ShapeDescriptor descriptor;
            var shapeType = shape.Metadata.Type;

            if (shapeTable.Descriptors.TryGetValue(shapeType, out descriptor))
            {
                var placementContext = new ShapePlacementContext
                {
                    Shape = shape,
                    DisplayType = displayType,
                    Differentiator = differentiator
                };

                var placement = descriptor.Placement(placementContext);
                if (placement != null)
                {
                    placement.Source = placementContext.Source;
                    return placement;
                }
            }

            return null;

        }
 public StaticPhysicalEntity(IShape shape, float weight = 1, bool inelasticCollision = false, bool elasticCollision = false)
 {
     Shape = shape;
     InelasticCollision = inelasticCollision;
     ElasticCollision = elasticCollision;
     Weight = weight;
 }
 public IntersectsPrefixTreeFilter(IShape queryShape, string fieldName, 
                                   SpatialPrefixTree grid, int detailLevel,
                                   int prefixGridScanLevel, bool hasIndexedLeaves)
     : base(queryShape, fieldName, grid, detailLevel, prefixGridScanLevel)
 {
     this.hasIndexedLeaves = hasIndexedLeaves;
 }
Exemple #15
0
        /// <summary>
        /// Creates a new primitive line object.
        /// </summary>
        public PrimitiveLine(ICollidable obj = null)
        {
            // create pixels
            pixel = new Texture2D(G.Game.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            var pixels = new Color[1];
            pixels[0] = Color.White;
            pixel.SetData(pixels);

            Colour = Color.White;
            Position = new Vector2(0, 0);
            Depth = 0;

            vectors = new ArrayList();

            if (obj != null)
            {
                switch (obj.Shape.Type)
                {
                    case ShapeType.Circle:
                        CreateCircle((Circle) obj.Shape);
                        break;
                    case ShapeType.Rectangle:
                        CreateRectangle((Rectangle) obj.Shape);
                        break;
                }
                shape = obj.Shape;
                this.obj = obj;
            }
        }
 public void Draw(IShape shape)
 {
     if (shape is Rectangle) { DrawRectangle(); }
     else if (shape is Circle) { DrawCircle(); }
     // If we want to introduce new shape(s),
     // we have to MODIFY this entity right HERE...
 }
        public bool MouseDown(PointerArgs e)
        {
            this.areCtrlShiftDown = (Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift &&
                                    (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control;

            if (this.areCtrlShiftDown)
            {
                RadDiagramShape topShape = this.HitService.GetTopItemNearPoint(e.Point, 0) as RadDiagramShape;
                if (topShape != null)
                {
                    RadDiagramConnector connector = new RadDiagramConnector() { }; 
                    connector.Name = "NewConnector" + connector.GetHashCode().ToString();

                    double xRatio = (e.Point.X - topShape.Bounds.X) / topShape.Width;
                    double yRatio = (e.Point.Y - topShape.Bounds.Y) / topShape.Height;

                    connector.Offset = new Point(xRatio, yRatio);
                    topShape.Connectors.Add(connector);

                    this.lastUsedShape = topShape;
                    return true;
                }
            }
            return false;
        }
 protected BuildShapeContext(IShape shape, string groupId, IShapeFactory shapeFactory, IShape layout)
 {
     Shape = shape;
     ShapeFactory = shapeFactory;
     GroupId = groupId;
     Layout = layout;
     FindPlacement = FindDefaultPlacement;
 }
Exemple #19
0
 public ShapeSprite(Game game, IBoard board, Score score, int size)
     : base(game)
 {
     this.game = game;
     this.score = score;
     this.size = size;
     shape = board.Shape;
 }
Exemple #20
0
 void Subject_ShapeDrawed(IShape subject, Graphics gr, Size size)
 {
     if (hit == 0 || dragged != subject) return;
     if ((hit & 1) != 0)
         gr.DrawLine(Pens.DeepSkyBlue, guidlines.X, -size.Height, guidlines.X, size.Height);
     if ((hit & 2) != 0)
         gr.DrawLine(Pens.DeepSkyBlue, -size.Width, guidlines.Y, size.Width, guidlines.Y);
 }
Exemple #21
0
 public Ground(int x, int y, int w, int h)
 {
     shape = new Bottom(_y);
     //<33333
     X = x;
     Y = y;
     W = w;
     H = h;
 }
    public AddMultiPointShapeCommand(IController controller, IShape shape)
      : base(controller) {
      if (shape == null)
        throw new ArgumentNullException("The shape is 'null' and cannot be inserted.");
      this.Text = "Add " + shape.EntityName;


      this.shape = shape;
    }
 protected ModelShapeContext(object model, IShape shape, String displayType, IShapeFactory shapeFactory, ModelShapeContext parentContext)
 {
     Model = model;
     Shape = shape;
     New = shapeFactory;
     FindPlacement = (partType, differentiator, defaultLocation) => new PlacementInfo {Location = defaultLocation, Source = String.Empty};
     ParentContext = parentContext;
     DisplayType = displayType;
 }
Exemple #24
0
 public CanvasCore()
 {
     mSelects = new List<IShape>();
     mNormals = new List<IShape>();
     mPull = null;
     mMouseDown = new Point2I();
     mRectShape = null;
     mSideBar = null;
     mObject = null;
 }
Exemple #25
0
 protected ShapeDto(IShape shape,Func<double,double> conversionFunction)
 {
     Area        = ConvertToDto(ConvertToDto(shape.Area, conversionFunction),conversionFunction);
     Perimeter   = ConvertToDto(shape.Perimeter, conversionFunction);
     Center      = shape.Center;
     Min         = shape.Bounds.Min;
     Max         = shape.Bounds.Max;
     Width       = ConvertToDto(shape.Bounds.Width,conversionFunction);
     Height      = ConvertToDto(shape.Bounds.Height, conversionFunction);
 }
Exemple #26
0
        public BaseModelBody(PhysicsState state, IShape shape, MassInfo massInfo, Coefficients coefficients, Lifespan lifetime, Guid modelId)
            : base(state, shape, massInfo, coefficients, lifetime)
        {
            if (modelId == Guid.Empty)
            {
                throw new ArgumentException("'guid' cannot be empty!");
            }

            ModelId = modelId;
        }
Exemple #27
0
        public IShape Cover(IShape shape)
        {
            CircleShape circle2 = (CircleShape)shape;
            float diffx = center.X - circle2.center.X;
            float diffy = center.Y - circle2.center.Y;
            float dist = (float)Math.Sqrt(diffx * diffx + diffy * diffy);
            float m = (circle2.radius - radius) / 2 / dist + 0.5f;

            return new CircleShape((circle2.center.X - center.X) * m + center.X, (circle2.center.Y - center.Y) * m + center.Y, (dist + radius + circle2.radius) / 2);
        }
        public static Rectangle GetFor(IShape shape)
        {
            var start = shape.Start;
             var end = shape.End;

             var topLeft = new Point(Math.Min(start.X, end.X), Math.Min(end.Y, start.Y));
             int width = Math.Abs(end.X - start.X);
             int height = Math.Abs(end.Y - start.Y);

             return new Rectangle(topLeft, new Size(width, height));
        }
 public static void Hide()
 {
     if(currentShape == null)
         return;
     diagramControl.Controller.Enabled = true;
     diagramControl.Focus();
     Editor.Visible = false;
     (currentShape as SimpleShapeBase).Text = Editor.Text;
     diagramControl.Controller.UnsuspendAllTools();
     currentShape = null;
 }
 public void Draw(IShape shape)
 {
     if (shape is Circle)
     {
         this.DrawCircle(shape as Circle);
     }
     else if (shape is Rectangle)
     {
         this.DrawRectangle(shape as Rectangle);
     }
 }
Exemple #31
0
 public BlueBorder(IShape decorated) : base(decorated)
 {
 }
Exemple #32
0
 public void Draw(IShape shape)
 {
     shape.Draw(this);
 }
Exemple #33
0
 public UserObject(int aHealth, IShape aShape)
 {
     this.health = aHealth;
     this.shape  = aShape;
 }
Exemple #34
0
 public static string ShapeDetails(IShape shape)
 {
     return($"area {shape.Area}, {shape.Sides}");
 }
Exemple #35
0
 public void DrawShape(IShape shape)
 {
     this.shapes.First(s => s.IsMatch(shape)).Draw(shape);
 }
Exemple #36
0
 public void M1(IShape s)
 {
 }
Exemple #37
0
        private PointF UpdateLocation(IShape shape, PointF currentLocation)
        {
            PointF newLocation = currentLocation;

            switch (_hitPosition)
            {
            case HitPositions.TopLeft:
            {
                newLocation = currentLocation;
                break;
            }

            case HitPositions.Top:
            {
                newLocation.X = shape.Location.X;
                newLocation.Y = currentLocation.Y;
                break;
            }

            case HitPositions.TopRight:
            {
                newLocation.X = shape.Location.X;
                newLocation.Y = currentLocation.Y;
                break;
            }

            case HitPositions.Right:
            {
                newLocation.X = shape.Location.X;
                newLocation.Y = shape.Location.Y;
                break;
            }

            case HitPositions.BottomRight:
            {
                newLocation.X = shape.Location.X;
                newLocation.Y = shape.Location.Y;
                break;
            }

            case HitPositions.Bottom:
            {
                newLocation.X = shape.Location.X;
                newLocation.Y = shape.Location.Y;
                break;
            }

            case HitPositions.BottomLeft:
            {
                newLocation.X = currentLocation.X;
                newLocation.Y = shape.Location.Y;
                break;
            }

            case HitPositions.Left:
            {
                newLocation.X = currentLocation.X;
                newLocation.Y = shape.Location.Y;
                break;
            }
            }

            return(newLocation);
        }
Exemple #38
0
 public void Draw(IShape shape)
 {
     this.renderer.Render(this.drawingContext, shape);
 }
Exemple #39
0
 public int IndexOf(IShape graphPath)
 {
     return(base.List.IndexOf(graphPath));
 }
Exemple #40
0
 /** Subclasses may override to transform or remove a shape for indexing */
 protected virtual IShape convertShapeFromGetDocuments(IShape shape)
 {
     return(shape);
 }
 public ContentShapeResult ContentShape(IShape shape)
 {
     return(ContentShapeImplementation(shape.Metadata.Type, ctx => shape).Location("Content"));
 }
Exemple #42
0
        protected virtual void adoc(String id, String shapeStr)
        {
            IShape shape = shapeStr == null ? null : ctx.ReadShapeFromWkt(shapeStr);

            AddDocument(newDoc(id, shape));
        }
Exemple #43
0
 /// <summary>
 /// Return true if given line intersects this shape.
 /// </summary>
 public static bool DoesIntersects(this IShape shape, LineSegment line)
 {
     return(shape
            .GetLines()
            .Any(shapeLine => shapeLine.FindIntersection(line) != null));
 }
Exemple #44
0
        private SizeF UpdateSize(IShape shape, PointF currentLocation)
        {
            float offsetSizeX = shape.Dimension.Width;
            float offsetSizeY = shape.Dimension.Height;

            switch (_hitPosition)
            {
            case HitPositions.TopLeft:
            {
                if (currentLocation.X < shape.Location.X)
                {
                    offsetSizeX = currentLocation.X - shape.Location.X;
                }
                else
                {
                    offsetSizeX = -(shape.Location.X - currentLocation.X);
                }

                if (currentLocation.Y < shape.Location.Y)
                {
                    offsetSizeY = currentLocation.Y - shape.Location.Y;
                }
                else
                {
                    offsetSizeY = -(shape.Location.Y - currentLocation.Y);
                }

                Ghost.MirrorPoint = new PointF(Ghost.Location.X + Ghost.Dimension.Width, Ghost.Location.Y + Ghost.Dimension.Height);

                break;
            }

            case HitPositions.Top:
            {
                offsetSizeX = 0;

                if (currentLocation.Y < shape.Location.Y)
                {
                    offsetSizeY = currentLocation.Y - shape.Location.Y;
                }
                else
                {
                    offsetSizeY = -(shape.Location.Y - currentLocation.Y);
                }

                Ghost.MirrorPoint = new PointF(Ghost.Location.X, Ghost.Location.Y + Ghost.Dimension.Height);

                break;
            }

            case HitPositions.TopRight:
            {
                if (currentLocation.X > shape.Location.X + shape.Dimension.Width)
                {
                    offsetSizeX = -(currentLocation.X - shape.Location.X - shape.Dimension.Width);
                }
                else
                {
                    offsetSizeX = shape.Location.X + shape.Dimension.Width - currentLocation.X;
                }

                if (currentLocation.Y < shape.Location.Y)
                {
                    offsetSizeY = currentLocation.Y - shape.Location.Y;
                }
                else
                {
                    offsetSizeY = -(shape.Location.Y - currentLocation.Y);
                }

                Ghost.MirrorPoint = new PointF(Ghost.Location.X, Ghost.Location.Y + Ghost.Dimension.Height);

                break;
            }

            case HitPositions.Right:
            {
                if (currentLocation.X > shape.Location.X + shape.Dimension.Width)
                {
                    offsetSizeX = -(currentLocation.X - shape.Location.X - shape.Dimension.Width);
                }
                else
                {
                    offsetSizeX = shape.Location.X + shape.Dimension.Width - currentLocation.X;
                }

                offsetSizeY = 0;

                Ghost.MirrorPoint = new PointF(Ghost.Location.X, Ghost.Center.Y);

                break;
            }

            case HitPositions.BottomRight:
            {
                if (currentLocation.X > shape.Location.X + shape.Dimension.Width)
                {
                    offsetSizeX = -(currentLocation.X - shape.Location.X - shape.Dimension.Width);
                }
                else
                {
                    offsetSizeX = shape.Location.X + shape.Dimension.Width - currentLocation.X;
                }

                if (currentLocation.Y < shape.Location.Y - shape.Dimension.Height)
                {
                    offsetSizeY = -(currentLocation.Y - shape.Location.Y - shape.Dimension.Height);
                }
                else
                {
                    offsetSizeY = shape.Location.Y + shape.Dimension.Height - currentLocation.Y;
                }

                Ghost.MirrorPoint = currentLocation;

                break;
            }

            case HitPositions.Bottom:
            {
                offsetSizeX = 0;

                if (currentLocation.Y < shape.Location.Y - shape.Dimension.Height)
                {
                    offsetSizeY = -(currentLocation.Y - shape.Location.Y - shape.Dimension.Height);
                }
                else
                {
                    offsetSizeY = shape.Location.Y + shape.Dimension.Height - currentLocation.Y;
                }

                Ghost.MirrorPoint = new PointF(Ghost.Location.X, Ghost.Location.Y);

                break;
            }

            case HitPositions.BottomLeft:
            {
                if (currentLocation.X < shape.Location.X)
                {
                    offsetSizeX = currentLocation.X - shape.Location.X;
                }
                else
                {
                    offsetSizeX = -(shape.Location.X - currentLocation.X);
                }

                if (currentLocation.Y < shape.Location.Y - shape.Dimension.Height)
                {
                    offsetSizeY = -(currentLocation.Y - shape.Location.Y - shape.Dimension.Height);
                }
                else
                {
                    offsetSizeY = shape.Location.Y + shape.Dimension.Height - currentLocation.Y;
                }

                Ghost.MirrorPoint = new PointF(Ghost.Location.X + Ghost.Dimension.Width, Ghost.Location.Y);

                break;
            }

            case HitPositions.Left:
            {
                if (currentLocation.X < shape.Location.X)
                {
                    offsetSizeX = currentLocation.X - shape.Location.X;
                }
                else
                {
                    offsetSizeX = -(shape.Location.X - currentLocation.X);
                }

                offsetSizeY = 0;

                Ghost.MirrorPoint = new PointF(Ghost.Location.X + Ghost.Dimension.Width, Ghost.Center.Y);

                break;
            }
            }

            return(new SizeF(shape.Dimension.Width - offsetSizeX, shape.Dimension.Height - offsetSizeY));
        }
Exemple #45
0
        private readonly IShape queryShape;            //the right hand side (constant)

        /// <summary>
        ///
        /// </summary>
        /// <param name="shapeValuesource">
        /// Must yield <see cref="IShape"/> instances from it's ObjectVal(doc). If null
        /// then the result is false. This is the left-hand (indexed) side.
        /// </param>
        /// <param name="op">the predicate</param>
        /// <param name="queryShape">The shape on the right-hand (query) side.</param>
        public ShapePredicateValueSource(ValueSource shapeValuesource, SpatialOperation op, IShape queryShape)
        {
            this.shapeValuesource = shapeValuesource;
            this.op         = op;
            this.queryShape = queryShape;
        }
Exemple #46
0
        /// <summary>
        /// this is used for running the program
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btnrun_Click(object sender, EventArgs e)
        {
            Graphics g = pnloutput.CreateGraphics();

            string command = txtinput.Text.ToLower();

            string[] commandline = command.Split(new String[] { "\n" },
                                                 StringSplitOptions.RemoveEmptyEntries);

            for (int k = 0; k < commandline.Length; k++)
            {
                string[] cmd = commandline[k].Split(' ');
                if (cmd[0].Equals("moveto") == true)
                {
                    pnloutput.Refresh();
                    string[] param = cmd[1].Split(',');
                    if (param.Length != 2)
                    {
                        MessageBox.Show("Incorrect Parameter");
                    }
                    else
                    {
                        Int32.TryParse(param[0], out x);
                        Int32.TryParse(param[1], out y);
                        moveTo(x, y);
                    }
                }
                else if (cmd[0].Equals("radius") == true)
                {
                    int r;
                    if (cmd[1].Equals("=") == true)
                    {
                        Int32.TryParse(cmd[2], out radius);
                    }
                    else if (cmd[1].Equals("+") == true)
                    {
                        Int32.TryParse(cmd[2], out r);
                        radius = radius + r;
                    }
                    else if (cmd[1].Equals("-") == true)
                    {
                        for (int rc = 0; rc < repeatval; rc++)
                        {
                            Int32.TryParse(cmd[2], out r);
                            radius = radius - r;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Syntax Error");
                    }
                }
                else if (cmd[0].Equals("width") == true)
                {
                    int w;
                    if (cmd[1].Equals("=") == true)
                    {
                        Int32.TryParse(cmd[2], out width);
                    }
                    else if (cmd[1].Equals("+") == true)
                    {
                        Int32.TryParse(cmd[2], out w);
                        width = width + w;
                    }
                    else if (cmd[1].Equals("-") == true)
                    {
                        for (int rc = 0; rc < repeatval; rc++)
                        {
                            Int32.TryParse(cmd[2], out w);
                            width = width - w;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Syntax Error");
                    }
                }
                else if (cmd[0].Equals("height") == true)
                {
                    int h;
                    if (cmd[1].Equals("=") == true)
                    {
                        Int32.TryParse(cmd[2], out height);
                    }
                    else if (cmd[1].Equals("+") == true)
                    {
                        Int32.TryParse(cmd[2], out h);
                        height = height + h;
                    }
                    else if (cmd[1].Equals("-") == true)
                    {
                        for (int rc = 0; rc < repeatval; rc++)
                        {
                            Int32.TryParse(cmd[2], out h);
                            height = height - h;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Syntax Error");
                    }
                }
                else if (cmd[0].Equals("drawto") == true)
                {
                    string[] param = cmd[1].Split(',');
                    int      x = 0, y = 0;
                    if (param.Length != 2)
                    {
                        MessageBox.Show("Incorrect Parameter");
                    }
                    else
                    {
                        Int32.TryParse(param[0], out x);
                        Int32.TryParse(param[1], out y);
                        drawTo(x, y);
                    }
                }
                else if (cmd[0].Equals("drawline") == true)
                {
                    string[] param = cmd[1].Split(',');
                    int      toX = 0, toY = 0;
                    if (param.Length != 2)
                    {
                        MessageBox.Show("Incorrect Parameter");
                    }
                    else
                    {
                        Int32.TryParse(param[0], out toX);
                        Int32.TryParse(param[1], out toY);
                        IShape line = factory.getShape("line");
                        line.set(x, y, toX, toY);
                        line.draw(g);
                    }
                }
                else if (cmd[0].Equals("circle") == true)
                {
                    if (cmd.Length != 2)
                    {
                        MessageBox.Show("Incorrect Parameter");
                    }
                    else
                    {
                        if (cmd[1].Equals("radius") == true)
                        {
                            IShape circle = factory.getShape("circle");
                            Circle c      = new Circle();
                            c.set(x, y, radius);
                            c.draw(g);
                        }
                        else
                        {
                            Int32.TryParse(cmd[1], out radius);
                            IShape circle = factory.getShape("circle");
                            Circle c      = new Circle();
                            c.set(x, y, radius);
                            c.draw(g);
                        }
                    }
                }
                else if (cmd[0].Equals("rectangle") == true)
                {
                    if (cmd.Length < 2)
                    {
                        MessageBox.Show("Invalid Parameter ");
                    }
                    else
                    {
                        string[] param = cmd[1].Split(',');
                        if (param.Length < 2)
                        {
                            MessageBox.Show("Invalid Parameter ");
                        }
                        else
                        {
                            Int32.TryParse(param[0], out width);
                            Int32.TryParse(param[1], out height);
                            IShape    circle = factory.getShape("rectangle");
                            Rectangle r      = new Rectangle();
                            r.set(x, y, width, height);
                            r.draw(g);
                        }
                    }
                }
                else if (cmd[0].Equals("polygon") == true)
                {
                    if (cmd.Length < 2)
                    {
                        MessageBox.Show("Invalid Parameter ");
                    }
                    else
                    {
                        string[] param = cmd[1].Split(',');
                        if (param.Length < 2)
                        {
                            MessageBox.Show("Invalid Parameter ");
                        }
                        else
                        {
                            Int32.TryParse(param[0], out width);
                            Int32.TryParse(param[1], out height);
                            IShape  circle = factory.getShape("polygon");
                            Polygon p      = new Polygon();
                            p.set(x, y, width, height);
                            p.draw(g);
                        }
                    }
                }
                else if (cmd[0].Equals("hexagon") == true)
                {
                    if (cmd.Length < 2)
                    {
                        MessageBox.Show("Invalid Parameter ");
                    }
                    else
                    {
                        string[] param = cmd[1].Split(',');
                        if (param.Length < 2)
                        {
                            MessageBox.Show("Invalid Parameter ");
                        }
                        else
                        {
                            Int32.TryParse(param[0], out width);
                            Int32.TryParse(param[1], out height);
                            IShape           circle = factory.getShape("hexagon");
                            IrregularHexagon i      = new IrregularHexagon();
                            i.set(x, y, width, height);
                            i.draw(g);
                        }
                    }
                }
                else if (cmd[0].Equals("3drectangle") == true)
                {
                    if (cmd.Length < 2)
                    {
                        MessageBox.Show("Invalid Parameter ");
                    }
                    else
                    {
                        string[] param = cmd[1].Split(',');
                        if (param.Length < 2)
                        {
                            MessageBox.Show("Invalid Parameter ");
                        }
                        else
                        {
                            Int32.TryParse(param[0], out width);
                            Int32.TryParse(param[1], out height);
                            IShape       circle = factory.getShape("3drectangle");
                            _3DRectangle r      = new _3DRectangle();
                            r.set(x, y, width, height);
                            r.draw(g);
                        }
                    }
                }
                else if (cmd[0].Equals("triangle") == true)
                {
                    string[] param = cmd[1].Split(',');
                    if (param.Length != 2)
                    {
                        MessageBox.Show("Incorrect Parameter");
                    }
                    else
                    {
                        Int32.TryParse(param[0], out width);
                        Int32.TryParse(param[1], out height);
                        IShape   circle = factory.getShape("triangle");
                        Triangle r      = new Triangle();
                        r.set(x, y, width, height);
                        r.draw(g);
                    }
                }
                else if (cmd[0].Equals("repeat") == true)
                {
                    Int32.TryParse(cmd[1], out repeatval);

                    if (cmd[2].Equals("circle") == true)
                    {
                        int r; Int32.TryParse(cmd[4], out r);
                        if (cmd[3].Equals("+") == true)
                        {
                            for (int rc = 0; rc < repeatval; rc++)
                            {
                                radius = radius + r;
                                IShape circle = factory.getShape("circle");
                                Circle c      = new Circle();
                                c.set(x, y, radius);
                                c.draw(g);
                            }
                        }
                        else if (cmd[3].Equals("-") == true)
                        {
                            for (int rc = 0; rc < repeatval; rc++)
                            {
                                radius = radius - r;
                                IShape circle = factory.getShape("circle");
                                Circle c      = new Circle();
                                c.set(x, y, radius);
                                c.draw(g);
                            }
                        }
                    }
                    else if (cmd[2].Equals("rectangle") == true)
                    {
                        int increment;
                        Int32.TryParse(cmd[4], out increment);
                        if (cmd[3].Equals("+") == true)
                        {
                            for (int rc = 0; rc < repeatval; rc++)
                            {
                                width  = width + increment;
                                height = height + increment;
                                IShape    circle = factory.getShape("rectangle");
                                Rectangle rec    = new Rectangle();
                                rec.set(x, y, width, height);
                                rec.draw(g);
                            }
                        }
                        else if (cmd[3].Equals("-") == true)
                        {
                            for (int rc = 0; rc < repeatval; rc++)
                            {
                                width  = width - increment;
                                height = height - increment;
                                IShape    circle = factory.getShape("rectangle");
                                Rectangle rec    = new Rectangle();
                                rec.set(x, y, width, height);
                                rec.draw(g);
                            }
                        }
                    }
                    else if (cmd[2].Equals("polygon") == true)
                    {
                        int increment;
                        Int32.TryParse(cmd[4], out increment);
                        if (cmd[3].Equals("+") == true)
                        {
                            for (int rc = 0; rc < repeatval; rc++)
                            {
                                width  = width + increment;
                                height = height + increment;
                                IShape  circle = factory.getShape("polygon");
                                Polygon pol    = new Polygon();
                                pol.set(x, y, width, height);
                                pol.draw(g);
                            }
                        }
                        else if (cmd[3].Equals("-") == true)
                        {
                            for (int rc = 0; rc < repeatval; rc++)
                            {
                                width  = width - increment;
                                height = height - increment;
                                IShape  circle = factory.getShape("polygon");
                                Polygon pol    = new Polygon();
                                pol.set(x, y, width, height);
                                pol.draw(g);
                            }
                        }
                    }
                    else if (cmd[2].Equals("hexagon") == true)
                    {
                        int increment;
                        Int32.TryParse(cmd[4], out increment);
                        if (cmd[3].Equals("+") == true)
                        {
                            for (int rc = 0; rc < repeatval; rc++)
                            {
                                width  = width + increment;
                                height = height + increment;
                                IShape           circle = factory.getShape("hexagon");
                                IrregularHexagon ih     = new IrregularHexagon();
                                ih.set(x, y, width, height);
                                ih.draw(g);
                            }
                        }
                        else if (cmd[3].Equals("-") == true)
                        {
                            for (int rc = 0; rc < repeatval; rc++)
                            {
                                width  = width - increment;
                                height = height - increment;
                                IShape           circle = factory.getShape("hexagon");
                                IrregularHexagon ih     = new IrregularHexagon();
                                ih.set(x, y, width, height);
                                ih.draw(g);
                            }
                        }
                    }
                    else if (cmd[2].Equals("triangle") == true)
                    {
                        int increment;
                        Int32.TryParse(cmd[4], out increment);
                        if (cmd[3].Equals("+") == true)
                        {
                            for (int rc = 0; rc < repeatval; rc++)
                            {
                                width  = width + increment;
                                height = height + increment;
                                IShape   circle = factory.getShape("triangle");
                                Triangle t      = new Triangle();
                                t.set(x, y, width, height);
                                t.draw(g);
                            }
                        }
                        else if (cmd[3].Equals("-") == true)
                        {
                            for (int rc = 0; rc < repeatval; rc++)
                            {
                                width  = width - increment;
                                height = height - increment;
                                IShape   circle = factory.getShape("triangle");
                                Triangle t      = new Triangle();
                                t.set(x, y, width, height);
                                t.draw(g);
                            }
                        }
                    }
                }
                else if (cmd[0].Equals("loop") == true)
                {
                    loopcheck = true;
                    if (loop == 0)
                    {
                        Int32.TryParse(cmd[1], out counter);
                        kStart = k;
                    }
                }
                else if (cmd[0].Equals("if"))
                {
                    if (cmd[1].Equals("counter") && cmd[2].Equals("=") && cmd[4].Equals("then"))
                    {
                        Int32.TryParse(cmd[3], out ifcounter);
                        if (ifcounter == (loop + 1))
                        {
                            if (cmd[5].Equals("radius"))
                            {
                                if (cmd[6].Equals("="))
                                {
                                    Int32.TryParse(cmd[7], out radius);
                                }
                                else if (cmd[6].Equals("+"))
                                {
                                    int r;
                                    Int32.TryParse(cmd[7], out r);
                                    radius += r;
                                    //MessageBox.Show("you are going right buddy");
                                }
                                else
                                if (cmd[6].Equals("-"))
                                {
                                    int r;
                                    Int32.TryParse(cmd[7], out r);
                                    radius = radius - r;
                                }
                            }
                            else
                            if (cmd[5].Equals("width"))
                            {
                                if (cmd[6].Equals("="))
                                {
                                    Int32.TryParse(cmd[7], out width);
                                    Console.WriteLine(width);
                                }
                                else
                                if (cmd[6].Equals("+"))
                                {
                                    int w; Int32.TryParse(cmd[7], out w);
                                    width = width + w;
                                }
                                else
                                if (cmd[6].Equals("-"))
                                {
                                    int w;
                                    Int32.TryParse(cmd[7], out w);
                                    width = width - w;
                                }
                            }
                            else if (cmd[5].Equals("height"))
                            {
                                if (cmd[6].Equals("="))
                                {
                                    Int32.TryParse(cmd[7], out height);
                                    Console.WriteLine(height);
                                }
                                else
                                if (cmd[6].Equals("+"))
                                {
                                    int h;
                                    Int32.TryParse(cmd[7], out h);
                                    height = height + h;
                                }
                                else if (cmd[6].Equals("-"))
                                {
                                    int h;
                                    Int32.TryParse(cmd[7], out h);
                                    height = height - h;
                                }
                            }
                        }
                    }
                }
                else if (cmd[0].Equals("endif"))
                {
                    if (cmd[1].Equals("radius"))
                    {
                        if (cmd[2].Equals("="))
                        {
                            int endifvar;
                            Int32.TryParse(cmd[3], out endifvar);
                            if (radius == endifvar)
                            {
                                break;
                            }
                        }
                    }
                    else
                    if (cmd[1].Equals("width"))
                    {
                        if (cmd[2].Equals("="))
                        {
                            int endifvar;
                            Int32.TryParse(cmd[3], out endifvar);
                            if (width == endifvar)
                            {
                                break;
                            }
                        }
                    }
                    else
                    if (cmd[1].Equals("height"))
                    {
                        if (cmd[2].Equals("="))
                        {
                            int endifvar;
                            Int32.TryParse(cmd[3], out endifvar);
                            if (height == endifvar)
                            {
                                break;
                            }
                        }
                    }
                }
                else if (cmd[0].Equals("endloop") == true)
                {
                    loopcheck = false;
                    if (counter > 0)
                    {
                        loop++;
                    }
                    if (counter == loop)
                    {
                        counter = 0;
                        loop    = 0;
                    }
                    else
                    {
                        k = kStart;
                    }
                }
                else if (loopcheck == true)
                {
                    MessageBox.Show("invalid Loop Command");
                }
                else if (!cmd[0].Equals(null))
                {
                    int errorLine = k + 1;
                    MessageBox.Show("Invalid command recognised on line " + errorLine, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemple #47
0
 public void M2(IShape s)
 {
 }
Exemple #48
0
        public Subscriber2(Shape shape)
        {
            IShape d = (IShape)shape;

            d.OnDraw += d_OnDraw;
        }
        public override void Execute(GrapeCity.Documents.Excel.Workbook workbook)
        {
            IWorksheet worksheet = workbook.Worksheets[0];

            #region theme
            //create a custom theme.
            Themes themes = new Themes();
            ITheme theme  = themes.Add("testTheme");
            theme.ThemeColorScheme[ThemeColor.Light1].RGB             = Color.FromArgb(255, 255, 255);
            theme.ThemeColorScheme[ThemeColor.Dark1].RGB              = Color.FromArgb(0, 0, 0);
            theme.ThemeColorScheme[ThemeColor.Light2].RGB             = Color.FromArgb(222, 222, 212);
            theme.ThemeColorScheme[ThemeColor.Dark2].RGB              = Color.FromArgb(30, 46, 47);
            theme.ThemeColorScheme[ThemeColor.Accent1].RGB            = Color.FromArgb(233, 117, 90);
            theme.ThemeColorScheme[ThemeColor.Accent2].RGB            = Color.FromArgb(122, 182, 186);
            theme.ThemeColorScheme[ThemeColor.Accent3].RGB            = Color.FromArgb(125, 181, 135);
            theme.ThemeColorScheme[ThemeColor.Accent4].RGB            = Color.FromArgb(230, 191, 94);
            theme.ThemeColorScheme[ThemeColor.Accent5].RGB            = Color.FromArgb(230, 143, 77);
            theme.ThemeColorScheme[ThemeColor.Accent6].RGB            = Color.FromArgb(194, 107, 112);
            theme.ThemeColorScheme[ThemeColor.Hyperlink].RGB          = Color.FromArgb(122, 182, 186);
            theme.ThemeColorScheme[ThemeColor.FollowedHyperlink].RGB  = Color.FromArgb(166, 140, 177);
            theme.ThemeFontScheme.Major[FontLanguageIndex.Latin].Name = "Gill Sans";
            theme.ThemeFontScheme.Minor[FontLanguageIndex.Latin].Name = "Gill Sans";

            //assign the custom theme for workbook.
            workbook.Theme = theme;
            #endregion

            //does not show sheet gridlines.
            worksheet.SheetView.DisplayGridlines = false;

            #region RowHeightColumnWidth
            //set row height and column width.
            worksheet.StandardHeight     = 12.75;
            worksheet.StandardWidth      = 8.43;
            worksheet.Rows[1].RowHeight  = 32.25;
            worksheet.Rows[2].RowHeight  = 13.5;
            worksheet.Rows[3].RowHeight  = 18.75;
            worksheet.Rows[6].RowHeight  = 18.75;
            worksheet.Rows[9].RowHeight  = 18.75;
            worksheet.Rows[12].RowHeight = 18.75;
            worksheet.Rows[15].RowHeight = 19.5;
            worksheet.Rows[16].RowHeight = 13.5;
            worksheet.Rows[33].RowHeight = 19.5;
            worksheet.Rows[34].RowHeight = 13.5;

            worksheet.Columns[0].ColumnWidth = 1.7109375;
            worksheet.Columns[1].ColumnWidth = 12.140625;
            worksheet.Columns[2].ColumnWidth = 12.140625;
            worksheet.Columns[3].ColumnWidth = 12.140625;
            worksheet.Columns[4].ColumnWidth = 11.85546875;
            worksheet.Columns[5].ColumnWidth = 12.7109375;
            worksheet.Columns[6].ColumnWidth = 13.85546875;
            worksheet.Columns[7].ColumnWidth = 44.7109375;
            #endregion

            #region Values
            //initialize worksheet's values.
            worksheet.Name = "BLOOD PRESSURE DATA";
            worksheet.Range["B2"].Value     = "BLOOD PRESSURE TRACKER";
            worksheet.Range["B4:F13"].Value = new object[, ] {
                { "NAME", null, null, null, null },
                { null, null, null, null, null },
                { null, null, null, "Systolic", "Diastolic" },
                { "TARGET BLOOD PRESSURE", null, null, 120, 80 },
                { null, null, null, null, null },
                { null, null, null, "Systolic", "Diastolic" },
                { "CALL PHYSICIAN IF ABOVE", null, null, 140, 90 },
                { null, null, null, null, null },
                { null, null, null, null, null },
                { "PHYSICIAN PHONE NUMBER", null, null, "[Phone Number]", null }
            };

            worksheet.Range["B16"].Value = "CHARTED PROGRESS";
            worksheet.Range["B34"].Value = "DATA ENTRY";
            #endregion

            #region Table
            //initialize table data.
            worksheet.Range["B36:H44"].Value = new object[, ] {
                { "TIME", "DATE", "AM/PM", "SYSTOLIC", "DIASTOLIC", "HEART RATE", "NOTES" },
                { new TimeSpan(10, 00, 00), DateTime.Parse("7/1/2013 12:00:00 AM"), "AM", 129, 99, 72, null },
                { new TimeSpan(18, 00, 00), DateTime.Parse("7/1/2013 12:00:00 AM"), "PM", 133, 80, 75, null },
                { new TimeSpan(10, 30, 00), DateTime.Parse("7/2/2012 12:00:00 AM"), "AM", 142, 86, 70, null },
                { new TimeSpan(19, 00, 00), DateTime.Parse("7/2/2012 12:00:00 AM"), "PM", 141, 84, 68, null },
                { new TimeSpan(09, 00, 00), DateTime.Parse("7/3/2012 12:00:00 AM"), "AM", 137, 84, 70, null },
                { new TimeSpan(18, 30, 00), DateTime.Parse("7/3/2012 12:00:00 AM"), "PM", 139, 83, 72, null },
                { new TimeSpan(10, 00, 00), DateTime.Parse("7/4/2012 12:00:00 AM"), "AM", 140, 85, 78, null },
                { new TimeSpan(18, 00, 00), DateTime.Parse("7/4/2012 12:00:00 AM"), "PM", 138, 85, 69, null },
            };
            ITable table = worksheet.Tables.Add(worksheet.Range["B36:H44"], true);
            table.ShowTotals = true;

            //set total row formulas.
            table.Columns[0].Total.Value       = "Average";
            table.Columns[3].TotalsCalculation = TotalsCalculation.Average;
            table.Columns[4].TotalsCalculation = TotalsCalculation.Average;
            table.Columns[5].TotalsCalculation = TotalsCalculation.Average;
            table.Columns[6].TotalsCalculation = TotalsCalculation.None;

            //config data body range and total range's number format.
            table.Columns[0].DataBodyRange.NumberFormat = "h:mm;@";
            table.Columns[1].DataBodyRange.NumberFormat = "m/d/yyyy";
            table.Columns[3].DataBodyRange.NumberFormat = "0";
            table.Columns[4].DataBodyRange.NumberFormat = "0";
            table.Columns[5].DataBodyRange.NumberFormat = "0";
            table.Columns[3].Total.NumberFormat         = "0";
            table.Columns[4].Total.NumberFormat         = "0";
            table.Columns[5].Total.NumberFormat         = "0";

            //config table range's alignment.
            table.Range.HorizontalAlignment = HorizontalAlignment.Left;
            table.Range.IndentLevel         = 0;
            table.Range.VerticalAlignment   = VerticalAlignment.Center;
            #endregion

            #region TableStyle
            //create a custom table style.
            ITableStyle tablestyle = workbook.TableStyles.Add("testStyle");
            tablestyle.TableStyleElements[TableStyleElementType.WholeTable].Font.ThemeColor   = ThemeColor.Dark1;
            tablestyle.TableStyleElements[TableStyleElementType.WholeTable].Font.TintAndShade = 0.25;
            tablestyle.TableStyleElements[TableStyleElementType.WholeTable].Borders[BordersIndex.EdgeTop].LineStyle             = BorderLineStyle.Thin;
            tablestyle.TableStyleElements[TableStyleElementType.WholeTable].Borders[BordersIndex.EdgeTop].ThemeColor            = ThemeColor.Accent1;
            tablestyle.TableStyleElements[TableStyleElementType.WholeTable].Borders[BordersIndex.EdgeTop].TintAndShade          = 0.4;
            tablestyle.TableStyleElements[TableStyleElementType.WholeTable].Borders[BordersIndex.InsideHorizontal].LineStyle    = BorderLineStyle.Thin;
            tablestyle.TableStyleElements[TableStyleElementType.WholeTable].Borders[BordersIndex.InsideHorizontal].ThemeColor   = ThemeColor.Accent1;
            tablestyle.TableStyleElements[TableStyleElementType.WholeTable].Borders[BordersIndex.InsideHorizontal].TintAndShade = 0.4;
            tablestyle.TableStyleElements[TableStyleElementType.WholeTable].Borders[BordersIndex.EdgeBottom].LineStyle          = BorderLineStyle.Thin;
            tablestyle.TableStyleElements[TableStyleElementType.WholeTable].Borders[BordersIndex.EdgeBottom].ThemeColor         = ThemeColor.Accent1;
            tablestyle.TableStyleElements[TableStyleElementType.WholeTable].Borders[BordersIndex.EdgeBottom].TintAndShade       = 0.4;
            tablestyle.TableStyleElements[TableStyleElementType.WholeTable].Borders[BordersIndex.EdgeLeft].LineStyle            = BorderLineStyle.Thin;
            tablestyle.TableStyleElements[TableStyleElementType.WholeTable].Borders[BordersIndex.EdgeLeft].ThemeColor           = ThemeColor.Accent1;
            tablestyle.TableStyleElements[TableStyleElementType.WholeTable].Borders[BordersIndex.EdgeLeft].TintAndShade         = 0.4;
            tablestyle.TableStyleElements[TableStyleElementType.WholeTable].Borders[BordersIndex.EdgeRight].LineStyle           = BorderLineStyle.Thin;
            tablestyle.TableStyleElements[TableStyleElementType.WholeTable].Borders[BordersIndex.EdgeRight].ThemeColor          = ThemeColor.Accent1;
            tablestyle.TableStyleElements[TableStyleElementType.WholeTable].Borders[BordersIndex.EdgeRight].TintAndShade        = 0.4;

            tablestyle.TableStyleElements[TableStyleElementType.FirstRowStripe].Interior.ThemeColor   = ThemeColor.Accent1;
            tablestyle.TableStyleElements[TableStyleElementType.FirstRowStripe].Interior.TintAndShade = 0.8;

            tablestyle.TableStyleElements[TableStyleElementType.HeaderRow].Font.Bold           = true;
            tablestyle.TableStyleElements[TableStyleElementType.HeaderRow].Font.ThemeColor     = ThemeColor.Dark1;
            tablestyle.TableStyleElements[TableStyleElementType.HeaderRow].Font.TintAndShade   = 0.25;
            tablestyle.TableStyleElements[TableStyleElementType.HeaderRow].Interior.ThemeColor = ThemeColor.Accent1;

            tablestyle.TableStyleElements[TableStyleElementType.TotalRow].Font.Bold         = true;
            tablestyle.TableStyleElements[TableStyleElementType.TotalRow].Font.ThemeColor   = ThemeColor.Dark1;
            tablestyle.TableStyleElements[TableStyleElementType.TotalRow].Font.TintAndShade = 0.25;
            tablestyle.TableStyleElements[TableStyleElementType.TotalRow].Borders[BordersIndex.EdgeTop].LineStyle  = BorderLineStyle.Double;
            tablestyle.TableStyleElements[TableStyleElementType.TotalRow].Borders[BordersIndex.EdgeTop].ThemeColor = ThemeColor.Accent1;

            //assign custom table style for table.
            table.TableStyle = workbook.TableStyles["testStyle"];
            #endregion

            #region Style
            //assign built-in styles for ranges.
            worksheet.Range["B2:H2"].Style = workbook.Styles["Heading 1"];
            worksheet.Range["B4:F4, B7:D7, B10:D10, B13:D13"].Style = workbook.Styles["Heading 2"];
            worksheet.Range["B16:H16, B34:H34"].Style = workbook.Styles["Heading 3"];

            //modify built-in styles.
            IStyle style_Heading1 = workbook.Styles["Heading 1"];
            style_Heading1.HorizontalAlignment = HorizontalAlignment.General;
            style_Heading1.VerticalAlignment   = VerticalAlignment.Center;
            style_Heading1.Font.ThemeFont      = ThemeFont.Major;
            style_Heading1.Font.Size           = 24;
            style_Heading1.Font.Bold           = true;
            style_Heading1.Font.ThemeColor     = ThemeColor.Accent1;
            style_Heading1.Borders[BordersIndex.EdgeBottom].LineStyle  = BorderLineStyle.Thick;
            style_Heading1.Borders[BordersIndex.EdgeBottom].ThemeColor = ThemeColor.Accent1;

            style_Heading1.IncludeAlignment  = true;
            style_Heading1.IncludeFont       = true;
            style_Heading1.IncludeBorder     = true;
            style_Heading1.IncludeNumber     = false;
            style_Heading1.IncludePatterns   = false;
            style_Heading1.IncludeProtection = false;

            IStyle style_Heading2 = workbook.Styles["Heading 2"];
            style_Heading2.HorizontalAlignment = HorizontalAlignment.General;
            style_Heading2.VerticalAlignment   = VerticalAlignment.Bottom;
            style_Heading2.Font.ThemeFont      = ThemeFont.Minor;
            style_Heading2.Font.Size           = 14;
            style_Heading2.Font.ThemeColor     = ThemeColor.Dark1;
            style_Heading2.Font.TintAndShade   = 0.25;
            style_Heading2.Font.Bold           = false;
            style_Heading2.Borders[BordersIndex.EdgeBottom].LineStyle    = BorderLineStyle.Dotted;
            style_Heading2.Borders[BordersIndex.EdgeBottom].ThemeColor   = ThemeColor.Light1;
            style_Heading2.Borders[BordersIndex.EdgeBottom].TintAndShade = -0.5;

            style_Heading2.IncludeAlignment  = true;
            style_Heading2.IncludeFont       = true;
            style_Heading2.IncludeBorder     = true;
            style_Heading2.IncludeNumber     = false;
            style_Heading2.IncludePatterns   = false;
            style_Heading2.IncludeProtection = false;

            IStyle style_Heading3 = workbook.Styles["Heading 3"];
            style_Heading3.HorizontalAlignment = HorizontalAlignment.General;
            style_Heading3.VerticalAlignment   = VerticalAlignment.Center;
            style_Heading3.Font.ThemeFont      = ThemeFont.Minor;
            style_Heading3.Font.Size           = 14;
            style_Heading3.Font.Bold           = true;
            style_Heading3.Font.ThemeColor     = ThemeColor.Dark1;
            style_Heading3.Font.TintAndShade   = 0.25;
            style_Heading3.Borders[BordersIndex.EdgeBottom].LineStyle  = BorderLineStyle.Thick;
            style_Heading3.Borders[BordersIndex.EdgeBottom].ThemeColor = ThemeColor.Accent2;

            style_Heading3.IncludeAlignment  = true;
            style_Heading3.IncludeFont       = true;
            style_Heading3.IncludeBorder     = true;
            style_Heading3.IncludeNumber     = false;
            style_Heading3.IncludePatterns   = false;
            style_Heading3.IncludeProtection = false;

            IStyle style_Normal = workbook.Styles["Normal"];
            style_Normal.NumberFormat        = "General";
            style_Normal.HorizontalAlignment = HorizontalAlignment.General;
            style_Normal.VerticalAlignment   = VerticalAlignment.Center;
            style_Normal.Font.ThemeFont      = ThemeFont.Minor;
            style_Normal.Font.Size           = 10;
            style_Normal.Font.ThemeColor     = ThemeColor.Dark1;
            style_Normal.Font.TintAndShade   = 0.25;

            style_Normal.IncludeAlignment  = true;
            style_Normal.IncludeFont       = true;
            style_Normal.IncludeBorder     = true;
            style_Normal.IncludeNumber     = true;
            style_Normal.IncludePatterns   = true;
            style_Normal.IncludeProtection = true;

            //modify cell styles.
            worksheet.Range["B4"].Borders[BordersIndex.EdgeBottom].LineStyle    = BorderLineStyle.None;
            worksheet.Range["C4:F4"].Borders[BordersIndex.EdgeBottom].LineStyle = BorderLineStyle.Thin;
            IRange range1 = worksheet.Range["E7:F7, E10:F10"];
            range1.Borders[BordersIndex.EdgeBottom].LineStyle    = BorderLineStyle.Dotted;
            range1.Borders[BordersIndex.EdgeBottom].ThemeColor   = ThemeColor.Light1;
            range1.Borders[BordersIndex.EdgeBottom].TintAndShade = -0.5;
            range1.Font.Bold = true;
            IRange range2 = worksheet.Range["E7, E10"];
            range2.Borders[BordersIndex.EdgeRight].LineStyle    = BorderLineStyle.Thin;
            range2.Borders[BordersIndex.EdgeRight].ThemeColor   = ThemeColor.Light1;
            range2.Borders[BordersIndex.EdgeRight].TintAndShade = -0.5;
            #endregion

            #region Chart
            //create a new chart.
            IShape shape = worksheet.Shapes.AddChart(ChartType.ColumnClustered, 8.99984251968504, 268.5, 627.750157480315, 184.5);

            //create series for chart.
            ISeries series_systolic  = shape.Chart.SeriesCollection.NewSeries();
            ISeries series_diatolic  = shape.Chart.SeriesCollection.NewSeries();
            ISeries series_HeartRate = shape.Chart.SeriesCollection.NewSeries();

            //set series formulas.
            series_systolic.Formula = "=SERIES('BLOOD PRESSURE DATA'!$E$36,'BLOOD PRESSURE DATA'!$C$37:$D$44,'BLOOD PRESSURE DATA'!$E$37:$E$44,1)";
            series_diatolic.Formula = "=SERIES('BLOOD PRESSURE DATA'!$F$36,'BLOOD PRESSURE DATA'!$C$37:$D$44,'BLOOD PRESSURE DATA'!$F$37:$F$44,2)";

            //set series plot on secondary axis, and change its chart type.
            series_HeartRate.AxisGroup = AxisGroup.Secondary;
            series_HeartRate.ChartType = ChartType.Line;
            series_HeartRate.Formula   = "=SERIES('BLOOD PRESSURE DATA'!$G$36,,'BLOOD PRESSURE DATA'!$G$37:$G$44,3)";

            //set series fill to gradient fill.
            series_systolic.Format.Fill.TwoColorGradient(GradientStyle.Horizontal, 1);
            series_systolic.Format.Fill.GradientAngle = 270;
            series_systolic.Format.Fill.GradientStops[0].Color.RGB = Color.FromArgb(255, 172, 175);
            series_systolic.Format.Fill.GradientStops[1].Color.RGB = Color.FromArgb(255, 227, 228);
            series_systolic.Format.Fill.GradientStops.Insert(0xFEC6C8, 0.35);
            series_systolic.Format.Line.Color.ObjectThemeColor = ThemeColor.Accent6;

            series_diatolic.Format.Fill.TwoColorGradient(GradientStyle.Horizontal, 1);
            series_diatolic.Format.Fill.GradientAngle = 270;
            series_diatolic.Format.Fill.GradientStops[0].Color.RGB = Color.FromArgb(255, 192, 147);
            series_diatolic.Format.Fill.GradientStops[1].Color.RGB = Color.FromArgb(255, 227, 212);
            series_diatolic.Format.Fill.GradientStops.Insert(0xFFCBA9, 0.35);
            series_diatolic.Format.Line.Color.ObjectThemeColor = ThemeColor.Accent5;

            //set series gap width and overlap.
            shape.Chart.ColumnGroups[0].GapWidth = 150;
            shape.Chart.ColumnGroups[0].Overlap  = 0;

            //set series line style.
            series_HeartRate.Format.Line.BeginArrowheadLength   = ArrowheadLength.Medium;
            series_HeartRate.Format.Line.BeginArrowheadStyle    = ArrowheadStyle.None;
            series_HeartRate.Format.Line.BeginArrowheadWidth    = ArrowheadWidth.Medium;
            series_HeartRate.Format.Line.Color.ObjectThemeColor = ThemeColor.Accent4;
            series_HeartRate.Format.Line.Color.TintAndShade     = 0;
            series_HeartRate.Format.Line.DashStyle          = LineDashStyle.Solid;
            series_HeartRate.Format.Line.EndArrowheadLength = ArrowheadLength.Medium;
            series_HeartRate.Format.Line.EndArrowheadStyle  = ArrowheadStyle.None;
            series_HeartRate.Format.Line.EndArrowheadWidth  = ArrowheadWidth.Medium;
            series_HeartRate.Format.Line.Style  = LineStyle.Single;
            series_HeartRate.Format.Line.Weight = 1.25;

            IAxis primary_axis = shape.Chart.Axes.Item(AxisType.Value, AxisGroup.Primary);
            primary_axis.HasTitle                  = true;
            primary_axis.AxisTitle.Text            = "BLOOD PRESSURE";
            primary_axis.AxisTitle.IncludeInLayout = true;

            IAxis secondary_axis = shape.Chart.Axes.Item(AxisType.Value, AxisGroup.Secondary);
            secondary_axis.HasTitle                  = true;
            secondary_axis.AxisTitle.Text            = "HEART RATE";
            secondary_axis.AxisTitle.IncludeInLayout = true;

            IAxis category_axis = shape.Chart.Axes.Item(AxisType.Category, AxisGroup.Primary);
            category_axis.HasTitle     = true;
            category_axis.CategoryType = CategoryType.CategoryScale;
            category_axis.Format.Line.Color.ColorType = SolidColorType.None;

            shape.Chart.HasTitle = false;
            //set chart font style.
            shape.Chart.ChartArea.Font.Size = 9;
            shape.Chart.ChartArea.Font.Color.ObjectThemeColor = ThemeColor.Dark1;
            shape.Chart.ChartArea.Font.Color.Brightness       = 0.5;
            #endregion


            #region Shape
            IShape shape1 = worksheet.Shapes.AddShape(AutoShapeType.Rectangle, 402, 77.25, 234, 100);
            shape1.Fill.Solid();
            shape1.Fill.Color.ObjectThemeColor = ThemeColor.Accent1;
            shape1.Fill.Color.Brightness       = 0.6;
            //set shape's border to no line.
            shape1.Line.Color.ColorType = SolidColorType.None;

            //set shape rich text.
            ITextRange shape1_p1 = shape1.TextFrame.TextRange.Paragraphs[0];
            shape1_p1.Text = "*";
            shape1_p1.Runs.Add(" Blood pressures may vary dependent on many");
            shape1_p1.Runs.Add(" factors.  Always consult with a physician about what is normal for you.  These numbers may vary slightly.");

            ITextRange shape1_p2 = shape1.TextFrame.TextRange.Paragraphs.Add("");
            ITextRange shape1_p3 = shape1.TextFrame.TextRange.Paragraphs.Add("Info from National Institute of Health:");
            ITextRange shape1_p4 = shape1.TextFrame.TextRange.Paragraphs.Add("http://www.nhlbi.nih.gov/health/health-topics/topics/hbp/");

            shape1.TextFrame.TextRange.Font.Size      = 10;
            shape1.TextFrame.TextRange.Font.ThemeFont = ThemeFont.Minor;
            shape1.TextFrame.TextRange.Font.Color.ObjectThemeColor = ThemeColor.Dark1;
            shape1.TextFrame.TextRange.Font.Color.Brightness       = 0.25;
            shape1_p3.Runs[0].Font.Bold = true;

            IShape shape2 = worksheet.Shapes.AddShape(AutoShapeType.Rectangle, 421.5, 546.75, 198, 50);
            shape2.Fill.Solid();
            shape2.Fill.Color.ObjectThemeColor = ThemeColor.Accent3;
            shape2.Fill.Color.Brightness       = 0.6;
            //set shape's border to no line.
            shape2.Line.Color.ColorType = SolidColorType.None;

            ITextRange shape2_p1 = shape2.TextFrame.TextRange.Paragraphs[0];
            shape2_p1.Text = "NOTE:";
            shape2_p1.Runs.Add(" Any blood pressure readings over the indicated numbers (\"CALL PHYSICIAN IF ABOVE\") will be");
            shape2_p1.Runs.Add(" highlighted.");

            shape2.TextFrame.TextRange.Font.Size      = 10;
            shape2.TextFrame.TextRange.Font.ThemeFont = ThemeFont.Minor;
            shape2.TextFrame.TextRange.Font.Color.ObjectThemeColor = ThemeColor.Dark1;
            shape2.TextFrame.TextRange.Font.Color.Brightness       = 0.25;
            shape2_p1.Runs[0].Font.Bold = true;
            #endregion

            #region DefinedName
            //create defined names for workbook.
            workbook.Names.Add("MaxDiastolic", "='BLOOD PRESSURE DATA'!$F$10");
            workbook.Names.Add("MaxSystolic", "='BLOOD PRESSURE DATA'!$E$10");
            #endregion

            #region ConditionalFormat
            //create conditional format for ranges.
            IFormatCondition condition1 = worksheet.Range["E37:E44"].FormatConditions.Add(FormatConditionType.Expression, formula1: "=E37>MaxSystolic") as IFormatCondition;
            IFormatCondition condition2 = worksheet.Range["F37:F44"].FormatConditions.Add(FormatConditionType.Expression, formula1: "=F37>MaxDiastolic") as IFormatCondition;
            condition1.Interior.Color = Color.Red;
            condition2.Interior.Color = Color.Red;
            #endregion
        }
Exemple #50
0
 /// <summary>
 /// Вычисляет площадь фигуры
 /// </summary>
 /// <param name="shape">Геометрическая фигура</param>
 /// <returns></returns>
 public static double CalculateShapeSquare(IShape shape)
 {
     return(shape.CalcSquare());
 }
 public SetColorCommand(IShape shape, string color)
 {
     _shape = shape;
     _color = color;
 }
        private void generateSlide_Click(object sender, EventArgs e)
        {
            //Creates PowerPoint Presentation
            IPresentation pptxDoc = Presentation.Create();
            //Adds slide to the PowerPoint
            ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank);
            //Adds textbox to the slide
            IShape textboxShape  = slide.AddTextBox(0, 0, 1024, 100);
            IShape textboxShape2 = slide.AddTextBox(0, 101, 1024, 200);


            if (imageUrlOne != "")
            {
                WebClient myWebClient = new WebClient();
                byte[]    bytes       = myWebClient.DownloadData(imageUrlOne);

                Stream pictureStream = new MemoryStream(bytes);

                IPicture picture = slide.Pictures.AddPicture(pictureStream, 50, 301, 150, 150);

                pptxDoc.Save(titleInput.Text + ".pptx");

                pictureStream.Dispose();
            }

            if (imageUrlTwo != "")
            {
                WebClient myWebClient = new WebClient();
                byte[]    bytes       = myWebClient.DownloadData(imageUrlTwo);

                Stream pictureStream = new MemoryStream(bytes);

                IPicture picture = slide.Pictures.AddPicture(pictureStream, 250, 301, 150, 150);

                pptxDoc.Save(titleInput.Text + ".pptx");

                pictureStream.Dispose();
            }

            if (imageUrlThree != "")
            {
                WebClient myWebClient = new WebClient();
                byte[]    bytes       = myWebClient.DownloadData(imageUrlThree);

                Stream pictureStream = new MemoryStream(bytes);

                IPicture picture = slide.Pictures.AddPicture(pictureStream, 450, 301, 150, 150);

                pptxDoc.Save(titleInput.Text + ".pptx");

                pictureStream.Dispose();
            }

            //Adds paragraph to the textbody of text box
            IParagraph title = textboxShape.TextBody.AddParagraph();
            IParagraph body  = textboxShape2.TextBody.AddParagraph();
            //Adds a TextPart to the paragraph
            ITextPart textPart  = title.AddTextPart();
            ITextPart textPart2 = body.AddTextPart();

            //Adds text to the TextPart
            textPart.Text  = titleInput.Text;
            textPart2.Text = bodyText.Text;
            // Formatting
            title.HorizontalAlignment = HorizontalAlignmentType.Center;
            body.HorizontalAlignment  = HorizontalAlignmentType.Center;
            IFont titleFont = title.Font;

            titleFont.Bold     = true;
            titleFont.FontSize = 40;


            //Saves the Presentation
            pptxDoc.Save(titleInput.Text + ".pptx");
            //Closes the Presentation
            pptxDoc.Close();
        }
Exemple #53
0
 public ShapeFacade()
 {
     circle    = new Circle();
     rectangle = new Rectangle();
     square    = new Square();
 }
Exemple #54
0
 public bool Contains(IShape shape)
 {
     return(this._geometric.GetBounds().Contains(shape.Geometric.GetBounds()));
 }
Exemple #55
0
 protected override IPoint RandomPointInEmptyShape(IShape shape)
 {
     return(shape.Center);
 }
Exemple #56
0
 protected virtual void adoc(String id, IShape shape)
 {
     AddDocument(newDoc(id, shape));
 }
Exemple #57
0
 public SpatialArgs(SpatialOperation operation, IShape shape)
 {
     // LUCENENET specific - changed from IllegalArgumentException to ArgumentNullException (.NET convention)
     this.Operation = operation ?? throw new ArgumentNullException(nameof(operation), "operation and shape are required");
     this.Shape     = shape ?? throw new ArgumentNullException(nameof(shape), "operation and shape are required");
 }
Exemple #58
0
            protected override void OnAssertFail(/*AssertionError*/ Exception e, /*Circle*/ IShape shape, IRectangle r, SpatialRelation ic)
            {
                ICircle s = shape as ICircle;
                //Check if the circle's edge appears to coincide with the shape.
                double radius = s.Radius;

                if (radius == 180)
                {
                    throw e;//if this happens, then probably a bug
                }
                if (radius == 0)
                {
                    IPoint p = s.Center;
                    //if touches a side then don't throw
                    if (p.X == r.MinX || p.X == r.MaxX ||
                        p.Y == r.MinY || p.Y == r.MaxY)
                    {
                        return;
                    }
                    throw e;
                }
                double eps = 0.0000001;

                s.Reset(s.Center.X, s.Center.Y, radius - eps);
                SpatialRelation rel1 = s.Relate(r);

                s.Reset(s.Center.X, s.Center.Y, radius + eps);
                SpatialRelation rel2 = s.Relate(r);

                if (rel1 == rel2)
                {
                    throw e;
                }
                s.Reset(s.Center.X, s.Center.Y, radius);//reset
                Console.WriteLine("Seed " + /*getContext().GetRunnerSeedAsString() +*/ ": Hid assertion due to ambiguous edge touch: " + s + " " + r);
            }
        public override Field[] CreateIndexableFields(IShape shape)
        {
            double distErr = SpatialArgs.CalcDistanceFromErrPct(shape, m_distErrPct, m_ctx);

            return(CreateIndexableFields(shape, distErr));
        }
Exemple #60
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FillShapeProcessor{TColor, TPacked}"/> class.
 /// </summary>
 /// <param name="brush">The brush.</param>
 /// <param name="shape">The shape.</param>
 public FillShapeProcessor(IBrush <TColor, TPacked> brush, IShape shape, GraphicsOptions options)
 {
     this.poly      = shape;
     this.fillColor = brush;
     this.options   = options;
 }