/// <summary>
 /// Constructor
 /// </summary>
 /// <param name="doc">Document used to create the new point</param>
 public TextViewModel(RhinoDoc doc, Rhino.Geometry.TextEntity textEntity)
 {
     _doc = doc;
       _textEntity = textEntity;
       _text = textEntity.TextFormula;
       if (string.IsNullOrWhiteSpace(_text))
     _text = textEntity.Text;
       // Mask type combo box list
       _maskTypeList.Add(Rhino.UI.LOC.STR("None"));
       _maskTypeList.Add(Rhino.UI.LOC.STR("Background"));
       _maskTypeList.Add(Rhino.UI.LOC.STR("Solid Color"));
     #if ON_OS_WINDOWS
       ShowMaskColorDialogCommand = new RhinoWindows.Input.DelegateCommand(ShowMaskColorDialog, null);
       ShowSelectTextFontCommand = new RhinoWindows.Input.DelegateCommand(ShowSelectTextFont, null);
       ShowTextFieldsFormCommand = new RhinoWindows.Input.DelegateCommand(ShowTextFieldsForm, null);
       ImportTextFileCommand = new RhinoWindows.Input.DelegateCommand(ImportTextFile, null);
     #endif
 }
    /// <summary>
    /// Constructor
    /// </summary>
    /// <param name="doc"></param>
    public TextFieldViewModel(RhinoDoc doc)
    {
      _doc = doc;

      #region Define all of the fields
      // area
      string name = Rhino.UI.LOC.STR("Area");
      string description = Rhino.UI.LOC.STR("Calculate the area of a closed curve, hatch, surface, or mesh");
      _fields.Add("Area", new TextFieldData(TextFieldType.area, name, description));
      // block instance count
      name = Rhino.UI.LOC.STR("BlockInstanceCount");
      description = Rhino.UI.LOC.STR("Number of instances of a given block");
      _fields.Add("BlockInstanceCount", new TextFieldData(TextFieldType.blockinstancecount, name, description));
      //curvelength
      name = Rhino.UI.LOC.STR("CurveLength");
      description = Rhino.UI.LOC.STR("Calculate the length of a curve");
      _fields.Add("CurveLength", new TextFieldData(TextFieldType.curvelength, name, description));
      //date
      name = Rhino.UI.LOC.STR("Date");
      description = Rhino.UI.LOC.STR("The current date");
      _fields.Add("Date", new TextFieldData(TextFieldType.date, name, description));
      //datemodified
      name = Rhino.UI.LOC.STR("DateModified");
      description = Rhino.UI.LOC.STR("Date this document was last saved");
      _fields.Add("DateModified", new TextFieldData(TextFieldType.datemodified, name, description));
      //documenttext
      name = Rhino.UI.LOC.STR("DocumentText");
      description = Rhino.UI.LOC.STR("DocumentText value for a defined key");
      _fields.Add("DocumentText", new TextFieldData(TextFieldType.documenttext, name, description));
      //filename
      name = Rhino.UI.LOC.STR("FileName");
      description = Rhino.UI.LOC.STR("The document's name and location");
      _fields.Add("FileName", new TextFieldData(TextFieldType.filename, name, description));
      //modelunits
      name = Rhino.UI.LOC.STR("ModelUnits");
      description = Rhino.UI.LOC.STR("Current working units for the document");
      _fields.Add("ModelUnits", new TextFieldData(TextFieldType.modelunits, name, description));
      //notes
      name = Rhino.UI.LOC.STR("Notes");
      description = Rhino.UI.LOC.STR("The notes for the document");
      _fields.Add("Notes", new TextFieldData(TextFieldType.notes, name, description));
      //numpages
      name = Rhino.UI.LOC.STR("NumPages");
      description = Rhino.UI.LOC.STR("Total number of layout pages in the document");
      _fields.Add("NumPages", new TextFieldData(TextFieldType.numpages, name, description));
      //objectname
      name = Rhino.UI.LOC.STR("ObjectName");
      description = Rhino.UI.LOC.STR("Name for a given object", 383);
      _fields.Add("ObjectName", new TextFieldData(TextFieldType.objectname, name, description));
      //pagename
      name = Rhino.UI.LOC.STR("PageName");
      description = Rhino.UI.LOC.STR("Name of the layout page that this text field exists on");
      _fields.Add(name, new TextFieldData(TextFieldType.pagename, name, description));
      //pagenumber
      name = Rhino.UI.LOC.STR("PageNumber");
      description = Rhino.UI.LOC.STR("Number of the layout page that this text field exists on");
      _fields.Add("PageNumber", new TextFieldData(TextFieldType.pagenumber, name, description));
      //usertext
      name = Rhino.UI.LOC.STR("UserText");
      description = Rhino.UI.LOC.STR("UserText value for a given object/key combination");
      _fields.Add("UserText", new TextFieldData(TextFieldType.usertext, name, description));
      #endregion

      // Map localized field name to English field name
      foreach (var item in _fields)
        _localizdeFieldNameDictionary.Add(item.Value.LocalName, item.Key);

      // Sort the localized field name list
      string[] keys = new string[_localizdeFieldNameDictionary.Count];
      _localizdeFieldNameDictionary.Keys.CopyTo(keys, 0);
      List<string> sortedList = new List<string>(keys);
      sortedList.Sort((string0, string1) => { return string0.CompareTo(string1); });
      _sortedLocalizedFieldNameList = sortedList.ToArray();

      // Select the first key in the sorted list
      var key = KeyFromLocalizedKey(_sortedLocalizedFieldNameList[0]);
      selectedFieldKey = key;

    #if ON_OS_WINDOWS
      // Command delegates for WPF
      SelectObjectButtonClickedCommand = new RhinoWindows.Input.DelegateCommand(SelectObjectButtonClicked, null);
      AddNameValuePairButtonClickedCommand = new RhinoWindows.Input.DelegateCommand(AddNameValuePairButtonClicked, null);
    #endif
    }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="doc">Document used to create the new point</param>
 public InsertCommandViewModel(RhinoDoc doc, InsertInstanceCommandOptions initialCommandOptions, bool droppingFileOnRhino)
     : base(doc)
 {
     _doc = doc;
       _droppingFileOnRhino = droppingFileOnRhino;
       CommandOptions = initialCommandOptions;
       CommandOptions.DocumentId = doc.DocumentId;
       promptInsertionPoint = CommandOptions.PromptForInsertionPoint;
       InsertionPoint = CommandOptions.InsertionPoint;
       promptScale = CommandOptions.PromptForScale;
       uniformlyScale = CommandOptions.UniformlyScale;
       Scale = CommandOptions.Scale;
       promptRotation = CommandOptions.PromptForRotationAngle;
       rotation = RhinoMath.ToDegrees(CommandOptions.RotationAngle);
       //
       // Initialize list of hidden instance definitions
       //
       // The combo box is disabled when DroppingFileOnRhino is true so hidden InstanceDefinition objects will
       // never get added so don't bother building the list
       if (!DroppingFileOnRhino)
     foreach (var idef in Document.InstanceDefinitions)
       if (IsHiddenIDef(idef))
     HiddenIDefs.Add(new InsertInstanceOptions(idef, doc.DocumentId));
       //
       // Initialize bock name combo box
       //
       // IncludeIDefInList checks this flag so set it before initializing the combo box
       if (DroppingFileOnRhino)
       {
     // TODO:
     //InsertCommandArgs item = new InsertCommandArgs(InsertCommandArgs);
     //item.DroppingFileOnRhino = true;
     //comboBoxName.Items.Add(item);
     //comboBoxName.SelectedIndex = 0;
     //buttonFile.Enabled = false;
       }
       else if (null != Document)
       {
     // Process the active documents InstanceDefinitions table and create a list of items to add
     var blocks = new List<InsertInstanceOptions>();
     foreach (var idef in Document.InstanceDefinitions)
       if (IncludeIDefInList(idef))
     blocks.Add(new InsertInstanceOptions(idef, Document.DocumentId));
     // Sort the list
     blocks.Sort(InsertInstanceOptions.Compare);
     int foundBlockName = -1;
     // Copy the list to the view model observable collection for binding by WPF or XCode
     foreach (var block in blocks)
     {
       blockList.Add(block);
       if (block.BlockId == BlockId)
     blockListSelectedIndex = blockList.Count - 1;
       if (foundBlockName < 0 && string.IsNullOrWhiteSpace(BlockName) && null != Document)
       {
     if (block.BlockName.Equals(BlockName, StringComparison.OrdinalIgnoreCase))
       foundBlockName = blockList.Count - 1;
       }
     }
     // TRR 21538: If no previous name exists, use the first active one on the list.
     if (blockListSelectedIndex < 0 && blockList.Count > 0)
       blockListSelectedIndex = Math.Max(0, foundBlockName);
       }
     #if ON_OS_WINDOWS
       // Register command callbacks for button click (command) events
       BrowseForFileButtonClickDelegate = new RhinoWindows.Input.DelegateCommand(WinBrowseForFileButtonClick, null);
     #endif
 }