Пример #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);
 }
Пример #2
0
        private void LoadFiles()
        {
            button_ProceedToPage2.Enabled = false;
            //at this point the chosen files really do exist
            m_CircuitData         = CircuitSerializer.DeserializeCircuit(textBox_Circuit.Text);
            m_CircuitData.Signals = null;
            Circuit circuit = CircuitConverter.Instance.ConvertToCircuit(m_CircuitData);

            foreach (BaseElement be in circuit)
            {
                if (be is SignalInput)
                {
                    ListViewItem li = new ListViewItem(be.Name);
                    //li.ToolTipText = String.Format("{0} ({1}, X: {2}, Y: {3})", be.);
                    li.Group = listView_CircuitIOs.Groups[0];
                    listView_CircuitIOs.Items.Add(li);
                }
                if (be is SignalOutput)
                {
                    ListViewItem li = new ListViewItem(be.Name);
                    li.Group = listView_CircuitIOs.Groups[1];
                    listView_CircuitIOs.Items.Add(li);
                }
            }

            m_SymbolData = SymbolSerializer.DeserializeSymbol(textBox_Symbol.Text);
            Symbol symbol = SymbolConverter.Instance.ConvertToSymbol(m_SymbolData);

            foreach (SymbolPart part in symbol)
            {
                if (part is PortPart)
                {
                    PortPart port = (PortPart)part;
                    if (port.Direction == DirectionType.Input)
                    {
                        ListViewItem li = new ListViewItem(port.Name);
                        //li.ToolTipText = String.Format("{0} ({1}, X: {2}, Y: {3})", port.Name, port.Direction, port.Location.X, port.Location.Y);
                        li.Group = listView_SymbolPorts.Groups[0];
                        listView_SymbolPorts.Items.Add(li);
                    }
                    if (port.Direction == DirectionType.Output)
                    {
                        ListViewItem li = new ListViewItem(port.Name);
                        //li.ToolTipText = String.Format("{0} ({1}, X: {2}, Y: {3})", port.Name, port.Direction, port.Location.X, port.Location.Y);
                        li.Group = listView_SymbolPorts.Groups[1];
                        listView_SymbolPorts.Items.Add(li);
                    }
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Adds terminals
        /// </summary>
        protected override void AddTerminals()
        {
            Macro macro = LinkedObject as Macro;

            foreach (SymbolPart part in m_Symbol)
            {
                if (part is PortPart)
                {
                    PortPart port = (PortPart)part;
                    Terminal term = macro.GetTerminalByName(port.Name);
                    if (term != null)
                    {
                        GraphicBaseElement element = GraphicObjectFactory.CreateInstance(typeof(Terminal), term);
                        element.Name     = port.Name;
                        element.Location = port.Location;
                        element.Angle    = port.Angle;
                        AddTerminal(element as GraphicTerminal);
                    }
                }
            }
        }
Пример #4
0
        internal override void MouseClick(PointF location)
        {
            SymbolPart part = new PortPart(location, m_Direction, "");

            OnNewSymbolPart(this, new NewSymbolPartEventArgs(part));
        }