コード例 #1
0
        private void ProfileTaskList_Drop(object sender, DragEventArgs e)
        {
            if (MainWindow.Instance.AccountGrid.SelectedItem != null)
            {
                CharacterProfile profile      = (CharacterProfile)MainWindow.Instance.AccountGrid.SelectedItem;
                DataObject       dObj         = (DataObject)e.Data;
                BMTask           task         = null;
                bool             removeSource = false;
                // drop originated from the left side 'TaskList'
                if (dObj.GetDataPresent("PersistentObject"))
                {
                    Type taskType = (Type)dObj.GetData("PersistentObject");
                    task = (BMTask)Activator.CreateInstance(taskType);
                    task.SetProfile(profile);
                }
                else if (sender == ProfileTaskList)// drop originated from itself.
                {
                    task         = (BMTask)dObj.GetData(dObj.GetFormats().FirstOrDefault());
                    removeSource = true;
                }
                if (task == null)
                {
                    return;
                }
                ListBoxItem targetItem = FindParent <ListBoxItem>((DependencyObject)e.OriginalSource);

                if (targetItem != null)
                {
                    BMTask targetTask = (BMTask)targetItem.Content;
                    for (int i = ProfileTaskList.Items.Count - 1; i >= 0; i--)
                    {
                        if (ProfileTaskList.Items[i].Equals(targetTask))
                        {
                            if (removeSource)
                            {
                                profile.Tasks.Remove(task);
                            }
                            profile.Tasks.Insert(i, task);
                            break;
                        }
                    }
                }
                else if (!removeSource)
                {
                    profile.Tasks.Add(task);
                }
                _isDragging = false;
                e.Handled   = true;
            }
        }
コード例 #2
0
ファイル: DataObjectTest.cs プロジェクト: dfr0/moon
		public void Defaults ()
		{
			DataObject dobj = new DataObject ();

			Assert.Throws<SecurityException> (() => dobj.GetFormats (), "GetFormats ()");
			Assert.Throws<SecurityException> (() => dobj.GetFormats (true), "GetFormats (true)");
			Assert.Throws<SecurityException> (() => dobj.GetFormats (false), "GetFormats (false)");

			Assert.Throws<SecurityException> (() => dobj.GetData (DataFormats.FileDrop), "GetData (string)");
			Assert.Throws<SecurityException> (() => dobj.GetData (DataFormats.FileDrop, true), "GetData (string,true)");
			Assert.Throws<SecurityException> (() => dobj.GetData (DataFormats.FileDrop, false), "GetData (string,false)");
			Assert.Throws<SecurityException> (() => dobj.GetData (typeof(string)), "GetData (Type)");

			Assert.Throws<SecurityException> (() => dobj.GetDataPresent (DataFormats.FileDrop), "GetDataPresent (string)");
			Assert.Throws<SecurityException> (() => dobj.GetDataPresent (DataFormats.FileDrop, true), "GetDataPresent (string,true)");
			Assert.Throws<SecurityException> (() => dobj.GetDataPresent (DataFormats.FileDrop, false), "GetDataPresent (string,false)");
			Assert.Throws<SecurityException> (() => dobj.GetDataPresent (typeof (string)), "GetDataPresent (Type)");

			Assert.Throws<SecurityException> (() => dobj.SetData (DataFormats.FileDrop), "SetData (string)");
			Assert.Throws<SecurityException> (() => dobj.SetData (DataFormats.FileDrop, true), "SetData (string,true)");
			Assert.Throws<SecurityException> (() => dobj.SetData (DataFormats.FileDrop, false), "SetData (string,false)");
			Assert.Throws<SecurityException> (() => dobj.SetData (typeof (string)), "SetData (Type)");
		}
コード例 #3
0
ファイル: MainWindow.xaml.cs プロジェクト: ychost/uest-pcs
 private void cvs1Drop(object sender, DragEventArgs e) {
     IDataObject data = new DataObject();
     data = e.Data;
     if (data.GetDataPresent(typeof(Rectangle))) {
         Rectangle rect = new Rectangle();
         rect = data.GetData(typeof(Rectangle)) as Rectangle;
         //canvas2.Children.Remove(rect);
         //canvas2.Children.Add(rect);
         string rectXaml = XamlWriter.Save(rect);
         StringReader stringReader = new StringReader(rectXaml);
         XmlReader xmlReader = XmlReader.Create(stringReader);
         UIElement clonedChild = (UIElement)XamlReader.Load(xmlReader);
         canvas1.Children.Add(clonedChild);
     }
 }
コード例 #4
0
        void TextEditor_Drop(object sender, DragEventArgs e)
        {
            Point pos = e.GetPosition(sender as IInputElement);

            System.Windows.DataObject o = e.Data as System.Windows.DataObject;
            string[] formats            = o.GetFormats();
            string   SAMPLE_FORMAT      = "DXUnionPacket.ViewModel.Sample";
            string   MSI_INSTALL_FORMAT = "DXInstaller.MSIInstaller";
            string   GONG_DD_FORMAT     = "GongSolutions.Wpf.DragDrop.DropInfo";
            string   text = "";

            foreach (string format in formats)
            {
                if (format.Equals(SAMPLE_FORMAT))
                {
                    if (o.GetDataPresent(SAMPLE_FORMAT))
                    {
                        lock (sync){
                            Object oo = o.GetData(SAMPLE_FORMAT);
                            Sample s  = o.GetData(SAMPLE_FORMAT, true) as Sample;
                            text = s.Text;
                            break;
                        }
                    }
                }
                if (format.Equals(MSI_INSTALL_FORMAT))
                {
                    MSIInstaller i = o.GetData(MSI_INSTALL_FORMAT) as MSIInstaller;
                    text = i.Guid;
                    break;
                }
            }
            if (!String.IsNullOrEmpty(text))
            {
                InsertText(text, pos);
            }
        }
コード例 #5
0
 public void SequenceDesignerViewModel_SetModelItemForServiceTypes_DataHaveDataContextNotResourceModel_NothingAddedToDataObject()
 {
     //------------Setup for test--------------------------
     var dsfSequenceActivity = new DsfSequenceActivity();
     var dsfMultiAssignActivity = new DsfMultiAssignActivity();
     dsfSequenceActivity.Activities.Add(dsfMultiAssignActivity);
     var sequenceDesignerViewModel = new SequenceDesignerViewModel(CreateModelItem(dsfSequenceActivity));
     var dataObject = new DataObject(GlobalConstants.ExplorerItemModelFormat, new TestDataWithContext());
     //------------Execute Test---------------------------
     sequenceDesignerViewModel.SetModelItemForServiceTypes(dataObject);
     //------------Assert Results-------------------------
     bool dataPresent = dataObject.GetDataPresent(DragDropHelper.ModelItemDataFormat);
     Assert.IsFalse(dataPresent);
 }
コード例 #6
0
 public void SequenceDesignerViewModel_SetModelItemForServiceTypes_Data_NothingAddedToDataObject()
 {
     //------------Setup for test--------------------------
     var dsfSequenceActivity = new DsfSequenceActivity();
     var dsfMultiAssignActivity = new DsfMultiAssignActivity();
     dsfSequenceActivity.Activities.Add(dsfMultiAssignActivity);
     var sequenceDesignerViewModel = new SequenceDesignerViewModel(CreateModelItem(dsfSequenceActivity));
     var dataObject = new DataObject("Some Wrong Format", new object());
     //------------Execute Test---------------------------
     sequenceDesignerViewModel.SetModelItemForServiceTypes(dataObject);
     //------------Assert Results-------------------------
     bool dataPresent = dataObject.GetDataPresent(DragDropHelper.ModelItemDataFormat);
     Assert.IsFalse(dataPresent);
 }
コード例 #7
0
        private static FrameworkName GetTargetFrameworkFromClipboard(DataObject dataObject)
        {
            Fx.Assert(dataObject != null, "dataObject should not be null");

            FrameworkName clipboardFrameworkName = null;
            if (dataObject.GetDataPresent(WorkflowClipboardFormat_TargetFramework))
            {
                clipboardFrameworkName = TryGetData(dataObject, WorkflowClipboardFormat_TargetFramework) as FrameworkName;
            }

            if (clipboardFrameworkName == null)
            {
                clipboardFrameworkName = FrameworkNameConstants.NetFramework40;
            }

            return clipboardFrameworkName;
        }