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


C# DataObject.SetWrappedData方法代码示例

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


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

示例1: OnKeyDown

		protected override void OnKeyDown(KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Tab || e.KeyCode == Keys.Oemcomma || e.KeyCode == Keys.Return || e.KeyCode == Keys.Space)
			{
				this.SetFocusEditorIndex((this.focusEditor + 1) % this.editor.Length, true);
				e.Handled = true;
			}
			else if ((e.KeyCode == Keys.C || e.KeyCode == Keys.X) && e.Control)
			{
				if (this.focusEditor == -1)
				{
					string valString = this.editor.Select(ve => ve.Value).ToString(", ");
					DataObject data = new DataObject();
					data.SetText(valString);
					data.SetWrappedData(this.DisplayedValue);
					Clipboard.SetDataObject(data);
					this.SetFocusEditorIndex(-1, true);
					if (e.KeyCode == Keys.X)
					{
						for (int i = 0; i < this.editor.Length; i++)
							this.editor[i].Value = 0;
					}
					e.Handled = true;
				}
				else
				{
					this.editor[this.focusEditor].OnKeyDown(e);
				}
			}
			else if (e.KeyCode == Keys.V && e.Control)
			{
				if (this.focusEditor == -1)
				{
					DataObject data = Clipboard.GetDataObject() as DataObject;
					bool success = false;
					if (data.GetWrappedDataPresent(this.DisplayedValue.GetType()))
					{
						object stored = data.GetWrappedData(this.DisplayedValue.GetType());
						this.SetValue(stored);
						this.PerformGetValue();
						this.OnEditingFinished(FinishReason.LeapValue);
						this.SetFocusEditorIndex(-1, true);
						success = true;
					}
					else if (data.ContainsText())
					{
						string valString = data.GetText();
						string[] token = valString.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
						for (int i = 0; i < Math.Min(token.Length, this.editor.Length); i++)
						{
							token[i] = token[i].Trim();
							decimal val;
							if (decimal.TryParse(token[i], out val))
							{
								this.editor[i].Value = val;
								success = true;
							}
						}
						if (success)
						{
							this.PerformSetValue();
							this.PerformGetValue();
							this.OnEditingFinished(FinishReason.LeapValue);
							this.SetFocusEditorIndex(-1, true);
						}
					}

					if (!success) System.Media.SystemSounds.Beep.Play();
					e.Handled = true;
				}
				else
				{
					this.editor[this.focusEditor].OnKeyDown(e);
				}
			}
			else
			{
				if (this.focusEditor != -1)
					this.editor[this.focusEditor].OnKeyDown(e);
				else
				{
					for (int i = 0; i < this.editor.Length; i++)
					{
						this.editor[i].OnKeyDown(e);
						if (e.Handled)
						{
							this.SetFocusEditorIndex(i, false);
							break;
						}
					}
				}
			}
			base.OnKeyDown(e);
		}
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:94,代码来源:VectorPropertyEditor.cs


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