IDictionaryServiceとは? わかりやすく解説

IDictionaryService インターフェイス

サービス通じてデザイナユーザー定義データ格納するために使用できる基本的なコンポーネント サイト固有のキーと値のペアのディクショナリを提供します

名前空間: System.ComponentModel.Design
アセンブリ: System (system.dll 内)
構文構文

Public Interface IDictionaryService
Dim instance As IDictionaryService
public interface IDictionaryService
public interface class IDictionaryService
public interface IDictionaryService
public interface IDictionaryService
解説解説
使用例使用例

サイト固有のキーと値のペアのディクショナリを通じてデータ共有するために、IDictionaryService使用したコントロールデザイナの例を次に示します

Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Drawing
Imports System.Data
Imports System.Windows.Forms

Namespace IDictionaryServiceControl

    ' This example control works with the IDictionaryServiceDesigner
 to demonstrate
    ' using the IDictionaryService for storing data provided by a designer,
 and
    ' accessing it from a control. The IDictionaryService provides a
 Site-specific 
    ' key-based dictionary. An IDictionaryServiceDesigner sets an ArrayList
 of strings 
    ' to the dictionary with a "DesignerData" key, and its
 contents are accessed and
    ' displayed once the Update box is clicked at design time.
    <DesignerAttribute(GetType(IDictionaryServiceDesigner),
 GetType(IDesigner))> _
     Public Class IDictionaryServiceControl
        Inherits System.Windows.Forms.UserControl
        Public al As ArrayList

        Public Sub New()
            ' Initializes the example control.
            al = New ArrayList()
            Me.Size = New Size(344, 88)
            Me.BackColor = Color.White
        End Sub 

        ' Draws the instructions and user interface, and any strings
 contained
        ' in a local ArrayList.
        Protected Overrides Sub
 OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
            If Me.DesignMode Then
                e.Graphics.DrawString("IDictionaryServiceDesigner
 Control", New Font(FontFamily.GenericMonospace,
 9), New SolidBrush(Color.Blue), 5, 4)
                e.Graphics.DrawString("Click the Update box to
 update display strings", New Font(FontFamily.GenericMonospace,
 8), New SolidBrush(Color.DarkGreen), 5, 17)
                e.Graphics.DrawString("from the IDictionaryService.",
 New Font(FontFamily.GenericMonospace, 8), New
 SolidBrush(Color.DarkGreen), 5, 29)

                e.Graphics.FillRectangle(New SolidBrush(Color.Beige),
 270, 7, 60, 10)
                e.Graphics.DrawRectangle(New Pen(New
 SolidBrush(Color.Black), 1), 270, 7, 60, 10)
                e.Graphics.DrawString("Update", New
 Font(FontFamily.GenericMonospace, 7), New SolidBrush(Color.Black),
 282, 7)

                Dim i As Integer
                For i = 0 To al.Count - 1
                    e.Graphics.DrawString(CStr(al(i)), New Font(FontFamily.GenericMonospace,
 8), New SolidBrush(Color.Black), 5, 44 + i * 12)
                Next i
            End If
        End Sub

        ' On mouse down, this method attempts to access the IDictionaryService
 and 
        ' obtain an ArrayList with a key of "DesignerData"
 in the dictionary.
        ' If successful, this ArrayList is set to the local ArrayList.
        Protected Overrides Sub
 OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
            ' Attempts to obtain the IDictionaryService using the Control.GetService
 method.
            Dim ds As IDictionaryService =
 CType(GetService(GetType(IDictionaryService)), IDictionaryService)
            ' If the service was obtained...
            If Not (ds Is
 Nothing) Then
                ' Attempts to retrieve a list with a key of "DesignerData".
                Dim list As ArrayList = CType(ds.GetValue("DesignerData"),
 ArrayList)
                ' If the list exists, sets the list obtained by the
 
                ' IDictionaryService to the local list.
                If Not (list Is
 Nothing) Then
                    Me.al = list
                End If
                Me.Refresh()
            End If
        End Sub 
    End Class 

    ' This designer uses the IDictionaryService to store an ArrayList
 of 
    ' information strings that the associated control can access and
 
    ' display. The IDictionaryService creates a new dictionary for each
 Site.
    Public Class IDictionaryServiceDesigner
        Inherits System.Windows.Forms.Design.ControlDesigner

        Public Sub New()
        End Sub 

        ' On designer initialization, this method attempts to obtain
 
        ' the IDictionaryService, and populates an ArrayList
        ' associated with a "DesignerData" key in the dictionary
 with 
        ' designer- and control-related information strings.
        Public Overrides Sub
 Initialize(ByVal component As System.ComponentModel.IComponent)
            MyBase.Initialize(component)
            Dim ds As IDictionaryService =
 CType(component.Site.GetService(GetType(IDictionaryService)),
 IDictionaryService)
            If Not (ds Is
 Nothing) Then
                ' If the dictionary service does not contain a 
                ' DesignerData key, adds an ArrayList for that key.
                If ds.GetValue("DesignerData")
 Is Nothing Then
                    ds.SetValue("DesignerData", New
 ArrayList())
                    ds.SetValue("DesignerData", New
 ArrayList())
                End If

                ' Obtains the ArrayList with the "DesignerData"
 key 
                ' from the dictionary service.
                Dim al As ArrayList = CType(ds.GetValue("DesignerData"),
 ArrayList)
                If Not (al Is
 Nothing) Then
                    al.Clear()
                    ' Populates the array list with designer and 
                    ' control information strings.
                    al.Add(("Designer type: " + Me.GetType().Name))
                    al.Add(("Control type:  " + Me.Control.GetType().Name))
                    al.Add(("Control name:  " + Me.Control.Name))
                End If
            End If
        End Sub 

        ' Translates the point to client coordinates and passes the
 
        ' messages to the control while over the click box.
        Protected Overrides Function
 GetHitTest(ByVal point As System.Drawing.Point)
 As Boolean
            Dim translated As Point = Me.Control.PointToClient(point)
            If translated.X > 269 And translated.X
 < 331 And translated.Y > 7 And translated.Y
 < 18 Then
                Return True
            Else
                Return MyBase.GetHitTest(point)
            End If
        End Function 
    End Class 

End Namespace 
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

namespace IDictionaryServiceControl
{
    // This example control works with the IDictionaryServiceDesigner
 to demonstrate
    // using the IDictionaryService for storing data provided by a designer,
 and
    // accessing it from a control. The IDictionaryService provides
 a Site-specific 
    // key-based dictionary. An IDictionaryServiceDesigner sets an ArrayList
 of strings 
    // to the dictionary with a "DesignerData" key, and its
 contents are accessed and
    // displayed once the Update box is clicked at design time.
    [DesignerAttribute(typeof(IDictionaryServiceDesigner), typeof(IDesigner))]
    public class IDictionaryServiceControl
 : System.Windows.Forms.UserControl
    {
        public ArrayList al;

        public IDictionaryServiceControl()
        {            
            // Initializes the example control.
            al = new ArrayList();
            this.Size = new Size(344, 88);
            this.BackColor = Color.White;
        }

        // Draws the instructions and user interface, and any strings
 contained 
        // in a local ArrayList.
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs
 e)
        {
            if( this.DesignMode )
            {
                e.Graphics.DrawString("IDictionaryServiceDesigner Control",
 new Font(FontFamily.GenericMonospace, 9), new
 SolidBrush(Color.Blue), 5, 4);                         
                e.Graphics.DrawString("Click the Update box to update display
 strings", new Font(FontFamily.GenericMonospace, 8), new
 SolidBrush(Color.DarkGreen), 5, 17);
                e.Graphics.DrawString("from the IDictionaryService.", new
 Font(FontFamily.GenericMonospace, 8), new SolidBrush(Color.DarkGreen),
 5, 29);                 
                
                e.Graphics.FillRectangle(new SolidBrush(Color.Beige),
 270, 7, 60, 10);
                e.Graphics.DrawRectangle(new Pen(new
 SolidBrush(Color.Black), 1), 270, 7, 60, 10);
                e.Graphics.DrawString("Update", new
 Font(FontFamily.GenericMonospace, 7), new SolidBrush(Color.Black),
 282, 7);

                for( int i=0; i<al.Count;
 i++ )            
                    e.Graphics.DrawString((string)al[i], new
 Font(FontFamily.GenericMonospace, 8), new SolidBrush(Color.Black),
 5, 44+(i*12));            
            }
        }

        // On mouse down, this method attempts to access the IDictionaryService
 and 
        // obtain an ArrayList with a key of "DesignerData"
 in the dictionary.
        // If successful, this ArrayList is set to the local ArrayList.
        protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs
 e)
        {
            // Attempts to obtain the IDictionaryService using the Control.GetService
 method.
            IDictionaryService ds = (IDictionaryService)GetService(typeof(IDictionaryService));
            // If the service was obtained...
            if( ds != null )
            {
                // Attempts to retrieve a list with a key of "DesignerData".
                ArrayList list = (ArrayList)ds.GetValue( "DesignerData"
 );
                // If the list exists, sets the list obtained by the
 
                // IDictionaryService to the local list.
                if( list != null )
                    this.al = list;
                this.Refresh();
            }
        }
    }

    // This designer uses the IDictionaryService to store an ArrayList
 of
    // information strings that the associated control can access and
 
    // display. The IDictionaryService creates a new dictionary for
 each Site.
    public class IDictionaryServiceDesigner
 : System.Windows.Forms.Design.ControlDesigner
    {
        public IDictionaryServiceDesigner()
        {
        }

        // On designer initialization, this method attempts to obtain
 
        // the IDictionaryService, and populates an ArrayList
        // associated with a "DesignerData" key in the dictionary
 with 
        // designer- and control-related information strings.
        public override void Initialize(System.ComponentModel.IComponent
 component)
        {
            base.Initialize(component);            
            IDictionaryService ds = (IDictionaryService)component.Site.GetService(typeof(IDictionaryService));
            if( ds != null )
            {
                // If the dictionary service does not contain a 
                // DesignerData key, adds an ArrayList for that key.
                if( ds.GetValue( "DesignerData" ) ==
 null )           
                {
                    ds.SetValue( "DesignerData", new
 ArrayList() );
                       ds.SetValue( "DesignerData", new
 ArrayList() );
                }

                // Obtains the ArrayList with the "DesignerData"
 key 
                // from the dictionary service.
                ArrayList al = (ArrayList)ds.GetValue( "DesignerData" );
                if( al != null )
                {
                    al.Clear();
                    // Populates the array list with designer and 
                    // control information strings.
                    al.Add( "Designer type: "+this.GetType().Name
 );
                    al.Add( "Control type:  "+this.Control.GetType().Name
 );
                    al.Add( "Control name:  "+this.Control.Name
 );                    
                }
            }
        }

        protected override bool GetHitTest(System.Drawing.Point
 point)
        {
            // Translates the point to client coordinates and passes
 the 
            // messages to the control while over the click box.
            Point translated = this.Control.PointToClient(point);
            if( translated.X > 269 && translated.X
 < 331 
                && translated.Y > 7 && translated.Y < 18 )
                return true;
            else
                return base.GetHitTest(point);
        }
    }
}
#using <System.Design.dll>
#using <System.Windows.Forms.dll>
#using <System.Data.dll>
#using <System.Drawing.dll>
#using <System.dll>

using namespace System;
using namespace System::Collections;
using namespace System::ComponentModel;
using namespace System::ComponentModel::Design;
using namespace System::Drawing;
using namespace System::Data;
using namespace System::Windows::Forms;
using namespace System::Windows::Forms::Design;

namespace IDictionaryServiceControl
{
   ref class IDictionaryServiceDesigner;

   // This example control works with the IDictionaryServiceDesigner
 to demonstrate
   // using the IDictionaryService for storing data provided by a designer,
 and
   // accessing it from a control. The IDictionaryService provides a
 Site-specific 
   // key-based dictionary. An IDictionaryServiceDesigner sets an ArrayList
 of strings 
   // to the dictionary with a "DesignerData" key, and its
 contents are accessed and
   // displayed once the Update box is clicked at design time.

   [DesignerAttribute(IDictionaryServiceDesigner::typeid,IDesigner::typeid)]
   public ref class IDictionaryServiceControl:
 public System::Windows::Forms::UserControl
   {
   public:
      ArrayList^ al;
      IDictionaryServiceControl()
      {
         // Initializes the example control.
         al = gcnew ArrayList;
         this->Size = System::Drawing::Size( 344, 88 );
         this->BackColor = Color::White;
      }

   protected:

      // Draws the instructions and user interface, and any strings
 contained 
      // in a local ArrayList.
      virtual void OnPaint( System::Windows::Forms::PaintEventArgs^
 e ) override
      {
         if ( this->DesignMode )
         {
            e->Graphics->DrawString( "IDictionaryServiceDesigner Control",
 gcnew System::Drawing::Font( FontFamily::GenericMonospace,9 ), gcnew SolidBrush(
 Color::Blue ), 5, 4 );
            e->Graphics->DrawString( "Click the Update box to update display
 strings", gcnew System::Drawing::Font( FontFamily::GenericMonospace,8 ), gcnew
 SolidBrush( Color::DarkGreen ), 5, 17 );
            e->Graphics->DrawString( "from the IDictionaryService.",
 gcnew System::Drawing::Font( FontFamily::GenericMonospace,8 ), gcnew SolidBrush(
 Color::DarkGreen ), 5, 29 );
            e->Graphics->FillRectangle( gcnew SolidBrush( Color::Beige ), 270,
 7, 60, 10 );
            e->Graphics->DrawRectangle( gcnew Pen( gcnew SolidBrush( Color::Black
 ),1 ), 270, 7, 60, 10 );
            e->Graphics->DrawString( "Update", gcnew System::Drawing::Font(
 FontFamily::GenericMonospace,7 ), gcnew SolidBrush( Color::Black ), 282, 7 );
            for ( int i = 0; i < al->Count;
 i++ )
               e->Graphics->DrawString( dynamic_cast<String^>(al[ i ]),
 gcnew System::Drawing::Font( FontFamily::GenericMonospace,8 ), gcnew SolidBrush(
 Color::Black ), 5.0f, 44.0f + (i * 12) );
         }
      }

      // On mouse down, this method attempts to access the IDictionaryService
 and 
      // obtain an ArrayList with a key of "DesignerData"
 in the dictionary.
      // If successful, this ArrayList is set to the local ArrayList.
      virtual void OnMouseDown( System::Windows::Forms::MouseEventArgs^
 /*e*/ ) override
      {
         // Attempts to obtain the IDictionaryService using the Control.GetService
 method.
         IDictionaryService^ ds = dynamic_cast<IDictionaryService^>(GetService(
 IDictionaryService::typeid ));

         // If the service was obtained...
         if ( ds != nullptr )
         {
            // Attempts to retrieve a list with a key of "DesignerData".
            ArrayList^ list = dynamic_cast<ArrayList^>(ds->GetValue( "DesignerData"
 ));
            
            // If the list exists, sets the list obtained by the 
            // IDictionaryService to the local list.
            if ( list != nullptr )
                        this->al = list;
            this->Refresh();
         }
      }

   };

   // This designer uses the IDictionaryService to store an ArrayList
 of
   // information strings that the associated control can access and
 
   // display. The IDictionaryService creates a new dictionary for each
 Site.
   public ref class IDictionaryServiceDesigner:
 public System::Windows::Forms::Design::ControlDesigner
   {
   public:
      IDictionaryServiceDesigner(){}

      // On designer initialization, this method attempts to obtain
 
      // the IDictionaryService, and populates an ArrayList
      // associated with a "DesignerData" key in the dictionary
 with 
      // designer- and control-related information strings.
      virtual void Initialize( System::ComponentModel::IComponent^
 component ) override
      {
         ControlDesigner::Initialize( component );
         IDictionaryService^ ds = dynamic_cast<IDictionaryService^>(component->Site->GetService(
 IDictionaryService::typeid ));
         if ( ds != nullptr )
         {
            // If the dictionary service does not contain a 
            // DesignerData key, adds an ArrayList for that key.
            if ( ds->GetValue( "DesignerData" ) ==
 nullptr )
            {
               ds->SetValue( "DesignerData", gcnew ArrayList );
               ds->SetValue( "DesignerData", gcnew ArrayList );
            }

            // Obtains the ArrayList with the "DesignerData"
 key 
            // from the dictionary service.
            ArrayList^ al = dynamic_cast<ArrayList^>(ds->GetValue( "DesignerData"
 ));
            if ( al != nullptr )
            {
               al->Clear();

               // Populates the array list with designer and 
               // control information strings.
               al->Add( String::Format( "Designer type: {0}", this->GetType()->Name
 ) );
               al->Add( String::Format( "Control type:  {0}", this->Control->GetType()->Name
 ) );
               al->Add( String::Format( "Control name:  {0}", this->Control->Name
 ) );
            }
         }
      }

   protected:
      virtual bool GetHitTest( System::Drawing::Point point )
 override
      {
         // Translates the point to client coordinates and passes the
 
         // messages to the control while over the click box.
         Point translated = this->Control->PointToClient(
 point );
         if ( translated.X > 269 && translated.X <
 331 && translated.Y > 7 && translated.Y < 18 )
                  return true;
         else
                  return ControlDesigner::GetHitTest( point );
      }
   };
}
import System.*;
import System.Collections.*;
import System.ComponentModel.*;
import System.ComponentModel.Design.*;
import System.Drawing.*;
import System.Data.*;
import System.Windows.Forms.*;

//  This example control works with the IDictionaryServiceDesigner to
 
//  demonstrate using the IDictionaryService for storing data provided
//  by a designer, and accessing it from a control. The IDictionaryService
//  provides a Site-specific key-based dictionary. An IDictionaryServiceDesigner
//  sets an ArrayList of strings to the dictionary with a "DesignerData"
 key, 
//  and its contents are accessed and displayed once the Update box
 is clicked at
//  design time.
/** @attribute DesignerAttribute(IDictionaryServiceDesigner.class
,
   IDesigner.class)
 */
public class IDictionaryServiceControl extends
 System.Windows.Forms.UserControl
{
    public ArrayList al;

    public IDictionaryServiceControl()
    {
        // Initializes the example control.
        al = new ArrayList();
        this.set_Size(new Size(344, 88));
        this.set_BackColor(Color.get_White());
    } //IDictionaryServiceControl

    // Draws the instructions and user interface, and any strings contained
 
    // in a local ArrayList.
    protected void OnPaint(System.Windows.Forms.PaintEventArgs
 e)
    {
        if (this.get_DesignMode()) {
            e.get_Graphics().DrawString("IDictionaryServiceDesigner Control"
,
                new Font(FontFamily.get_GenericMonospace(), 9),
 
                new SolidBrush(Color.get_Blue()), 5, 4);
            e.get_Graphics().DrawString("Click the Update box to update"
                + " display strings", new Font(FontFamily.
                get_GenericMonospace(), 8), 
                new SolidBrush(Color.get_DarkGreen()), 5, 17);
            e.get_Graphics().DrawString("from the IDictionaryService.",
 
                new Font(FontFamily.get_GenericMonospace(), 8),
 
                new SolidBrush(Color.get_DarkGreen()), 5, 29);
            e.get_Graphics().FillRectangle(new SolidBrush(Color.get_Beige()),
 
                270, 7, 60, 10);
            e.get_Graphics().DrawRectangle(new Pen(new
 
                SolidBrush(Color.get_Black()), 1), 270, 7, 60, 10);
            e.get_Graphics().DrawString("Update", new
 
                Font(FontFamily.get_GenericMonospace(), 7), 
                new SolidBrush(Color.get_Black()), 282, 7);

            for (int i = 0; i < al.get_Count();
 i++) {
                e.get_Graphics().DrawString((System.String)(al.get_Item(i)),
                    new Font(FontFamily.get_GenericMonospace(), 8),
 
                    new SolidBrush(Color.get_Black()), 5, 44 +
 i * 12);
            }
        }
    } //OnPaint

    // On mouse down, this method attempts to access the IDictionaryService
 and
    // obtain an ArrayList with a key of "DesignerData" in
 the dictionary.
    // If successful, this ArrayList is set to the local ArrayList.
    protected void OnMouseDown(System.Windows.Forms.MouseEventArgs
 e)
    {
        // Attempts to obtain the IDictionaryService using 
        //the Control.GetService method.
        IDictionaryService ds = (IDictionaryService)
            (GetService(IDictionaryService.class.ToType()));

        // If the service was obtained...
        if (ds != null) {
            // Attempts to retrieve a list with a key of "DesignerData".
            ArrayList list = (ArrayList)(ds.GetValue("DesignerData"));

            // If the list exists, sets the list obtained by the 
            // IDictionaryService to the local list.
            if (list != null) {
                this.al = list;
            }
            this.Refresh();
        }
    } //OnMouseDown
} //IDictionaryServiceControl

//  This designer uses the IDictionaryService to store an ArrayList
 of
//  information strings that the associated control can access and 
//  display. The IDictionaryService creates a new dictionary for each
 Site.
public class IDictionaryServiceDesigner extends
 
    System.Windows.Forms.Design.ControlDesigner
{
    public IDictionaryServiceDesigner()
    {
    } //IDictionaryServiceDesigner

    // On designer initialization, this method attempts to obtain 
    // the IDictionaryService, and populates an ArrayList
    // associated with a "DesignerData" key in the dictionary
 with 
    // designer- and control-related information strings.
    public void Initialize(System.ComponentModel.IComponent
 component)
    {
        super.Initialize(component);

        IDictionaryService ds = (IDictionaryService)(component.get_Site().
            GetService(IDictionaryService.class.ToType()));

        if (ds != null) {
            // If the dictionary service does not contain a 
            // DesignerData key, adds an ArrayList for that key.
            if (ds.GetValue("DesignerData") == null)
 {
                ds.SetValue("DesignerData", new ArrayList());
                ds.SetValue("DesignerData", new ArrayList());
            }
            // Obtains the ArrayList with the "DesignerData"
 key 
            // from the dictionary service.
            ArrayList al = (ArrayList)(ds.GetValue("DesignerData"));

            if (al != null) {
                al.Clear();

                // Populates the array list with designer and 
                // control information strings.
                al.Add("Designer type: " + this.GetType().get_Name());
                al.Add("Control type:  " 
                    + this.get_Control().GetType().get_Name());
                al.Add("Control name:  " + this.get_Control().get_Name());
            }
        }
    } //Initialize

    protected boolean GetHitTest(System.Drawing.Point point)
    {
        // Translates the point to client coordinates and passes the
 
        // messages to the control while over the click box.
        Point translated = this.get_Control().PointToClient(point);

        if (translated.get_X() > 269 && translated.get_X()
 < 331 && 
            translated.get_Y() > 7 && translated.get_Y() < 18) {
            return true;
        }
        else {
            return super.GetHitTest(point);
        }
    } //GetHitTest
} //IDictionaryServiceDesigner
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
IDictionaryService メンバ
System.ComponentModel.Design 名前空間

IDictionaryService メソッド


パブリック メソッドパブリック メソッド

参照参照

関連項目

IDictionaryService インターフェイス
System.ComponentModel.Design 名前空間

IDictionaryService メンバ




英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「IDictionaryService」の関連用語

IDictionaryServiceのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



IDictionaryServiceのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS