GetData() public method

public GetData ( Type format ) : object
format System.Type
return object
Example #1
0
        protected void DisplayClipboardData()
        {
            if (!skipFirst)
            {
                skipFirst = true;
                return;
            }
            try
            {
                IDataObject iData = new DataObject();
                iData = Clipboard.GetDataObject();

                if (iData.GetDataPresent(DataFormats.Text))
                {
                    string text = (string)iData.GetData(DataFormats.Text);
                    txtClipBoard.Text = text;
                    int next = clipBoardTextService.process(text);
                    txtStartNumber.Text = next.ToString();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Example #2
0
        //拖动到这个房间的完成
        public void personDragDrop(object sender, DragEventArgs e)
        {
            //  e.Effect = DragDropEffects.Move;
            Button button = sender as Button;

            System.Windows.Forms.DataObject ido = e.Data as System.Windows.Forms.DataObject;

            Person person = new Person();

            person = ido.GetData(person.GetType()) as Person;

            // MessageBox.Show(person.getNoteName(), "测试");
        }
Example #3
0
        public static TransferDataSource ToXwt(this SWF.DataObject data)
        {
            var result = new TransferDataSource();

            result.DataRequestCallback = dt => data.GetData(dt.ToSwf());

            foreach (var item in data.GetFormats())
            {
                var format = ToXwtTransferType(item);
                if (format == TransferDataType.Uri)
                {
                    result.DataRequestCallback = dt => {
                        var value = data.GetData(TransferDataType.Uri.ToSwf());
                        var uris  = ((string[])value).Select(f => new Uri(f)).ToArray();
                        return(uris);
                    };
                }
                result.AddType(format);
            }

            return(result);
        }
Example #4
0
        internal void HandleCopy()
        {

            if (SelectedState.Self.SelectedFrame != null)
            {
                Clipboard.Clear();
                DataObject dataObject = new DataObject("frame", FileManager.CloneObject(SelectedState.Self.SelectedFrame));
                var item = dataObject.GetData("frame");
                Clipboard.SetDataObject(
                    dataObject, false, 10, 40);
            }
            else if (SelectedState.Self.SelectedChain != null)
            {
                Clipboard.Clear();
                var toAdd = FileManager.CloneObject(SelectedState.Self.SelectedChain);
                DataObject dataObject = new DataObject("chain", toAdd);
                Clipboard.SetDataObject(
                    dataObject, false, 10, 40);
            }
        }
 protected override string GetTextFromDataObject(IDataObject dataObject, IServiceProvider provider)
 {
     IDataObjectMapper dataObjectMapper = ((IDataObjectMappingService) provider.GetService(typeof(IDataObjectMappingService))).GetDataObjectMapper(dataObject, DataFormats.Text);
     if (dataObjectMapper != null)
     {
         DataObject mappedDataObject = new DataObject();
         dataObjectMapper.PerformMapping(provider, dataObject, mappedDataObject);
         if (mappedDataObject.GetDataPresent(DataFormats.Text))
         {
             return (string) mappedDataObject.GetData(DataFormats.Text);
         }
     }
     if (dataObject.GetDataPresent(CodeWizard.CodeWizardDataFormat))
     {
         ITextLanguage codeLanguage = this.GetCodeLanguage(provider);
         if (codeLanguage != null)
         {
             return codeLanguage.GetTextFromDataObject(dataObject, provider);
         }
     }
     return base.GetTextFromDataObject(dataObject, provider);
 }
Example #6
0
        private void DisplayClipboardData()
        {
            IDataObject iData = new DataObject();
            iData = Clipboard.GetDataObject();

            if (iData.GetDataPresent(DataFormats.Rtf))
                this.richTextBox1.Rtf = (string)iData.GetData(DataFormats.Rtf);
            else if (iData.GetDataPresent(DataFormats.Text))
                this.richTextBox1.Text = (string)iData.GetData(DataFormats.Text);
            else
                this.richTextBox1.Text = "[Clipboard data is not RTF or ASCII Text]";
        }
Example #7
0
		//-------------------------------------------------------------------------------------
		/// <summary>
		///  опирует в clipboard текущую ¤чейку. ”дал¤ет формат html представлени¤.
		/// </summary>
		/// <returns></returns>
		public DataObject GetCellClipboardContent()
		{
			DataObject obj = new DataObject(CurrentCell.FormattedValue);
			DataObject newObj = new DataObject();

			//this.Sele

			string[] types = obj.GetFormats();
			foreach(String type in types)
			{
				if(type != DataFormats.Html)
					newObj.SetData(type, obj.GetData(type));
			}
			return newObj;
		}
 /// <summary>
 /// Extract SampleCsDragDropData from DataObject
 /// </summary>
 public SampleCsDragData GetSampleCsDragData(DataObject data)
 {
     if (null != data && data.GetDataPresent(typeof(SampleCsDragData)))
     return data.GetData(typeof(SampleCsDragData)) as SampleCsDragData;
       return null;
 }
Example #9
0
    protected override void OnGiveFeedback(F.GiveFeedbackEventArgs e) {
      e.UseDefaultCursors = true;
      var doo = new F.DataObject(_DataObject);

      if (doo.GetDataPresent("DragWindow")) {
        IntPtr hwnd = GetIntPtrFromData(doo.GetData("DragWindow"));
        User32.PostMessage(hwnd, 0x403, IntPtr.Zero, IntPtr.Zero);
      } else {
        e.UseDefaultCursors = true;
      }
      if (IsDropDescriptionValid(_DataObject)) {
        e.UseDefaultCursors = false;
        Cursor.Current = Cursors.Arrow;
      } else {
        e.UseDefaultCursors = true;
      }

      if (IsShowingLayered(doo)) {
        e.UseDefaultCursors = false;
        Cursor.Current = Cursors.Arrow;
      } else {
        e.UseDefaultCursors = true;
      }
    }
		private void ShellTreeView_GiveFeedback(object sender, GiveFeedbackEventArgs e) {
			e.UseDefaultCursors = true;
			var doo = new System.Windows.Forms.DataObject(this._DataObject);
			if (doo.GetDataPresent("DragWindow")) {
				IntPtr hwnd = ShellView.GetIntPtrFromData(doo.GetData("DragWindow"));
				User32.PostMessage(hwnd, 0x403, IntPtr.Zero, IntPtr.Zero);
			} else {
				e.UseDefaultCursors = true;
			}

			if (ShellView.IsDropDescriptionValid(this._DataObject)) {
				e.UseDefaultCursors = false;
				Cursor.Current = Cursors.Arrow;
			} else {
				e.UseDefaultCursors = true;
			}

			if (ShellView.IsShowingLayered(doo)) {
				e.UseDefaultCursors = false;
				Cursor.Current = Cursors.Arrow;
			} else {
				e.UseDefaultCursors = true;
			}

			base.OnGiveFeedback(e);
		}
Example #11
0
        public static void Main()
        {
            PrintFormatInfo(DataFormats.GetFormat(DataFormats.Bitmap));
            PrintFormatInfo(DataFormats.GetFormat(DataFormats.CommaSeparatedValue));
            PrintFormatInfo(DataFormats.GetFormat(DataFormats.Dib));
            PrintFormatInfo(DataFormats.GetFormat(DataFormats.Dif));
            PrintFormatInfo(DataFormats.GetFormat(DataFormats.EnhancedMetafile));
            PrintFormatInfo(DataFormats.GetFormat(DataFormats.FileDrop));
            PrintFormatInfo(DataFormats.GetFormat(DataFormats.Html));
            PrintFormatInfo(DataFormats.GetFormat(DataFormats.Locale));
            PrintFormatInfo(DataFormats.GetFormat(DataFormats.MetafilePict));
            PrintFormatInfo(DataFormats.GetFormat(DataFormats.OemText));
            PrintFormatInfo(DataFormats.GetFormat(DataFormats.Palette));
            PrintFormatInfo(DataFormats.GetFormat(DataFormats.PenData));
            PrintFormatInfo(DataFormats.GetFormat(DataFormats.Riff));
            PrintFormatInfo(DataFormats.GetFormat(DataFormats.Rtf));
            PrintFormatInfo(DataFormats.GetFormat(DataFormats.Serializable));
            PrintFormatInfo(DataFormats.GetFormat(DataFormats.StringFormat));
            PrintFormatInfo(DataFormats.GetFormat(DataFormats.SymbolicLink));
            PrintFormatInfo(DataFormats.GetFormat(DataFormats.Text));
            PrintFormatInfo(DataFormats.GetFormat(DataFormats.Tiff));
            PrintFormatInfo(DataFormats.GetFormat(DataFormats.UnicodeText));
            PrintFormatInfo(DataFormats.GetFormat(DataFormats.WaveAudio));

            // Add our own format
            PrintFormatInfo(DataFormats.GetFormat("Birthday"));

            // Test some basic stuff
            DataObject dobj;
            Control    c;
            string     rtf;

            c   = new Control();
            rtf = "\\r\\t\\f  string";

            // Load the data object
            dobj = new DataObject(DataFormats.Text, "I am text");
            dobj.SetData(c.GetType(), c);
            dobj.SetData(DataFormats.Rtf, rtf);

            PrintFormats("GetFormats(): ", dobj.GetFormats());                                                           // Count should be 5
            PrintFormats("GetFormats(true): ", dobj.GetFormats(true));                                                   // Count should be 5
            PrintFormats("GetFormats(false): ", dobj.GetFormats(false));                                                 // Count should be 3

            Console.WriteLine("GetDataPresent(typeof(string)): {0}", dobj.GetDataPresent(typeof(string)));               // We expect true
            Console.WriteLine("GetDataPresent(DataFormats.Text): {0}", dobj.GetDataPresent(DataFormats.Text));           // We expect true
            Console.WriteLine("GetDataPresent(DataFormats.WaveAudio): {0}", dobj.GetDataPresent(DataFormats.WaveAudio)); // We expect false

            Console.WriteLine("GetData(DataFormats.Rtf): {0}", dobj.GetData(DataFormats.Rtf));                           // We expect "\r\t\f  string"

            clipboard clip = new clipboard();

            PrintClipboardContents();

            IDataObject data;

            data = Clipboard.GetDataObject();

            if (data != null && data.GetDataPresent(DataFormats.Bitmap))
            {
                image = (Image)Clipboard.GetDataObject().GetData(DataFormats.Bitmap);
            }

            Bitmap i = new Bitmap("test.bmp");
            string s = "bummerä";

            Clipboard.SetDataObject(s);

            Application.Run(clip);
        }
Example #12
0
        private void GetClipboardData()
        {
            //
            // Data on the clipboard uses the
            // IDataObject interface
            //
            IDataObject iData = new DataObject();

            try
            {
                iData = Clipboard.GetDataObject();
            }
            catch (System.Runtime.InteropServices.ExternalException externEx)
            {
                // Copying a field definition in Access 2002 causes this sometimes?
                //Debug.WriteLine("InteropServices.ExternalException: {0}", externEx.Message);
                return;
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.ToString());
                return;
            }

            //
            // Get Text if it is present
            //
            if (iData.GetDataPresent(DataFormats.UnicodeText))
            {
                if (_EnableClipboardSearch)
                {
                    _SearchedWord = (string)iData.GetData(DataFormats.UnicodeText);
                    textBoxSearchKeyWord.Text = _SearchedWord;
                    searchWord(_SearchedWord, _EnableClipboardSearch);
                }
                //ctlClipboardText.Text = (string)iData.GetData(DataFormats.Text);

                //strText = "Text";

                //Debug.WriteLine((string)iData.GetData(DataFormats.Text));
            }
        }
Example #13
0
        private void GetClipboardData()
        {
            //
            // Data on the clipboard uses the 
            // IDataObject interface
            //
            IDataObject dataObject = new DataObject();
            
            try
            {
                dataObject = Clipboard.GetDataObject();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Clip2Web Error: " + ex.ToString());
                return;
            }

            var formats = dataObject.GetFormats();
            
            if(formats.Contains(INTERESTING_FORMAT) || dataObject.GetDataPresent(DataFormats.Bitmap))
            {
                m_imageData = (System.Drawing.Bitmap)dataObject.GetData(DataFormats.Bitmap);
                m_trayIcon.ShowBalloonTip(1000, "Clip Saved!", "Click to copy path", ToolTipIcon.Info);
            }
        }
Example #14
0
        /// <summary>
        /// This method needs heavy revision.
        /// 
        /// Since element on which was module dropped is COM interface IHTMLElement
        /// and that seems like it's not supporting own module tag (it gets removed on whatever operation),
        /// this method adds id to IHTMLElement(if needed), to be able to identify it in HtmlAgilityPack HtmlDocument
        /// then adds preview output as end to that element, then converts document back to COM IHTMLDocument2
        /// 
        /// Doh.
        /// 
        /// TODO: Could use hard refactoring, probably own customized html editor
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void theSite_drop(DataObject sender, DragEventArgs e)
        {
            CFormController.Instance.mainForm.setStatus("Module(s) Added");
            if (sender.GetData("System.Windows.Forms.ListView+SelectedListViewItemCollection", false) != null)
            {
                // Get module preview (multiple modules can be dragged)
                String input = String.Empty;
                ListView.SelectedListViewItemCollection listViewItemModules = (ListView.SelectedListViewItemCollection)sender.GetData("System.Windows.Forms.ListView+SelectedListViewItemCollection", false);
                foreach (ListViewItem listViewItemModule in listViewItemModules)
                {
                    input += CXMLParser.Instance.GetPreviewFromProjectXML(CXMLParser.Instance.GetNodeFromModule(CModuleReader.Instance.GetModuleInstanceFromName(listViewItemModule.Text)).OuterHtml);
                }

                // Get relative drop location
                Point htmlEditorCorner = htmlEditor1.PointToScreen(new Point(0, 0));
                int X = e.X - htmlEditorCorner.X;
                int Y = e.Y - htmlEditorCorner.Y;

                // Get element on which module was dropped
                IHTMLElement hoverElem = htmlEditor1.HtmlDocument2.ElementFromPoint(X, Y);
                IHTMLElement moduleElem = null;

                // If it gets dropped on module, pass its parent element instead
                if(CRestrictedEditDesigner.isModule(hoverElem, out moduleElem))
                {
                    hoverElem = moduleElem;
                }

                if (hoverElem.tagName.Equals("BODY"))
                {
                    Debug.WriteLine("dropped on body");
                    if (hoverElem.innerText == null && hoverElem.innerHTML == null)
                        htmlEditor1.LoadDocument("<body>" + input + "</body>");
                    else
                        htmlEditor1.LoadDocument("<body>" + hoverElem.innerHTML + input + "</body>");
                }
                else
                {
                    Debug.WriteLine("dropped on " + hoverElem.tagName);

                    //Mshtml deletes <module> in element load,
                    //uhm so it has to be converted to HtmlAgilityPack.HtmlDocument
                    //and then back
                    String guid = Guid.NewGuid().ToString();
                    Boolean idChanged;
                    if (hoverElem.id == null)
                    {
                        hoverElem.id = guid;
                        idChanged = true;
                    }
                    else
                    {
                        guid = hoverElem.id;
                        idChanged = false;
                    }

                    // Get wanted element and modify its content
                    HtmlAgilityPack.HtmlDocument htmlDoc = HTMLDocumentConverter.mshtmlDocToAgilityPackDoc(htmlEditor1.HtmlDocument2);
                    HtmlAgilityPack.HtmlNode node = htmlDoc.GetElementbyId(guid);

                    // Dont remove id if it was there before
                    if(idChanged)
                        node.Attributes.Remove("id");

                    // Need to create element, because HtmlNode dont have OuterHtml settable
                    HtmlNode addedModulesNode = htmlDoc.CreateElement("div");
                    addedModulesNode.InnerHtml = input;

                    try
                    {
                        // Well, this sometimes fails.. god knows why
                        htmlDoc.DocumentNode.InsertAfter(addedModulesNode, node);
                    }
                    catch (Exception)
                    {
                        // So if it fails, add module in the end of parent module
                        node.ParentNode.InnerHtml += input;
                    }

                    // And back to IHTMLDocument
                    htmlEditor1.LoadDocument("<body>" + htmlDoc.DocumentNode.InnerHtml + "</body>");
                }
            }
        }
Example #15
0
 public object GetData(string format)
 {
     return(_dao.GetData(format));
 }
Example #16
0
 public virtual void OnToolboxDataItemPicked(ToolboxDataItem dataItem)
 {
     IDesignerHost service = (IDesignerHost) this.ServiceProvider.GetService(typeof(IDesignerHost));
     IDataObject dataObject = dataItem.GetDataObject(service);
     string html = string.Empty;
     if (dataObject != null)
     {
         if (dataObject.GetDataPresent(DataFormats.Html))
         {
             html = dataObject.GetData(DataFormats.Html).ToString();
         }
         else if (dataObject.GetDataPresent(DataFormats.Text))
         {
             html = dataObject.GetData(DataFormats.Text).ToString();
         }
         else if (this.DataObjectConverter.CanConvertToHtml(dataObject) == DataObjectConverterInfo.CanConvert)
         {
             DataObject newDataObject = new DataObject();
             if (this.DataObjectConverter.ConvertToHtml(dataObject, newDataObject))
             {
                 html = (string) newDataObject.GetData(DataFormats.Html);
             }
         }
         BatchedUndoUnit unit = this._editor.OpenBatchUndo("Toolbox");
         try
         {
             this._editor.Document.InsertHtml(html);
         }
         finally
         {
             unit.Close();
         }
     }
 }
Example #17
0
        //protected override void WndProc(ref Message m)
        //{
        //    const int WM_DRAWCLIPBOARD = 0x308;
        //    const int WM_CHANGECBCHAIN = 0x030D;
        //    switch (m.Msg)
        //    {
        //        case WM_DRAWCLIPBOARD:
        //            DisplayClipboardData();
        //            Win32API.SendMessage(nextClipboardViewer, m.Msg, m.WParam, m.LParam);
        //            break;
        //        case WM_CHANGECBCHAIN:
        //            if (m.WParam == nextClipboardViewer)
        //                nextClipboardViewer = m.LParam;
        //            else
        //                Win32API.SendMessage(nextClipboardViewer, m.Msg, m.WParam, m.LParam);
        //            break;
        //        default:
        //            base.WndProc(ref m);
        //            break;
        //    }
        //}
        private void DisplayClipboardData()
        {
            try
            {
                IDataObject iData = new DataObject();
                iData = Clipboard.GetDataObject();

                MessageBox.Show(iData.GetData(DataFormats.UnicodeText).ToString());

                //if (iData.GetDataPresent(DataFormats.Rtf))
                //    richTextBox1.Rtf = (string)iData.GetData(DataFormats.Rtf);
                //else if (iData.GetDataPresent(DataFormats.Text))
                //    richTextBox1.Text = (string)iData.GetData(DataFormats.Text);
                //else
                //    richTextBox1.Text = "[Clipboard data is not RTF or ASCII Text]";
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Example #18
0
		public static void Main ()
		{
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.Bitmap));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.CommaSeparatedValue));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.Dib));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.Dif));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.EnhancedMetafile));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.FileDrop));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.Html));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.Locale));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.MetafilePict));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.OemText));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.Palette));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.PenData));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.Riff));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.Rtf));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.Serializable));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.StringFormat));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.SymbolicLink));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.Text));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.Tiff));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.UnicodeText));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.WaveAudio));

			// Add our own format
			PrintFormatInfo(DataFormats.GetFormat("Birthday"));

			// Test some basic stuff
			DataObject	dobj;
			Control		c;
			string		rtf;

			c = new Control();
			rtf = "\\r\\t\\f  string";

			// Load the data object
			dobj = new DataObject(DataFormats.Text, "I am text");
			dobj.SetData(c.GetType(), c);
			dobj.SetData(DataFormats.Rtf, rtf);

			PrintFormats("GetFormats(): ", dobj.GetFormats());		// Count should be 5
			PrintFormats("GetFormats(true): ", dobj.GetFormats(true));	// Count should be 5
			PrintFormats("GetFormats(false): ", dobj.GetFormats(false));	// Count should be 3

			Console.WriteLine("GetDataPresent(typeof(string)): {0}", dobj.GetDataPresent(typeof(string)));			// We expect true
			Console.WriteLine("GetDataPresent(DataFormats.Text): {0}", dobj.GetDataPresent(DataFormats.Text));		// We expect true
			Console.WriteLine("GetDataPresent(DataFormats.WaveAudio): {0}", dobj.GetDataPresent(DataFormats.WaveAudio));	// We expect false

			Console.WriteLine("GetData(DataFormats.Rtf): {0}", dobj.GetData(DataFormats.Rtf));				// We expect "\r\t\f  string"

			clipboard clip = new clipboard ();

			PrintClipboardContents();

			IDataObject data;

			data = Clipboard.GetDataObject();

			if (data != null && data.GetDataPresent(DataFormats.Bitmap)) {
				image = (Image)Clipboard.GetDataObject().GetData(DataFormats.Bitmap);
			}

			Bitmap i = new Bitmap("test.bmp");
			string s = "bummerä";

			Clipboard.SetDataObject(s);

			Application.Run (clip);
		}
Example #19
0
        private void DisplayClipboardData()
        {
            try
            {
                IDataObject iData = new DataObject();
                iData = Clipboard.GetDataObject();

                MessageBox.Show(iData.GetData(DataFormats.UnicodeText).ToString());
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Example #20
0
        private void DisplayClipboardData()
        {
            if (iniciarToolStripMenuItem.Checked)
            {

                try
                {
                    IDataObject iData = new DataObject();
                    iData = Clipboard.GetDataObject();
                    //if (iData.GetDataPresent(DataFormats.Rtf))
                       // richTextBox1.Rtf = (string)iData.GetData(DataFormats.Rtf);
                   // else if (iData.GetDataPresent(DataFormats.Text))
                        //richTextBox1.Text = (string)iData.GetData(DataFormats.Text);
                    //else
                        if (iData.GetDataPresent(DataFormats.Bitmap))
                        {

                            if (original)
                                img = (Image)iData.GetData(DataFormats.Bitmap);
                            else
                                img = Redimensionar((Image)iData.GetData(DataFormats.Bitmap), width, height, 90);

                            //pictureBox1.Image = Redimensionar((Image)iData.GetData(DataFormats.Bitmap), 160, 120, 90);

                            if (defaultRoute)
                            {

                                ruta = System.Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + "\\imagen" + numImage + ".jpg";

                                //ruta = Application.StartupPath+"\\imagen" + numImage + ".jpg";

                                img.Save(ruta, formato);
                            }
                            else

                                if (!defaultRoute)
                                {

                                    do
                                    {

                                        ruta = folderBrowserDialog1.SelectedPath + @"\imagen" + numImage + ".jpg";
                                        numImage++;
                                    } while (File.Exists(ruta));

                                    FileIOPermission f3 = new FileIOPermission(FileIOPermissionAccess.Write, ruta);

                                    try
                                    {
                                        f3.Demand();
                                    }
                                    catch (SecurityException s)
                                    {
                                        Console.WriteLine(s.Message);
                                    }
                                    img.Save(ruta, formato);
                                }
                            toolStripStatusLabel2.Text = ruta;
                            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                            pictureBox1.ImageLocation = ruta;

                            numImage++;
                            txtruta.Text = ruta;
                            if (notificacionesToolStripMenuItem.Checked)

                            if (!original)
                                notifyIcon1.ShowBalloonTip(1, "Imagen Guardada " + width + "x" + height, ruta, ToolTipIcon.None);
                            else
                                notifyIcon1.ShowBalloonTip(1, "Imagen Guardada " + img.Width + "x" + img.Height, ruta, ToolTipIcon.None);

                        }

                }
                catch (Exception e)
                {

                    MessageBox.Show(e.ToString());
                }
            }
        }
Example #21
0
		public void TestText ()
		{
			DataObject d = new DataObject ();

			d.SetText ("yo");

			Assert.AreEqual (false, d.ContainsAudio (), "A1");
			Assert.AreEqual (false, d.ContainsFileDropList (), "A2");
			Assert.AreEqual (false, d.ContainsImage (), "A3");
			Assert.AreEqual (true, d.ContainsText (), "A4");
			Assert.AreEqual (false, d.ContainsText (TextDataFormat.CommaSeparatedValue), "A5");

			Assert.AreEqual ("yo", d.GetText (), "A6");
			Assert.AreEqual ("yo", d.GetData (DataFormats.StringFormat), "A6-1");
			
			d.SetText ("<html></html>", TextDataFormat.Html);
			Assert.AreEqual (true, d.ContainsText (), "A7");
			Assert.AreEqual (false, d.ContainsText (TextDataFormat.CommaSeparatedValue), "A8");
			Assert.AreEqual (true, d.ContainsText (TextDataFormat.Html), "A9");
			Assert.AreEqual (false, d.ContainsText (TextDataFormat.Rtf), "A10");
			Assert.AreEqual (true, d.ContainsText (TextDataFormat.Text), "A11");
			Assert.AreEqual (true, d.ContainsText (TextDataFormat.UnicodeText), "A12");

			// directly put a string
			d.SetData ("yo");

			Assert.AreEqual (true, d.ContainsText (TextDataFormat.Text), "A13");
			Assert.AreEqual (true, d.ContainsText (TextDataFormat.UnicodeText), "A14");

			Assert.AreEqual ("yo", d.GetData (DataFormats.StringFormat), "A15");
			Assert.AreEqual ("yo", d.GetData (DataFormats.Text), "A16");
			Assert.AreEqual ("yo", d.GetData (DataFormats.UnicodeText), "A17");
		}
Example #22
0
        public static List <string> GetFiles(System.Runtime.InteropServices.ComTypes.IDataObject pDataObj)
        {
            System.Runtime.InteropServices.ComTypes.FORMATETC formatV = new System.Runtime.InteropServices.ComTypes.FORMATETC()
            {
                cfFormat = (Int16)DataFormats.GetFormat(NativeMethods.CFSTR_FILEDESCRIPTORW).Id,
                dwAspect = DVASPECT.DVASPECT_CONTENT,
                tymed    = TYMED.TYMED_HGLOBAL
            };
            System.Runtime.InteropServices.ComTypes.FORMATETC formatShell = new System.Runtime.InteropServices.ComTypes.FORMATETC()
            {
                cfFormat = (Int16)DataFormats.GetFormat(NativeMethods.CFSTR_SHELLIDLIST).Id,
                dwAspect = DVASPECT.DVASPECT_CONTENT,
                tymed    = TYMED.TYMED_HGLOBAL
            };
            System.Runtime.InteropServices.ComTypes.FORMATETC format = new System.Runtime.InteropServices.ComTypes.FORMATETC()
            {
                cfFormat = (Int16)DataFormats.GetFormat(NativeMethods.CF_HDROP).Id,
                dwAspect = DVASPECT.DVASPECT_CONTENT,
                tymed    = TYMED.TYMED_HGLOBAL
            };

            STGMEDIUM medium;

            bool bVirtualData  = true;
            bool bVirtualShell = false;

            try
            {
                pDataObj.GetData(ref formatV, out medium);
            }
            catch (Exception)
            {
                if (pDataObj is System.Windows.Forms.DataObject)
                {
                    List <string> files1 = new List <string>();
                    //medium = new STGMEDIUM();
                    System.Windows.Forms.DataObject dob = (System.Windows.Forms.DataObject)pDataObj;
                    StringCollection z = (StringCollection)dob.GetData(typeof(StringCollection));
                    foreach (string s in z)
                    {
                        files1.Add(s);
                    }

                    /*
                     * if (dob.ContainsFileDropList())
                     * {
                     *  StringCollection c = dob.GetFileDropList();
                     *  foreach (string s in c)
                     *  {
                     *      files1.Add(s);
                     *  }
                     * }
                     * else
                     * {
                     *  string objFormat = dob.GetFormats().FirstOrDefault(x => x.Equals("FileDrop"));
                     *  if (!string.IsNullOrEmpty(objFormat))
                     *  {
                     *      object obj = dob.GetData("FileDrop");
                     *      if (obj is string)
                     *          files1.Add((string)obj);
                     *  }
                     * }
                     */
                    return(files1);
                }
                else
                {
                    int ret = pDataObj.QueryGetData(ref format);
                    if (ret > 0)
                    {
                        bVirtualShell = true;

                        Debug.WriteLine("!!!!SPECIAL FOLDER!!!!");
                        pDataObj.GetData(ref formatShell, out medium);
                    }
                    else
                    {
                        try
                        {
                            pDataObj.GetData(ref format, out medium);
                        }
                        catch (Exception)
                        {
                            bVirtualShell = true;

                            Debug.WriteLine("!!!!SPECIAL FOLDER!!!!");
                            pDataObj.GetData(ref formatShell, out medium);
                        }
                    }

                    /*
                     * if (ret != 0)
                     * {
                     *  Debug.WriteLine("------- GET FORMATS -------");
                     *  IEnumFORMATETC en = pDataObj.EnumFormatEtc(DATADIR.DATADIR_GET);
                     *  System.Runtime.InteropServices.ComTypes.FORMATETC[] fc = new System.Runtime.InteropServices.ComTypes.FORMATETC[10];
                     *  int[] fetched = new int[10];
                     *  int ret1 = en.Next(10, fc, fetched);
                     *  for (int i = 0; i < fetched[0]; i++)
                     *  {
                     *      DataFormats.Format f = DataFormats.GetFormat(fc[i].cfFormat);
                     *
                     *      string sn = f.Name;
                     *      Debug.WriteLine("FORMAT: " + sn);
                     *  }
                     *  Debug.WriteLine("---------------------------");
                     *
                     *  pDataObj.GetData(ref formatShell, out medium);
                     *  IntPtr ptr1;
                     *  ptr1 = medium.unionmember;
                     *  IntPtr ptrLock = NativeMethods.GlobalLock(ptr1);
                     *
                     *
                     *  List<IntPtr> lsUnk = ProcessCIDA(ptrLock);
                     *  foreach (IntPtr intPtr in lsUnk)
                     *  {
                     *      foreach (Environment.SpecialFolder suit in Enum.GetValues(typeof(Environment.SpecialFolder)))
                     *      {
                     *          var desktopPIDL = IntPtr.Zero;
                     *          int r = Shell32.SHGetSpecialFolderLocation(IntPtr.Zero, (int)suit, ref desktopPIDL);
                     *
                     *          string spath = Environment.GetFolderPath(suit);
                     *
                     *
                     *          string s1 = PidlManager.GetPidlDisplayName(desktopPIDL);
                     *          string s2 = PidlManager.GetPidlDisplayName(intPtr);
                     *
                     *          bool be = Shell32.ILIsEqual(intPtr, desktopPIDL);
                     *          if (be || s1.Equals(s2))
                     *          {
                     *              ItemIdList iptm = ItemIdList.Create(desktopPIDL);
                     *              byte[][] b = iptm.GetItemData();
                     *              string s = "finded!!!:" + suit;
                     *
                     *              ItemIdList iptm1 = ItemIdList.Create(intPtr);
                     *              byte[][] b1 = iptm1.GetItemData();
                     *          }
                     *      }
                     *
                     *      Shell32.ILFree(intPtr);
                     *  }
                     *
                     *  IntPtr ptrUnLock = NativeMethods.GlobalUnlock(ptrLock);
                     *
                     * }
                     * else
                     * {
                     *  pDataObj.GetData(ref format, out medium);
                     * }
                     */
                }

                bVirtualData = false;
            }

            IntPtr ptr;

            ptr = medium.unionmember;

            List <string> files = new List <string>();

            if (bVirtualData)
            {
                GetVirtualFileNamesFromDataObject(ptr, ref files);
            }
            else
            {
                if (!bVirtualShell)
                {
                    GetFileNamesFromDataObject(ptr, ref files);
                }
                else
                {
                    GetSystemVirtualFileNamesFromDataObject(ptr, ref files);
                }
            }

            NativeMethods.ReleaseStgMedium(ref medium);


            return(files);
        }