Esempio n. 1
0
        public bool WriteBCF(BCFComponent bcfComponent)
        {
            bool result = false;

            try
            {
                string guidFolder = bcfComponent.DirectoryPath;

                if (Directory.Exists(guidFolder))
                {
                    string markupPath = Path.Combine(guidFolder, "markup.bcf");
                    string imagePath  = Path.Combine(guidFolder, "snapshot.png");
                    string viewPath   = Path.Combine(guidFolder, "viewpoint.bcfv");

                    bool markupResult = WriteMarkup(markupPath, bcfComponent.Markup);
                    bool viewResult   = WriteVisualizationInfo(viewPath, bcfComponent.VisualizationInfo);
                    result = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to write bcf.\n" + ex.Message, "Write BCF", MessageBoxButton.OK, MessageBoxImage.Warning);
                result = false;
            }
            return(result);
        }
Esempio n. 2
0
 public IssueInfo(BCFComponent component)
 {
     m_component = component;
     issueTitle  = m_component.Markup.Topic.Title;
     if (null != m_component.Markup.Topic.Index)
     {
         issueNumber = m_component.Markup.Topic.Index;
     }
 }
Esempio n. 3
0
        public BCFZIP ReadBCF(string bcfPath)
        {
            BCFZIP bcfZip = new BCFZIP();

            try
            {
                string tempBcfPath   = "";
                string tempZipPath   = "";
                string tempZipFolder = "";

                FindFilePaths(bcfPath, out tempBcfPath, out tempZipPath, out tempZipFolder);

                bcfZip.FileName = bcfPath;

                byte[] buf;
                using (FileStream fileStream = new FileStream(bcfPath, FileMode.Open))
                {
                    buf = new byte[fileStream.Length];
                    fileStream.Read(buf, 0, buf.Length);
                    fileStream.Close();
                }

                if (File.Exists(tempBcfPath))
                {
                    File.Delete(tempBcfPath);
                }
                if (null != buf)
                {
                    using (FileStream fileStream = new FileStream(tempBcfPath, FileMode.OpenOrCreate))
                    {
                        fileStream.Write(buf, 0, buf.Length);
                        fileStream.Close();
                    }
                }

                if (File.Exists(tempZipPath))
                {
                    File.Delete(tempZipPath);
                }
                File.Move(tempBcfPath, tempZipPath);

                if (Directory.Exists(tempZipFolder))
                {
                    Directory.Delete(tempZipFolder, true);
                }

                if (DecompressFiles(tempZipPath, tempZipFolder))
                {
                    string[] directories = Directory.GetDirectories(tempZipFolder);
                    if (directories.Length > 0)
                    {
                        BCFComponent[] bcfComponents = new BCFComponent[directories.Length];
                        for (int i = 0; i < directories.Length; i++)
                        {
                            DirectoryInfo directoryInfo = new DirectoryInfo(directories[i]);
                            string        guidFolder    = directoryInfo.FullName;
                            string        markupPath    = Path.Combine(guidFolder, "markup.bcf");
                            string        imagePath     = Path.Combine(guidFolder, "snapshot.png");
                            string        viewPath      = Path.Combine(guidFolder, "viewpoint.bcfv");
                            string        colorPath     = Path.Combine(guidFolder, "colorscheme.xml");

                            BCFComponent bcfComponent = new BCFComponent();
                            bool         isReadable   = false;
                            bcfComponent.DirectoryPath     = guidFolder;
                            bcfComponent.GUID              = directoryInfo.Name;
                            bcfComponent.Markup            = ReadMarkup(markupPath, out isReadable);
                            bcfComponent.Snapshot          = ReadSnapshot(imagePath, out isReadable);
                            bcfComponent.VisualizationInfo = ReadVisualizationInfo(viewPath, out isReadable);
                            bcfComponent.ColorSchemeInfo   = ReadColorSchemeInfo(colorPath, out isReadable);

                            bcfComponents[i] = bcfComponent;
                        }
                        bcfZip.BCFComponents = bcfComponents;
                    }
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
            }
            return(bcfZip);
        }