Ejemplo n.º 1
0
 private SymbolPartData ConvertSymbolPart(SymbolPart symbolPart)
 {
     if (symbolPart is LinePart)
     {
         LinePart linePart = (LinePart)symbolPart;
         PointF   p1       = linePart.GetPoint(0);
         PointF   p2       = linePart.GetPoint(1);
         return(new SymbolLineData(p1.X, p1.Y, p2.X, p2.Y));
     }
     if (symbolPart is RectanglePart)
     {
         RectanglePart rectPart = (RectanglePart)symbolPart;
         return(new SymbolRectData(rectPart.Location.X, rectPart.Location.Y, rectPart.Width, rectPart.Height));
     }
     if (symbolPart is TextPart)
     {
         TextPart textPart = (TextPart)symbolPart;
         return(new SymbolTextData(textPart.Location.X, textPart.Location.Y, textPart.Text));
     }
     if (symbolPart is PortPart)
     {
         PortPart portPart = (PortPart)symbolPart;
         return(new SymbolPortData(portPart.Location.X, portPart.Location.Y, portPart.Angle, portPart.Direction, portPart.Name));
     }
     return(null);
 }
Ejemplo n.º 2
0
        public int SelectPartAt(PointF location)
        {
            int found = 0;

            foreach (SymbolPart part in m_Symbol)
            {
                if (part.IsNear(location))
                {
                    found++;
                    m_GrabHandle = part.GetGrabHandle(location);
                    if (part.Equals(m_SelectedPart) == false)
                    {
                        if (m_SelectedPart != null)
                        {
                            m_SelectedPart.IsSelected = false;
                        }
                        part.IsSelected = true;
                        m_SelectedPart  = part;
                        UpdateBackground();
                        Invalidate();
                    }
                }
            }
            if (found == 0 && m_SelectedPart != null)
            {
                m_SelectedPart.IsSelected = false;
                m_SelectedPart            = null;
                m_GrabHandle = null;
                UpdateBackground();
                Invalidate();
            }
            return(found);
        }
Ejemplo n.º 3
0
        internal override void MouseClick(PointF location)
        {
            SymbolPart part = m_Editor.GetPartAt(location);

            if (OnPartSelected != null)
            {
                OnPartSelected(this, new PartSelectedEventArgs(part));
            }
        }
Ejemplo n.º 4
0
 private void CreateParts(Symbol symbol, SymbolData symbolData)
 {
     foreach (SymbolPartData partData in symbolData.SymbolParts)
     {
         SymbolPart part = ConvertPartData(partData);
         if (part != null)
         {
             symbol.AddPart(part);
         }
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Selects a part at the given location
        /// </summary>
        /// <param name="location">location of interest</param>
        /// <returns></returns>
        public SymbolPart GetPartAt(PointF location)
        {
            int        found     = 0;
            SymbolPart foundPart = null;

            foreach (SymbolPart part in m_Symbol)
            {
                if (part.IsNear(location))
                {
                    found++;
                    foundPart = part;
                }
            }
            if (found == 1)
            {
                return(foundPart);
            }
            return(null);
        }
Ejemplo n.º 6
0
 protected override void OnMouseClick(MouseEventArgs e)
 {
     base.OnMouseClick(e);
     if (m_CurrentTool == null)
     {
         return;
     }
     m_CurrentTool.MouseClick(Translate(e.Location, true));
     if (m_CurrentTool is PartDeletionTool)
     {
         if (SelectPartAt(Translate(e.Location, false)) == 1)
         {
             m_Symbol.RemovePart(m_SelectedPart);
             m_SelectedPart = null;
             RaiseChangedEvent();
             UpdateDrawing();
             UpdateBackground();
             Invalidate();
         }
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="part">The selected part</param>
 public PartSelectedEventArgs(SymbolPart part)
 {
     m_Part = part;
 }
 public NewSymbolPartEventArgs(SymbolPart symbolPart)
 {
     m_SymbolPart = symbolPart;
 }