Exemplo n.º 1
0
        private void spreadSheet_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            double dvalue;
            String strValue = spreadSheet.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();

            if (String.IsNullOrWhiteSpace(strValue))
            {
                return;
            }
            switch (e.ColumnIndex)
            {
            /*case 1:
             *  if (!int.TryParse(strValue, out value))
             *  {
             *      spreadSheet.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = "";
             *  }
             *  break;*/
            case 5:
            case 6:
                if (!double.TryParse(strValue, out dvalue))
                {
                    double tmp = KicadUnitConvert.From_mm(1.270);
                    spreadSheet.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = tmp.ToString();
                }
                break;

            case 7:
                if (!double.TryParse(strValue, out dvalue))
                {
                    double tmp = KicadUnitConvert.From_mm(3.810);
                    spreadSheet.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = tmp.ToString();
                }
                break;
            }
        }
Exemplo n.º 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());
        }