c# - Set default value for string prompt -


the editor class has method called getstring prompts user string value via autocad's command prompt. call in wrapper method:

public static string promptuserforstring(string message = "enter string: ", string defaultanswer = "") {     return _editor.getstring("\n" + message).stringresult; } 

the argument message becomes message user sees when prompted string. how set value of default answer automatically set answer if user hits enter right away becomes value in screen shot below

enter image description here

so 1 automatically typed answer meaning user can either hit enter value of 1 or change 1 whatever non-default answer want

i paste code example different prompts :

using system; using system.collections.generic; using autodesk.autocad.editorinput; using autodesk.autocad.geometry; using autodesk.autocad.applicationservices;  namespace editorutilities {     /// <summary>     /// prompts active document ( mdiactivedocument )     /// </summary>     public class editorhelper : ieditorhelper     {         private readonly editor _editor;          public editorhelper(document document)         {             _editor = document.editor;         }          public promptentityresult promptforobject(string promptmessage, type allowedtype, bool exactmatchofallowedtype)         {             var polyoptions = new promptentityoptions(promptmessage);             polyoptions.setrejectmessage("entity not of type " + allowedtype);             polyoptions.addallowedclass(allowedtype, exactmatchofallowedtype);             var polyresult = _editor.getentity(polyoptions);             return polyresult;         }          public promptpointresult promptforpoint(string promptmessage, bool usedashedline = false, bool usebasepoint = false, point3d basepoint = new point3d(),bool allownone = true)         {             var pointoptions = new promptpointoptions(promptmessage);             if (usebasepoint)             {                 pointoptions.usebasepoint = true;                 pointoptions.basepoint = basepoint;                 pointoptions.allownone = allownone;             }              if (usedashedline)             {                 pointoptions.usedashedline = true;             }             var pointresult = _editor.getpoint(pointoptions);             return pointresult;         }          public promptpointresult promptforpoint(promptpointoptions promptpointoptions)         {             return _editor.getpoint(promptpointoptions);         }          public promptdoubleresult promptfordouble(string promptmessage, double defaultvalue = 0.0)         {             var doubleoptions = new promptdoubleoptions(promptmessage);             if (math.abs(defaultvalue - 0.0) > double.epsilon)             {                 doubleoptions.usedefaultvalue = true;                 doubleoptions.defaultvalue = defaultvalue;             }             var promptdoubleresult = _editor.getdouble(doubleoptions);             return promptdoubleresult;         }          public promptintegerresult promptforinteger(string promptmessage)         {             var promptintresult = _editor.getinteger(promptmessage);             return promptintresult;         }          public promptresult promptforkeywordselection(             string promptmessage, ienumerable<string> keywords, bool allownone, string defaultkeyword = "")         {             var promptkeywordoptions = new promptkeywordoptions(promptmessage) { allownone = allownone };             foreach (var keyword in keywords)             {                 promptkeywordoptions.keywords.add(keyword);             }             if (defaultkeyword != "")             {                 promptkeywordoptions.keywords.default = defaultkeyword;             }             var keywordresult = _editor.getkeywords(promptkeywordoptions);             return keywordresult;         }          public point3dcollection promptforrectangle(out promptstatus status, string promptmessage)         {             var resultrectanglepointcollection = new point3dcollection();             var viewcornerpointresult = promptforpoint(promptmessage);             var pointpromptstatus = viewcornerpointresult.status;             if (viewcornerpointresult.status == promptstatus.ok)             {                 var rectanglejig = new rectanglejig(viewcornerpointresult.value);                 var jigresult = _editor.drag(rectanglejig);                 if (jigresult.status == promptstatus.ok)                 {                     // remove duplicate point @ end of rectangle                     var polyline = rectanglejig.polyline;                     var viewpolylinepoints = geometryutility.getpointsfrompolyline(polyline);                     if (viewpolylinepoints.count == 5)                     {                         viewpolylinepoints.removeat(4); // dont know why true, mirror point last point                     }                 }                 pointpromptstatus = jigresult.status;             }             status = pointpromptstatus;             return resultrectanglepointcollection;         }          public promptselectionresult promptforselection(string promptmessage = null, selectionfilter filter = null)         {             var selectionoptions = new promptselectionoptions { messageforadding = promptmessage };             var selectionresult = string.isnullorempty(promptmessage) ? _editor.selectall(filter) : _editor.getselection(selectionoptions, filter);             return selectionresult;         }          public promptselectionresult promptforselection(promptselectionoptions promptselectionoptions,selectionfilter filter = null)         {             return _editor.getselection(promptselectionoptions, filter);         }          public void writemessage(string message)         {             _editor.writemessage(message);         }          public void drawvector(point3d from, point3d to, int color, bool drawhighlighted)         {             _editor.drawvector(from, to, color, drawhighlighted);         }     } } 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -