Пример #1
0
        private void Paste(DataGrid?dataGrid)
        {
            if (dataGrid == null)
            {
                return;
            }

            var table = ClipboardHelper.GetClipboardDataAsTable();

            if (table == null)
            {
                throw new ImportException(Resources.ImportNormalizedTableExpected);
            }

            if (Settings.IsCellSelectionEnabled)
            {
                PasteCells(dataGrid, table);
            }
            else
            {
                PasteRows(table);
            }
        }
Пример #2
0
        /// <summary>
        /// Parses the item.
        /// </summary>
        private async Task ParseItem()
        {
            PoeItem item       = default;
            var     retryCount = 2;

            for (int i = 0; i < retryCount; i++)
            {
                item = await ClipboardHelper.GetItemInClipboard();

                if (item == null)
                {
                    return;
                }

                if (!item.Identified)
                {
                    await Task.Delay(50);

                    continue;
                }

                break;
            }

            if (item == null || !item.Identified)
            {
                return;
            }

            if (item.ItemClass == ItemClass.Unknown)
            {
                return;
            }

            this.Newitem?.Invoke(this, item);
            ClipboardHelper.ClearClipboard();
        }
        private void CutOrDelete(IDataObject dataObject, out bool isDeleted)
        {
            isDeleted = false;

            IFocusNodeState      State       = StateView.State;
            IFocusBlockListInner ParentInner = State.PropertyToInner(PropertyName) as IFocusBlockListInner;

            Debug.Assert(ParentInner != null);

            Debug.Assert(StartIndex <= EndIndex);

            int OldBlockCount  = ParentInner.BlockStateList.Count;
            int SelectionCount = EndIndex - StartIndex;

            if (SelectionCount < ParentInner.BlockStateList.Count || !NodeHelper.IsCollectionNeverEmpty(State.Node, PropertyName))
            {
                if (dataObject != null)
                {
                    List <IBlock> BlockList = new List <IBlock>();
                    for (int i = StartIndex; i < EndIndex; i++)
                    {
                        IFocusBlockState BlockState = ParentInner.BlockStateList[i];
                        BlockList.Add(BlockState.ChildBlock);
                    }

                    ClipboardHelper.WriteBlockList(dataObject, BlockList);
                }

                IFocusController Controller = StateView.ControllerView.Controller;
                Controller.RemoveBlockRange(ParentInner, StartIndex, EndIndex);

                Debug.Assert(ParentInner.BlockStateList.Count == OldBlockCount - SelectionCount);

                StateView.ControllerView.ClearSelection();
                isDeleted = true;
            }
        }
Пример #4
0
        private void CutOrDelete(IDataObject dataObject, out bool isDeleted)
        {
            isDeleted = false;

            IFocusNodeState      State       = StateView.State;
            IFocusBlockListInner ParentInner = State.PropertyToInner(PropertyName) as IFocusBlockListInner;

            Debug.Assert(ParentInner != null);
            Debug.Assert(BlockIndex >= 0 && BlockIndex < ParentInner.BlockStateList.Count);

            IFocusBlockState BlockState = (IFocusBlockState)ParentInner.BlockStateList[BlockIndex];

            int OldNodeCount   = ParentInner.Count;
            int SelectionCount = EndIndex - StartIndex;

            if (SelectionCount < BlockState.StateList.Count || ParentInner.BlockStateList.Count > 1 || !NodeHelper.IsCollectionNeverEmpty(State.Node, PropertyName))
            {
                if (dataObject != null)
                {
                    List <Node> NodeList = new List <Node>();
                    for (int i = StartIndex; i < EndIndex; i++)
                    {
                        NodeList.Add(BlockState.StateList[i].Node);
                    }

                    ClipboardHelper.WriteNodeList(dataObject, NodeList);
                }

                FocusController Controller = StateView.ControllerView.Controller;
                Controller.RemoveNodeRange(ParentInner, BlockIndex, StartIndex, EndIndex);

                Debug.Assert(ParentInner.Count == OldNodeCount - SelectionCount);

                StateView.ControllerView.ClearSelection();
                isDeleted = true;
            }
        }
Пример #5
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void MenuItemCallback(object sender, EventArgs e)
        {
            var wpfTextView   = WpfTextViewHelper.GetWpfTextView(ServiceProvider);
            var caretPosition = WpfTextViewHelper.GetCaretPosition(wpfTextView);

            var clipboardText = ClipboardHelper.GetText();

            if (string.IsNullOrWhiteSpace(clipboardText))
            {
                return;
            }

            var formatedText = TextHelper.GetFormattedText(clipboardText);

            if (string.IsNullOrWhiteSpace(formatedText))
            {
                return;
            }

            var edit = wpfTextView.TextBuffer.CreateEdit();

            edit.Insert(caretPosition, formatedText);
            edit.Apply();
        }
Пример #6
0
        static void Main(string[] args)
        {
            try
            {
                if (args.Length > 0)
                {
                    string path = args[0];

                    if (File.Exists(path))
                    {
                        ClipboardHelper.CopyStringToClipboard(path);
                    }
                    else
                    {
                        Console.WriteLine($"File not found: \"{path}\"");
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"ERROR: {ex.Message}");
                Console.ReadKey();
            }
        }
Пример #7
0
        public void ImageTransparencyTest()
        {
            // Before running copy an image from SnagIt's editor with transparency
            var data    = System.Windows.Clipboard.GetDataObject();
            var formats = data.GetFormats();

            //foreach (var f in formats)
            //    Console.WriteLine(" - " + f.ToString());

            string file = @"c:\temp\test.png";

            //var imgSource = System.Windows.Clipboard.GetImage();  // this won't display in a WPF Image control from SnagIt
            //using (var img = WindowUtilities.BitmapSourceToBitmap(imgSource))
            //{
            using (var img = ClipboardHelper.GetImage())
            {
                Assert.IsNotNull(img, "Image is null - no image data on the clipboard?");

                File.Delete(file);
                img.Save(file, ImageFormat.Png);
            }

            ShellUtils.ShellExecute(file);
        }
Пример #8
0
        private void ContextMenuOpening(object sender, System.ComponentModel.CancelEventArgs e)
        {
            contextmenu_captureclipboard.Enabled  = ClipboardHelper.ContainsImage();
            contextmenu_capturelastregion.Enabled = RuntimeConfig.LastCapturedRegion != Rectangle.Empty;

            // IE context menu code
            try
            {
                if (conf.IECapture && IECaptureHelper.IsIERunning())
                {
                    this.contextmenu_captureie.Enabled = true;
                }
                else
                {
                    this.contextmenu_captureie.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                LOG.WarnFormat("Problem accessing IE information: {0}", ex.Message);
            }

            // Multi-Screen captures
            this.contextmenu_capturefullscreen.Click           -= new System.EventHandler(this.CaptureFullScreenToolStripMenuItemClick);
            this.contextmenu_capturefullscreen.DropDownOpening -= new System.EventHandler(MultiScreenDropDownOpening);
            this.contextmenu_capturefullscreen.DropDownClosed  -= new System.EventHandler(MultiScreenDropDownClosing);
            if (Screen.AllScreens.Length > 1)
            {
                this.contextmenu_capturefullscreen.DropDownOpening += new System.EventHandler(MultiScreenDropDownOpening);
                this.contextmenu_capturefullscreen.DropDownClosed  += new System.EventHandler(MultiScreenDropDownClosing);
            }
            else
            {
                this.contextmenu_capturefullscreen.Click += new System.EventHandler(this.CaptureFullScreenToolStripMenuItemClick);
            }
        }
Пример #9
0
        /// <summary>
        /// Upload a single File to Imgur
        /// </summary>
        /// <param name="file">Path to Image</param>
        public static async Task UploadSingle(string file)
        {
            ImgurUploader imgur = new ImgurUploader();
            await imgur.Login();

            using (MemoryStream stream = new MemoryStream()) {
                try {
                    //Binary Image
                    using (FileStream fstream = new FileStream(file, FileMode.Open, FileAccess.Read)) {
                        await fstream.CopyToAsync(stream);

                        //Set Stream Position to 0
                        stream.Position = 0;
                    }

                    //Image Size
                    string kb = $"{stream.Length / 1024d:0.#}";

                    //e.g. "Uploading Image (123KB)"
                    ShowNotification(string.Format(strings.uploading, kb), NotificationType.Progress, false);

                    string link = await imgur.Upload(stream);

                    await ClipboardHelper.CopyLink(link, false);

                    Notification?.Close();
                } catch {
                    //Unsupported File Type? Internet connection error?
                    await ShowNotificationAsync(strings.errorInstantUpload, NotificationType.Error, ActionTroubleshoot);
                }
            }

            await Task.Delay(500);

            Application.Current.Shutdown(0);
        }
Пример #10
0
        /// <summary>
        /// Replaces the selection with the content of the clipboard.
        /// </summary>
        /// <param name="isChanged">True if something was replaced or added.</param>
        public override void Paste(out bool isChanged)
        {
            isChanged = false;

            if (ClipboardHelper.TryReadNode(out INode Node))
            {
                PasteNode(Node, out isChanged);
            }

            else if (ClipboardHelper.TryReadNodeList(out IList <INode> NodeList))
            {
                PasteNodeList(NodeList, out isChanged);
            }

            else if (ClipboardHelper.TryReadBlockList(out IList <IBlock> BlockList))
            {
                PasteBlockList(BlockList, out isChanged);
            }

            else if (ClipboardHelper.TryReadText(out string Text) && Text.Length > 0)
            {
                PasteText(Text, out isChanged);
            }
        }
Пример #11
0
        /// <summary>
        /// Parses the item.
        /// </summary>
        private async Task ParseItem()
        {
            PoeItem item       = default;
            var     retryCount = 2;

            for (int i = 0; i < retryCount; i++)
            {
                await Simulate.Events().ClickChord(WindowsInput.Events.KeyCode.LControlKey, WindowsInput.Events.KeyCode.C).Invoke();

                await Task.Delay(100);

                item = ClipboardHelper.GetItemInClipboard();

                if (item == null)
                {
                    return;
                }

                if (!item.Identified)
                {
                    await Task.Delay(50);

                    continue;
                }

                break;
            }

            if (item == null || !item.Identified)
            {
                return;
            }

            this.Newitem?.Invoke(this, item);
            ClipboardHelper.ClearClipboard();
        }
Пример #12
0
        private void registerHotKeys()
        {
            //bind to clipboard
            ShellHook          sh;
            ClipboardHelper    ch;
            GlobalHotkeyHelper gh;

            System.Windows.Forms.Form f;

            f  = new System.Windows.Forms.Form();
            sh = new ShellHook(f.Handle);
            //sh.WindowActivated += sh_WindowActivated;
            //sh.RudeAppActivated += sh_WindowActivated;
            ch = new ClipboardHelper(f.Handle);
            ch.ClipboardGrabbed += ch_ClipboardGrabbed;
            ch.RegisterClipboardListener();

            gh = new GlobalHotkeyHelper(f.Handle);
            gh.GlobalHotkeyFired += new GlobalHotkeyHandler(gh_GlobalHotkeyFired);

            //gh.RegisterHotKey(72783, KeyModifiers.Control, VirtualKeys.VK_COMMA);
            //gh.RegisterHotKey(72784, KeyModifiers.Alt, VirtualKeys.VK_PERIOD);
            gh.RegisterHotKey(72784, KeyModifiers.Control, VirtualKeys.VK_2);
        }
 private void tsmCopyColumn_Click(object sender, EventArgs e)
 {
     if (m_contextMenuManagerColumnCell != null)
     {
         try
         {
             StringBuilder sb = new StringBuilder();
             foreach (Xceed.Grid.DataRow row in m_contextMenuManagerColumnCell.ParentGrid.DataRows)
             {
                 if (!row.Visible)
                 {
                     continue;
                 }
                 sb.Append(row.Cells[m_contextMenuManagerColumnCell.ParentColumn.FieldName].GetDisplayText().Replace(System.Environment.NewLine, " "));
                 sb.Append(System.Environment.NewLine);
             }
             ClipboardHelper.CopyTextToClipboard(sb.ToString());
         }
         catch (Exception ex)
         {
             ExceptionProcess.ProcessWithNotify(ex);
         }
     }
 }
Пример #14
0
 void WebView_Command(object sender, CommandEventArgs e)
 {
     if (e.CommandId == _idCommandAddAllToFavorites)
     {
         var categoryRegex = new Regex(@"data-filtercat=""(?<category>\w+?)"".*background-color: rgb");
         var m             = categoryRegex.Match(_browser.WebView.GetHtml());
         ExtractAllImages(m.Success ? m.Groups["category"].Value : null);
         AddToFavorites(DownloadImages(_allImages));
     }
     else if (e.CommandId == _idCommandAddToFavorites)
     {
         var images = DownloadImages(new[] { e.MenuInfo.SourceUrl });
         if (images.Any())
         {
             AddToFavorites(images.First().Value, images.First().Key);
         }
     }
     else if (e.CommandId == _idCommandEdit)
     {
         var images = DownloadImages(new[] { e.MenuInfo.SourceUrl });
         if (!images.Any())
         {
             return;
         }
         LoadImageToEditor(images.First().Value);
         ViewMode_Click(EditMode, EventArgs.Empty);
     }
     else if (e.CommandId == _idCommandDownload)
     {
         var images = DownloadImages(new[] { e.MenuInfo.SourceUrl });
         if (images.Any())
         {
             ClipboardHelper.PutPngToClipboard(images.First().Value);
         }
     }
 }
Пример #15
0
        /// <summary>
        /// This virtual method is called when ApplicationCommands.Paste command is executed.
        /// </summary>
        /// <param name="args"></param>
        protected virtual void OnExecutedPaste(ExecutedRoutedEventArgs args)
        {
            Debug.WriteLine("OnExecutedPaste begin");

            // parse the clipboard data
            List <string[]> rowData = ClipboardHelper.ParseClipboardData();

            // call OnPastingCellClipboardContent for each cell
            int minRowIndex           = Items.IndexOf(CurrentItem);
            int maxRowIndex           = Items.Count - 1;
            int minColumnDisplayIndex = (SelectionUnit != DataGridSelectionUnit.FullRow) ? Columns.IndexOf(CurrentColumn) : 0;
            int maxColumnDisplayIndex = Columns.Count - 1;
            int rowDataIndex          = 0;

            for (int i = minRowIndex; i < maxRowIndex && rowDataIndex < rowData.Count; i++, rowDataIndex++)
            {
                int columnDataIndex = 0;
                for (int j = minColumnDisplayIndex; j < maxColumnDisplayIndex && columnDataIndex < rowData[rowDataIndex].Length; j++, columnDataIndex++)
                {
                    DataGridColumn column = ColumnFromDisplayIndex(j);
                    column.OnPastingCellClipboardContent(Items[i], rowData[rowDataIndex][columnDataIndex]);
                }
            }
        }
Пример #16
0
 protected override void SetToClipboardInt(string text)
 {
     ClipboardHelper.CopyToClipboard(text);
 }
Пример #17
0
        /// <summary>
        /// Adds Copy/Cut/Paste Context menu options
        /// </summary>
        public void AddCopyPaste()
        {
            var selText = Model.ActiveEditor?.AceEditor?.GetSelection();
            var model   = Model;

            var miCut = new MenuItem {
                Header = "Cut", InputGestureText = "Ctrl-X"
            };

            miCut.Click += (o, args) => model.ActiveEditor.SetSelection("");
            ContextMenu.Items.Add(miCut);

            var miCopy = new MenuItem()
            {
                Header = "Copy", InputGestureText = "Ctrl-C"
            };

            miCopy.Click += (o, args) => ClipboardHelper.SetText(selText, true);
            ContextMenu.Items.Add(miCopy);

            var miCopyHtml = new MenuItem()
            {
                Header = "Copy As Html", InputGestureText = Model.Commands.CopyAsHtmlCommand.KeyboardShortcut
            };

            miCopyHtml.Command = Model.Commands.CopyAsHtmlCommand;
            ContextMenu.Items.Add(miCopyHtml);

            bool hasClipboardData = false;
            var  miPaste          = new MenuItem()
            {
                Header = "Paste", InputGestureText = "Ctrl-V"
            };

            if (ClipboardHelper.ContainsImage())
            {
                hasClipboardData = true;
                miPaste.Header   = "Paste Image";
                miPaste.Click   += (o, args) => model.ActiveEditor?.PasteOperation();
            }
            else
            {
                hasClipboardData = ClipboardHelper.ContainsText();
                miPaste.Click   += (s, e) => Model.ActiveEditor.PasteOperation();
            }

            miPaste.IsEnabled = hasClipboardData;

            ContextMenu.Items.Add(miPaste);

            if (string.IsNullOrEmpty(selText))
            {
                miCopy.IsEnabled     = false;
                miCopyHtml.IsEnabled = false;
                miCut.IsEnabled      = false;
            }
            else
            {
                if (Model.ActiveEditor?.MarkdownDocument?.EditorSyntax != "markdown")
                {
                    miCopyHtml.IsEnabled = false;
                }
                else
                {
                    ContextMenu.Items.Add(new Separator());
                    var miRemoveFormatting = new MenuItem
                    {
                        Header           = "Remove Markdown Formatting",
                        InputGestureText = Model.Commands.RemoveMarkdownFormattingCommand.KeyboardShortcut
                    };
                    miRemoveFormatting.Command = Model.Commands.RemoveMarkdownFormattingCommand;
                    ContextMenu.Items.Add(miRemoveFormatting);
                }

                ContextMenu.Items.Add(new Separator());

                var miSearch = new MenuItem()
                {
                    Header = "Web Search of Selection..."
                };
                miSearch.Click += (o, args) =>
                {
                    var engine = new SearchEngine();
                    engine.OpenSearchEngine(selText);
                };
                ContextMenu.Items.Add(miSearch);



                var miSearchWords = new MenuItem()
                {
                    Header = "Web Search and Link..."
                };
                miSearchWords.Click += async(o, args) =>
                {
                    var engine = new SearchEngine();
                    var list   = await engine.GetSearchLinks(selText);

                    if (list == null)
                    {
                        model.Window.ShowStatusError("Failed to retrieve search matches.");
                        return;
                    }

                    foreach (var item in list.Take(10))
                    {
                        var sp = new StackPanel()
                        {
                        };
                        sp.Children.Add(new TextBlock()
                        {
                            Text       = item.Title,
                            FontWeight = FontWeight.FromOpenTypeWeight(600)
                        });
                        sp.Children.Add(new TextBlock()
                        {
                            Text       = item.Url,
                            FontStyle  = FontStyles.Italic,
                            FontSize   = 12,
                            Margin     = new Thickness(0, 1, 0, 0),
                            Foreground = System.Windows.Media.Brushes.SteelBlue
                        });
                        var si = new MenuItem {
                            Header = sp
                        };
                        si.Click += (s, e) =>
                        {
                            var md = $"[{selText}]({item.Url})";
                            model.ActiveEditor.SetSelection(md);
                            e.Handled = true;
                        };
                        miSearchWords.Items.Add(si);
                    }

                    model.Window.Dispatcher.Invoke(() =>
                    {
                        ContextMenu.IsOpen          = true;
                        miSearchWords.IsSubmenuOpen = true;
                    });
                };
                ContextMenu.Items.Add(miSearchWords);
            }

            AddSpeech();
        }
Пример #18
0
 protected override object GetClipboardDataObjectInt(string html, string plainText)
 {
     return(ClipboardHelper.CreateDataObject(html, plainText));
 }
Пример #19
0
        /// <summary>
        /// Add items to a context menu for the selected item
        /// </summary>
        /// <param name="menu"></param>
        public virtual void AddContextMenuItems(ContextMenuStrip menu, Surface surface)
        {
            bool push = surface.Elements.CanPushDown(this);
            bool pull = surface.Elements.CanPullUp(this);

            ToolStripMenuItem item;

            // Pull "up"
            if (pull)
            {
                item        = new ToolStripMenuItem(Language.GetString(LangKey.editor_uptotop));
                item.Click += delegate {
                    surface.Elements.PullElementsToTop(this);
                    surface.Elements.Invalidate();
                };
                menu.Items.Add(item);
                item        = new ToolStripMenuItem(Language.GetString(LangKey.editor_uponelevel));
                item.Click += delegate {
                    surface.Elements.PullElementsUp(this);
                    surface.Elements.Invalidate();
                };
                menu.Items.Add(item);
            }
            // Push "down"
            if (push)
            {
                item        = new ToolStripMenuItem(Language.GetString(LangKey.editor_downtobottom));
                item.Click += delegate {
                    surface.Elements.PushElementsToBottom(this);
                    surface.Elements.Invalidate();
                };
                menu.Items.Add(item);
                item        = new ToolStripMenuItem(Language.GetString(LangKey.editor_downonelevel));
                item.Click += delegate {
                    surface.Elements.PushElementsDown(this);
                    surface.Elements.Invalidate();
                };
                menu.Items.Add(item);
            }

            // Duplicate
            item        = new ToolStripMenuItem(Language.GetString(LangKey.editor_duplicate));
            item.Click += delegate {
                DrawableContainerList dcs = this.Clone();
                dcs.Parent = surface;
                dcs.MoveBy(10, 10);
                surface.AddElements(dcs);
                surface.DeselectAllElements();
                surface.SelectElements(dcs);
            };
            menu.Items.Add(item);

            // Copy
            item        = new ToolStripMenuItem(Language.GetString(LangKey.editor_copytoclipboard));
            item.Image  = ((System.Drawing.Image)(editorFormResources.GetObject("copyToolStripMenuItem.Image")));
            item.Click += delegate {
                ClipboardHelper.SetClipboardData(typeof(DrawableContainerList), this);
            };
            menu.Items.Add(item);

            // Cut
            item        = new ToolStripMenuItem(Language.GetString(LangKey.editor_cuttoclipboard));
            item.Image  = ((System.Drawing.Image)(editorFormResources.GetObject("btnCut.Image")));
            item.Click += delegate {
                ClipboardHelper.SetClipboardData(typeof(DrawableContainerList), this);
                foreach (DrawableContainer container in this)
                {
                    surface.RemoveElement(container, true);
                }
            };
            menu.Items.Add(item);

            // Delete
            item        = new ToolStripMenuItem(Language.GetString(LangKey.editor_deleteelement));
            item.Image  = ((System.Drawing.Image)(editorFormResources.GetObject("removeObjectToolStripMenuItem.Image")));
            item.Click += delegate {
                foreach (DrawableContainer container in this)
                {
                    surface.RemoveElement(container, true);
                }
            };
            menu.Items.Add(item);

            // Reset
            bool canReset = false;

            foreach (DrawableContainer container in this)
            {
                if (container.hasDefaultSize)
                {
                    canReset = true;
                }
            }
            if (canReset)
            {
                item = new ToolStripMenuItem("Reset size");
                //item.Image = ((System.Drawing.Image)(editorFormResources.GetObject("removeObjectToolStripMenuItem.Image")));
                item.Click += delegate {
                    foreach (DrawableContainer container in this)
                    {
                        if (container.hasDefaultSize)
                        {
                            Size defaultSize = container.DefaultSize;
                            container.Invalidate();
                            container.MakeBoundsChangeUndoable(false);
                            container.Width  = defaultSize.Width;
                            container.Height = defaultSize.Height;
                            container.Invalidate();
                        }
                    }
                };
                menu.Items.Add(item);
            }
        }
Пример #20
0
        /// <summary>
        /// Adds Copy/Cut/Paste Context menu options
        /// </summary>
        public void AddCopyPaste()
        {
            var selText = Model.ActiveEditor?.AceEditor?.GetSelection();
            var model   = Model;

            var miCut = new MenuItem {
                Header = "Cut", InputGestureText = "Ctrl-X"
            };

            miCut.Click += (o, args) => model.ActiveEditor.SetSelection("");
            ContextMenu.Items.Add(miCut);

            var miCopy = new MenuItem()
            {
                Header = "Copy", InputGestureText = "Ctrl-C"
            };

            miCopy.Click += (o, args) =>
            {
                ClipboardHelper.SetText(selText, true);
            };
            ContextMenu.Items.Add(miCopy);

            var miCopyHtml = new MenuItem()
            {
                Header = "Copy As Html", InputGestureText = Model.Commands.CopyAsHtmlCommand.KeyboardShortcut
            };

            miCopyHtml.Command = Model.Commands.CopyAsHtmlCommand;
            ContextMenu.Items.Add(miCopyHtml);

            bool hasClipboardData = false;
            var  miPaste          = new MenuItem()
            {
                Header = "Paste", InputGestureText = "Ctrl-V"
            };

            if (ClipboardHelper.ContainsImage())
            {
                hasClipboardData = true;
                miPaste.Header   = "Paste Image";
                miPaste.Click   += (o, args) => model.ActiveEditor?.PasteOperation();
            }
            else
            {
                hasClipboardData = ClipboardHelper.ContainsText();
                miPaste.Click   += (s, e) => Model.ActiveEditor.PasteOperation();
            }

            miPaste.IsEnabled = hasClipboardData;

            ContextMenu.Items.Add(miPaste);

            if (string.IsNullOrEmpty(selText))
            {
                miCopy.IsEnabled     = false;
                miCopyHtml.IsEnabled = false;
                miCut.IsEnabled      = false;
            }
            else
            {
                if (Model.ActiveEditor?.EditorSyntax != "markdown")
                {
                    miCopyHtml.IsEnabled = false;
                }
                else
                {
                    ContextMenu.Items.Add(new Separator());
                    var miRemoveFormatting = new MenuItem
                    {
                        Header           = "Remove Markdown Formatting",
                        InputGestureText = Model.Commands.RemoveMarkdownFormattingCommand.KeyboardShortcut
                    };
                    miRemoveFormatting.Command = Model.Commands.RemoveMarkdownFormattingCommand;
                    ContextMenu.Items.Add(miRemoveFormatting);
                }
            }
        }
 private void FrmSeleccionarLibroPresupuesto_KeyDown(object sender, KeyEventArgs e)
 {
     ClipboardHelper.SetPortapapeles(e, GridTitulos);
 }
Пример #22
0
 private Clipboard()
 {
     board = new ClipboardHelper();
 }
Пример #23
0
 private void btnCopyText_Click(object sender, EventArgs e)
 {
     ClipboardHelper.SetClipboardText(this, GetSelectedControlErrorLog());
 }
Пример #24
0
 /// <summary>
 /// Checks the pledge status.
 /// </summary>
 private async Task CheckPledgeStatus()
 {
     await ClipboardHelper.CheckPledgeStatusAsync();
 }
Пример #25
0
        protected virtual void OnExecutedPaste(ExecutedRoutedEventArgs args)
        {
            try
            {
                //Debug.WriteLine("OnExecutedPaste begin");
                // parse the clipboard data
                object          obj     = this.DetailType;
                List <string[]> rowData = ClipboardHelper.ParseClipboardData();
                //bool hasAddedNewRow = false;
                if (rowData != null)
                {
                    // call OnPastingCellClipboardContent for each cell
                    if (this.SelectedIndex != -1)
                    {
                        object item = null;
                        if (CurrentItem == null)
                        {
                            item = this.Items[this.SelectedIndex];//Added by william at 2017-04-20  工具条中的命令找不至CurrentItem
                        }
                        else
                        {
                            item = CurrentItem;
                        }

                        //int minRowIndex = LoopNameCollection.IndexOf(CurrentItem);
                        int minRowIndex = Items.IndexOf(item);
                        int maxRowIndex = Items.Count - 1;

                        int minColumnDisplayIndex;
                        if (CurrentColumn != null)
                        {
                            minColumnDisplayIndex = (SelectionUnit != DataGridSelectionUnit.FullRow) ? Columns.IndexOf(CurrentColumn) : 0;
                        }
                        else
                        {
                            minColumnDisplayIndex = 0;
                        }


                        int maxColumnDisplayIndex = Columns.Count - 1;
                        int rowDataIndex          = 1;
                        for (int i = minRowIndex; i <= maxRowIndex && rowDataIndex < rowData.Count; i++, rowDataIndex++)
                        {
                            #region 将数据粘贴至新增的行中
                            //if (CanUserAddRows)
                            //{

                            //    if (CanUserPasteToNewRows && CanUserAddRows && i == maxRowIndex)
                            //    {
                            //        // add a new row to be pasted to
                            //        ICollectionView cv = CollectionViewSource.GetDefaultView(Items);
                            //        IEditableCollectionView iecv = cv as IEditableCollectionView;
                            //        if (iecv != null)
                            //        {
                            //          //  hasAddedNewRow = true;
                            //            iecv.AddNew();

                            //            if (rowDataIndex + 1 < rowData.Count)
                            //            {
                            //                // still has more items to paste, update the maxRowIndex
                            //                maxRowIndex = Items.Count - 1;
                            //            }
                            //        }
                            //    }
                            //    else if (i == maxRowIndex)
                            //    {
                            //        continue;
                            //    }
                            //}
                            #endregion

                            int columnDataIndex = 0;
                            for (int j = minColumnDisplayIndex; j <= maxColumnDisplayIndex && columnDataIndex < rowData[rowDataIndex].Length; j++, columnDataIndex++)
                            {
                                DataGridColumn column = ColumnFromDisplayIndex(j);

                                if (column.Header.ToString() != "编号" && column.Header.ToString() != "编码" && column.Header.ToString() != "输出组号" && column.Header.ToString() != "手键号")
                                {
                                    if (column.Visibility == Visibility.Visible)
                                    {
                                        column.OnPastingCellClipboardContent(Items[i], rowData[rowDataIndex][columnDataIndex]);
                                    }
                                    else
                                    {
                                        columnDataIndex = columnDataIndex - 1;
                                    }
                                }
                            }
                            UpdateToModel(this.DetailType, Items[i], rowData[0], rowData[rowDataIndex]);
                        }
                    }
                    else
                    {
                        int rowDataIndex = 1;
                        if (this.SelectedCells != null)   //更新列信息
                        {
                            bool singleColumnFlag = true; //仅允许选择一列进行粘贴
                            if (SelectedCells.Count > 2)
                            {
                                int            columnIndex = this.SelectedCells[0].Column.DisplayIndex;
                                DataGridColumn column1     = ColumnFromDisplayIndex(columnIndex);
                                columnIndex = this.SelectedCells[1].Column.DisplayIndex;
                                DataGridColumn column2 = ColumnFromDisplayIndex(columnIndex);
                                if (column1.Header != column2.Header)
                                {
                                    singleColumnFlag = false;
                                }
                            }
                            if (singleColumnFlag)
                            {
                                for (int i = 0; i < this.SelectedCells.Count; i++)
                                {
                                    object         item        = this.SelectedCells[i].Item;
                                    int            columnIndex = this.SelectedCells[i].Column.DisplayIndex;
                                    DataGridColumn column      = ColumnFromDisplayIndex(columnIndex);
                                    if (column.Visibility == Visibility.Visible)
                                    {
                                        if (column.Header.ToString() == rowData[0][0])                            //粘贴列与复制列为同一列
                                        {
                                            column.OnPastingCellClipboardContent(item, rowData[rowDataIndex][0]); //固定为1列
                                            UpdateToModel(this.DetailType, item, rowData[0], rowData[rowDataIndex]);
                                        }
                                        else
                                        {
                                            break;
                                        }
                                    }

                                    //((EditableLinkageConfigMixed)this.SelectedCells[0].Item).ID
                                }
                            }
                        }
                    }



                    #region 更新选中区域
                    //if (hasAddedNewRow)
                    //{
                    //    UnselectAll();
                    //    UnselectAllCells();

                    //    CurrentItem = Items[minRowIndex];

                    //    if (SelectionUnit == DataGridSelectionUnit.FullRow)
                    //    {
                    //        SelectedItem = Items[minRowIndex];
                    //    }
                    //    else if (SelectionUnit == DataGridSelectionUnit.CellOrRowHeader ||
                    //             SelectionUnit == DataGridSelectionUnit.Cell)
                    //    {
                    //        SelectedCells.Add(new DataGridCellInfo(Items[minRowIndex], Columns[minColumnDisplayIndex]));

                    //    }
                    //}
                    #endregion
                }
            }
            catch (Exception ex)
            {
            }
        }
Пример #26
0
 public void CopyToClipboard()
 {
     // TODO: Build url
     ClipboardHelper.SetClipboardData(SelectedLutim.LutimInfo.Short);
 }
Пример #27
0
 private void btnCopyConfig_Click(object sender, RoutedEventArgs e)
 {
     ClipboardHelper.CopyFiles(ViewModelHelper.GetViewStateFile());
 }
        private void OnImageMouseClik(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            barButtonItemImagePaste.Enabled         = ClipboardHelper.GetImageFormClipboard() != null || ClipboardHelper.GetPngFormClipboard() != null || Clipboard.ContainsText(TextDataFormat.Html);
            barButtonItemImageFavoritesAdd.Enabled  = _currentClipartObject != _defaultClipartObject;
            barButtonItemImageFavoritesOpen.Enabled = FavoriteImagesManager.Instance.Images.Any();
            barButtonItemReset.Enabled = _currentClipartObject != _defaultClipartObject;

            popupMenuImage.ShowPopup(Cursor.Position);
        }
Пример #29
0
 protected override void SetToClipboardInt(string html, string plainText)
 {
     ClipboardHelper.CopyToClipboard(html, plainText);
 }
Пример #30
0
 /// <summary>
 /// Command callback.
 /// Called to copy the kana writing of the vocab to the clipboard.
 /// </summary>
 /// <param name="vocab">Vocab to copy.</param>
 private void OnKanaCopy(ExtendedVocab vocab)
 {
     ClipboardHelper.SetText(vocab.DbVocab.KanaWriting);
 }
        /// <summary>
        /// Creates a context menu.
        /// </summary>
        /// <param name="parms"></param>
        /// <param name="model"></param>
        /// <param name="webBrowser"></param>
        public void ShowContextMenu(PositionAndDocumentType parms, AppModel model, WebBrowser webBrowser)
        {
            var ctm = new ContextMenu();

            var mi = new MenuItem()
            {
                Header           = "View in Web _Browser",
                Command          = model.Commands.ViewInExternalBrowserCommand,
                InputGestureText = model.Commands.ViewInExternalBrowserCommand.KeyboardShortcut
            };

            ctm.Items.Add(mi);

            mi = new MenuItem()
            {
                Header           = "Refresh _Browser",
                Command          = model.Commands.RefreshPreviewCommand,
                InputGestureText = "F5"
            };
            ctm.Items.Add(mi);

            mi = new MenuItem()
            {
                Header  = "View Html _Source",
                Command = model.Commands.ViewHtmlSourceCommand
            };
            ctm.Items.Add(mi);

            ctm.Items.Add(new Separator());


            mi = new MenuItem()
            {
                Header  = "Save As _Html",
                Command = model.Commands.SaveAsHtmlCommand,
            };
            ctm.Items.Add(mi);

            mi = new MenuItem()
            {
                Header  = "Save As _Pdf",
                Command = model.Commands.GeneratePdfCommand,
            };
            ctm.Items.Add(mi);

            mi = new MenuItem()
            {
                Header  = "P_rint...",
                Command = model.Commands.PrintPreviewCommand,
            };
            ctm.Items.Add(mi);

            bool separatorAdded = false;

            if (!string.IsNullOrEmpty(parms.Id))
            {
                ctm.Items.Add(new Separator());
                separatorAdded = true;

                mi = new MenuItem()
                {
                    Header = "Copy Id to Clipboard: #" + parms.Id,
                };
                mi.Click += (s, e) =>
                {
                    ClipboardHelper.SetText("#" + parms.Id);
                };
                ctm.Items.Add(mi);
            }

            if (!string.IsNullOrEmpty(parms.Src))
            {
                if (!separatorAdded)
                {
                    ctm.Items.Add(new Separator());
                    separatorAdded = true;
                }

                mi = new MenuItem()
                {
                    Header = "Edit Image in Image editor"
                };
                mi.Click += (o, args) =>
                {
                    var image = HttpUtility.UrlDecode(parms.Src.Replace("file:///", ""));
                    image = mmFileUtils.NormalizeFilenameWithBasePath(image,
                                                                      Path.GetDirectoryName(model.ActiveDocument.Filename));
                    mmFileUtils.OpenImageInImageEditor(image);
                };
                ctm.Items.Add(mi);
            }

            if (!string.IsNullOrEmpty(parms.Href))
            {
                // Navigate relative hash links in the document
                if (parms.Href.StartsWith("#") && parms.Href.Length > 1)
                {
                    if (!separatorAdded)
                    {
                        ctm.Items.Add(new Separator());
                        separatorAdded = true;
                    }

                    var docModel = new DocumentOutlineModel();
                    int lineNo   = docModel.FindHeaderHeadline(model.ActiveEditor?.GetMarkdown(), parms.Href?.Substring(1));
                    if (lineNo > -1)
                    {
                        mi = new MenuItem()
                        {
                            Header = "Jump to: " + parms.Href, CommandParameter = parms.Href.Substring(1)
                        };
                        mi.Click += (s, e) =>
                        {
                            var mitem = s as MenuItem;

                            var anchor = mitem.CommandParameter as string;
                            if (string.IsNullOrEmpty(anchor))
                            {
                                return;
                            }

                            docModel = new DocumentOutlineModel();
                            lineNo   = docModel.FindHeaderHeadline(model.ActiveEditor?.GetMarkdown(), anchor);

                            if (lineNo != -1)
                            {
                                model.ActiveEditor.GotoLine(lineNo);
                            }
                        };
                        ctm.Items.Add(mi);
                    }
                }
            }


            ctm.Items.Add(new Separator());

            mi = new MenuItem()
            {
                Header  = "Edit Preview _Theme",
                Command = model.Commands.EditPreviewThemeCommand,
            };
            ctm.Items.Add(mi);

            mi = new MenuItem()
            {
                Header  = "Configure Preview Syncing",
                Command = model.Commands.PreviewSyncModeCommand,
            };
            ctm.Items.Add(mi);

            ctm.Items.Add(new Separator());


            mi = new MenuItem()
            {
                Header           = "Toggle Preview Window",
                Command          = model.Commands.TogglePreviewBrowserCommand,
                IsCheckable      = true,
                InputGestureText = model.Commands.TogglePreviewBrowserCommand.KeyboardShortcut,
                IsChecked        = model.IsPreviewBrowserVisible
            };
            ctm.Items.Add(mi);

            webBrowser.ContextMenu = ctm;
            ctm.Placement          = System.Windows.Controls.Primitives.PlacementMode.MousePoint;
            ctm.PlacementTarget    = webBrowser;
            ctm.IsOpen             = true;
        }