Example #1
0
 private void ActionHolder_DragEnter(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(typeof(ActionHolder)))
     {
         e.Effect = DragDropEffects.Move | DragDropEffects.Copy | DragDropEffects.Scroll;
     }
 }
 private void Form1_DragDrop(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(DataFormats.FileDrop))
     {
         string[] filePaths = (string[])(e.Data.GetData(DataFormats.FileDrop));
         foreach (string fileLoc in filePaths)
         {
             // Code to read the contents of the text file
             if (File.Exists(fileLoc))
             {
                 this.reportFileName = fileLoc;
                 try
                 {
                     report = dem.ReadReport(reportFileName);
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show("Invalid Report File: \n" + ex.Message);
                 }
                 labelDataExportProfileName.Text = report.DataExportProfileName;
                 labelExportCompleted.Text = (report.DataExportCompleted) ? "Yes" : "No";
                 labelExportStartedAt.Text = report.DataExportStartedAt;
                 labelExportFinishedAt.Text = report.DataExportFinishedAt;
                 labelExportedIn.Text = report.DataExportedIn;
                 labelExportedRecords.Text = report.TotalExportedRecords.ToString();
             }
         }
     }
 }
Example #3
0
		protected override void OnDragDrop(DragEventArgs e)
		{
			OnDragOver(e);
			if (e.Effect == DragDropEffects.None) return;
			Item item = (Item)e.Data.GetData(typeof(Item));
			if (e.Effect == DragDropEffects.Link) {
				if (Item == null) {
					Item = new Item(item.ID, (byte)(item.Count/2), Slot, item.Damage);
					item.Count -= Item.Count;
				} else {
					byte count = Item.Count;
					Item.Count = Math.Min((byte)(count+item.Count/2), (byte)64);
					item.Count -= (byte)(Item.Count-count);
				}
			} else if (e.Effect == DragDropEffects.Move && Item != null && item.ID == Item.ID && Item.Damage == item.Damage) {
				byte count = (byte)Math.Min((int)Item.Count + item.Count, item.Stack);
				byte over = (byte)Math.Max((int)Item.Count + item.Count - item.Stack, 0);
				Item = new Item(Item.ID, count, Slot, Item.Damage);
				other = (over>0) ? new Item(Item.ID, over) : null;
			} else {
				other = Item; Item = item;
				if (e.Effect == DragDropEffects.Copy)
					Item = new Item(Item.ID, Item.Count, Slot, Item.Damage);
				else Item.Slot = Slot;
			}
			LostFocus += OnLostFocus;
			Select();
		}
Example #4
0
        private void flowLayoutPanel1_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {

                // ドラッグ中のファイルやディレクトリの取得
                string[] drags = (string[])e.Data.GetData(DataFormats.FileDrop);

                foreach (string d in drags)
                {
                    if (System.IO.File.Exists(d))
                    {
                        e.Effect = DragDropEffects.Copy;
                    }
                    else if (System.IO.Directory.Exists(d))
                    {
                        e.Effect = DragDropEffects.Copy;
                    }
                }
            }
            else if(e.Data.GetDataPresent(DataFormats.Text))
            {
                // ドラッグ中のファイルやディレクトリの取得
                string link = (string)e.Data.GetData(DataFormats.Text);
                e.Effect = DragDropEffects.Copy;
            }
        }
        public static string ProcessDataObject(DragEventArgs e) {
            // If the dropped object is from ArcCatalog then export the geodatabase
            // to XML and return pathname.
            if (e.Data.GetDataPresent("ESRI Names")) {
                return GeodatabaseUtility.ExportXml(e);
            }

            // If a use dropped one or more files then get first file and verify that it
            // has a "xml" or "diagram" extension.
            if (e.Data.GetDataPresent(DataFormats.FileDrop)) {
                object drop = e.Data.GetData(DataFormats.FileDrop);
                if (drop == null) { return null; }

                string[] files = drop as string[];
                if (files == null) { return null; }
                if (files.Length != 1) { return null; }

                string file = files[0];
                string extension = System.IO.Path.GetExtension(file);
                switch (extension.ToUpper()) {
                    case ".XML":
                    case ".DIAGRAM":
                        return file;
                    default:
                        return null;
                }
            }

            // Invalid DataObject. Return Null.
            return null;
        }
Example #6
0
		private void DragDrop(object sender, DragEventArgs e)
		{
			try
			{
				foreach (Type CurrentType in AcceptTypes)
				{
					if (e.Data.GetDataPresent(CurrentType.FullName))
					{
						if (CurrentType.IsArray)
						{
							object[] objs = (object[])(e.Data.GetData(CurrentType.FullName));
							foreach (object obj in objs)
								AcceptContents(obj);
						}
						else
							AcceptContents(e.Data.GetData(CurrentType.FullName));

						e.Effect = DragDropEffects.Link;
					}
				}
			}
			catch (Exception ex)
			{
				Trace.WriteLine(ex);
				Debug.Assert(false, ex.ToString());
				throw;
			}
		}
        public static string ExportXml(DragEventArgs e) {
            // Get dropped object
            if (!e.Data.GetDataPresent("ESRI Names")) { return null; }
            object drop = e.Data.GetData("ESRI Names");

            // Convert to byte array
            MemoryStream memoryStream = (MemoryStream)drop;
            byte[] bytes = memoryStream.ToArray();
            object byteArray = (object)bytes;

            // Get First WorkpaceName
            INameFactory nameFactory = new NameFactoryClass();
            IEnumName enumName = nameFactory.UnpackageNames(ref byteArray);
            IName name = enumName.Next();
            IWorkspaceName workspaceName = name as IWorkspaceName;
            if (workspaceName != null){
                return GeodatabaseUtility.ExportWorkspaceXml(workspaceName);
            };

            MessageBox.Show(
                Resources.TEXT_DROPPED_OBJECT_NOT_VALID_GEODATABASE,
                Resources.TEXT_APPLICATION,
                MessageBoxButtons.OK,
                MessageBoxIcon.Error,
                MessageBoxDefaultButton.Button1,
                MessageBoxOptions.DefaultDesktopOnly);
            return null;
        }
Example #8
0
 private void frm_DragDrop(object sender, DragEventArgs e)
 {
     Array a = (Array)e.Data.GetData(DataFormats.FileDrop);
     if (a != null)
     {
         string s = a.GetValue(0).ToString();
         bool isDirectory = Directory.Exists(s);
         if (isDirectory)
         {
             _directory = s;
         }
         bool isFile = File.Exists(s);
         if (isFile)
         {
             string filepart = s.Substring(s.LastIndexOf("\\") + 1);
             string pattern = patternMacro(filepart);
             txtPattern.Text = pattern;
             txtNewName.Text = filepart;
             _directory = s.Substring(0, s.LastIndexOf("\\"));
         }
         if (!isDirectory && !isFile)
         {
             // Something odd, just ignore
         }
         this.Activate();	// in the case Explorer overlaps this form
     }
     RefreshGrid();
 }
Example #9
0
 /// <summary>
 /// Checks what operations are available for dragging onto the target with the drag files.
 /// </summary>
 /// <param name="dragEventArgs">The <see cref="System.Windows.Forms.DragEventArgs"/> instance containing the event data.</param>
 protected override void DragEnter(DragEventArgs dragEventArgs)
 {
     //  Check the drag files - if they're all XML, we can validate them against the XSD.
     dragEventArgs.Effect =
         DragItems.All(di => string.Compare(Path.GetExtension(di), ".xml", StringComparison.InvariantCultureIgnoreCase) == 0)
             ? DragDropEffects.Link : DragDropEffects.None;
 }
Example #10
0
 void control_DragEnter(object sender, DragEventArgs e)
 {
     Debug.WriteLine("c");
     if (e.Data.GetDataPresent(DataFormats.FileDrop))
         e.Effect = DragDropEffects.Link;
     else e.Effect = DragDropEffects.None;
 }
Example #11
0
		private void lblMagicDragArea_DragDrop(object sender, DragEventArgs e)
		{
			List<string> files = validateDrop(e.Data);
			if (files.Count == 0) return;
			try
			{
				foreach (var file in files)
				{
					var prefs = GetCuePrefs();
					string ext = Path.GetExtension(file).ToUpper();
					Disc disc = null;
					if (ext == ".ISO")
						disc = Disc.FromIsoPath(file);
					else if(ext == ".CUE")
						disc = Disc.FromCuePath(file, prefs);
					string baseName = Path.GetFileNameWithoutExtension(file);
					baseName += "_hawked";
					prefs.ReallyDumpBin = true;
					var cueBin = disc.DumpCueBin(baseName, GetCuePrefs());
					Dump(cueBin, Path.GetDirectoryName(file), prefs);
				}
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.ToString(), "oops! error");
				throw;
			}
		}
Example #12
0
File: Form1.cs Project: viticm/pap2
 private void Form1_DragEnter(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(DataFormats.FileDrop))
         e.Effect = DragDropEffects.Copy;
     else
         e.Effect = DragDropEffects.None; 
 }
Example #13
0
        private void lvReadingQueue_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof (Book)))
            {
                var book = (Book) e.Data.GetData(typeof (Book));

                // if is already in reading queue, do not add it again
                foreach (ListViewItem existingItem in lvReadingQueue.Items)
                {
                    if (((Book) existingItem.Tag).Id == book.Id)
                        return;
                }

                var insertIndex = lvReadingQueue.Items.Count;

                Point cp = lvReadingQueue.PointToClient(new Point(e.X, e.Y));
                ListViewItem dragToItem = lvReadingQueue.GetItemAt(cp.X, cp.Y);
                if (dragToItem != null)
                {
                    insertIndex = dragToItem.Index;
                }

                var item = new ListViewItem(book.Title);
                item.Tag = book;

                lvReadingQueue.Items.Insert(insertIndex, item);

                applicationService.QueueForReading(book.Id, insertIndex);
            }
        }
 private void DragDropFile_DragEnter(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(DataFormats.FileDrop))
     {
         e.Effect = DragDropEffects.Copy;
     }
 }
Example #15
0
 private void button1_DragEnter(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(DataFormats.Text))
         e.Effect = DragDropEffects.Copy;
     else
         e.Effect = DragDropEffects.Copy;
 }
        private void lstVw_DragDrop(object sender, DragEventArgs e)
        {
            if (readOnlyMode) return;

            string s = (string)e.Data.GetData(DataFormats.Html);
            List<string> urls = new List<string>();

            string sourceUrl = GetSourceURL(s);
            if (sourceUrl != null)
            {
                WebBrowser wb = new WebBrowser();
                wb.DocumentText = s;
                do { Application.DoEvents(); } while (wb.ReadyState != WebBrowserReadyState.Complete);
                urls.AddRange(ExtractUrls(wb.Document.Links, "href", sourceUrl));
                urls.AddRange(ExtractUrls(wb.Document.Images, "src", sourceUrl));
                wb.Dispose();
            }

            var items = new List<ListViewItem>();
            items.AddRange(urls.Select(url => CreateNewItem(url)));
            populateItems(items);

            if (urls.Count > 0)
                this.OnAttachedFileDeleted(e);

            updateToolBarButtons();
        }
Example #17
0
 private void listView1_DragDrop(object sender, DragEventArgs e)
 {
     ListViewItem lvi = new ListViewItem();
     lvi.Text = (String)e.Data.GetData(DataFormats.Text);
     lvi.SubItems.Add("pepe");
     listView1.Items.Add(lvi);
 }
Example #18
0
        protected override void OnDragDrop(DragEventArgs drgevent) {
            if (drgevent.Data.GetDataPresent(DataFormats.FileDrop)) {
                string[] filelist = (string[])drgevent.Data.GetData(DataFormats.FileDrop, false);
                if (filelist.Length != 1) {
                    MessageBox.Show(
                        "アイテムは1つだけドロップしてください。",
                        Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                string path = filelist[0];

                if (_mode == FileBrowseStyle.Directory && !Directory.Exists(path)) {
                    MessageBox.Show(
                        "ファイルではなくフォルダをドロップしてください。",
                        Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else if (_mode != FileBrowseStyle.Directory && Directory.Exists(path)) {
                    MessageBox.Show(
                        "フォルダではなくファイルをドロップしてください。",
                        Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                pathComboBox.Text = path;
            }
        }
Example #19
0
 void MainFormDragOver(object sender, DragEventArgs e)
 {
     //permitir el arraster sobre la forma
     if (e.Data.GetDataPresent(DataFormats.FileDrop)){
         e.Effect = DragDropEffects.Copy;
     }
 }
Example #20
0
        private void frmMain_DragOverOrEnter(object sender, DragEventArgs e)
        {
            e.Effect = DragDropEffects.None;

            if (ImageCollection.IsAvailable(e))
            {
                bool allow = true;

                if (e.Data.GetDataPresent(DataFormats.FileDrop))
                {
                    string[] paths = (string[])e.Data.GetData(DataFormats.FileDrop);

                    allow = false;
                    for (int i = 0; i < paths.Length; ++i)
                    {
                        if (TiXMain.CheckFile(paths[i]))
                        {
                            allow = true;
                            break;
                        }
                    }
                }

                if (allow)
                    e.Effect = DragDropEffects.Move;
            }
        }
Example #21
0
 void lbDrop_DragEnter(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(DataFormats.FileDrop))
         e.Effect = DragDropEffects.All;
     else
         e.Effect = DragDropEffects.None;
 }
        protected override void OnDragOver(DragEventArgs e)
        {
            base.OnDragOver(e);

            if (IsOurDrag(e.Data))
                e.Effect = (e.KeyState == 9) ? DragDropEffects.Copy : DragDropEffects.Move;
            else if (IsFileDrop(e.Data))
                e.Effect = DragDropEffects.Copy;
            else
                return;

            TreeNode node = base.GetNodeAt(PointToClient(new Point(e.X,e.Y)));
            node = ChangeDropTarget(node);

            if (node != null)
            {
                if (!base.SelectedNodes.Contains(node))
                    HighlightTarget(node);
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }

            DragScroll(e);
        }
Example #23
0
 private void TextBox1DragDrop(object sender, DragEventArgs e)
 {
     try
     {
         Array array = (Array)e.Data.GetData(DataFormats.FileDrop);
         if (array != null)
         {
             string text = array.GetValue(0).ToString();
             int num = text.LastIndexOf(".", StringComparison.Ordinal);
             if (num != -1)
             {
                 string text2 = text.Substring(num);
                 text2 = text2.ToLower();
                 if (text2 == ".exe" || text2 == ".dll")
                 {
                     Activate();
                     textBox1.Text = text;
                     int num2 = text.LastIndexOf("\\", StringComparison.Ordinal);
                     if (num2 != -1)
                     {
                         DirectoryName = text.Remove(num2, text.Length - num2);
                     }
                     if (DirectoryName.Length == 2)
                     {
                         DirectoryName += "\\";
                     }
                 }
             }
         }
     }
     catch
     {
     }
 }
        protected override void OnDragDrop(DragEventArgs e)
        {
            if (IsOurDrag(e.Data))
            {
                ArrayList draggedNodes = (ArrayList)e.Data.GetData(typeof(ArrayList));
                TreeNode targetNode = base.GetNodeAt(PointToClient(new Point(e.X,e.Y)));
                targetNode = ChangeDropTarget(targetNode);

                if (draggedNodes != null && targetNode != null)
                    DragNodes(draggedNodes,targetNode,e.Effect);
            }
            else if (IsFileDrop(e.Data))
            {
                TreeNode targetNode = base.GetNodeAt(PointToClient(new Point(e.X,e.Y)));
                targetNode = ChangeDropTarget(targetNode);

                if (targetNode == null) return;
                
                // the data is in the form of an array of paths
                Array aFiledrop = (Array)e.Data.GetData(DataFormats.FileDrop);

                // make a string array
                string[] paths = new string[aFiledrop.Length];
                for (int i=0; i<paths.Length; i++)
                    paths[i] = aFiledrop.GetValue(i) as string;

                // queue the copy/move operation so we don't hang this thread and block the calling app
                BeginInvoke(new OnFileDropHandler(OnFileDrop),new object[]{paths,targetNode});

                // somehow querycontinuedrag doesn't work in this case
                UnhighlightTarget();
            }
            else base.OnDragDrop(e);
        }
        private void dataGridView1_DragDrop(object sender, DragEventArgs e)
        {
            try
            {
                // The mouse locations are relative to the screen, so they must be
                // converted to client coordinates.
                var clientPoint = dataGridView1.PointToClient(new Point(e.X, e.Y));

                // Get the row index of the item the mouse is below.
                rowIndexOfItemUnderMouseToDrop = dataGridView1.HitTest(clientPoint.X, clientPoint.Y).RowIndex;

                // If the drag operation was a move then remove and insert the row.
                if (e.Effect == DragDropEffects.Move)
                {
                    //var rowToMove2 = e.Data.GetData(typeof(DataGridViewRow)) as DataGridViewRow;
                    var rowToMove = dtDataControl.Rows[rowIndexFromMouseDown];
                    var row = dtDataControl.NewRow();
                    for (int i = 0; i < dtDataControl.Columns.Count; i++)
                        row[i] = rowToMove[i];

                    dtDataControl.Rows.RemoveAt(rowIndexFromMouseDown);
                    dtDataControl.Rows.InsertAt(row, rowIndexOfItemUnderMouseToDrop);
                    dataGridView1.CurrentCell = dataGridView1[1, rowIndexOfItemUnderMouseToDrop];
                    dtDataControl.AcceptChanges();
                    Console.WriteLine("OK");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Example #26
0
 private void BostList_DragEnter(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(typeof(string)))
         e.Effect = DragDropEffects.Copy;
     else
         e.Effect = DragDropEffects.None;
 }
Example #27
0
        private void pAppList_DragDrop(object sender, DragEventArgs e)
        {
            try
            {
                Array aryFiles = ((Array)e.Data.GetData(DataFormats.FileDrop));
                for (int i = 0; i < aryFiles.Length; i++)
                {
                    if (File.Exists(aryFiles.GetValue(i).ToString()))
                    {
                        string dest = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "api",
                            Path.GetFileName(aryFiles.GetValue(i).ToString()));
                        if (File.Exists(dest))
                        {
                            MessageBox.Show(string.Format("[{0}]文件已存在",aryFiles.GetValue(i).ToString()));
                            continue;
                        }
                        File.Copy(aryFiles.GetValue(i).ToString(),dest);
                    }

                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.ToString());
            }
        }
 private void btnTranslateTo_DragEnter(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(DataFormats.Text) && e.AllowedEffect == DragDropEffects.Move)
     {
         e.Effect = DragDropEffects.Move;
     }
 }
Example #29
0
        private void Form1_DragDrop(object sender, DragEventArgs e)
        {
            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop, false);
            int fileCount = files.Count();
            if( fileCount > 6 )
            {
                fileCount = 6;
            }
            Bitmap henseiBitmap = new Bitmap(488 * 2, 376 * 3, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            Graphics henseiGraphics = Graphics.FromImage(henseiBitmap);

            List<String> fl = LoadFilePath(files);
            fl.Sort();
            for (int i = 0; i < fileCount; i++)
            {
                Console.WriteLine(fl[i]);
                Bitmap orig = new Bitmap(fl[i].ToString());
                Bitmap copy = orig.Clone(new Rectangle(312, 94, 488, 376), orig.PixelFormat);
                henseiGraphics.DrawImage(copy, henseiPosition[i, 0], henseiPosition[i, 1], copy.Width, copy.Height);
                orig.Dispose();

            }
            henseiGraphics.Dispose();
            String outPath = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "hensei.png");
            henseiBitmap.Save(outPath);
            System.Diagnostics.Process p = System.Diagnostics.Process.Start(outPath);
        }
Example #30
0
		private void DragOver(object sender, DragEventArgs e)
		{
			e.Effect = DragDropEffects.None;
			foreach (Type CurrentType in AcceptTypes)
			{
				if (e.Data.GetDataPresent(CurrentType.FullName))
				{
					bool Cancel = false;
					if (CurrentType.IsArray)
					{
						object[] objs = (object[])(e.Data.GetData(CurrentType.FullName));
						foreach (object obj in objs)
						{
							VerifyContents(obj, ref Cancel);
							if (Cancel)
								break;
						}
					}
					else
						VerifyContents(e.Data.GetData(CurrentType.FullName), ref Cancel);

					if (! Cancel)
						e.Effect = DragDropEffects.Link;
				}
			}
		}
        //Getting Objects from the clipboard
        private void DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            TxDragAndDropClipboardServices clipboardServices = new TxDragAndDropClipboardServices();

            // verify that the data has the right format:
            if (e.Data.GetDataPresent(clipboardServices.Format))
            {
                // get the ClipboardData:
                ITxClipboardData clipboardData;
                clipboardServices.CopyFromDataObject(e.Data, out clipboardData);
                TxClipboardData cData = clipboardData as TxClipboardData;
                // the objects list is inside the clipboard data
            }
        }
Example #32
0
        private void dataGridTable_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            string[] theFiles = (string[])e.Data.GetData(System.Windows.Forms.DataFormats.FileDrop);
            //(we only use the first one... one table at a time ppl!)
            string theDataFile  = theFiles[0];
            var    tableDataSet = new DataSet();

            if (tblFileOperations.LoadByteDataIntoView(LoadAndDecodeFile(theDataFile)))
            {
                SetDataGridTableView(tblFileOperations.TableDataSet);
                this.Text            = WindowTitle + " - " + theDataFile;
                currentTableFileName = theDataFile;
            }
        }
Example #33
0
        private void OnDragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            Array a = (Array)e.Data.GetData(DataFormats.FileDrop);

            if (a != null)
            {
                if (FileDroppedEvent != null)
                {
                    FileDroppedEvent.BeginInvoke(this, new FileDroppedEventArgs(a), null, null);

                    frmOwner.Activate();
                }
            }
        }
Example #34
0
        private void WinMD5Form_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                // Assign the file names to a string array, in
                // case the user has selected multiple files.
                string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);

                foreach (string file in files)
                {
                    Enqueue(new QueueItem(file, JustTheFileName(file)));
                }
            }
        }
Example #35
0
 /// <summary>
 /// Form's Drag Drop event handler
 /// </summary>
 /// <param name="sender">Sending object</param>
 /// <param name="e">Drag event arguments</param>
 private void MainForm_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
 {
     if (e.Data.GetDataPresent(DataFormats.FileDrop))
     {
         string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
         foreach (string file in files)
         {
             if (File.Exists(file))
             {
                 this.OpenDiskView(file);
             }
         }
     }
 }
Example #36
0
 public void treeViewRepo_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
 {
     //See if there is a TreeNode being dragged
     if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", true))
     {
         //TreeNode found allow move effect
         e.Effect = DragDropEffects.Move;
     }
     else
     {
         //No TreeNode found, prevent move
         e.Effect = DragDropEffects.None;
     }
 }
        void buttonDragDropHandle_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(ConsultNoteControl)))
            {
                ConsultNoteControl theCNC = (ConsultNoteControl)e.Data.GetData(typeof(ConsultNoteControl));
                System.Diagnostics.Debug.Assert((sender is Button) && (sender == buttonDragDropHandle) && (theCNC.ParentControl != null) && (theCNC.ParentControl is ConsultNotesControl));
                ConsultNoteDataConverter theMovingCNDC = theCNC._myCNDC;
                theCNC._myCollection.Remove(theMovingCNDC);
                _theCNsDC.Insert(0, theMovingCNDC);

                StoryEditor theSE = (StoryEditor)FindForm();
                theSE.ReInitConsultNotesPane(_theCNsDC);
            }
        }
        private void TestSuiteTreeView_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            if (IsValidFileDrop(e.Data))
            {
                //string[] fileNames = (string[])e.Data.GetData( DataFormats.FileDrop );
                //if ( fileNames.Length == 1 )
                //	loader.LoadProject( fileNames[0] );
                //else
                //	loader.LoadProject( fileNames );

                //if (loader.IsProjectLoaded && loader.TestProject.IsLoadable)
                //	loader.LoadTest();
            }
        }
Example #39
0
 private void AshtakavargaControl_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
 {
     if (e.Data.GetDataPresent(typeof(mhora.DivisionalChart)))
     {
         Division div = Division.CopyFromClipboard();
         if (null == div)
         {
             return;
         }
         this.userOptions.VargaType = div;
         this.SetOptions(this.userOptions);
         this.OnRecalculate(h);
     }
 }
Example #40
0
        private void listView2_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            String text = (String)e.Data.GetData("".GetType());

            if (text.Equals("files"))
            {
                incs.CopySelections(files, e);
                files.RemoveSelections();
            }
            else if (text.Equals("incs"))
            {
                incs.MoveSelections(e);
            }
        }
Example #41
0
        /// <summary>
        /// Somebody dropped something on our listview - perform the action
        /// </summary>
        private void listView1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            // Can only drop files, so check
            if (!e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                return;
            }

            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
            foreach (string file in files)
            {
                string dest     = homeFolder + "\\" + Path.GetFileName(file);
                bool   isFolder = Directory.Exists(file);
                bool   isFile   = File.Exists(file);
                if (!isFolder && !isFile)                                               // Ignore if it doesn't exist
                {
                    continue;
                }

                try
                {
                    switch (e.Effect)
                    {
                    case DragDropEffects.Copy:
                        if (isFile)                                                                     // TODO: Need to handle folders
                        {
                            File.Copy(file, dest, false);
                        }
                        break;

                    case DragDropEffects.Move:
                        if (isFile)
                        {
                            File.Move(file, dest);
                        }
                        break;

                    case DragDropEffects.Link:                                          // TODO: Need to handle links
                        break;
                    }
                }
                catch (IOException ex)
                {
                    MessageBox.Show(this, "Failed to perform the specified operation:\n\n" + ex.Message, "File operation failed", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
            }

            RefreshView();
        }
Example #42
0
        private void OnDragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            //Event handler for dropping onto the listview
            try {
                DataObject data = (DataObject)e.Data;
                if (data.GetDataPresent(DataFormats.FileDrop))
                {
                    //Local file
                    string[] names = (string[])data.GetData(DataFormats.FileDrop);
                    if (names.Length > 0)
                    {
                        //Save attachment
                        long             id         = Convert.ToInt64(this.lsvActions.SelectedItems[0].Name);
                        Issue.Action     action     = this.mIssue.Item(id);
                        Issue.Attachment attachment = action.Item(0);
                        attachment.Filename = names[0];
                        attachment.Save();
                    }
                }
                else if (data.GetDataPresent("FileGroupDescriptor"))
                {
                    //Outlook attachment
                    //Set the position within the current stream to the beginning of the file name
                    //return the file name in the fileName variable
                    System.IO.MemoryStream stream = (System.IO.MemoryStream)data.GetData("FileGroupDescriptor");
                    stream.Seek(76, System.IO.SeekOrigin.Begin);
                    byte[] fileName = new byte[256];
                    stream.Read(fileName, 0, 256);
                    System.Text.Encoding encoding = System.Text.Encoding.ASCII;
                    string name = encoding.GetString(fileName);
                    name = name.TrimEnd('\0');

                    //Write the file content to a file under the same path of the exe file.
                    stream = (System.IO.MemoryStream)e.Data.GetData("FileContents");
                    System.IO.FileStream fs = new System.IO.FileStream(name, System.IO.FileMode.Create);
                    stream.WriteTo(fs);
                    fs.Close();

                    //Save attachment
                    long             id         = Convert.ToInt64(this.lsvActions.SelectedItems[0].Name);
                    Issue.Action     action     = this.mIssue.Item(id);
                    Issue.Attachment attachment = action.Item(0);
                    attachment.Filename = name;
                    attachment.Save();
                }
            }
            catch (Exception ex) { reportError(ex); }
            finally { setUserServices(); }
        }
Example #43
0
        protected override void OnDragDrop(System.Windows.Forms.DragEventArgs e)
        {
            base.OnDragDrop(e);

            var pt         = PointToClient(new Point(e.X, e.Y));
            var hoveredTab = GetTabPage(pt);

            if (hoveredTab != null && e.Data.GetDataPresent(typeof(TabPage)))
            {
                e.Effect = DragDropEffects.Move;
                var draggedTab = (TabPage)e.Data.GetData(typeof(TabPage));

                var draggedTabIndex = FindIndex(draggedTab);
                var hoveredTabIndex = FindIndex(hoveredTab);

                if (draggedTabIndex != hoveredTabIndex)
                {
                    SuspendLayout();

                    /// Remove/Insertすると再描画されてしまう
                    if (draggedTabIndex < hoveredTabIndex)
                    {
                        for (int i = draggedTabIndex; i < hoveredTabIndex; ++i)
                        {
                            var tmp = TabPages[i];
                            TabPages[i]     = TabPages[i + 1];
                            TabPages[i + 1] = tmp;
                        }
                    }
                    else
                    {
                        for (int i = draggedTabIndex; i > hoveredTabIndex; --i)
                        {
                            var tmp = TabPages[i - 1];
                            TabPages[i - 1] = TabPages[i];
                            TabPages[i]     = tmp;
                        }
                    }

                    SelectedTab = draggedTab;

                    ResumeLayout();
                }
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }
        }
Example #44
0
        //***************************************************************************************************
        // richTextBox1_DragEnter - Custom Event. Drops the copied text being dragged onto the richTextBox  *
        //***************************************************************************************************
        private void richTextBox1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            // variables
            int    i;
            String s;

            // Get start position to drop the text.
            i = richTextBox1.SelectionStart;
            s = richTextBox1.Text.Substring(i);
            richTextBox1.Text = richTextBox1.Text.Substring(0, i);

            // Drop the text on to the RichTextBox.
            richTextBox1.Text += e.Data.GetData(DataFormats.Text).ToString();
            richTextBox1.Text += s;
        }
Example #45
0
        private void treeView1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.Text))
            {
                e.Effect = DragDropEffects.Move;
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }


            DragHelper.ImageList_DragEnter(this.treeView1.Handle, e.X - this.treeView1.Left,
                                           e.Y - this.treeView1.Top);
        }
 private void textEditorDragDrop(object sender, System.Windows.Forms.DragEventArgs e)
 {
     string[] file_name = e.Data.GetData(DataFormats.FileDrop) as string[];
     if (file_name != null && file_name.Length > 0)
     {
         if (string.Compare(System.IO.Path.GetExtension(file_name[0]), Constants.ProjectExtension, true) == 0)
         {
             WorkbenchServiceFactory.ProjectService.OpenProject(file_name[0]);
         }
         else
         {
             WorkbenchServiceFactory.FileService.OpenFile(file_name[0], null);
         }
     }
 }
Example #47
0
        void txtDocument_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            try
            {
                Image img = default(Image);
                img = Image.FromFile(((Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString());
                Clipboard.SetImage(img);

                this.txtDocument.SelectionStart = 0;
                this.txtDocument.Paste();
            }
            catch (Exception)
            {
            }
        }
Example #48
0
 private void listView1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
 {
     if (m_InternalDragDrop)
     {
         return;
     }
     if (e.Data.GetData(typeof(ButtonItem)) == null)
     {
         e.Effect = DragDropEffects.None;
     }
     else
     {
         e.Effect = DragDropEffects.Move;
     }
 }
Example #49
0
        protected override void OnDragDrop(System.Windows.Forms.DragEventArgs de)
        {
            tableControl.OnDesignerDragStop();
            //tableConrolDesignerDrag.OnDragStop();

            dragDropHandler.BeforeDragDrop();

            bool isDroppedFromToolbox = Utils.GetIsDroppedFromToolbox(this);

            tableControl.InDragDrop = true;
            base.OnDragDrop(de);
            tableControl.InDragDrop = false;

            dragDropHandler.AfterDragDrop(de, isDroppedFromToolbox);
        }
Example #50
0
        //
        private void label1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
        {
            TreeListNode node = GetDragNode(e.Data);

            if (node != null)
            {
                e.Effect          = DragDropEffects.Copy;
                Cursor            = Cursors.Hand;
                label1.ImageIndex = 1;
            }
            else
            {
                Cursor = Cursors.No;
            }
        }
Example #51
0
 private void MainForm_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
 {
     try
     {
         string[] FileList = (string[])e.Data.GetData(DataFormats.FileDrop, false);
         if (String.Equals(FileList[0].Substring(FileList[0].Length - 4), ".vcf", StringComparison.OrdinalIgnoreCase))
         {
             textBox1.Text = FileList[0];
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error: " + ex.Message);
     }
 }
Example #52
0
        private void grdMeta_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            GridControl grid = sender as GridControl;

            DataTable table = grid.DataSource as DataTable;

            DataRow row = e.Data.GetData(typeof(DataRow)) as DataRow;

            if (row != null && table != null && row.Table != table)
            {
                table.ImportRow(row);

                row.Delete();
            }
        }
Example #53
0
        private void ctlTreeView_DragOver(object sender, System.Windows.Forms.DragEventArgs e)
        {
            TreeNode nodeOver = ctlTreeView.GetNodeAt(ctlTreeView.PointToClient(Cursor.Position));

            if (nodeOver != null && CanDrag((string)e.Data.GetData(DataFormats.Text), nodeOver.Name))
            {
                e.Effect = DragDropEffects.Move;
                HighlightNode(nodeOver);
            }
            else
            {
                e.Effect = DragDropEffects.None;
                HighlightNode(null);
            }
        }
Example #54
0
 void nodeTreeView_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
 {
     if (e.Data.GetDataPresent(System.Windows.Forms.DataFormats.FileDrop, false))
     {
         e.Effect = System.Windows.Forms.DragDropEffects.All;
     }
     else if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", false))
     {
         e.Effect = this.effect_by_mod_state;
     }
     else
     {
         e.Effect = DragDropEffects.None;
     }
 }
Example #55
0
        // apply image to cell
        private void _flex_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            int row = _flex.MouseRow;
            int col = _flex.MouseCol;

            if (row > -1 && col > -1)
            {
                Image img = e.Data.GetData(typeof(Bitmap)) as Image;
                if (img != null)
                {
                    _flex.SetCellImage(row, col, img);
                    _flex.Select(row, col);
                }
            }
        }
Example #56
0
 public void DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
 {
     DragDropArray = (Array)e.Data.GetData(DataFormats.FileDrop);
     if (DragDropArray != null)
     {
         if (LoadingMediaList == "")
         {
             LoadingMediaList   = "Import";
             Thread_MediaLoader = new Thread(new ThreadStart(DragDropThread));
             Thread_MediaLoader.IsBackground = true;
             Thread_MediaLoader.Name         = "MediaLoader:DragDrop";
             Thread_MediaLoader.Start();
         }
     }
 }
Example #57
0
        private void listView1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            if (m_InternalDragDrop)
            {
                return;
            }
            ButtonItem item = e.Data.GetData(typeof(ButtonItem)) as ButtonItem;

            if (item == null)
            {
                return;
            }
            listView1.Items.Add(item.Text, item.ImageIndex);
            item.Parent.SubItems.Remove(item);
        }
Example #58
0
        private void c1Sizer1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            // move control when finished dragging
            Control ctl = e.Data.GetData(typeof(Button)) as Control;

            if (ctl != null)
            {
                Rectangle rc = GetCellAt(e.X, e.Y);
                if (rc.Width > 0)
                {
                    ctl.Bounds = rc;
                    Console.WriteLine(this.c1Sizer1.GridDefinition);
                }
            }
        }
Example #59
0
        private void textBox1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            FileNames.Clear();
            foreach (string fileName in
                     (string[])e.Data.GetData(DataFormats.FileDrop))
            {
                FileNames.Add(fileName);
            }
            string[]     TheseFiles = (string[])FileNames.ToArray(typeof(string));
            string       FileName   = TheseFiles[0];
            StreamReader sr         = new StreamReader(FileName);

            textBox1.Text = sr.ReadToEnd();
            sr.Close();
        }
Example #60
0
        private void listBox1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
        {
            Select_Extension.SelectedIndex = 0; //sets default container, if not set crashes
            File_Input.Items.Clear();
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                e.Effect = DragDropEffects.All;
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }

            //add set FileDirectory here to browse in file location before hitting generate
        }