示例#1
0
 public void addPart(Parts part)
 {
     partList.Add(part);
 }
示例#2
0
        /// <summary>
        /// 给指定标签页添加一个零件信息
        /// </summary>
        /// <param name="partItemBox">标签页</param>
        /// <param name="part">零件信息</param>
        private void addPartItem(ListBox partItemBox, Parts part, bool isChecked = false)
        {
            ListBoxItem partItem;
            Expander partExp;
            CheckBox partCB;
            Grid expGrid, detailGrid;
            Button openButton, settingButton, removeButtom;
            Label creatorLable, timeLabel, projectLable, typeLable, enginLable, asmLable;

            partItem = new ListBoxItem();
            partExp = new Expander();
            partCB = new CheckBox();
            openButton = new Button();
            settingButton = new Button();
            removeButtom = new Button();
            expGrid = new Grid();
            detailGrid = new Grid();
            creatorLable = new Label();
            timeLabel = new Label();
            projectLable = new Label();
            typeLable = new Label();
            enginLable = new Label();
            asmLable = new Label();

            creatorLable.Content = "作者:" + part.creator;
            timeLabel.Content = "上传时间:" + part.creationTime;
            projectLable.Content = "所属工程:" + part.project;
            typeLable.Content = "类型:" + part.type;
            if (Convert.ToBoolean(int.Parse(part.EnginDrw)))
            {
                enginLable.Content = "有配套工程图";
            }
            else
            {
                enginLable.Content = "没有配套工程图";
            }
            if (Convert.ToBoolean(int.Parse(part.AsmModel)))
            {
                asmLable.Content = "属于某个装配体模型";
            }
            else
            {
                asmLable.Content = "不属于某个装配体模型";
            }
            creatorLable.Margin = new Thickness(0, 0, 0, 0);
            timeLabel.Margin = new Thickness(0, 15, 0, 0);
            projectLable.Margin = new Thickness(0, 30, 0, 0);
            typeLable.Margin = new Thickness(0, 45, 0, 0);
            enginLable.Margin = new Thickness(0, 60, 0, 0);
            asmLable.Margin = new Thickness(0, 75, 0, 0);

            openButton.Content = "打开";
            settingButton.Content = "配置";
            removeButtom.Content = "移除";
            openButton.Margin = new Thickness(0, 0, 100, 0);
            settingButton.Margin = new Thickness(0, 0, 50, 0);
            removeButtom.Margin = new Thickness(0, 0, 0, 0);
            openButton.HorizontalAlignment = HorizontalAlignment.Right;
            settingButton.HorizontalAlignment = HorizontalAlignment.Right;
            removeButtom.HorizontalAlignment = HorizontalAlignment.Right;
            openButton.Focusable = false;
            removeButtom.Focusable = false;
            settingButton.Focusable = false;
            removeButtom.Click += new RoutedEventHandler(rmButtom_Click);
            settingButton.Click += new RoutedEventHandler(buttonAttributeEditor_Click );
            openButton.Click += new RoutedEventHandler(opButtom_Click);

            partCB.Content = part.name;
            partCB.FontSize = 15;
            partCB.Focusable = false;
            partCB.IsChecked = isChecked;
            partCB.Checked += new RoutedEventHandler(syncItemCheckBox);
            partCB.Unchecked += new RoutedEventHandler(syncItemCheckBox);

            expGrid.Children.Add(partCB);
            expGrid.Children.Add(openButton);
            expGrid.Children.Add(settingButton);
            expGrid.Children.Add(removeButtom);
            expGrid.HorizontalAlignment = HorizontalAlignment.Stretch;
            expGrid.Width = window.Width-150;

            detailGrid.Children.Add(creatorLable);
            detailGrid.Children.Add(timeLabel);
            detailGrid.Children.Add(projectLable);
            detailGrid.Children.Add(typeLable);
            detailGrid.Children.Add(enginLable);
            detailGrid.Children.Add(asmLable);
            expGrid.HorizontalAlignment = HorizontalAlignment.Stretch;

            partExp.Header = expGrid;
            partExp.Content = detailGrid;
            partExp.Focusable = false;
            partExp.HorizontalAlignment = HorizontalAlignment.Stretch;

            partItem.Content = partExp;
            partItem.IsSelected = false;
            partItem.Focusable = false;
            partItem.Tag = part;
            partItemBox.Items.Add(partItem);
            partItem.MouseEnter += new MouseEventHandler(this.item_MouseEnter);
            partItem.MouseLeave += new MouseEventHandler(item_MouseLeave);
            
        }
示例#3
0
        /// <summary>
        /// 打开文件夹中具体零件文件
        /// </summary>
        /// <param name="part"></param>
        private void opFile(Parts part)
        {
            string dirPath = @fileFolderPath + "\\" + part.project;
            string filePath = dirPath + "\\" + part.name;
            // Connect to Solid Edge.
            var application = SolidEdgeUtils.Connect(true, true);
            // Get a reference to the Documents collection.
            var documents = application.Documents;
            // Get a folder that has Solid Edge files.
            var folder = new DirectoryInfo(dirPath);
            // Get the installed version of Solid Edge.
            var solidEdgeVesion = application.GetVersion();
            // Disable prompts.
            application.DisplayAlerts = false;

            if (Directory.Exists(dirPath))
            {
                List<string> extension = new List<string>(3);
                extension.Add(".par");
                extension.Add(".asm");
                //extension.Add(".cfg");
                if (File.Exists(filePath + extension[0]))
                {
                    //string partName = System.IO.Path.GetFileName();
                    string fullPath = System.IO.Path.GetFullPath(filePath + extension[0]);
                    // Open the document.
                    var document = (SolidEdgeFramework.SolidEdgeDocument)documents.Open(fullPath);
                    // Give Solid Edge a chance to do processing.
                    application.DoIdle();
                }
                else if (File.Exists(filePath + extension[1]))
                {
                    string fullPath = Path.GetFullPath(filePath + extension[1]);
                    // Open the document.
                    var document = (SolidEdgeFramework.SolidEdgeDocument)documents.Open(fullPath);
                    // Give Solid Edge a chance to do processing.
                    application.DoIdle();
                }
            }
        }
示例#4
0
 /// <summary>
 /// 移除文件夹中具体零件文件
 /// </summary>
 /// <param name="part"></param>
 private void rmFile(Parts part)
 {
     string dirPath = @fileFolderPath + "\\" + part.project;
     string filePath = dirPath + "\\" + part.name;
     if (Directory.Exists(dirPath))
     {
         List<string> extension = new List<string>(3);
         extension.Add(".par");
         extension.Add(".asm");
         extension.Add(".cfg");
         for (int i = 0; i < 3; ++i)
         {
             if (File.Exists(filePath + extension[i]))
             {
                 File.Delete(filePath + extension[i]);
                 if (Directory.GetDirectories(dirPath).Length == 0 && Directory.GetFiles(dirPath).Length == 0)
                 {
                     Directory.Delete(dirPath);
                 }
             }
         }                
     }                    
 }
示例#5
0
        /// <summary>
        /// 从文件中移除某零件
        /// </summary>
        /// <param name="part"></param>
        private void rmXmlPart(Parts part)
        {
            XmlDocument xmlDoc = new XmlDocument();
            XmlReaderSettings settings = new XmlReaderSettings();
            settings.IgnoreComments = true;
            XmlReader reader = XmlReader.Create(@sourcePath, settings);
            xmlDoc.Load(reader);
            reader.Close();

            XmlNode xmlPartData = xmlDoc.SelectSingleNode("part_data");
            XmlElement xePartData = (XmlElement)xmlPartData;
            string partPath = string.Format("/part_data/project[@Name=\"{0}\"]/part[@Name=\"{1}\"]", part.project, part.name);
            XmlElement xePart = (XmlElement)xePartData.SelectSingleNode(partPath);
            XmlNode xmlProject = xePart.ParentNode;
            xePart.ParentNode.RemoveChild(xePart);            
            if (!xmlProject.HasChildNodes) xmlProject.ParentNode.RemoveChild(xmlProject);
            xmlDoc.Save(@sourcePath);
        }
示例#6
0
        /// <summary>
        /// 从文件中读取零件信息与工程信息
        /// </summary>
        public void readParts()
        {
            ProjectofParts projectData;
            Parts partData;
            string name;
            string creator;
            string creationTime;
            string project;
            string type;
            string EnginDrw;
            string AsmModel;

            projectList = new List<ProjectofParts>();
            partList = new List<Parts>();

            XmlDocument xmlDoc = new XmlDocument();
            XmlReaderSettings settings = new XmlReaderSettings();
            settings.IgnoreComments = true;
            XmlReader reader = XmlReader.Create(@sourcePath, settings);
            xmlDoc.Load(reader);

            XmlNode xmlPartData = xmlDoc.SelectSingleNode("part_data");
            XmlNodeList xmlProjectList = xmlPartData.ChildNodes;
            foreach(XmlNode xmlProject in xmlProjectList)
            {
                XmlElement xeProject = (XmlElement)xmlProject;
                projectData = new ProjectofParts(xeProject.GetAttribute("Name").ToString());
                XmlNodeList xmlPartList = xmlProject.ChildNodes;
                foreach(XmlNode xmlPart in xmlPartList)
                {
                    XmlElement xePart = (XmlElement)xmlPart;
                    name = xePart.GetAttribute("Name").ToString();
                    creator = xePart.GetAttribute("Creator").ToString();
                    project = xePart.GetAttribute("Project").ToString();
                    creationTime = xePart.GetAttribute("CreationTime").ToString();
                    type = xePart.GetAttribute("Type").ToString();
                    EnginDrw = xePart.GetAttribute("EnginDrw").ToString();
                    AsmModel = xePart.GetAttribute("AsmModel").ToString();

                    partData = new Parts(name, creator, creationTime, project, type, EnginDrw, AsmModel);
                    projectData.addPart(partData);
                    projectData.partListSort();
                    partList.Add(partData);

                }
                projectList.Add(projectData);
            }
            projectListSort();
            partListSort();
            reader.Close();
        }