当前位置: 首页>>代码示例>>C#>>正文


C# IWindowsFormsEditorService.CloseDropDown方法代码示例

本文整理汇总了C#中IWindowsFormsEditorService.CloseDropDown方法的典型用法代码示例。如果您正苦于以下问题:C# IWindowsFormsEditorService.CloseDropDown方法的具体用法?C# IWindowsFormsEditorService.CloseDropDown怎么用?C# IWindowsFormsEditorService.CloseDropDown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IWindowsFormsEditorService的用法示例。


在下文中一共展示了IWindowsFormsEditorService.CloseDropDown方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EditValue

        /// <summary>
        /// Called when we want to edit the value of a property.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="provider"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            if (edSvc != null)
            {
                UI.Actions.MessageAction messageAction = context.Instance as UI.Actions.MessageAction;
                if (messageAction != null)
                {
                    ListBox listBox = new ListBox();
                    foreach (UI.Message message in messageAction.Scene.Messages)
                    {
                        listBox.Items.Add(message);
                    }

                    listBox.SelectedItem = messageAction.Scene.GetMessage((int)value);
                    listBox.SelectedIndexChanged += ((s, e) => { edSvc.CloseDropDown(); });

                    edSvc.DropDownControl(listBox);

                    return listBox.SelectedItem != null ? (listBox.SelectedItem as UI.Message).ID : -1;
                }
            }

            return value;
        }
开发者ID:RasterCode,项目名称:OtterUI,代码行数:32,代码来源:UIMessageEditor.cs

示例2: EditValue

        /// <summary>
        /// Called when we want to edit the value of the property.  Brings up the a drop down list box of masks.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="provider"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            if (edSvc != null)
            {
                GUIControl controlContext = context.Instance as GUIControl;

                ListBox listBox = new ListBox();
                listBox.Items.Add("None");
                AddControls(listBox, controlContext.ParentView.Controls);

                listBox.SelectedItem = value;
                listBox.SelectedIndexChanged += (s, e) => { edSvc.CloseDropDown(); };

                edSvc.DropDownControl(listBox);

                //no valid item selected; return previous value
                if (listBox.SelectedIndex == -1 || listBox.SelectedItem == null)
                    return value;

                //"None" selected
                if (listBox.SelectedIndex == 0)
                    return -1;

                return (listBox.SelectedItem as GUIMask).ID;
            }

            return value;
        }
开发者ID:RasterCode,项目名称:OtterUI,代码行数:36,代码来源:UIMaskEditor.cs

示例3: EditValue

        /// <summary>
        /// Called when we want to edit the value of a property.  Displays a listbox with the available fonts.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="provider"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            if (edSvc != null)
            {
                ListBox listBox = new ListBox();
                foreach (GUIFont font in GUIProject.CurrentProject.Fonts)
                {
                    listBox.Items.Add(font);
                }

                listBox.SelectedItem = GUIProject.CurrentProject.GetFont((int)value);
                listBox.SelectedIndexChanged += (s, e) => { edSvc.CloseDropDown(); };

                edSvc.DropDownControl(listBox);

                return listBox.SelectedItem != null ? (listBox.SelectedItem as GUIFont).ID : -1;
            }

            return value;
        }
开发者ID:RasterCode,项目名称:OtterUI,代码行数:28,代码来源:UIFontEditor.cs

示例4: PercentControl

            /// <summary>
            /// Initializes a new instance of the <see cref="AngleControl"/> class.
            /// </summary>
            /// <param name="initialAngle">The initial angle.</param>
            public PercentControl(float initialAngle, IWindowsFormsEditorService edService)
            {
                this.Value = initialAngle;

                this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
                this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);

                TrackBar trackBar = new TrackBar
                {
                    Dock = DockStyle.Right,
                    LargeChange = 25,
                    Maximum = 100,
                    Minimum = 0,
                    Orientation = Orientation.Vertical,
                    SmallChange = 5,
                    TickFrequency = 10,
                    TickStyle = TickStyle.Both,
                    Value = (int)(initialAngle * 100f)
                };

                base.Controls.Add(trackBar);

                trackBar.ValueChanged += (s, ea) => this.Value = trackBar.Value / 100f;
                
                trackBar.MouseUp += (s, ea) => edService.CloseDropDown();
            }
开发者ID:Andrea,项目名称:MercuryParticleEngine,代码行数:30,代码来源:PercentEditor.cs

示例5: EditValue

		[RefreshProperties(RefreshProperties.All)]public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
		{
			if (context == null || provider == null || context.Instance == null)
			{
				return base.EditValue(provider, value);
			}
			
			oEditorService =  (System.Windows.Forms.Design.IWindowsFormsEditorService) provider.GetService(typeof(IWindowsFormsEditorService));
			if (oEditorService != null)
			{
				
				// Get the Back reference to the Custom Property
				CustomProperty.CustomPropertyDescriptor oDescriptor =  (CustomProperty.CustomPropertyDescriptor) context.PropertyDescriptor;
				CustomProperty cp =  (CustomProperty) oDescriptor.CustomProperty;
				
				// Declare attributes
				UIListboxDatasource datasource;
				UIListboxValueMember valuemember;
				UIListboxDisplayMember displaymember;
				
				// Get attributes
				datasource =  (UIListboxDatasource) context.PropertyDescriptor.Attributes[typeof(UIListboxDatasource)];
				valuemember =  (UIListboxValueMember) context.PropertyDescriptor.Attributes[typeof(UIListboxValueMember)];
				displaymember =  (UIListboxDisplayMember) context.PropertyDescriptor.Attributes[typeof(UIListboxDisplayMember)];
				
				oList.BorderStyle = BorderStyle.None;
				oList.IntegralHeight = true;
				
				if (datasource != null)
				{
					oList.DataSource = datasource.Value;
				}
				
				if (displaymember != null)
				{
					oList.DisplayMember = displaymember.Value;
				}
				
				if (valuemember != null)
				{
					oList.ValueMember = valuemember.Value;
				}
				
				if (value != null)
				{
					if (value.GetType().Name == "String")
					{
						oList.Text =  (string) value;
					}
					else
					{
						oList.SelectedItem = value;
					}
				}
				
				
				oList.SelectedIndexChanged += new System.EventHandler(this.SelectedItem);
				
				oEditorService.DropDownControl(oList);
				if (oList.SelectedIndices.Count == 1)
				{
					cp.SelectedItem = oList.SelectedItem;
					cp.SelectedValue = oSelectedValue;
					value = oList.Text;
				}
				oEditorService.CloseDropDown();
			}
			else
			{
				return base.EditValue(provider, value);
			}
			
			return value;
			
		}
开发者ID:BackupTheBerlios,项目名称:zp7-svn,代码行数:75,代码来源:UIListboxEditor.cs

示例6: EditValue

        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            //look for a TrackBarEditorData Attribute.
            TrackBarEditorData usedata = null;
            foreach (Attribute iterate in context.PropertyDescriptor.Attributes)
            {
                if (iterate.GetType() == typeof(TrackBarEditorData))
                {
                    usedata = (TrackBarEditorData)iterate;
                    break;
                }

            }
            if (usedata == null) usedata = new TrackBarEditorData(0, 200);
            var returntype = value.GetType(); //type to return.
            Debug.Print(("Type of context.instance-" + context.Instance.GetType().Name));
            if (provider != null)
            {

                mserv = ((IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)));

                if (mserv != null)
                {
                    // This is an internal Microsoft class representing the PropertyGrid entry for our component.
                    PictureBox DropDownBox = new PictureBox();
                    DropDownBox.BorderStyle = BorderStyle.None;
                    DropDownBox.Resize += new EventHandler(DropDownBox_Resize);
                    TrackBar tb = new TrackBar();
                    //set the minimum to min, and maximum to maximum value.
                    tb.Minimum = minvalueset;
                    tb.Maximum=maxvalueset;
                    //scale the value as needed.
                    double currentvalue = (double)(Convert.ChangeType(value, TypeCode.Double)??0);
                    tb.LargeChange = 4096;
                    tb.SmallChange = 256;
                    tb.TickFrequency = 256;
                    tb.TickStyle = TickStyle.BottomRight;

                    //scale it to between Int.MinValue and int.MaxValue.

                    double Percentage = currentvalue/(usedata.Maximum - usedata.Minimum);
                    if (double.IsInfinity(Percentage)) Percentage = 0;
                    int scaled = (int)((((double)maxvalueset - (double)minvalueset) * Percentage) + (double)minvalueset);

                    tb.Value = scaled;

                    // Drop the trackbar

                    mserv.DropDownControl(tb);

                    scaled = tb.Value;
                    //now we need to work backwards.
                    Percentage = ((double)scaled) / ((double)maxvalueset - (double)minvalueset);
                    double usethisvalue = Percentage * (usedata.Maximum - usedata.Minimum) + usedata.Minimum;

                    value = Convert.ChangeType(usethisvalue, returntype);

                    // Close the list control after selection.
                    mserv.CloseDropDown();
                }
            }
            return value;
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:63,代码来源:SpecialTypeEditors.cs


注:本文中的IWindowsFormsEditorService.CloseDropDown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。