/// <summary> /// OnCloseDocument event handler. /// </summary> private void OnCloseDocument(object sender, DocumentEventArgs e) { // By the time we get here, our user data has been written to the document // (if there was any). So, call Clear() to notify anyone watching for // this event. SampleCsStringTableHelpers.Clear(); }
/// <summary> /// Called by Rhino when the user wants to run the command. /// </summary> protected override Result RunCommand(RhinoDoc doc, RunMode mode) { GetOption go = new GetOption(); go.SetCommandPrompt("Select command option"); int add_index = go.AddOption("Add"); int delete_index = go.AddOption("Delete"); int list_index = go.AddOption("List"); go.Get(); if (go.CommandResult() != Result.Success) { return(go.CommandResult()); } CommandLineOption option = go.Option(); if (null == option) { return(Result.Failure); } int index = option.Index; if (index == add_index) { string str = string.Empty; Result rc = RhinoGet.GetString("String to add", false, ref str); if (rc == Result.Success) { SampleCsStringTableHelpers.Add(str); } } else if (index == delete_index) { string str = string.Empty; Result rc = RhinoGet.GetString("String to delete", false, ref str); if (rc == Result.Success) { SampleCsStringTableHelpers.Remove(str); } } else if (index == list_index) { int count = SampleCsStringTableHelpers.Count(); if (0 == count) { RhinoApp.WriteLine("0 string items to list."); } else { for (int i = 0; i < count; i++) { RhinoApp.WriteLine(SampleCsStringTableHelpers.GetAt(i)); } } } return(Result.Success); }
/// <summary> /// OnEndOpenDocument event handler. /// </summary> void OnEndOpenDocument(object sender, DocumentOpenEventArgs e) { // By the time we get here, our user data has been read from the document // (if there was any). So, call Refresh() to notify anyone watching for // this event. SampleCsStringTableHelpers.Refresh(); }
/// <summary> /// Clears or fills the list box. /// </summary> void RefreshListBox(bool bFill) { if (this.Visible) { this.listBox.Items.Clear(); if (bFill) { for (int i = 0; i < SampleCsStringTableHelpers.Count(); i++) { this.listBox.Items.Add(SampleCsStringTableHelpers.GetAt(i)); } } } }