private void _importButton_Click(object sender, EventArgs e) { CheckNeedToSaveChanges(); if (!SelectedPlugin.IsConfigured()) { MessageBox.Show("Please complete the plugin configuration of the selected plugin first.", "Incompletely configured plugin", MessageBoxButtons.OK); return; } SetFormMode(FormMode.Importing); DisableAllButtons(); try { _importProgressBar.Value = 0; _feedBackLabel.Text = String.Empty; _hoster.Import(SelectedPlugin.Name, ProgressUpdate, FeedbackUpdate); } catch (Exception ex) { ShowException(ex, "Import error"); } finally { Thread.Sleep(500); SetFormMode(FormMode.Normal); DoButtonEnabling(); } }
public void RemoveSelectedPlugin() { DialogResult result = messagingService.ShowDialog("Do you really want to delete the selected plug-in?", "Delete plug-in?", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { try { File.Delete(SelectedPlugin.FilePath(PLUGIN_DIR)); File.Delete(Path.Combine(SelectedPlugin.Directory, SelectedPlugin.Config.File + ".plugin")); } catch (UnauthorizedAccessException) { messagingService.ShowMessage("Unauthorized access. Run program as Administrator.", "Error"); return; } catch (Exception) { messagingService.ShowMessage("Deleting plugin failed. Restart application and try again.", "Error"); return; } messagingService.ShowDialog("Update complete, do you want to restart the application to apply the update.", "Update complete", MessageBoxButtons.OK); Plugins.Remove(SelectedPlugin); PluginChecker.Instance.RemovePlugin(SelectedPlugin); } }
private void _configureButton_Click(object sender, EventArgs e) { CheckNeedToSaveChanges(); if (SelectedPlugin != null) { string selectedPluginName = SelectedPlugin.Name; SelectedPlugin.ShowConfigurationDialog(this); _hoster.ReloadPlugins(); FillPluginComboBox(); _pluginComboBox.SelectedItem = selectedPluginName; } }
private void RemoteActionButton_Click(object sender, EventArgs e) { if (SelectedPlugin.DownloadState == DownloadState.InformationDownloaded) { if (SelectedPlugin != null) { System.Diagnostics.Process.Start(SelectedPlugin.RemoteLocation); } } else if (SelectedPlugin.DownloadState == DownloadState.Error) { SelectedPlugin.ResetDownloadState(); ShowSelectedPluginInformation(); } }
private void DoButtonEnabling() { bool hasAvailableChannels = _availableChannelsListBox.Items.Count > 0; bool hasAvailableChannelSelected = hasAvailableChannels && _availableChannelsListBox.SelectedIndices.Count > 0; bool hasChannelsToSkip = _channelsToSkipListBox.Items.Count > 0; bool hasChannelsToSkipSelected = hasChannelsToSkip && _channelsToSkipListBox.SelectedItems.Count > 0; bool hasSelectedPlugin = SelectedPlugin != null; bool hasConfiguredPlugin = SelectedPlugin != null && SelectedPlugin.IsConfigured(); _addChannelButton.Enabled = hasAvailableChannelSelected; _removeChannelButton.Enabled = hasChannelsToSkipSelected; _addAllChannelButton.Enabled = hasAvailableChannels; _removeAllChannelButton.Enabled = hasChannelsToSkip; _importButton.Enabled = hasSelectedPlugin && hasAvailableChannels; _configureButton.Enabled = hasSelectedPlugin; _refreshButton.Enabled = hasConfiguredPlugin; _saveButton.Enabled = _needToSaveChanges; }
private void FillChannelListBoxes(bool forceChannelsReload) { _availableChannelsListBox.Items.Clear(); _channelsToSkipListBox.Items.Clear(); if (_pluginComboBox.SelectedIndex >= 0) { if (SelectedPlugin != null && SelectedPlugin.IsConfigured()) { try { List <ImportGuideChannel> guideChannels = SelectedPlugin.GetAllImportChannels(forceChannelsReload, ProgressUpdate, FeedbackUpdate); foreach (ImportGuideChannel guideChannel in guideChannels) { if (!SelectedPluginSetting.ChannelsToSkip.Contains(guideChannel)) { _availableChannelsListBox.Items.Add(guideChannel); } else { // if the ChannelName format was changed, make sure that ChannelNames in ChannelsToSkip reflect this change ImportGuideChannel importGuideChannel = SelectedPluginSetting.ChannelsToSkip.Find(a => a.ExternalId == guideChannel.ExternalId); if (importGuideChannel != null && !importGuideChannel.ChannelName.Equals(guideChannel.ChannelName)) { importGuideChannel.ChannelName = guideChannel.ChannelName; _needToSaveChanges = true; } } } foreach (ImportGuideChannel channel in SelectedPluginSetting.ChannelsToSkip) { _channelsToSkipListBox.Items.Add(channel); } } catch (Exception ex) { ShowException(ex, "Import error"); } } } }
private void _refreshButton_Click(object sender, EventArgs e) { if (!SelectedPlugin.IsConfigured()) { MessageBox.Show("Please complete the plugin configuration of the selected plugin first.", "Incompletely configured plugin", MessageBoxButtons.OK); return; } SetFormMode(FormMode.RefreshingChannels); DisableAllButtons(); try { _needToSaveChanges = false; FillChannelListBoxes(true); } catch (Exception ex) { ShowException(ex, "Error refreshing channels"); } finally { SetFormMode(FormMode.Normal); DoButtonEnabling(); } }
private void ShowSelectedPluginInformation() { object selectedItem = ListBox.SelectedItem; if (selectedItem == null) { LastUpdatedTitleLabel.Text = "Select an item to view update information"; LastUpdatedTitleLabel.Visible = true; LastUpdatedValueLabel.Visible = false; RemoteActionButton.Visible = false; } else if (AllFeed != null) { RssItem item = GetItemFor(AllFeed, SelectedPlugin); SelectedRssItem = item; if (item != null) { string glueLink = item.GlueLink; SelectedPlugin.RemoteLocation = glueLink; if (SelectedPlugin.DownloadState == DownloadState.InformationDownloaded) { LastUpdatedTitleLabel.Text = "Last Update: "; LastUpdatedValueLabel.Visible = true; LastUpdatedValueLabel.Text = SelectedPlugin.LastUpdate.ToString(); RemoteActionButton.Visible = true; RemoteActionButton.Text = "Go to GlueVault"; RemoteActionButton2.Visible = true; RemoteActionButton2.Text = "Install Latest Plugin"; } else if (SelectedPlugin.DownloadState == DownloadState.NotStarted) { LastUpdatedTitleLabel.Text = "Downloading information for " + item.Title; SelectedPlugin.TryStartDownload((arg) => { // The window may have been closed already if (this.Visible) { try { this.Invoke((MethodInvoker) delegate { ShowSelectedPluginInformation(); }); } catch { // no big deal, it's disposed most likely because the user closed the window. } } }); } else if (SelectedPlugin.DownloadState == DownloadState.Error) { LastUpdatedTitleLabel.Text = "Error getting information about plugin"; RemoteActionButton.Visible = true; RemoteActionButton2.Visible = false; RemoteActionButton.Text = "Try again"; } } else { LastUpdatedTitleLabel.Text = "Plugin not found on GlueVault.com:"; LastUpdatedValueLabel.Visible = false; RemoteActionButton.Visible = false; RemoteActionButton2.Visible = false; } //LastUpdatedTitleLabel.Text = "Last Updated:"; //LastUpdatedValueLabel.Text = "12 34 5678"; //LastUpdatedTitleLabel.Visible = true; //LastUpdatedValueLabel.Visible = true; //RemoteActionButton.Visible = true; //RemoteActionButton.Text = "Refresh"; } }