Example #1
0
        public static void getNoteTypeList()
        {
            try
            {
                if (File.Exists(GV.notetypefile))
                {
                    System.IO.StreamReader fileData = new System.IO.StreamReader(GV.notetypefile);
                    //Execute a loop over the rows.
                    string line;

                    while ((line = fileData.ReadLine()) != null)
                    {
                        if (!GV.noteTypeListColl.Contains(line))
                        {
                            GV.noteTypeListColl.Add(line);
                        }
                    }
                    fileData.Close();
                    UIH.toastIT("Note list files read sucessfully!", "File Read", NotificationType.Information);
                }
                else
                {
                    UIH.toastIT("Note able to read note list file!", "Note Type list File Read Error", NotificationType.Error);
                }
            }
            catch (System.Exception ex)
            {
                UIH.toastIT("Note able to read from note list file!", "Note Type list File Read Error", NotificationType.Error);
            }
        }
Example #2
0
        private void btn_browse_mapperFile_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Filter           = "Mapper XML files (*.XMLMapper)|*.XMLMapper|CSV Mapper (*.CSVMapper1)|*.CSVMapper1"; // "Mapper files (*.Mapper)|*.map";
                ofd.RestoreDirectory = true;
                DialogResult sdResult = ofd.ShowDialog();

                foreach (string file in ofd.FileNames)
                {
                    //extract the data from the selected file.
                    GH.getFileObject(file, "mapper");
                }
                //set that file to the combobox
                cBox_Mapper.SelectedIndex = cBox_Mapper.Items.Count - 1;
                C3D_2016_Anno.Global.fileItem FI = (C3D_2016_Anno.Global.fileItem)cBox_Mapper.SelectedItem;

                GH.getMapper(FI.filePath);
                //set that file to the combobox
                UIH.toastIT("Mapper files read sucessfully!", "File Read", NotificationType.Information);
            }
            catch (System.Exception ee)
            {
                GH.writeLog(ee.ToString());
            }
        }
Example #3
0
        private void btn_selectViewport_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //check if defnition and  note list are selected
                if (checkifDefnitionsSelected())
                {
                    //rest progressbar
                    proBar.Value = 0;

                    using (GV.Doc.LockDocument())
                    {
                        short val = (short)AcAp.GetSystemVariable("CVPORT");

                        if (val != 1)
                        {
                            GV.processStatus = false;
                            UIH.toastIT("This option works only in Paperspace (Layouts), please swtich to paperspace and try again!", "Viewport Not Preset", NotificationType.Error);
                        }
                        else
                        {
                            Helper.ViewportExtensions.getvPortCoordinatesADV();
                            if (GV.processStatus == true && GV.selObjects_forProcessing != null)
                            {
                                bw.WorkerSupportsCancellation = true;
                                bw.WorkerReportsProgress      = true;
                                //bw.ProgressChanged += bw_ProgressChanged;
                                bw.DoWork += new DoWorkEventHandler(bw_UpdateProgressBar);
                                //start work
                                if (bw.IsBusy != true)
                                {
                                    bw.RunWorkerAsync();
                                }

                                ProcessLabels();
                                updateUIdata();

                                UIH.toastIT("All selected labels processed successfully!", "Status", NotificationType.Success);
                            }
                        }
                    }
                }
            }
            catch (Autodesk.Civil.CivilException ex)
            {
                GH.errorBox(ex.ToString());
            }
            catch (Autodesk.AutoCAD.Runtime.Exception ex)
            {
                GH.errorBox(ex.ToString());
            }
            catch (System.Exception ee)
            {
                GH.errorBox(ee.ToString());
            }
        }
Example #4
0
        private void btn_selectLabels_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //check if defnition and  note list are selected
                if (checkifDefnitionsSelected())
                {
                    //rest progressbar
                    proBar.Value = 0;


                    using (GV.Doc.LockDocument())
                    {
                        PromptSelectionResult psRes = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.GetSelection(new SelectionFilter(LCH.selectionFilter(GV.labelFilterType)));

                        if (psRes.Status == PromptStatus.OK)
                        {
                            SelectionSet acSSet = psRes.Value;
                            GV.selObjects_forProcessing = acSSet.GetObjectIds();

                            //get key notes based on the selection

                            bw.WorkerSupportsCancellation = true;
                            bw.WorkerReportsProgress      = true;
                            //bw.ProgressChanged += bw_ProgressChanged;
                            bw.DoWork += new DoWorkEventHandler(bw_UpdateProgressBar);
                            //start work
                            if (bw.IsBusy != true)
                            {
                                bw.RunWorkerAsync();
                            }

                            ProcessLabels();

                            updateUIdata();

                            UIH.toastIT("All selected labels processed successfully!", "Status", NotificationType.Success);
                        }
                    }
                }
            }
            catch (Autodesk.Civil.CivilException ex)
            {
                GH.errorBox(ex.ToString());
            }
            catch (Autodesk.AutoCAD.Runtime.Exception ex)
            {
                GH.errorBox(ex.ToString());
            }
            catch (System.Exception ee)
            {
                GH.errorBox(ee.ToString());
            }
        }
Example #5
0
 private void btn_fetchtamplateFile_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         int index = cBox_template.SelectedIndex;
         GH.getFiles("template");
         cBox_template.SelectedIndex = index;
         UIH.toastIT("Defnition files read sucessfully!", "File Read", NotificationType.Information);
     }
     catch (System.Exception ee)
     {
         GH.writeLog(ee.ToString());
     }
 }
Example #6
0
        public static List <string> getSST(string styleName)
        {
            try
            {
                if (File.Exists(GV.sstFile))
                {
                    System.IO.StreamReader file = new System.IO.StreamReader(GV.sstFile);
                    //Execute a loop over the rows.
                    string line;

                    while ((line = file.ReadLine()) != null)
                    {
                        SSTList = line.Split(Convert.ToChar('|')).ToList();

                        foreach (string item in SSTList)
                        {
                            //check the style name if it matches and get rest of the data.
                            if (item == styleName)
                            {
                                string noteType = SSTList[1];
                                string KNLoc    = SSTList[2];
                                return(SSTList);
                            }
                            else
                            {
                                SSTList = null;
                            }
                        }
                    }
                    file.Close();
                }
                else
                {
                    UIH.toastIT("Note list files read sucessfully!", "File Read", NotificationType.Information);
                }
            }
            catch (System.Exception ex)
            {
                UIH.toastIT("Note able to find Style details for " + styleName + " Please add style details to SST file to continue!", "SST File Read Error", NotificationType.Warning);
                return(null);
            }
            if (SSTList == null)
            {
                UIH.toastIT("Note able to find Style details for " + styleName + " Please add style details to SST file to continue!", "SST File Read Error", NotificationType.Warning);
            }
            return(null);
        }
Example #7
0
 private void NoteType_styleAssingmentHeader_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         UIH.sortColumn(sender, listView_styleComponentMapper);
     }
     catch (Autodesk.Civil.CivilException ex)
     {
         GH.errorBox(ex.ToString());
     }
     catch (Autodesk.AutoCAD.Runtime.Exception ex)
     {
         GH.errorBox(ex.ToString());
     }
     catch (System.Exception ee)
     {
         GH.errorBox(ee.ToString());
     }
 }
Example #8
0
 public static void updateNoteTypeList()
 {
     try
     {
         if (File.Exists(GV.notetypefile))
         {
             using (var writer = new StreamWriter(GV.notetypefile))
             {
                 foreach (string line in GV.noteTypeListColl)
                 {
                     writer.WriteLine(line);
                 }
                 UIH.toastIT("Note Type List File Updated Successfully!", "Note Type list File Write", NotificationType.Success);
             }
         }
     }
     catch (System.Exception ex)
     {
         UIH.toastIT("Note able to write to note list file!", "Note Type list File Write Error", NotificationType.Error);
     }
 }
Example #9
0
        private void btn_browse_templateFile_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // Create an instance of the open file dialog box.
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Filter           = "Note list XML files (*.XMLNotes)|*.XMLNotes|CSV Notes without double quotes (*.CSVNotes1)|*.CSVNotes1|CSV Notes with double quotes (*.CSVNotes2)|*.CSVNotes2"; //"XML files (*.xml)|*.def";
                ofd.RestoreDirectory = true;
                DialogResult sdResult = ofd.ShowDialog();



                if (sdResult != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }

                foreach (string file in ofd.FileNames)
                {
                    //if the file dont exits add


                    //extract the data from the selected file.
                    GH.getFileObject(file, "template");
                }
                //set that file to the combobox
                cBox_template.SelectedIndex = cBox_template.Items.Count - 1;
                C3D_2016_Anno.Global.fileItem FI = (C3D_2016_Anno.Global.fileItem)cBox_template.SelectedItem;
                GH.getTemplateDetails(FI.filePath);
                UIH.toastIT("Note list files read sucessfully!", "File Read", NotificationType.Information);
            }
            catch (System.Exception ee)
            {
                GH.writeLog(ee.ToString());
            }
        }
Example #10
0
        private void btn_CreateKeyNote_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (cBox_objectType.SelectedIndex >= 0)
                {
                    LCH.getCurrentDwgVars();
                    using (GV.Doc.LockDocument())
                    {
                        //get title
                        string objTypeSelected = cBox_objectType.SelectedItem.ToString();
                        GV.textHeight = Convert.ToDouble(tBox_textHeight.Text);
                        //get items
                        mTextLabel = "";

                        //key note heading
                        if (tBox_Heading.Text != "")
                        {
                            LCH.getCurrentFont();
                            if (btn_HeadingBold.IsChecked == true || btn_HeadingUnderline.IsChecked == true)
                            {
                                mTextLabel += "{";
                            }
                            if (btn_HeadingBold.IsChecked == true)
                            {
                                mTextLabel += "\\f" + GV.currentFont + "|b1;";
                            }

                            if (btn_HeadingUnderline.IsChecked == true)
                            {
                                mTextLabel += "\\L";
                            }

                            mTextLabel += tBox_Heading.Text + @"}\P";
                            mTextLabel  = mTextLabel.Replace(@"\\", @"\");
                        }
                        else
                        {
                            mTextLabel += tBox_Heading.Text + @" \P";
                        }

                        foreach (var item in GV.NotesCollection_Anno2[cBox_objectType.SelectedItem.ToString()])
                        {
                            mTextLabel += item.Key + GV.keynoteSeperator + item.Value + @" \P";
                        }

                        #region Create Keynote Text
                        if (!mTextLabel.Equals(string.Empty))
                        {
                            switch (GV.keynotetexttype)
                            {
                            case "mtext":
                            {
                                LCH.createMtextwithJIG(mTextLabel);
                            }
                            break;

                            default:
                            {
                                LCH.createMtextwithJIG(mTextLabel);
                            }
                            break;
                            }
                            #endregion
                        }
                    }
                }
                else
                {
                    UIH.toastIT("Notes not found.", "No Notes Found", NotificationType.Error);
                }
            }
            catch (Autodesk.Civil.CivilException ex)
            {
                GH.errorBox(ex.ToString());
            }
            catch (Autodesk.AutoCAD.Runtime.Exception ex)
            {
                GH.errorBox(ex.ToString());
            }
            catch (System.Exception ee)
            {
                GH.errorBox(ee.ToString());
            }
        }
Example #11
0
 private void notelistColumnHeader_Click(object sender, RoutedEventArgs e)
 {
     UIH.sortColumn(sender, lBox_CurrentNotes);
 }
Example #12
0
        private void btn_selectViewport_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                clearUIValues();
                if (checkifDefnitionsSelected())
                {
                    cBox_objectType.ItemsSource = null;
                    lBox_labels.ItemsSource     = null;
                    GV.clearSelection();
                    GV.all_label_coll.Clear();
                    tBox_Heading.Text = "";

                    //rest progressbar
                    proBar.Value = 0;

                    //MyCommands.vpshp();

                    //GV.Doc.SendStringToExecute("vpshp", true, false, false);

                    LCH.getCurrentDwgVars();
                    #region main
                    using (GV.Doc.LockDocument())
                    {
                        short val = (short)AcAp.GetSystemVariable("CVPORT");
                        if (val != 1)
                        {
                            GV.processStatus = false;
                            UIH.toastIT("This option works only in Paperspace (Layouts), please swtich to paperspace and try again!", "Viewport Not Preset", NotificationType.Error);
                        }
                        else
                        {
                            Helper.ViewportExtensions.getvPortCoordinatesADV();

                            if (GV.processStatus == true && GV.selObjects_forProcessing != null)
                            {
                                bw.WorkerSupportsCancellation = true;
                                bw.WorkerReportsProgress      = true;
                                //bw.ProgressChanged += bw_ProgressChanged;
                                bw.DoWork += new DoWorkEventHandler(bw_UpdateProgressBar);
                                //start work
                                if (bw.IsBusy != true)
                                {
                                    bw.RunWorkerAsync();
                                }
                                int index    = 1;
                                int objCount = GV.selObjects_forProcessing.Count();
                                GV.pBarMaxVal = objCount;

                                foreach (ObjectId objID in GV.selObjects_forProcessing)
                                {
                                    LCH.getlabelvalueSpecific(objID);

                                    #region ProgressBAR

                                    GH.printDebug("", "", false, true);
                                    GV.pBarStatus = "Labels Processed: " + index + @"/" + objCount;
                                    UpdateProgressBar(index, objCount, GV.pBarStatus);
                                    //GV.pmeter.MeterProgress();
                                    Helper.UIHelper.DoEvents();

                                    GV.pBarCurrentVal = index;

                                    //assign it work
                                    index++;
                                    #endregion
                                }
                                updateUIdata();

                                UIH.toastIT("All selected labels processed successfully!", "Status", NotificationType.Success);
                            }
                        }
                    }
                    #endregion
                }
                else
                {
                    UIH.toastIT("Check if defintion and note files are selected!", "Missing defintion/note file", NotificationType.Error);
                }
            }
            catch (Autodesk.Civil.CivilException ex)
            {
                GH.errorBox(ex.ToString());
            }
            catch (Autodesk.AutoCAD.Runtime.Exception ex)
            {
                GH.errorBox(ex.ToString());
            }
            catch (System.Exception ee)
            {
                GH.errorBox(ee.ToString());
            }
        }
Example #13
0
        private void btn_selectLabels_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //check if defnition and  note list are selected
                if (checkifDefnitionsSelected())
                {
                    //rest progressbar
                    proBar.Value = 0;
                    GV.all_label_coll.Clear();
                    clearUIValues();
                    GV.clearSelection();
                    tBox_Heading.Text = "";

                    LCH.getCurrentDwgVars();
                    using (GV.Doc.LockDocument())
                    {
                        GH.writeLog("\n Running command : btn_selectLabels_Click");

                        PromptSelectionResult psRes = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.GetSelection(new SelectionFilter(LCH.selectionFilter(GV.labelFilterType)));

                        if (psRes.Status == PromptStatus.OK)
                        {
                            SelectionSet acSSet = psRes.Value;
                            GV.selObjects_forProcessing = acSSet.GetObjectIds();
                            GH.qprint("Number of objects selected: " + psRes.Value.Count);
                            GH.writeLog("\nNumber of objects selected: " + psRes.Value.Count);

                            //get key notes based on the selection
                            #region process labels Styles
                            bw.WorkerSupportsCancellation = true;
                            bw.WorkerReportsProgress      = true;
                            //bw.ProgressChanged += bw_ProgressChanged;
                            bw.DoWork += new DoWorkEventHandler(bw_UpdateProgressBar);
                            //start work
                            if (bw.IsBusy != true)
                            {
                                bw.RunWorkerAsync();
                            }


                            int index = 1;

                            int objCount = GV.selObjects_forProcessing.Count();
                            GV.pBarMaxVal = objCount;

                            //GV.pmeter.Start("Processing Labels");
                            //GV.pmeter.SetLimit(objCount);


                            foreach (ObjectId objID in GV.selObjects_forProcessing)
                            {
                                LCH.getlabelvalueSpecific(objID);

                                #region ProgressBAR

                                GH.printDebug("", "", false, true);
                                GV.pBarStatus = "Labels Processed: " + index + @"/" + objCount;
                                UpdateProgressBar(index, objCount, GV.pBarStatus);
                                //GV.pmeter.MeterProgress();
                                Helper.UIHelper.DoEvents();

                                GV.pBarCurrentVal = index;

                                //assign it work
                                //bw.ReportProgress(index);
                                index++;
                                #endregion
                            }
                            //GV.pmeter.Stop();
                            //LCH.getlabelvalues();
                            //LCH.getlabelvalues(acSSet.GetObjectIds(), trans);
                            updateUIdata();

                            UIH.toastIT("All selected labels processed successfully!", "Status", NotificationType.Success);
                            #endregion
                        }
                    }
                }
                else
                {
                    UIH.toastIT("Check if defintion and note files are selected!", "Missing defintion/note file", NotificationType.Error);
                }
            }
            catch (Autodesk.Civil.CivilException ex)
            {
                GH.errorBox(ex.ToString());
            }
            catch (Autodesk.AutoCAD.Runtime.Exception ex)
            {
                GH.errorBox(ex.ToString());
            }
            catch (System.Exception ee)
            {
                GH.errorBox(ee.ToString());
            }
        }