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


C# ConvertOperation.CanPerform方法代码示例

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


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

示例1: CanDeserializeFromData

        protected override bool CanDeserializeFromData(DataObject data)
        {
            ConvertOperation convert = new ConvertOperation(data, ConvertOperation.Operation.Convert);
            if (convert.CanPerform(this.editedCmpType)) return true;

            if (convert.CanPerform(typeof(GameObject)))
            {
                GameObject obj = convert.Perform<GameObject>().FirstOrDefault();
                return obj != null && obj.GetComponent(this.editedCmpType) != null;
            }

            return false;
        }
开发者ID:Naturaldoc,项目名称:duality,代码行数:13,代码来源:ComponentRefPropertyEditor.cs

示例2: DeserializeFromData

 protected override void DeserializeFromData(DataObject data)
 {
     ConvertOperation convert = new ConvertOperation(data, ConvertOperation.Operation.Convert);
     if (convert.CanPerform(this.editedCmpType))
     {
         var refQuery = convert.Perform(this.editedCmpType);
         if (refQuery != null)
         {
             Component[] refArray = refQuery.Cast<Component>().ToArray();
             this.component = (refArray != null && refArray.Length > 0) ? refArray[0] : null;
             this.PerformSetValue();
             this.PerformGetValue();
             this.OnEditingFinished(FinishReason.LeapValue);
         }
     }
     else if (convert.CanPerform(typeof(GameObject)))
     {
         GameObject obj = convert.Perform<GameObject>().FirstOrDefault();
         Component cmp = obj != null ? obj.GetComponent(this.editedCmpType) : null;
         if (cmp != null)
         {
             this.component = cmp;
             this.PerformSetValue();
             this.PerformGetValue();
             this.OnEditingFinished(FinishReason.LeapValue);
         }
     }
 }
开发者ID:Naturaldoc,项目名称:duality,代码行数:28,代码来源:ComponentRefPropertyEditor.cs

示例3: CanConvertFrom

        public override bool CanConvertFrom(ConvertOperation convert)
        {
            if (convert.AllowedOperations.HasFlag(ConvertOperation.Operation.CreateRes))
            {
                return convert.CanPerform<Pixmap>();
            }

            if (convert.AllowedOperations.HasFlag(ConvertOperation.Operation.Convert))
            {
                List<Pixmap> availData = convert.Perform<Pixmap>(ConvertOperation.Operation.Convert).ToList();
                return availData.Any(t => this.FindMatch(t) != null);
            }

            return false;
        }
开发者ID:sinithwar,项目名称:duality,代码行数:15,代码来源:TextureFromPixmap.cs

示例4: DeserializeFromData

 protected override void DeserializeFromData(DataObject data)
 {
     ConvertOperation convert = new ConvertOperation(data, ConvertOperation.Operation.Convert);
     if (convert.CanPerform(typeof(GameObject)))
     {
         var refQuery = convert.Perform(typeof(GameObject));
         if (refQuery != null)
         {
             GameObject[] refArray = refQuery.Cast<GameObject>().ToArray();
             this.gameObj = (refArray != null && refArray.Length > 0) ? refArray[0] : null;
             this.PerformSetValue();
             this.PerformGetValue();
             this.OnEditingFinished(FinishReason.LeapValue);
         }
     }
 }
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:16,代码来源:GameObjectRefPropertyEditor.cs

示例5: CanConvertFrom

        public override bool CanConvertFrom(ConvertOperation convert)
        {
            if (convert.AllowedOperations.HasFlag(ConvertOperation.Operation.CreateRes))
            {
                return convert.CanPerform<Texture>();
            }

            if (convert.AllowedOperations.HasFlag(ConvertOperation.Operation.Convert))
            {
                List<Texture> availData = convert.Perform<Texture>(ConvertOperation.Operation.Convert).ToList();
                return availData.Any(t =>
                    this.FindMatchingResources<Texture,Material>(t, IsMatch)
                    .Any());
            }

            return false;
        }
开发者ID:SirePi,项目名称:duality,代码行数:17,代码来源:MaterialFromTexture.cs

示例6: OnDragDrop

		protected override void OnDragDrop(DragEventArgs e)
		{
			// Check children first. Only accept the drop if they don't
			e.Effect = DragDropEffects.None;
			base.OnDragDrop(e);
			if (e.Effect != DragDropEffects.None) return;

			DataObject dragDropData = e.Data as DataObject;
			if (!this.ReadOnly && dragDropData != null)
			{
				ConvertOperation convert = new ConvertOperation(dragDropData, ConvertOperation.Operation.All);
				if (convert.CanPerform<Sound>())
				{
					// Accept drop
					e.Effect = e.AllowedEffect;

					UndoRedoManager.Do(new CreateSoundEmitterSourceAction(
						this.GetValue().Cast<SoundEmitter>(), 
						convert.Perform<Sound>().Select(s => new SoundEmitter.Source(s))));
				}
			}
		}
开发者ID:KSLcom,项目名称:duality,代码行数:22,代码来源:SoundEmitterPropertyEditor.cs

示例7: CanConvertFrom

 public override bool CanConvertFrom(ConvertOperation convert)
 {
     return
         convert.AllowedOperations.HasFlag(ConvertOperation.Operation.CreateObj) &&
         convert.CanPerform<Material>();
 }
开发者ID:ruzli,项目名称:duality,代码行数:6,代码来源:DynamicLightingPlugin.cs

示例8: objectView_DragDrop

        private void objectView_DragDrop(object sender, DragEventArgs e)
        {
            this.objectView.BeginUpdate();

            bool effectMove = (e.Effect & DragDropEffects.Move) != DragDropEffects.None;
            bool effectCopy = (e.Effect & DragDropEffects.Copy) != DragDropEffects.None;
            DataObject data = e.Data as DataObject;
            if (data != null)
            {
                ConvertOperation convertOp = new ConvertOperation(data, ConvertOperation.Operation.All);
                this.tempDropTarget = this.DragDropGetTargetNode();
                if (data.ContainsGameObjectRefs())
                {
                    this.tempDropData = data.GetGameObjectRefs();

                    // Display context menu if both moving and copying are availabled
                    if (effectMove && effectCopy)
                        this.contextMenuDragMoveCopy.Show(this, this.PointToClient(new Point(e.X, e.Y)));
                    else if (effectCopy)
                        this.copyHereToolStripMenuItem_Click(this, null);
                    else if (effectMove)
                        this.moveHereToolStripMenuItem_Click(this, null);
                }
                else if (data.ContainsComponentRefs())
                {
                    this.tempDropData = data.GetComponentRefs();

                    // Display context menu if both moving and copying are availabled
                    if (effectMove && effectCopy)
                        this.contextMenuDragMoveCopy.Show(this, this.PointToClient(new Point(e.X, e.Y)));
                    else if (effectCopy)
                        this.copyHereToolStripMenuItem_Click(this, null);
                    else if (effectMove)
                        this.moveHereToolStripMenuItem_Click(this, null);
                }
                else if (this.tempDropTarget != null && convertOp.CanPerform<Component>())
                {
                    GameObject dropObj = null;
                    if (this.tempDropTarget is GameObjectNode)
                        dropObj = (this.tempDropTarget as GameObjectNode).Obj;
                    else
                        dropObj = (this.tempDropTarget as ComponentNode).Component.GameObj;

                    var componentQuery = convertOp.Perform<Component>();
                    if (componentQuery != null)
                    {
                        // Create Components
                        CreateComponentAction createAction = new CreateComponentAction(dropObj, componentQuery.Where(c => c.GameObj == null));
                        UndoRedoManager.BeginMacro();
                        UndoRedoManager.Do(new DeleteComponentAction(componentQuery.Select(c => dropObj.GetComponent(c.GetType())).NotNull()));
                        UndoRedoManager.Do(createAction);
                        UndoRedoManager.EndMacro(UndoRedoManager.MacroDeriveName.FromLast);

                        bool selCleared = false;
                        foreach (Component newComponent in createAction.Result)
                        {
                            NodeBase dataNode = this.FindNode(newComponent);
                            if (dataNode == null) continue;
                            TreeNodeAdv viewNode = this.objectView.FindNode(this.objectModel.GetPath(dataNode));
                            if (viewNode == null) continue;
                            if (!selCleared)
                            {
                                this.objectView.ClearSelection();
                                selCleared = true;
                            }
                            viewNode.IsSelected = true;
                            this.objectView.EnsureVisible(viewNode);
                        }
                    }
                }
                else if (convertOp.CanPerform<GameObject>())
                {
                    GameObject dropObj = (this.tempDropTarget is GameObjectNode) ? (this.tempDropTarget as GameObjectNode).Obj : null;
                    var gameObjQuery = convertOp.Perform<GameObject>();
                    if (gameObjQuery != null)
                    {
                        CreateGameObjectAction action = new CreateGameObjectAction(dropObj, gameObjQuery);
                        UndoRedoManager.Do(action);

                        bool selCleared = false;
                        foreach (GameObject newObj in action.Result)
                        {
                            NodeBase dataNode = this.FindNode(newObj);
                            if (dataNode == null) continue;
                            TreeNodeAdv viewNode = this.objectView.FindNode(this.objectModel.GetPath(dataNode));
                            if (viewNode == null) continue;
                            if (!selCleared)
                            {
                                this.objectView.ClearSelection();
                                selCleared = true;
                            }
                            viewNode.IsSelected = true;
                            this.objectView.EnsureVisible(viewNode);
                        }
                    }
                }
            }

            this.objectView.EndUpdate();
        }
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:100,代码来源:SceneView.cs

示例9: OnKeyDown

        protected override void OnKeyDown(KeyEventArgs e)
        {
            if (e.KeyCode == Keys.C && e.Control)
            {
                DataObject data = new DataObject();
                data.SetBatchInfos(new[] { this.DisplayedValue as BatchInfo });
                Clipboard.SetDataObject(data);
                e.Handled = true;
            }
            else if (e.KeyCode == Keys.V && e.Control)
            {
                DataObject data = Clipboard.GetDataObject() as DataObject;
                ConvertOperation convert = new ConvertOperation(data, ConvertOperation.Operation.All);
                IEnumerable<BatchInfo> refQuery = null;
                if (convert.CanPerform<BatchInfo>() && (refQuery = convert.Perform<BatchInfo>()) != null)
                {
                    this.SetValue(refQuery.FirstOrDefault());
                    this.PerformGetValue();
                    this.OnEditingFinished(FinishReason.LeapValue);
                }
                else
                    System.Media.SystemSounds.Beep.Play();

                e.Handled = true;
            }
            base.OnKeyDown(e);
        }
开发者ID:hbcameleon,项目名称:duality,代码行数:27,代码来源:BatchInfoPropertyEditor.cs

示例10: CanConvertFrom

 public override bool CanConvertFrom(ConvertOperation convert)
 {
     return
         convert.AllowedOperations.HasFlag(ConvertOperation.Operation.CreateRes) &&
         convert.CanPerform<BatchInfo>();
 }
开发者ID:sinithwar,项目名称:duality,代码行数:6,代码来源:MaterialFromBatchInfo.cs

示例11: CanConvertFrom

 public override bool CanConvertFrom(ConvertOperation convert)
 {
     return
         convert.AllowedOperations.HasFlag(ConvertOperation.Operation.Convert) &&
         convert.CanPerform<Texture>();
 }
开发者ID:KSLcom,项目名称:duality,代码行数:6,代码来源:DataConverters.cs

示例12: DeserializeFromData

 protected override void DeserializeFromData(DataObject data)
 {
     ConvertOperation convert = new ConvertOperation(data, ConvertOperation.Operation.All);
     if (convert.CanPerform(this.editedResType))
     {
         var refQuery = convert.Perform(this.editedResType);
         if (refQuery != null)
         {
             Resource[] refArray = refQuery.Cast<Resource>().ToArray();
             this.contentPath = (refArray != null && refArray.Length > 0) ? refArray[0].Path : null;
             this.PerformSetValue();
             this.PerformGetValue();
             this.OnEditingFinished(FinishReason.LeapValue);
         }
     }
 }
开发者ID:SirePi,项目名称:duality,代码行数:16,代码来源:IContentRefPropertyEditor.cs

示例13: GetPreviewHash

        protected override int GetPreviewHash()
        {
            if (this.contentPath == null) return 0;

            IContentRef contentRef = new ContentRef<Resource>(null, this.contentPath);
            if (!contentRef.IsAvailable) return 0;

            ConvertOperation convOp = new ConvertOperation(new[] { contentRef.Res }, ConvertOperation.Operation.Convert);
            if (convOp.CanPerform<Pixmap>())
            {
                Pixmap basePx = convOp.Perform<Pixmap>().FirstOrDefault();
                PixelData basePxLayer = basePx != null ? basePx.MainLayer : null;
                return basePxLayer != null ? basePxLayer.GetHashCode() : 0;
            }
            else if (convOp.CanPerform<AudioData>())
            {
                AudioData audioData = convOp.Perform<AudioData>().FirstOrDefault();
                return (audioData != null && audioData.OggVorbisData != null) ? audioData.OggVorbisData.GetHashCode() : 0;
            }

            return this.contentPath.GetHashCode();
        }
开发者ID:SirePi,项目名称:duality,代码行数:22,代码来源:IContentRefPropertyEditor.cs

示例14: DeserializeFromData

 protected override void DeserializeFromData(DataObject data)
 {
     ConvertOperation convert = new ConvertOperation(data, ConvertOperation.Operation.All);
     if (convert.CanPerform(this.editedResType))
     {
         var refQuery = convert.Perform(this.editedResType);
         if (refQuery != null)
         {
             Resource[] refArray = refQuery.Cast<Resource>().ToArray();
             UpdateContentPath((refArray != null && refArray.Length > 0) ? refArray[0].Path : null);
         }
     }
 }
开发者ID:BraveSirAndrew,项目名称:duality,代码行数:13,代码来源:IContentRefPropertyEditor.cs


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