Beispiel #1
0
        private void SetClipboard(ClipboardItem clipboardItem)
        {
            var dataObject = new DataObject();

            foreach(var pair in clipboardItem.Objects)
                dataObject.SetData(pair.Key, pair.Value);

            Clipboard.SetDataObject(dataObject, true, 5, 100);
            AutoClearFormatting();

            //uncheck all other items
            foreach(var ci in listClipboardItem)
                ci.MenuItem.Checked = false;

            //check current item
            clipboardItem.MenuItem.Checked = true;

            currentClipboardItem = clipboardItem;
        }
Beispiel #2
0
        private void AddClipboardItem(ClipboardItem clipboardItem)
        {
            currentClipboardItem = clipboardItem;
            listClipboardItem.Add(currentClipboardItem);

            //remove last item if list is greater than maximum size
            if(listClipboardItem.Count > 10)
                listClipboardItem.RemoveAt(0);

            AutoClearFormatting();
        }
Beispiel #3
0
        private ClipboardItem GetClipboard()
        {
            var clipboardItem = new ClipboardItem();
            var dataObject = Clipboard.GetDataObject();
            var formats = dataObject.GetFormats();

            foreach(var format in formats)
            {
                var data = dataObject.GetData(format);
                clipboardItem.Objects.Add(format, data);
            }

            var menuItem = new ToolStripMenuItem();
            clipboardItem.MenuItem = menuItem;
            menuItem.Tag = clipboardItem;
            menuItem.Click += menuItemClickHandler;
            menuItem.Text = DateTime.Now.ToString();

            //mark the current clipboard as checked
            foreach(var ci in listClipboardItem)
                ci.MenuItem.Checked = false;

            menuItem.Checked = true;

            //determine clipboard content text
            var text = (string)dataObject.GetData("Text");

            if(text == null)
            {
                var data = (string[])dataObject.GetData("FileName");
                text = string.Join("\n", data);
            }

            menuItem.DropDown.Items.Add(text);

            return clipboardItem;
        }
Beispiel #4
0
        public ClipboardItem BackslashesToSlashes()
        {
            var clipboardItem = new ClipboardItem();
            var dataObject = Clipboard.GetDataObject();
            var formats = dataObject.GetFormats();

            var textData = (string)dataObject.GetData("Text");
            textData = textData.Replace('\\', '/');
            clipboardItem.Objects.Add("Text", textData);

            var menuItem = new ToolStripMenuItem();
            clipboardItem.MenuItem = menuItem;
            menuItem.Tag = clipboardItem;
            menuItem.Click += menuItemClickHandler;
            menuItem.Text = DateTime.Now.ToString();

            //mark the current clipboard as checked
            foreach(var ci in listClipboardItem)
                ci.MenuItem.Checked = false;

            menuItem.Checked = true;

            //determine clipboard content text
            if(textData != null)
            {
                menuItem.DropDown.Items.Add(textData);
            }

            return clipboardItem;
        }