private void loadStyleItem(int moverVal) { try { collIndex = collIndex + moverVal; if (collIndex <= selObjs.Count) { Global.labelComponentItem item = (Global.labelComponentItem)selObjs[collIndex - 1]; tBox_styleName.Text = item.styleName; Blink(false, ""); } else { loadStyleItem(-2); } } 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()); //close the grid grid_addStyle.Visibility = System.Windows.Visibility.Hidden; } }
private void Btn_addStyle_Click(object sender, RoutedEventArgs e) { try { //load the current item if (selObjs.Where(item => item.styleName == tBox_styleName.Text).Any() == true) { LI = selObjs.Where(item => item.styleName == tBox_styleName.Text).Single(); } //check if that object already exists if (GV.labelComponentItem_coll.Where(LabelItem => LabelItem.styleName == LI.styleName).Any() == false) { //check if all the values are filled in if (tBox_styleName.Text == string.Empty) { Blink(true, "Style name missing, please enter"); } //else if (tBox_styleKNloc.Text == string.Empty) //{ // Blink(true, "Style KN location missing, please enter"); //} else if (cBox_styleType.Text == string.Empty) { Blink(true, "Style type missing, please enter"); } else { //user approval LI.labelType = cBox_styleType.Text; LI.learnStatus = true; GV.labelComponentItem_coll.Add(LI); //if note type note in the list then add to the list and the file addNoteType(); if (selObjs.Where(item => item.styleName == LI.styleName).Any() == true) { selObjs.Remove(selObjs.Where(item => item.styleName == LI.styleName).Single()); } //check if next item exsits if so move or else close moveOrClose(); Blink(false, ""); } } else // item already exists { Blink(true, "Style already exists!"); moveOrClose(); } } catch (System.Exception ex) { GH.writeLog(ex.ToString()); } }
public static void getStyleStructureFileDetails(string filePath) { try { //clear collection GV.labelComponentItem_coll.Clear(); Dictionary <string, string> result = new Dictionary <string, string>(); result = xmlParser.getXMLVaulesStrings(filePath, "STYLE", "name"); foreach (var item in result) { Global.labelComponentItem LI = new Global.labelComponentItem(); LI.styleName = item.Key; LI.KNComponentID = new List <int>(Array.ConvertAll(item.Value.Split(','), int.Parse)); GV.labelComponentItem_coll.Add(LI); } } catch (System.Exception ex) { } }
private void btn_learn_Click(object sender, RoutedEventArgs e) { try { collIndex = 0; selObjs.Clear(); LCH.getCurrentDwgVars(); using (GV.Doc.LockDocument()) { //ask the user to pick a style to read about the style //Seleciton options, with single selection PromptSelectionOptions Options = new PromptSelectionOptions(); Options.SingleOnly = true; //Options.SinglePickInSpace = true; Autodesk.AutoCAD.Internal.Utils.SetFocusToDwgView(); PromptSelectionResult psRes = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.GetSelection(Options, new SelectionFilter(LCH.selectionFilter(GV.labelFilterType))); if (psRes.Status == PromptStatus.OK) { SelectionSet acSSet = psRes.Value; GV.selObjects_forProcessing = acSSet.GetObjectIds(); foreach (ObjectId objID in GV.selObjects_forProcessing) { //get the name of the label LI = new Global.labelComponentItem(); LI.styleName = LCH.getLabelName(objID); LI.objType = LCH.getObjType(objID); LI.objID = objID; GV.ed.WriteMessage("LI.name: " + LI.styleName); GV.ed.WriteMessage("LI.objType: " + LI.objType); //get the component id which has the value 99 Dictionary<string, string> CompNameVals = new Dictionary<string, string>(); CompNameVals = Helper.LabelTextExtractor.getLabelValsAll(objID); //get the location of the value and store it against the style name and id. int i = 0; LI.KNComponentID = new List<int>(); string KNLoc = ""; foreach (var item in CompNameVals) { if (item.Value == "99") { LI.KNComponentID.Add(Convert.ToInt32(item.Key)); KNLoc = item.Key + ","; i++; } } //check if there is a comman at the end of the KN and remove that KNLoc = KNLoc.Remove(KNLoc.Length - 1); if (selObjs.Where(item => item.styleName == LI.styleName).Any() == false) { selObjs.Add(LI); } //show this on the confirmation box - once the user confirms its then add to the list. or discard that item tBox_styleName.Text = LI.styleName; //tBox_styleKNloc.Text = KNLoc; // ask the user to pick the mapper configuration //store the configuration to settings file } grid_addStyle.Visibility = System.Windows.Visibility.Visible; } } } catch (System.Exception ex) { GH.writeLog(ex.ToString()); } }