void IActiveElement.Deactivate(SnippetEventArgs e) { if (e.Reason == DeactivateReason.Deleted) { Deactivate(); return; } if (e.Reason == DeactivateReason.ReturnPressed) { OKButtonClick(null, null); } if (e.Reason == DeactivateReason.EscapePressed) { CancelButtonClick(null, null); } Deactivate(); }
/// <summary> /// Main logic of switch snippet. Called when user ends the snippet interactive mode. /// Inserts switch body depending on the type of switch condition: /// Inserts all cases if condition is enum, generic switch body with one case otherwise. /// </summary> void InteractiveModeCompleted(object sender, SnippetEventArgs e) { if (e.Reason != DeactivateReason.ReturnPressed) { return; } int offset; string conditionText = GetSwitchConditionText(this.context, out offset); IReturnType conditionType = ResolveConditionType(conditionText, offset); string switchBodyIndent = GetBodyIndent(this.Editor.Document, this.InsertionPosition); if (conditionType != null && IsEnum(conditionType)) { GenerateEnumSwitchBodyCode(this.InsertionPosition, conditionType, switchBodyIndent); } else { GenerateGenericSwitchBodyCode(this.InsertionPosition, switchBodyIndent); } }