コード例 #1
0
        /// <summary>
        /// Creates the static resources required by the DragDropHelper class.
        /// </summary>
        static DragDropHelper()
        {
            // The common format used in the drag and drop operations.
            DragDropHelper.dataFormat = DataFormats.GetDataFormat("DragDropItemsControl");

            // IsDragSource
            DragDropHelper.IsDragSourceProperty = DependencyProperty.RegisterAttached(
                "IsDragSource",
                typeof(Boolean),
                typeof(DragDropHelper),
                new UIPropertyMetadata(IsDragSourceChanged));

            // IsDragTarget
            DragDropHelper.IsDropTargetProperty = DependencyProperty.RegisterAttached(
                "IsDropTarget",
                typeof(Boolean),
                typeof(DragDropHelper),
                new UIPropertyMetadata(IsDropTargetChanged));

            // IsDragOver
            DragDropHelper.IsDragOverProperty = DependencyProperty.RegisterAttached(
                "IsDragOver",
                typeof(Boolean),
                typeof(DragDropHelper));

            // DragDropTemplate
            DragDropHelper.DragDropTemplateProperty = DependencyProperty.RegisterAttached(
                "DragDropTemplate",
                typeof(DataTemplate),
                typeof(DragDropHelper));
        }
コード例 #2
0
        // TODO: Need to add support for delayed rendering
        public void SetClipboardData(IOrderedDictionary <string, MemoryStream> data)
        {
            try
            {
                _clipboardHelper.OpenClipboard();
                _clipboardHelper.EmptyClipboard();

                var formats       = new OrderedDictionary <string, int>();
                var clipboardData = new Dictionary <string, MemoryStream>();
                foreach (var format in data)
                {
                    var dataFormat = DataFormats.GetDataFormat(format.Key);
                    try
                    {
                        _clipboardHelper.SetClipboardData(dataFormat.Id, format.Value);

                        // Store format names as lowercase
                        formats[format.Key.ToLower()]       = dataFormat.Id;
                        clipboardData[format.Key.ToLower()] = format.Value;
                    }
                    catch
                    {
                        // Do nothing
                    }
                }

                _formats        = formats;
                _formatsCurrent = true;
                _clipboardData  = clipboardData;
            }
            finally
            {
                _clipboardHelper.CloseClipboard();
            }
        }
コード例 #3
0
        private void ExecuteCopyResultsCommand(object parameter)
        {
            const string XML_SPREADSHEET_DATA_FORMAT = "XML Spreadsheet";

            ColumnInfo[] ColumnInfos = { new ColumnInfo("Project"),    new ColumnInfo("Component"), new ColumnInfo("Method"),       new ColumnInfo("Outcome"), new ColumnInfo("Output"),
                                         new ColumnInfo("Start Time"), new ColumnInfo("End Time"),  new ColumnInfo("Duration (ms)", hAlignment.Right) };

            var aResults = Model.Tests.Select(test => test.ToArray()).ToArray();

            var resource = "Rubberduck Test Results - {0}";
            var title    = string.Format(resource, DateTime.Now.ToString(CultureInfo.InvariantCulture));

            //var textResults = title + Environment.NewLine + string.Join("", _results.Select(result => result.ToString() + Environment.NewLine).ToArray());
            var csvResults  = ExportFormatter.Csv(aResults, title, ColumnInfos);
            var htmlResults = ExportFormatter.HtmlClipboardFragment(aResults, title, ColumnInfos);
            var rtfResults  = ExportFormatter.RTF(aResults, title);

            MemoryStream strm1 = ExportFormatter.XmlSpreadsheetNew(aResults, title, ColumnInfos);

            //Add the formats from richest formatting to least formatting
            _clipboard.AppendStream(DataFormats.GetDataFormat(XML_SPREADSHEET_DATA_FORMAT).Name, strm1);
            _clipboard.AppendString(DataFormats.Rtf, rtfResults);
            _clipboard.AppendString(DataFormats.Html, htmlResults);
            _clipboard.AppendString(DataFormats.CommaSeparatedValue, csvResults);
            //_clipboard.AppendString(DataFormats.UnicodeText, textResults);

            _clipboard.Flush();
        }
コード例 #4
0
        private void PasteNote(object obj)
        {
            Notebook notebook = obj as Notebook;

            if (notebook != null)
            {
                DataFormat format = DataFormats.GetDataFormat(typeof(NoteClipboardData).FullName);
                if (!Clipboard.ContainsData(format.Name))
                {
                    return;
                }

                NoteClipboardData data = Clipboard.GetData(format.Name) as NoteClipboardData;
                if (data != null)
                {
                    int  index = Hub.Instance.Storage.GetNoteCount(notebook);
                    Note note  = ViewModelLocator.Instance.NoteMenu.CreateNewNote(data.Name, notebook, false, index, data.Text);
                    if (data.Files != null && data.Files.Any())
                    {
                        foreach (ClipboardFile file in data.Files)
                        {
                            NoteFile nf = NoteFile.Create(file.Name, file.MimeType, file.Data, note);
                            note.Text = note.Text.Replace(file.FileName, nf.FileName);
                        }
                        note.Save();
                    }
                }
            }
        }
コード例 #5
0
        private static void DoCopyNote(Note note)
        {
            NoteClipboardData data = new NoteClipboardData
            {
                Name = note.Name,
                Text = note.DecryptedText,
                Tags = new List <string>(note.Tags)
            };

            if (note.Files.Any())
            {
                data.Files = new List <ClipboardFile>();
                foreach (NoteFile noteFile in note.Files)
                {
                    ClipboardFile file = new ClipboardFile
                    {
                        Name     = noteFile.Name,
                        Data     = File.ReadAllBytes(noteFile.FullName),
                        FileName = noteFile.FileName,
                        MimeType = MimeTypeMap.GetMimeType(Path.GetExtension(noteFile.FileName))
                    };
                    data.Files.Add(file);
                }
            }

            DataFormat format = DataFormats.GetDataFormat(typeof(NoteClipboardData).FullName);

            IDataObject dataObj = new DataObject();

            dataObj.SetData(format.Name, data, false);
            Clipboard.SetDataObject(dataObj, false);
        }
コード例 #6
0
        private void ExecuteCopyResultsCommand(object parameter)
        {
            const string xmlSpreadsheetDataFormat = "XML Spreadsheet";

            if (_results == null)
            {
                return;
            }
            ColumnInfo[] columnInfos = { new ColumnInfo("Type"), new ColumnInfo("Project"), new ColumnInfo("Component"), new ColumnInfo("Issue"), new ColumnInfo("Line", hAlignment.Right), new ColumnInfo("Column", hAlignment.Right) };

            var resultArray = _results.OfType <IExportable>().Select(result => result.ToArray()).ToArray();

            var resource = _results.Count == 1
                ? RubberduckUI.CodeInspections_NumberOfIssuesFound_Singular
                : RubberduckUI.CodeInspections_NumberOfIssuesFound_Plural;

            var title = string.Format(resource, DateTime.Now.ToString(CultureInfo.InvariantCulture), _results.Count);

            var textResults = title + Environment.NewLine + string.Join("", _results.OfType <IExportable>().Select(result => result.ToClipboardString() + Environment.NewLine).ToArray());
            var csvResults  = ExportFormatter.Csv(resultArray, title, columnInfos);
            var htmlResults = ExportFormatter.HtmlClipboardFragment(resultArray, title, columnInfos);
            var rtfResults  = ExportFormatter.RTF(resultArray, title);

            // todo: verify that this disposing this stream breaks the xmlSpreadsheetDataFormat
            var stream = ExportFormatter.XmlSpreadsheetNew(resultArray, title, columnInfos);

            //Add the formats from richest formatting to least formatting
            _clipboard.AppendStream(DataFormats.GetDataFormat(xmlSpreadsheetDataFormat).Name, stream);
            _clipboard.AppendString(DataFormats.Rtf, rtfResults);
            _clipboard.AppendString(DataFormats.Html, htmlResults);
            _clipboard.AppendString(DataFormats.CommaSeparatedValue, csvResults);
            _clipboard.AppendString(DataFormats.UnicodeText, textResults);

            _clipboard.Flush();
        }
コード例 #7
0
ファイル: ClipboardReader.cs プロジェクト: metaseed/Metakey
        /// <summary>
        /// Handle and begin to read the specified data format.
        /// </summary>
        /// <param name="format">The data's format to read.</param>
        internal void BeginRead(string format)
        {
            Requires.NotNullOrEmpty(format, nameof(format));
            Requires.IsFalse(IsReadable);

            IsReadable  = false;
            _readLength = 0;
            var formatetc = new FORMATETC
            {
                cfFormat = (short)DataFormats.GetDataFormat(format).Id,
                dwAspect = DVASPECT.DVASPECT_CONTENT,
                lindex   = -1,
                tymed    = TYMED.TYMED_HGLOBAL
            };

            Requires.IsFalse(Consts.S_OK != QueryGetDataInner(ref formatetc));

            try
            {
                GetDataInner(ref formatetc, out _stgmedium);
                if (_stgmedium.unionmember != IntPtr.Zero && _stgmedium.tymed == TYMED.TYMED_HGLOBAL)
                {
                    _dataHandleRef = new HandleRef(this, _stgmedium.unionmember);
                    _dataHandle    = CoreHelper.Win32GlobalLock(_dataHandleRef);
                    _dataSize      = DataHelper.IntPtrToInt32(CoreHelper.Win32GlobalSize(_dataHandleRef));
                    IsReadable     = true;
                }
            }
            catch (Exception exception)
            {
                Logger.Instance.Error(exception);
                EndRead();
            }
        }
コード例 #8
0
        public override void Execute(object parameter)
        {
            const string XML_SPREADSHEET_DATA_FORMAT = "XML Spreadsheet";

            ColumnInfo[] ColumnInfos = { new ColumnInfo("Project"), new ColumnInfo("Folder"), new ColumnInfo("Component"), new ColumnInfo("Declaration Type"), new ColumnInfo("Scope"),
                                         new ColumnInfo("Name"),    new ColumnInfo("Return Type") };

            // this.ProjectName, this.CustomFolder, this.ComponentName, this.DeclarationType.ToString(), this.Scope
            var aDeclarations = _state.AllUserDeclarations.Select(declaration => declaration.ToArray()).ToArray();

            const string resource = "Rubberduck User Declarations - {0}";
            var          title    = string.Format(resource, DateTime.Now.ToString(CultureInfo.InvariantCulture));

            var csvResults  = ExportFormatter.Csv(aDeclarations, title, ColumnInfos);
            var htmlResults = ExportFormatter.HtmlClipboardFragment(aDeclarations, title, ColumnInfos);
            var rtfResults  = ExportFormatter.RTF(aDeclarations, title);

            var strm1 = ExportFormatter.XmlSpreadsheetNew(aDeclarations, title, ColumnInfos);

            //Add the formats from richest formatting to least formatting
            _clipboard.AppendStream(DataFormats.GetDataFormat(XML_SPREADSHEET_DATA_FORMAT).Name, strm1);
            _clipboard.AppendString(DataFormats.Rtf, rtfResults);
            _clipboard.AppendString(DataFormats.Html, htmlResults);
            _clipboard.AppendString(DataFormats.CommaSeparatedValue, csvResults);

            _clipboard.Flush();
        }
コード例 #9
0
        private void Paste_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            var fmt = DataFormats.GetDataFormat("XDrawShape");

            e.CanExecute = Clipboard.ContainsText() && Clipboard.GetText().StartsWith("<GeometryDrawing");
            e.Handled    = true;
        }
コード例 #10
0
        private void ExecuteCopyResultsCommand(object parameter)
        {
            const string XML_SPREADSHEET_DATA_FORMAT = "XML Spreadsheet";

            if (_results == null)
            {
                return;
            }
            ColumnInfo[] ColumnInfos = { new ColumnInfo("Type"), new ColumnInfo("Project"), new ColumnInfo("Component"), new ColumnInfo("Issue"), new ColumnInfo("Line", hAlignment.Right), new ColumnInfo("Column", hAlignment.Right) };

            var aResults = _results.Select(result => result.ToArray()).ToArray();

            var resource = _results.Count == 1
                ? RubberduckUI.CodeInspections_NumberOfIssuesFound_Singular
                : RubberduckUI.CodeInspections_NumberOfIssuesFound_Plural;

            var title = string.Format(resource, DateTime.Now.ToString(CultureInfo.InvariantCulture), _results.Count);

            var textResults = title + Environment.NewLine + string.Join("", _results.Select(result => result.ToString() + Environment.NewLine).ToArray());
            var csvResults  = ExportFormatter.Csv(aResults, title, ColumnInfos);
            var htmlResults = ExportFormatter.HtmlClipboardFragment(aResults, title, ColumnInfos);
            var rtfResults  = ExportFormatter.RTF(aResults, title);

            MemoryStream strm1 = ExportFormatter.XmlSpreadsheetNew(aResults, title, ColumnInfos);

            //Add the formats from richest formatting to least formatting
            _clipboard.AppendStream(DataFormats.GetDataFormat(XML_SPREADSHEET_DATA_FORMAT).Name, strm1);
            _clipboard.AppendString(DataFormats.Rtf, rtfResults);
            _clipboard.AppendString(DataFormats.Html, htmlResults);
            _clipboard.AppendString(DataFormats.CommaSeparatedValue, csvResults);
            _clipboard.AppendString(DataFormats.UnicodeText, textResults);

            _clipboard.Flush();
        }
コード例 #11
0
 public string[] GetFormats()
 {
     return(new string[3] {
         DataFormats.Text,
         DataFormats.GetDataFormat("XML").Name,
         DataFormats.GetDataFormat(typeof(MoneyDataObject).FullName).Name
     });
 }
コード例 #12
0
        // ---------------------------------------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Static constructor.
        /// </summary>
        static CompositionEngine()
        {
            IdeaTransferFormat = DataFormats.GetDataFormat(CompositionEngine.FORMAT_CODE_IDEA);

            CurrentMousePosition = Display.NULL_POINT;

            DefineContextMenuOptions();
        }
コード例 #13
0
 static FORMATETC CreateFormatEtc(string format, TYMED tymed) =>
 new FORMATETC
 {
     cfFormat = (short)DataFormats.GetDataFormat(format).Id,
     tymed    = tymed,
     dwAspect = DVASPECT.DVASPECT_CONTENT,
     lindex   = -1,
     ptd      = IntPtr.Zero
 };
コード例 #14
0
        public List <DataFormat> GetSynthesizedFormats(string format)
        {
            var lowerFormat = format.ToLower();

            if (!_sythesizedFormats.TryGetValue(lowerFormat, out var availableFormats))
            {
                return(new List <DataFormat>());
            }
            return(availableFormats.Select(x => DataFormats.GetDataFormat(x)).ToList());
        }
コード例 #15
0
 public void StartDrag(IDragInfo dragInfo)
 {
     DragDrop.DragDrop.DefaultDragHandler.StartDrag(dragInfo);
     if (dragInfo.SourceItem is IToolboxItem toolbox)
     {
         var format = toolbox.DataSource.Data.Format;
         dragInfo.DataFormat = DataFormats.GetDataFormat(format);
         dragInfo.Data       = toolbox.DataSource.Data.Data;
         dragInfo.Effects    = dragInfo.Data != null ? DragDropEffects.Copy | DragDropEffects.Move : DragDropEffects.None;
     }
 }
コード例 #16
0
        private void Text_MouseButtonDown(object sender, MouseButtonEventArgs e)
        {
            var virtualFileDataObject = new VirtualFileDataObject();

            // Provide simple text (in the form of a NULL-terminated ANSI string)
            virtualFileDataObject.SetData(
                (short)(DataFormats.GetDataFormat(DataFormats.Text).Id),
                Encoding.Default.GetBytes("This is some sample text\0"));

            DoDragDropOrClipboardSetDataObject(e.ChangedButton, Text, virtualFileDataObject, DragDropEffects.Copy);
        }
コード例 #17
0
 public override void StartDrag(IDragInfo dragInfo)
 {
     base.StartDrag(dragInfo);
     if (dragInfo.Data is CaptureImage image)
     {
         dragInfo.DataFormat = DataFormats.GetDataFormat(DataFormats.Bitmap);
         var dataObj = new DataObject();
         dataObj.SetImage(image.TransformedImage);
         dragInfo.DataObject = dataObj;
     }
 }
コード例 #18
0
        /// <summary>
        /// Places a project item in the clipboard
        /// </summary>
        /// <param name="ref">Project item to copy</param>
        public void ProjectItemCopyClipboard(Reference @ref)
        {
            var dataFormat = DataFormats.GetDataFormat(typeof(ClipboardData).FullName);

            ClipboardData data = new ClipboardData();

            data.Cut           = false;
            data.QualifiedName = @ref.QualifiedName;

            Clipboard.SetData(dataFormat.Name, data);
        }
コード例 #19
0
 public object GetData(string format)
 {
     if (format == DataFormats.Text || format == DataFormats.GetDataFormat("XML").Name)
     {
         return(this.xml);
     }
     else if (format == DataFormats.GetDataFormat(typeof(MoneyDataObject).FullName).Name)
     {
         return(this);
     }
     return(null);
 }
コード例 #20
0
        private void CopyMenuItem_Click(object sender, ExecutedRoutedEventArgs e)
        {
            Clipboard.Clear();

            var format = DataFormats.GetDataFormat(typeof(Node).FullName);

            //now copy to clipboard
            IDataObject dataObj = new DataObject();

            dataObj.SetData(format.Name, TreeView1.SelectedItem, false);
            Clipboard.SetDataObject(dataObj, true);
        }
コード例 #21
0
        public bool MoveNext()
        {
            // Get next format
            var formatId = _format?.Id ?? 0;

            if ((formatId = _clipboardHelper.EnumClipboardFormats(formatId)) == 0)
            {
                return(false);
            }
            _format = DataFormats.GetDataFormat(formatId);

            return(true);
        }
コード例 #22
0
ファイル: DataObject.cs プロジェクト: metaseed/Metakey
        private int GetDataIntoOleStructs(ref FORMATETC formatetc, ref STGMEDIUM medium, bool doNotReallocate)
        {
            var format = DataFormats.GetDataFormat(formatetc.cfFormat).Name;

            var hr = SaveStreamToHandle(medium.unionmember, _data[format], doNotReallocate);

            if (hr == Consts.S_OK)
            {
                medium.tymed = TYMED.TYMED_HGLOBAL;
            }

            return(hr);
        }
コード例 #23
0
        /// <summary>
        /// Sets managed data to a clipboard DataObject.
        /// </summary>
        /// <param name="dataObject">The DataObject to set the data on.</param>
        /// <param name="format">The clipboard format.</param>
        /// <param name="data">The data object.</param>
        /// <remarks>
        /// Because the underlying data store is not storing managed objects, but
        /// unmanaged ones, this function provides intelligent conversion, allowing
        /// you to set unmanaged data into the COM implemented IDataObject.</remarks>
        public static void SetDataEx(this IDataObject dataObject, string format, object data)
        {
            DataFormat dataFormat = DataFormats.GetDataFormat(format);

            // Initialize the format structure
            var formatETC = new FORMATETC();

            formatETC.cfFormat = (short)dataFormat.Id;
            formatETC.dwAspect = DVASPECT.DVASPECT_CONTENT;
            formatETC.lindex   = -1;
            formatETC.ptd      = IntPtr.Zero;

            // Try to discover the TYMED from the format and data
            TYMED tymed = GetCompatibleTymed(format, data);

            // If a TYMED was found, we can use the system DataObject
            // to convert our value for us.
            if (tymed != TYMED.TYMED_NULL)
            {
                formatETC.tymed = tymed;

                // Set data on an empty DataObject instance
                var conv = new System.Windows.DataObject();
                conv.SetData(format, data, true);

                // Now retrieve the data, using the COM interface.
                // This will perform a managed to unmanaged conversion for us.
                STGMEDIUM medium;
                ((ComIDataObject)conv).GetData(ref formatETC, out medium);
                try
                {
                    // Now set the data on our data object
                    ((ComIDataObject)dataObject).SetData(ref formatETC, ref medium, true);
                }
                catch
                {
                    // On exceptions, release the medium
                    ReleaseStgMedium(ref medium);
                    throw;
                }
            }
            else
            {
                // Since we couldn't determine a TYMED, this data
                // is likely custom managed data, and won't be used
                // by unmanaged code, so we'll use our custom marshaling
                // implemented by our COM IDataObject extensions.

                ComDataObjectExtensions.SetManagedData((ComIDataObject)dataObject, format, data);
            }
        }
コード例 #24
0
        /// <inheritdoc />
        public void StartDrag(IDragInfo dragInfo)
        {
            alreadyDropped = false;
            var items   = dragInfo.SourceItems.OfType <object>().ToList();
            var wrapper = new SerializableWrapper()
            {
                Items = items,
                DragDropCopyKeyState = DragDropKeyStates.ControlKey               //dragInfo.DragDropCopyKeyState
            };

            dragInfo.Data       = wrapper;
            dragInfo.DataFormat = DataFormats.GetDataFormat(DataFormats.Serializable);
            dragInfo.Effects    = dragInfo.Data != null ? DragDropEffects.Copy | DragDropEffects.Move : DragDropEffects.None;
        }
コード例 #25
0
        private static SerializableWrapper GetSerializableWrapper(IDropInfo dropInfo)
        {
            var data = dropInfo.Data;

            if (data is DataObject dataObject)
            {
                var dataFormat = DataFormats.GetDataFormat(DataFormats.Serializable);
                data = dataObject.GetDataPresent(dataFormat.Name) ? dataObject.GetData(dataFormat.Name) : data;
            }

            var wrapper = data as SerializableWrapper;

            return(wrapper);
        }
コード例 #26
0
        private void TextUrl_MouseButtonDown(object sender, MouseButtonEventArgs e)
        {
            var virtualFileDataObject = new VirtualFileDataObject();

            // Provide simple text and an URL in priority order
            // (both in the form of a NULL-terminated ANSI string)
            virtualFileDataObject.SetData(
                (short)(DataFormats.GetDataFormat(CFSTR_INETURLA).Id),
                Encoding.Default.GetBytes("http://blogs.msdn.com/delay/\0"));
            virtualFileDataObject.SetData(
                (short)(DataFormats.GetDataFormat(DataFormats.Text).Id),
                Encoding.Default.GetBytes("http://blogs.msdn.com/delay/\0"));

            DoDragDropOrClipboardSetDataObject(e.ChangedButton, TextUrl, virtualFileDataObject, DragDropEffects.Copy);
        }
コード例 #27
0
        public void CaptureImage()
        {
            var img = new CaptureImage(TestUtil.DummyBitmapSource(2, 2))
            {
                JpegQualityLevel = 100
            };

            img.ImageRatioSize.Width = 10;

            var mock = new Mock <IDragInfo>();

            mock.SetupGet(d => d.Data).Returns(img);
            new ImageDragSource().StartDrag(mock.Object);

            mock.VerifySet(d => d.DataFormat = DataFormats.GetDataFormat(DataFormats.Bitmap), Times.Once());
            mock.VerifySet(d => d.DataObject = It.Is(img.TransformedImage,
                                                     new LambdaEqualityComparer <object>(VerifyDataObject)), Times.Once());
コード例 #28
0
        private static Stream ReadFromDataObject(DataObject dataObject, int fileIndex)
        {
            var formatetc = new FORMATETC
            {
                cfFormat = (short)DataFormats.GetDataFormat(NativeMethods.CFSTR_FILECONTENTS).Id,
                dwAspect = DVASPECT.DVASPECT_CONTENT,
                lindex   = fileIndex,
                ptd      = new IntPtr(0),
                tymed    = TYMED.TYMED_ISTREAM
            };

            STGMEDIUM medium;

            System.Runtime.InteropServices.ComTypes.IDataObject obj2 = dataObject;
            obj2.GetData(ref formatetc, out medium);

            try
            {
                if (medium.tymed == TYMED.TYMED_ISTREAM)
                {
                    var mediumStream = (IStream)Marshal.GetTypedObjectForIUnknown(medium.unionmember, typeof(IStream));
                    Marshal.Release(medium.unionmember);

                    var streaWrapper = new ComStreamWrapper(mediumStream, FileAccess.Read, ComRelease.None);

                    streaWrapper.Closed += delegate(object sender, EventArgs e)
                    {
                        NativeMethods.ReleaseStgMedium(ref medium);
                        Marshal.FinalReleaseComObject(mediumStream);
                    };

                    return(streaWrapper);
                }

                throw new NotSupportedException(string.Format("Unsupported STGMEDIUM.tymed ({0})", medium.tymed));
            }
            catch
            {
                NativeMethods.ReleaseStgMedium(ref medium);
                throw;
            }
        }
コード例 #29
0
ファイル: MainWindow.xaml.cs プロジェクト: spurnaye/QPAS
        private void TradesGridContextMenuCopyTagsBtn_Click(object sender, RoutedEventArgs e)
        {
            //Copies a list of tags from the selected trade to the clipboard
            DataFormat dataFormat = DataFormats.GetDataFormat(typeof(List <int>).FullName);

            IDataObject dataObject = new DataObject();

            var selectedTrade = (Trade)TradesGrid.SelectedItem;

            if (selectedTrade.Tags == null)
            {
                return;
            }

            List <int> dataToCopy = selectedTrade.Tags.Select(x => x.ID).ToList();

            dataObject.SetData(dataFormat.Name, dataToCopy, false);

            Clipboard.SetDataObject(dataObject, false);
        }
コード例 #30
0
        /// <summary>
        /// Pastes a project item from clipboard
        /// </summary>
        /// <param name="dest">Destination</param>
        public void ProjectItemPasteClipboard(Reference dest)
        {
            var dataFormat = DataFormats.GetDataFormat(typeof(ClipboardData).FullName);

            if (Clipboard.ContainsData(dataFormat.Name))
            {
                ClipboardData data      = (ClipboardData)Clipboard.GetData(dataFormat.Name);
                var           reference = ActiveProject.Root.GetReference(data.QualifiedName);

                if (data.Cut)
                {
                    ProjectItemMove(reference, dest);
                    Clipboard.Clear();
                }
                else
                {
                    ProjectItemCopy(reference, dest);
                }
            }
        }