Example #1
0
        /// <summary>
        /// Method that copies item from the history list to the clipboard
        /// (if anything is in the clipboard, it will be removed and be replaced with the selected item)
        /// </summary>
        private void Button_Copy_Click(object sender, RoutedEventArgs e)
        {
            if (crClipHistoryList.SelectedIndex < 0)
            {
                MessageBox.Show("No item selected!", "Select Item First!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                /// string currentlySelected = crClipHistoryList.SelectedItem.ToString();
                /// Dictionary<string,string> keyValuePairs = currentlySelected.Split("=")

                /// The following works too!
                /// var selectedClipboardRecord = crClipHistoryList.SelectedItems[0] as ClipboardRecords;
                /// Clipboard.SetText(selectedClipboardRecord.Content);

                /// The following works too!
                /// ClipboardRecords selectedHistoryRecord = (ClipboardRecords)crClipHistoryList.SelectedItems[0];
                /// Clipboard.SetText(selectedHistoryRecord.Content);

                /// The following works too!
                ClipboardRecords selectedHistoryRecord = crClipHistoryList.SelectedItem as ClipboardRecords;
                Clipboard.SetText(selectedHistoryRecord.Content);

                Notifications showNotification = new Notifications("Item copied!");
                showNotification.Show();
            }
        }
Example #2
0
 private void AddSeedData()
 {
     string[] seedData = { "A string of Data", "Another string of data", "Why not? lets have another string", "A string of Data", "Another string of data", "Why not? lets have another string", "A string of Data", "Another string of data", "Why not? lets have another string", "A string of Data", "Another string of data", "Why not? lets have another string" };
     foreach (string str in seedData)
     {
         ClipboardRecords newRecord = new ClipboardRecords();
         newRecord.Counter = listCounter;
         newRecord.Content = str;
         newRecord.Size    = SizeSuffix(GetSize(str));
         crClipHistoryList.Items.Add(newRecord);
         this.listCounter++;
     }
 }
Example #3
0
        /// <summary>
        /// Method that copies the selected item from the history list and replaces it with what is in the clipboard
        /// if clipboard is empty, it merely copies the item to clipboard
        /// </summary>
        private void Button_Copy_And_Replace_Click(object sender, RoutedEventArgs e)
        {
            /// Get the current data from clipboard
            ClipboardRecords selectedHistoryRecord = crClipHistoryList.SelectedItem as ClipboardRecords;
            string           currentlySelected     = selectedHistoryRecord.Content;

            /// setting the selected item's content to what is in the clipboard
            selectedHistoryRecord.Content = Clipboard.GetText();

            /// lets copy the selected item to the clipboard
            Clipboard.SetText(currentlySelected);

            /// let's refresh our listview control...
            crClipHistoryList.Items.Refresh();
        }
Example #4
0
        private void AddClipboardContent()
        {
            /// if clipboard is empty, we simply return...
            if (Clipboard.ContainsData(DataFormats.Text) == false)
            {
                return;
            }

            if (Clipboard.ContainsText())
            {
                ClipboardRecords cr = new ClipboardRecords();
                cr.Counter = 1;
                cr.Content = Clipboard.GetText();
                cr.Size    = SizeSuffix(GetSize(Clipboard.GetText()));
                /// instead of the Add() method, we will use the Insert() method,
                /// as the Add() method will append the new clipboard content.
                /// Insert() on the other hand adds the new clipboard content
                /// to the beginning of the list
                /// crClipHistoryList.Items.Add(cr);
                crClipHistoryList.Items.Insert(0, cr);
                this.listCounter++;
                crClipHistoryList.Items.Refresh();

                /// lets notify the user via a balloon popup notification
                /// that the newly copied item has been added to the
                /// clipboard history list
                Notifications itemAdded = new Notifications("Copied to Clipboard History!");
                itemAdded.Show();
            }

            IDataObject clipBoardData = Clipboard.GetDataObject();

            crCurrentContent.Content = Clipboard.GetText(); // set the label to what's currently in the clipboard

            var totalCharacters = 0;

            totalCharacters = Clipboard.GetText().Count();

            crCurrentStats.Content = "Stats: Total Characters: " + totalCharacters;
            //throw new NotImplementedException();
        }
Example #5
0
        public void PasteOnLoad()
        {
            /// if clipboard is empty, we simply return...
            if (Clipboard.ContainsData(DataFormats.Text) == false)
            {
                return;
            }

            IDataObject clipBoardData = Clipboard.GetDataObject();

            crCurrentContent.Content = Clipboard.GetText(); // set the label to what's currently in the clipboard

            ClipboardRecords currentClipboardItem = new ClipboardRecords();

            currentClipboardItem.Counter = listCounter;
            currentClipboardItem.Content = Clipboard.GetText();
            currentClipboardItem.Size    = SizeSuffix(GetSize(Clipboard.GetText()));
            crClipHistoryList.Items.Add(currentClipboardItem);

            this.listCounter++;
        }