コード例 #1
1
        private IDataObject CloneClipboard(IDataObject obj)
        {
            if (obj == null)
                return null;

            string[] formats = obj.GetFormats();
            if (formats.Length == 0)
                return null;

            IDataObject newObj = new DataObject();
            
            foreach (string format in formats)
            {
				if (format.Contains("EnhancedMetafile")) //Ignore this. Cannot be processed in .NET
					continue;

				object o = obj.GetData(format);

                if (o != null)
                {
                    newObj.SetData(o);
                }
            }

            return newObj;
        }
        public bool LimitDragDropOptions(IDataObject data)
        {
            var formats = data.GetFormats();
            if(!formats.Any())
            {
                return true;
            }


            var modelItemString = formats.FirstOrDefault(s => s.IndexOf("ModelItemsFormat", StringComparison.Ordinal) >= 0);
            if(!String.IsNullOrEmpty(modelItemString))
            {
                var innnerObjectData = data.GetData(modelItemString);
                var modelList = innnerObjectData as List<ModelItem>;
                if(modelList != null && modelList.Count > 1)
                {
                    if(modelList.FirstOrDefault(c => c.ItemType == typeof(FlowDecision) || c.ItemType == typeof(FlowSwitch<string>)) != null)
                    {
                        return false;
                    }
                }
            }

            modelItemString = formats.FirstOrDefault(s => s.IndexOf("ModelItemFormat", StringComparison.Ordinal) >= 0);
            if(String.IsNullOrEmpty(modelItemString))
            {
                modelItemString = formats.FirstOrDefault(s => s.IndexOf("WorkflowItemTypeNameFormat", StringComparison.Ordinal) >= 0);
                if(String.IsNullOrEmpty(modelItemString))
                {
                    return true;
                }
            }
            var objectData = data.GetData(modelItemString);
            return DropPointOnDragEnter(objectData);
        }
コード例 #3
0
        static string GetImageUrl(IDataObject data)
        {
            var fileDrops = (string[])data.GetData(DataFormats.FileDrop);
            if (fileDrops?.Length >= 1) return fileDrops[0];

            var text = (string)data.GetData(DataFormats.UnicodeText);
            return text;
        }
コード例 #4
0
ファイル: CommonUtil.cs プロジェクト: ctsyolin/ieunit
        public static string GetDataFilePath(IDataObject data) {
            string fileName = null;
            string[] fileNames = (string[]) data.GetData(DataFormats.FileDrop);
            if ( (fileNames != null) && (fileNames.Length > 0) ) {
                fileName = fileNames[0];
            } else {
                fileName = (string) data.GetData("UnicodeText");
            }

            return fileName;
        }
コード例 #5
0
        public bool IsValidDataObject(IDataObject obj)
        {
            bool result = false;

            var elt = (FrameworkElement)this.TargetUI;

            var storeItemVM = elt.DataContext as StoreItemViewModelBase;
            //var channelVM = elt.DataContext as ChannelViewModel;

            if (storeItemVM != null)
            {
                if (obj.GetDataPresent(typeof(StoreItemViewModelBase[])))
                {
                    var data = (StoreItemViewModelBase[])obj.GetData(typeof(StoreItemViewModelBase[]));

                    result = data != null && data.Length > 0;
                    //.Any(droppedStoreItemVM => !channelListVM.Contains(droppedChannelVM));
                }
            }
            //else if (channelVM != null)
            //{
            //    if (obj.GetDataPresent(typeof(ChannelViewModel[])))
            //    {
            //        var data = (ChannelViewModel[])obj.GetData(typeof(ChannelViewModel[]));

            //        result = data
            //            .Any(droppedChannelVM => channelVM != droppedChannelVM);
            //    }
            //}

            return result;
        }
コード例 #6
0
ファイル: DragDropHandler.cs プロジェクト: Pjanssen/Outliner
 public static OutlinerNode[] GetNodesFromDataObject(IDataObject dragData)
 {
     if (dragData.GetDataPresent(typeof(OutlinerNode[])))
         return (OutlinerNode[])dragData.GetData(typeof(OutlinerNode[]));
     else
         return null;
 }
コード例 #7
0
        private void ProcessFileNames(IDataObject obj, string format)
        {
            try
            {
                var fileNames = obj.GetData(format, true) as string[];

                var fileName = fileNames.FirstOrDefault();

                if (fileName != null)
                {
                    var file = File.ReadAllBytes(fileName);



                    using (var ms = new System.IO.MemoryStream(file))
                    {
                        var image = new BitmapImage();
                        image.BeginInit();
                        image.CacheOption = BitmapCacheOption.OnLoad; // here
                        image.StreamSource = ms;
                        image.EndInit();
                        ViewModel.Model.SquareDraft = image;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().Name, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #8
0
		public override void Drop(IDataObject data, int index, DropEffect finalEffect)
		{
			try {
				string insertText = (data.GetData(typeof(string[])) as string[])
					.Aggregate((text, part) => text += part);
				ITextAnchor marker;
				int length = 0;
				if (index == this.Children.Count) {
					if (index == 0)
						marker = null;
					else
						marker = (this.Children[index - 1] as XamlOutlineNode).EndMarker;
					if (marker == null) {
						marker = this.EndMarker;
						length = -1; // move backwards
					} else {
						length = 2 + (this.Children[index - 1] as XamlOutlineNode).elementName.Length;
					}
				} else
					marker = (this.Children[index] as XamlOutlineNode).Marker;
				
				int offset = marker.Offset + length;
				Editor.Document.Insert(offset, insertText);
			} catch (Exception ex) {
				throw ex;
			}
		}
コード例 #9
0
        public override bool Search(string fullFileName, string searchTerm)
        {
            Document document    = null;
            Regex    searchRegex = new Regex(searchTerm, RegexOptions.IgnoreCase);

            try
            {
                document = application.Documents.Open(fullFileName);
                document.ActiveWindow.Selection.WholeStory();
                document.ActiveWindow.Selection.Copy();
                IDataObject data = Clipboard.GetDataObject();
                if (data?.GetData(DataFormats.Text) == null)
                {
                    return(false);
                }

                string currentWordFile = data.GetData(DataFormats.Text).ToString();
                return(searchRegex.IsMatch(currentWordFile));
            }
            catch (Exception e1)
            {
                Logger.Error($"Error searching for {searchTerm} in {fullFileName}", e1);
                return(false);
            }
            finally
            {
                document?.Close();
            }
        }
コード例 #10
0
ファイル: DropTargetBase.cs プロジェクト: atombender/learning
 public virtual UIElement ExtractElement(IDataObject obj)
 {
     string xamlString = obj.GetData(supportedFormat) as string;
     XmlReader reader = XmlReader.Create(new StringReader(xamlString));
     UIElement elt = XamlReader.Load(reader) as UIElement;
     return elt;
 }
コード例 #11
0
        /// <summary>
        /// Attempts to create a new HTMLData.  This can return null if the DataObject
        /// couldn't be created based upon the IDataObject.
        /// </summary>
        /// <param name="iDataObject">The IDataObject from which to create the HTML Data Object</param>
        /// <returns>The HTMLData, null if it couldn't be created.</returns>
        public static HTMLData Create(IDataObject iDataObject)
        {
            string[] loser = iDataObject.GetFormats();

            if (OleDataObjectHelper.GetDataPresentSafe(iDataObject, DataFormats.Html))
            {

                try
                {
                    HTMLData data = new HTMLData(iDataObject, null);
                    return string.IsNullOrEmpty(data.HTML) ? null : data;
                }
                catch (FormatException)
                {
                    // EML files with HTML inside of them report that they are HTML
                    // However, when we try to read the format, we have problems reading it
                    // So we will skip loading html that we cannot load
                    return null;
                }

            }
            else if (HtmlDocumentClassFormatPresent(iDataObject))
            {
                return new HTMLData(iDataObject, (IHTMLDocument2)iDataObject.GetData(typeof(HTMLDocumentClass)));
            }
            else
                return null;
        }
コード例 #12
0
        // Retrieves the text from the IDataObject instance.
        // Then create a textbox with the text data. 
        protected override void DoPaste(IDataObject dataObject) 
        {
            ElementList = new List<UIElement>(); 

            // Get the string from the data object.
            string text = dataObject.GetData(DataFormats.UnicodeText, true) as string;
 
            if ( String.IsNullOrEmpty(text) )
            { 
                // OemText can be retrieved as CF_TEXT. 
                text = dataObject.GetData(DataFormats.Text, true) as string;
            } 

            if ( !String.IsNullOrEmpty(text) )
            {
                // Now, create a text box and set the text to it. 
                TextBox textBox = new TextBox();
 
                textBox.Text = text; 
                textBox.TextWrapping = TextWrapping.Wrap;
 
                // Add the textbox to the internal array list.
                ElementList.Add(textBox);
            }
 
        }
コード例 #13
0
		public void OnDropCompleted(IDataObject obj, Point dropPoint)
		{
			string serializedObject = obj.GetData(SupportedFormat.Name) as string;
			XmlReader reader = XmlReader.Create(new StringReader(serializedObject));
			UIElement elt = XamlReader.Load(reader) as UIElement;

			(TargetUI as Panel).Children.Add(elt);
		}
コード例 #14
0
ファイル: FolderNode.cs プロジェクト: Bombadil77/SharpDevelop
		public override DropEffect CanDrop(IDataObject data, DropEffect requestedEffect)
		{
			var paths = data.GetData(typeof(string[])) as string[];
			if (paths != null) {
				return requestedEffect == DropEffect.Link ? DropEffect.Move : requestedEffect;
			}
			return DropEffect.None;
		}
 protected virtual bool CanDropDataObject(IDataObject dataObj)
 {
     if (dataObj != null)
     {
         if (dataObj is ComponentDataObjectWrapper)
         {
             object[] draggingObjects = this.GetDraggingObjects(dataObj, true);
             if (draggingObjects == null)
             {
                 return false;
             }
             bool flag = true;
             for (int i = 0; flag && (i < draggingObjects.Length); i++)
             {
                 flag = (flag && (draggingObjects[i] is IComponent)) && this.client.IsDropOk((IComponent) draggingObjects[i]);
             }
             return flag;
         }
         try
         {
             object data = dataObj.GetData(DataFormat, false);
             if (data == null)
             {
                 return false;
             }
             IDesignerSerializationService service = (IDesignerSerializationService) this.GetService(typeof(IDesignerSerializationService));
             if (service == null)
             {
                 return false;
             }
             ICollection is2 = service.Deserialize(data);
             if (is2.Count > 0)
             {
                 bool flag2 = true;
                 foreach (object obj3 in is2)
                 {
                     if (obj3 is IComponent)
                     {
                         flag2 = flag2 && this.client.IsDropOk((IComponent) obj3);
                         if (!flag2)
                         {
                             return flag2;
                         }
                     }
                 }
                 return flag2;
             }
         }
         catch (Exception exception)
         {
             if (System.Windows.Forms.ClientUtils.IsCriticalException(exception))
             {
                 throw;
             }
         }
     }
     return false;
 }
コード例 #16
0
		public object GetDropData(IDataObject obj)
		{
			string serializedObject = obj.GetData(SupportedFormat.Name) as string;
			if (string.IsNullOrEmpty(serializedObject))
				return null;

			XmlReader reader = XmlReader.Create(new StringReader(serializedObject));
			return XamlReader.Load(reader) as UIElement;
		}
コード例 #17
0
        /// <summary>
        /// Determines the offset of the drag.
        /// </summary>
        /// <param name="obj">The data object that describes the data that is being dragged.</param>
        /// <returns>The point indicating the offset.</returns>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="obj"/> is <see langword="null" />.
        /// </exception>
        public Point GetOffsetPoint(IDataObject obj)
        {
            {
                Lokad.Enforce.Argument(() => obj);
            }

            var p = (Point)obj.GetData(DragDropHelpers.OffsetPointDataFormatName);
            return p;
        }
コード例 #18
0
        /// <summary>
        /// Creates the UI element that is used as the drag feedback item.
        /// </summary>
        /// <param name="obj">The data object that describes the data that is being dragged.</param>
        /// <returns>An UI element that is used as the drag object.</returns>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="obj"/> is <see langword="null" />.
        /// </exception>
        public UIElement GetVisualFeedback(IDataObject obj)
        {
            {
                Lokad.Enforce.Argument(() => obj);
            }

            var storedObject = obj.GetData(s_SupportedFormat.Name);
            return DragDropManager.GetDragVisualizationFor(TargetUI, storedObject);
        }
コード例 #19
0
ファイル: Item.cs プロジェクト: dzamkov/DUIP
        /// <summary>
        /// Gets an item from a data object.
        /// </summary>
        public static Item FromDataObject(IDataObject Object)
        {
            string[] formats = Object.GetFormats();

            string text = Object.GetData("Text") as string;
            if (text != null)
            {
                return new StringItem(text);
            }

            string[] file = (Object.GetData("FileNameW") as string[]) ?? (Object.GetData("FileName") as string[]);
            if (file != null && file.Length == 1)
            {
                return new StandardFileItem(file[0]);
            }

            return null;
        }
コード例 #20
0
ファイル: user.cs プロジェクト: krikelin/BungaSpotify-2009
        public override void DropItem(IDataObject data)
        {
            String d = (String)data.GetData(DataFormats.StringFormat);
            Track track = new Track(this.Host.MusicService, d.Split(':')[2]);
            track.LoadAsync(new { });
            bool dw = this.Host.MusicService.InsertTrack(this.Playlist, track, 0);
            this.Playlist.Tracks.Insert(0, track);

            this.Render();
        }
コード例 #21
0
 protected override string GetTextFromDataObject(IDataObject dataObject, IServiceProvider serviceProvider)
 {
     if (dataObject.GetDataPresent(CodeWizard.CodeWizardDataFormat))
     {
         string codeWizardTypeName = dataObject.GetData(CodeWizard.CodeWizardDataFormat).ToString();
         CodeWizardHost host = new CodeWizardHost(serviceProvider);
         return host.RunCodeWizard(codeWizardTypeName, this.CodeDomProvider);
     }
     return base.GetTextFromDataObject(dataObject, serviceProvider);
 }
コード例 #22
0
        IEnumerable<String> GetPdfFiles(IDataObject dataObject)
        {
            String[] files = (String[])dataObject.GetData("FileDrop");
            if (files == null) { return null; }

            // TODO: instead of ".pdf", get supported formats from BookLibrary
            var pdfs = files.Where(x => Path.GetExtension(x).EqualsIC(".pdf"));
            if (pdfs.FirstOrDefault() == null) { return null; }
            return pdfs;
        }
コード例 #23
0
ファイル: WordListEntries.cs プロジェクト: dbremner/szotar
		public static WordListEntries FromDataObject(IDataObject data) {
			if (data == null)
				return null;

			var wle = data.GetData(typeof(WordListEntries)) as WordListEntries;
			if (wle != null)
				return wle;

			var searchResults = data.GetData(typeof(TranslationPair[])) as TranslationPair[];
			if (searchResults != null) {
				var entries = new List<WordListEntry>();
				foreach (var sr in searchResults)
					entries.Add(new WordListEntry(null, sr.Phrase, sr.Translation));
				return new WordListEntries(null, entries);
			}

			// Try to parse as CSV.
			return FromDelimitedText(GetText(data));			
		}
コード例 #24
0
 public static void SaveClipboardImageToFile(IDataObject data, string fileName)
 {
     using (Bitmap image = (Bitmap)data.GetData(DataFormats.Bitmap))
     using (MemoryStream ms = new MemoryStream())
     {
         image.Save(ms, GetImageFormat(Path.GetExtension(fileName)));
         byte[] buffer = ms.ToArray();
         File.WriteAllBytes(fileName, buffer);
     }
 }
コード例 #25
0
        private string GetText(IDataObject dataObject)
        {
            if(dataObject.GetDataPresent(DataFormats.UnicodeText))
            {
                var text = dataObject.GetData(DataFormats.UnicodeText);
                return text?.ToString() ?? "";

            }
            return "";
        }
コード例 #26
0
ファイル: FileDrop.cs プロジェクト: neurocache/ilSFV
		/// <summary>
		/// Gets the list of <see cref="FileDrop"/> from the specified <see cref="IDataObject"/>. Includes objects dragged from Explorer and Outlook.
		/// </summary>
		/// <param name="data">The <see cref="IDataObject"/>.</param>
		/// <returns>The list of <see cref="FileDrop"/> from the specified <see cref="IDataObject"/>.</returns>
		public static List<FileDrop> GetList(IDataObject data)
		{
			List<FileDrop> list = new List<FileDrop>();

			if (data != null)
			{
				if (data.GetDataPresent("FileDrop"))
				{
					string[] fileNames = data.GetData("FileDrop") as string[];

					if (fileNames != null && fileNames.Length > 0)
					{
						foreach (string fileName in fileNames)
						{
							list.Add(new FileDrop(fileName));
						}
					}
				}
				else if (data.GetDataPresent("FileGroupDescriptor"))
				{
					Stream stream = (Stream)data.GetData("FileGroupDescriptor");
					byte[] fileGroupDescriptor = new byte[512];
					stream.Read(fileGroupDescriptor, 0, 512);

					// build the filename from the FileGroupDescriptor block
					StringBuilder fileName = new StringBuilder();
					for (int i = 76; fileGroupDescriptor[i] != 0; i++)
					{
						fileName.Append(Convert.ToChar(fileGroupDescriptor[i]));
					}
					stream.Close();

					MemoryStream ms = (MemoryStream)data.GetData("FileContents", true);
					byte[] fileBytes = new byte[ms.Length];
					ms.Position = 0;
					ms.Read(fileBytes, 0, (int)ms.Length);

					list.Add(new FileDrop(fileName.ToString(), fileBytes));
				}
			}

			return list;
		}
コード例 #27
0
ファイル: Form1.cs プロジェクト: madcapsoftware/web-xslt
        private void button1_Click(object sender, System.EventArgs e)
        {
            ido = Clipboard.GetDataObject();

            try
            {
                string datastr = ido.GetData(comboBox1.Text).ToString();
                if (datastr == "System.IO.MemoryStream") throw new Exception();
                textBox2.Text = datastr;
            }
            catch
            {

                var data = (MemoryStream)ido.GetData(comboBox1.Text);

                if (data == null)
                {
                    textBox2.Text = "No \"" + comboBox1.Text + "\" on Clipboard\r\nAvailable formats:\r\n";
                    for (var i = 0; i < ido.GetFormats().Length; i++)
                    {
                        textBox2.Text += ido.GetFormats()[i] + " " + ido.GetFormats()[i].GetType();
                        textBox2.Text += "\r\n";
                    }

                }
                else
                {
                    string mathMl;
                    using (data)
                    {
                        using (var sr = new StreamReader(data))
                        {
                            mathMl = sr.ReadToEnd();
                        }
                    }

                    textBox2.Text = mathMl.Replace("><", ">\r\n<");
                }
                // good, for text
                //textBox2.Text = (string)ido.GetData(DataFormats.UnicodeText);
            }
        }
コード例 #28
0
 /// <summary>
 /// Creates a BrowserData based upon an IDataObject
 /// </summary>
 /// <param name="iDataObject">The IDataObject from which to create the BrowserData</param>
 /// <returns>The BrowserData, null if no BrowserData could be created</returns>
 public static BrowserData Create(IDataObject iDataObject)
 {
     // Validate required format
     BrowserClipboardData browserClip = (BrowserClipboardData)iDataObject.GetData(FORMAT_NAME);
     if (browserClip != null)
     {
         return new BrowserData(iDataObject, browserClip);
     }
     else
         return null;
 }
コード例 #29
0
ファイル: MainWindow.xaml.cs プロジェクト: ufcpp/UfcppSample
        private string Parse(IDataObject data, Mode mode)
        {
            var html = data.GetData(DataFormats.Html) as string;

            if (html != null)
            {
                var p = new HtmlParser(mode);
                return p.Parse(html);
            }

            var rtf = data.GetData(DataFormats.Rtf) as string;

            if (rtf != null)
            {
                var p = new RtfParser(mode);
                return p.Parse(rtf);
            }

            return null;
        }
コード例 #30
0
 /// <summary>
 /// 
 /// </summary>
 /// <returns>null if data isn't in this format</returns>
 public static SerializableUniverse GetFromWindowsClipboard(IDataObject dataBlob)
 {
     SerializableUniverse retVal = null;
     if (dataBlob.GetDataPresent(typeof(SerializableUniverse)))
     {
         // someday, we might worry about this
         // System.Runtime.InteropServices.COMException
         // but not now
         retVal = (SerializableUniverse)dataBlob.GetData(typeof(SerializableUniverse));
     }
     return retVal;
 }
コード例 #31
0
        protected String GetFileNameFromDrop(IDataObject dropData)
        {
            String result = String.Empty;

            if (dropData.GetDataPresent(DataFormats.FileDrop))
            {
                String[] files = (string[])dropData.GetData(DataFormats.FileDrop);
                result = files[0];
            }

            return result;
        }
コード例 #32
0
        void IDropTarget.Drop(object source, IDataObject data)
        {
            // do something with the dropped data in our view model
            var s = data?.GetData(DataFormats.CommaSeparatedValue) as string;

            if (s != null)
            {
                var split = s.Split(new [] { ',', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var item in split)
                {
                    if (!String.IsNullOrEmpty(item))
                    {
                        Items.Add(item);
                    }
                }
            }
        }
コード例 #33
0
ファイル: IdeService.cs プロジェクト: teksoi/codestream
        /// <summary>
        /// https://stackoverflow.com/questions/518701/clipboard-gettext-returns-null-empty-string
        /// </summary>
        /// <remarks>Only works when apartmentState is STA</remarks>
        /// <returns></returns>
        public string GetClipboardText()
        {
            IDataObject idat = null;
            // ReSharper disable once NotAccessedVariable
            Exception threadEx = null;
            object    text     = "";

            System.Threading.Thread staThread = new System.Threading.Thread(
                delegate() {
                try {
                    idat = Clipboard.GetDataObject();
                    text = idat?.GetData(DataFormats.Text);
                }
                catch (Exception ex) {
                    threadEx = ex;
                }
            });
            staThread.SetApartmentState(ApartmentState.STA);
            staThread.Start();
            staThread.Join();

            return(text as string);
        }
コード例 #34
0
        /// <summary>
        /// Loads from clipboard
        /// </summary>
        /// <param name="setter">Setter</param>
        public static void LoadFromClipboard(this ISeriesSetter setter)
        {
            IDataObject dob = Clipboard.GetDataObject();

            string[] form = dob.GetFormats();
            foreach (string f in form)
            {
                Type type = Type.GetType(f + ",Chart.Drawing", false);
                if (type == null)
                {
                    continue;
                }
                if (type.GetInterface(typeof(ISeries).Name) == null)
                {
                    continue;
                }
                ISeries s = dob.GetData(f) as ISeries;
                if (s != null)
                {
                    setter.Series = s;
                    break;
                }
            }
        }
コード例 #35
0
ファイル: Aufg6.cs プロジェクト: Saritus/WinProg
    private void button2_Click(object sender, System.EventArgs e)
    {
        SaveFileDialog sfd = new SaveFileDialog();

        sfd.InitialDirectory = "G:\\winprog\\winprog\\bin";
        sfd.Filter           = "Textdateien|*.txt|Rich Text Format|*.rtf|Alle Dateien|*.*";
        if (sfd.ShowDialog() == DialogResult.OK)
        {
            switch (Path.GetExtension(sfd.FileName))
            {
            case ".txt":
                richTextBox1.SaveFile(sfd.FileName, RichTextBoxStreamType.PlainText);
                break;

            case ".rtf":
                richTextBox1.SaveFile(sfd.FileName);
                break;

            case ".html":
                TextWriter tw = new StreamWriter(sfd.FileName);
                richTextBox1.SelectAll();
                richTextBox1.Copy();
                IDataObject iData = Clipboard.GetDataObject();
                string[]    f     = iData.GetFormats();
                string      rtf   = (string)iData.GetData(DataFormats.Rtf);
                break;

            default:
                //richTextBox1.Text = "Unknown file extension " + Path.GetExtension(ofd.FileName);
                richTextBox1.SaveFile(sfd.FileName, RichTextBoxStreamType.PlainText);
                break;
            }
            //richTextBox1.LoadFile(ofd.FileName);
            //richTextBox1.Text = ofd.FileName;
        }
    }
コード例 #36
0
        public static string GetTextFromClipboard()
        {
            //
            // http://msdn.microsoft.com/en-us/library/system.windows.forms.clipboard.aspx
            //
            string clipboardText = "";

            // Declares an IDataObject to hold the data returned from the clipboard.
            // Retrieves the data from the clipboard.
            IDataObject iData = Clipboard.GetDataObject();

            // Determines whether the data is in a format you can use.
            if (iData.GetDataPresent(DataFormats.Text))
            {
                // Yes it is.
                clipboardText = (String)iData.GetData(DataFormats.Text);
            }
            else
            {
                // No it is not.
            }

            return(clipboardText);
        }
コード例 #37
0
ファイル: MessageQueue.cs プロジェクト: heng222/MyRepository
        private LiveMessageItem GetDragObject(object sender, IDataObject data)
        {
            object[] obj  = data.GetData(typeof(object[])) as object[];
            var      item = obj[1] as LiveMessageItem;

            if (item != null)
            {
                return(item);
            }
            else
            {
                return(null);
            }

            /*
             * string result = "";
             * string name=item.Name;
             * string length = item.LengthText;
             * result = name;
             * if (!string.IsNullOrEmpty(result))
             *  return result;
             * else
             *  return "";*/
        }
コード例 #38
0
        private object GetDataFromDataObject(IDataObject dataObject, string dataFormat, bool autoConvert)
        {
            object data = null;

            try
            {
                data = dataObject.GetData(dataFormat, autoConvert);
            }
            catch (System.Runtime.InteropServices.COMException)
            {
                // Fail to get the data by the invalid value like tymed(DV_E_TYMED) 
                // or others(Aspect, Formatetc).
                // It depends on application's IDataObject::GetData implementation.
                clipboardInfo.AppendText("Fail to get data!!! ***COMException***");
            }
            catch (OutOfMemoryException)
            {
                // Fail by the out of memory from getting data on Clipboard. 
                // Occurs with the low memory.
                clipboardInfo.AppendText("Fail to get data!!! ***OutOfMemoryException***");
            }

            return data;
        }
コード例 #39
0
        /// <summary>
        /// 이미지 이름으로 찾는다.
        /// </summary>
        /// <param name="imgName">이미지파일명이나 herf 경로</param>
        /// <returns></returns>
        public Image Image_Get(string imgName)
        {
            string strElName;

            mshtml.IHTMLElement2     body2        = (mshtml.IHTMLElement2)HTMLDoc.body;
            mshtml.IHTMLControlRange controlRange = (mshtml.IHTMLControlRange)body2.createControlRange();
            IHTMLElementCollection   imgs         = HTMLDoc.images;

            Image image = null;

            foreach (mshtml.HTMLImg objImg in imgs)
            {
                if (objImg.nameProp != imgName && objImg.href != imgName)
                {
                    continue;
                }


                controlRange.add((mshtml.IHTMLControlElement)objImg);
                controlRange.execCommand("Copy", false, System.Reflection.Missing.Value);
                controlRange.remove(0);
                strElName = objImg.nameProp;

                if (Clipboard.GetDataObject() != null)
                {
                    IDataObject data = Clipboard.GetDataObject();

                    if (data.GetDataPresent(DataFormats.Bitmap))
                    {
                        image = (Image)data.GetData(DataFormats.Bitmap, true);
                    }
                }
            }

            return(image);
        }
コード例 #40
0
 private void openLaboratoryManualToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (OpenFileDialog ofd = new OpenFileDialog()
     {
         ValidateNames = true, Multiselect = false, Filter = "Word Document|*.docx|Word 97 - 2003 Document|*.doc"
     })
     {
         if (ofd.ShowDialog() == DialogResult.OK)
         {
             object readOnly = true;
             object visible  = true;
             //object save = false;
             object fileName = ofd.FileName;
             MessageBox.Show(fileName.ToString());
             object missing = Type.Missing;
             //object newTemplate = false;
             //object docType = 0;
             Microsoft.Office.Interop.Word._Document    oDoc  = null;
             Microsoft.Office.Interop.Word._Application oWord = new Microsoft.Office.Interop.Word.Application()
             {
                 Visible = false
             };
             oDoc = oWord.Documents.Open(
                 ref fileName, ref missing, ref readOnly, ref missing,
                 ref missing, ref missing, ref missing, ref missing,
                 ref missing, ref missing, ref missing, ref visible,
                 ref missing, ref missing, ref missing, ref missing);
             oDoc.ActiveWindow.Selection.WholeStory();
             oDoc.ActiveWindow.Selection.Copy();
             IDataObject data = Clipboard.GetDataObject();
             rtfData.Rtf = data.GetData(DataFormats.Rtf).ToString();
             oWord.Quit(ref missing, ref missing, ref missing);
             lblExpTitle.Text = fileName.ToString();
         }
     }
 }
コード例 #41
0
 public static FileShellOpt GetFileOprationFromClipboard()
 {
     try
     {
         IDataObject  o          = Clipboard.GetDataObject();
         object       opt        = o.GetData("Preferred DropEffect");
         byte[]       moveEffect = new byte[] { 0, 0, 0, 0 };
         MemoryStream stream     = opt as MemoryStream;
         stream.Read(moveEffect, 0, 4);
         if (moveEffect[0] == 2)
         {
             return(FileShellOpt.CUT);
         }
         else
         {
             return(FileShellOpt.COPY);
         }
     }
     catch (Exception ee)
     {
         Logger.E(ee);
     }
     return(FileShellOpt.COPY);
 }
コード例 #42
0
            private void ClipChanged()
            {
                IDataObject     iData  = null;
                ClipboardFormat?format = null;

                try
                {
                    iData = System.Windows.Forms.Clipboard.GetDataObject();

                    foreach (var f in formats)
                    {
                        if (iData.GetDataPresent(f))
                        {
                            format = (ClipboardFormat)Enum.Parse(typeof(ClipboardFormat), f);
                            break;
                        }
                    }

                    object data = iData.GetData(format.ToString());

                    if (data == null || format == null)
                    {
                        return;
                    }

                    if (OnClipboardChange != null)
                    {
                        OnClipboardChange((ClipboardFormat)format, data);
                    }
                }
                catch (ExternalException ex)
                {
                    // The internal implements will raise the ExternalExcption
                    // when the clipboard is being used by the another process.
                }
            }
コード例 #43
0
        private async void Window_Drop(object sender, DragEventArgs e)
        {
            IDataObject data = e.Data;

            if (data.GetDataPresent(DataFormats.FileDrop))
            {
                object value     = data.GetData(DataFormats.FileDrop);
                var    filenames = value as string[];
                if (filenames != null && filenames.Length > 0)
                {
                    string firstFile = filenames.FirstOrDefault(FileUtility.IsSupportedFile);
                    if (firstFile != null)
                    {
                        e.Handled = true;

                        bool canceled = AskToSaveCurrentFile();
                        if (!canceled)
                        {
                            await OpenLocalPackage(firstFile);
                        }
                    }
                }
            }
        }
コード例 #44
0
        protected override void OnDragDrop(DragEventArgs drgevent)
        {
            if ((drgevent.AllowedEffect & DragDropEffects.Link) == DragDropEffects.Link)
            {
                drgevent.Effect = DragDropEffects.Link;
            }

            IDataObject iData = drgevent.Data;

            if (iData.GetDataPresent(DataFormats.FileDrop))
            {
                string[] files = (string[])iData.GetData(DataFormats.FileDrop);

                foreach (string file in files)
                {
                    if (File.Exists(file))
                    {
                        InternalOpenFile(file);
                    }
                }
            }

            base.OnDragDrop(drgevent);
        }
コード例 #45
0
        public void Paste()
        {
            IDataObject dataObject = Clipboard.GetDataObject();

            if (dataObject.GetDataPresent(typeof(Hashtable).FullName))
            {
                Hashtable dictionary = (Hashtable)dataObject.GetData(typeof(Hashtable));

                foreach (DictionaryEntry n in dictionary)
                {
                    if (!this.ContainsName((string)n.Key))
                    {
                        ICloneable   cloneable = (ICloneable)n.Value;
                        object       value     = cloneable.Clone();
                        ResourceItem item      = this.AddResource((string)n.Key, value);
                        item.Selected = true;
                    }
                    else
                    {
                        MessageBox.Show(this, "Resource \'" + n.Key + "\' already exists.", StringTable.GetString("ApplicationName"));
                    }
                }
            }
        }
コード例 #46
0
ファイル: ClipboardContents.cs プロジェクト: t00/KeePassCore
        private void GetDataPriv(bool bSimpleOnly)
        {
            if (bSimpleOnly)
            {
                if (ClipboardUtil.ContainsText())
                {
                    m_strText = ClipboardUtil.GetText();
                }
            }
            else             // Advanced backup
            {
                m_vContents = new List <KeyValuePair <string, object> >();

                IDataObject idoClip = Clipboard.GetDataObject();
                foreach (string strFormat in idoClip.GetFormats())
                {
                    KeyValuePair <string, object> kvp =
                        new KeyValuePair <string, object>(strFormat,
                                                          idoClip.GetData(strFormat));

                    m_vContents.Add(kvp);
                }
            }
        }
コード例 #47
0
        //
        // The rest of the methods are derived from the WPF implementation of getting
        // data from an OLE IDataObject. We use our own logic because there are built in
        // mechanisms within WPF that result in retries on getting clipboard data which
        // is undesirable for paths that check the clipboard data in a hot path.
        // See https://github.com/dotnet/wpf/blob/212f376fbca58bf2970964610c426ee05e633872/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/dataobject.cs
        // for information on how dataobject is used in WPF. This code only supports
        // a subset of the functionality for now because it is limited to text.
        //
        private static string?GetData(IDataObject dataObject, FORMATETC format)
        {
            var af = new FORMATETC[1];

            af[0] = format;
            var sm = new STGMEDIUM[1];

            dataObject.GetData(af, sm);
            var medium = sm[0];

            try
            {
                if (medium.tymed != 1) // TYMED_HGLOBAL
                {
                    return(null);
                }

                return(ReadStringFromHandle(medium.unionmember, format.cfFormat == CF_UNICODETEXT));
            }
            finally
            {
                ReleaseStgMedium(ref medium);
            }
        }
コード例 #48
0
        private static string GetClipboardText()
        {
            string Result    = string.Empty;
            Thread staThread = new Thread(x =>
            {
                try
                {
                    string ResultText        = Clipboard.GetText();
                    IDataObject myDataObject = Clipboard.GetDataObject();
                    string[] files           = (string[])myDataObject.GetData(DataFormats.FileDrop);

                    if (ResultText != "")
                    {
                        Result = ResultText;
                    }
                    else if (files != null)
                    {
                        for (int i = 0; i < files.Count(); i++)
                        {
                            Result = Result + files[i];
                            Result = Result + " | ";
                        }
                        Result = Result.Remove(Result.Length - 3);
                    }
                }
                catch (Exception ex)
                {
                    Result = "";
                }
            });

            staThread.SetApartmentState(ApartmentState.STA);
            staThread.Start();
            staThread.Join();
            return(Result);
        }
コード例 #49
0
        private void CopyCoverImageFromClipboard()
        {
            Image image = null;

            if (Clipboard.ContainsImage())
            {
                image = Clipboard.GetImage();
            }
            else
            {
                IDataObject myDataObject = Clipboard.GetDataObject();
                string[]    files        = (string[])myDataObject.GetData(DataFormats.FileDrop);

                if (files.Length == 1 && BookWave.Desktop.Util.ImageConverter.FileIsValid(files[0]))
                {
                    image = Image.FromFile(files[0]);
                }
            }

            if (image != null)
            {
                ChangeCoverImage(image);
            }
        }
コード例 #50
0
ファイル: PasswordBox.cs プロジェクト: luckypal/Kiosk
 protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
 {
     if (keyData == (Keys)131158 || keyData == (Keys.LButton | Keys.MButton | Keys.Back | Keys.Space | Keys.Shift))
     {
         IDataObject dataObject = Clipboard.GetDataObject();
         if (dataObject.GetDataPresent(DataFormats.Text))
         {
             ReplaceSelection((string)dataObject.GetData(DataFormats.Text));
             return(true);
         }
     }
     else
     {
         if (keyData == (Keys)131139 || keyData == (Keys.LButton | Keys.MButton | Keys.Back | Keys.Space | Keys.Control) || keyData == (Keys.RButton | Keys.MButton | Keys.Back | Keys.Space | Keys.Shift))
         {
             return(true);
         }
         if (keyData == Keys.Delete)
         {
             DeleteChar();
         }
     }
     return(base.ProcessCmdKey(ref msg, keyData));
 }
コード例 #51
0
 /// <summary>
 /// Check if the IDataObject has an image
 /// </summary>
 /// <param name="dataObject"></param>
 /// <returns>true if an image is there</returns>
 public static bool ContainsImage(IDataObject dataObject)
 {
     if (dataObject != null)
     {
         if (dataObject.GetDataPresent(DataFormats.Bitmap) ||
             dataObject.GetDataPresent(DataFormats.Dib) ||
             dataObject.GetDataPresent(DataFormats.Tiff) ||
             dataObject.GetDataPresent(DataFormats.EnhancedMetafile) ||
             dataObject.GetDataPresent(FORMAT_PNG) ||
             dataObject.GetDataPresent(FORMAT_JPG) ||
             dataObject.GetDataPresent(FORMAT_GIF))
         {
             return(true);
         }
         List <string> imageFiles = GetImageFilenames(dataObject);
         if (imageFiles != null && imageFiles.Count > 0)
         {
             return(true);
         }
         if (dataObject.GetDataPresent(FORMAT_FILECONTENTS))
         {
             try {
                 MemoryStream imageStream = dataObject.GetData(FORMAT_FILECONTENTS) as MemoryStream;
                 if (isValidStream(imageStream))
                 {
                     using (Image tmpImage = Image.FromStream(imageStream)) {
                         // If we get here, there is an image
                         return(true);
                     }
                 }
             } catch (Exception) {
             }
         }
     }
     return(false);
 }
コード例 #52
0
    public void MyClipboardMethod()
    {
        // Creates a new data format.
        DataFormats.Format myFormat = DataFormats.GetFormat("myFormat");

        /* Creates a new object and stores it in a DataObject using myFormat
         * as the type of format. */
        MyNewObject myObject     = new MyNewObject();
        DataObject  myDataObject = new DataObject(myFormat.Name, myObject);

        // Copies myObject into the clipboard.
        Clipboard.SetDataObject(myDataObject);

        // Performs some processing steps.

        // Retrieves the data from the clipboard.
        IDataObject myRetrievedObject = Clipboard.GetDataObject();

        // Converts the IDataObject type to MyNewObject type.
        MyNewObject myDereferencedObject = (MyNewObject)myRetrievedObject.GetData(myFormat.Name);

        // Prints the value of the Object in a textBox.
        textBox1.Text = myDereferencedObject.MyObjectValue;
    }
コード例 #53
0
        static void FillDataStore(TransferDataStore store, IDataObject data, TransferDataType [] types)
        {
            foreach (var type in types)
            {
                string format = type.ToWpfDataFormat();
                if (!data.GetDataPresent(format))
                {
                    // This is a workaround to support type names which don't include the assembly name.
                    // It eases integration with Windows DND.
                    format = NormalizeTypeName(format);
                    if (!data.GetDataPresent(format))
                    {
                        continue;
                    }
                }

                var value = data.GetData(format);
                if (type == TransferDataType.Text)
                {
                    store.AddText((string)value);
                }
                else if (type == TransferDataType.Uri)
                {
                    var uris = ((string [])value).Select(f => new Uri(f)).ToArray();
                    store.AddUris(uris);
                }
                else if (value is byte[])
                {
                    store.AddValue(type, (byte[])value);
                }
                else
                {
                    store.AddValue(type, value);
                }
            }
        }
コード例 #54
0
            private void ClipChanged()
            {
                IDataObject iData = Clipboard.GetDataObject();

                ClipboardFormat?format = null;

                foreach (var f in formats)
                {
                    if (iData.GetDataPresent(f))
                    {
                        format = (ClipboardFormat)Enum.Parse(typeof(ClipboardFormat), f);
                        break;
                    }
                }

                object data = iData.GetData(format.ToString());

                if (data == null || format == null)
                {
                    return;
                }

                OnClipboardChange?.Invoke((ClipboardFormat)format, data);
            }
コード例 #55
0
ファイル: IDataObjectExtensions.cs プロジェクト: kiple/gitter
        public static T GetData <T>(this IDataObject data)
        {
            Verify.Argument.IsNotNull(data, nameof(data));

            return((T)data.GetData(typeof(T)));
        }
コード例 #56
0
ファイル: Pribors.cs プロジェクト: iamkvv/gaudit
        private void btnGetClipBoard_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;

                IDataObject iData = Clipboard.GetDataObject();

                if (iData.GetDataPresent(DataFormats.Html))
                {
                    string html = ((String)iData.GetData(DataFormats.Html));

                    string[] htmlarr = html.Split(new string[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);

                    if (String.IsNullOrEmpty(html) ||
                        htmlarr.Count() < 5 ||
                        htmlarr[5].Split(':')[2] != @"//my.dom.gosuslugi.ru/organization-cabinet/#!/device/list")
                    {
                        MessageBox.Show("Для работы с реестром приборов учета перейдите на страницу \n\r" +
                                        "https://my.dom.gosuslugi.ru/organization-cabinet/#!/device/list \n\r" +
                                        "и скопируйте в буфер таблицу приборов учета. ",
                                        "Ошибка", MessageBoxButtons.OK,
                                        MessageBoxIcon.Stop);
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("В буфере не обнаружены корректные данные.");
                    return;
                }

                if (iData.GetDataPresent(DataFormats.UnicodeText)) //получим массив строк
                {
                    string   cliptxt = (String)iData.GetData(DataFormats.UnicodeText);
                    string[] cliparr = cliptxt.Split(new string[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);

                    int      skip = 0;
                    string[] z;
                    string[] data = cliparr.Skip(7).ToArray();  //пропускаем загловок страницы

                    while ((z = data.Skip(skip).Take(7).ToArray()).Count() != 0)
                    {
                        skip += 7;
                        priborAdapter.Insert(
                            ActiveAudit.ID,
                            ActiveAudit.ID_Company,
                            z[0],
                            z[1].Split('\t')[0],
                            z[1].Split('\t')[1],
                            z[2].Split('\t')[0],
                            z[2].Split('\t')[1],
                            z[3] + " " + z[4],
                            z[6]);
                    }

                    grdPribors.DataSource = priborAdapter.GetDataByActiveAudit(ActiveAudit.ID, ActiveAudit.ID_Company);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Clipboard.Clear();
                Cursor.Current = Cursors.Default;
                ActiveAudit.CheckGrid(grdPribors);
            }
        }
コード例 #57
0
 /// <summary>
 /// Create an array of FileItem objects based on a data object that contains a FileDrop
 /// </summary>
 /// <param name="dataObject">data object containing the file drop</param>
 /// <returns></returns>
 public static FileItem[] CreateArrayFromDataObject(IDataObject dataObject)
 {
     string[] filePaths = (string[])dataObject.GetData(DataFormats.FileDrop);
     return(CreateArrayFromPaths(filePaths));
 }
コード例 #58
0
 /// <summary>
 /// Does the passed data object have this format?
 /// </summary>
 /// <param name="dataObject">data object</param>
 /// <returns>true if the data object has the format, otherwise false</returns>
 public bool CanCreateFrom(IDataObject dataObject)
 {
     return(OleDataObjectHelper.GetDataPresentSafe(dataObject, DataFormats.FileDrop) && dataObject.GetData(DataFormats.FileDrop) != null);
 }
コード例 #59
0
        private void GetEmbeddedObjectText(object embeddedObject, StringBuilder sbText)
        {
            string text;

            IAccessible acc = embeddedObject as IAccessible;

            if (acc != null)
            {
                text = acc.get_accName(NativeMethods.CHILD_SELF);
                if (!string.IsNullOrEmpty(text))
                {
                    sbText.Append(text);
                    return;
                }
            }

            // Didn't get IAccessible (or didn't get a name from it).
            // Try the IDataObject technique instead...

            int         hr         = NativeMethods.S_FALSE;
            IDataObject dataObject = null;
            IOleObject  oleObject  = embeddedObject as IOleObject;

            if (oleObject != null)
            {
                // Try IOleObject::GetClipboardData (which returns an IDataObject) first...
                hr = oleObject.GetClipboardData(0, out dataObject);
            }

            // If that didn't work, try the embeddedObject as a IDataObject instead...
            if (hr != NativeMethods.S_OK)
            {
                dataObject = embeddedObject as IDataObject;
            }

            if (dataObject == null)
            {
                return;
            }

            // Got the IDataObject. Now query it for text formats. Try Unicode first...

            bool fGotUnicode = true;

            UnsafeNativeMethods.FORMATETC fetc = new UnsafeNativeMethods.FORMATETC();
            fetc.cfFormat = DataObjectConstants.CF_UNICODETEXT;
            fetc.ptd      = IntPtr.Zero;
            fetc.dwAspect = DataObjectConstants.DVASPECT_CONTENT;
            fetc.lindex   = -1;
            fetc.tymed    = DataObjectConstants.TYMED_HGLOBAL;

            UnsafeNativeMethods.STGMEDIUM med = new UnsafeNativeMethods.STGMEDIUM();
            med.tymed          = DataObjectConstants.TYMED_HGLOBAL;
            med.pUnkForRelease = IntPtr.Zero;
            med.hGlobal        = IntPtr.Zero;

            hr = dataObject.GetData(ref fetc, ref med);

            if (hr != NativeMethods.S_OK || med.hGlobal == IntPtr.Zero)
            {
                // If we didn't get Unicode, try for ANSI instead...
                fGotUnicode   = false;
                fetc.cfFormat = DataObjectConstants.CF_TEXT;

                hr = dataObject.GetData(ref fetc, ref med);
            }

            // Did we get anything?
            if (hr != NativeMethods.S_OK || med.hGlobal == IntPtr.Zero)
            {
                return;
            }

            //lock the memory, so data can be copied into
            IntPtr globalMem = UnsafeNativeMethods.GlobalLock(med.hGlobal);

            try
            {
                //error check for the memory pointer
                if (globalMem == IntPtr.Zero)
                {
                    return;
                }

                unsafe
                {
                    //get the string
                    if (fGotUnicode)
                    {
                        text = new string((char *)globalMem);
                    }
                    else
                    {
                        text = new string((sbyte *)globalMem);
                    }
                }

                sbText.Append(text);
            }
            finally
            {
                //unlock the memory
                UnsafeNativeMethods.GlobalUnlock(med.hGlobal);
                UnsafeNativeMethods.ReleaseStgMedium(ref med);
            }
        }
コード例 #60
0
        public void PasteInData(ref DataGridView dgv)
        {
            char[] rowSplitter    = { '\n', '\r' }; // Cr and Lf.
            char[] columnSplitter = { '\t', ',' };  // Tab. ,

            IDataObject dataInClipboard = Clipboard.GetDataObject();

            string stringInClipboard = dataInClipboard.GetData(DataFormats.Text).ToString();

            string[] rowsInClipboard = stringInClipboard.Split(rowSplitter, StringSplitOptions.RemoveEmptyEntries);

            int ClipboardColsNum = (rowsInClipboard[0].Split(columnSplitter)).Length;


            int r = dgv.SelectedCells[0].RowIndex;
            int c = dgv.SelectedCells[0].ColumnIndex;


            if (dgv.Rows.Count < (r + rowsInClipboard.Length))
            {
                dgv.Rows.Add(r + rowsInClipboard.Length - dgv.Rows.Count);
            }


            if (dgv.ColumnCount < (c + ClipboardColsNum))
            {
                dgv.ColumnCount = (c + ClipboardColsNum);
            }

            for (int i = 1; i < dgv.ColumnCount; i++)
            {
                string NewColName = Convert.ToChar(64 + i).ToString();
                dgv.Columns[i].Name       = NewColName;
                dgv.Columns[i].HeaderText = NewColName;
            }

            // Loop through lines:

            int iRow = 0;

            while (iRow < rowsInClipboard.Length)
            {
                string[] valuesInRow = rowsInClipboard[iRow].Split(columnSplitter);
                if (iRow != 0)
                {
                    dgv.Rows[r + iRow].HeaderCell.Value = iRow.ToString();
                }
                int jCol = 0;
                while (jCol < valuesInRow.Length)
                {
                    if ((dgv.ColumnCount - 1) >= (c + jCol))
                    {
                        dgv.Rows[r + iRow].Cells[c + jCol].Value = valuesInRow[jCol];
                    }
                    jCol += 1;
                }

                dgv.Rows[r + iRow].Cells[0].Value = true;
                iRow += 1;
            }
        }