コード例 #1
0
        public bool LoadPatternInfo(string programPath)
        {
            Stream fstream = null;

            try
            {
                string extension = Path.GetExtension(programPath);
                if (extension != ".pattern")
                {
                    MessageBox.Show("请确认打开的是后缀为pattern的文件");
                    return(false);
                }
                fstream = new FileStream(programPath, FileMode.Open, FileAccess.Read);
                BinaryFormatter binFormat = new BinaryFormatter();
                this.currPInfo = (PatternInfo)binFormat.Deserialize(fstream);
                return(true);
            }
            catch (Exception e)
            {
                //throw e;
                return(false);
            }
            finally
            {
                if (fstream != null)
                {
                    fstream.Close();
                }
            }
        }
コード例 #2
0
        private void lswPath_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.currPath = String.Empty;
            if (this.lswPath.SelectedIndices.Count > 0)
            {
                if (this.lswPath.SelectedIndices[0] > -1)
                {
                    this.currPath = this.lswPath.SelectedItems[0].Text;
                }
                else
                {
                    return;
                }
            }
            if (String.IsNullOrEmpty(currPath))
            {
                return;
            }
            this.patternName         = Path.GetFileName(currPath);
            this.txtPatternName.Text = this.patternName;
            this.currPInfo           = CADImport.Instance.GetPatternInfo(currPath);

            this.listViewLoadData();
            //画图
            this.btnGenerate_Click(null, null);
        }
コード例 #3
0
        /// <summary>
        /// 加载文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.InitialDirectory = Application.StartupPath;
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                this.currPath            = openFileDialog.FileName;
                this.patternName         = Path.GetFileName(currPath);
                this.txtPatternName.Text = this.patternName;
            }
            if (String.IsNullOrEmpty(currPath))
            {
                return;
            }
            CADImport.Instance.AddFilePath(this.currPath);
            this.lswPathLoad();
            if (this.ckbLoadDefault.Checked)
            {
                this.currPInfo = CADImport.Instance.GetPatternInfo(this.currPath);
                this.currPInfo.GetText();
                this.currPInfo.LoadDefault();
                this.listViewLoadData();
            }
        }
コード例 #4
0
 private void lswPath_SelectedIndexChanged(object sender, EventArgs e)
 {
     this.currPath = String.Empty;
     if (this.lswPath.SelectedIndices.Count > 0)
     {
         if (this.lswPath.SelectedIndices[0] > -1)
         {
             this.currPath = this.lswPath.SelectedItems[0].Text;
         }
         else
         {
             return;
         }
     }
     if (String.IsNullOrEmpty(currPath))
     {
         return;
     }
     CADImport.Instance.CurrTrajPath = currPath;
     this.currPinfo = CADImport.Instance.GetCurPatternInfo();
     if (this.currPinfo == null)
     {
         MessageBox.Show("指定轨迹不存在");
         return;
     }
     this.UpdateTxtSeperator();
     this.showHeadslst();
     //this.UpdatelstHeadSelected();
     this.updateHeadSelFirst();
     this.updateCmbLayOut();
     this.listViewLoadData();
     this.lstPathColor();
 }
コード例 #5
0
        /// <summary>
        /// 加载文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click_1(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.InitialDirectory = Application.StartupPath;
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                this.currPath = openFileDialog.FileName;
            }
            if (String.IsNullOrEmpty(currPath))
            {
                return;
            }
            CADImport.Instance.AddFilePath(this.currPath);
            this.lswPathLoad();
            if (this.ckbLoadDefault.Checked)
            {
                this.currPinfo = CADImport.Instance.GetPatternInfo(this.currPath);
                //this.currPinfo.GetText();
                this.currPinfo.LoadDefault();
                this.updateCmbLayOut();
                this.listViewLoadData();
            }
            else
            {
                this.currPinfo = CADImport.Instance.GetPatternInfo(this.currPath);
                this.UpdateTxtSeperator();
            }
            this.lstPathColor();
        }
コード例 #6
0
        /// <summary>
        /// lswComponents中加载数据
        /// </summary>
        private void listViewLoadData()
        {
            this.initLswComponents2();
            PatternInfo patInfor = this.currPinfo;

            lswComponents.BeginUpdate();
            this.lswComponents.Items.Clear();
            int count = 0;

            foreach (CompProperty comp in patInfor.CompListStanded)
            {
                count++;
                ListViewItem item = new ListViewItem();
                item.Text = count.ToString();
                foreach (ColumnHeader column in this.lswComponents.Columns)
                {
                    if (column.Text == HeadName.Design.ToString())
                    {
                        item.SubItems.Add(comp.Desig);
                        continue;
                    }
                    if (column.Text == HeadName.Comp.ToString())
                    {
                        item.SubItems.Add(comp.Comp);
                        continue;
                    }
                    if (column.Text == HeadName.X.ToString())
                    {
                        item.SubItems.Add(comp.Mid.X.ToString("F3"));
                        continue;
                    }
                    if (column.Text == HeadName.Y.ToString())
                    {
                        item.SubItems.Add(comp.Mid.Y.ToString("F3"));
                        continue;
                    }
                    if (column.Text == HeadName.Rot.ToString())
                    {
                        item.SubItems.Add(comp.Rotation.ToString("F3"));
                        continue;
                    }
                    if (column.Text == HeadName.LayOut.ToString())
                    {
                        item.SubItems.Add(comp.LayOut);
                        continue;
                    }
                }

                lswComponents.Items.Add(item);
            }
            lswComponents.EndUpdate();
            this.adjustColumnWidth();
        }
コード例 #7
0
 private void loadTrajectory()
 {
     this.showRunInfo("Start loading ...");
     if (new DialogImport().ShowDialog() == DialogResult.OK)
     {
         PatternInfo pattern = CADImport.Instance.GetCurPatternInfo();
         if (pattern != null && pattern.CompListStanded != null && pattern.CompListStanded.Count >= 0)
         {
             this.laststepStatus = true;
             this.showRunInfo("Successfully open the trajectory file,Please click the next key to edit Component Library");
             return;
         }
     }
     this.showRunInfo("failed to load trajectory file,Please click the next key to load the trajectory file again");
     this.laststepStatus = false;
 }
コード例 #8
0
        private void editTrajetory()
        {
            this.showRunInfo("Start editing the trajetory and create the pattern ...");
            PatternInfo pattern = CADImport.Instance.GetCurPatternInfo();

            if (new TrajectoryDialog02().ShowDialog() == DialogResult.OK)
            {
                this.laststepStatus = true;
                this.btnNext.Text   = "Done";
                this.showRunInfo("Successfully edit the trajectory,Please click the Done key to create the Pattern");
            }
            else
            {
                this.laststepStatus = false;
            }
        }
コード例 #9
0
        private void componentLibEdit()
        {
            this.showRunInfo("Start editing Component Library ...");
            PatternInfo pattern = CADImport.Instance.GetCurPatternInfo();

            if (new DialogComponentLibEdit().Setup(pattern).ShowDialog() == DialogResult.OK)
            {
                this.laststepStatus = true;
                this.showRunInfo("Successfully edit the Component Library,Please click the next key to edit the trajectory");
            }
            else
            {
                this.laststepStatus = false;
                this.showRunInfo("failed to edit the Component Library,Please click the next key to edit Component Library again");
            }
        }
コード例 #10
0
 private void ImportEdit_Load(object sender, EventArgs e)
 {
     this.initLswPath();
     this.lswPathLoad();
     this.lstPathColor();
     //FileUtils.ReadLines(pathHelp, out textHelp);
     if (CADImport.Instance.GetCurPatternInfo() == null)
     {
         return;
     }
     this.currPinfo = CADImport.Instance.GetCurPatternInfo();
     this.UpdateTxtSeperator();
     this.showHeadslst();
     this.updateHeadSelFirst();
     this.updateCmbLayOut();
 }
コード例 #11
0
        public void AddFilePath(string trajPath)
        {
            if (String.IsNullOrEmpty(trajPath))
            {
                return;
            }
            this.CurrTrajPath = trajPath;
            if (PathPatternDic.ContainsKey(trajPath))
            {
                this.RemovePatternInfo(trajPath);
            }
            PatternInfo patterInfo = new PatternInfo(trajPath);
            //获取文本
            Result res = patterInfo.GetText();

            if (res != Result.OK)
            {
                MessageBox.Show("加载轨迹文件失败");
                return;
            }
            PathPatternDic.Add(trajPath, patterInfo);
        }
コード例 #12
0
 private void lstPathColor()
 {
     foreach (ListViewItem item in lswPath.Items)
     {
         PatternInfo p = CADImport.Instance.GetPatternInfo(item.Text);
         if (!p.IsPatternCreated)
         {
             item.ForeColor = Color.Red;
         }
         else
         {
             item.ForeColor = Color.Black;
         }
         if (item.Text == this.currPath)
         {
             item.BackColor = Color.DeepSkyBlue;
         }
         else
         {
             item.BackColor = Color.White;
         }
     }
 }
コード例 #13
0
        /// <summary>
        /// lswComponents中加载数据
        /// </summary>
        private void listViewLoadData()
        {
            PatternInfo patInfor = this.currPInfo;

            lswComponents.BeginUpdate();
            this.lswComponents.Items.Clear();
            int count = 0;

            foreach (CompProperty comp in patInfor.CompListStanded)
            {
                count++;
                ListViewItem item = new ListViewItem();
                item.Text = count.ToString();
                item.SubItems.Add(comp.Desig);
                item.SubItems.Add(comp.Comp);
                item.SubItems.Add(comp.Mid.X.ToString("F3"));
                item.SubItems.Add(comp.Mid.Y.ToString("F3"));
                item.SubItems.Add(comp.Rotation.ToString("F3"));
                item.SubItems.Add(comp.LayOut);
                lswComponents.Items.Add(item);
            }
            lswComponents.EndUpdate();
            this.adjustColumnWidth();
        }
コード例 #14
0
        private void TrajectoryDialog_Load(object sender, EventArgs e)
        {
            FileUtils.ReadLines(pathHelp, out textHelp);
            //当前是否有程序
            if (FluidProgram.Current == null)
            {
                this.txtPatternName.Enabled = false;
                this.lblPatternName.Enabled = false;
            }
            this.currPInfo = CADImport.Instance.GetCurPatternInfo();
            if (this.currPInfo == null)
            {
                return;
            }
            this.patternName = this.currPInfo.PatternName;
            if (string.IsNullOrEmpty(this.patternName))
            {
                return;
            }

            this.txtPatternName.Text = this.patternName;
            this.initialListView();
            this.listViewLoadData();
        }
コード例 #15
0
 public DialogComponentLibEdit Setup(PatternInfo pInfo)
 {
     this.curPinfo   = pInfo;
     this.curUserLib = this.curPinfo.LibUser;
     return(this);
 }
コード例 #16
0
 public ImportEdit Setup(PatternInfo pinfo)
 {
     this.Currinfo = pinfo;
     return(this);
 }