コード例 #1
0
 public override void Draw(Graphics g)
 {
     if (Visible)
     {
         Propertys.AllDoBeforeDraw(g);
         DrawObject.Draw(g, Layout.Rectangle);
         BackObjects.AllDrawSelf(g);
         UIObjects.AllDrawSelf(g);
         Propertys.AllDoAfterDraw(g);
     }
 }
コード例 #2
0
        private void GraphicsPropertiesChangedHandler(DrawObject drawObject, GraphicsProperties graphicsProperties)
        {
            float pulseSize = SysConfig.GetSysConfig().LaserConfig.PulseSize;

            OutterCircleSize = new SizeF(this.GraphicsProperties.ExclusionSize + pulseSize,
                                         this.GraphicsProperties.ExclusionSize + pulseSize);
            InnerCircleSize = new SizeF(pulseSize, pulseSize);
            OutterCircle    = new Circle(CenterPoint, OutterCircleSize);
            InnerCircle     = new Circle(CenterPoint, InnerCircleSize);
            this.pictureBox.Invalidate();
        }
コード例 #3
0
        public Vector2D[] GetIntersectPositions(DrawObject drawObject0, DrawObject drawObject1, bool extendDrawObject0 = false)
        {
            if (drawObject0 == null || drawObject1 == null)
            {
                return(null);
            }

            if (drawObject0 is TDrawObject0 tDrawObject0 && drawObject1 is TDrawObject1 tDrawObject1)
            {
                return(GetIntersectPositions(tDrawObject0, tDrawObject1, extendDrawObject0));
            }
コード例 #4
0
ファイル: ListShapes.cs プロジェクト: IrinaIa/GraphicsEditor
 public void DeleteShape(DrawObject drawObject)
 {
     foreach (DrawObject o in list)
     {
         if (drawObject.ID ==
             o.ID)
         {
             list.Remove(o);
             return;
         }
     }
 }
コード例 #5
0
ファイル: Line.cs プロジェクト: mirror222/ZeroSystem
        public void DrawObject(Layer layer, DrawObject item)
        {
            Point[] cPoints = item.ConvertPoints(layer);
            bool    bDraw   = Boundary.BoundFix(ref cPoints[0], ref cPoints[1], new Rectangle4(layer.LayerRectangleWithoutAxisY));

            if (bDraw)
            {
                IntPtr cOldPen = __cGDI.SelectPen(item.Pens[0]);
                __cGDI.DrawLine(cPoints[0].X, cPoints[0].Y, cPoints[1].X, cPoints[1].Y);
                __cGDI.RemoveObject(__cGDI.SelectPen(cOldPen));
            }
        }
コード例 #6
0
        static void Main(string[] args)
        {
            DrawObject[] newobj = new DrawObject[3];
            newobj[0] = new line();
            newobj[1] = new Circle();
            newobj[2] = new Triangle();

            foreach (DrawObject drawObj in newobj)
            {
                drawObj.Draw();
            }
        }
コード例 #7
0
        protected void AddNewObject(DrawArea drawArea, DrawObject o)
        {
            drawArea.GraphicsList.UnselectAll();

            o.Selected = true;
            drawArea.GraphicsList.Add(o);

            drawArea.Capture = true;
            drawArea.Refresh();

            drawArea.SetDirty();
        }
        }         //public void StartListen()

        //根据请求的formid,这里为page1~n,即对应画面里的名称,获得该page里相关文本的xml格式数据,用以返回给web显示。
        //本程序中,其他图元的相关代码被注释掉了,需要的话,可以根据需要继续完善其他图元的相关信息。
        //返回给客户的XML数据格式为:,其中id为图元中属性id值,建议采用数字作为id
        //<objectlist>
        //<object id="1">
        //<value>12.3</value>
        //</object>
        //<object id="2">
        //<value>45.6</value>
        //</object>
        //</objectlist>
        public string GetFormWebXml(string formid)
        {
            string xml    = "<?xml version=\" & chr(34) & \"1.0\" & chr(34) & \"?><empty/></xml>";
            int    nCount = tabMain.TabPages.Count;

            for (int k = 0; k < nCount; k++)
            {
                VisualGraph.VisualGraph drawArea = (VisualGraph.VisualGraph)tabMain.TabPages[k].Controls[0];
                string s = tabMain.TabPages[k].Text;
                if (s.Equals(formid))
                {
                    using (StringWriter sw = new StringWriter())
                    {
                        XmlTextWriter writer = new XmlTextWriter(sw);
                        writer.WriteStartElement("objectlist");
                        int n = drawArea.ObjList.Count();
                        for (int i = 0; i < n; i++)
                        {
                            DrawObject o = drawArea.ObjList[i];
                            switch (o.ObjectType)
                            {
                            case Global.DrawType.DrawText:    //文本
                                DrawText m = (DrawText)o;
                                //xml make
                                if (m.textName != "")
                                {
                                    writer.WriteStartElement("object");
                                    writer.WriteAttributeString("id", m.ID.ToString());
                                    writer.WriteStartElement("value");
                                    writer.WriteString(m.CurText);
                                    writer.WriteEndElement();
                                    writer.WriteEndElement();
                                }
                                break;

                                /*
                                 * case 7://图片
                                 *  DrawPic m7 = (DrawPic)o
                                 *  writer.WriteStartElement("object");
                                 *  writer.WriteAttributeString("id", m7.Id);
                                 *  writer.WriteEndElement();
                                 *  break;*/
                            }
                        }
                        writer.WriteEndElement();
                        writer.Close();
                        xml = sw.ToString();
                        sw.Close();
                    }
                }
            }
            return(xml);
        }
コード例 #9
0
 public DrawFlowTable(DrawObject indrawObject)
 {
     drawObject = indrawObject;
     flowTable.Columns.Add(colName);
     colName.MaxLength = 2000;
     flowTable.Columns.Add(colInNode);
     flowTable.Columns.Add(colOutNode);
     flowTable.Columns.Add(colFunction);
     flowTable.Columns.Add(colRole);
     flowTable.Columns.Add(colInfo);
     nodeList = drawObject.NodeList;
 }
コード例 #10
0
ファイル: ObjectActive.cs プロジェクト: Aquars1989/RunningBox
 /// <summary>
 /// 繪製物件
 /// </summary>
 /// <param name="g">Graphics物件</param>
 public override void Draw(Graphics g)
 {
     if (Visible)
     {
         UIOffSetY = 0;
         Skills.AllDoBeforeDraw(g);
         Propertys.AllDoBeforeDraw(g);
         DrawObject.Draw(g, Layout.Rectangle);
         Propertys.AllDoAfterDraw(g);
         Skills.AllDoAfterDraw(g);
     }
 }
コード例 #11
0
    void Start()
    {
        // Draw the projectile as a line with 2 points.
        drawObject = GetComponent <DrawObject>();
        drawPoints = new List <Vector3>();
        drawPoints.Add(new Vector3(0, 4, 0));
        drawPoints.Add(new Vector3(0, -4, 0));
        drawObject.SetPoints(drawPoints);

        // Destroy the projectile in "life" seconds.
        Invoke("Hit", life);
    }
コード例 #12
0
        private void panel1_MouseDown(object sender, MouseEventArgs e)
        {
            if (dh.ManagerMode)
            {
                return;
            }
            var find = dh.Objects.ObjectList.ToArray().FirstOrDefault(g => ((DrawObject)g).ObjectBound.Contains(e.Location));

            if (find != null)
            {
                selectedObject = find as DrawObject;
            }
        }
コード例 #13
0
ファイル: MainPropertie.cs プロジェクト: bqIcelove/DrawTools
 /// <summary>
 /// 打开此窗体
 /// </summary>
 /// <param name="drawObject">画图</param>
 public static DialogResult ShowPropertiesDialog(DrawObject drawObject)
 {
     if (frmMain == null)
         frmMain = new MainPropertie();
     frmMain.SelectionUcProperiesForm(drawObject);
     DialogResult dr = frmMain.ShowDialog();
     if (dr==DialogResult.OK)
     {
         drawObject.SetOldProperties();
         drawObject.NewProperties = ((ucProperiesBase)frmMain.plProperties.Controls[0]).GetProperties();
     }
     return dr;
 }
コード例 #14
0
ファイル: SaveImageToXml.cs プロジェクト: xuanximoming/PIC
        public string SavePoint(ImageCtl drawArea)
        {
            string s = "";

            for (int i = 0; i < drawArea.GraphicsList.Count; i++)//查找点
            {
                DrawObject o = drawArea.GraphicsList[i];
                if (o.GetType().FullName == "BaseControls.ImageBox.DrawTools.DrawPoint")
                {
                    s = ((DrawPoint)o).Point.X.ToString() + ";" + ((DrawPoint)o).Point.Y.ToString() + ";" + o.ID.ToString();
                }
            }
            return(s);
        }
コード例 #15
0
        public DrawObjectDescription GetDescription(DrawObject drawObject)
        {
            if (!(drawObject is TDrawObject tDrawObject))
            {
                return(null);
            }

            if (!CheckIsValidDrawObject(tDrawObject))
            {
                return(null);
            }

            return(new DrawObjectDescription(GetTypeName(tDrawObject)));
        }
コード例 #16
0
ファイル: ActiveLaser.cs プロジェクト: marlonnn/Cii.Lar
        private void GraphicsPropertiesChangedHandler(DrawObject drawObject, GraphicsProperties graphicsProperties)
        {
            float pulseSize = SysConfig.GetSysConfig().LaserConfig.PulseSize;

            activeCircle.OutterCircleSize = new SizeF(this.GraphicsProperties.ExclusionSize + pulseSize,
                                                      this.GraphicsProperties.ExclusionSize + pulseSize);
            activeCircle.InnerCircleSize = new SizeF(pulseSize, pulseSize);

            for (int i = 0; i < activeCircle.InnerCircles.Count; i++)
            {
                activeCircle.InnerCircles[i] = new Circle(activeCircle.InnerCircles[i].CenterPoint, activeCircle.InnerCircleSize);
                activeCircle.OutterCircle[i] = new Circle(activeCircle.OutterCircle[i].CenterPoint, activeCircle.OutterCircleSize);
            }
            this.pictureBox.Invalidate();
        }
コード例 #17
0
        public void Init(Game_Interface Interface, DrawObject CurrentDrawObject)
        {
            this._Interface         = Interface;
            this._CurrentDrawObject = CurrentDrawObject;
            PropertiesInput_Label Type = new PropertiesInput_Label("Type", _CurrentDrawObject.Type.ToString());

            this.AddControl(Type);
            _Active = new PropertiesInput_Bool("Active", _CurrentDrawObject.Active, new EventHandler(ActiveChanged));
            this.AddControl(_Active);
            _Translation = new PropertiesInput_Vertex("Translation", _CurrentDrawObject.Translation, new EventHandler(TranslationChanged));
            this.AddControl(_Translation);
            _Rotation = new PropertiesInput_Vertex("Rotation", _CurrentDrawObject.Rotation, new EventHandler(RotationChanged));
            this.AddControl(_Rotation);
            _Scale = new PropertiesInput_Vertex("Scale", _CurrentDrawObject.Scale, new EventHandler(ScaleChanged));
            this.AddControl(_Scale);
        }
コード例 #18
0
ファイル: Form1.cs プロジェクト: sjyfok/cpp
 void vs_MouseClick(object sender, MouseEventArgs e)
 {
     VisualGraph.VisualGraph drawArea = (VisualGraph.VisualGraph)sender;
     if (e.Button == MouseButtons.Left)
     {
         if (drawArea.ObjList.SelectionCount > 0)
         {
             DrawObject obj = drawArea.ObjList.GetSelectedObject(0);
             this.propertyGrid1.SelectedObject = obj;
         }
         else
         {
             this.propertyGrid1.SelectedObject = drawArea;
         }
     }
 }
コード例 #19
0
 public EffectRecord(int lr)
 {
     _startmillis = now.millis;
     _endmillis   = now.millis + 300;
     _lr          = lr;
     if (lr == CdjData.Left)
     {
         drawobj = _recordl;
     }
     else
     {
         drawobj = _recordr;
     }
     _y = datacalc.JudgeLineY;
     _x = datacalc.realtimerecordx(lr);
 }
コード例 #20
0
        public void MoveOffset(DrawObject drawObject, double offset, Vector2D relativeTo)
        {
            if (!CheckDrawObjectMoveable(drawObject))
            {
                throw new InvalidCastException(nameof(drawObject));
            }

            var tDrawObject = drawObject as TDrawObject;

            if (relativeTo == null)
            {
                throw new ArgumentNullException(nameof(relativeTo));
            }

            OnMoveOffset(tDrawObject, offset, relativeTo);
        }
コード例 #21
0
ファイル: Asteroid.cs プロジェクト: Labocania/BlackWidowClone
    void Start()
    {
        manager = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager>();

        // Position the points that make up our line renderer and polygon collider such that
        // they create a circle with the radius and number of segments we've specified.
        drawObject   = GetComponent <DrawObject>();
        polyCollider = GetComponent <PolygonCollider2D>();
        linePoints   = circleSegments + 1;
        polyPoints   = new Vector2[linePoints];
        drawPoints   = new List <Vector3>();
        float part = 360f / circleSegments;
        int   i    = 0;

        while (i < linePoints)
        {
            float   duh = part * i * (2 * Mathf.PI / 360) * -1 + Mathf.PI / 2;
            Vector3 pos = new Vector3((Mathf.Cos(duh) * radius), (Mathf.Sin(duh) * radius), 0);

            // Randomize the position of the points a bit on the x and y so we get a more random shape.
            if (i != 0 && i != (linePoints - 1))
            {
                pos = new Vector3(pos.x + Random.Range(-radius / 4, radius / 4), pos.y + Random.Range(-radius / 4, radius / 4), 0);
            }

            drawPoints.Add(pos);
            polyPoints[i] = new Vector2(pos.x, pos.y);
            i++;
        }
        drawObject.SetPoints(drawPoints);
        polyCollider.points = polyPoints;

        // Set the velocity to a random amount based on our initial speed.
        GetComponent <Rigidbody2D>().velocity = new Vector2(Random.Range(-initialSpeed, initialSpeed), Random.Range(-initialSpeed, initialSpeed));
        // Increase velocity by 10% per level.
        GetComponent <Rigidbody2D>().velocity *= (0.9f + (manager.currentLevel / 10f));

        // If asteroid collision is enabled then allow the asteroid to rotate.
        if (manager.asteroidCollision)
        {
            GetComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation;
        }
        else
        {
            GetComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.None;
        }
    }
コード例 #22
0
ファイル: MACD.cs プロジェクト: dox0/uTrade
        internal List <DrawObject> GetDrawingObj(PriceInfo pInfo)
        {
            List <DrawObject> lstDrawObj = new List <DrawObject>();


            double[] emaFast  = MathUtil.CalcEMA(pInfo.getPrice(PriceConstants.PRICE_CLOSE), FastPeriod);
            double[] emaSlow  = MathUtil.CalcEMA(pInfo.getPrice(PriceConstants.PRICE_CLOSE), SlowPeriod);
            double[] emaDiff  = MathUtil.CalcDiff(emaFast, emaSlow);
            double[] dea      = MathUtil.CalcEMA(emaDiff, SignalPeriod);
            double[] macdDiff = MathUtil.CalcDiff(emaDiff, dea);

            DrawObject obj = new DrawObject()
            {
                Type      = DrawObjectType.Line,
                Name      = pInfo.Name + "_emaFast",
                Thickness = 1,
                Color     = Colors.Blue,
                Vals      = emaFast
            };

            lstDrawObj.Add(obj);

            DrawObject obj2 = new DrawObject()
            {
                Type      = DrawObjectType.Line,
                Name      = pInfo.Name + "_emaSlow",
                Thickness = 1,
                Color     = Colors.Red,
                Vals      = emaSlow
            };

            lstDrawObj.Add(obj2);

            DrawObject obj3 = new DrawObject()
            {
                Type      = DrawObjectType.zVLines,
                Name      = pInfo.Name + "_macdDiff",
                Thickness = 1,
                Color     = Colors.Red,
                Vals      = macdDiff
            };

            lstDrawObj.Add(obj3);

            return(lstDrawObj);
        }
コード例 #23
0
        private static DrawObjectModel GetDrawObjectModel(DrawObject drawObject)
        {
            var model = new DrawObjectModel(drawObject);
            SDrawObjectDescription description = null;

            foreach (var descriptor in DrawObjectDescriptionUtil.DrawObjectDescriptors)
            {
                description = descriptor.GetDescription(drawObject);
                if (description != null)
                {
                    break;
                }
            }

            model.TypeName = description?.TypeName ?? drawObject.ToString();
            return(model);
        }
コード例 #24
0
        protected void AddNewObject(DrawArea drawArea, DrawObject o)
        {
            drawArea.GraphicsList.UnselectAll();

            o.Selected = true;
            drawArea.GraphicsList.Add(o);
            string oName = o.GetType().Name;

            if (oName == "Switch" || oName == "SwitchPort")
            {
                drawArea.mapType = "NetDataSet";
            }
            drawArea.Capture = true;
            drawArea.Refresh();

            drawArea.SetDirty();
        }
コード例 #25
0
        private void OpenPage(string pagename)
        {
            string s = myProjectPath + pagename + ".page";

            try
            {
                using (FileStream fs = new FileStream(s, FileMode.Open))
                {
                    if (fs != null)
                    {
                        //open pages form
                        VisualGraph.VisualGraph vs = new VisualGraph.VisualGraph();
                        vs.Name              = pagename;
                        vs.Width             = 800;
                        vs.Height            = 480;
                        vs.MouseClick       += new MouseEventHandler(vs_MouseClick);
                        vs.MouseDoubleClick += new MouseEventHandler(vs_MouseDoubleClick);
                        TabPage page = new TabPage();
                        page.Name = pagename;
                        page.Text = pagename;
                        page.Tag  = pagename;
                        page.Controls.Add(vs);
                        tabMain.TabPages.Add(page);
                        tabMain.SelectTab(pagename);
                        BinaryFormatter BinaryRead = new BinaryFormatter();
                        vs.ObjList = (ObjList)BinaryRead.Deserialize(fs);
                        //设置每个图元的lock和runmode属性
                        int count = vs.ObjList.Count();
                        for (int i = 0; i < count; i++)
                        {
                            DrawObject o = (DrawObject)vs.ObjList[i];
                            o.RunMode = true;
                            o.Lock    = true;
                        }
                        vs.BackGroundColor = (Color)BinaryRead.Deserialize(fs);;
                        fs.Close();
                        vs.Invalidate();
                    }
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("Exception:" + ex.ToString(), " Save Page error.");
            }
        }
コード例 #26
0
        // 애니메이션 테스트
        void AnimationTest(object sender, EventArgs args)
        {
            DrawObject obj = (DrawObject)sender;

            if (obj.Key == "btnStart")
            {
                // msec가 0이면 무한반복
                dh.Objects["Object1"].Animation(AnimationType.Rotation, 360, 0);
                dh.Objects["Object2"].Animation(AnimationType.Width, 500, 0);
            }
            else
            {
                // 동작 정지
                dh.Objects["Object1"].AnimationClear();
                dh.Objects["Object2"].AnimationClear();
                dh.Objects["Object2"].Width = 100;
            }
        }
コード例 #27
0
            public override void Draw(DrawObject drawObject, float x, float y, float width, float height)
            {
                Console.WriteLine("");

                //Print the coordinates and the value of Cell object
                if (drawObject.Type == DrawObjectEnum.Cell)
                {
                    Console.WriteLine("[X]: " + x + " [Y]: " + y + " [Width]: " + width + " [Height]: " + height + " [Cell Value]: " + drawObject.Cell.StringValue);
                }

                //Print the coordinates and the shape name of Image object
                if (drawObject.Type == DrawObjectEnum.Image)
                {
                    Console.WriteLine("[X]: " + x + " [Y]: " + y + " [Width]: " + width + " [Height]: " + height + " [Shape Name]: " + drawObject.Shape.Name);
                }

                Console.WriteLine("----------------------");
            }
コード例 #28
0
        public override void Execute()
        {
            int width = 0, height = 0, n = 0;

            n = graphicsList.SelectionCount;
            if (n > 0)
            {
                DrawObject obj = null;
                for (int i = n - 1; i >= 0; i--)
                {
                    obj    = (DrawObject)graphicsList.ASelection[i];
                    width  = (int)(obj.GetRectangle().Width *rate);
                    height = (int)(obj.GetRectangle().Height *rate);
                    obj.setRectangleWidth(width);
                    obj.setRectangleHeight(height);
                }
            }
        }
コード例 #29
0
 public override void Execute()
 {
     int x_aris = 0, y_aris = 0, width = 0, height = 0, n = 0;
     graphicsList.SelectAll();
     n = graphicsList.SelectionCount;
     DrawObject obj = null;
     for (int i = n - 1; i >= 0; i--)
     {
         obj = (DrawObject)graphicsList.ASelection[i];
         x_aris = (int)(obj.GetRectangle().X * rate);
         y_aris = (int)(obj.GetRectangle().Y * rate);
         width = (int)(obj.GetRectangle().Width * rate);
         height = (int)(obj.GetRectangle().Height * rate);
         obj.setRectangleX(x_aris);
         obj.setRectangleY(y_aris);
         obj.setRectangleWidth(width);
         obj.setRectangleHeight(height);
     }
 }
コード例 #30
0
        public void LifeTime_Tick(Object sender, EventArgs e)
        {
            LifeForm lf = new LifeForm(Coloni, Par);

            this.NewColoni(Coloni, CurrentOrder, Par, Stat); //create start coloni if coloni.count == 0
            CurrentOrder.UpdateOrder(Coloni);                //<<

            lf.Growing(Coloni);                              //growing for everybody
            lf.Search(Coloni, CurrentOrder);                 //search target to move
            lf.Move(Coloni);
            CurrentOrder.UpdateOrder(Coloni);                //<<

            lf.Sex(Coloni);
            lf.Death(Coloni, Stat);
            DrawObject.DrawLf(Coloni, Par);
            lf.RemoveBody(Coloni);
            CurrentOrder.UpdateOrder(Coloni); //<<
            lf.Born(Coloni, Stat);
        }
コード例 #31
0
 public void DealEventProperty(bool bClick, object sender, MouseEventArgs e)
 {
     VisualGraph.VisualGraph drawArea = (VisualGraph.VisualGraph)sender;
     if (e.Button == MouseButtons.Left)
     {
         //取得鼠标位置
         Point      point = new Point(e.X, e.Y);
         DrawObject gp    = drawArea.ObjList.GetSelectedObject(point);
         if (gp != null)//选中了
         {
             if (bClick)
             {
                 if (gp.Click != "")//deal the click event
                 {
                     string[] strContent = gp.Click.Split('+');
                     if (strContent[0].Equals("打开画面"))
                     {
                         tabMain.SelectTab(strContent[1]);
                     }
                     else if (strContent[0].Equals("写变量值"))
                     {
                         WritetoDevice(strContent[1], strContent[2]);
                     }
                 }
             }
             else
             {
                 if (gp.DoubleClick != "")//deal the dclick event
                 {
                     string[] strContent = gp.Click.Split('+');
                     if (strContent[0].Equals("打开画面"))
                     {
                         tabMain.SelectTab(strContent[1]);
                     }
                     else if (strContent[0].Equals("写变量值"))
                     {
                         WritetoDevice(strContent[1], strContent[2]);
                     }
                 }
             }
         }
     }
 }
コード例 #32
0
ファイル: ToolObject.cs プロジェクト: bqIcelove/DrawTools
        /// <summary>
        /// Add new object to draw area.
        /// Function is called when user left-clicks draw area,
        /// and one of ToolObject-derived tools is active.
        /// </summary>
        /// <param name="drawArea"></param>
        /// <param name="o"></param>
        protected void AddNewObject(DrawArea drawArea, DrawObject o)
        {
            int al = drawArea.TheLayers.ActiveLayerIndex;
            drawArea.TheLayers[al].Graphics.UnselectAll();

            o.Selected = true;
            o.Dirty = true;
            int objectID = 0;
            // Set the object id now
            for (int i = 0; i < drawArea.TheLayers.Count; i++)
            {
                objectID = +drawArea.TheLayers[i].Graphics.Count;
            }
            objectID++;
            o.ID = objectID;
            drawArea.TheLayers[al].Graphics.Add(o);

            drawArea.Capture = true;
            drawArea.Refresh();
        }
コード例 #33
0
 public static DrawObject CreateCircle(double x, double y, double r)
 {
     var o = new DrawObject();
     o.SetCircle(x, y, r);
     return o;
 }
コード例 #34
0
        public int MoveService(DrawObject client,GraphicsList GList,Point Goal)
        {
            client.PretendToMoveStart(Goal.X, Goal.Y);
            foreach (DrawObject o in GList.graphicsList)
            {
                if (o == client)
                {
                    continue;

                }
                else
                {   //judge the point?if line judge point, if rectangle?
                    //we have two point list
                    ArrayList clientpoints = client.GetCriticalPointList();
                    ArrayList Servicepoints = o.GetCriticalPointList();

                    for (int i = 0; i < clientpoints.Count; i++)
                    {
                        for(int j=0;j<Servicepoints.Count;j++)
                        {
                            int result = JudgeVertical(((Point)clientpoints[i]), ((Point)Servicepoints[j]));
                            if (result>0)
                            {

                                client.PretendToMoveOver(Goal.X, Goal.Y);

                                if (result == 1)
                                {
                                    client.Move(((Point)Servicepoints[j]).X, Goal.Y);
                                    return 1;

                                }
                                else if (result == 2)
                                {
                                    client.Move(Goal.X, ((Point)Servicepoints[j]).Y);
                                    return 1;

                                }
                                else
                                {

                                }

                            }

                        }

                    }

                }

            }
            client.PretendToMoveOver(Goal.X, Goal.Y);
            //every object has his own relation algrithum critical point
            //otherobject
            //if havent relation
            client.Move(Goal.X, Goal.Y);
            //client origin move(Goal)
            //if haverelation
            //
            return 1;
        }
コード例 #35
0
 public CommandChangeProperty(DrawObject prepareHitProject)
 {
     this.prepareHitProject = prepareHitProject;
 }
コード例 #36
0
ファイル: DrawRectangle.cs プロジェクト: bqIcelove/DrawTools
 protected override void FillDrawObjectFields(DrawObject drawObject)
 {
     base.FillDrawObjectFields(drawObject);
 }
コード例 #37
0
ファイル: GraphicsList.cs プロジェクト: bqIcelove/DrawTools
 /// <summary>
 /// Replace object in specified place.
 /// Used for Undo.
 /// </summary>
 public void Replace(int index, DrawObject obj)
 {
     if (index >= 0 &&
         index < graphicsList.Count)
     {
         graphicsList.RemoveAt(index);
         graphicsList.Insert(index, obj);
     }
 }
コード例 #38
0
ファイル: ToolPointer.cs プロジェクト: bqIcelove/DrawTools
        /// <summary>
        /// Right mouse button is released
        /// </summary>
        /// <param name="drawArea"></param>
        /// <param name="e"></param>
        public override void OnMouseUp(DrawArea drawArea, MouseEventArgs e)
        {
            int al = drawArea.TheLayers.ActiveLayerIndex;
            if (selectMode == SelectionMode.NetSelection)
            {
                // Group selection
                drawArea.TheLayers[al].Graphics.SelectInRectangle(drawArea.NetRectangle);

                selectMode = SelectionMode.None;
                drawArea.DrawNetRectangle = false;
            }

            if (resizedObject != null)
            {
                // after resizing
                resizedObject.Normalize();
                resizedObject = null;
            }

            drawArea.Capture = false;
            drawArea.Refresh();

            if (commandChangeState != null && wasMove)
            {
                // Keep state after moving/resizing and add command to history
                commandChangeState.NewState(drawArea.TheLayers);
                drawArea.AddCommandToHistory(commandChangeState);
                commandChangeState = null;
            }
            lastPoint = drawArea.BackTrackMouse(e.Location);
        }
コード例 #39
0
ファイル: ToolPointer.cs プロジェクト: bqIcelove/DrawTools
        /// <summary>
        /// Left mouse button is pressed
        /// </summary>
        /// <param name="drawArea"></param>
        /// <param name="e"></param>
        public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e)
        {
            commandChangeState = null;
            wasMove = false;

            selectMode = SelectionMode.None;
            Point point = drawArea.BackTrackMouse(new Point(e.X, e.Y));

            // Test for resizing (only if control is selected, cursor is on the handle)
            int al = drawArea.TheLayers.ActiveLayerIndex;
            int n = drawArea.TheLayers[al].Graphics.SelectionCount;

            for (int i = 0; i < n; i++)
            {
                DrawObject o = drawArea.TheLayers[al].Graphics.GetSelectedObject(i);
                int handleNumber = o.HitTest(point);

                if (handleNumber > 0)
                {
                    selectMode = SelectionMode.Size;
                    // keep resized object in class members
                    resizedObject = o;
                    resizedObjectHandle = handleNumber;
                    // Since we want to resize only one object, unselect all other objects
                    drawArea.TheLayers[al].Graphics.UnselectAll();
                    o.Selected = true;
                    commandChangeState = new CommandChangeState(drawArea.TheLayers);
                    break;
                }
            }

            // Test for move (cursor is on the object)
            if (selectMode == SelectionMode.None)
            {
                int n1 = drawArea.TheLayers[al].Graphics.Count;
                DrawObject o = null;

                for (int i = 0; i < n1; i++)
                {
                    if (drawArea.TheLayers[al].Graphics[i].HitTest(point) == 0)
                    {
                        o = drawArea.TheLayers[al].Graphics[i];
                        break;
                    }
                }

                if (o != null)
                {
                    selectMode = SelectionMode.Move;

                    // Unselect all if Ctrl is not pressed and clicked object is not selected yet
                    if ((Control.ModifierKeys & Keys.Control) == 0 &&
                        !o.Selected)

                        drawArea.TheLayers[al].Graphics.UnselectAll();

                    // Select clicked object
                    o.Selected = true;
                    commandChangeState = new CommandChangeState(drawArea.TheLayers);

                    drawArea.Cursor = Cursors.SizeAll;
                }
            }

            // Net selection
            if (selectMode == SelectionMode.None)
            {
                // click on background
                if ((Control.ModifierKeys & Keys.Control) == 0)
                    drawArea.TheLayers[al].Graphics.UnselectAll();

                selectMode = SelectionMode.NetSelection;
                drawArea.DrawNetRectangle = true;
            }

            lastPoint.X = point.X;
            lastPoint.Y = point.Y;
            startPoint.X = point.X;
            startPoint.Y = point.Y;

            drawArea.Capture = true;
            drawArea.NetRectangle = DrawRectangle.GetNormalizedRectangle(startPoint, lastPoint);
            drawArea.Refresh();
        }
コード例 #40
0
ファイル: ToolPointer.cs プロジェクト: dalinhuang/tdcodes
        /// <summary>
        /// Right mouse button is released
        /// </summary>
        /// <param name="drawArea"></param>
        /// <param name="e"></param>
        public override void OnMouseUp(DrawArea drawArea, MouseEventArgs e)
        {
            if ( selectMode == SelectionMode.NetSelection )
            {
                // Remove old selection rectangle
                ControlPaint.DrawReversibleFrame(
                    drawArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(startPoint, lastPoint)),
                    Color.Black,
                    FrameStyle.Dashed);

                // Make group selection
                drawArea.GraphicsList.SelectInRectangle(
                    DrawRectangle.GetNormalizedRectangle(startPoint, lastPoint));

                selectMode = SelectionMode.None;
            }

            if ( resizedObject != null )
            {
                // after resizing
                resizedObject.Normalize();
                resizedObject = null;
            }

            drawArea.Capture = false;
            drawArea.Refresh();

            if ( commandChangeState != null  && wasMove )
            {
                // Keep state after moving/resizing and add command to history
                commandChangeState.NewState(drawArea.GraphicsList);
                drawArea.AddCommandToHistory(commandChangeState);
                commandChangeState = null;
            }
        }
コード例 #41
0
ファイル: ToolPointer.cs プロジェクト: dalinhuang/tdcodes
        /// <summary>
        /// Left mouse button is pressed
        /// </summary>
        /// <param name="drawArea"></param>
        /// <param name="e"></param>
        public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e)
        {
            commandChangeState = null;
            wasMove = false;

            selectMode = SelectionMode.None;
            Point point = new Point(e.X, e.Y);

            // Test for resizing (only if control is selected, cursor is on the handle)
            foreach (DrawObject o in drawArea.GraphicsList.Selection)
            {
                int handleNumber = o.HitTest(point);

                if (handleNumber > 0)
                {
                    selectMode = SelectionMode.Size;

                    // keep resized object in class member
                    resizedObject = o;
                    resizedObjectHandle = handleNumber;

                    // Since we want to resize only one object, unselect all other objects
                    drawArea.GraphicsList.UnselectAll();
                    o.Selected = true;

                    commandChangeState = new CommandChangeState(drawArea.GraphicsList);

                    break;
                }
            }

            // Test for move (cursor is on the object)
            if ( selectMode == SelectionMode.None )
            {
                int n1 = drawArea.GraphicsList.Count;
                DrawObject o = null;

                for ( int i = 0; i < n1; i++ )
                {
                    if ( drawArea.GraphicsList[i].HitTest(point) == 0 )
                    {
                        o = drawArea.GraphicsList[i];
                        break;
                    }
                }

                if ( o != null )
                {
                    selectMode = SelectionMode.Move;

                    // Unselect all if Ctrl is not pressed and clicked object is not selected yet
                    if ( ( Control.ModifierKeys & Keys.Control ) == 0  && !o.Selected )
                        drawArea.GraphicsList.UnselectAll();

                    // Select clicked object
                    o.Selected = true;

                    commandChangeState = new CommandChangeState(drawArea.GraphicsList);

                    drawArea.Cursor = Cursors.SizeAll;
                }
            }

            // Net selection
            if ( selectMode == SelectionMode.None )
            {
                // click on background
                if ( ( Control.ModifierKeys & Keys.Control ) == 0 )
                    drawArea.GraphicsList.UnselectAll();

                selectMode = SelectionMode.NetSelection;

            }

            lastPoint.X = e.X;
            lastPoint.Y = e.Y;
            startPoint.X = e.X;
            startPoint.Y = e.Y;

            drawArea.Capture = true;

            drawArea.Refresh();

            if ( selectMode == SelectionMode.NetSelection )
            {
                // Draw selection rectangle in initial position
                ControlPaint.DrawReversibleFrame(
                    drawArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(startPoint, lastPoint)),
                    Color.Black,
                    FrameStyle.Dashed);
            }
        }
コード例 #42
0
ファイル: MainPropertie.cs プロジェクト: bqIcelove/DrawTools
        private void SelectionUcProperiesForm(DrawObject drawObject)
        {
            //清除
            plProperties.Controls.Clear();

            if (htUcCache == null)
                htUcCache = new Hashtable();
            //缓存
            if (!htUcCache.ContainsKey(drawObject.drawingType))
                htUcCache.Add(drawObject.drawingType, GetNewUcProperies(drawObject.GetType()));
            //设置参数
            (htUcCache[drawObject.drawingType] as ucProperiesBase).SetGraphicsProperties(drawObject.NowProperties);
            //填充窗体
            (htUcCache[drawObject.drawingType] as ucProperiesBase).FillProperties();
            //设置属性窗体
            SetUcProperiesForm(htUcCache[drawObject.drawingType] as ucProperiesBase);
        }
コード例 #43
0
 public static DrawObject CreateCircle(Point p, double r)
 {
     var o = new DrawObject();
     o.SetCircle(p, r);
     return o;
 }
コード例 #44
0
ファイル: GraphicsList.cs プロジェクト: bqIcelove/DrawTools
 /// <summary>
 /// Thanks to Member 3272353 for this fix to object ordering problem.
 /// </summary>
 /// <param name="obj"></param>
 public void Append(DrawObject obj)
 {
     graphicsList.Add(obj);
 }
コード例 #45
0
ファイル: GraphicsList.cs プロジェクト: bqIcelove/DrawTools
        public void Add(DrawObject obj)
        {
            graphicsList.Sort();
            foreach (DrawObject o in graphicsList)
                o.ZOrder++;

            graphicsList.Insert(0, obj);
        }
コード例 #46
0
ファイル: CommandAdd.cs プロジェクト: bqIcelove/DrawTools
 // Create this command with DrawObject instance added to the list
 public CommandAdd(DrawObject drawObject)
     : base()
 {
     // Keep copy of added object
     this.drawObject = drawObject.Clone();
 }
コード例 #47
0
ファイル: CommandAdd.cs プロジェクト: gitter-badger/UROCare
 // Create this command with DrawObject instance added to the list
 public CommandAdd(DrawObject drawObject)
 {
     // Keep copy of added object
     _drawObject = drawObject.Clone();
 }