コード例 #1
0
ファイル: Module.cs プロジェクト: jjacksons/GLUE
        protected void SetPoint(ePoint pointid, UnitPoint point, Module mod)
        {
            if (pointid == ePoint.FromPoint)
            {
                mod.FromPoint = point;

            }
            if (pointid == ePoint.ToPoint) mod.ToPoint = point;
            if (pointid == ePoint.StartPoint)
            {
                mod.StartPoint = point;
                if ((mod.horizontal && mod.EndPoint.X == mod.StartPoint.X + 1 && mod.EndPoint.Y == mod.StartPoint.Y) || (!mod.horizontal && mod.EndPoint.Y == mod.StartPoint.Y+1 && mod.EndPoint.X == mod.StartPoint.X)) return;
                if (mod.horizontal) point.X += 1;
                else point.Y +=1;
                SetPoint(ePoint.EndPoint, point, mod);

            }
            if (pointid == ePoint.EndPoint)
            {
                mod.EndPoint = point;
                if ((mod.horizontal && mod.EndPoint.X == mod.StartPoint.X + 1 && mod.EndPoint.Y == mod.StartPoint.Y) || (!mod.horizontal && mod.EndPoint.Y == mod.StartPoint.Y + 1 && mod.EndPoint.X == mod.StartPoint.X)) return;
                if (mod.horizontal) point.X -= 1;
                else point.Y -= 1;
                SetPoint(ePoint.StartPoint, point, mod);

            }
        }
コード例 #2
0
ファイル: Module.cs プロジェクト: jjacksons/GLUE
 public void Finish()
 {
     m_endPoint = GetPoint(m_pointId);
     m_owner.FromPoint = m_clone.FromPoint;
     m_owner.StartPoint = m_clone.StartPoint;
     m_owner.EndPoint = m_clone.EndPoint;
     m_owner.ToPoint = m_clone.ToPoint;
     m_clone = null;
 }
コード例 #3
0
ファイル: Module.cs プロジェクト: jjacksons/GLUE
        public virtual eDrawObjectMouseDown OnMouseDown(ICanvas canvas, UnitPoint point, ISnapPoint snappoint)
        {
            if (!tofrom && !child)
            {
                foreach (IDrawObject i in canvas.DataModel.GetHitObjects(canvas, point)) if (i.GetType().ToString().IndexOf("Module") >= 0 && i != this)
                    {
                        from_connections = (ModuleItems.Module)i;
                        if (from_connections.ToPoint == point) foreach (Property p in from_connections.properties) if (p.name == "to") foreach (Property q in properties) if (q.name == "name") p.value = q.value;
                        if (from_connections.FromPoint == point) foreach (Property p in from_connections.properties) if (p.name == "from") foreach (Property q in properties) if (q.name == "name") p.value = q.value;
                    }

                return eDrawObjectMouseDown.Done;
            }
            if (currentPoint == ePoint.FromPoint)
            {
                m_p1 = point;
                currentPoint = ePoint.StartPoint;
                foreach (IDrawObject i in canvas.DataModel.GetHitObjects(canvas, point)) if (i.GetType().ToString().IndexOf("Module") >= 0 && i != this) from_connections = (ModuleItems.Module)i;
                if (from_connections != null) foreach (Property p in properties) if (p.name == "from") foreach (Property q in from_connections.properties) if (q.name == "name") p.value = q.value;
                if (from_connections != null && child) foreach (Property p in properties) if (p.name == "parent") foreach (Property q in from_connections.properties) if (q.name == "name") p.value = q.value;
                return eDrawObjectMouseDown.Continue;
            }
            if (currentPoint == ePoint.StartPoint)
            {
                currentPoint = ePoint.EndPoint;
                if (snappoint is PerpendicularSnapPoint && snappoint.Owner is Module)
                {
                    Module src = snappoint.Owner as Module;
                    m_p2 = HitUtil.NearestPointOnLine(src.FromPoint, src.EndPoint, m_p1, true);
                    if (horizontal) m_p3 = new UnitPoint(m_p2.X + 1, m_p2.Y);
                    else m_p3 = new UnitPoint(m_p2.X, m_p2.Y - 1);
                    if (child) return eDrawObjectMouseDown.Done;
                    return eDrawObjectMouseDown.Continue;
                }
                if (snappoint is PerpendicularSnapPoint && snappoint.Owner is Canvas.DrawTools.Line)
                {
                    Canvas.DrawTools.Line src = snappoint.Owner as Canvas.DrawTools.Line;
                    m_p2 = HitUtil.NearestPointOnLine(src.P1, src.P2, m_p1, true);
                    if (horizontal) m_p3 = new UnitPoint(m_p2.X + 1, m_p2.Y);
                    else m_p3 = new UnitPoint(m_p2.X, m_p2.Y - 1);
                    if (child) return eDrawObjectMouseDown.Done;
                    return eDrawObjectMouseDown.Continue;
                }
                if (snappoint is PerpendicularSnapPoint && snappoint.Owner is Canvas.DrawTools.Arc)
                {
                    Canvas.DrawTools.Arc src = snappoint.Owner as Canvas.DrawTools.Arc;
                    m_p2 = HitUtil.NearestPointOnCircle(src.Center, src.Radius, m_p1, 0);
                    if (horizontal) m_p3 = new UnitPoint(m_p2.X + 1, m_p2.Y);
                    else m_p3 = new UnitPoint(m_p2.X, m_p2.Y - 1);
                    if (child) return eDrawObjectMouseDown.Done;
                    return eDrawObjectMouseDown.Continue;
                }
                if (Control.ModifierKeys == Keys.Control)
                    point = HitUtil.OrthoPointD(m_p1, point, 45);
                m_p2 = point;
                if (horizontal) m_p3 = new UnitPoint(m_p2.X + 1, m_p2.Y);
                else m_p3 = new UnitPoint(m_p2.X, m_p2.Y - 1);
                if (child) return eDrawObjectMouseDown.Done;
                return eDrawObjectMouseDown.Continue;
            }
            Selected = false;
            currentPoint = ePoint.ToPoint;
            if (snappoint is PerpendicularSnapPoint && snappoint.Owner is Module)
            {
                Module src = snappoint.Owner as Module;
                m_p4 = HitUtil.NearestPointOnLine(src.FromPoint, src.EndPoint, m_p3, true);
                return eDrawObjectMouseDown.Done;
            }
            if (snappoint is PerpendicularSnapPoint && snappoint.Owner is Canvas.DrawTools.Line)
            {
                Canvas.DrawTools.Line src = snappoint.Owner as Canvas.DrawTools.Line;
                m_p4 = HitUtil.NearestPointOnLine(src.P1, src.P2, m_p3, true);
                return eDrawObjectMouseDown.Done;
            }
            if (snappoint is PerpendicularSnapPoint && snappoint.Owner is Canvas.DrawTools.Arc)
            {
                Canvas.DrawTools.Arc src = snappoint.Owner as Canvas.DrawTools.Arc;
                m_p4 = HitUtil.NearestPointOnCircle(src.Center, src.Radius, m_p3, 0);
                return eDrawObjectMouseDown.Done;
            }
            if (Control.ModifierKeys == Keys.Control)
                point = HitUtil.OrthoPointD(m_p1, point, 45);
            m_p4 = point;
            foreach (IDrawObject i in canvas.DataModel.GetHitObjects(canvas, point)) if (i.GetType().ToString().IndexOf("Module") >= 0 && i != this) to_connections = (ModuleItems.Module)i;
            if (to_connections != null) foreach (Property p in properties) if (p.name == "to") foreach (Property q in to_connections.properties) if (q.name == "name") p.value = q.value;
            return eDrawObjectMouseDown.Done;
        }
コード例 #4
0
ファイル: Module.cs プロジェクト: jjacksons/GLUE
 public NP(Module owner, ePoint id)
 {
     m_owner = owner;
     m_clone = m_owner.Clone() as Module;
     m_pointId = id;
     m_originalPoint = GetPoint(m_pointId);
 }
コード例 #5
0
ファイル: Module.cs プロジェクト: jjacksons/GLUE
 public virtual void Copy(Module acopy)
 {
     base.Copy(acopy);
     m_p1 = acopy.m_p1;
     m_p2 = acopy.m_p2;
     m_p3 = acopy.m_p3;
     Selected = acopy.Selected;
 }