digitaltimeformateditor.cs

来自「中文名:Windows Forms 程序设计 英文名:Windows Form」· CS 代码 · 共 45 行

CS
45
字号
#region Using directives

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing.Design;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.Design;

#endregion

namespace AlarmClockControlLibrary {

  public class DigitalTimeFormatEditor : System.Drawing.Design.UITypeEditor {

    public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) {
        return UITypeEditorEditStyle.Modal;
    }

    public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) {

      if( (context != null) && (provider != null) ) {
        // Access the property browser’s UI display service, IWindowsFormsEditorService
        IWindowsFormsEditorService editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

        if( editorService != null ) {
          // Create an instance of the UI editor dialog
          DigitalTimeFormatEditorForm modalEditor = new DigitalTimeFormatEditorForm();

          // Pass the UI editor dialog the current property value
          modalEditor.DigitalTimeFormat = (string)value;

          // Display the UI editor dialog
          if( editorService.ShowDialog(modalEditor) == DialogResult.OK ) {
            // Return the new property value from the UI editor dialog
            return modalEditor.DigitalTimeFormat;
          }
        }
      }
      return base.EditValue(context, provider, value);
    }
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?