示例#1
0
        private void Draw(object[] stringArray, Color clientColor)
        {
            using (Graphics graphics = Graphics.FromImage(DrawBox.Image))
            {
                if (stringArray[4].ToString() == "True")
                {
                    graphics.DrawLine(new Pen(Color.White, 1), new Point(Convert.ToInt32(stringArray[0]), Convert.ToInt32(stringArray[1])), new Point(Convert.ToInt32(stringArray[2]), Convert.ToInt32(stringArray[3])));
                }
                else
                {
                    graphics.DrawLine(new Pen(clientColor, 1), new Point(Convert.ToInt32(stringArray[0]), Convert.ToInt32(stringArray[1])), new Point(Convert.ToInt32(stringArray[2]), Convert.ToInt32(stringArray[3])));
                }
            }

            foreach (StreamWriter streamWriter in streamWriters)
            {
                if (stringArray[4].ToString() == "True")
                {
                    string dataString = stringArray[0] + "." + stringArray[1] + "." + stringArray[2] + "." + stringArray[3] + "." + Color.White.Name;
                    streamWriter.WriteLine(dataString);
                }
                else
                {
                    string dataString = stringArray[0] + "." + stringArray[1] + "." + stringArray[2] + "." + stringArray[3] + "." + clientColor.Name;
                    streamWriter.WriteLine(dataString);
                }
                Thread.Sleep(1);
                streamWriter.Flush();
            }
            DrawBox.Invalidate();
        }
示例#2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            Config();

            Globals.Game = this;

            Menu.EditorData.Load(Globals.EditorDataSaveDir);

            DrawBox.InitializeDefaultServices(this, graphics, defaultSkin);

            DrawBox.KeyboardInput.Enabled = false;
            DrawBox.MouseInput.Enabled    = false;

            var guiManager = new GUIManager(this);

            guiManager.Initialize();
            guiManager.Enabled = false;
            guiManager.Visible = false;
            Services.AddService(typeof(GUIManager), guiManager);
            Globals.GUIManager = guiManager;

            Push.InitializeServices(DrawBox.Debug);

            Globals.Random         = new EvoSim.RandomNumberGenerators.UniformRandomGenerator();
            Globals.GaussianRandom = new EvoSim.RandomNumberGenerators.NormalRandomGenerator(0, 1000, Globals.Random);             //Initialize the Gaussian with the same random nubmer generator.

            Pseudo.Static_Random         = Globals.Random;
            Pseudo.Static_GaussianRandom = Globals.GaussianRandom;

            //StateManager.Push(new States.InitializeState(), new GameTime());
            StateManager.Push(new States.InitializeState(), new GameTime());
        }
示例#3
0
 public PartialDrawBox(DrawBox drawBox)
 {
     MarginBox  = drawBox.MarginBox;
     BorderBox  = drawBox.BorderBox;
     PaddingBox = drawBox.PaddingBox;
     ContentBox = drawBox.ContentBox;
 }
示例#4
0
        public void SelectDrawBox(DrawBox selected)
        {
            if (selected != null)
            {
                if (!DrawBoxList.Contains(selected))
                {
                    Debug.AddExceptionInClass(this.GetType(), "SelectDrawBox", "Selected drawbox is not part of this container");
                    return;
                }

                SelectedDrawBox    = selected;
                selected.Activated = true;
            }
            else
            {
                SelectedDrawBox = null;
            }

            foreach (DrawBox box in DrawBoxList)
            {
                if (selected != box)
                {
                    box.Activated = false;
                }
            }

            if (oldSelected != SelectedDrawBox && HasSwitched != null)
            {
                HasSwitched(this, SelectedDrawBox);
            }
        }
示例#5
0
 private void Draw(object[] stringArray)
 {
     using (Graphics graphics = Graphics.FromImage(DrawBox.Image))
     {
         graphics.DrawLine(new Pen(Color.FromName((string)stringArray[4]), 1), new Point(Convert.ToInt32(stringArray[0]), Convert.ToInt32(stringArray[1])), new Point(Convert.ToInt32(stringArray[2]), Convert.ToInt32(stringArray[3])));
     }
     DrawBox.Invalidate();
 }
示例#6
0
 private void DrawBox_MouseMove(object sender, MouseEventArgs e)
 {
     if (Drawing)
     {
         Line.SecondPoint = new Point(e.X, e.Y);
         DrawBox.Refresh();
     }
 }
示例#7
0
        public override void Idle(Microsoft.Xna.Framework.GameTime gameTime)
        {
            base.Idle(gameTime);

            SelectDrawBox(SelectedDrawBox);

            oldSelected = SelectedDrawBox;
        }
示例#8
0
        public void Test3_1_Tuples()
        {
            var b1 = new Tuple <Double, Double>(0, 0);

            var b2 = new DrawBox <Tuple <Double, Double> >(new Tuple <double, double, double>(0, 0, 0), new Tuple <double, double>(0, 0));

            Assert.Equal(b1, b2.Shape); //structural equality
        }
示例#9
0
 private void DrawLine(Factory.IAbstractFactory factory)
 {
     Brush.IBrush brush = factory.CreateBrush();
     brush.SetGraph(g);
     brush.SetColor(currentColor);
     brush.SetSize(size);
     brush.Draw(g, prevPoint, currentPoint);
     DrawBox.Invalidate();
 }
示例#10
0
      private void ClearButton_Click(object sender, EventArgs e)
      {
          Graphics   draw  = DrawBox.CreateGraphics();
          Brush      clear = new SolidBrush(DrawBox.BackColor);
          RectangleF Clear = new RectangleF(0, 0, DrawBox.Width, DrawBox.Height);

          draw.FillRectangle(clear, Clear);
          shapes = null;
      }
示例#11
0
        private void DrawBox_MouseMove(object sender, MouseEventArgs e)
        {
            if (isMouseDown == true && originPoint != null)
            {
                SendData(originPoint.X.ToString(), originPoint.Y.ToString(), e.Location.X.ToString(), e.Location.Y.ToString());

                DrawBox.Invalidate();
                originPoint = e.Location;
            }
        }
示例#12
0
      private void DrawButton_Click(object sender, EventArgs e)
      {
          if (shapes == null)
          {
              shapes = new List <Shape>();
          }
          Graphics draw = DrawBox.CreateGraphics();
          int      randomShape;

          if (checkBoxColorOfShapes.Checked)
          {
              color = colorDialog.Color;
          }
          else
          {
              color = Color.FromArgb(rnd.Next(256), rnd.Next(256), rnd.Next(256));
          }
          for (int i = 0; i < trackBarDrawings.Value; i++)
          {
              switch (randomShape = rnd.Next(0, 5))
              {
              case 0:
                  shapes.Add(new Point(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                       pen = new Pen(color, 2)));
                  break;

              case 1:
                  shapes.Add(new Line(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                      rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                      pen = new Pen(color, 2)));
                  break;

              case 2:
                  shapes.Add(new Rectangle(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                           rnd.Next(0, DrawBox.Width), rnd.Next(DrawBox.Height),
                                           pen = new Pen(color, 2)));
                  break;

              case 3:
                  shapes.Add(new Circle(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                        rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                        pen = new Pen(color, 2)));
                  break;

              case 4:
                  shapes.Add(new Ellipse(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                         rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                         pen = new Pen(color, 2)));
                  break;
              }
          }
          DrawBox.Refresh();
      }
示例#13
0
 public void AddEntry(Tabular t, DrawBox Titel, DrawBox Content)
 {
     int n = t.Rows;
     t.addRow();
     t.addRow();
     t.addRow();
     t.setRowPen(n, Line);
     t.setRowPen(n + 1, HalbLine);
     t.setRowPen(n + 2, Line);
     t[n + 1, 0] = Titel;
     t[n + 2, 0] = Content.Geometry(2);
 }
示例#14
0
        public Form1()
        {
            _5pW   = _5pL = _5pD = 0;
            p5flag = drawflag = imgflag = whsflag = true;
            this.Hide();
            this.Location = new Point(150, 150);
            //this.ShowInTaskbar = true;
            InitializeComponent();


            //Gomoku a = new Gomoku();
            //a.ShowDialog();

            this.ShowInTaskbar = true;

            trackBar1.Hide();
            ColorBox.Hide();
            button2.Hide();

            Login log = new Login();

            log.ShowDialog();
            if (log.DialogResult == DialogResult.Cancel)
            {
                this.Close();
            }
            else
            {
                this.Show();
                //this.ShowInTaskbar = true;
                SetUpData init = log.Get();
                Username = init.UserName;


                MLabel.Hide();
                //Box.ForeColor = Bcolor;
                UserBox.DataSource = UserList;
                myGraphic          = DrawBox.CreateGraphics();
                DrawBox.BringToFront();

                c.Setup(init.IP, init.Port);


                //addMsg("2.成功連線");

                msgHandler = this.addMsg;
                dwHandler  = this.addDw;
                imgHandler = this.ShowPic;
                c.Recv(processMsgComeIn, processDwComeIn, processImgComeIn);

                //MessageBox.Show("歡迎加入~");
            }
        }
示例#15
0
      private void button1_Click(object sender, EventArgs e)
      {
          Pen pen;

          if (shapes == null)
          {
              shapes = new List <Shape>();
          }
          if (checkBoxColorOfShapes.Checked)
          {
              color = colorDialog.Color;
          }
          else
          {
              color = Color.FromArgb(rnd.Next(256), rnd.Next(256), rnd.Next(256));
          }
          for (int i = 0; i < trackBarDrawings.Value; i++)
          {
              switch (comboBoxAdd.SelectedIndex)
              {
              case 0:
                  shapes.Add(new Point(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                       pen = new Pen(color, 2)));
                  break;

              case 1:
                  shapes.Add(new Line(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                      rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                      pen = new Pen(color, 2)));
                  break;

              case 2:
                  shapes.Add(new Rectangle(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                           rnd.Next(0, DrawBox.Width), rnd.Next(DrawBox.Height),
                                           pen = new Pen(color, 2)));
                  break;

              case 3:
                  shapes.Add(new Circle(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                        rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                        pen = new Pen(color, 2)));
                  break;

              case 4:
                  shapes.Add(new Ellipse(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                         rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                         pen = new Pen(color, 2)));
                  break;
              }
          }
          DrawBox.Refresh();
      }
示例#16
0
        public void AddDrawBoxAsField(DrawBox drawBox, DrawBoxAlignment drawBoxAlignment)
        {
            container.AddDrawBox(drawBox);

            if (lastField.Count != 0)
            {
                drawBox.Y = Push.GetBottomSide(lastField.ToArray()) + VerticalMargin + extraVerticalMargin;
            }

            alignments.Add(drawBox, drawBoxAlignment);

            AddNewFieldList();
            lastField.Add(drawBox);
        }
示例#17
0
 public void RemoveDrawBox(DrawBox drawBox)
 {
     for (int x = 0; x < SlotArray.GetLength(0); x++)
     {
         for (int y = 0; y < SlotArray.GetLength(1); y++)
         {
             if (SlotArray[x, y] != null && SlotArray[x, y].DrawBox == drawBox)
             {
                 RemoveSlotAt(x, y);
                 return;
             }
         }
     }
 }
示例#18
0
 public void AddDrawBox(DrawBox drawBox)
 {
     for (int y = 0; y < SlotArray.GetLength(1); y++)
     {
         for (int x = 0; x < SlotArray.GetLength(0); x++)
         {
             if (SlotArray[x, y] == null)
             {
                 SetDrawBoxAt(drawBox, x, y);
                 return;
             }
         }
     }
 }
示例#19
0
      private void buttonRemove_Click(object sender, EventArgs e)
      {
          int number = (int)numericUpDownNumOfShape.Value;

          if (shapes == null)
          {
              shapes = new List <Shape>();
          }
          if (number < shapes.Count)
          {
              shapes.RemoveAt(number);
              DrawBox.Refresh();
          }
      }
示例#20
0
        protected override void DrawBoxHasBeenAdded(DrawBox box, SlotBox.SlotHandler handler)
        {
            base.DrawBoxHasBeenAdded(box, handler);

            foreach (var d in DrawBoxList)
            {
                if (d.Y + d.Height > highestY)
                {
                    highestY = d.Y + d.Height;
                }
            }

            Scrollbar.Height   = Height;
            Scrollbar.MaxValue = highestY - Height;
        }
示例#21
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (textBoxChangeX.Text == null)
     {
         textBoxChangeX.Text = "0";
     }
     if (textBoxChangeY.Text == null)
     {
         textBoxChangeY.Text = "0";
     }
     if (shapes != null && textBoxChangeX.Text != "0" && textBoxChangeY.Text != "0")
     {
         shapes[(int)numericUpDownNumOfShape.Value].CoordsChange(int.Parse(textBoxChangeX.Text), int.Parse(textBoxChangeY.Text));
         DrawBox.Refresh();
     }
 }
示例#22
0
 private void checkBox1_CheckedChanged(object sender, EventArgs e)
 {
     onDraw = !onDraw;
     if (onDraw == true)
     {
         DrawBox.BringToFront();
         DrawBox.Focus();
         //for (int i = 0; i < px.Count; i++)
         //{
         //  myGraphic.FillEllipse(myBrush, py[i], px[i], Bsize, Bsize);
         //}
     }
     else
     {
         DrawBox.Parent.Invalidate(new Rectangle(DrawBox.Location, DrawBox.Size), true);
     }
 }
示例#23
0
        public void SetDrawBoxAt(DrawBox drawBox, int x, int y)
        {
            if (SlotArray[x, y] != null)
            {
                RemoveDrawBoxInSlot(SlotArray[x, y]);
            }

            SlotArray[x, y] = AddNewSlot();

            if (drawBox != null)
            {
                PutDrawBoxInSlot(drawBox, SlotArray[x, y]);
                drawBox.SizeChanged += new SizeChangedEvent(drawBox_SizeChanged);
            }

            CheckSize();
        }
示例#24
0
        protected override void DrawBoxHasBeenRemoved(DrawBox box, SlotBox.SlotHandler handler)
        {
            base.DrawBoxHasBeenRemoved(box, handler);

            if (DrawBoxList.Count != 0)
            {
                SelectDrawBox(DrawBoxList[0]);
            }

            foreach (var pair in drawBoxesWithKey)
            {
                if (pair.Value == box)
                {
                    drawBoxesWithKey.Remove(pair.Key);
                    break;
                }
            }
        }
示例#25
0
        public void SelectNext()
        {
            int index = DrawBoxList.IndexOf(SelectedDrawBox);

            index++;

            if (index >= DrawBoxList.Count)
            {
                index = 0;
            }

            SelectedDrawBox = DrawBoxList[index];

            if (oldSelected != SelectedDrawBox && HasSwitched != null)
            {
                HasSwitched(this, SelectedDrawBox);
            }
        }
示例#26
0
 private void buttonMoveAll_Click(object sender, EventArgs e)
 {
     if (textBoxChangeX.Text == null)
     {
         textBoxChangeX.Text = "0";
     }
     if (textBoxChangeY.Text == null)
     {
         textBoxChangeY.Text = "0";
     }
     if (shapes != null && textBoxChangeX.Text != "0" && textBoxChangeY.Text != "0")
     {
         for (int i = 0; i < shapes.Count; i++)
         {
             shapes[i].CoordsChange(int.Parse(textBoxChangeX.Text), int.Parse(textBoxChangeY.Text));
         }
         DrawBox.Refresh();
     }
 }
示例#27
0
 /// <summary>
 /// Updates particles and cleans up particle array
 /// </summary>
 public void ParticleLifeCycle()
 {
     try
     {
         for (;;)
         {
             Thread.Sleep(20);
             _manager.UpdateParticles();
             Invoke((MethodInvoker)(() =>
             {
                 DrawBox.Invalidate();
                 DrawBox.Update();
             }));
         }
     }
     catch (ThreadAbortException ex)
     {
         Debug.Print("Particle display Thread aborted.");
     }
 }
示例#28
0
        public String addDw(String str)
        {
            DrawBox.BringToFront();
            myGraphic = DrawBox.CreateGraphics();

            String[]   Words  = str.Split('.');
            int        Nsize  = Int32.Parse(Words[1]);
            Color      Ncolor = System.Drawing.ColorTranslator.FromHtml(Words[2]);
            SolidBrush NBrush = new SolidBrush(Ncolor);
            int        i      = 0;

            try
            {
                for (i = 3; Words[i] != "!"; i += 2)
                {
                    if (i < Words.Length)
                    {
                        try
                        {
                            x = Int32.Parse(Words[i + 1]);
                            y = Int32.Parse(Words[i]);
                            px.Add(x);
                            py.Add(y);
                            if (onDraw == true)
                            {
                                myGraphic.FillEllipse(NBrush, y, x, Nsize, Nsize);
                            }
                        }
                        catch
                        {
                            MessageBox.Show(Words[i + 1]);
                        }
                    }
                }
            }
            catch
            {
                MessageBox.Show("畫太多了唷!");
            }
            return("OK");
        }
示例#29
0
        // Postition
        private DrawBox CalculatePositions(CoreUIDomElement element, DrawBox box)
        {
            var style           = element.Style;
            var marginBox       = box.MarginBox;
            var borderBox       = box.BorderBox;
            var paddingBox      = box.PaddingBox;
            var contentBox      = box.ContentBox;
            var parentLocation  = element.Parent.DrawBox.ContentBox.Location;
            var location        = parentLocation;
            var previousSibling = element.Previous();

            if (previousSibling != null)
            {
                if (element.Style.Display == DisplayStyle.Block)
                {
                    location = location + new Size(0, previousSibling.DrawBox.BorderBox.Location.Y);
                }

                var previousElement = previousSibling as CoreUIDomElement;

                if (previousElement != null)
                {
                }
            }


            marginBox.Location  = location;
            borderBox.Location  = style.Margin.GetDrawPosition(marginBox);
            paddingBox.Location = style.Border.Box.GetDrawPosition(borderBox);
            contentBox.Location = style.Padding.GetDrawPosition(paddingBox);

            return(new DrawBox
            {
                BorderBox = borderBox,
                ContentBox = contentBox,
                MarginBox = marginBox,
                PaddingBox = paddingBox
            });
        }
示例#30
0
        // Height

        private DrawBox CalculateHeight(CoreUIDomElement element, DrawBox currentBox)
        => element.Style.Display switch
        {
示例#31
0
        protected override void DrawBoxHasBeenAdded(DrawBox box, SlotBox.SlotHandler handler)
        {
            base.DrawBoxHasBeenAdded(box, handler);

            SelectDrawBox(box);
        }