本文整理汇总了C#中IDataObject类的典型用法代码示例。如果您正苦于以下问题:C# IDataObject类的具体用法?C# IDataObject怎么用?C# IDataObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IDataObject类属于命名空间,在下文中一共展示了IDataObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ItemDropped
public override bool ItemDropped(IDataObject dragData)
{
if (IsValidDropTarget(dragData))
{
OutlinerNode[] droppedNodes = GetNodesFromDataObject(dragData);
Int32[] droppedNodeHandles = new Int32[droppedNodes.Length];
Tree.BeginTimedUpdate();
Tree.BeginTimedSort();
Int32 i = 0;
foreach (OutlinerNode n in droppedNodes)
{
//Tree.LinkObject((OutlinerObject)n, Data.Handle, false, false);
droppedNodeHandles[i] = ((OutlinerObject)n).Handle;
i++;
}
//Tree.RaiseObjectLinkedEvent(new NodeLinkedEventArgs(droppedNodeHandles, Data.Handle));
Tree.RaiseObjectAddedToContainerEvent(new NodeGroupedEventArgs(droppedNodeHandles, Data.Handle, true, false));
return true;
}
return false;
}
开发者ID:Pjanssen,项目名称:Outliner,代码行数:26,代码来源:ContainerDragDropHandler.cs
示例2: DoPaste
// Retrieves the text from the IDataObject instance.
// Then create a textbox with the text data.
protected override void DoPaste(IDataObject dataObject)
{
ElementList = new List<UIElement>();
// Get the string from the data object.
string text = dataObject.GetData(DataFormats.UnicodeText, true) as string;
if ( String.IsNullOrEmpty(text) )
{
// OemText can be retrieved as CF_TEXT.
text = dataObject.GetData(DataFormats.Text, true) as string;
}
if ( !String.IsNullOrEmpty(text) )
{
// Now, create a text box and set the text to it.
TextBox textBox = new TextBox();
textBox.Text = text;
textBox.TextWrapping = TextWrapping.Wrap;
// Add the textbox to the internal array list.
ElementList.Add(textBox);
}
}
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:28,代码来源:TextClipboardData.cs
示例3: GetNodesFromDataObject
public static OutlinerNode[] GetNodesFromDataObject(IDataObject dragData)
{
if (dragData.GetDataPresent(typeof(OutlinerNode[])))
return (OutlinerNode[])dragData.GetData(typeof(OutlinerNode[]));
else
return null;
}
开发者ID:Pjanssen,项目名称:Outliner,代码行数:7,代码来源:DragDropHandler.cs
示例4: GetDragDropEffect
public override DragDropEffects GetDragDropEffect(IDataObject dragData)
{
if (IsValidDropTarget(dragData))
return DragDropEffects.Copy;
else
return Outliner.TreeView.DragDropEffectsNone;
}
开发者ID:Pjanssen,项目名称:Outliner,代码行数:7,代码来源:LayerDragDropHandler.cs
示例5: ExtractElement
public virtual UIElement ExtractElement(IDataObject obj)
{
string xamlString = obj.GetData(supportedFormat) as string;
XmlReader reader = XmlReader.Create(new StringReader(xamlString));
UIElement elt = XamlReader.Load(reader) as UIElement;
return elt;
}
开发者ID:atombender,项目名称:learning,代码行数:7,代码来源:DropTargetBase.cs
示例6: Drop
public override void Drop(IDataObject data, int index, DropEffect finalEffect)
{
try {
string insertText = (data.GetData(typeof(string[])) as string[])
.Aggregate((text, part) => text += part);
ITextAnchor marker;
int length = 0;
if (index == this.Children.Count) {
if (index == 0)
marker = null;
else
marker = (this.Children[index - 1] as XamlOutlineNode).EndMarker;
if (marker == null) {
marker = this.EndMarker;
length = -1; // move backwards
} else {
length = 2 + (this.Children[index - 1] as XamlOutlineNode).elementName.Length;
}
} else
marker = (this.Children[index] as XamlOutlineNode).Marker;
int offset = marker.Offset + length;
Editor.Document.Insert(offset, insertText);
} catch (Exception ex) {
throw ex;
}
}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:27,代码来源:XamlOutlineNode.cs
示例7: LimitDragDropOptions
public bool LimitDragDropOptions(IDataObject data)
{
var formats = data.GetFormats();
if(!formats.Any())
{
return true;
}
var modelItemString = formats.FirstOrDefault(s => s.IndexOf("ModelItemsFormat", StringComparison.Ordinal) >= 0);
if(!String.IsNullOrEmpty(modelItemString))
{
var innnerObjectData = data.GetData(modelItemString);
var modelList = innnerObjectData as List<ModelItem>;
if(modelList != null && modelList.Count > 1)
{
if(modelList.FirstOrDefault(c => c.ItemType == typeof(FlowDecision) || c.ItemType == typeof(FlowSwitch<string>)) != null)
{
return false;
}
}
}
modelItemString = formats.FirstOrDefault(s => s.IndexOf("ModelItemFormat", StringComparison.Ordinal) >= 0);
if(String.IsNullOrEmpty(modelItemString))
{
modelItemString = formats.FirstOrDefault(s => s.IndexOf("WorkflowItemTypeNameFormat", StringComparison.Ordinal) >= 0);
if(String.IsNullOrEmpty(modelItemString))
{
return true;
}
}
var objectData = data.GetData(modelItemString);
return DropPointOnDragEnter(objectData);
}
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:35,代码来源:DropEnabledActivityDesignerUtils.cs
示例8: Format
public string Format(IDataObject obj)
{
if (obj == null) return string.Empty;
var cls = _resolver.GetObjectClass(obj.Context.GetInterfaceType(obj));
var allProps = cls.GetAllProperties();
var result = new StringBuilder();
foreach (var prop in allProps.OfType<StringProperty>().OrderBy(p => p.Name))
{
var txtVal = obj.GetPropertyValue<string>(prop.Name);
if (!string.IsNullOrWhiteSpace(txtVal))
{
result.AppendLine(txtVal);
}
}
foreach (var prop in allProps.OfType<EnumerationProperty>().OrderBy(p => p.Name))
{
var enumVal = obj.GetPropertyValue<int>(prop.Name);
var txtVal = prop.Enumeration.GetLabelByValue(enumVal);
if (!string.IsNullOrWhiteSpace(txtVal))
{
result.AppendLine(txtVal);
}
}
return result.ToString();
}
开发者ID:daszat,项目名称:zetbox,代码行数:29,代码来源:DataObjectFormatter.cs
示例9: CheckRequiredProperties
private static void CheckRequiredProperties(IDataObject dataObj, ref DataObjectOperationResult result)
{
//Get Required Properties
var requiredProperties = dataObj.GetType()
.GetProperties()
.Where(x => Attribute.IsDefined(x, typeof(RequiredValueAttribute)));
//Check to Ensure Required Properties are not Null or empty
foreach (var reqProp in requiredProperties)
{
var prop = dataObj.GetType().GetProperty(reqProp.Name);
var propValue = prop.GetValue(dataObj, null);
bool isNull = false;
switch (prop.PropertyType.Name.ToLower())
{
case "string":
isNull = string.IsNullOrEmpty((string)propValue);
break;
default:
isNull = propValue == null;
break;
}
if (isNull)
{
RequiredValueAttribute reqAttrib = (RequiredValueAttribute)(prop.GetCustomAttributes(typeof(RequiredValueAttribute), false)[0]);
//var reqAttrib = prop.GetCustomAttribute<RequiredValueAttribute>();
result.Message = "A Required Value is Missing";
result.ErrorMessages.Add(reqProp.Name, reqAttrib.ErrorMessage);
result.Success = false;
}
}
}
开发者ID:sympletech,项目名称:SympleLib,代码行数:34,代码来源:AttributeValidator.cs
示例10: AppendData
public void AppendData(ref IDataObject data, MouseEventArgs e)
{
if (!(this.list.InputHitTest(e.GetPosition(e.OriginalSource as UIElement)) is ListBox)
&& !(this.list.InputHitTest(e.GetPosition(e.OriginalSource as UIElement)) is ScrollViewer)
&& !(e.OriginalSource is Thumb))
{
object o = this.list.SelectedItem;
// This is cheating .. just for an example's sake..
Debug.Assert(!data.GetDataPresent(DataFormats.Text));
if (o.GetType() == typeof(XmlElement))
{
data.SetData(DataFormats.Text, ((XmlElement)o).OuterXml);
}
else
{
data.SetData(DataFormats.Text, o.ToString());
}
Debug.Assert(!data.GetDataPresent(o.GetType().ToString()));
data.SetData(o.GetType().ToString(), o);
}
else
{
data = null;
}
}
开发者ID:cipjota,项目名称:Chronos,代码行数:29,代码来源:ListBoxDragDropDataProvider.cs
示例11: CloneClipboard
private IDataObject CloneClipboard(IDataObject obj)
{
if (obj == null)
return null;
string[] formats = obj.GetFormats();
if (formats.Length == 0)
return null;
IDataObject newObj = new DataObject();
foreach (string format in formats)
{
if (format.Contains("EnhancedMetafile")) //Ignore this. Cannot be processed in .NET
continue;
object o = obj.GetData(format);
if (o != null)
{
newObj.SetData(o);
}
}
return newObj;
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:26,代码来源:ClipboardSnapshot.cs
示例12: CreateFrom
/// <summary>
/// Create an OleDataObject from a .NET IDataObject.
/// </summary>
/// <param name="ido">IDataObject to extract OleDataObject from</param>
/// <returns>A new instance of OleDataObject mapped to the inner
/// OleDataObject of the specified IDataObject or null if unable
/// to extract OleDataObject from IDataObject</returns>
public static OleDataObject CreateFrom(IDataObject ido)
{
// initialize OleDataObject
OleDataObject oleDataObject = new OleDataObject();
// attempt to convert to concrete DataObject class
DataObject dataObject = ido as DataObject;
if (dataObject == null)
{
return null;
}
// To extract an OleDataObject from a DataObject, we first need to
// get the "innerData" field of the DataObject. This field is of type
// System.Windows.Forms.UnsafeNativeMethods.OleConverter. Next, we
// need to get the "innerData" field of the OleConverter, which is of
// type System.Windows.Forms.UnsafeNativeMethods.IOleDataObject
const string INNER_DATA_FIELD = "innerData";
object innerData = oleDataObject.GetField(dataObject, INNER_DATA_FIELD);
object innerInnerData = oleDataObject.GetField(innerData, INNER_DATA_FIELD);
// attempt to convert the 'private' ole data object contained in
// innerData into an instance of our locally defined IOleDataObject
oleDataObject.m_dataObject = innerInnerData as IOleDataObject;
if (oleDataObject.m_dataObject != null)
{
return oleDataObject;
}
else
{
return null;
}
}
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:40,代码来源:OleDataObject.cs
示例13: IsValidDataObject
public bool IsValidDataObject(IDataObject obj)
{
bool result = false;
var elt = (FrameworkElement)this.TargetUI;
var storeItemVM = elt.DataContext as StoreItemViewModelBase;
//var channelVM = elt.DataContext as ChannelViewModel;
if (storeItemVM != null)
{
if (obj.GetDataPresent(typeof(StoreItemViewModelBase[])))
{
var data = (StoreItemViewModelBase[])obj.GetData(typeof(StoreItemViewModelBase[]));
result = data != null && data.Length > 0;
//.Any(droppedStoreItemVM => !channelListVM.Contains(droppedChannelVM));
}
}
//else if (channelVM != null)
//{
// if (obj.GetDataPresent(typeof(ChannelViewModel[])))
// {
// var data = (ChannelViewModel[])obj.GetData(typeof(ChannelViewModel[]));
// result = data
// .Any(droppedChannelVM => channelVM != droppedChannelVM);
// }
//}
return result;
}
开发者ID:ChristinaKarandasheva,项目名称:qwerty,代码行数:32,代码来源:StoreItemDropTargetAdvisor.cs
示例14: Create
/// <summary>
/// Attempts to create a new HTMLData. This can return null if the DataObject
/// couldn't be created based upon the IDataObject.
/// </summary>
/// <param name="iDataObject">The IDataObject from which to create the HTML Data Object</param>
/// <returns>The HTMLData, null if it couldn't be created.</returns>
public static HTMLData Create(IDataObject iDataObject)
{
string[] loser = iDataObject.GetFormats();
if (OleDataObjectHelper.GetDataPresentSafe(iDataObject, DataFormats.Html))
{
try
{
HTMLData data = new HTMLData(iDataObject, null);
return string.IsNullOrEmpty(data.HTML) ? null : data;
}
catch (FormatException)
{
// EML files with HTML inside of them report that they are HTML
// However, when we try to read the format, we have problems reading it
// So we will skip loading html that we cannot load
return null;
}
}
else if (HtmlDocumentClassFormatPresent(iDataObject))
{
return new HTMLData(iDataObject, (IHTMLDocument2)iDataObject.GetData(typeof(HTMLDocumentClass)));
}
else
return null;
}
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:34,代码来源:HTMLData.cs
示例15: DoCopy
protected override void DoCopy(IDataObject dataObject)
{
// samgeo - Presharp issue
// Presharp gives a warning when local IDisposable variables are not closed
// in this case, we can't call Dispose since it will also close the underlying stream
// which needs to be open for consumers to read
#pragma warning disable 1634, 1691
#pragma warning disable 6518
// Save the data in the data object.
MemoryStream stream = new MemoryStream();
Strokes.Save(stream);
stream.Position = 0;
(new UIPermission(UIPermissionClipboard.AllClipboard)).Assert();//BlessedAssert
try
{
dataObject.SetData(StrokeCollection.InkSerializedFormat, stream);
}
finally
{
UIPermission.RevertAssert();
}
#pragma warning restore 6518
#pragma warning restore 1634, 1691
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:25,代码来源:ISFClipboardData.cs
示例16: IsValidDropTarget
public override bool IsValidDropTarget(IDataObject dragData)
{
if (Tree == null)
return false;
else
return base.IsValidDropTarget(dragData);
}
开发者ID:Pjanssen,项目名称:Outliner,代码行数:7,代码来源:TreeDragDropHandler.cs
示例17: GetDragDropEffect
public virtual DragDropEffects GetDragDropEffect(IDataObject dragData)
{
if (this.IsValidDropTarget(dragData))
return this.DefaultDragDropEffect;
else
return TreeView.NoneDragDropEffects;
}
开发者ID:Sugz,项目名称:Outliner-3.0,代码行数:7,代码来源:MaxNodeDragDropHandler.cs
示例18: DataObjectToString
public override string[] DataObjectToString(IDataObject obj)
{
Daily daily = (Daily)obj;
string[] strArray = base.DataObjectToString((IDataObject)daily);
strArray[0] = this.DateTimeToString(daily.Date, true);
return strArray;
}
开发者ID:smther,项目名称:FreeOQ,代码行数:7,代码来源:DailyExporter.cs
示例19: SupportsDataObject
protected override bool SupportsDataObject(IServiceProvider provider, IDataObject dataObject)
{
bool flag = false;
IDataObjectMappingService service = (IDataObjectMappingService) provider.GetService(typeof(IDataObjectMappingService));
if (service != null)
{
IDataObjectMapper dataObjectMapper = service.GetDataObjectMapper(dataObject, DataFormats.Text);
if (dataObjectMapper != null)
{
if (dataObjectMapper.CanMapDataObject(provider, dataObject))
{
flag = true;
}
else
{
flag = false;
}
}
}
if (!flag && dataObject.GetDataPresent(CodeWizard.CodeWizardDataFormat))
{
ITextLanguage codeLanguage = this.GetCodeLanguage(provider);
if (codeLanguage != null)
{
flag = codeLanguage.SupportsDataObject(provider, dataObject);
}
}
if (!base.SupportsDataObject(provider, dataObject))
{
return flag;
}
return true;
}
开发者ID:ikvm,项目名称:webmatrix,代码行数:33,代码来源:WebFormsDocumentLanguage.cs
示例20: ItemDropped
public override bool ItemDropped(IDataObject dragData)
{
if (IsValidDropTarget(dragData))
{
OutlinerNode[] droppedNodes = GetNodesFromDataObject(dragData);
Int32[] droppedNodeHandles = new Int32[droppedNodes.Length];
Tree.BeginTimedUpdate();
Tree.BeginTimedSort();
Boolean group = (Control.ModifierKeys & Keys.Control) != Keys.Control;
Int32 i = 0;
foreach (OutlinerNode n in droppedNodes)
{
Tree.LinkObject((OutlinerObject)n, Data.Handle, group, true);
droppedNodeHandles[i] = ((OutlinerObject)n).Handle;
i++;
}
if (group)
{
Tree.RaiseObjectGroupedEvent(new NodeGroupedEventArgs(droppedNodeHandles, Data.Handle, true, true));
Int32[] childHandles = getChildHandles(droppedNodes);
if (childHandles.Length > 0)
Tree.RaiseObjectGroupedEvent(new NodeGroupedEventArgs(childHandles, Data.Handle, true, false));
}
else
Tree.RaiseObjectLinkedEvent(new NodeLinkedEventArgs(droppedNodeHandles, Data.Handle));
return true;
}
return false;
}
开发者ID:Pjanssen,项目名称:Outliner,代码行数:34,代码来源:GroupDragDropHandler.cs
注:本文中的IDataObject类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论