Ejemplo n.º 1
0
        public void generateSnapshot(string folderIssue)
        {
            try
            {
                string snapshot = Path.Combine(folderIssue, "snapshot.png");

                // get the state of COM
                ComApi.InwOpState10 oState = ComBridge.State;
                // get the IO plugin for image
                ComApi.InwOaPropertyVec options = oState.GetIOPluginOptions("lcodpimage");

                //export the viewpoint to the image
                oState.DriveIOPlugin("lcodpimage", snapshot, options);
                System.Drawing.Bitmap  oBitmap     = new System.Drawing.Bitmap(snapshot);
                System.IO.MemoryStream ImageStream = new System.IO.MemoryStream();
                oBitmap.Save(ImageStream, System.Drawing.Imaging.ImageFormat.Jpeg);
                oBitmap.Dispose();
                //IM.postAttach(issueKey, File.ReadAllBytes(snapshot), IM.ConvertToBytes(v), g);
                //   postAttach2(issueKey, ConvertToBytes(v), "viewpoint.bcfv");
            }
            catch (System.Exception ex1)
            {
                MessageBox.Show("exception: " + ex1);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructor
        /// </summary>
        public Navis2JiraWin()
        {
            InitializeComponent();
            DataContext = jira;
            jira.IssuesBCFCollection = new ObservableCollection <IssueBCF>();
            oState = ComBridge.State;

            Refresh();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Constructor
        /// </summary>
        public Navis2JiraWin()
        {
            InitializeComponent();
            DataContext = jira;
            jira.IssuesBCFCollection = new ObservableCollection<IssueBCF>();
            oState = ComBridge.State;

            Refresh();
        }
Ejemplo n.º 4
0
        private void AddURL(string name, string link, string category, List <stringedLink> exLinks)
        {
            ComApi.InwOpState10 state = ComApiBridge.ComApiBridge.State;

            // create the hyperlink collection
            ComApi.InwURLOverride oMyURLOoverride = (ComApi.InwURLOverride)state.ObjectFactory(ComApi.nwEObjectType.eObjectType_nwURLOverride, null, null);

            foreach (var ex in exLinks)
            {
                // create one hyperlink
                ComApi.InwURL2 oMyURL = (ComApi.InwURL2)state.ObjectFactory(ComApi.nwEObjectType.eObjectType_nwURL, null, null);

                oMyURL.name = ex.Link_Name;
                oMyURL.URL  = ex.Link_URL;
                oMyURL.SetCategory(ex.Link_Category, "LcOaURL" + ex.Link_Category + "Hyperlink");

                // add the new hyperlink to the hyperlink collection
                ComApi.InwURLColl oURLColl = oMyURLOoverride.URLs();
                oURLColl.Add(oMyURL);

                // get current selected items
                ModelItemCollection modelItemCollectionIn = new ModelItemCollection(navisApp.ActiveDocument.CurrentSelection.SelectedItems);
                //convert to InwOpSelection of COM API
                ComApi.InwOpSelection comSelectionOut = ComApiBridge.ComApiBridge.ToInwOpSelection(modelItemCollectionIn);
                // set the hyplerlink of the model items
                state.SetOverrideURL(comSelectionOut, oMyURLOoverride);
                // enable to the hyperlinks visible
                state.URLsEnabled = true;
            }

            // create recent hyperlink
            {
                ComApi.InwURL2 oMyURL = (ComApi.InwURL2)state.ObjectFactory(ComApi.nwEObjectType.eObjectType_nwURL, null, null);

                oMyURL.name = name;
                oMyURL.URL  = link;
                oMyURL.SetCategory(category, "LcOaURL" + category + "Hyperlink");

                // add the new hyperlink to the hyperlink collection
                ComApi.InwURLColl oURLColl = oMyURLOoverride.URLs();
                oURLColl.Add(oMyURL);

                // get current selected items
                ModelItemCollection modelItemCollectionIn = new ModelItemCollection(navisApp.ActiveDocument.CurrentSelection.SelectedItems);
                //convert to InwOpSelection of COM API
                ComApi.InwOpSelection comSelectionOut = ComApiBridge.ComApiBridge.ToInwOpSelection(modelItemCollectionIn);
                // set the hyplerlink of the model items
                state.SetOverrideURL(comSelectionOut, oMyURLOoverride);
                // enable to the hyperlinks visible
                state.URLsEnabled = true;
            }
        }
Ejemplo n.º 5
0
        public void GetNavisSnapshot()
        {
            try
            {
                string tempImg = Path.Combine(Path.GetTempPath(), "BCFier", Path.GetTempFileName() + ".png");
                // get the state of COM
                ComApi.InwOpState10 oState = ComBridge.State;
                // get the IO plugin for image
                ComApi.InwOaPropertyVec options = oState.GetIOPluginOptions("lcodpimage");
                //export the viewpoint to the image
                oState.DriveIOPlugin("lcodpimage", tempImg, options);
                Bitmap bitmap      = new Bitmap(tempImg);
                var    imageStream = new MemoryStream();
                bitmap.Save(imageStream, ImageFormat.Jpeg);
                bitmap.Dispose();

                AddViewControl.AddViewpoint(tempImg);
                File.Delete(tempImg);
            }
            catch (Exception ex1)
            {
                MessageBox.Show("exception: " + ex1, "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Background Worker
        /// </summary>
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = (BackgroundWorker)sender;

            //create a temporary directory
            _tempFolder = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "CASE.Navis2BCF", System.IO.Path.GetRandomFileName());
            if (!Directory.Exists(_tempFolder))
            {
                Directory.CreateDirectory(_tempFolder);
            }

            //if set to attach selected elements, do it only once
            if (_elemCheck == 1)
            {
                elementList = oDoc.CurrentSelection.SelectedItems.Where(o => o.InstanceGuid != Guid.Empty).ToList <ModelItem>();
            }

            for (int i = 0; i < jira.IssuesBCFCollection.Count(); i++)
            {
                try
                {
                    IssueBCF issue = jira.IssuesBCFCollection[i];

                    //for each issue create a subdirectory named as the guid
                    string        g           = Guid.NewGuid().ToString();
                    string        issueFolder = System.IO.Path.Combine(_tempFolder, g);
                    DirectoryInfo di          = Directory.CreateDirectory(issueFolder);

                    // get the state of COM
                    ComApi.InwOpState10 oState = ComBridge.State;
                    // get the IO plugin for image
                    ComApi.InwOaPropertyVec options = oState.GetIOPluginOptions("lcodpimage");
                    // configure the option "export.image.format" to export png and image size
                    foreach (ComApi.InwOaProperty opt in options.Properties())
                    {
                        if (opt.name == "export.image.format")
                        {
                            opt.value = "lcodpexpng";
                        }
                        if (opt.name == "export.image.width")
                        {
                            opt.value = 1600;
                        }
                        if (opt.name == "export.image.height")
                        {
                            opt.value = 900;
                        }
                    }


                    string snapshot = System.IO.Path.Combine(issueFolder, "snapshot.png");

                    XDocument v = new XDocument();

                    //need to use a dispatcher to access resource on a different process
                    Dispatcher.BeginInvoke(new Action(() =>
                    {
                        oDoc.SavedViewpoints.CurrentSavedViewpoint = issue.viewpoint;
                        v = generateViewpoint(issue.viewpoint.Viewpoint);
                    }));
                    XDocument m = new XDocument();
                    m = generateMarkup(issue, g);
                    //set the view to the saved one

                    //export the viewpoint to the image
                    oState.DriveIOPlugin("lcodpimage", snapshot, options);
                    System.Drawing.Bitmap  oBitmap     = new System.Drawing.Bitmap(snapshot);
                    System.IO.MemoryStream ImageStream = new System.IO.MemoryStream();
                    oBitmap.Save(ImageStream, System.Drawing.Imaging.ImageFormat.Jpeg);
                    oBitmap.Dispose();
                    v.Save(issueFolder + @"\viewpoint.bcfv");
                    m.Save(issueFolder + @"\markup.bcf");
                } // END TRY
                catch (System.Exception ex1)
                {
                    MessageBox.Show("exception: " + ex1);
                }
                worker.ReportProgress((100 * (i + 1)) / jira.IssuesBCFCollection.Count());// HAS TO BE OUT OF THE DISPATCHER!
            }// END LOOP
        }