mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 02:37:03 -07:00
Introduced a very simple "singleton" service-locator, which allowed for a removal of specific implementations which were very limited. With this it's easier to access dependencies.
This commit is contained in:
parent
3ebdf3d2fe
commit
80d8f51fc5
53 changed files with 744 additions and 1230 deletions
|
@ -25,6 +25,7 @@ using System.Collections.Generic;
|
|||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Greenshot.Configuration;
|
||||
|
@ -191,37 +192,38 @@ namespace Greenshot {
|
|||
}
|
||||
|
||||
private void DisplayPluginTab() {
|
||||
if (!PluginHelper.Instance.HasPlugins()) {
|
||||
tabcontrol.TabPages.Remove(tab_plugins);
|
||||
} else {
|
||||
// Draw the Plugin listview
|
||||
listview_plugins.BeginUpdate();
|
||||
listview_plugins.Items.Clear();
|
||||
listview_plugins.Columns.Clear();
|
||||
string[] columns = {
|
||||
Language.GetString("settings_plugins_name"),
|
||||
Language.GetString("settings_plugins_version"),
|
||||
Language.GetString("settings_plugins_createdby"),
|
||||
Language.GetString("settings_plugins_dllpath")};
|
||||
foreach (string column in columns) {
|
||||
listview_plugins.Columns.Add(column);
|
||||
}
|
||||
PluginHelper.Instance.FillListview(listview_plugins);
|
||||
// Maximize Column size!
|
||||
for (int i = 0; i < listview_plugins.Columns.Count; i++) {
|
||||
listview_plugins.AutoResizeColumn(i, ColumnHeaderAutoResizeStyle.ColumnContent);
|
||||
int width = listview_plugins.Columns[i].Width;
|
||||
listview_plugins.AutoResizeColumn(i, ColumnHeaderAutoResizeStyle.HeaderSize);
|
||||
if (width > listview_plugins.Columns[i].Width) {
|
||||
listview_plugins.Columns[i].Width = width;
|
||||
}
|
||||
}
|
||||
listview_plugins.EndUpdate();
|
||||
listview_plugins.Refresh();
|
||||
|
||||
// Disable the configure button, it will be enabled when a plugin is selected AND isConfigurable
|
||||
button_pluginconfigure.Enabled = false;
|
||||
if (!SimpleServiceProvider.Current.GetAllInstances<IGreenshotPlugin>().Any())
|
||||
{
|
||||
tabcontrol.TabPages.Remove(tab_plugins);
|
||||
return;
|
||||
}
|
||||
// Draw the Plugin listview
|
||||
listview_plugins.BeginUpdate();
|
||||
listview_plugins.Items.Clear();
|
||||
listview_plugins.Columns.Clear();
|
||||
string[] columns = {
|
||||
Language.GetString("settings_plugins_name"),
|
||||
Language.GetString("settings_plugins_version"),
|
||||
Language.GetString("settings_plugins_createdby"),
|
||||
Language.GetString("settings_plugins_dllpath")};
|
||||
foreach (string column in columns) {
|
||||
listview_plugins.Columns.Add(column);
|
||||
}
|
||||
PluginHelper.Instance.FillListView(listview_plugins);
|
||||
// Maximize Column size!
|
||||
for (int i = 0; i < listview_plugins.Columns.Count; i++) {
|
||||
listview_plugins.AutoResizeColumn(i, ColumnHeaderAutoResizeStyle.ColumnContent);
|
||||
int width = listview_plugins.Columns[i].Width;
|
||||
listview_plugins.AutoResizeColumn(i, ColumnHeaderAutoResizeStyle.HeaderSize);
|
||||
if (width > listview_plugins.Columns[i].Width) {
|
||||
listview_plugins.Columns[i].Width = width;
|
||||
}
|
||||
}
|
||||
listview_plugins.EndUpdate();
|
||||
listview_plugins.Refresh();
|
||||
|
||||
// Disable the configure button, it will be enabled when a plugin is selected AND isConfigurable
|
||||
button_pluginconfigure.Enabled = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -333,9 +335,8 @@ namespace Greenshot {
|
|||
|
||||
listview_destinations.Items.Clear();
|
||||
listview_destinations.ListViewItemSorter = new ListviewWithDestinationComparer();
|
||||
ImageList imageList = new ImageList();
|
||||
imageList.ImageSize = coreConfiguration.ScaledIconSize;
|
||||
listview_destinations.SmallImageList = imageList;
|
||||
ImageList imageList = new ImageList {ImageSize = coreConfiguration.ScaledIconSize};
|
||||
listview_destinations.SmallImageList = imageList;
|
||||
int imageNr = -1;
|
||||
foreach (IDestination currentDestination in DestinationHelper.GetAllDestinations()) {
|
||||
Image destinationImage = currentDestination.DisplayIcon;
|
||||
|
@ -502,7 +503,8 @@ namespace Greenshot {
|
|||
MainForm.RegisterHotkeys();
|
||||
|
||||
// Make sure the current language & settings are reflected in the Main-context menu
|
||||
MainForm.Instance.UpdateUi();
|
||||
var mainForm = SimpleServiceProvider.Current.GetInstance<MainForm>();
|
||||
mainForm?.UpdateUi();
|
||||
DialogResult = DialogResult.OK;
|
||||
} else {
|
||||
tabcontrol.SelectTab(tab_output);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue