Example #1
0
	//-----------------------------------------------------------------------------------------------
	
	public void Add(Figure figure)
	{
		for (int y = 0; y < figure.form.GetLength(0); y++)
			for (int x = 0; x < figure.form.GetLength(1); x++)
				if (figure.form[y, x] && y+figure.position.Y>=0)
					this.cells[y + figure.position.Y, x + figure.position.X] = true;
	}
        public virtual void ExecuteFigureCreationCommand(string[] splitFigString)
        {
            switch (splitFigString[0])
            {
                case "vertex":
                    {
                        Vector3D location = Vector3D.Parse(splitFigString[1]);
                        currentFigure = new Vertex(location);
                        break;
                    }
                case "segment":
                    {
                        Vector3D a = Vector3D.Parse(splitFigString[1]);
                        Vector3D b = Vector3D.Parse(splitFigString[2]);
                        currentFigure = new LineSegment(a, b);
                        break;
                    }
                case "triangle":
                    {
                        Vector3D a = Vector3D.Parse(splitFigString[1]);
                        Vector3D b = Vector3D.Parse(splitFigString[2]);
                        Vector3D c = Vector3D.Parse(splitFigString[3]);
                        currentFigure = new Triangle(a, b, c);
                        break;
                    }
            }

            this.EndCommandExecuted = false;
        }
 static void Main()
 {
     Figure fig = new Figure(3, 2);
     fig = fig.Rotate(fig, 30);
     Console.WriteLine(fig.Width);
     Console.WriteLine(fig.Height);
 }
Example #4
0
 public Move(Step step, Board board)
 {
     _board = board;
     Step = new Step(step);
     oldFrom = _board[(step.FromX << 3) + step.FromY];
     oldTo = _board[(step.ToX << 3) + step.ToY];
 }
Example #5
0
 public SquareItem(Square square, Figure figure, Color color)
 {
     this.innerSquare = square;
     this.SetBackgroundColor(square);
     this.FigureType = figure;
     this.FigureColor = color;
     this.ColoredFigure = ColoredFigureHelper.Create(color, figure);
 }
Example #6
0
File: Queen.cs Project: Artui/Labs
 public void Hit(Figure newFig)
 {
     this.figure.x = newFig.x;
     this.figure.y = newFig.y;
     Console.WriteLine("Figure is hit");
     newFig.changeAbToMove();
     Console.WriteLine("New current koords are x:" + this.figure.x + ", y:" + this.figure.y);
 }
Example #7
0
 /// <summary>
 /// Resets the original setup
 /// </summary>
 public static void Reset()
 {
     hasToGoBackwards = false;
     turnIsRunning = false;
     currentFigure = null;
     currentStep = 0;
     lastStep = 0;
 }
 public Figure Rotate(Figure figure, double angleForRotate)
 {
     double newWidth = Math.Abs(Math.Cos(angleForRotate)) * figure.Width +
         Math.Abs(Math.Sin(angleForRotate)) * figure.Height;
     double newHeight = Math.Abs(Math.Sin(angleForRotate)) * figure.Width +
         Math.Abs(Math.Cos(angleForRotate)) * figure.Height;
     figure = new Figure(newWidth, newHeight);
     return figure;
 }
 static void Main()
 {
     Figure figure = new Figure(1, 2);
     figure.Width = -6;
     Console.WriteLine(figure.Width);
     figure = Figure.GetRotatedFigure(figure, 5);
     Console.WriteLine(figure.Width);
     Console.WriteLine(figure.Height);
 }
        public static Figure GetRotatedSize(Figure figure, double angleToRotateInDegree)
        {
            double angle = angleToRotateInDegree;

            double rotatedWidth = Math.Abs(Math.Cos(angle)) * figure.Width + Math.Abs(Math.Sin(angle)) * figure.Height;
            double rotatedHeight = Math.Abs(Math.Sin(angle)) * figure.Width + Math.Abs(Math.Cos(angle)) * figure.Height;

            return new Figure(rotatedWidth, rotatedHeight);
        }
Example #11
0
 /// <summary>
 /// Return a gamefigure if there is one to send home. otherwise null is returned
 /// </summary>
 /// <param name="figure"></param>
 /// <returns></returns>
 public Figure GetFigureToSendHome(Figure figure)
 {
     if (isBench) return null;
     ArrayList figuresOnField = GetFiguresOnField();
     if (figuresOnField.Count == 0) return null;
     Figure figureToSendHome = (Figure)figuresOnField[0];
     if (FigureCtrl.GetPlayer(figureToSendHome).Color.Equals(FigureCtrl.GetPlayer(figure).Color))
         return null;
     return figureToSendHome;
 }
Example #12
0
        public static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            Figure original = new Figure(2, 5);
            PrintFigureWidthAndHeight(original);

            Figure rotated = Figure.GetRotatedFigure(original, 90);
            PrintFigureWidthAndHeight(rotated);
        }
Example #13
0
 private void Form1_MouseMove(object sender, MouseEventArgs e)
 {
     if (draw)
     {
         g.Clear(Color.White);
         f = flist.Last();
         f.Change(x, y, e.X, e.Y);
         flist.Draw(g);
     }
 }
Example #14
0
    public static Figure RotateFigure(Figure currentFigure, double rotationAngleInRadians)
    {
        double rotatedWidth = Math.Abs(Math.Cos(rotationAngleInRadians)) * currentFigure.Width +
            Math.Abs(Math.Sin(rotationAngleInRadians)) * currentFigure.Height;
        double rotatedHeight = Math.Abs(Math.Sin(rotationAngleInRadians)) * currentFigure.Width +
            Math.Abs(Math.Cos(rotationAngleInRadians)) * currentFigure.Height;
        Figure rotatedFigure = new Figure(rotatedWidth, rotatedHeight);

        return rotatedFigure;
    }
Example #15
0
    public static Figure GetRotatedFigure(Figure figure, double angleOfRotation)
    {
        double rotatedSizeWidth = (Math.Abs(Math.Cos(angleOfRotation)) * figure.Width) +
            (Math.Abs(Math.Sin(angleOfRotation)) * figure.Heigth);
        double rotatedSizeHeight = (Math.Abs(Math.Sin(angleOfRotation)) * figure.Width) +
            (Math.Abs(Math.Cos(angleOfRotation)) * figure.Heigth);

        Figure rotatedFigure = new Figure(rotatedSizeWidth, rotatedSizeHeight);

        return rotatedFigure;
    }
Example #16
0
 public object Clone()
 {
     var copied = new Figure(this.Body);
     copied.Elements = GetFigureFromArray(copied.Body);
     copied.Position = this.Position;
     for (int i = 0; i < copied.Elements.Count; i++)
     {
         copied.Elements[i].Position.Left = this.Elements[i].Position.Left;
         copied.Elements[i].Position.Top = this.Elements[i].Position.Top;
     }
     return copied;
 }
Example #17
0
 /// <summary>
 /// fetches a text randomly and displays it
 /// </summary>
 /// <param name="figure"></param>
 public static void ShowRandomText(Figure figure)
 {
     if (isActive)
     {
         if (notYetDisplayedTexts.Count == 0)
             notYetDisplayedTexts.AddRange(texts);
         int randomIndex = UnityEngine.Random.Range(0, notYetDisplayedTexts.Count);
         string text = (string)notYetDisplayedTexts[randomIndex];
         ShowText(figure, text);
         notYetDisplayedTexts.Remove(text);
     }
 }
Example #18
0
 private void drawQuetion(Graphics g)
 {
     List<Figure> figures = generateQuetion();
     int i = 0, x = 0, y = 0;
     while (i < 8) {
         drawFigure(g, x, y, figures[i]);
         x += offset;
         if (i == 2 || i == 5) { y += offset; x = 0; }
         i += 1;
     }
     answer = figures[8];
 }
    //Methods:
    public static Figure GetRotatedFigure(Figure size, double angle)
    {
        double cosWidth = Math.Abs(Math.Cos(angle)) * size.Width;
        double sinHeight = Math.Abs(Math.Sin(angle)) * size.Height;
        double sinWidth = Math.Abs(Math.Sin(angle)) * size.Width;
        double cosHeight = Math.Abs(Math.Cos(angle)) * size.Height;

        double newWidth = cosWidth + sinHeight;
        double newHeight = sinWidth + cosHeight;

        return new Figure(newWidth, newHeight);
    }
Example #20
0
        public List<Position> GetMoves(Figure figure, ChessField cf)
        {
            Position pos = figure.Position;
            List<Position> l = new List<Position>();
            switch (figure.GetFigureType())
            {
                case FigureTypes.King:
                    {

                        break;
                    }
            }
        }
Example #21
0
    public void ConnectTo(Figure figure)
    {
        foreach (Pin pin in pins) {
            pin.position = pin.position + position - figure.position;
            pin.transform.parent = figure.transform.FindChild("PinWrapper");
        }

        int arrayOriginalSize = figure.pins.Length;
        Array.Resize< Pin >(ref figure.pins, figure.pins.Length + pins.Length);
        Array.Copy(pins, 0, figure.pins, arrayOriginalSize, pins.Length);
        pins = new Pin[0];
        Reinit();
    }
    public static Figure GetRotatedFigure(Figure figure, double rotatedFigureAngle)
    {
        double width;
        double height;

        width = Math.Abs(Math.Cos(rotatedFigureAngle)) * figure.width +
            Math.Abs(Math.Sin(rotatedFigureAngle)) * figure.height;
        height = Math.Abs(Math.Sin(rotatedFigureAngle)) * figure.width +
            Math.Abs(Math.Cos(rotatedFigureAngle)) * figure.height;

        Figure rotatedFigure = new Figure(width, height);

        return rotatedFigure;
    }
Example #23
0
        static void Main(string[] args)
        {
            Figure[] figures = new Figure[] {
                new Point(0, 0),
                new Point(3, 1),
                new Point(5, 10),
                new Circle(new Point(3, 5), 30),
                new Segment(new Point(100, 50), new Point(50, 100)),
                new Polygon(new Point(0, 0), new Point(3, 1), new Point(5, 10))
            };

            foreach (Figure fig in figures) {
                Console.WriteLine(fig);
            }
        }
 private void pictureBox3_Click_1(object sender, EventArgs e)
 {
     chosenFigure = new S();
     Scores.Text = "4000 очков";
     price = 4000;
     chosenFigureName.Text = "S";
     if (scoresCount >= price)
     {
         label2.Enabled = true;
     }
     else
     {
         label2.Enabled = false;
     }
 }
Example #25
0
    /// <summary>
    /// places a figure at the very beginning of the game (without moving the smoothly)
    /// </summary>
    /// <param name="figure"></param>
    public void InitiallyPlaceFigure(Figure figure)
    {
        if (GameCtrl.GameIsRunning) throw new InvalidGameStateException();
        if (IsOccupied) throw new InvalidGameStateException();

        foreach (FieldPosition fieldPosition in fieldPositions)
        {
            if (!fieldPosition.IsOccupied)
            {
                AdjustReferences(fieldPosition, figure);
                figure.gameObject.transform.position = fieldPosition.gameObject.transform.position;
                break;
            }
        }
    }
Example #26
0
 private void Form1_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         draw = true;
         x = e.X;
         y = e.Y;
         if (CurrentFigure == "Polyline")
             currentType = Type.GetType("lab1.Classes.Line");
         currentType = TypeList.First(SomeType => SomeType.Name == CurrentFigure);
         f = (Figure)Activator.CreateInstance(currentType);
         f.Change(x, y, x, y);
         flist.Add(f);
         f.Draw(g);
     }
 }
Example #27
0
	public Figure(Figure figureCopy)
	{
		if (figureCopy != null && this != null)
		{
			this.nameFigure = figureCopy.nameFigure;
			this.position = figureCopy.position;
			this.form = new bool[figureCopy.form.GetLength(0), figureCopy.form.GetLength(1)];
			for (int y = 0; y < this.form.GetLength(0); y++)
			{
				for (int x = 0; x < this.form.GetLength(1); x++)
				{
					this.form[y, x] = figureCopy.form[y, x];
				}
			}
		}
	}
Example #28
0
 private void drawFigure(Graphics g, int x0, int y0, Figure figure)
 {
     Pen p = new Pen(figure.getColor(), 4);
     SolidBrush b = new SolidBrush(figure.getColor());
     switch (figure.getType()) {
         case Figure.Type.CIRCLE:
             g.FillEllipse(b, x0, y0, 60, 60);
             break;
         case Figure.Type.RECTANGLE:
             g.FillRectangle(b, x0, y0, 60, 60);
             break;
         case Figure.Type.TRIANGLE:
             g.FillPolygon(b, new PointF[] { new PointF(x0, y0), new PointF(x0+60, y0), new PointF(x0 + 30, y0+60) });
             break;
     }
 }
Example #29
0
 static void Main()
 {
     Figure[] figures = new Figure[]
     {
         new Line(),
         new Circle(),
         new Line(),
         new SpecialFigure(),
         new Line(),
     };
     foreach (var f in figures)
     {
         f.Draw();
         Console.WriteLine();
     }
 }
Example #30
0
 public MyList<Position> GetMoves(Figure figure, ChessField cf)
 {
     Position pos = figure.Position;
     MyList<Position> l = new MyList<Position>();
     int x = pos.GetX(), y = pos.GetY();
     try
     {
         l.Add(new Position(x + 1, y + 2));
     }
     catch{}
     try
     {
         l.Add(new Position(x + 1, y + -2));
     }
     catch { }
     try
     {
         l.Add(new Position(x - 1, y + 2));
     }
     catch { }
     try
     {
         l.Add(new Position(x - 1, y - 2));
     }
     catch { }
     try
     {
         l.Add(new Position(x + 2, y + 1));
     }
     catch { }
     try
     {
         l.Add(new Position(x + 2, y - 1));
     }
     catch { }
     try
     {
         l.Add(new Position(x - 2, y +1));
     }
     catch { }
     try
     {
         l.Add(new Position(x -2, y - 1));
     }
     catch { }
     return l;
 }
Example #31
0
 public void setMemoryFigure(Figure figure)
 {
     this.memoryFigure = figure;
 }
Example #32
0
        /// <summary>
        /// Starts the segment.
        /// </summary>
        /// <param name="atIndex">At index.</param>
        /// <param name="location">The location.</param>
        public virtual void StartSegment(int atIndex, CorePoint location)
        {
            if (Splitters.Count <= ActiveSplitters)
            {
                Splitters.Add(new LineSegmentSplitter {
                    IsNew = true
                });
            }

            var splitter = Splitters[ActiveSplitters];

            splitter.SplitterCollectorIndex = SplittersCollector;

            ActiveSplitters++;
            var animSpeed = Model.Chart.View.AnimationsSpeed;
            var noAnim    = Model.Chart.View.DisableAnimations;

            var areaLimit = ChartFunctions.ToDrawMargin(double.IsNaN(AreaLimit)
                ? Model.Chart.AxisY[ScalesYAt].FirstSeparator
                : AreaLimit, AxisOrientation.Y, Model.Chart, ScalesYAt);

            if (Values != null && atIndex == 0)
            {
                if (Model.Chart.View.DisableAnimations || IsNew)
                {
                    Figure.StartPoint = new Point(location.X, areaLimit);
                }
                else
                {
                    Figure.BeginAnimation(PathFigure.StartPointProperty,
                                          new PointAnimation(new Point(location.X, areaLimit), animSpeed));
                }

                IsNew = false;
            }

            if (atIndex != 0)
            {
                Figure.Segments.Remove(splitter.Bottom);

                if (splitter.IsNew)
                {
                    splitter.Bottom.Point = new Point(location.X, Model.Chart.DrawMargin.Height);
                    splitter.Left.Point   = new Point(location.X, Model.Chart.DrawMargin.Height);
                }

                if (noAnim)
                {
                    splitter.Bottom.Point = new Point(location.X, areaLimit);
                }
                else
                {
                    splitter.Bottom.BeginAnimation(LineSegment.PointProperty,
                                                   new PointAnimation(new Point(location.X, areaLimit), animSpeed));
                }
                Figure.Segments.Insert(atIndex, splitter.Bottom);

                Figure.Segments.Remove(splitter.Left);
                if (noAnim)
                {
                    splitter.Left.Point = location.AsPoint();
                }
                else
                {
                    splitter.Left.BeginAnimation(LineSegment.PointProperty,
                                                 new PointAnimation(location.AsPoint(), animSpeed));
                }
                Figure.Segments.Insert(atIndex + 1, splitter.Left);

                return;
            }

            if (splitter.IsNew)
            {
                splitter.Bottom.Point = new Point(location.X, Model.Chart.DrawMargin.Height);
                splitter.Left.Point   = new Point(location.X, Model.Chart.DrawMargin.Height);
            }

            Figure.Segments.Remove(splitter.Left);
            if (Model.Chart.View.DisableAnimations)
            {
                splitter.Left.Point = location.AsPoint();
            }
            else
            {
                splitter.Left.BeginAnimation(LineSegment.PointProperty,
                                             new PointAnimation(location.AsPoint(), animSpeed));
            }
            Figure.Segments.Insert(atIndex, splitter.Left);
        }
Example #33
0
    public void Run()
    {
        var loader = new FigureRecipeLoader(objectLocator, pathManager);

        FigureRecipe genesis3FemaleRecipe = loader.LoadFigureRecipe("genesis-3-female", null);
        FigureRecipe genitaliaRecipe      = loader.LoadFigureRecipe("genesis-3-female-genitalia", genesis3FemaleRecipe);
        FigureRecipe genesis3FemaleWithGenitaliaRecipe = new FigureRecipeMerger(genesis3FemaleRecipe, genitaliaRecipe).Merge();
        Figure       genesis3FemaleWithGenitalia       = genesis3FemaleWithGenitaliaRecipe.Bake(null);

        Figure parentFigure = genesis3FemaleWithGenitalia;

        FigureRecipe livHairRecipe = loader.LoadFigureRecipe("liv-hair", null);
        var          livHairFigure = livHairRecipe.Bake(parentFigure);

        var surfaceProperties = SurfacePropertiesJson.Load(pathManager, livHairFigure);
        var processor         = new FaceTransparencyProcessor(device, shaderCache, livHairFigure, surfaceProperties);

        for (int surfaceIdx = 0; surfaceIdx < livHairFigure.Geometry.SurfaceCount; ++surfaceIdx)
        {
            string surfaceName = livHairFigure.Geometry.SurfaceNames[surfaceIdx];

            string textureFileName;
            if (surfaceName == "Hairband")
            {
                continue;
            }
            else if (surfaceName == "Cap")
            {
                textureFileName = fileLocator.Locate("/Runtime/Textures/outoftouch/!hair/OOTHairblending2/Liv/OOTUtilityLivCapT.jpg");
            }
            else
            {
                textureFileName = fileLocator.Locate("/Runtime/Textures/outoftouch/!hair/OOTHairblending2/Liv/OOTUtilityLivHairT.png");
            }

            RawFloatTexture opacityTexture = new RawFloatTexture {
                value = 1,
                image = new RawImageInfo {
                    file  = new FileInfo(textureFileName),
                    gamma = 1
                }
            };

            processor.ProcessSurface(surfaceIdx, livHairFigure.DefaultUvSet.Name, opacityTexture);
        }

        var transparencies = processor.FaceTransparencies;

        for (int i = 0; i < 10; ++i)
        {
            int    faceIdx     = i * 3000;
            int    surfaceIdx  = livHairFigure.Geometry.SurfaceMap[faceIdx];
            string surfaceName = livHairFigure.Geometry.SurfaceNames[surfaceIdx];

            var  uvSet = livHairFigure.DefaultUvSet;
            Quad face  = uvSet.Faces[faceIdx];

            Console.WriteLine("face {0}: ", faceIdx);
            Console.WriteLine("  transparency: " + transparencies[faceIdx]);
            Console.WriteLine("  surface: " + surfaceName);
            Console.WriteLine("  uv 0: {0}", uvSet.Uvs[face.Index0]);
            Console.WriteLine("  uv 1: {0}", uvSet.Uvs[face.Index1]);
            Console.WriteLine("  uv 2: {0}", uvSet.Uvs[face.Index2]);
            Console.WriteLine("  uv 3: {0}", uvSet.Uvs[face.Index3]);
            Console.WriteLine();
        }
        Console.WriteLine("min = " + transparencies.Min());
        Console.WriteLine("avg = " + transparencies.Average());
        Console.WriteLine("max = " + transparencies.Max());
    }
Example #34
0
        private void ButtonClickCreate(object sender, RoutedEventArgs e)
        {
            Create newItem = new Create();

            if (newItem.ShowDialog() == true)
            {
                Figure Blue   = new Figure(new BlueFigure());
                Figure Yellow = new Figure(new YellowFigure());

                if ("Синий круг" == newItem.FirureName)
                {
                    int g = -400;
                    for (int i = 0; i < newItem.FigureCount; i++)
                    {
                        Random  random        = new Random();
                        int     randomNumber1 = random.Next(0, 100);
                        Ellipse ellipseNew    = Blue.getCircle();
                        g = g + 100;
                        ellipseNew.Margin = new Thickness(-340, g, 0, 0);
                        Greed.Children.Add(ellipseNew);
                    }
                }
                if ("Жёлтый круг" == newItem.FirureName)
                {
                    int g = -400;
                    for (int i = 0; i < newItem.FigureCount; i++)
                    {
                        Random  random        = new Random();
                        int     randomNumber1 = random.Next(0, 100);
                        Ellipse ellipseNew    = Yellow.getCircle();
                        g = g + 100;
                        ellipseNew.Margin = new Thickness(-150, g, 0, 0);
                        Greed.Children.Add(ellipseNew);
                    }
                }
                if ("Синий квадрат" == newItem.FirureName)
                {
                    int g = -400;
                    for (int i = 1; i < newItem.FigureCount + 1; i++)
                    {
                        Random    random        = new Random();
                        int       randomNumber1 = random.Next(0, 100);
                        Rectangle ellipseNew    = Blue.getSquary();
                        g = g + 110;
                        ellipseNew.Margin = new Thickness(150, g, 0, 0);
                        Greed.Children.Add(ellipseNew);
                    }
                }
                if ("Жёлтый квадрат" == newItem.FirureName)
                {
                    int g = -400;
                    for (int i = 0; i < newItem.FigureCount; i++)
                    {
                        Random    random        = new Random();
                        int       randomNumber1 = random.Next(0, 100);
                        Rectangle ellipseNew    = Yellow.getSquary();
                        g = g + 110;
                        ellipseNew.Margin = new Thickness(340, g, 0, 0);
                        Greed.Children.Add(ellipseNew);
                    }
                }
            }
            else
            {
                MessageBox.Show("Error open window");
            }
        }
Example #35
0
        /// <summary>
        /// Графический путь для рисования текстового блока
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="figure"></param>
        /// <param name="textBlock"></param>
        /// <param name="padding"></param>
        /// <param name="wordWrap"></param>
        /// <returns></returns>
        public static GraphicsPath GetTextBlockTransformedPath(Graphics graphics, Figure figure,
                                                               ITextBlock textBlock, Padding padding, bool wordWrap = false)
        {
            var outRectSize  = Helper.GetSize(figure.Transform);
            var text         = textBlock.Text;
            var graphicsPath = new GraphicsPath();

            using (var sf = new StringFormat(StringFormat.GenericTypographic))
            {
                Helper.UpdateStringFormat(sf, textBlock.Alignment);
                if (!string.IsNullOrWhiteSpace(textBlock.Text))
                {
                    if (wordWrap)
                    {
                        var size = outRectSize;
                        size.Width -= padding.Left + padding.Right;
                        var rect = new RectangleF(PointF.Empty, size);
                        graphicsPath.AddString(text, new FontFamily(textBlock.FontName),
                                               (int)textBlock.FontStyle, textBlock.FontSize, rect, sf);
                    }
                    else
                    {
                        graphicsPath.AddString(text, new FontFamily(textBlock.FontName),
                                               (int)textBlock.FontStyle, textBlock.FontSize, PointF.Empty, sf);
                    }
                }
                else
                {
                    graphicsPath.AddLine(PointF.Empty, PointF.Empty);
                }
            }
            var textBounds = graphicsPath.GetBounds();

            if (textBounds.IsEmpty)
            {
                return(new GraphicsPath());
            }
            var dx = outRectSize.Width - textBounds.Width - padding.Right;
            var dy = outRectSize.Height - textBounds.Height - padding.Bottom;

            switch (textBlock.Alignment)
            {
            case ContentAlignment.TopLeft:
                dx = padding.Left;
                dy = padding.Top;
                break;

            case ContentAlignment.TopCenter:
                dx = dx / 2f + padding.Left / 2;
                dy = padding.Top;
                break;

            case ContentAlignment.TopRight:
                dy = padding.Top;
                break;

            case ContentAlignment.MiddleLeft:
                dx = padding.Left;
                dy = dy / 2f + padding.Top / 2;
                break;

            case ContentAlignment.MiddleCenter:
                dx = dx / 2f + padding.Left / 2;
                dy = dy / 2f + padding.Top / 2;
                break;

            case ContentAlignment.MiddleRight:
                dy = dy / 2f + padding.Top / 2;
                break;

            case ContentAlignment.BottomLeft:
                dx = padding.Left;
                break;

            case ContentAlignment.BottomCenter:
                dx = dx / 2f + padding.Left / 2;
                break;
            }
            var eps = Helper.EPSILON;
            var kfx = (outRectSize.Width < eps) ? eps : 1 / outRectSize.Width;
            var kfy = (outRectSize.Height < eps) ? eps : 1 / outRectSize.Height;
            var pts = graphicsPath.PathPoints;

            for (var i = 0; i < pts.Length; i++)
            {
                pts[i].X = kfx * (pts[i].X - textBounds.Left + dx) - 0.5f;
                pts[i].Y = kfy * (pts[i].Y - textBounds.Top + dy) - 0.5f;
            }
            var ptt = graphicsPath.PathTypes;

            figure.Transform.Matrix.TransformPoints(pts);
            return(new GraphicsPath(pts, ptt));
        }
Example #36
0
 public void initializeFigure(Figure figure)
 {
     this.figure = figure;
     figure.getGameObject().transform.position = worldPosition;
 }
Example #37
0
 private static void RemoveFromBoard(Figure figure)
 {
     BoardFigureScripts.Synergies.SynergyManager.RemoveFigure(figure);
     _activeAllyFigures.Remove(figure);
     _pieceCounter.UpdateCostSum(figure.Piece.PieceType, -figure.Cost);
 }
Example #38
0
 public int Move(string user, int y_from, int x_from, int y_to, int x_to, Figures figure = Figures.NONE)
 {
     if (user == white_player.Email && board.GetColor() == Colors.WHITE)
     {
         if (Events.ContainsKey(black_player.Email))
         {
             Events.Remove(black_player.Email);
         }
         Figure fig = board.GetFigure(y_from, x_from);
         if (fig != null)
         {
             int code;
             if (fig.GetType() == typeof(Pawn) && figure != Figures.NONE)
             {
                 code = ((Pawn)fig).Move(y_to, x_to, figure);
             }
             else
             {
                 code = fig.Move(y_to, x_to);
             }
             if (board.IsCheckMate())
             {
                 EndGame(Colors.WHITE);
             }
             else
             {
                 Events.Add(black_player.Email, -1);
             }
             return(code);
         }
         return(0);
     }
     else if (user == black_player.Email && board.GetColor() == Colors.BLACK)
     {
         if (Events.ContainsKey(white_player.Email))
         {
             Events.Remove(white_player.Email);
         }
         Figure fig = board.GetFigure(y_from, x_from);
         if (fig != null)
         {
             int code;
             if (fig.GetType() == typeof(Pawn) && figure != Figures.NONE)
             {
                 code = ((Pawn)fig).Move(y_to, x_to, figure);
             }
             else
             {
                 code = fig.Move(y_to, x_to);
             }
             if (board.IsCheckMate())
             {
                 Events.Add(white_player.Email, -2);
                 Events.Add(black_player.Email, -2);
                 EndGame(Colors.BLACK);
             }
             else
             {
                 Events.Add(white_player.Email, -1);
             }
             return(code);
         }
         return(0);
     }
     return(-2);
 }
Example #39
0
 public void setCurrentFigure(Figure figure)
 {
     this.currentFigure = figure;
 }
Example #40
0
 /// <summary>
 /// フィギュア情報を削除します。
 /// </summary>
 public void Clear()
 {
     this.fig = null;
 }
Example #41
0
        private void ChessBoard_MouseClick(object sender, MouseEventArgs e)
        {
            int[] clickCoord = new int[2];
            clickCoord[0] = (int)(((e.X - BEGIN_X) - ((e.X - BEGIN_X) % STEP)) / STEP);
            clickCoord[1] = (int)(((e.Y - BEGIN_Y) - ((e.Y - BEGIN_Y) % STEP)) / STEP);
            Step qurStep = getStepFromCoord(clickCoord);

            if (qurStep != null)
            {
                qurStep.doStep(tile.Figures);
                if (drawCoordBuffer.Count > 0)
                {
                    drawCoordBuffer.Clear();
                }
                if (allowedSteps.Count > 0)
                {
                    allowedSteps.Clear();
                }
            }
            else
            {
                if (drawCoordBuffer.Count > 0)
                {
                    drawCoordBuffer.Clear();
                    Refresh();
                    return;
                }
                Figure qurF = tile.getFigureFromCoord(clickCoord);
                if (qurF == null)
                {
                    return;
                }
                // если мы щёлкнули по фигуре
                switch (qurF.GetType().ToString())
                {
                case "ChessDriver.Figures.Pawn":
                    allowedSteps = ((Pawn)qurF).getAllowedSteps(tile.Figures);
                    break;

                case "ChessDriver.Figures.Knight":
                    allowedSteps = ((Knight)qurF).getAllowedSteps(tile.Figures);
                    break;

                case "ChessDriver.Figures.King":
                    allowedSteps = ((King)qurF).getAllowedSteps(tile.Figures);
                    break;

                case "ChessDriver.Figures.Bishop":
                    allowedSteps = ((Bishop)qurF).getAllowedSteps(tile.Figures);
                    break;

                case "ChessDriver.Figures.Queen":
                    allowedSteps = ((Queen)qurF).getAllowedSteps(tile.Figures);
                    break;

                case "ChessDriver.Figures.Rook":
                    allowedSteps = ((Rook)qurF).getAllowedSteps(tile.Figures);
                    break;
                }
                float[] coordForFigureBorder = getCoordsForDrawing(qurF.Coord);
                drawCoordBuffer.Add("rectangle", new float[2] {
                    coordForFigureBorder[0] + 2, coordForFigureBorder[1] + 4
                });
                foreach (Step step in allowedSteps)
                {
                    float[] coordForDrawSteps = getCoordsForDrawing(step);
                    drawCoordBuffer.Add("point" + allowedSteps.IndexOf(step), new float[2] {
                        coordForDrawSteps[0] + STEP / 2, coordForDrawSteps[1] + STEP / 2
                    });
                }
            }
            Refresh();
        }
        private void button2_Click(object sender, EventArgs e)
        {
            ClearForm1();
            //---
            PreparareForm(0, 110, 0, 110);
            richTextBox1.AppendText("Paleidimas\n");
            //---
            Cell[,] A = new Cell[X_max + 1, Y_max + 1];
            //---
            for (int i = 0; i < A.GetLength(0); i++)
            {
                for (int u = 0; u < A.GetLength(1); u++)
                {
                    A[i, u] = new Cell(true);
                }
            }
            //---
            //---
            z1           = chart1.Series.Add("Pradine figura");
            z1.ChartType = SeriesChartType.Line;
            z1.Color     = Color.Blue;
            //---
            z2           = chart1.Series.Add("Maršrutas");
            z2.ChartType = SeriesChartType.Line;
            z2.Color     = Color.Red;
            //---
            p1           = chart1.Series.Add("O");
            p1.ChartType = SeriesChartType.Point;
            p1.Color     = Color.Black;
            //---
            z1.BorderWidth = 1;
            p1.BorderWidth = 3;

            //int N = 7;
            //int[] Layout = getFigureLayout(N);

            Figure f = new Figure(A, 10, 90, 10, 90);

            f.Draw(z1, p1);

            int[] start = { 0, 0 };
            int[] end   = { 99, 99 };

            printMatrix(A);

            /*
             * for (int i = 0; i < A.GetLength(0); i++)
             * {
             *  for (int u = 0; u < A.GetLength(1); u++)
             *  {
             *      if (f.isInside(i, u))
             *      {
             *          A[i, u].Valid = false;
             *          A[i, u].Symbol = 'Q';
             *      }
             *  }
             * }
             */

            int[][] route = BFS(A, start, end);
            for (int i = 0; i < route.GetLength(0); i++)
            {
                System.Diagnostics.Debug.WriteLine(route[i][0] + " " + route[i][1]);
                z2.Points.AddXY(route[i][0], route[i][1]);
            }
            printMatrix(A);
            //---
        }
Example #43
0
        /// <summary>
        /// Метод, отвечающий за перемещение и масштабирование фигур.
        /// </summary>
        /// <para name = "_figure">Переменная хранащая объект для которого нужно выполнять действия</para>
        /// <para name = "pivots">Переменная хранащая опорные точки выбранного объекта</para>
        /// <para name = "DeltaX">Переменная хранащая разницу по координате X</para>
        /// <para name = "DeltaY">Переменная хранащая разницу по координате Y</para>
        public void ScaleSelectFigure(Figure Selectedfigure, Pivots pivots, int DeltaX, int DeltaY)
        {
            if ((Selectedfigure.PointSelect[0].X - Selectedfigure.PointSelect[2].X != 0) && (Selectedfigure.PointSelect[0].Y - Selectedfigure.PointSelect[2].Y != 0))
            {
                Selectedfigure.PointSelect = Selectedfigure.Path.PathPoints;
            }

            if (Selectedfigure.IdFigure == pivots.IdFigure)
            {
                switch (pivots.ControlPointF)
                {
                case 0:
                    if (Selectedfigure.PointSelect[0].X + DeltaX < Selectedfigure.PointSelect[1].X)
                    {
                        Selectedfigure.PointSelect[0].X += DeltaX;
                    }

                    if (Selectedfigure.PointSelect[0].Y + DeltaY < Selectedfigure.PointSelect[3].Y)
                    {
                        Selectedfigure.PointSelect[0].Y += DeltaY;
                    }
                    Selectedfigure.Path.Reset();
                    Selectedfigure.Path.AddRectangle(_rectangleLTRBd.ShowRectangle(Selectedfigure.PointSelect[0], Selectedfigure.PointSelect[2]));
                    break;

                case 1:
                    if (Selectedfigure.PointSelect[2].X + DeltaX > Selectedfigure.PointSelect[0].X)
                    {
                        Selectedfigure.PointSelect[2].X += DeltaX;
                    }
                    if (Selectedfigure.PointSelect[0].Y + DeltaY < Selectedfigure.PointSelect[2].Y)
                    {
                        Selectedfigure.PointSelect[0].Y += DeltaY;
                    }
                    Selectedfigure.Path.Reset();
                    Selectedfigure.Path.AddRectangle(_rectangleLTRBd.ShowRectangle(Selectedfigure.PointSelect[0], Selectedfigure.PointSelect[2]));
                    break;

                case 2:
                    if (Selectedfigure.PointSelect[2].X + DeltaX > Selectedfigure.PointSelect[3].X)
                    {
                        Selectedfigure.PointSelect[2].X += DeltaX;
                    }
                    if (Selectedfigure.PointSelect[2].Y + DeltaY > Selectedfigure.PointSelect[1].Y)
                    {
                        Selectedfigure.PointSelect[2].Y += DeltaY;
                    }
                    Selectedfigure.Path.Reset();
                    Selectedfigure.Path.AddRectangle(_rectangleLTRBd.ShowRectangle(Selectedfigure.PointSelect[0], Selectedfigure.PointSelect[2]));
                    break;

                case 3:
                    if (Selectedfigure.PointSelect[0].X + DeltaX < Selectedfigure.PointSelect[2].X)
                    {
                        Selectedfigure.PointSelect[0].X += DeltaX;
                    }
                    if (Selectedfigure.PointSelect[2].Y + DeltaY > Selectedfigure.PointSelect[0].Y)
                    {
                        Selectedfigure.PointSelect[2].Y += DeltaY;
                    }
                    Selectedfigure.Path.Reset();
                    Selectedfigure.Path.AddRectangle(_rectangleLTRBd.ShowRectangle(Selectedfigure.PointSelect[0], Selectedfigure.PointSelect[2]));
                    break;
                }
            }
            if (Selectedfigure.CurrentFigure != 1)
            {
                for (int i = 0; i < Selectedfigure.PointSelect.Length; i++)
                {
                    Selectedfigure.EditPivots(i, _rectangleForPivots.SelectFigure(Selectedfigure.PointSelect[i], Selectedfigure.Pen.Width));
                }
            }
            else
            {
                int k = 0;
                for (int i = 0; i < Selectedfigure.PointSelect.Length; i += 3)
                {
                    Selectedfigure.EditPivots(k, _rectangleForPivots.SelectFigure(Selectedfigure.PointSelect[i], Selectedfigure.Pen.Width));
                    k++;
                }
            }
        }
Example #44
0
 /// <summary>
 /// Метод, выполняющий выделение фигуры
 /// </summary>
 /// <para name = "e">Переменная хранащая значение координат курсора мыши</para>
 /// <para name = "figuree">Переменная хранащая объект выделения</para>
 /// <para name = "SelectedFigures">Список выделенных объектов</para>
 public void ScaleFigure(MouseEventArgs e, Figure figuree, List <Figure> figuresSelectedList)
 {
     figuree.PointSelect  = figuree.Path.PathPoints;
     figuree.SelectFigure = true;
     figuresSelectedList.Add(figuree);
 }
Example #45
0
        /// <summary>
        /// This method runs when the update starts
        /// </summary>
        public override void OnSeriesUpdateStart()
        {
            ActiveSplitters = 0;

            if (SplittersCollector == int.MaxValue - 1)
            {
                //just in case!
                Splitters.ForEach(s => s.SplitterCollectorIndex = 0);
                SplittersCollector = 0;
            }

            SplittersCollector++;

            if (Figure != null && Values != null)
            {
                var yIni = ChartFunctions.ToDrawMargin(Values.GetTracker(this).YLimit.Min, AxisOrientation.Y, Model.Chart, ScalesYAt);

                if (Model.Chart.View.DisableAnimations)
                {
                    Figure.StartPoint = new Point(0, yIni);
                }
                else
                {
                    Figure.BeginAnimation(PathFigure.StartPointProperty,
                                          new PointAnimation(new Point(0, yIni),
                                                             Model.Chart.View.AnimationsSpeed));
                }
            }

            if (IsPathInitialized)
            {
                Model.Chart.View.EnsureElementBelongsToCurrentDrawMargin(Path);
                Path.Stroke          = Stroke;
                Path.StrokeThickness = StrokeThickness;
                Path.Fill            = Fill;
                Path.Visibility      = Visibility;
                Path.StrokeDashArray = StrokeDashArray;
                return;
            }

            IsPathInitialized = true;

            Path = new Path
            {
                Stroke          = Stroke,
                StrokeThickness = StrokeThickness,
                Fill            = Fill,
                Visibility      = Visibility,
                StrokeDashArray = StrokeDashArray
            };

            Panel.SetZIndex(Path, Panel.GetZIndex(this));

            var geometry = new PathGeometry();

            Figure = new PathFigure();
            geometry.Figures.Add(Figure);
            Path.Data = geometry;
            Model.Chart.View.AddToDrawMargin(Path);

            var y = ChartFunctions.ToDrawMargin(ActualValues.GetTracker(this).YLimit.Min, AxisOrientation.Y, Model.Chart, ScalesYAt);

            Figure.StartPoint = new Point(0, y);

            var i = Model.Chart.View.Series.IndexOf(this);

            Panel.SetZIndex(Path, Model.Chart.View.Series.Count - i);
        }
Example #46
0
        //-------------------------------------------------------------------
        // CalcFigurePosition
        //-------------------------------------------------------------------
        internal void CalcFigurePosition(
            FigureParaClient paraClient,          // IN:
            uint fswdir,                          // IN:  current direction
            ref PTS.FSRECT fsrcPage,              // IN:  page rectangle
            ref PTS.FSRECT fsrcMargin,            // IN:  rectangle within page margins
            ref PTS.FSRECT fsrcTrack,             // IN:  track rectangle
            ref PTS.FSRECT fsrcFigurePreliminary, // IN:  prelim figure rect calculated from figure props
            int fMustPosition,                    // IN:  must find position in this track?
            int fInTextLine,                      // IN:  it is attached to text line
            out int fPushToNextTrack,             // OUT: push to next track?
            out PTS.FSRECT fsrcFlow,              // OUT: FlowAround rectangle
            out PTS.FSRECT fsrcOverlap,           // OUT: Overlap rectangle
            out PTS.FSBBOX fsbbox,                // OUT: bbox
            out PTS.FSRECT fsrcSearch)            // OUT: search area for overlap
        {
            Figure element = (Figure)Element;

            // If overlapping happens, let PTS find another position withing
            // the track rectangle.

            FigureHorizontalAnchor horizAnchor = element.HorizontalAnchor;
            FigureVerticalAnchor   vertAnchor  = element.VerticalAnchor;

            fsrcSearch = CalculateSearchArea(horizAnchor, vertAnchor, ref fsrcPage, ref fsrcMargin, ref fsrcTrack, ref fsrcFigurePreliminary);

            if (vertAnchor == FigureVerticalAnchor.ParagraphTop &&
                fsrcFigurePreliminary.v != fsrcMargin.v &&                                               // If we're not at the top of the column
                ((fsrcFigurePreliminary.v + fsrcFigurePreliminary.dv) > (fsrcTrack.v + fsrcTrack.dv)) && // And we exceed column height
                !PTS.ToBoolean(fMustPosition))                                                           // Can delay placement is handled by figure properties.
            {
                fPushToNextTrack = PTS.True;
            }
            else
            {
                fPushToNextTrack = PTS.False;
            }


            // Use rectangle proposed by PTS and make sure that figure fits completely in the page.

            fsrcFlow = fsrcFigurePreliminary;

            if (FigureHelper.IsHorizontalColumnAnchor(horizAnchor))
            {
                fsrcFlow.u += CalculateParagraphToColumnOffset(horizAnchor, fsrcFigurePreliminary);
            }

            // Apply horizontal and vertical offsets. Offsets are limited by page height and width
            fsrcFlow.u += TextDpi.ToTextDpi(element.HorizontalOffset);
            fsrcFlow.v += TextDpi.ToTextDpi(element.VerticalOffset);

            // Overlap rectangle is the same as flow around rect
            fsrcOverlap = fsrcFlow;


            /* If we're anchored to column/content left or right, inflate our overlap width to prevent from aligning two figures right next to one another
             * by incorporating column gap information */
            if (!FigureHelper.IsHorizontalPageAnchor(horizAnchor) &&
                horizAnchor != FigureHorizontalAnchor.ColumnCenter &&
                horizAnchor != FigureHorizontalAnchor.ContentCenter)
            {
                double columnWidth, gap, rule;
                int    cColumns;

                FigureHelper.GetColumnMetrics(StructuralCache, out cColumns, out columnWidth, out gap, out rule);

                int duColumnWidth            = TextDpi.ToTextDpi(columnWidth);
                int duGapWidth               = TextDpi.ToTextDpi(gap);
                int duColumnWidthWithGap     = duColumnWidth + duGapWidth;
                int fullColumns              = (fsrcOverlap.du / duColumnWidthWithGap);
                int duRoundedToNearestColumn = ((fullColumns + 1) * duColumnWidthWithGap) - duGapWidth;

                fsrcOverlap.du = duRoundedToNearestColumn; // Round overlap rect to nearest column

                if (horizAnchor == FigureHorizontalAnchor.ContentRight ||
                    horizAnchor == FigureHorizontalAnchor.ColumnRight)
                {
                    fsrcOverlap.u = (fsrcFlow.u + fsrcFlow.du + duGapWidth) - fsrcOverlap.du;
                }

                // Force search rect to only work vertically within overlap space.
                fsrcSearch.u  = fsrcOverlap.u;
                fsrcSearch.du = fsrcOverlap.du;
            }

            // Bounding box is equal to actual size of the figure.
            fsbbox          = new PTS.FSBBOX();
            fsbbox.fDefined = PTS.True;
            fsbbox.fsrc     = fsrcFlow;
        }
Example #47
0
 /// <summary>
 /// Initializes the specified prescription.
 /// </summary>
 /// <param name="prescription">The prescription.</param>
 private void Initialize(Figure figure)
 {
     this.bdsFigure.DataSource       = figure;
     this.bdsFigureDetail.DataSource = figure.FigureDetail;
 }
Example #48
0
 /// <summary>
 /// Реализация интерфейса IRendererTransformedPath
 /// </summary>
 /// <param name="graphics"></param>
 /// <param name="figure"></param>
 /// <returns></returns>
 public virtual GraphicsPath GetTransformedPath(Graphics graphics, Figure figure)
 {
     return(GetTextBlockTransformedPath(graphics, figure, this, Padding, WordWrap));
 }
Example #49
0
 public Cell(Figure figure, GameSide playerSide)
 {
     _figure = figure;
     _active = figure.Side == SideUtil.Convert(playerSide);
 }
 public DesignTimeChessBoardCellViewModel()
     : base(1, 1, FigureColor.Black)
 {
     Figure = new Figure(FigureType.Pawn, FigureColor.White, "A2");
 }
Example #51
0
 public void setPreviewFigure(Figure figure)
 {
     this.previewFigure = figure;
 }
Example #52
0
 public bool IsTarget(Figure f)
 {
     return(!f.Marked(ignore));
 }
Example #53
0
        internal void GetFigureProperties(
            FigureParaClient paraClient,        // IN:
            int fInTextLine,                    // IN:  it is attached to text line
            uint fswdir,                        // IN:  current direction
            int fBottomUndefined,               // IN:  bottom of page is not defined
            out int dur,                        // OUT: width of figure
            out int dvr,                        // OUT: height of figure
            out PTS.FSFIGUREPROPS fsfigprops,   // OUT: figure attributes
            out int cPolygons,                  // OUT: number of polygons
            out int cVertices,                  // OUT: total number of vertices in all polygons
            out int durDistTextLeft,            // OUT: distance to text from MinU side
            out int durDistTextRight,           // OUT: distance to text from MaxU side
            out int dvrDistTextTop,             // OUT: distance to text from MinV side
            out int dvrDistTextBottom)          // OUT: distance to text from MaxV side
        {
            Invariant.Assert(StructuralCache.CurrentFormatContext.FinitePage);

            uint fswdirPara = PTS.FlowDirectionToFswdir(((FlowDirection)Element.GetValue(FrameworkElement.FlowDirectionProperty)));

            IntPtr pfsFigureContent;

            PTS.FSBBOX fsbbox;
            int        cColumns;
            int        dvrTopSpace;

            PTS.FSCOLUMNINFO[] columnInfoCollection;
            IntPtr             pmcsclientOut;
            MbpInfo            mbp;

            Figure element = (Figure)Element;

            // Initialize the subpage size. PTS subpage margin is always set to 0 for Figures.
            // If width on figure is specified, use the specified value.
            // Border and padding of the figure is extracted from available subpage width.
            // We use StructuralCache.CurrentFormatContext's page dimensions as limiting values for figure MBP
            mbp = MbpInfo.FromElement(Element, StructuralCache.TextFormatterHost.PixelsPerDip);
            // We do not mirror margin as it's used to dist text left and right, and is unnecessary.

            durDistTextLeft = durDistTextRight = dvrDistTextTop = dvrDistTextBottom = 0;

            // Calculate specified width. IsAuto flag is needed because Auto is formatted the same way as column and will
            // not return Double.NaN.
            bool   isWidthAuto;
            double specifiedWidth = FigureHelper.CalculateFigureWidth(StructuralCache, element,
                                                                      element.Width,
                                                                      out isWidthAuto);


            double anchorLimitedWidth = LimitTotalWidthFromAnchor(specifiedWidth, TextDpi.FromTextDpi(mbp.MarginLeft + mbp.MarginRight));
            int    subpageWidth       = Math.Max(1, TextDpi.ToTextDpi(anchorLimitedWidth) - (mbp.BPLeft + mbp.BPRight));

            // Calculate figure height, IsAuto flag is used as specifiedHeight will never be NaN.
            bool   isHeightAuto;
            double specifiedHeight = FigureHelper.CalculateFigureHeight(StructuralCache, element,
                                                                        element.Height,
                                                                        out isHeightAuto);

            double anchorLimitedHeight = LimitTotalHeightFromAnchor(specifiedHeight, TextDpi.FromTextDpi(mbp.MarginTop + mbp.MarginBottom));
            int    subpageHeight       = Math.Max(1, TextDpi.ToTextDpi(anchorLimitedHeight) - (mbp.BPTop + mbp.BPBottom));

            // Initialize column info. Figure always has just 1 column.
            cColumns             = 1;
            columnInfoCollection = new PTS.FSCOLUMNINFO[cColumns];
            columnInfoCollection[0].durBefore = 0;
            columnInfoCollection[0].durWidth  = subpageWidth;

            // Create subpage
            {
                PTS.FSFMTR fsfmtr;
                IntPtr     brParaOut;
                PTS.FSRECT marginRect = new PTS.FSRECT(0, 0, subpageWidth, subpageHeight);

                CreateSubpageFiniteHelper(PtsContext, IntPtr.Zero, PTS.False, _mainTextSegment.Handle, IntPtr.Zero, PTS.False, PTS.True,
                                          fswdir, subpageWidth, subpageHeight, ref marginRect,
                                          cColumns, columnInfoCollection, PTS.False,
                                          out fsfmtr, out pfsFigureContent, out brParaOut, out dvr, out fsbbox, out pmcsclientOut,
                                          out dvrTopSpace);

                if (brParaOut != IntPtr.Zero)
                {
                    PTS.Validate(PTS.FsDestroySubpageBreakRecord(PtsContext.Context, brParaOut));
                }
            }

            // PTS subpage does not support autosizing, but Figure needs to autosize to its
            // content. To workaround this problem, second format of subpage is performed, if
            // necessary. It means that if the width of bounding box is smaller than subpage's
            // width, second formatting is performed.

            if (PTS.ToBoolean(fsbbox.fDefined))
            {
                if (fsbbox.fsrc.du < subpageWidth && isWidthAuto)
                {
                    // There is a need to reformat PTS subpage, so destroy any resourcces allocated by PTS
                    // during previous formatting.
                    if (pfsFigureContent != IntPtr.Zero)
                    {
                        PTS.Validate(PTS.FsDestroySubpage(PtsContext.Context, pfsFigureContent), PtsContext);
                    }
                    if (pmcsclientOut != IntPtr.Zero)
                    {
                        MarginCollapsingState mcs = PtsContext.HandleToObject(pmcsclientOut) as MarginCollapsingState;
                        PTS.ValidateHandle(mcs);
                        mcs.Dispose();
                        pmcsclientOut = IntPtr.Zero;
                    }
                    // Create subpage with new width.
                    subpageWidth = fsbbox.fsrc.du + 1; // add 1/300px to avoid rounding errors
                    columnInfoCollection[0].durWidth = subpageWidth;

                    // Create subpage
                    PTS.FSFMTR fsfmtr;
                    IntPtr     brParaOut;
                    PTS.FSRECT marginRect = new PTS.FSRECT(0, 0, subpageWidth, subpageHeight);

                    CreateSubpageFiniteHelper(PtsContext, IntPtr.Zero, PTS.False, _mainTextSegment.Handle, IntPtr.Zero, PTS.False, PTS.True,
                                              fswdir, subpageWidth, subpageHeight, ref marginRect,
                                              cColumns, columnInfoCollection, PTS.False,
                                              out fsfmtr, out pfsFigureContent, out brParaOut, out dvr, out fsbbox, out pmcsclientOut,
                                              out dvrTopSpace);

                    if (brParaOut != IntPtr.Zero)
                    {
                        PTS.Validate(PTS.FsDestroySubpageBreakRecord(PtsContext.Context, brParaOut));
                    }
                }
            }
            else
            {
                subpageWidth = TextDpi.ToTextDpi(TextDpi.MinWidth);
            }


            // Get the size of the figure. For height PTS already reports calculated value.
            // But width is the same as subpage width. Include margins in dur since we are not using
            // distance to text anymore.
            dur = subpageWidth + mbp.MBPLeft + mbp.MBPRight;

            // Destroy objects created by PTS, but not used here.
            if (pmcsclientOut != IntPtr.Zero)
            {
                MarginCollapsingState mcs = PtsContext.HandleToObject(pmcsclientOut) as MarginCollapsingState;
                PTS.ValidateHandle(mcs);
                mcs.Dispose();
                pmcsclientOut = IntPtr.Zero;
            }

            dvr += mbp.MBPTop + mbp.MBPBottom;
            if (!isHeightAuto)
            {
                // Replace height with explicit height if specified, adding margins in addition to height
                // Border and padding are included in specified height but margins are external
                dvr = TextDpi.ToTextDpi(anchorLimitedHeight) + mbp.MarginTop + mbp.MarginBottom;
            }

            FigureHorizontalAnchor horzAnchor = element.HorizontalAnchor;
            FigureVerticalAnchor   vertAnchor = element.VerticalAnchor;

            fsfigprops.fskrefU = (PTS.FSKREF)(((int)horzAnchor) / 3);
            fsfigprops.fskrefV = (PTS.FSKREF)(((int)vertAnchor) / 3);
            fsfigprops.fskalfU = (PTS.FSKALIGNFIG)(((int)horzAnchor) % 3);
            fsfigprops.fskalfV = (PTS.FSKALIGNFIG)(((int)vertAnchor) % 3);

            // PTS does not allow to anchor delayed figures to 'Character'
            if (!PTS.ToBoolean(fInTextLine))
            {
                if (fsfigprops.fskrefU == PTS.FSKREF.fskrefChar)
                {
                    fsfigprops.fskrefU = PTS.FSKREF.fskrefMargin;
                    fsfigprops.fskalfU = PTS.FSKALIGNFIG.fskalfMin;
                }
                if (fsfigprops.fskrefV == PTS.FSKREF.fskrefChar)
                {
                    fsfigprops.fskrefV = PTS.FSKREF.fskrefMargin;
                    fsfigprops.fskalfV = PTS.FSKALIGNFIG.fskalfMin;
                }
            }

            // Always wrap text on both sides of the floater.
            fsfigprops.fskwrap       = PTS.WrapDirectionToFskwrap(element.WrapDirection);
            fsfigprops.fNonTextPlane = PTS.False;
            fsfigprops.fAllowOverlap = PTS.False;
            fsfigprops.fDelayable    = PTS.FromBoolean(element.CanDelayPlacement);

            // Tight wrap is disabled for now.
            cPolygons = cVertices = 0;

            // Update handle to PTS subpage.
            ((FigureParaClient)paraClient).SubpageHandle = pfsFigureContent;
        }
Example #54
0
 public virtual bool MoveFigure(int i, int j, Vector3 destination, Figure a, Figure[,] gameState, bool[,] possibleMoves)
 {
     return(true);
 }
Example #55
0
 public override Brush GetBrush(Figure figure)
 {
     return(new HatchBrush(HatchStyle, HatchColor, Color.FromArgb(_fill.Opacity, _fill.Color)));
 }
        public FlowDocument GenerateDocument()
        {
            var context         = DataEntitiesProvider.Provide();
            var currentOlympiad = context.Olympiad_Infoes.OrderByDescending(x => x.StartDate).First();

            var events = context.Events.Where(x => x.OlympiadId == currentOlympiad.Id)
                         .ToDictionary(e => e.Code, e => e.Mind_Sport);

            var entrants = context.Entrants.Where(x => x.OlympiadId == currentOlympiad.Id)
                           .GroupBy(x => x.Game_Code)
                           .ToDictionary(gp => gp.Key, gp => gp.Count());

            var games = context.Games.Where(x => !x.Code.StartsWith("ZZ"))
                        .ToDictionary(g => g.Code, g => g.Mind_Sport);


            FlowDocument doc = new FlowDocument();

            doc.ColumnWidth = 200; // 96ths of an inch
            doc.FontFamily  = new FontFamily("Verdana");

            Paragraph topPara = new Paragraph();

            topPara.TextAlignment = TextAlignment.Left;
            topPara.FontSize      = 12;
            topPara.FontWeight    = FontWeights.Bold;
            topPara.Margin        = new Thickness(4);
            topPara.Inlines.Add(new Run("Numbers in Events"));
            doc.Blocks.Add(topPara);

            var grandTotal = 0;

            foreach (var gameCode in games.Keys.OrderBy(x => x))
            {
                if (!entrants.Keys.Any(x => x.StartsWith(gameCode)))
                {
                    continue;
                }

                Section topSection = new Section();

                // http://stackoverflow.com/questions/12397089/how-can-i-keep-a-table-together-in-a-flowdocument

                Paragraph para = new Paragraph();
                para.TextAlignment = TextAlignment.Left;
                para.Margin        = new Thickness(0);
                para.FontWeight    = FontWeights.Normal;
                para.FontSize      = 10;

                Figure figure = new Figure();
                figure.CanDelayPlacement = false;
                figure.BorderBrush       = Brushes.Black;
                figure.BorderThickness   = new Thickness(1);

                Paragraph innerpara = new Paragraph();
                innerpara.TextAlignment = TextAlignment.Left;
                innerpara.Margin        = new Thickness(4);
                innerpara.FontWeight    = FontWeights.Bold;
                innerpara.FontSize      = 12;
                innerpara.Inlines.Add(new Run(games[gameCode]));
                figure.Blocks.Add(innerpara);

                Table table = new Table()
                {
                    CellSpacing = 0
                };
                table.Columns.Add(new TableColumn()
                {
                    Width = new GridLength(40)
                });
                table.Columns.Add(new TableColumn()
                {
                    Width = new GridLength(120)
                });
                table.Columns.Add(new TableColumn()
                {
                    Width = new GridLength(40)
                });
                table.RowGroups.Add(new TableRowGroup());

                var subtotal = 0;

                foreach (var eventCode in entrants.Keys.Where(x => x.StartsWith(gameCode)))
                {
                    var eventName = events[eventCode];

                    var row = new TableRow();
                    row.Cells.Add(new TableCell(new Paragraph(new Run(eventCode))
                    {
                        Margin = new Thickness(2), FontSize = 10
                    }));
                    row.Cells.Add(new TableCell(new Paragraph(new Run(eventName))
                    {
                        Margin = new Thickness(2), FontSize = 10
                    }));
                    row.Cells.Add(new TableCell(new Paragraph(new Run(entrants[eventCode].ToString()))
                    {
                        Margin = new Thickness(2), FontSize = 10
                    }));
                    table.RowGroups[0].Rows.Add(row);
                    subtotal   += entrants[eventCode];
                    grandTotal += entrants[eventCode];
                }

                var trow = new TableRow();
                trow.Cells.Add(new TableCell(new Paragraph(new Run(""))
                {
                    Margin = new Thickness(2), FontSize = 10, FontWeight = FontWeights.Bold
                }));
                trow.Cells.Add(new TableCell(new Paragraph(new Run("Total"))
                {
                    Margin = new Thickness(2), FontSize = 10, FontWeight = FontWeights.Bold
                }));
                trow.Cells.Add(new TableCell(new Paragraph(new Run(subtotal.ToString()))
                {
                    Margin = new Thickness(2), FontSize = 10, FontWeight = FontWeights.Bold
                }));
                table.RowGroups[0].Rows.Add(trow);

                figure.Blocks.Add(table);
                para.Inlines.Add(figure);
                topSection.Blocks.Add(para);

                doc.Blocks.Add(topSection);
            }

            Paragraph gtpara = new Paragraph();

            gtpara.TextAlignment = TextAlignment.Left;
            gtpara.Margin        = new Thickness(0);
            gtpara.FontWeight    = FontWeights.Normal;
            gtpara.FontSize      = 10;

            Figure gtfigure = new Figure();

            gtfigure.CanDelayPlacement = false;
            gtfigure.BorderBrush       = Brushes.Black;
            gtfigure.BorderThickness   = new Thickness(1);

            Table gttable = new Table()
            {
                CellSpacing = 0
            };

            gttable.Columns.Add(new TableColumn()
            {
                Width = new GridLength(40)
            });
            gttable.Columns.Add(new TableColumn()
            {
                Width = new GridLength(120)
            });
            gttable.Columns.Add(new TableColumn()
            {
                Width = new GridLength(40)
            });
            gttable.RowGroups.Add(new TableRowGroup());

            var gtrow = new TableRow();

            gtrow.Cells.Add(new TableCell(new Paragraph(new Run(""))
            {
                Margin = new Thickness(2), FontSize = 10, FontWeight = FontWeights.Bold
            }));
            gtrow.Cells.Add(new TableCell(new Paragraph(new Run("Grand Total"))
            {
                Margin = new Thickness(2), FontSize = 10, FontWeight = FontWeights.Bold
            }));
            gtrow.Cells.Add(new TableCell(new Paragraph(new Run(grandTotal.ToString()))
            {
                Margin = new Thickness(2), FontSize = 10, FontWeight = FontWeights.Bold
            }));
            gttable.RowGroups[0].Rows.Add(gtrow);

            gtfigure.Blocks.Add(gttable);
            gtpara.Inlines.Add(gtfigure);
            doc.Blocks.Add(gtpara);

            return(doc);
        }
Example #57
0
 private static void AddToBoard(Figure figure)
 {
     BoardFigureScripts.Synergies.SynergyManager.AddFigure(figure);
     _activeAllyFigures.Add(figure);
     _pieceCounter.UpdateCostSum(figure.Piece.PieceType, figure.Cost);
 }
        public static void Run()
        {
            // ExStart:DrawingUsingGraphicsPath
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_DrawingAndFormattingImages();

            // Create an instance of BmpOptions and set its various properties
            BmpOptions ImageOptions = new BmpOptions();

            ImageOptions.BitsPerPixel = 24;

            // Create an instance of FileCreateSource and assign it to Source property
            ImageOptions.Source = new FileCreateSource(dataDir + "sample_1.bmp", false);

            // Create an instance of Image
            using (Image image = Image.Create(ImageOptions, 500, 500))
            {
                // Create and initialize an instance of Graphics
                Graphics graphics = new Graphics(image);

                // Clear the image surface with white color
                graphics.Clear(Color.White);

                // Create an instance of GraphicsPath
                GraphicsPath graphicspath = new GraphicsPath();

                // Create an instance of Figure
                Figure figure = new Figure();

                // Add EllipseShape to the figure by defining boundary Rectangle
                figure.AddShape(new EllipseShape(new RectangleF(0, 0, 499, 499)));

                // Add RectangleShape to the figure
                figure.AddShape(new RectangleShape(new RectangleF(0, 0, 499, 499)));

                // Add TextShape to the figure by defining the boundary Rectangle and Font
                figure.AddShape(new TextShape("Aspose.Imaging", new RectangleF(170, 225, 170, 100), new Font("Arial", 20), StringFormat.GenericTypographic));

                // Add figures to the GraphicsPath object
                graphicspath.AddFigures(new[] { figure });

                // Draw Path
                graphics.DrawPath(new Pen(Color.Blue), graphicspath);

                // Create an instance of HatchBrush and set its properties
                HatchBrush hatchbrush = new HatchBrush();
                hatchbrush.BackgroundColor = Color.Brown;
                hatchbrush.ForegroundColor = Color.Blue;
                hatchbrush.HatchStyle      = HatchStyle.Vertical;

                // Fill path by supplying the brush and GraphicsPath objects
                graphics.FillPath(hatchbrush, graphicspath);

                // Save the changes.
                image.Save();

                // Display Status.
                Console.WriteLine("Processing completed successfully.");
            }
            // ExEnd:DrawingUsingGraphicsPath
        }
Example #59
0
 public void Drag(Figure figure, int dx, int dy)
 {
     figure.Resize(figure.width + dx, figure.height + dy);
 }
Example #60
0
 private static void MoveFigure(Figure sender, int nextRow, int nextColumn)
 {
     Figures[sender.Position.Row, sender.Position.Column] = null;
     Figures[nextRow, nextColumn] = sender;
     sender.MoveGraphicsToPosition(PointToPoint3D(GetTileCenter(nextRow, nextColumn)));
 }