/// <summary> /// Cloud clipboard copy event handler /// </summary> private void CloudClipboardCopy() { try { try { if (!CommonFunctionality.processIsRunning("ClipboardMonitor")) beginClipboardCopy(); } catch (Exception e) { CommonFunctionality.Instance.Authenticate(true); // reauthenticate - session timeout? if (!CommonFunctionality.processIsRunning("ClipboardMonitor")) beginClipboardCopy(); } } catch (Exception e) { PrintLogCritialException(e); } }
/// <summary> /// Configures the shell extension menu and sets on click events /// </summary> /// <param name="menu">The menu.</param> /// <exception cref="System.Exception">Unable to setup cntent menu : + creationError.Message</exception> private void ConfigureShellExtension(ContextMenuStrip menu) // throws Exception[ { /* Create content menu */ try { try { var cloudcopyandpaste = new ToolStripMenuItem { Text = "Cloud copy/paste" }; cloudcopyandpaste.Image = Images.cloud16; menu.Items.Add(cloudcopyandpaste); var cloudclipboard = new ToolStripMenuItem { Text = "Clipboard" }; cloudclipboard.Image = Images.clipboard_empty; if (CommonFunctionality.processIsRunning("ClipboardMonitor")) { CommonFunctionality.Instance.logger.LogIt("Found ClipboardMonitor, using it..."); isUsingClipboardMonitor = true; } else { // first give the user the ability to manually copy the clkipboard contents... var cloudClipboardCopyMenuItem = new ToolStripMenuItem { Text = "Clipboard copy" }; cloudClipboardCopyMenuItem.Image = Images.clipboard_copy; cloudclipboard.DropDownItems.Add(cloudClipboardCopyMenuItem); cloudClipboardCopyMenuItem.Click += (sender, args) => CloudClipboardCopy(); isUsingClipboardMonitor = false; } var cloudClipboardPasteMenuItem = new ToolStripMenuItem { Text = "Clipboard paste" }; cloudClipboardPasteMenuItem.Image = Images.clipboard_paste; var cloudfilestorage = new ToolStripMenuItem { Text = "File" }; cloudfilestorage.Image = Images.file; var cloudCopyMenuItem = new ToolStripMenuItem { Text = "File copy" }; cloudCopyMenuItem.Image = Images.clipboard_copy; var cloudPasteMenuItem = new ToolStripMenuItem { Text = "File paste" }; cloudPasteMenuItem.Image = Images.clipboard_paste; PopulateDynamicMenuItems(cloudPasteMenuItem, cloudClipboardPasteMenuItem); /* Setup event handlers for the various options in the content menu. */ cloudCopyMenuItem.Click += (sender, args) => CloudCopyItem(); bool click_on_empty_space = SelectedItemPaths.Count<string>() > 0; // If we clicked on background of folder? // Finally add the menu items to the context menu. if (click_on_empty_space) // can only copy selected items cloudfilestorage.DropDownItems.Add(cloudCopyMenuItem); if (cloudClipboardPasteMenuItem.DropDownItems.Count > 0) cloudclipboard.DropDownItems.Add(cloudClipboardPasteMenuItem); if (cloudPasteMenuItem.DropDownItems.Count > 0) cloudfilestorage.DropDownItems.Add(cloudPasteMenuItem); cloudcopyandpaste.DropDownItems.Add(cloudclipboard); cloudcopyandpaste.DropDownItems.Add(cloudfilestorage); } catch (System.Net.WebException webex) { throw new System.Net.WebException("Problem configuring the shell extension:" + webex.Message); } catch (Exception) { // last ditch effort is to reauthenticate CommonFunctionality.Instance.Authenticate(true); ConfigureShellExtension(menu); } } catch (Exception creationError) { // throw it up higher throw new Exception( "Unable to setup cloud copy and paste shell extension menu : " + creationError.Message, creationError); } }