Common_SimpleServerTask_VBNet\ButtonTextEditor.vb
' Copyright 2011 ESRI ' ' All rights reserved under the copyright laws of the United States ' and applicable international laws, treaties, and conventions. ' ' You may freely redistribute and use this sample code, with or ' without modification, provided you include the original copyright ' notice and use restrictions. ' ' See the use restrictions. ' Imports Microsoft.VisualBasic Imports System Namespace Commom_SimpleServerTask_VBNet ''' <summary> ''' Edits ButtonText property on a SimpleTask. ''' </summary> Public Class ButtonTextEditor Inherits System.Drawing.Design.UITypeEditor ''' <summary> ''' Edits the value of the specified object using the editor style indicated by GetEditStyle. ''' </summary> ''' <param name="context">An ITypeDescriptorContext that can be used to gain additional context information<see cref="System.ComponentModel.ITypeDescriptorContext"/></param> ''' <param name="provider">An IServiceProvider that this editor can use to obtain services</param> ''' <param name="value">The object to edit</param> ''' <returns>The edited value.</returns> Public Overloads Overrides Function EditValue(ByVal typeDescriptorContext As System.ComponentModel.ITypeDescriptorContext, ByVal serviceProvider As System.IServiceProvider, ByVal value As Object) As Object ' Make sure a valid type descriptor context and service provider were passed in If (typeDescriptorContext IsNot Nothing) AndAlso (serviceProvider IsNot Nothing) Then ' If the type descriptor context's instance (the control - in this case a simple task - ' being configured) is null, exit the method without updating any properties If typeDescriptorContext.Instance Is Nothing Then Return value End If ' Instantiate the form to edit the simple task's button text Dim buttonTextEditorForm As New ButtonTextEditorForm(TryCast(value, String)) ' Show the form. If the form closes by the user clicking OK, then update the button ' text with that specified on the form. If buttonTextEditorForm.ShowDialog() = System.Windows.Forms.DialogResult.OK Then value = buttonTextEditorForm.Value End If End If Return value End Function ''' <summary> ''' Gets the editor style used by the EditValue method ''' </summary> ''' <param name="context">An ITypeDescriptorContext that can be used to gain additional context information<see cref="System.ComponentModel.ITypeDescriptorContext"/></param> ''' <returns>If the context is not null, the Style will always be returned as Modal, otherwise will return a default edit style</returns> Public Overloads Overrides Function GetEditStyle(ByVal typeDescriptorContext As System.ComponentModel.ITypeDescriptorContext) As System.Drawing.Design.UITypeEditorEditStyle If typeDescriptorContext IsNot Nothing Then Return System.Drawing.Design.UITypeEditorEditStyle.Modal End If Return MyBase.GetEditStyle(typeDescriptorContext) End Function End Class End Namespace