예제 #1
0
        private void Update_Click(object sender, EventArgs e)
        {
            if (_Pins != null)
            {
                Component.RemovePins();
                int length = _Pins.Count / 4;
                int xstart = -(length / 2) * 200;
                int ystart = (length / 2) * 200;
                for (int i = 0; i < _Pins.Count; i++)
                {
                    KicadLibPin curpin = _Pins[i];

                    curpin.Name = spreadSheet.Rows[i].Cells[0].Value.ToString();
                    curpin.Pin  = spreadSheet.Rows[i].Cells[1].Value.ToString(); //(i + 1).ToString();
                    //curpin.Orientation = new KicadLibPinOrientation(spreadSheet.Rows[i].Cells[2].Value.ToString());
                    curpin.Type     = new KicadLibPinType(spreadSheet.Rows[i].Cells[3].Value.ToString());
                    curpin.Shape    = new KicadLibPinShape(spreadSheet.Rows[i].Cells[4].Value.ToString());
                    curpin.Sizename = (System.Convert.ToDouble(spreadSheet.Rows[i].Cells[5].Value.ToString()));
                    curpin.Sizenum  = (System.Convert.ToDouble(spreadSheet.Rows[i].Cells[6].Value.ToString()));
                    curpin.Length   = (System.Convert.ToDouble(spreadSheet.Rows[i].Cells[7].Value.ToString()));

                    if (newComponent)
                    {
                        curpin.Length = 200;
                        curpin.Part   = curpin.Dmg = 1;

                        if (i < length)
                        {
                            curpin.Position.Y        = ystart + 400;
                            curpin.Position.X        = xstart + i * 200;
                            curpin.Orientation.Value = KicadLibPinOrientation.PinOrentation.Down;
                        }
                        else if (i < 2 * length)
                        {
                            curpin.Position.X        = xstart * (-1) + 400;
                            curpin.Position.Y        = ystart - (i - length) * 200;
                            curpin.Orientation.Value = KicadLibPinOrientation.PinOrentation.Left;
                        }
                        else if (i < 3 * length)
                        {
                            curpin.Position.Y        = ystart * (-1) - 400;
                            curpin.Position.X        = xstart * (-1) - (i - 2 * length) * 200;
                            curpin.Orientation.Value = KicadLibPinOrientation.PinOrentation.Up;
                        }
                        else
                        {
                            curpin.Position.X        = xstart - 400;
                            curpin.Position.Y        = ystart * (-1) + (i - 3 * length) * 200;
                            curpin.Orientation.Value = KicadLibPinOrientation.PinOrentation.Right;
                        }
                    }

                    Component.DrawObjects.Add(curpin);
                }

                modified = true;
            }
        }
예제 #2
0
        public DialogResult ShowMyDalog(int id)
        {
            if (id == 0)
            {
                NewCmpProperties properties = new NewCmpProperties();
                if (properties.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
                {
                    this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                    return(System.Windows.Forms.DialogResult.Cancel);
                }
                else
                {
                    Component.Definition.Name      = properties.CompName;
                    Component.Definition.Reference = properties.Designator;
                    KicadLibFX F0 = new KicadLibFX(0);
                    KicadLibFX F1 = new KicadLibFX(1);
                    KicadLibFX F2 = new KicadLibFX(2);
                    KicadLibFX F3 = new KicadLibFX(3);

                    F0.Reference = properties.Designator;
                    F1.Reference = properties.CompName;
                    Component.Parameters.Add(F0);
                    Component.Parameters.Add(F1);
                    Component.Parameters.Add(F2);
                    Component.Parameters.Add(F3);

                    _Pins = new List <KicadLibPin>();
                    for (int i = 0; i < properties.PinCount; i++)
                    {
                        KicadLibPin curpin = new KicadLibPin();
                        spreadSheet.Rows.Add();
                        curpin.Pin = (i + 1).ToString();
                        curpin.Orientation.Value = KicadLibPinOrientation.PinOrentation.Left;
                        curpin.Type.Value        = KicadLibPinType.PinType.Input;
                        curpin.Shape.Value       = KicadLibPinShape.PinShape.Line;
                        curpin.Sizenum           = curpin.Sizename = KicadUnitConvert.From_mm(1.270);
                        curpin.Length            = 3.810;
                        _Pins.Add(curpin);

                        spreadSheet.Rows[i].Cells[1].Value = (i + 1).ToString();
                        spreadSheet.Rows[i].Cells[2].Value = "Left";
                        spreadSheet.Rows[i].Cells[3].Value = "Input";
                        spreadSheet.Rows[i].Cells[4].Value = "Line";

                        spreadSheet.Rows[i].Cells[5].Value = 50;
                        spreadSheet.Rows[i].Cells[6].Value = 50;
                        spreadSheet.Rows[i].Cells[7].Value = 200;
                        //spreadSheet.Rows[i].Cells[8].Value = true;
                    }
                    newComponent = true;
                }
            }
            else if (id == 1)
            {
                _Pins = new List <KicadLibPin>();
                foreach (Object obj in Component.DrawObjects)
                {
                    if (obj.GetType() == typeof(KicadLibPin))
                    {
                        KicadLibPin curpin = (KicadLibPin)obj;
                        _Pins.Add(curpin);
                        spreadSheet.Rows.Add(
                            curpin.Name,
                            curpin.Pin,
                            KicadLibPinOrientation.StringValues[(int)curpin.Orientation.Value],
                            KicadLibPinType.StringValues[(int)curpin.Type.Value],
                            KicadLibPinShape.StringValues[(int)curpin.Shape.Value],
                            curpin.Sizename,
                            curpin.Sizenum,
                            curpin.Length /*,
                                           * true*/);
                    }
                }
                newComponent = false;
            }
            else
            {
                return(System.Windows.Forms.DialogResult.Abort);
            }

            return(base.ShowDialog());
        }