// ============================================ // PROTECTED (Methods) Event Handlers // ============================================ protected void OnDragDataReceived(object sender, DragDataReceivedArgs args) { // Get Drop Paths object[] filesPath = Dnd.GetDragReceivedPaths(args); if (this.userInfo == MyInfo.GetInstance()) { // Copy Selected Files Into Directory foreach (string filePath in filesPath) { FileUtils.CopyAll(filePath, currentDirectory.FullName); } // Refresh Icon View Refresh(); } else { // Send Files foreach (string filePath in filesPath) { PeerSocket peer = (PeerSocket)P2PManager.KnownPeers[userInfo]; bool fisDir = FileUtils.IsDirectory(filePath); Debug.Log("Send To '{0}' URI: '{1}'", userInfo.Name, filePath); if (FileSend != null) { FileSend(peer, filePath, fisDir); } } } Drag.Finish(args.Context, true, false, args.Time); }
private void OnSharedFoldersListDragDataReceived(object o, DragDataReceivedArgs args) { bool success = false; string allPaths = System.Text.Encoding.UTF8.GetString(args.SelectionData.Data); string[] paths = allPaths.Split('\n'); foreach (string path in paths) { string cleanPath = path.Trim(); if (cleanPath != "") { LoggingService.LogDebug(cleanPath); Uri uri = new Uri(cleanPath); if (uri.IsFile) { if (System.IO.Directory.Exists(uri.LocalPath) == true) { sharedFoldersListStore.AppendValues(new object[] { uri.LocalPath }); success = true; } } } } Gtk.Drag.Finish(args.Context, success, false, args.Time); }
static void MainWindow_DragDataReceived(object o, DragDataReceivedArgs args) { string data = System.Text.Encoding.UTF8.GetString(args.SelectionData.Data); data = data.Trim('\r', '\n', '\0'); if (Util.IsRunningOnMono()) { data = data.Replace("file://", ""); } else { data = data.Replace("file:///", ""); } data = data.Replace("%20", " "); // gtk inserts these for spaces? maybe? wtf. try { if (data.EndsWith(".gslice")) { GenerateGCodeForSliceFile(data); } else { LoadGCodeFile(data); } } catch (Exception e) { using (var dialog = new Gtk.MessageDialog(MainWindow, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok, "Exception loading {0} : {1}", data, e.Message)) { dialog.Show(); } } }
private void on_avatarButton_drag_data_received(object sender, DragDataReceivedArgs args) { if (args.SelectionData.Length >= 0 && args.SelectionData.Format == 8) { //Console.WriteLine ("Received {0} in label", args.SelectionData.Text); try { string fileName = new Uri(args.SelectionData.Text.Trim()).LocalPath; Gdk.Pixbuf pixbuf = new Gdk.Pixbuf(fileName); if (pixbuf.Width > 80 | pixbuf.Height > 80) { pixbuf = pixbuf.ScaleSimple(80, 80, Gdk.InterpType.Hyper); } avatarImage.Pixbuf = pixbuf; avatarImage.Sensitive = true; } catch (Exception ex) { Gui.ShowMessageDialog(ex.Message); } } Gtk.Drag.Finish(args.Context, false, false, args.Time); }
// ============================================ // PROTECTED (Methods) Event Handlers // ============================================ protected void OnDragDataReceived(object sender, DragDataReceivedArgs args) { IconViewDropPosition pos; TreePath path; // Get Dest Item Position if (iconView.GetDestItemAtPos(args.X, args.Y, out path, out pos) == false) { Drag.Finish(args.Context, false, false, args.Time); return; } // Select Item (Change Icon To Activate it) UserInfo userInfo = store.GetUserInfo(path); // Get Drop Paths object[] filesPath = Dnd.GetDragReceivedPaths(args); foreach (string filePath in filesPath) { Debug.Log("Send To '{0}' URI: '{1}'", userInfo.Name, filePath); if (SendFile != null) { SendFile(this, userInfo, filePath); } } Drag.Finish(args.Context, true, false, args.Time); }
private void OnDropFiles(object o, DragDataReceivedArgs args) { string data = System.Text.Encoding.UTF8.GetString(args.SelectionData.Data); string[] urls = Regex.Split(data, "\r\n"); int count = 0; foreach (string s in urls) { if (s != null && s.Length > 0) { ++count; } } string[] files = new string[count]; count = 0; foreach (string s in urls) { if (s != null && s.Length > 0) { files[count++] = s; } } OpenAssembly(files); Drag.Finish(args.Context, true, false, args.Time); }
private void TreeViewDragDataReceived(object o, DragDataReceivedArgs args) { if (args.SelectionData.Length > 0) { string motofiles = System.Text.Encoding.UTF8.GetString(args.SelectionData.Data); System.Text.Encoding enc = System.Text.Encoding.UTF8; string files = System.Web.HttpUtility.UrlDecode(motofiles, enc); files = files.Replace("\0", ""); files = files.Replace("\r", ""); string[] fileArray = files.Split('\n', StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < fileArray.Length; i++) { if (fileArray[i].StartsWith("file://")) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { fileArray[i] = fileArray[i].Substring(8); } else { fileArray[i] = fileArray[i].Substring(7); } } } AddSongs(fileArray); } }
void HandleDragDataReceived(object o, DragDataReceivedArgs args) { args.RetVal = true; if (args.Info == DragDropTargets.TagListEntry.Info) { if (TagsAdded != null) { TagsAdded(args.SelectionData.GetTagsData(), Parent, this); } return; } if (args.Info == DragDropTargets.TagQueryEntry.Info) { if (!focusedLiterals.Contains(this)) { if (LiteralsMoved != null) { LiteralsMoved(focusedLiterals, Parent, this); } } // Unmark the literals as focused so they don't get nixed focusedLiterals = null; } }
private void MainWindow_DragDataReceived(object o, DragDataReceivedArgs args) { // TODO: Generate random name for the picture being downloaded // Only handle URIs if (args.Info != 100) { return; } string fullData = System.Text.Encoding.UTF8.GetString(args.SelectionData.Data); foreach (string individualFile in fullData.Split('\n')) { string file = individualFile.Trim(); if (file.StartsWith("http") || file.StartsWith("ftp")) { var client = new System.Net.WebClient(); string tempFilePath = System.IO.Path.GetTempPath() + System.IO.Path.GetFileName(file); var progressDialog = PintaCore.Chrome.ProgressDialog; try { PintaCore.Chrome.MainWindowBusy = true; progressDialog.Title = Catalog.GetString("Downloading Image"); progressDialog.Text = ""; progressDialog.Show(); client.DownloadProgressChanged += (sender, e) => { progressDialog.Progress = e.ProgressPercentage; }; client.DownloadFile(file, tempFilePath); if (PintaCore.Workspace.OpenFile(tempFilePath)) { // Mark as not having a file, so that the user doesn't unintentionally // save using the temp file. PintaCore.Workspace.ActiveDocument.HasFile = false; } } catch (Exception e) { progressDialog.Hide(); PintaCore.Chrome.ShowErrorDialog(PintaCore.Chrome.MainWindow, Catalog.GetString("Download failed"), string.Format(Catalog.GetString("Unable to download image from {0}.\nDetails: {1}"), file, e.Message)); } finally { client.Dispose(); progressDialog.Hide(); PintaCore.Chrome.MainWindowBusy = false; } } else if (file.StartsWith("file://")) { PintaCore.Workspace.OpenFile(new Uri(file).LocalPath); } } }
private static void HandleLabelDragDataReceived(object sender, DragDataReceivedArgs args) { if (args.SelectionData.Length >= 0 && args.SelectionData.Format == 8) { Console.WriteLine("Received {0} in label", args.SelectionData); Gtk.Drag.Finish(args.Context, true, false, args.Time); } Gtk.Drag.Finish(args.Context, false, false, args.Time); }
protected void OnDragDataReceived(object sender, DragDataReceivedArgs args) { string data; string [] uriList; List <string> errors; data = Encoding.UTF8.GetString(args.SelectionData.Data); // Sometimes we get a null at the end, and it crashes us. data = data.TrimEnd('\0'); errors = new List <string> (); uriList = Regex.Split(data, "\r\n"); foreach (string uri in uriList) { string file, path, filename; if (string.IsNullOrEmpty(uri)) { continue; } try { file = uri.Remove(0, 7); // 7 is the length of file:// // I have to use System.IO here due to a Gtk namespace conflict filename = System.IO.Path.GetFileName(file); if (!file.EndsWith(".dll")) { errors.Add(filename); continue; } if (!Directory.Exists(Paths.UserAddinInstallationDirectory)) { Directory.CreateDirectory(Paths.UserAddinInstallationDirectory); } path = Paths.UserAddinInstallationDirectory.Combine(filename); File.Copy(file, path, true); if (errors.Count > 0) { new PluginErrorDialog(errors.ToArray()); } PluginManager.InstallLocalPlugins(); } catch (Exception e) { Log <ManagePluginsPreferencesWidget> .Error("An unexpected error occurred installing your plugin"); Log <ManagePluginsPreferencesWidget> .Debug("{0}\n{1}", e.Message, e.StackTrace); } } }
private void OnDragDataReceived(object sender, DragDataReceivedArgs e) { byte[] data = e.SelectionData.Data; Int64 value = BitConverter.ToInt64(data, 0); if (value != 0) { GCHandle handle = (GCHandle) new IntPtr(value); DragDropData = (ISerializable)handle.Target; } }
protected void HandleDragDataReceived(object o, DragDataReceivedArgs args) { if (Editable == false) { return; } Gtk.Widget source = Gtk.Drag.GetSourceWidget(args.Context); HandleDataReceived(args.Info, source, args.SelectionData); source = null; }
private void HandleCanvasDragDataReceived(object o, DragDataReceivedArgs args) { if (args.SelectionData.Target.Name == "application/x-solidide.shape") { Shape shape = (Shape)args.SelectionData.Data.FromArray(); shape.Matrix.Translate(args.X, args.Y); (this as IDesigner).AddShapes(shape); Gtk.Drag.Finish(args.Context, true, false, args.Time); } Gtk.Drag.Finish(args.Context, false, false, args.Time); }
private void OnDragDataReceived(object o, DragDataReceivedArgs args) { string data = System.Text.Encoding.UTF8.GetString(args.SelectionData.Data); if (!badguySprites.ContainsKey(data)) { badguySprites.Add(data, CrateSprite(data)); } if (data != "") { if (badguys.Count == 0) { Gtk.Drag.SourceSet(this, Gdk.ModifierType.Button1Mask, source_table, DragAction.Move); } Command command; if (draggedID > NONE) //We were moving { if (SelectedObjectNr > draggedID) { SelectedObjectNr--; } if (SelectedObjectNr == draggedID) { draggedID = NONE; return; } command = new SortedListMoveCommand <string>( "Changed position of badguy \"" + data + "\" in the queue", _object, field, draggedID, SelectedObjectNr); draggedID = NONE; } else //We were adding { command = new SortedListAddCommand <string>( "Added badguy \"" + data + "\" into the queue", _object, field, data, SelectedObjectNr); } command.Do(); UndoManager.AddCommand(command); dragging = false; //update heigth SetSizeRequest(-1, ROW_HEIGHT * ((badguys.Count - 1) / TILES_PER_ROW + 1)); } Gtk.Drag.Finish(args.Context, true, false, args.Time); }
public void OnDragDataReceived(object o, DragDataReceivedArgs args) { Log.Debug("BEGIN OnDragDataReceived"); bool success = false; string data = System.Text.Encoding.UTF8.GetString( args.SelectionData.Data); Gtk.TreeModel model; Gtk.TreeIter iter; if (!this.Selection.GetSelected(out model, out iter)) { return; } if (!IsSingle) { string serverName = FindServerName(iter, model); if (serverName == null) { return; } conn = Global.Connections [serverName]; } switch (args.Info) { case 0: { string[] uri_list = Regex.Split(data, "\r\n"); Util.ImportData(conn, parent, uri_list); success = true; break; } case 1: Util.ImportData(conn, parent, data); success = true; break; } Log.Debug("import success: {0}", success.ToString()); Gtk.Drag.Finish(args.Context, success, false, args.Time); Log.Debug("END OnDragDataReceived"); }
private void OnTorrentDragDataReceived(object o, DragDataReceivedArgs args) { string [] uriList = (Encoding.UTF8.GetString(args.SelectionData.Data).TrimEnd()).Split('\n'); foreach (string s in uriList) { Uri uri = new Uri(s.TrimEnd()); if (uri.IsFile) { logger.Info("URI dropped " + uri); torrentController.addTorrent(uri.LocalPath); } } }
/* Video Area */ public void OnVideoAreaDragDataReceived(object o, DragDataReceivedArgs args) { string uriString = Encoding.UTF8.GetString(args.SelectionData.Data); bool success = false; Uri fileUri; if (Uri.TryCreate(uriString, UriKind.Absolute, out fileUri) && (args.Info == DragDrop.DragDropTargetUriList)) { Base.OpenVideo(fileUri); success = true; } Gtk.Drag.Finish(args.Context, success, false, args.Time); }
private void avatarIconView_DragDataReceived(object sender, DragDataReceivedArgs args) { if (args.SelectionData.Length >= 0 && args.SelectionData.Format == 8) { try { string fileName = new Uri(args.SelectionData.Text.Trim()).LocalPath; if (File.Exists(fileName)) { AddFile(fileName); } } catch (Exception ex) { Gui.ShowMessageDialog(ex.Message); } } Gtk.Drag.Finish(args.Context, false, false, args.Time); }
public void DragDataReceivedHandler(object o, DragDataReceivedArgs args) { if (args.Context.Targets[0].Name == "text/uri-list") { var context = args.Context; var thing = args.SelectionData.Text; var data = args.SelectionData.Data; string encoded = System.Text.Encoding.UTF8.GetString(data); var paths = encoded.Split('\r').Select(x => Uri.UnescapeDataString(x.Replace("file:///", "")).Trim()).ToList <string>(); foreach (var path in paths) { Console.WriteLine(path); } add(paths); } }
///<summary> /// Handles drag and drop of files ///</summary> void OnDragDataReceived(object o, DragDataReceivedArgs args) { string uriStr = System.Text.Encoding.Default.GetString(args.SelectionData.Data); // get individual uris... // according to text/uri-list, uris are separated // by "\r\n" uriStr = uriStr.Trim(); uriStr = uriStr.Replace("\r\n", "\n"); string[] uris = uriStr.Split('\n'); // we are done Gtk.Drag.Finish(args.Context, false, false, args.Time); // load the files Services.File.LoadFiles(uris); }
void HandleDragDataReceived(object sender, DragDataReceivedArgs args) { //if (args.Info == DragDropTargets.TargetType.UriList // || args.Info == DragDropTargets.TargetType.PlainText) { // /* // * If the drop is coming from inside f-spot then we don't want to import // */ // if (Gtk.Drag.GetSourceWidget (args.Context) != null) // return; // var list = args.SelectionData.GetUriListData (); // collection.LoadItems (list.ToArray ()); // Gtk.Drag.Finish (args.Context, true, false, args.Time); //} }
void HandleBugsListDragDataReceived(object o, DragDataReceivedArgs args) { if (CheckAndDrop(args.X, args.Y, false, args.Context)) { Gtk.TreePath path; Gtk.TreeViewDropPosition pos; bugsList.GetDestRowAtPos(args.X, args.Y, out path, out pos); TreeIter it; bugsStore.GetIter(out it, path); int order = (int)bugsStore.GetValue(it, ColPriority); SetOrder(order, draggedBugs); Gtk.Drag.Finish(args.Context, true, true, args.Time); } else { Gtk.Drag.Finish(args.Context, false, true, args.Time); } }
/// <summary> /// Handles the drag data received. /// See the EnableDrag and HandleDragDataGet in the ComponentLibraryPad where the drag /// has started and drag source is set /// </summary> /// <param name='o'> /// O. /// </param> /// <param name='args'> /// Arguments. /// </param> private void HandleDragDataReceived(object o, DragDataReceivedArgs args) { Widget source = Drag.GetSourceWidget(args.Context); TreeView treeView = source as TreeView; TreeIter selectedItem; if (treeView != null && treeView.Selection.GetSelected(out selectedItem)) { ComponentsLibraryNode selectedNode = treeView.Model.GetValue(selectedItem, 0) as ComponentsLibraryNode; Cairo.PointD translation = m_experimentCanvasWidget.ExperimentCanvas.View.ViewToDrawing(args.X, args.Y); ExperimentNode node = m_applicationViewModel.Experiment.AddComponentFromDefinition(selectedNode.Data, translation.X, translation.Y); m_experimentDrawer.DrawComponent(node, true); } Drag.Finish(args.Context, true, false, args.Time); }
/// <summary> /// Emitted on the drop site. If the data was recieved to preview the data, call /// Gdk.Drag.Status (), else call Gdk.Drag.Finish () /// RetVal = true on success /// </summary> void HandleDragDataReceived(object o, DragDataReceivedArgs args) { if (drag_data_requested) { SelectionData data = args.SelectionData; string uris = Encoding.UTF8.GetString(data.Data); drag_data = Regex.Split(uris, "\r\n") .Where(uri => uri.StartsWith("file://")); drag_data_requested = false; drag_is_desktop_file = drag_data.Any(d => d.EndsWith(".desktop")); Owner.SetHoveredAcceptsDrop(); } Gdk.Drag.Status(args.Context, DragAction.Copy, Gtk.Global.CurrentEventTime); args.RetVal = true; }
void HandleDragDataReceived(object sender, DragDataReceivedArgs args) { if (args.Info == (uint)FSpot.DragDropTargets.TargetType.UriList || args.Info == (uint)FSpot.DragDropTargets.TargetType.PlainText) { /* * If the drop is coming from inside f-spot then we don't want to import */ if (Gtk.Drag.GetSourceWidget(args.Context) != null) { return; } UriList list = args.SelectionData.GetUriListData(); collection.LoadItems(list.ToArray()); Gtk.Drag.Finish(args.Context, true, false, args.Time); } }
void HandleDragDataReceived(object o, DragDataReceivedArgs args) { args.RetVal = true; if (args.Info == DragDropTargets.TagListEntry.Info) { InsertTerm(args.SelectionData.GetTagsData(), Root, null); return; } if (args.Info == DragDropTargets.TagQueryEntry.Info) { // FIXME: use drag data HandleLiteralsMoved(Literal.FocusedLiterals, Root, null); // Prevent them from being removed again Literal.FocusedLiterals = new List <Literal> (); } }
void OnDragDataReceived(object o, DragDataReceivedArgs args) { var data = args.SelectionData; string text = (new System.Text.ASCIIEncoding()).GetString(data.Data); string draggedFileName = null; if (text.StartsWith("file:")) { draggedFileName = (text.Substring(7)).Trim('\t', (char)0x0a, (char)0x0d); } else if (text.StartsWith("http://")) { draggedFileName = (text.Trim('\t', (char)0x0a, (char)0x0d)); } LoadRectangle(new Coordinate <double>(args.X, args.Y), draggedFileName); Gtk.Drag.Finish(args.Context, true, false, args.Time); _preview.QueueDraw(); }
private void DragDataReceivedHandler(object o, DragDataReceivedArgs args) { /* //args.Context. * switch(args.Info) { * case (uint) DragTargetType.UriList: * { * UriList uriList = new UriList(args.SelectionData); * string[] paths = uriList.ToLocalPaths(); * * if(paths.Length > 0) * { * if(!isManual) { * Application.EnqueueFileSend(serviceInfo, uriList.ToLocalPaths()); * } else { * // Prompt for the info to send here * } * } else { * // check for a tomboy notes * foreach(Uri uri in uriList) { * if( (uri.Scheme.CompareTo("note") == 0) && * (uri.Host.CompareTo("tomboy") == 0) ) { * string[] files = new string[1]; * string tomboyID = uri.AbsolutePath.Substring(1); * * string homeFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); * string path = System.IO.Path.Combine(homeFolder, ".tomboy"); * path = System.IO.Path.Combine(path, tomboyID + ".note"); * files[0] = path; * Logger.Debug("Go and get the tomboy note {0}", path); * Application.EnqueueFileSend(serviceInfo, files); * } * } * } * break; * } * default: * break; * } */ //Logger.Debug("DragDataReceivedHandler called"); Gtk.Drag.Finish(args.Context, true, false, args.Time); }
private void OnDragDataReceived(object o, DragDataReceivedArgs args) { // string data = System.Text.Encoding.UTF8.GetString (args.SelectionData.Data); //no data transmitted on "fake drag"s if (Editor != null) { MousePos = MouseToWorld(new Vector((float)args.X, (float)args.Y)); //emulated click on current editor to place object and perform "fake drag" Editor.OnMouseButtonPress(MousePos, 1, ModifierType.Button1Mask); Editor.OnMouseButtonRelease(MousePos, 1, ModifierType.Button1Mask); Gtk.Drag.Finish(args.Context, true, false, args.Time); } else { LogManager.Log(LogLevel.Warning, "DragDataRecieved OK, but there is no editor that can handle it"); Gtk.Drag.Finish(args.Context, false, false, args.Time); } }
protected void HandleDragDataReceived(object o, DragDataReceivedArgs args) { if (Editable == false) return; Gtk.Widget source = Gtk.Drag.GetSourceWidget (args.Context); HandleDataReceived (args.Info, source, args.SelectionData); source = null; }