사용자 지정 편집기의 코드는 암호를 입력하기 위한 드롭다운 텍스트 상자를 표시하는 System.Drawing.Design.UITypeEditor 클래스에서 파생된 편집기를 보여 줍니다. GetEditStyle 재정의는 UIEditorEditStyle.DropDown을 반환하여 드롭다운 하위 컨트롤을 나타냅니다. 서비스 메서드 DropDownControl 및 CloseDropDown 은 CreatePassword를 사용하여 만든 컨트롤을 관리합니다.
다음 코드는 사용자 지정 드롭다운 편집기에 대한 클래스 정의입니다.
/*************************************************************************
* Copyright (c) 1999-2004 Microsoft Corporation. All rights reserved. *
* *
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY *
* KIND, WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE *
* IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR *
* PURPOSE. THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE *
* OF THIS CODE AND INFORMATION REMAINS WITH THE USER. *
*************************************************************************/
using System;
using System.ComponentModel;
using System.Drawing.Design;
using System.Windows.Forms;
using System.Windows.Forms.Design;
using System.Security;
using System.Security.Permissions;
using Microsoft.BizTalk.Adapter.Framework;
using Microsoft.BizTalk.Adapter.Framework.Forms;
namespace AdapterManagement.ComponentModel {
/// <summary>
/// PasswordUITypeEditor implements a user interface for acquiring passwords
/// within a visual designer.
/// </summary>
public class PasswordUITypeEditor : UITypeEditor {
public const char PasswordChar = '\u25cf';
private IWindowsFormsEditorService _service = null;
private TextBox _password = null;
[SecurityPermissionAttribute(SecurityAction.LinkDemand)]
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) {
if (null != context && null != context.Instance) {
return UITypeEditorEditStyle.DropDown;
}
return base.GetEditStyle(context);
}
[SecurityPermissionAttribute(SecurityAction.LinkDemand)]
public override object EditValue(ITypeDescriptorContext context,
IServiceProvider provider,
object value) {
if (null != context && null != context.Instance && null != provider) {
this._service = (IWindowsFormsEditorService) provider.GetService
(typeof(IWindowsFormsEditorService));
if (null != this._service) {
this._password = CreatePassword();
this._service.DropDownControl(this._password);
value = this._password.Text;
}
}
return value;
}
private TextBox CreatePassword () {
TextBox password = new TextBox();
password.PasswordChar = PasswordUITypeEditor.PasswordChar;
password.Leave += new EventHandler(password_Leave);
}
private void password_Leave(object sender, EventArgs e) {
if (null != this._service) {
this._service.CloseDropDown();
}
}
} // PasswordUITypeEditor
} // Microsoft.BizTalk.Adapter.Framework.ComponentModel
참고 항목
사용자 지정 어댑터 구성 디자이너
어댑터 구성을 위한 사용자 지정 모달 대화 상자 편집기
어댑터 구성을 위한 사용자 지정 형식 변환기
어댑터에 대한 고급 구성 요소