Ejemplo n.º 1
0
 private void updateCompShow(ComponentEx comp)
 {
     this.txtModel.Text   = comp.component.Name;
     this.nudWidth.Value  = (decimal)comp.component.Width;
     this.nudHeight.Value = (decimal)comp.component.Height;
     this.lswDotLoad(comp);
 }
Ejemplo n.º 2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            string name = this.txtModel.Text;

            if (this.curPinfo.UserComps.Contains(name))
            {
                MessageBox.Show("can not delete the component");
                return;
            }
            ComponentEx comp = this.findCompByName(name);

            if (comp == null)
            {
                return;
            }
            this.curUserLib.Remove(comp);
            if (this.curUserLib.FindAll().Count > 0)
            {
                this.curUserComp = this.curUserLib.FindAll()[0];
                if (this.curUserComp.component.GetPoints(getTech()).Count > 0)
                {
                    this.dot = this.curUserComp.component.GetPoints(getTech())[0];
                }
            }
            this.canChange = false;
            this.updateCompShow(this.curUserComp);
            this.updateDotShow();
            this.lswUnEditedLoad();
            this.canChange = true;
        }
Ejemplo n.º 3
0
        private void btnClone_Click(object sender, EventArgs e)
        {
            string name = this.txtModel.Text;

            if (String.IsNullOrEmpty(name))
            {
                return;
            }
            bool isFind = checkComponent(name);

            if (isFind)
            {
                MessageBox.Show("the component is in the Lib");
                return;
            }
            if (this.curUserComp == null)
            {
                return;
            }
            int         index = findMaxIndex(this.curUserLib);
            ComponentEx cmp   = new ComponentEx(index + 1);

            cmp.component      = this.curUserComp.component.DepCopy();
            cmp.component.Name = name;
            this.curLib.Add(cmp);
            this.lswLibLoad();
            this.drawComponent(this.curUserComp);
        }
Ejemplo n.º 4
0
        private void drawComponent(ComponentEx comp)
        {
            if (comp == null)
            {
                return;
            }
            this.componentShape1.AddRect((float)comp.component.Width, (float)comp.component.Height);

            //List<PointD> points = new List<PointD>();
            //foreach (var item in comp.component.GetPoints())
            //{
            //    points.Add(item.point);
            //}
            if (this.rbtAdh.Checked)
            {
                this.componentShape1.AddPoints(comp.component.GetPoints(Technology.Adh));
            }
            if (this.rbtSold.Checked)
            {
                this.componentShape1.AddPoints(comp.component.GetPoints(Technology.Adh));
            }


            this.componentShape1.AddOnePoint(this.dot);
            this.componentShape1.BeginPaint();
        }
Ejemplo n.º 5
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string name = this.txtModel.Text;

            if (String.IsNullOrEmpty(name))
            {
                return;
            }
            bool isFind = checkComponent(name);

            if (isFind)
            {
                MessageBox.Show("the component is in the Lib");
                return;
            }
            int index = this.findMaxIndex(this.curUserLib);

            this.curUserComp = new ComponentEx(index + 1);
            this.curUserComp.component.Name = name;
            this.compName = name;
            this.curUserComp.component.Width  = (double)this.nudWidth.Value;
            this.curUserComp.component.Height = (double)this.nudHeight.Value;
            this.curUserLib.Add(this.curUserComp);
            this.canChange = false;
            this.lswUnEditedLoad();
            this.updateCompShow(this.curUserComp);
            this.drawComponent(this.curUserComp);
            this.canChange = true;
        }
Ejemplo n.º 6
0
        public void GetPoints(ComponentLib lib)
        {
            this.points.Clear();
            bool        isFind = false;
            PointD      pRotated;
            ComponentEx cmp = new ComponentEx(0);

            if (lib == null || lib.FindAll().Count == 0)
            {
                return;
            }
            foreach (ComponentEx item in lib.FindAll())
            {
                if (item.component.Name.Contains(this.Comp) || this.Comp.Contains(item.component.Name))
                {
                    isFind = true;
                    cmp    = item;
                    break;
                }
            }
            if (isFind)
            {
                if (tech == Technology.Adh)
                {
                    if (cmp.component.AdhPoints.Count > 0)
                    {
                        foreach (GlueDot p in cmp.component.GetPoints(Technology.Adh))
                        {
                            GlueDot dot = new GlueDot();
                            dot.IsWeight = p.IsWeight;
                            dot.Weight   = p.Weight;
                            dot.Radius   = p.Radius;
                            dot.NunShots = p.NunShots;
                            dot.index    = p.index;
                            dot.point    = new PointD(p.point);
                            this.RotateComp(dot.point, this.rotation, out pRotated);
                            dot.point = pRotated + this.mid;
                            this.points.Add(dot);
                        }
                    }
                    else
                    {
                        GlueDot dot = new GlueDot();
                        dot.point = new PointD(this.mid);
                        this.points.Add(dot);
                    }
                }
            }
            else
            {
                GlueDot dot = new GlueDot();
                dot.point = new PointD(this.mid);
                this.points.Add(dot);
            }
        }
Ejemplo n.º 7
0
        public void GetUserLib()
        {
            int index = 0;

            this.LibUser.Clear();
            foreach (string item in this.UserComps)
            {
                index = this.LibUser.Count;
                ComponentEx compnt = new ComponentEx(index + 1);
                compnt.component.Name   = item;
                compnt.component.Width  = 0;
                compnt.component.Height = 0;
                this.LibUser.Add(compnt);
            }
        }
Ejemplo n.º 8
0
 private void colorListItem()
 {
     foreach (ListViewItem item in this.lswUnEdited.Items)
     {
         ComponentEx cmp = findCmpByName(item.SubItems[1].Text);
         if (cmp != null && cmp.component.Width > 0 && cmp.component.Height > 0 && cmp.component.GetPoints(getTech()).Count > 0)
         {
             item.ForeColor = Color.Black;
         }
         else
         {
             item.ForeColor = Color.Red;
         }
     }
 }
Ejemplo n.º 9
0
 private void lswLib_MouseClick(object sender, MouseEventArgs e)
 {
     if (this.lswLib.SelectedIndices.Count > 0)
     {
         this.canChange                 = false;
         compName                       = this.lswLib.SelectedItems[0].SubItems[1].Text;
         this.txtModel.Text             = compName;
         this.curLibComp                = this.findComponentInLib(this.curLib, compName);
         this.curLibComp.component.Tech = this.getTech();
         this.updateCompShow(this.curLibComp);
         this.lswUserShow();
         this.drawComponent(this.curLibComp);
         this.lswLibShow();
         this.canChange = true;
     }
 }
Ejemplo n.º 10
0
 private void lswUnEdited_MouseClick(object sender, MouseEventArgs e)
 {
     if (this.lswUnEdited.SelectedIndices.Count > 0)
     {
         this.canChange     = false;
         compName           = this.lswUnEdited.SelectedItems[0].SubItems[1].Text;
         this.txtModel.Text = compName;
         this.curUserComp   = this.findComponentInLib(this.curUserLib, compName);
         if (this.curUserComp.component.GetPoints(getTech()).Count > 0)
         {
             this.dot = this.curUserComp.component.GetPoints(getTech())[0];
         }
         this.updateCompShow(this.curUserComp);
         this.updateDotShow();
         this.lswUserShow();
         this.drawComponent(this.curUserComp);
         this.canChange = true;
     }
 }
Ejemplo n.º 11
0
 public void adjustLswDotWidth(ComponentEx comp)
 {
     if (comp.component.GetPoints(this.getTech()).Count > 0)
     {
         int width1    = 0;
         int widthBack = 0;
         int widthSum  = 0;
         foreach (ColumnHeader item in this.lswDots.Columns)
         {
             widthBack  = item.Width;
             item.Width = -1;
             width1     = item.Width;
             if (width1 < widthBack)
             {
                 item.Width = widthBack;
             }
             else
             {
                 item.Width = width1;
             }
             widthSum += item.Width;
         }
         int columnCount = this.lswDots.Columns.Count - 1;
         int widthAvg    = (this.lswDots.Width - widthSum) / columnCount;
         for (int i = 1; i < this.lswDots.Columns.Count; i++)
         {
             if (this.lswDots.Columns[i].Width < widthAvg)
             {
                 this.lswDots.Columns[i].Width = widthAvg;
             }
         }
         int widthEach = (this.lswUnEdited.Width - widthSum) / columnCount;
         if (widthEach >= 0)
         {
             for (int i = 1; i < this.lswUnEdited.Columns.Count; i++)
             {
                 this.lswUnEdited.Columns[i].Width += widthEach;
             }
         }
     }
 }
Ejemplo n.º 12
0
        /// <summary>
        /// 将用户Lib融入到已有Lib
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnMerge_Click(object sender, EventArgs e)
        {
            bool isFinded = false;

            if (string.IsNullOrEmpty(this.curLib.PathLib))
            {
                return;
            }
            ComponentLib lib = new ComponentLib();

            lib.Clear();
            lib.AddRange(this.curLib.FindAll());
            this.curLib.Save();
            int index = findMaxIndex(lib);

            foreach (var userComp in this.curUserLib.FindAll())
            {
                isFinded = false;
                foreach (var libComp in lib.FindAll())
                {
                    if (libComp.component.Name == userComp.component.Name)
                    {
                        isFinded = true;
                        continue;
                    }
                }
                if (isFinded == false)
                {
                    index++;
                    ComponentEx cmp = new ComponentEx(index);
                    cmp.component = userComp.component.DepCopy();
                    lib.Add(cmp);
                }
            }
            string path = string.Format("{0}\\{1}.lib", Path.GetDirectoryName(this.curLib.GetPath()), Path.GetFileNameWithoutExtension(this.curLib.GetPath()));

            lib.SetPath(path);
            lib.PathLib = path;
            lib.Save();
        }
Ejemplo n.º 13
0
        public void lswDotLoad(ComponentEx comp)
        {
            this.lswDots.BeginUpdate();
            this.lswDots.Items.Clear();
            int count = 0;

            foreach (GlueDot dot in comp.component.GetPoints(this.getTech()))
            {
                count++;
                ListViewItem item = new ListViewItem();
                item.Text = count.ToString();
                item.SubItems.Add("(" + dot.point.X.ToString("F3") + "," + dot.point.Y.ToString("F3") + ")");
                item.SubItems.Add(dot.Weight.ToString("F3"));
                item.SubItems.Add(dot.Radius.ToString("F3"));
                item.SubItems.Add(dot.IsWeight.ToString());
                item.Tag  = dot;
                dot.index = count;
                this.lswDots.Items.Add(item);
            }
            this.lswDots.EndUpdate();
            adjustLswDotWidth(comp);
        }
Ejemplo n.º 14
0
        private void getType()
        {
            for (int i = 0; i < CADImport.libStrArray.Length; i++)
            {
                string line = CADImport.libStrArray[i];
                if (line.Contains("[") && line.Contains("]"))
                {
                    int    mid          = line.LastIndexOf(',');
                    int    last         = line.LastIndexOf(']');
                    string before       = line.Substring(0, mid);
                    string after        = line.Substring(mid + 1, last - mid - 1);
                    int    redindexStar = i;
                    int    redindexEnd  = i;
                    int    solindexStar = i;
                    int    solindexEnd  = i;
                    for (int j = i + 1; j < CADImport.libStrArray.Length; j++)
                    {
                        if (CADImport.libStrArray[j].Contains(".adh"))
                        {
                            redindexStar = j;
                        }
                        if (CADImport.libStrArray[j].Contains(".end"))
                        {
                            redindexEnd = j;
                            break;
                        }
                    }
                    for (int j = i + 1; j < CADImport.libStrArray.Length; j++)
                    {
                        if (CADImport.libStrArray[j].Contains(".sol"))
                        {
                            solindexStar = j;
                        }
                        if (CADImport.libStrArray[j].Contains(".end"))
                        {
                            solindexEnd = j;
                            break;
                        }
                    }
                    List <PointD> pointsred = new List <PointD>();
                    pointsred.Clear();
                    for (int k = redindexStar + 1; k < redindexEnd; k++)
                    {
                        PointD   p       = new PointD();
                        string[] splited = CADImport.libStrArray[k].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                        double   x       = 0;
                        double   y       = 0;
                        if (double.TryParse(splited[0], out x) && double.TryParse(splited[1], out y))
                        {
                            p.X = x;
                            p.Y = y;
                        }

                        pointsred.Add(p);
                    }

                    List <PointD> pointssol = new List <PointD>();
                    pointssol.Clear();
                    for (int k = solindexStar + 1; k < solindexEnd; k++)
                    {
                        PointD   p       = new PointD();
                        string[] splited = CADImport.libStrArray[k].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                        double   x       = 0;
                        double   y       = 0;
                        if (double.TryParse(splited[0], out x) && double.TryParse(splited[1], out y))
                        {
                            p.X = x;
                            p.Y = y;
                        }

                        pointssol.Add(p);
                    }



                    int index = this.lib.FindAll().Count;

                    ComponentEx comp = new ComponentEx(index + 1);
                    comp.component.Name = after;
                    foreach (var item in pointsred)
                    {
                        GlueDot dot  = new GlueDot();
                        int     cout = comp.component.AdhPoints.Count;
                        dot.index  = cout + 1;
                        dot.point  = new PointD(item.X, item.Y);
                        dot.Weight = (double)0;
                        dot.Radius = (double)0;
                        comp.component.AdhPoints.Add(dot);
                    }
                    foreach (var item in pointssol)
                    {
                        GlueDot dot  = new GlueDot();
                        int     cout = comp.component.SldPoints.Count;
                        dot.index  = cout + 1;
                        dot.point  = new PointD(item.X, item.Y);
                        dot.Weight = (double)0;
                        dot.Radius = (double)0;
                        comp.component.SldPoints.Add(dot);
                    }

                    lib.Add(comp);
                }
            }
        }