當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。