示例#1
0
        static void Main(string[] args)
        {
            var bcf = new BCF {
                Project = new ProjectXMLFile {
                    Project = new BCFProject {
                        Name      = "Sample Project",
                        ProjectId = "0HE7wY7irAE9b6u8RhVcUT"
                    }
                },
                Version = new VersionXMLFile("1.0"),
                Topics  = new List <Topic> {
                    new Topic {
                        Markup = new MarkupXMLFile {
                            Header = new BCFHeader {
                                Files = new List <BCFFile> {
                                    new BCFFile {
                                        Date       = DateTime.Now,
                                        Filename   = "Sample.ifc",
                                        IfcProject = "0HE7wY7irAE9b6u8RhVcUT",
                                        IfcSpatialStructureElement = "3sYjbGNsP7hQb8RP1A$gnO"
                                    }
                                }
                            },
                            Comments = new List <BCFComment> {
                                new BCFComment(
                                    Guid.NewGuid(),
                                    Guid.NewGuid(),
                                    "open",
                                    DateTime.Now,
                                    "Blaseius Aichel",
                                    "This needs to be replaced completely!")
                                {
                                    Topic = new AttrIDNode(new Guid("9B981279-4B63-46A0-ABF0-432E27B5ADC0"))
                                }
                            },
                            Topic      = new BCFTopic(new Guid("9B981279-4B63-46A0-ABF0-432E27B5ADC0"), "Sample Topic"),
                            Viewpoints = new List <BCFViewpoint> {
                                new BCFViewpoint(Guid.NewGuid())
                                {
                                    Snapshot = "snapshot01.png", Viewpoint = "Base Viewpoint"
                                }
                            }
                        },
                        Snapshots = new List <KeyValuePair <string, byte[]> > {
                            new KeyValuePair <string, byte[]>("snapshot01.png", File.ReadAllBytes("snapshot01.png"))
                        },
                        Visualization = new VisualizationXMLFile {
                        }
                    }
                }
            };

            using (var output = File.Create("sample.bcf"))
            {
                var data = bcf.Serialize();
                data.CopyTo(output);
                output.Close();
            }
        }
示例#2
0
        private static List <Topic> LoadTopics(string bcfFilePath)
        {
            using (FileStream stream = System.IO.File.Open(bcfFilePath, FileMode.Open))
            {
                BCF bcf = BCF.Deserialize(stream);

                return(bcf.Topics);
            }
        }
示例#3
0
        private void bttnRename_Click(object sender, EventArgs e)
        {
            try
            {
                if (listViewIssue.SelectedIndices.Count > 0)
                {
                    int          index = listViewIssue.SelectedIndices[0];
                    ListViewItem item  = listViewIssue.Items[index];

                    if (null != item.Tag)
                    {
                        BCF        bcf        = item.Tag as BCF;
                        RenameForm renameForm = new RenameForm(bcf.IssueNumber);
                        if (renameForm.ShowDialog() == DialogResult.OK)
                        {
                            bcf.IssueNumber = renameForm.IssueNumber;
                            renameForm.Close();

                            string topicId = bcf.MarkUp.MarkUpTopic.TopicGuid;
                            if (bcfFiles.ContainsKey(topicId))
                            {
                                bcfFiles.Remove(topicId);
                                bcfFiles.Add(topicId, bcf);
                            }

                            listViewIssue.Items.RemoveAt(index);

                            ListViewItem newItem = new ListViewItem();
                            newItem.Text = bcf.IssueNumber;
                            newItem.SubItems.Add(bcf.MarkUp.MarkUpTopic.Title);
                            newItem.Tag = bcf;
                            listViewIssue.Items.Add(newItem);

                            listViewIssue.Sort();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to change the number of the issue.\n" + ex.Message, "CommandForm:bttnRename_Click", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
示例#4
0
        private List <Models.DisplayTopic> LoadTopics(string bcfFilePath, string BCFFileName)
        {
            using (FileStream stream = System.IO.File.Open(bcfFilePath, FileMode.Open))
            {
                try
                {
                    BCF bcf = BCF.Deserialize(stream);

                    List <Models.DisplayTopic> DisplayTopics = bcf.Topics.Select(o => new Models.DisplayTopic(o)).ToList();

                    return(DisplayTopics);
                }
                catch (Exception ex)
                {
                    //Fail silently :-(
                    return(new List <Models.DisplayTopic>());
                }
            }
        }
示例#5
0
 private void DisplayIssues()
 {
     try
     {
         foreach (string topicId in bcfFiles.Keys)
         {
             BCF          bcf  = bcfFiles[topicId];
             ListViewItem item = new ListViewItem();
             item.Text = bcf.IssueNumber;
             item.SubItems.Add(bcf.MarkUp.MarkUpTopic.Title);
             item.Tag = bcf;
             listViewIssue.Items.Add(item);
         }
         listViewIssue.Sort();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Failed to display BCF Issues onto the command window.\n" + ex.Message, "CommandForm:DisplayIssues", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
示例#6
0
        private void listViewIssue_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listViewIssue.SelectedItems.Count > 0)
            {
                int i = listViewIssue.SelectedIndices[0];
                if (i > -1)
                {
                    ListViewItem item = listViewIssue.Items[i];
                    if (null != item.Tag)
                    {
                        BCF bcf = item.Tag as BCF;
                        selectedView    = bcf.IssueNumber.ToString() + " - " + bcf.MarkUp.MarkUpTopic.Title;
                        selectedBCF     = bcf;
                        selectedComment = new Comment();
                    }

                    ClearAllContents();
                    DisplayBcfData(i);
                }
            }
        }
示例#7
0
        private void DisplayBcfData(int index)
        {
            try
            {
                ListViewItem item = listViewIssue.Items[index];
                if (null != item.Tag)
                {
                    BCF bcf = item.Tag as BCF;
                    selectedBCF = bcf;
                    //snapshot
                    pictureBox.Image = bcf.SnapShot;

                    //listViewModel
                    foreach (IfcFile ifc in bcf.MarkUp.Header)
                    {
                        ListViewItem modelItem = new ListViewItem();
                        modelItem.Text = ifc.FileName;
                        modelItem.SubItems.Add(ifc.Date.ToString());
                        modelItem.Tag = ifc;

                        listViewModel.Items.Add(modelItem);
                    }

                    //listViewStatus
                    foreach (Comment comment in bcf.MarkUp.Comments)
                    {
                        ListViewItem commentItem = new ListViewItem();
                        commentItem.Text = comment.Date.ToString();
                        commentItem.SubItems.Add(comment.VerbalStatus);
                        commentItem.SubItems.Add(comment.Author);
                        commentItem.SubItems.Add(comment.CommentString);
                        commentItem.SubItems.Add(comment.Action);
                        commentItem.Tag = comment;

                        listViewStatus.Items.Add(commentItem);
                    }

                    //listViewComponents
                    int i = 1;
                    int j = 1;
                    foreach (HOK.BCFReader.GenericClasses.Component component in bcf.ViewPoint.Components)
                    {
                        int          eId           = 0;
                        ListViewItem componentItem = new ListViewItem();
                        if (null != component.AuthoringToolId)
                        {
                            if (int.TryParse(component.AuthoringToolId, out eId))
                            {
                                ElementId elementId = new ElementId(eId);
                                Element   element   = m_doc.GetElement(elementId);
                                if (null != element)
                                {
                                    componentItem.Text = element.Name;
                                    componentItem.Tag  = element;
                                }
                                else
                                {
                                    componentItem.Text      = "Missing Component #" + i;
                                    componentItem.ForeColor = System.Drawing.Color.Gray;
                                    i++;
                                }
                            }
                            else
                            {
                                componentItem.Text      = "Unknown Component #" + j;
                                componentItem.ForeColor = System.Drawing.Color.Gray;
                                j++;
                            }
                            componentItem.SubItems.Add(component.AuthoringToolId);
                        }
                        else
                        {
                            componentItem.Text = "Unknown Component #" + j;
                            componentItem.SubItems.Add(component.IfcGuid);
                            componentItem.ForeColor = System.Drawing.Color.Gray;
                            j++;
                        }
                        listViewComponents.Items.Add(componentItem);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to display BCF data onto the command window.\n" + ex.Message, "CommandForm:DisplayBcfData", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }