static SamplerStatus GetString(JigPrompts prompts) { var rst = prompts.AcquireString(_StringOptions); _rst = rst; var cur = Form.MousePosition; if (Form.MousePosition != _cur) { _cur = cur; return(SamplerStatus.OK); } else { return(SamplerStatus.NoChange); } }
protected override SamplerStatus Sampler(JigPrompts prompts) { string jigResultValue = null; if (this.Options is JigPromptPointOptions pointOptions) { var result = prompts.AcquirePoint(pointOptions); this.JigResult = result; jigResultValue = result.Value.ToString(); } else if (this.Options is JigPromptDistanceOptions distanceOptions) { var result = prompts.AcquireDistance(distanceOptions); this.JigResult = result; jigResultValue = result.Value.ToString(); } else if (this.Options is JigPromptAngleOptions angleOptions) { var result = prompts.AcquireAngle(angleOptions); this.JigResult = result; jigResultValue = result.Value.ToString(); } else if (this.Options is JigPromptStringOptions stringOptions) { var result = prompts.AcquireString(stringOptions); this.JigResult = result; jigResultValue = result.StringResult; } if (jigResultValue == null) { return(SamplerStatus.Cancel); } else if (jigResultValue != this.JigResultValue) { this.JigResultValue = jigResultValue; return(SamplerStatus.OK); } return(SamplerStatus.NoChange); }
// EntityJig protocol protected override SamplerStatus Sampler(JigPrompts prompts) { // Get the current phase var p = _phases[_phase]; // If we're dealing with a geometry-typed phase (distance, // point or angle input) we can use some common code var gp = p as GeometryPhase; if (gp != null) { JigPromptGeometryOptions opts; if (gp is DistancePhase) { opts = new JigPromptDistanceOptions(); } else if (gp is AnglePhase) { opts = new JigPromptAngleOptions(); } else if (gp is PointPhase) { opts = new JigPromptPointOptions(); } else // Should never happen { opts = null; } // Set up the user controls opts.UserInputControls = (UserInputControls.Accept3dCoordinates | UserInputControls.NoZeroResponseAccepted | UserInputControls.NoNegativeResponseAccepted); // All our distance inputs will be with a base point // (which means the initial base point or an offset from // that) opts.UseBasePoint = true; opts.Cursor = CursorType.RubberBand; opts.Message = p.Message; opts.BasePoint = (gp.Offset == null ? _pt.TransformBy(_ucs) : (_pt + gp.Offset.Invoke(_phases, _pt)).TransformBy(_ucs)); // The acquisition method varies on the phase type if (gp is DistancePhase) { var phase = (DistancePhase)gp; var pdr = prompts.AcquireDistance((JigPromptDistanceOptions)opts); if (pdr.Status == PromptStatus.OK) { // If the difference between the new value and its // previous value is negligible, return "no change" if (System.Math.Abs((double)phase.Value - pdr.Value) < Tolerance.Global.EqualPoint) { return(SamplerStatus.NoChange); } // Otherwise we update the appropriate variable // based on the phase phase.Value = pdr.Value; _phases[_phase] = phase; return(SamplerStatus.OK); } } else if (gp is PointPhase) { var phase = (PointPhase)gp; var ppr = prompts.AcquirePoint((JigPromptPointOptions)opts); if (ppr.Status == PromptStatus.OK) { // If the difference between the new value and its // previous value is negligible, return "no change" var tmp = ppr.Value.TransformBy(_ucs.Inverse()); if (tmp.DistanceTo((Point3d)phase.Value) < Tolerance.Global.EqualPoint) { return(SamplerStatus.NoChange); } // Otherwise we update the appropriate variable // based on the phase phase.Value = tmp; _phases[_phase] = phase; return(SamplerStatus.OK); } } else if (gp is AnglePhase) { var phase = (AnglePhase)gp; var par = prompts.AcquireAngle((JigPromptAngleOptions)opts); if (par.Status == PromptStatus.OK) { // If the difference between the new value and its // previous value is negligible, return "no change" if ((double)phase.Value - par.Value < Tolerance.Global.EqualPoint) { return(SamplerStatus.NoChange); } // Otherwise we update the appropriate variable // based on the phase phase.Value = par.Value; _phases[_phase] = phase; return(SamplerStatus.OK); } } } else { // p is StringPhase var phase = (StringPhase)p; var psr = prompts.AcquireString(p.Message); if (psr.Status == PromptStatus.OK) { phase.Value = psr.StringResult; _phases[_phase] = phase; return(SamplerStatus.OK); } } return(SamplerStatus.Cancel); }
protected override SamplerStatus Sampler(JigPrompts prompts) { switch (mCurJigFactorIndex) { case 1: var prOptions1 = new JigPromptPointOptions("\nArrow Location:"); // Set properties such as UseBasePoint and BasePoint of the prompt options object if necessary here. prOptions1.UserInputControls = UserInputControls.Accept3dCoordinates | UserInputControls.GovernedByOrthoMode | UserInputControls.GovernedByUCSDetect | UserInputControls.UseBasePointElevation; var prResult1 = prompts.AcquirePoint(prOptions1); if (prResult1.Status == PromptStatus.Cancel && prResult1.Status == PromptStatus.Error) { return(SamplerStatus.Cancel); } if (prResult1.Value.Equals(mArrowLocation)) //Use better comparison method if necessary. { return(SamplerStatus.NoChange); } else { mArrowLocation = prResult1.Value; return(SamplerStatus.OK); } case 2: var xDiff = mTextLocation.X - mArrowLocation.X; var yDiff = mTextLocation.Y - mArrowLocation.Y; var angle = Math.Atan2(yDiff, xDiff) * 180.0 / Math.PI; if (angle > 45 && angle < 135 || angle < -45 && angle > -135) { Entity.TextAttachmentDirection = TextAttachmentDirection.AttachmentVertical; } else { Entity.TextAttachmentDirection = TextAttachmentDirection.AttachmentHorizontal; } Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("\n" + angle); var prOptions2 = new JigPromptPointOptions("\nLanding Location:"); // Set properties such as UseBasePoint and BasePoint of the prompt options object if necessary here. prOptions2.UseBasePoint = true; prOptions2.BasePoint = mArrowLocation; prOptions2.UserInputControls = UserInputControls.Accept3dCoordinates | UserInputControls.GovernedByOrthoMode | UserInputControls.GovernedByUCSDetect | UserInputControls.UseBasePointElevation; var prResult2 = prompts.AcquirePoint(prOptions2); if (prResult2.Status == PromptStatus.Cancel && prResult2.Status == PromptStatus.Error) { return(SamplerStatus.Cancel); } if (prResult2.Value.Equals(mTextLocation)) //Use better comparison method if necessary. { return(SamplerStatus.NoChange); } else { mTextLocation = prResult2.Value; return(SamplerStatus.OK); } case 3: var prOptions3 = new JigPromptStringOptions("\nText Content:"); // Set properties such as UseBasePoint and BasePoint of the prompt options object if necessary here. prOptions3.UserInputControls = UserInputControls.AcceptOtherInputString; var prResult3 = prompts.AcquireString(prOptions3); if (prResult3.Status == PromptStatus.Cancel && prResult3.Status == PromptStatus.Error) { return(SamplerStatus.Cancel); } if (prResult3.StringResult.Equals(mMText)) //Use better comparison method if necessary. { return(SamplerStatus.NoChange); } else { mMText = prResult3.StringResult; return(SamplerStatus.OK); } } return(SamplerStatus.OK); }