Example #1
0
 internal static void OnDragDataReceived(object sender, Gtk.DragDataReceivedArgs e)
 {
     if (NotebookDragDataReceived != null)
     {
         NotebookDragDataReceived(sender, e);
     }
 }
Example #2
0
        void OnDragDataReceived(object o, Gtk.DragDataReceivedArgs args)
        {
            if (args.Info != (uint)TargetList.UriList)
            {
                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("file://"))
                {
                    var filePath = new FilePath(file);

                    try {
                        if (Services.ProjectService.IsWorkspaceItemFile(filePath))
                        {
                            IdeApp.Workspace.OpenWorkspaceItem(filePath);
                        }
                        else
                        {
                            IdeApp.Workbench.OpenDocument(filePath, null, -1, -1, MonoDevelop.Ide.Gui.OpenDocumentOptions.Default, null, null, this);
                        }
                    } catch (Exception e) {
                        MonoDevelop.Core.LoggingService.LogError("unable to open file {0} exception was :\n{1}", file, e.ToString());
                    }
                }
            }
        }
Example #3
0
        async void OnDragDataReceived(object o, Gtk.DragDataReceivedArgs args)
        {
            if (args.Info != (uint)TargetList.UriList)
            {
                return;
            }
            string fullData = System.Text.Encoding.UTF8.GetString(args.SelectionData.Data);

            var loadWorkspaceItems = !IsInsideTabStrip(args.X, args.Y);
            var files = new List <Ide.Gui.FileOpenInformation> ();

            foreach (string individualFile in fullData.Split('\n'))
            {
                string file = individualFile.Trim();
                if (file.StartsWith("file://"))
                {
                    var filePath = new FilePath(file);
                    if (filePath.IsDirectory)
                    {
                        if (!loadWorkspaceItems)                         // skip directories when not loading solutions
                        {
                            continue;
                        }
                        filePath = Directory.EnumerateFiles(filePath).FirstOrDefault(p => Services.ProjectService.IsWorkspaceItemFile(p));
                    }
                    if (!filePath.IsNullOrEmpty)                     // skip empty paths
                    {
                        files.Add(new Ide.Gui.FileOpenInformation(filePath, null, 0, 0, Ide.Gui.OpenDocumentOptions.DefaultInternal)
                        {
                            DockNotebook = this
                        });
                    }
                }
            }

            if (files.Count > 0)
            {
                if (loadWorkspaceItems)
                {
                    try {
                        IdeApp.OpenFiles(files);
                    } catch (Exception e) {
                        LoggingService.LogError($"Failed to open dropped files", e);
                    }
                }
                else                     // open workspace items as files
                {
                    foreach (var file in files)
                    {
                        try {
                            await IdeApp.Workbench.OpenDocument(file).ConfigureAwait(false);
                        } catch (Exception e) {
                            LoggingService.LogError($"unable to open file {file}", e);
                        }
                    }
                }
            }
        }
Example #4
0
    protected virtual void lbl_drop_drag_data_received(object o, Gtk.DragDataReceivedArgs args)
    {
        bool   success = false;
        string data    = System.Text.Encoding.UTF8.GetString(args.SelectionData.Data);

        switch (args.Info)
        {
        case 0:         //uri-list
            string[] uri_list = Regex.Split(data, "\r\n");
            foreach (string u in uri_list)
            {
                if (u.Length > 0)
                {
                    Runner.Run(u);
                }
            }
            success = true;
            break;
        }
        Gtk.Drag.Finish(args.Context, success, false, args.Time);
    }
Example #5
0
    private void OnDragDataReceived(object o, Gtk.DragDataReceivedArgs args)
    {
        string data = System.Text.Encoding.UTF8.GetString(args.SelectionData.Data);

        data += "\r\n";
        LogManager.Log(LogLevel.Debug, "Drag&Drop Uri-list received: {0}", data);

        int    index    = 0;            //index of first letter in filename
        string filename = "";

        // repeat until there's existing file that ends ".stl" or ".stwm"
        while (!(File.Exists(filename) && (filename.Substring(filename.Length - 4) == ".stl" || filename.Substring(filename.Length - 5) == ".stwm")))
        {
            index = data.IndexOf("file:", index);                                                       //move pointer to next "file:"

            if (index == -1)
            {
                LogManager.Log(LogLevel.Debug, "		No more filenames... aborting");
                Gtk.Drag.Finish(args.Context, false, false, args.Time);
                return;
            }
            index += 5;                                                                                 //move pointer after next "file:" to reach filename
            string uri = data.Substring(index, data.IndexOf('\n', index) - index - 1);
            filename = Uri.UnescapeDataString(uri);                                                     //convert excape sequences ("%2b" = "+") to normal text
            LogManager.Log(LogLevel.Debug, "		Found filename: {0}", filename);
        }

        if (!ChangeConfirm("load a new level"))
        {
            Gtk.Drag.Finish(args.Context, false, false, args.Time);
            return;
        }

        Gtk.Drag.Finish(args.Context, true, false, args.Time);

        Load(filename);                         //load the level
    }
Example #6
0
        private void HandleDragDataReceived(object o, DragDataReceivedArgs args)
        {
            args.RetVal = true;

            if (args.Info == DragDropTargets.TagListEntry.Info) {

                InsertTerm (args.SelectionData.GetTagsData (), rootTerm, null);
                return;
            }

            if (args.Info == DragDropTargets.TagQueryEntry.Info) {

                // FIXME: use drag data
                HandleLiteralsMoved (Literal.FocusedLiterals, rootTerm, null);

                // Prevent them from being removed again
                Literal.FocusedLiterals = null;

                return;
            }
        }
Example #7
0
 private void OnIconViewDragDataReceived(object o, DragDataReceivedArgs args)
 {
     Console.WriteLine("OnIconViewDragDataReceived: {0}", (DragTargetType)args.Info);
        bool bFolderCreated = false;
        switch (args.Info)
        {
     case (uint) DragTargetType.iFolderID:
      string ifolderID =
       System.Text.Encoding.UTF8.GetString(args.SelectionData.Data);
      iFolderHolder holder = ifdata.GetAvailableiFolder(ifolderID);
      if (holder != null)
       DownloadiFolder(holder);
      break;
     case (uint) DragTargetType.UriList:
      UriList uriList = new UriList(args.SelectionData);
      if (uriList.Count == 1)
      {
       string path = uriList.ToLocalPaths()[0];
        DomainInformation[] domains = domainController.GetDomains();
        if (domains.Length <= 0) return;
        string domainID = domains[0].ID;
        DomainInformation defaultDomain = domainController.GetDefaultDomain();
        if (defaultDomain != null)
     domainID = defaultDomain.ID;
        DragCreateDialog cd = new DragCreateDialog(this, domains, domainID, path);
        cd.TransientFor = this;
        int rc = 0;
        do
        {
     rc = cd.Run();
     cd.Hide();
     if (rc == (int)ResponseType.Ok)
     {
      try
      {
       string selectedFolder = cd.iFolderPath.Trim();
       string selectedDomain = cd.DomainID;
       string parentDir = System.IO.Path.GetDirectoryName( selectedFolder );
       if ( ( parentDir == null ) || ( parentDir == String.Empty ) )
       {
        iFolderMsgDialog dg = new iFolderMsgDialog(
     this,
     iFolderMsgDialog.DialogType.Warning,
     iFolderMsgDialog.ButtonSet.Ok,
     "",
     Util.GS("Invalid folder specified"),
     Util.GS("An invalid folder was specified"));
        dg.Run();
        dg.Hide();
        dg.Destroy();
        continue;
       }
       iFolderHolder ifHolder = null;
       try
       {
        ifHolder =
     ifdata.CreateiFolder(selectedFolder,
       selectedDomain);
       }
       catch(Exception e)
       {
        if (DisplayCreateOrSetupException(e))
        {
     continue;
        }
       }
       if(ifHolder == null)
        throw new Exception("Simias returned null");
       rc = 0;
       Util.LastCreatedPath = ifHolder.iFolder.UnManagedPath;
       if(ClientConfig.Get(ClientConfig.KEY_SHOW_CREATION,
       "true") == "true")
       {
        iFolderCreationDialog dlg =
     new iFolderCreationDialog(ifHolder.iFolder);
        dlg.TransientFor = this;
        int createRC;
        do
        {
     createRC = dlg.Run();
     if(createRC == (int)Gtk.ResponseType.Help)
     {
      Util.ShowHelp("myifolders.html", this);
     }
        }while(createRC != (int)Gtk.ResponseType.Ok);
        dlg.Hide();
        if(dlg.HideDialog)
        {
     ClientConfig.Set(
      ClientConfig.KEY_SHOW_CREATION, "false");
        }
        cd.Destroy();
        cd = null;
       }
      }
      catch (Exception e)
      {
       Console.WriteLine(e.Message);
       continue;
      }
     }
        }
        while(rc == (int)ResponseType.Ok);
      }
      break;
     default:
      break;
        }
        Gtk.Drag.Finish (args.Context, bFolderCreated, false, args.Time);
 }
Example #8
0
        private void MainWindow_DragDataReceived(object o, DragDataReceivedArgs args)
        {
            // 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 ("file://"))
                    PintaCore.Workspace.OpenFile (new Uri (file).LocalPath);
            }
        }
Example #9
0
        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");
        }
Example #10
0
        private void TreeviewDragDataReceived(object o, DragDataReceivedArgs args)
        {
            if (args.SelectionData.Target.Name != TorrentTreeView.FileAtom.Name)
                return;

            string [] uriList = (Encoding.UTF8.GetString(args.SelectionData.Data).TrimEnd()).Split('\n');

            foreach(string s in uriList){
                try
                {
                    Uri uri = new Uri(s.TrimEnd());
                    if (uri.IsFile && uri.LocalPath.EndsWith(".torrent", StringComparison.OrdinalIgnoreCase))
                        LoadTorrent(uri.LocalPath);
                }
                catch
                {
                }
            }
        }
Example #11
0
	/* 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);
	}
Example #12
0
 public static void PrintDragData(DragDataReceivedArgs e)
 {
     LogError("SuggestedAction: {0}, X:{1} Y:{2}", e.Context.SuggestedAction, e.X, e.Y);
     PrintSelectionData(e.SelectionData);
 }
	public void HandleTagSelectionDragDataReceived (object o, DragDataReceivedArgs args)
	{
        TreePath path;
        TreeViewDropPosition position;
        if (!tag_selection_widget.GetDestRowAtPos((int)args.X, (int)args.Y, out path, out position))
            return;

        Tag tag = path == null ? null : tag_selection_widget.TagByPath (path);
		if (tag == null)
			return;

		switch (args.Info) {
		case (uint)TargetType.PhotoList:
			db.BeginTransaction ();
			AddTagExtended (SelectedIds (), new Tag[] {tag});
			db.CommitTransaction ();
			query_widget.PhotoTagsChanged (new Tag[] {tag});
			break;
		case (uint)TargetType.UriList:
			UriList list = new UriList (args.SelectionData);
			
			db.BeginTransaction ();
			List<Photo> photos = new List<Photo> ();
			foreach (Uri photo_uri in list) {
				Photo photo = db.Photos.GetByUri (photo_uri);
				
				// FIXME - at this point we should import the photo, and then continue
				if (photo == null)
					continue;
				
				// FIXME this should really follow the AddTagsExtended path too
				photo.AddTag (new Tag[] {tag});
				photos.Add (photo);
			}
			db.Photos.Commit (photos.ToArray ());
			db.CommitTransaction ();
			InvalidateViews ();
			break;
		case (uint)TargetType.TagList:
			Category parent;
            if (position == TreeViewDropPosition.Before || position == TreeViewDropPosition.After) {
                parent = tag.Category;
            } else {
                parent = tag as Category;
            }

			if (parent == null || tag_selection_widget.TagHighlight.Length < 1) {
                args.RetVal = false;
				return;
            }

            int moved_count = 0;
            Tag [] highlighted_tags = tag_selection_widget.TagHighlight;
			foreach (Tag child in tag_selection_widget.TagHighlight) {
                // FIXME with this reparenting via dnd, you cannot move a tag to root.
                if (child != parent && child.Category != parent && !child.IsAncestorOf(parent)) {
                    child.Category = parent as Category;

                    // Saving changes will automatically cause the TreeView to be updated
                    db.Tags.Commit (child);
                    moved_count++;
                }
            }

            // Reselect the same tags
            tag_selection_widget.TagHighlight = highlighted_tags;

            args.RetVal = moved_count > 0;
			break;
		}
	}
Example #14
0
        /// <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);


                if (selectedNode.Data.ID.Equals (ChallengeMetadataDefinition.ChallengeScopeGuid) && isChallengeExp()){
                    Drag.Finish (args.Context, true, false, args.Time);
                    return;
                } else if(selectedNode.Data.ID.Equals (ChallengeMetadataDefinition.ChallengeScopeGuid)){
                    m_applicationViewModel.Experiment.ExperimentInfo.IsChallenge = "True";
                    m_applicationContext.MainWindow.ExperimentCanvasPad.UpdateExperimentToolbarForChallenge ();
                }

                ExperimentNode node = null;

                if (m_subExperiment != null)
                    node = m_subExperiment.AddComponentFromDefinition (selectedNode.Data, translation.X, translation.Y);
                else
                    node = m_applicationViewModel.Experiment.AddComponentFromDefinition (selectedNode.Data, translation.X, translation.Y);

                m_experimentDrawer.DrawComponent (node, true);

                // HERZUM SPRINT 1.1 IF
                if (node is ExperimentDecisionNode) {

                    BasicNodeControl decisionControl;
                    double x = 0;
                    if (m_applicationContext.NodeControlFactory.TryGetNodeControl (node, out decisionControl)) {
                        x = decisionControl.DisplayBox.X + decisionControl.DisplayBox.Width / 2 - 10;
                    }

                    ExperimentNode exitDecisionNode = null;
                    // HERZUM SPRINT 2.0: TLAB-148
                    IEnumerable<ExperimentNodeConnection> edges = decisionControl.ExperimentNode.Owner.Edges;
                    // END HERZUM SPRINT 2.0: TLAB-148

                    // HERZUM SPRINT 2.0: TLAB-148
                    // foreach (ExperimentNodeConnection edge in m_applicationViewModel.Experiment.Edges){
                    foreach (ExperimentNodeConnection edge in edges) {
                        // END HERZUM SPRINT 2.0: TLAB-148
                        if (edge.Source.Equals (decisionControl.ExperimentNode)) { 
                            if (edge.Target is ExitDecisionNode) {
                                edge.Target.Data.X = x - 10;
                                exitDecisionNode = edge.Target;
                            } else if (edge.Target is ScopeNode) {
                                if (edge.Target.Data.Metadata.Label.Equals ("Scope 1"))
                                    edge.Target.Data.X = x - 50 - 190;
                                else 
                                    edge.Target.Data.X = x + 50;
                            }
                            m_experimentDrawer.DrawComponent (edge.Target, true);
                            m_experimentDrawer.DrawEdge (edge, false);
                        }
                    }

                    // HERZUM SPRINT 2.0: TLAB-148
                    // foreach (ExperimentNodeConnection edge in m_applicationViewModel.Experiment.Edges){
                    foreach (ExperimentNodeConnection edge in edges) {
                        // END HERZUM SPRINT 2.0: TLAB-148
                        if (edge.Target.Equals (exitDecisionNode) && !edge.Source.Equals (node))
                            m_experimentDrawer.DrawEdge (edge, false);
                    }
                }
                // END HERZUM SPRINT 1.1 IF
            }

            Drag.Finish (args.Context, true, false, args.Time);
        }
Example #15
0
		public void HandleDragDataReceived (object o, DragDataReceivedArgs args)
		{
	        TreePath path;
	        TreeViewDropPosition position;

	        if ( ! GetDestRowAtPos ((int)args.X, (int)args.Y, out path, out position))
	            return;

	        Tag tag = path == null ? null : TagByPath (path);
			if (tag == null)
				return;

			if (args.Info == DragDropTargets.PhotoListEntry.Info) {
				database.BeginTransaction ();

				Photo[] photos = args.SelectionData.GetPhotosData ();

				foreach (Photo photo in photos) {

					if (photo == null)
						continue;

					photo.AddTag (tag);
					database.Photos.Commit (photo);

					// FIXME: AddTagExtendes from Mainwindow.cs does some tag-icon handling.
					// this should be done here or completely located to the Tag-class.
				}
				database.CommitTransaction ();

				// FIXME: this needs to be done somewhere:
				//query_widget.PhotoTagsChanged (new Tag[] {tag});
				return;
			}

			if (args.Info == (uint)DragDropTargets.TargetType.UriList) {
				UriList list = args.SelectionData.GetUriListData ();

				database.BeginTransaction ();
				List<Photo> photos = new List<Photo> ();
				foreach (var photo_uri in list) {
					Photo photo = database.Photos.GetByUri (photo_uri);

					// FIXME - at this point we should import the photo, and then continue
					if (photo == null)
						continue;

					// FIXME this should really follow the AddTagsExtended path too
					photo.AddTag (new Tag[] {tag});
					photos.Add (photo);
				}
				database.Photos.Commit (photos.ToArray ());
				database.CommitTransaction ();

				// FIXME: this need to be done
				//InvalidateViews (); // but it seems not to be needed. tags are updated through in IconView through PhotoChanged
				return;
			}

			if (args.Info == DragDropTargets.TagListEntry.Info) {
				Category parent;
	            if (position == TreeViewDropPosition.Before || position == TreeViewDropPosition.After) {
	                parent = tag.Category;
	            } else {
	                parent = tag as Category;
	            }

				if (parent == null || TagHighlight.Length < 1) {
	                args.RetVal = false;
					return;
	            }

	            int moved_count = 0;
	            Tag [] highlighted_tags = TagHighlight;
				foreach (Tag child in TagHighlight) {
	                // FIXME with this reparenting via dnd, you cannot move a tag to root.
	                if (child != parent && child.Category != parent && !child.IsAncestorOf(parent)) {
	                    child.Category = parent;

	                    // Saving changes will automatically cause the TreeView to be updated
	                    database.Tags.Commit (child);
	                    moved_count++;
	                }
	            }

	            // Reselect the same tags
	            TagHighlight = highlighted_tags;

	            args.RetVal = moved_count > 0;
			}
		}
Example #16
0
        private void HandleDragDataReceived (object o, DragDataReceivedArgs args)
        {
            TreeView treeView = (TreeView) o;
            bool success = false;

            //1. check if we can drop at the given position
            TreePath path;
            TreeViewDropPosition pos;
            if (!treeView.GetDestRowAtPos (args.X, args.Y, out path, out pos)) 
            {
                args.RetVal = false;
                Gtk.Drag.Finish(args.Context, success, false, args.Time);
                return;
            }

            //2. check if given position can find corresponding iter (iter holds value with PackageSourceInfo)
            Gtk.TreeIter folderIter;
            if (!m_packageContentStore.GetIter (out folderIter, path))
            {
                args.RetVal = false;
                Gtk.Drag.Finish(args.Context, success, false, args.Time);
                return;
            }

            //if user drop the item not on the folder then return false
            PackageHeirarchyItem folder = this.treeView.Model.GetValue(folderIter, 0) as PackageHeirarchyItem;
            if(folder == null) 
            {
                args.RetVal = false;
                Gtk.Drag.Finish(args.Context, success, false, args.Time);
                return;
            }

            if (pos == TreeViewDropPosition.Before)
                treeView.SetDragDestRow (path, TreeViewDropPosition.IntoOrBefore);
            else if (pos == TreeViewDropPosition.After)
                treeView.SetDragDestRow (path, TreeViewDropPosition.IntoOrAfter);

            Gdk.Drag.Status (args.Context, args.Context.SuggestedAction, args.Time);

            string data = System.Text.Encoding.UTF8.GetString(args.SelectionData.Data);
            List<string> paths = new List<string>(System.Text.RegularExpressions.Regex.Split(data, "\r\n"));
            paths.RemoveAll(string.IsNullOrEmpty);
            paths.RemoveAt(paths.Count-1); // I don't know what last object is, but I tested and noticed that it is not a path

            foreach (string uriPath in paths) 
            {
                string localPath = new Uri(uriPath).LocalPath;
                System.Console.WriteLine ("Got Path {0}", localPath);
                PackageFileSourceInfo newItem = m_viewModel.Add(folder, localPath);

                //update also a view
                if(newItem != null) 
                {
                    AddNodeToTreeModel(newItem, folderIter);
                }
            }

            success = true;
            Gtk.Drag.Finish(args.Context, success, false, args.Time);
        }
Example #17
0
		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);
		}
		/// <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;
		}
Example #19
0
        private void OnDragDataReceived(object sender, DragDataReceivedArgs args)
        {
            if (args.SelectionData.Length > 0 && args.SelectionData.Format == 8) {
                string uris = Encoding.ASCII.GetString (args.SelectionData.Data, 0, args.SelectionData.Length);

                foreach (string str in uris.Trim ().Split ('\n')) {
                    string uristr = str.Trim (); // remove the '\r'

                    if (uristr == String.Empty)
                        continue;

                    Uri uri = new Uri (uristr);
                    if (!uri.IsFile) {
                        continue;
                    }

                    try {
                        VirtualMachine machine = new VirtualMachine (uri.LocalPath);
                        controller.Manager.AddMachine (machine);
                    } catch (Exception e) {
                        Console.Error.WriteLine ("Could not load virtual machine: " + e);
                    }
                }
            }
        }
Example #20
0
		private void OnTorrentDragDataReceived(object sender, DragDataReceivedArgs args)
		{
			TreePath path;
			TreeViewDropPosition pos;
			TreeIter iter;
			TorrentLabel label;
						
			string hashcode = (Encoding.UTF8.GetString(args.SelectionData.Data));
			
			if(!labelTreeView.GetDestRowAtPos(args.X, args.Y, out path, out pos))
				return;
			if(!labelTreeView.Model.GetIter(out iter, path))
				return;
				
			label = (TorrentLabel) labelTreeView.Model.GetValue(iter, 0);
			if(label == allLabel || label == DownloadingLabel || label == SeedingLabel)
				return;
				
			foreach (TorrentManager manager in torrents.Keys) {
				if(manager.GetHashCode().ToString() == hashcode) {
					label.AddTorrent(manager);
				}
			}
			
		}
Example #21
0
        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 HandleIconViewDragDataReceived (object sender, DragDataReceivedArgs args)
	{
	 	Widget source = Gtk.Drag.GetSourceWidget (args.Context);     
		
		switch (args.Info) {
		case (uint)TargetType.TagList:
			//
			// Translate the event args from viewport space to window space,
			// drag events use the viewport.  Owen sends his regrets.
			//
			int item = icon_view.CellAtPosition (args.X + (int) icon_view.Hadjustment.Value, 
							     args.Y + (int) icon_view.Vadjustment.Value);

			//Console.WriteLine ("Drop cell = {0} ({1},{2})", item, args.X, args.Y);
			if (item >= 0) {
				if (icon_view.Selection.Contains (item))
					AttachTags (tag_selection_widget.TagHighlight, SelectedIds());
				else 
					AttachTags (tag_selection_widget.TagHighlight, new int [] {item});
			}
			break;
		case (uint)TargetType.UriList:

			/* 
			 * If the drop is coming from inside f-spot then we don't want to import 
			 */
			if (source != null)
				return;

			UriList list = new UriList (args.SelectionData);
			ImportUriList (list, (args.Context.Action & Gdk.DragAction.Copy) != 0);
			break;
#if ENABLE_REPARENTING
		case (uint)TargetType.PhotoList:
			int p_item = icon_view.CellAtPosition (args.X + (int) icon_view.Hadjustment.Value, 
							     args.Y + (int) icon_view.Vadjustment.Value);

			if (p_item >= 0)
			{
				PhotoVersionCommands.Reparent cmd = new PhotoVersionCommands.Reparent ();
				
				cmd.Execute (db.Photos, SelectedPhotos(), query.Photos [p_item], GetToplevel (null));
				UpdateQuery ();
			}
	
			break;
#endif
		}

		Gtk.Drag.Finish (args.Context, true, false, args.Time);
	}
		private void HandleDragDataReceived (object o, DragDataReceivedArgs args)
		{
			InsertTerm (rootTerm, null);

			args.RetVal = true;
		}
	void HandlePhotoViewDragDataReceived (object sender, DragDataReceivedArgs args)
	{
	 	//Widget source = Gtk.Drag.GetSourceWidget (args.Context);     
		//Console.WriteLine ("Drag received {0}", source == null ? "null" : source.TypeName);

		HandleAttachTagCommand (sender, null);
		
		Gtk.Drag.Finish (args.Context, true, false, args.Time);
	}	
Example #25
0
        void OnDragDataReceived(object o, DragDataReceivedArgs args)
        {
            Console.WriteLine("OnDragDataReceived: {0}", (TargetType)args.Info);
            Console.WriteLine("Position: {0} {1}", args.X, args.Y);
            switch ((TargetType)args.Info)
            {
                case TargetType.Text:
                    // preprocess input string...
                    String input = Encoding.UTF8.GetString(args.SelectionData.Data).Trim();
                    string[] words = input.Split('\n');
                    List<string> nwords = new List<string>();
                    foreach (string word in words)
                    {
                        String nword = word;
                        // let's just ignore anything that's not a zip or jar
                        if(!word.ToLower().Contains(".jar") && !word.ToLower().Contains(".zip"))
                            continue;
                        // trim nonsense
                        if(word.StartsWith("file://"))
                        {
                            nword = nword.Substring(7);
                        }
                        nwords.Add(nword);
                    }
                    // filtered away everything... just stop.
                    if(nwords.Count == 0)
                        return;
                    // if the drop target is the jar list
                    if (o == jarModList)
                    {
                        TreePath path;
                        TreeIter iter;
                        TreeViewDropPosition droppos;
                        jarModList.GetDestRowAtPos (args.X,args.Y,out path, out droppos);
                        jarModList.Model.GetIter (out iter, path);
                        if(path != null)
                        {
                            Console.WriteLine("Got position ;) " + path.Indices[0]);
                            switch(droppos)
                            {
                                case TreeViewDropPosition.Before:
                                case TreeViewDropPosition.IntoOrBefore:
                                    AddJarMods(nwords.ToArray(), path.Indices[0]);
                                break;
                                case TreeViewDropPosition.After:
                                case TreeViewDropPosition.IntoOrAfter:
                                    AddJarMods(nwords.ToArray(), path.Indices[0]+1);
                                break;
                            }
                        }
                        else
                        {
                            Console.WriteLine("Indeterminate position... ");
                            AddJarMods(nwords.ToArray(), -1);
                        }
                    }
                    // if it's the modloader list
                    else if (o == mlModList)
                        AddMLMods(nwords.ToArray());
                    break;

                // let's hope this never happens, because it sure doesn't happen here. :whistles:
                case TargetType.Uri:
                    foreach (string uri in Encoding.UTF8.GetString(args.SelectionData.Data).Trim().Split('\n'))
                        Console.WriteLine("Uri: {0}", Uri.UnescapeDataString(uri));
                    break;
                // Handle reorder events inside the list.
                // This is only needed because the Reorderable property stops working
                // when you use custom drag&drop handling
                case TargetType.Movement:
                    if (o == jarModList)
                    {
                        TreePath path;
                        TreeIter srcIter;
                        TreeIter destIter;
                        TreeViewDropPosition droppos;
                        jarModList.GetDestRowAtPos (args.X,args.Y,out path, out droppos);
                        String sourceStr = System.Text.Encoding.UTF8.GetString (args.SelectionData.Data);
                        int sourceInt = int.Parse(sourceStr);
                        int destInt = -1;
                        modStore.IterNthChild(out srcIter,sourceInt);
                        if(path != null)
                        {
                            jarModList.Model.GetIter (out destIter, path);
                            destInt = path.Indices[0];
                            switch(droppos)
                            {
                                case TreeViewDropPosition.Before:
                                case TreeViewDropPosition.IntoOrBefore:
                                    modStore.MoveBefore(srcIter,destIter);
                                break;
                                case TreeViewDropPosition.After:
                                case TreeViewDropPosition.IntoOrAfter:
                                    modStore.MoveAfter(srcIter,destIter);
                                break;
                            }

                            Console.WriteLine("Moving something!: from {0} to {1}", sourceInt, destInt );
                        }
                        else
                        {
                            // HACK : this is needed becuase of a GTK# API bug.
                            // See: http://mono.1490590.n4.nabble.com/On-a-ListStore-moving-items-on-the-list-some-questions-td2222829.html
                            TreeIter stDestIter;
                            modStore.GetIterFromString(out stDestIter, (Convert.ToUInt16(modStore.IterNChildren()) - 1).ToString());
                            modStore.MoveAfter(srcIter, stDestIter);
                            Console.WriteLine("Moving something!: from {0} to End", sourceInt );
                        }
                        // mod order most probably did change.
                        changed_mod_order = true;
                    }
                    break;
            }
            Console.WriteLine();
            bool success = true;
            Gtk.Drag.Finish (args.Context, success, false, args.Time);
        }
Example #26
0
        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;
            }
        }
Example #27
0
        private void OnTorrentDragDataReceived(object sender, DragDataReceivedArgs args)
        {
            if (args.SelectionData.Target == null)
                return;
            if (args.SelectionData.Target.Name != TorrentTreeView.RowAtom.Name)
                return;

            TreePath path;
            TreeViewDropPosition pos;
            TreeIter iter;
            TorrentLabel label;

            if(!labelTreeView.GetDestRowAtPos(args.X, args.Y, out path, out pos))
                return;
            if(!labelTreeView.Model.GetIter(out iter, path))
                return;

            label = (TorrentLabel) labelTreeView.Model.GetValue(iter, 0);
            if(label == LabelController.All || label == LabelController.Downloading || label == LabelController.Seeding)
                return;

            if (args.SelectionData.Format != 8)
                return;

            InfoHash target = new InfoHash (args.SelectionData.Data);
            Download download = TorrentController.Torrents.Find (delegate (Download o) {
                return o.InfoHash == target;
            });
            if (download == null)
                return;

            if (label != LabelController.Delete)
            {
                label.AddTorrent(download);
            }
            else
            {
                if (!labelTreeView.Selection.GetSelected (out iter))
                    return;

                label = (TorrentLabel)labelTreeView.Model.GetValue (iter, 0);
                label.RemoveTorrent (download);
            }
        }
Example #28
0
        protected void DropHandler2(object o, DragDataReceivedArgs args)
        {
            try {
                string fichero = FormatDropString (args.SelectionData.Text);
                this.FileOutputDirEntry.Text = fichero;
            }
            catch (Exception)
            {

            }
        }
Example #29
0
 private void OnIconViewDragDataReceived(object o, DragDataReceivedArgs args)
 {
     bool bFolderCreated = false;
        switch (args.Info)
        {
     case (uint) DragTargetType.iFolderID:
      string ifolderID =
       System.Text.Encoding.UTF8.GetString(args.SelectionData.Data);
      iFolderHolder holder = ifdata.GetAvailableiFolder(ifolderID);
      if (holder != null)
       DownloadiFolder(holder, true);
      break;
     case (uint) DragTargetType.UriList:
      UriList uriList = new UriList(args.SelectionData);
      if (uriList.Count == 1)
      {
       string path = null;
       try
       {
        path = uriList.ToLocalPaths()[0];
       }
       catch
       {
        return;
       }
       DomainInformation[] domains = domainController.GetDomains();
       if (domains.Length <= 0) return;
       string domainID = domains[0].ID;
       DomainInformation defaultDomain = domainController.GetDefaultDomain();
       if (defaultDomain != null)
        domainID = defaultDomain.ID;
       DragCreateDialog cd = new DragCreateDialog(this, domains, domainID, path, ifws);
       cd.TransientFor = this;
       int rc = 0;
       do
       {
        rc = cd.Run();
        cd.Hide();
        if (rc == (int)ResponseType.Ok)
        {
     try
     {
      string selectedFolder = cd.iFolderPath.Trim();
      string selectedDomain = cd.DomainID;
      bool SSL = cd.ssl;
      string algorithm = cd.EncryptionAlgorithm;
      string parentDir = System.IO.Path.GetDirectoryName( selectedFolder );
      if ( ( parentDir == null ) || ( parentDir == String.Empty ) )
      {
       iFolderMsgDialog dg = new iFolderMsgDialog(
        this,
        iFolderMsgDialog.DialogType.Warning,
        iFolderMsgDialog.ButtonSet.Ok,
        "",
        Util.GS("Invalid folder specified"),
        Util.GS("An invalid folder was specified"));
       dg.Run();
       dg.Hide();
       dg.Destroy();
       continue;
      }
      iFolderHolder ifHolder = null;
      try
      {
       if( algorithm != null)
       {
        DomainInformation domainInfo = domainController.GetDomain(selectedDomain);
        if( !domainInfo.Authenticated)
        {
     DisplayLoginMesg();
     continue;
        }
        bool passPhraseStatus = false;
        bool passphraseStatus = false;
        try
        {
                                               passphraseStatus = simws.IsPassPhraseSet(selectedDomain);
        }
        catch(Exception)
        {
     DisplayLoginMesg();
     continue;
        }
        if(passphraseStatus == true)
        {
     string passphrasecheck = simws.GetPassPhrase(selectedDomain);
     if( passphrasecheck == null || passphrasecheck =="")
     {
      Debug.PrintLine(" passphrase not entered at login");
      passPhraseStatus = ShowVerifyDialog(selectedDomain, simws);
     }
     else
     {
      passPhraseStatus = true;
     }
        }
        else
        {
     passPhraseStatus = ShowEnterPassPhraseDialog(selectedDomain, simws);
        }
        if( passPhraseStatus == false)
        {
     continue;
        }
       }
       ifHolder = ifdata.CreateiFolder(selectedFolder, selectedDomain, SSL, algorithm);
      }
      catch(Exception e)
      {
       if (DisplayCreateOrSetupException(e))
       {
        continue;
       }
      }
      if(ifHolder == null)
       throw new Exception("Simias returned null");
      rc = 0;
      Util.LastCreatedPath = ifHolder.iFolder.UnManagedPath;
      if ((bool)ClientConfig.Get(ClientConfig.KEY_SHOW_CREATION))
      {
       iFolderCreationDialog dlg =
        new iFolderCreationDialog(ifHolder.iFolder);
       dlg.TransientFor = this;
       int createRC;
       do
       {
        createRC = dlg.Run();
        if(createRC == (int)Gtk.ResponseType.Help)
        {
     Util.ShowHelp("myifolders.html", this);
        }
       }while(createRC != (int)Gtk.ResponseType.Ok);
       dlg.Hide();
       if(dlg.HideDialog)
       {
        ClientConfig.Set(
     ClientConfig.KEY_SHOW_CREATION, false);
       }
       cd.Destroy();
       cd = null;
      }
     }
     catch (Exception e)
     {
      Debug.PrintLine(e.Message);
      continue;
     }
        }
       }
       while(rc == (int)ResponseType.Ok);
      }
      break;
     default:
      break;
        }
        Gtk.Drag.Finish (args.Context, bFolderCreated, false, args.Time);
 }
Example #30
0
 void OnDragDataReceived(object o, Gtk.DragDataReceivedArgs args)
 {
     DockNotebookManager.OnDragDataReceived(o, args);
 }
Example #31
0
 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;
     }
 }
Example #32
0
        private void OnDragDataReceived(object o, DragDataReceivedArgs args)
        {
            if (args.Info != (uint) TargetType.UriList &&
                args.Info != (uint) TargetType.Uri) {
                Drag.Finish (args.Context, false, false, args.Time);
                return;
            }

            string path = System.Text.Encoding.UTF8.GetString (args.SelectionData.Data).Trim ();
            Driver.connection.ChangeStation (path);
        }
        private void OnDragDataReceived(object o, DragDataReceivedArgs args)
        {
            string dragData = Encoding.UTF8.GetString (args.SelectionData.Data).Trim ();
            XmlReader reader = XmlTextReader.Create (new StringReader (dragData));
            string element = "", type = "", database = "", hash = "";

            while (reader.Read ()) {

                switch (reader.NodeType) {
                case XmlNodeType.Text:

                    if (element.Contains ("Hash"))
                        hash = reader.Value;
                    if (element.Contains ("Table")) {
                        addDropTable (database, type, hash, reader.Value);
                    }
                    break;
                case XmlNodeType.Element:
                    element = reader.Name;
                    // Read attributes
                    while (reader.MoveToNextAttribute ()) {
                        if (reader.Name.Contains ("TYPE"))
                            type = reader.Value;
                        if (reader.Name.Contains ("NAMEDB"))
                            database = reader.Value;
                    }
                    break;
                }
            }

            Gtk.Drag.Finish (args.Context, true, false, args.Time);
        }
        private void OnDragDataReceived( object sender, DragDataReceivedArgs args )
        {
            if( args.X > 0 && args.Y > 0 )
            {
                TreePath path = null;
                this.GetPathAtPos( args.X, args.Y, out path );

                if( drag_buffer != null && path != null )
                {
                    //update indexes
                    int insert_point = int.Parse( path.ToString() ) - 1;
                    if( insert_point >= 0 )
                    {
                        foreach( int index in drag_buffer )
                        {
                            object temp_value = Items[ index ];
                            bool was_checked  = ( checked_items.IndexOf( index ) != -1 );
                            //removes the old item
                            Items.RemoveAt( index );
                            //add it to the new location
                            Items.InsertAt( insert_point, temp_value );
                            if( was_checked )
                            {
                                checked_items.Remove( index        );
                                checked_items.Add   ( insert_point );
                            }
                            insert_point++;
                        }
                    }
                }
            }
        }
Example #35
0
		private void DataReceived (object o, DragDataReceivedArgs args)
		{
			//bool sucess = false;
			//Gtk.Widget source = Gtk.Drag.GetSourceWidget (args.Context);
			/*string data = System.Text.Encoding.UTF8.GetString (args.SelectionData.Data);
			/*switch (args.Info)
			{
				case 0:
					button.Label = (System.DateTime.Now.ToString());
					sucess = true;
					break;
				case 1:
					Gtk.Layout layout = (Gtk.Layout) o;
					layout = addImage(layout, null, args.X, args.Y);
					sucess = true;
					break;
			}*/
			if (MonoUML.Widgets.Hub.Instance.DraggedElement != null)
			{
				//FIXME
				ExpertCoder.Uml2.Element element = MonoUML.Widgets.Hub.Instance.DraggedElement;
				//UML Elements
				ExpertCoder.Uml2.Actor actor;
				ExpertCoder.Uml2.UseCase uCase;
				ExpertCoder.Uml2.Class clss;
				//
				if ((clss = element as ExpertCoder.Uml2.Class) != null)
				{ 
					UMLClass umlClass = UMLClass.CreateNew (_diagram, clss);
					umlClass.Move (_pointer_x, _pointer_y);
					this.AddElement (umlClass); 
				}
				else if ((actor = element as ExpertCoder.Uml2.Actor) != null)
				{ 
					UMLActor umlActor = UMLActor.CreateNew (_diagram, actor);
					umlActor.Move (_pointer_x, _pointer_y);
					this.AddElement (umlActor); 
				}
				else if ((uCase = element as ExpertCoder.Uml2.UseCase) != null)
				{ 
					UMLUseCase umlUseCase = UMLUseCase.CreateNew (_diagram, uCase);
					umlUseCase.Move (_pointer_x, _pointer_y); 
					this.AddElement (umlUseCase);
				}
			}
			//System.Console.WriteLine (MonoUML.Widgets.Hub.Instance.DraggedElement);
			MonoUML.Widgets.Hub.Instance.DraggedElement = null;
			Gtk.Drag.Finish (args.Context, true, false, args.Time);
		}
		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);
				}
			}		
		}