Пример #1
0
 private void LblNew_Click(object sender, EventArgs e)
 {
     InitGraphics();
     GetFocus(lblGroup, false);
     DrawObj.Clear();
     pnlPaint.Refresh();
 }
Пример #2
0
        protected override void LoadContent()
        {
            Tools.Init(GraphicsDevice, Content, this);
            Global.Init();


            //online
            startScreen = new DrawObj(Tools.cm.Load <Texture2D>("screens/startScreen"), new Vector2(0), null, Color.White, 0, Vector2.Zero, new Vector2(0.24385f, 0.2154f), SpriteEffects.None, 0);
            //Texture2D[] copArray = Animation.loadTextures("copGif", 1);
            //Texture2D copF = copArray[0];
            //Engine copy = PhysicsManager.createAndGetNewEngine(50, 0.2f, 15, 1);

            //for (int i = 0; i < 200; i++)
            //{
            //    Global.copList.Add(new Cop("masks/policeCarM", copArray, new BotKeys(), Global.copList.Count + 2, copy,
            //    copF, new Vector2(0, -100), null, Color.White, 0, new Vector2(730, 1440),
            //           new Vector2(0.1f), 0, 0.1f, Tools.pm, 1.2f));
            //}

            //rankMl = new Rank(Global.copList);


            //camera
            leftVp  = new Viewport(0, 0, Tools.W / 2, Tools.H);
            rightVp = new Viewport(Tools.W / 2, 0, Tools.W / 2, Tools.H);

            Cme    = new Camera(Global.me, leftVp, Vector2.Zero, Global.zoom);
            Cenemy = new Camera(Global.player2, leftVp, Vector2.Zero, Global.zoom);

            //Global.cam = new Camera(Global.me, new Viewport(0, 0, Tools.W, Tools.H), Vector2.Zero, Global.zoom);
        }
Пример #3
0
 protected void WriteCharacterData(DrawObj c)
 {
     WriteAndReadClasses.WriteNecceryUpdataData(writer, Global.me, Global.bg.obstacleList);
     //writer.Write(c.pos.X);
     //writer.Write(c.pos.Y);
     //writer.Write(c.rot);
 }
Пример #4
0
        /// <summary>
        /// Dùng để tạo mới một đối tượng hình ảnh, dựa vào giá trị thiết lập hiện tại của người dùng
        /// </summary>
        private void AddShape()
        {
            Brush brush = CreateBrush();
            Pen   pen   = new Pen(color: lblBorderColor.BackColor, width: trbPenWidth.Value)
            {
                DashStyle = (DashStyle)cmbDashStyle.SelectedIndex,
            };

            switch (MyShape)
            {
            case SHAPES.LINE: DrawObj.Add(new MyLine(pen, brush)); break;

            case SHAPES.ELLIPSE: DrawObj.Add(new MyEllipse(pen, brush)); break;

            case SHAPES.RECTANGLE: DrawObj.Add(new MyRectangle(pen, brush)); break;

            case SHAPES.CURVE: DrawObj.Add(new MyCurve(pen, brush)); break;

            case SHAPES.CLOSEDCURVE: DrawObj.Add(new MyClosedCurve(pen, brush)); break;

            case SHAPES.POLYGON: DrawObj.Add(new MyPolygon(pen, brush)); break;

            case SHAPES.CUSTOM: DrawObj.Add(new MyPath(pen, brush)); break;

            case SHAPES.ARC: DrawObj.Add(new MyArc(pen, brush, trbStartAngle.Value, trbSweepAngle.Value)); break;
            }
            DrawObj[DrawObj.Count - 1].IsFilled     = this.Fill;
            DrawObj[DrawObj.Count - 1].IsDrawBorder = ckbBorder.Checked;
        }
Пример #5
0
        private static void InitPropertyDict()
        {
            //drawobj
            int count = DrawObj.GetPropertyNames().Length;

            for (int i = 0; i < count; i++)
            {
                _propertyIndexDict.Add(DrawObj.GetPropertyNames()[i], new PropertyIndex((int)DrawType.Obj, i));
            }

            //drawvector
            count = DrawVector.GetPropertyNames().Length;
            for (int i = 0; i < count; i++)
            {
                _propertyIndexDict.Add(DrawVector.GetPropertyNames()[i], new PropertyIndex((int)DrawType.Vector, i));
            }

            //drawtext
            count = DrawText.GetPropertyNames().Length;
            for (int i = 0; i < count; i++)
            {
                _propertyIndexDict.Add(DrawText.GetPropertyNames()[i], new PropertyIndex((int)DrawType.Text, i));
            }

            //todo add control:variable
        }
Пример #6
0
 private void MouseDown_Select(Point eLocation)
 {
     //Nếu nhấn phím CTRL, sẽ chọn đồng thời nhiều shape. Nếu hình đã chọn mà chọn lần 2, sẽ thành bỏ chọn
     if (IsCTRL_pressed)
     {
         DrawObj.ForEach((Action <MyShapes>)(shape =>
         {
             if (shape.Select(eLocation))
             {
                 shape.IsSelected = !shape.IsSelected;
             }
         }));
     }
     //Nếu không nhấn CTRL, chỉ có thể chọn duy nhất 1 hình rồi return
     else
     {
         SelectedShape = SelectShape(eLocation);
         FirstPoint    = eLocation;
         if (SelectedShape != null)
         {
             UpdateInfo();
             if (IsZooming)
             {
                 SelectedShape.SelectPoint(eLocation);
             }
             IsDrawRegion = false;
         }
         else    //Draw a rectangle region
         {
             IsDrawRegion   = true;
             SelectedRegion = new Rectangle(eLocation, new Size(0, 0));
         }
     }
     RePaint();
 }
Пример #7
0
        private void CmbPenType_SelectedIndexChanged(object sender, EventArgs e)
        {
            pnlHatchFill.Visible   = false;
            pnlTextFill.Visible    = false;
            pnlLinearAngle.Visible = false;
            switch ((PenType)cmbPenType.SelectedIndex)
            {
            case PenType.HatchFill:
                pnlHatchFill.Visible = true;
                break;

            case PenType.PathGradient:
            case PenType.LinearGradient:
                pnlLinearAngle.Visible = true;
                break;

            case PenType.TextureFill:
                pnlTextFill.Visible = true;
                pnlPaint.Refresh();
                break;
            }
            DrawObj.ForEach(shape =>
            {
                if (shape.IsSelected)
                {
                    shape.Brush = CreateBrush();
                }
            });
            UpdateSelectedShape();
            pnlPaint.Focus();
        }
Пример #8
0
        private void FrmMain_KeyDown(object sender, KeyEventArgs e)
        {
            IsCTRL_pressed = e.Control;
            lblGroup.Tag   = false;
            GetFocus(lblGroup, false);
            pnlPaint.Focus();
            switch (e.KeyCode)
            {
            case Keys.Delete:
            case Keys.Back:
                for (int i = 0; i < DrawObj.Count; i++)
                {
                    if (DrawObj[i].IsSelected)
                    {
                        DrawObj.RemoveAt(i--);
                    }
                }
                break;

            case Keys.A:
                if (IsCTRL_pressed)
                {
                    GetFocus(lblSelect, true);
                    CurrentACTION = ACTION.SELECT;
                    DrawObj.ForEach(shape => shape.IsSelected = true);
                }
                break;
            }
            RePaint();
        }
Пример #9
0
        private void InitList()
        {
            _list = new List <IPropertyExpression>();

            //drawobj
            string[] names = DrawObj.GetPropertyNames();
            int      count = names.Length;

            for (int i = 0; i < count; i++)
            {
                AddParameter(names[i]);
            }

            //drawvector
            if (_container.IsVector)
            {
                names = DrawVector.GetPropertyNames();
                count = names.Length;
                for (int i = 0; i < count; i++)
                {
                    AddParameter(names[i]);
                }
            }

            //draw child
            if (_container.PropertyNames != null)
            {
                count = _container.PropertyNames.Length;
                for (int i = 0; i < count; i++)
                {
                    AddParameter(_container.PropertyNames[i]);
                }
            }
        }
Пример #10
0
        public override void StartResearch()
        {
            stepNumber = 0;
            if (DrawObj != null)
            {
                DrawObj.StepNumber = stepNumber;
            }

            Debug.Assert(MWindow.Start.Content.ToString() == "Start");
            MWindow.Start.Content = "Stop";


            // *tmp
            //StepCount = 3;
            //StepCount = 4;

            MWindow.Initial.IsEnabled  = false;
            MWindow.Final.IsEnabled    = true;
            MWindow.Next.IsEnabled     = true;
            MWindow.Previous.IsEnabled = false;
            MWindow.Save.IsEnabled     = true;

            if ((bool)MWindow.Flat.IsChecked)
            {
                if (DrawObj != null)
                {
                    HierarchicDraw hierDraw = DrawObj as HierarchicDraw;
                    hierDraw.IsFlat = true;
                }
            }

            DrawObj.DrawInitial();
        }
Пример #11
0
        private void DrawAcivationStep()
        {
            BitArray step = LabSessionManager.GetActivationStep(ResearchStepNumber);

            for (int j = 0; j < step.Count; ++j)
            {
                DrawObj.ActivateOrDeactivateVertex(j, step[j]);
            }
        }
Пример #12
0
 /// <summary>
 /// drawing a single object all over the screen
 /// </summary>
 /// <param name="d"></param>
 public static void DrawSingle(DrawObj d)
 {
     grd.Viewport = new Viewport(0, 0, Tools.W, Tools.H);
     grd.Clear(Color.CornflowerBlue);
     Tools.sb.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend,
                    null, null, null, null, null);
     d.draw();
     Tools.sb.End();
 }
Пример #13
0
        /// <summary>
        /// Draw Object를 추가 한다.
        /// </summary>
        /// <param name="obj"></param>
        public void AddDrawObbject(DrawObj obj)
        {
            if (obj == null)
            {
                return;
            }

            DrawObjectList.Add(obj);
        }
        public ConstructionMenuControl(string id, string _strControlHeader, DrawObj.Sprite _background)
        {
            ID = id;
            strControlHeader = _strControlHeader;
            menuBackground = _background;

            menuButtons = new List<FancyButtonControl>();
            destinationDropDown = new FancyDropDownBoxControl();
            facilityTypeDropDown = new FancyDropDownBoxControl();
        }
Пример #15
0
 private void CmbDashStyle_SelectedIndexChanged(object sender, EventArgs e)
 {
     DrawObj.ForEach(shape =>
     {
         if (shape.IsSelected)
         {
             shape.Pen.DashStyle = (DashStyle)cmbDashStyle.SelectedIndex;
         }
     });
     RePaint();
 }
Пример #16
0
        /// <summary>
        /// Dùng để tạo ra 1 bitmap từ graphics
        /// </summary>
        /// <returns>1 bitmap </returns>
        private Bitmap CreateImage()
        {
            DrawObj.ForEach(shape => shape.IsSelected = false);
            RePaint();
            Bitmap    bitmap = new Bitmap(pnlPaint.Width, pnlPaint.Height);
            Graphics  graph  = Graphics.FromImage(bitmap);
            Rectangle rect   = pnlPaint.RectangleToScreen(pnlPaint.ClientRectangle);

            graph.CopyFromScreen(rect.Location, Point.Empty, pnlPaint.Size);
            return(bitmap);
        }
Пример #17
0
        private void DrawFinal()
        {
            stepNumber = LabSessionManager.GetStepCount() - 1;
            MWindow.mainCanvas.Children.Clear();
            DrawObj.DrawFinal();
            MWindow.TextBoxStepNumber.Text = stepNumber.ToString();

            MWindow.Next.IsEnabled     = false;
            MWindow.Previous.IsEnabled = true;
            MWindow.Initial.IsEnabled  = true;
            MWindow.Final.IsEnabled    = false;
        }
Пример #18
0
        /// <summary>
        /// this function checks the collsion of two circles represent objects area
        /// </summary>
        /// <param name="obstacleC">the obstacle circle</param>
        /// <param name="obstacle">the obstacle</param>
        /// <param name="Obstaclescale">obstacle scale</param>
        /// <param name="player">the second object usuually the player</param>
        /// <param name="playerC">the circle of the second obj</param>
        /// <returns></returns>
        public static Boolean TwoCircles(Circle obstacleC, DrawObj obstacle, DrawObj player, Circle playerC)
        {
            float   Obstaclescale = obstacle.scale.X;
            Vector2 div           = ((obstacle.Position - (obstacle.Origin * Obstaclescale) + (obstacleC.position * Obstaclescale))
                                     - (player.Position - (player.Origin * player.scale) + (playerC.position * player.scale)));

            if (div.Length() < ((obstacleC.radius * obstacle.scale.X) + (playerC.radius * player.scale.X)))
            {
                return(true);
            }
            return(false);
        }
Пример #19
0
 private void CmbHatchFill_SelectedIndexChanged(object sender, EventArgs e)
 {
     DrawObj.ForEach(shape =>
     {
         if (shape.IsSelected)
         {
             shape.Brush = new HatchBrush((HatchStyle)cmbHatchFill.SelectedIndex, Color.Blue);
         }
     });
     UpdateSelectedShape();
     RePaint();
 }
Пример #20
0
 private bool Group()
 {
     if (DrawObj.Count(shape => shape.IsSelected) > 1)
     {
         DrawObj.Add(new Group(DrawObj));
         return(true);
     }
     else
     {
         return(false);
     }
 }
Пример #21
0
        public void OnInitialButtonClick()
        {
            stepNumber                     = 0;
            DrawObj.StepNumber             = stepNumber;
            MWindow.TextBoxStepNumber.Text = stepNumber.ToString();
            MWindow.mainCanvas.Children.Clear();
            DrawObj.DrawInitial();

            MWindow.Initial.IsEnabled  = false;
            MWindow.Final.IsEnabled    = true;
            MWindow.Next.IsEnabled     = true;
            MWindow.Previous.IsEnabled = false;
        }
Пример #22
0
        public void OnPreviousButtonClick()
        {
            MWindow.Next.IsEnabled  = true;
            MWindow.Final.IsEnabled = true;
            DrawObj.StepNumber      = stepNumber - 1;
            DrawObj.DrawPrevious(stepNumber);
            stepNumber--;

            if (stepNumber == 0)
            {
                MWindow.Previous.IsEnabled = false;
                MWindow.Initial.IsEnabled  = false;
            }
            MWindow.TextBoxStepNumber.Text = stepNumber.ToString();
        }
Пример #23
0
        public void OnNextButtonClick()
        {
            MWindow.Previous.IsEnabled = true;
            MWindow.Initial.IsEnabled  = true;

            stepNumber++;
            DrawObj.StepNumber = stepNumber;
            DrawObj.DrawNext(stepNumber);
            if (stepNumber == StepCount - 1)
            {
                MWindow.Next.IsEnabled  = false;
                MWindow.Final.IsEnabled = false;
            }
            MWindow.TextBoxStepNumber.Text = stepNumber.ToString();
        }
Пример #24
0
        public static Boolean isInFrame(Camera cm, DrawObj f)
        {
            Matrix  mat = cm.Mat;
            Vector2 tmp = new Vector2(f.Position.X + (f.CurrentFrame.Width - f.Origin.X) * f.scale.X,
                                      f.Position.Y + (f.CurrentFrame.Height - f.Origin.Y) * f.scale.Y);

            tmp = Vector2.Transform(tmp, mat);
            if (tmp.X < cm.vp.Width && tmp.X > 0)
            {
                if (tmp.Y < cm.vp.Height && tmp.Y > 0)
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #25
0
        /// <summary>
        /// Rendering 초기화작업
        /// </summary>
        public void RenderInit()
        {
            DrawModelManager = new ModelManager(dx_Device);
            DrawModelManager.CreateDrawModel(dx_Device, ModelManager.ROBOT, "Robot.dds");
            DrawModelManager.CreateDrawModel(dx_Device, ModelManager.HAZARD, "Hazard.jpg");
            DrawModelManager.CreateDrawModel(dx_Device, ModelManager.COLOR, "ColorBlob.png");


            RobotObj = new DrawObj(dx_Device, ModelManager.ROBOT);

            //움직임 초기화
            RobotMover = new ModelActionController(RobotObj);

            MainCamera = new Camera(dx_Device);
            UIState    = UI_READY;
        }
Пример #26
0
 private void RemoveEdges()
 {
     for (int i = 0; i < edgesToRemove.Count; i++)
     {
         string edgeUid = DrawObj.GenerateEdgeUid(edgesToRemove[i]);
         for (int j = 0; j < MWindow.mainCanvas.Children.Count; j++)
         {
             if (MWindow.mainCanvas.Children[j].Uid == edgeUid)
             {
                 MWindow.mainCanvas.Children.RemoveAt(j);
                 break;
             }
         }
     }
     edgesToRemove.Clear();
 }
Пример #27
0
 public override void StartResearch()
 {
     //MWindow.Start.Content = "Stop";
     MWindow.Start.IsEnabled = false;
     MWindow.mainCanvas.Children.Clear();
     MWindow.ChartData = null;
     activesCount.Clear();
     ResearchStepNumber = 0;
     UpdateStepNumber();
     Dispatcher.CurrentDispatcher.Invoke(DispatcherPriority.Background, new Action(() =>
     {
         DrawObj.DrawFinal();
     }));
     DrawActivationProcess();
     MWindow.Start.IsEnabled = true;
     //MWindow.Start.Content = "Start";
 }
Пример #28
0
        private void PrepareEdgeToRemove(EdgesAddedOrRemoved edge)
        {
            edgesToRemove.Add(edge);

            string edgeUid = DrawObj.GenerateEdgeUid(edge);

            for (int j = 0; j < MWindow.mainCanvas.Children.Count; j++)
            {
                if (MWindow.mainCanvas.Children[j].Uid == edgeUid)
                {
                    Line line = (Line)MWindow.mainCanvas.Children[j];
                    line.Stroke          = (SolidColorBrush) new BrushConverter().ConvertFromString("#ff0000");
                    line.StrokeThickness = 2;
                    break;
                }
            }
        }
Пример #29
0
        private void AddEdge(EdgesAddedOrRemoved edge)
        {
            edgesToChangeColor.Add(edge);

            Line edgeElem = new Line
            {
                Uid             = DrawObj.GenerateEdgeUid(edge),
                Stroke          = (SolidColorBrush) new BrushConverter().ConvertFromString("#006600"),
                StrokeThickness = 2,
                X1 = DrawObj.Vertices[edge.Vertex1].X,
                Y1 = DrawObj.Vertices[edge.Vertex1].Y,
                X2 = DrawObj.Vertices[edge.Vertex2].X,
                Y2 = DrawObj.Vertices[edge.Vertex2].Y
            };

            MWindow.mainCanvas.Children.Add(edgeElem);
        }
Пример #30
0
        public static float GroupMiddlePosX(List <Obstacle> ol, DrawObj character)
        {
            float characterRightPos = character.Position.X - ((character.Origin.X + character.CurrentFrame.Width) * character.scale.X);
            float obstacleWidth     = ol[0].CurrentFrame.Width * ol[0].scale.X;
            float X = 0;

            for (int i = 0; i < ol.Count - 2; i++)
            {
                float obstacleLeftPos = (ol[i].Position - (ol[i].Origin * ol[i].scale)).X;
                if (obstacleLeftPos > characterRightPos)
                {
                    X += obstacleWidth;
                    int tmpI = i + 1;
                    int cnt  = 1;
                    while (obstacleLeftPos + (obstacleWidth * cnt) + 10 >= (ol[tmpI].Position.X - (ol[tmpI].Origin.X * ol[tmpI].scale.X)))
                    {
                        X += obstacleWidth;
                        cnt++;
                        tmpI++;
                    }
                    return((X / 2) + obstacleLeftPos);
                }
            }


            for (int i = ol.Count - 2; i < ol.Count; i++)
            {
                float obstacleLeftPos = (ol[i].Position - (ol[i].Origin * ol[i].scale)).X;
                if (obstacleLeftPos > characterRightPos)
                {
                    int cnt = 1;
                    X += obstacleWidth;
                    int tmpI = i + 1;
                    while (tmpI < ol.Count && obstacleLeftPos + (obstacleWidth * cnt) + 10 >= (ol[tmpI].Position.X - (ol[tmpI].Origin.X * ol[tmpI].scale.X)))
                    {
                        X += obstacleWidth;
                        cnt++;
                        tmpI++;
                    }
                    return((X / 2) + obstacleLeftPos);
                }
            }
            Global.restartBots = true;
            return(0);
        }
Пример #31
0
 private void FixAddedEdes()
 {
     for (int i = 0; i < edgesToChangeColor.Count; i++)
     {
         string edgeUid = DrawObj.GenerateEdgeUid(edgesToChangeColor[i]);
         for (int j = 0; j < MWindow.mainCanvas.Children.Count; j++)
         {
             if (MWindow.mainCanvas.Children[j].Uid == edgeUid)
             {
                 Line line = (Line)MWindow.mainCanvas.Children[j];
                 line.Stroke          = (SolidColorBrush) new BrushConverter().ConvertFromString("#323336");
                 line.StrokeThickness = 1;
                 break;
             }
         }
     }
     edgesToChangeColor.Clear();
 }