Example #1
0
        private void AddPlayerTokensGUI()
        {
            var colors = new List <SolidColorBrush>()
            {
                Brushes.Green, Brushes.Purple, Brushes.Red, Brushes.Blue
            };

            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    Ellipse playerToken = new Ellipse
                    {
                        Visibility      = Visibility.Hidden,
                        Margin          = new Thickness(4),
                        Fill            = colors[i],
                        Stroke          = new SolidColorBrush(Colors.Black),
                        StrokeThickness = 0
                    };
                    //Engine.Game.Players[i].Tokens[j].Ellipse = playerToken;
                    Ellipses.Add(playerToken);
                    Board.Children.Add(playerToken);
                    playerToken.MouseDown += PlayerToken_MouseDown;
                }
            }
        }
Example #2
0
        private void DrawClick(object obj)
        {
            if (MousePosition != default(Point))
            {
                return;
            }

            Point mousePoint = Mouse.GetPosition((IInputElement)obj);

            Point prev = PrevPoint;

            PrevPoint = mousePoint;

            ++CountEdges;

            if (CountEdges == 2)
            {
                ColorsWindow colorWin = new ColorsWindow(this);

                double width  = Math.Abs(prev.X - PrevPoint.X);
                double height = Math.Abs(prev.Y - PrevPoint.Y);

                double left = Math.Min(prev.X, PrevPoint.X);
                double top  = Math.Min(prev.Y, PrevPoint.Y);

                CurrentEllipse.Width  = width;
                CurrentEllipse.Height = height;
                CurrentEllipse.Stroke = new SolidColorBrush(Colors.Black);

                CurrentEllipse.Margin = new Thickness(left, top, 0, 0);

                if (colorWin.ShowDialog() == true)
                {
                    CurrentEllipse.Fill = new SolidColorBrush(CurrentColor);
                }

                CurrentEllipse.Name = String.Format("Ellipse_{0}", Ellipses.Count + 1);

                Ellipses.Add(CurrentEllipse);


                CurrentEllipse = new Ellipse();
                OnPropertyChanged("Ellipses");
                CountEdges = 0;
            }
        }
Example #3
0
        public void Remove(string input)
        {
            int index = ChartInputs.IndexOf(input);

            ChartInputs.RemoveAt(index);
            Ellipses.RemoveAt(index);
            Lines.RemoveAt(index);
            WrapItems.Children.RemoveAt(index);

            /*foreach(StackPanel item in WrapItems.Children)
             * {
             *  if((item.Children[0] as TextBlock).Text == input)
             *  {
             *      WrapItems.Children.Remove(item);
             *      break;
             *  }
             * }*/
        }
Example #4
0
        private void ParseEllipses(XmlReader r)
        {
            r.ReadStartElement();

            while (r.NodeType == XmlNodeType.Element)
            {
                if (r.Name == "Ellipse")
                {
                    Ellipses.Add(new GenericPostureEllipse(r));
                }
                else
                {
                    string outerXml = r.ReadOuterXml();
                    log.DebugFormat("Unparsed content in XML: {0}", outerXml);
                }
            }

            r.ReadEndElement();
        }
Example #5
0
        public void Add(string name, Brush ellipse, Brush line)
        {
            ChartInputs.Add(name);
            Ellipses.Add(ellipse);
            Lines.Add(line);
            StackPanel Items = new StackPanel()
            {
                Margin = new Thickness()
                {
                    Left  = 5,
                    Right = 5
                },
                Orientation = Orientation.Vertical,
                Children    =
                {
                    CreateTextBlock(name),
                    CreateTextBox(name)
                }
            };

            WrapItems.Children.Add(Items);
        }
Example #6
0
        private void OpenFile(object obj)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.DefaultExt = ".xml";
            openFileDialog.Filter     = "XML documents (.xml)|*.xml";
            if (openFileDialog.ShowDialog() == true)
            {
                string            fileName = openFileDialog.FileName;
                List <EllipseDTO> ellipses = new List <EllipseDTO>();

                XmlSerializer serializer = new XmlSerializer(typeof(List <EllipseDTO>));

                using (XmlReader reader = XmlReader.Create(fileName))
                {
                    ellipses = (List <EllipseDTO>)serializer.Deserialize(reader);
                }

                Ellipses.Clear();

                for (int i = 0; i < ellipses.Count; ++i)
                {
                    Ellipses.Add(new Ellipse()
                    {
                        Name   = String.Format("Ellipse_{0}", i + 1),
                        Stroke = Brushes.Black,
                        Fill   = new SolidColorBrush(ellipses[i].Color),
                        Margin = new Thickness(ellipses[i].CenterX, ellipses[i].CenterY, 0, 0),
                        Width  = ellipses[i].Width,
                        Height = ellipses[i].Height
                    });
                }

                OnPropertyChanged("Ellipses");
            }
        }
 private static PointF EllipsePositionInBounds(Ellipses ellipse, RectangleF bound_rectangle)
 {
     PointF position = new PointF(ellipse.CX.Contains("%") ? (((bound_rectangle.Width * SBMLExtension.Util.readSingle(ellipse.CX)) / 100f)) : (SBMLExtension.Util.readSingle(ellipse.CX)),
         ellipse.CY.Contains("%") ? (((bound_rectangle.Height * SBMLExtension.Util.readSingle(ellipse.CY)) / 100f)) : (SBMLExtension.Util.readSingle(ellipse.CY)));
     return position;
 }
 private static PointF CorrectEllipseRadii(Ellipses ellipse, RectangleF bound_rectangle)
 {
     if (string.IsNullOrEmpty(ellipse.RX))
         ellipse.RX = ellipse.RY;
     if (string.IsNullOrEmpty(ellipse.RY))
         ellipse.RY = ellipse.RX;
     return new PointF(ellipse.RX.Contains("%") ? ((bound_rectangle.Width * SBMLExtension.Util.readSingle(ellipse.RX)) / 100f) : SBMLExtension.Util.readSingle(ellipse.RX),
         ellipse.RY.Contains("%") ? ((bound_rectangle.Height * SBMLExtension.Util.readSingle(ellipse.RY)) / 100f) : SBMLExtension.Util.readSingle(ellipse.RY));
 }
Example #9
0
        //DRAW BUTTON
        private void BtDraw_Click(object sender, EventArgs e)
        {
            //SQUARE
            if (rbSquare.Checked == true)
            {
                Squares aShape = new Squares();
                aShape.ShapeType   = EnumShapeType.Square;
                aShape.XCoord      = Convert.ToInt32(this.tbXCoord.Text);
                aShape.YCoord      = Convert.ToInt32(this.tbYCoord.Text);
                aShape.Side        = Convert.ToDouble(this.tbSide.Text);
                aShape.BrushColor  = (EnumBrushingColor)this.cbBrColor.SelectedItem;
                aShape.BorderColor = (EnumBorderColor)this.cbBoColor.SelectedItem;

                this.myListOfShapes.Add(aShape);

                index = myListOfShapes.LastIndexOf(aShape);

                this.panel1.Refresh();

                this.listBoxShapes.Items.Clear();

                foreach (Shapes element in myListOfShapes)
                {
                    this.listBoxShapes.Items.Add(element);
                }

                this.btUp.Focus();
            }
            //RECTANGLE
            else if (rbRectangle.Checked == true)
            {
                Rectangles aShape = new Rectangles();
                aShape.ShapeType   = EnumShapeType.Rectangle;
                aShape.XCoord      = Convert.ToInt32(this.tbXCoord.Text);
                aShape.YCoord      = Convert.ToInt32(this.tbYCoord.Text);
                aShape.Height      = Convert.ToDouble(this.tbHeight.Text);
                aShape.Length      = Convert.ToDouble(this.tbLength.Text);
                aShape.BrushColor  = (EnumBrushingColor)this.cbBrColor.SelectedItem;
                aShape.BorderColor = (EnumBorderColor)this.cbBoColor.SelectedItem;

                this.myListOfShapes.Add(aShape);

                index = myListOfShapes.LastIndexOf(aShape);

                this.panel1.Refresh();

                this.listBoxShapes.Items.Clear();

                foreach (Shapes element in myListOfShapes)
                {
                    this.listBoxShapes.Items.Add(element);
                }

                this.btUp.Focus();
            }
            //CIRCLE
            else if (rbCircle.Checked == true)
            {
                Circles aShape = new Circles();
                aShape.ShapeType   = EnumShapeType.Circle;
                aShape.XCoord      = Convert.ToInt32(this.tbXCoord.Text);
                aShape.YCoord      = Convert.ToInt32(this.tbYCoord.Text);
                aShape.Radius      = Convert.ToDouble(this.tbRadius.Text);
                aShape.BrushColor  = (EnumBrushingColor)this.cbBrColor.SelectedItem;
                aShape.BorderColor = (EnumBorderColor)this.cbBoColor.SelectedItem;

                this.myListOfShapes.Add(aShape);

                index = myListOfShapes.LastIndexOf(aShape);

                this.panel1.Refresh();

                this.listBoxShapes.Items.Clear();

                foreach (Shapes element in myListOfShapes)
                {
                    this.listBoxShapes.Items.Add(element);
                }

                this.btUp.Focus();
            }
            //ELIPSES
            else if (rbEllipse.Checked == true)
            {
                Ellipses aShape = new Ellipses();
                aShape.ShapeType   = EnumShapeType.Ellipse;
                aShape.XCoord      = Convert.ToInt32(this.tbXCoord.Text);
                aShape.YCoord      = Convert.ToInt32(this.tbYCoord.Text);
                aShape.XRadius     = Convert.ToDouble(this.tbXRadius.Text);
                aShape.YRadius     = Convert.ToDouble(this.tbYRadius.Text);
                aShape.BrushColor  = (EnumBrushingColor)this.cbBrColor.SelectedItem;
                aShape.BorderColor = (EnumBorderColor)this.cbBoColor.SelectedItem;

                this.myListOfShapes.Add(aShape);

                index = myListOfShapes.LastIndexOf(aShape);

                this.panel1.Refresh();

                this.listBoxShapes.Items.Clear();

                foreach (Shapes element in myListOfShapes)
                {
                    this.listBoxShapes.Items.Add(element);
                }

                this.btUp.Focus();
            }
        }
 internal static EllipseParameter GetEllipseParameters(Ellipses type)
 {
     return m_Transforms[type];
 }
Example #11
0
 private void ClearWindow(object obj)
 {
     Ellipses.Clear();
     OnPropertyChanged("Ellipses");
 }
Example #12
0
        /********************DRAW BUTTON*******************/
        private void BtDraw_Click(object sender, EventArgs e)
        {
            if (this.rbRectangle.Checked == true)
            {
                Rectangles myRectangle = new Rectangles();

                myRectangle.XCoord           = Convert.ToInt32(this.tbXCoord.Text);
                myRectangle.YCoord           = Convert.ToInt32(this.tbYCoord.Text);
                myRectangle.Width            = Convert.ToDouble(this.tbHeight.Text);
                myRectangle.Length           = Convert.ToDouble(this.tbLength.Text);
                myRectangle.ShapeBorderColor = (EnumBorderColor)cbBColor.SelectedItem;
                myRectangle.ShapeFillColor   = (EnumBrushingColor)cbSColor.SelectedItem;
                myRectangle.ShapeType        = EnumShapeType.rectangle;

                ListOfShapes.Add(myRectangle);
            }
            if (this.rbSquare.Checked == true)
            {
                Squares mySquare = new Squares();

                mySquare.XCoord           = Convert.ToInt32(this.tbXCoord.Text);
                mySquare.YCoord           = Convert.ToInt32(this.tbYCoord.Text);
                mySquare.Side             = Convert.ToDouble(this.tbSide.Text);
                mySquare.ShapeBorderColor = (EnumBorderColor)cbBColor.SelectedItem;
                mySquare.ShapeFillColor   = (EnumBrushingColor)cbSColor.SelectedItem;
                mySquare.ShapeType        = EnumShapeType.square;

                ListOfShapes.Add(mySquare);
            }
            if (this.rbEllipses.Checked == true)
            {
                Ellipses myEllipse = new Ellipses();

                myEllipse.XCoord           = Convert.ToInt32(this.tbXCoord.Text);
                myEllipse.YCoord           = Convert.ToInt32(this.tbYCoord.Text);
                myEllipse.XRadius          = Convert.ToDouble(this.tbXRadius.Text);
                myEllipse.YRadius          = Convert.ToDouble(this.tbYRadius.Text);
                myEllipse.ShapeBorderColor = (EnumBorderColor)cbBColor.SelectedItem;
                myEllipse.ShapeFillColor   = (EnumBrushingColor)cbSColor.SelectedItem;
                myEllipse.ShapeType        = EnumShapeType.ellipse;

                ListOfShapes.Add(myEllipse);
            }
            if (this.rbCircle.Checked == true)
            {
                Circles myCircle = new Circles();

                myCircle.XCoord           = Convert.ToInt32(this.tbXCoord.Text);
                myCircle.YCoord           = Convert.ToInt32(this.tbYCoord.Text);
                myCircle.Radius           = Convert.ToDouble(this.tbRadius.Text);
                myCircle.ShapeBorderColor = (EnumBorderColor)cbBColor.SelectedItem;
                myCircle.ShapeFillColor   = (EnumBrushingColor)cbSColor.SelectedItem;
                myCircle.ShapeType        = EnumShapeType.circle;

                ListOfShapes.Add(myCircle);
            }

            if (ListOfShapes.Count != 0)
            {
                this.listBoxShapes.Items.Clear();
                foreach (Shapes element in ListOfShapes)
                {
                    this.listBoxShapes.Items.Add(element);
                }
                this.btUp.Focus();
            }

            this.panelDraw.Invalidate();
            this.panelDraw.Update();
        }
Example #13
0
 internal static EllipseParameter GetEllipseParameters(Ellipses type)
 {
     return(m_Transforms[type]);
 }