Class1.cs
上传用户:hbhltzc
上传日期:2022-06-04
资源大小:1925k
文件大小:2k
源码类别:

xml/soap/webservice

开发平台:

Visual C++

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Windows.Forms;
  5. using System.ComponentModel;
  6. using System.Drawing;
  7. using System.Xml.Schema;
  8. using XmlNotepad;
  9. namespace Microsoft {    
  10.     /// <summary>
  11.     /// This is a custom builder for editing font values using the FontDialog.
  12.     /// You can specify this builder using the following annotation in your schema:
  13.     ///     vs:builder="Microsoft.FontBuilder"
  14.     ///     vs:assembly="FontBuilder"
  15.     /// where xmlns:vs="http://schemas.microsoft.com/Visual-Studio-Intellisense"
  16.     /// </summary>
  17.     class FontBuilder : IXmlBuilder {
  18.         FontDialog fd = new FontDialog();
  19.         ISite site;
  20.         IIntellisenseProvider owner;
  21.         public IIntellisenseProvider Owner {
  22.             get { return this.owner; }
  23.             set { this.owner = value; }
  24.         }
  25.         public ISite Site {
  26.             get { return this.site; }
  27.             set { this.site = value; }
  28.         }
  29.         public string Caption { get { return "&Font picker..."; } }
  30.         public bool EditValue(IWin32Window owner, XmlSchemaType type, string input, out string output) {
  31.             output = input;
  32.             FontConverter fc = new FontConverter();
  33.             Font f = null;
  34.             try {
  35.                 f = (Font)fc.ConvertFromString(input);
  36.                 fd.Font = f;
  37.             } catch {
  38.             }
  39.             
  40.             if (fd.ShowDialog(owner) == DialogResult.OK) {
  41.                 output = fc.ConvertToString(fd.Font);
  42.                 return true;
  43.             } else {
  44.                 return false;
  45.             }
  46.         }
  47.     }
  48. }