1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-22 18:15:47 +02:00

Make Plugins form always show Configure button when configurable

This commit is contained in:
chylex 2018-04-28 15:19:58 +02:00
parent 5c8fc1d136
commit 5b1dcc88cc

View File

@ -9,6 +9,7 @@ namespace TweetDuck.Plugins.Controls{
sealed partial class PluginControl : UserControl{
private readonly PluginManager pluginManager;
private readonly Plugin plugin;
private readonly bool isConfigurable;
private int nextHeight;
@ -20,6 +21,8 @@ public PluginControl(PluginManager pluginManager, Plugin plugin) : this(){
this.pluginManager = pluginManager;
this.plugin = plugin;
this.isConfigurable = pluginManager.IsPluginConfigurable(plugin);
float dpiScale = this.GetDPIScale();
if (dpiScale > 1F){
@ -58,7 +61,7 @@ private void panelDescription_Resize(object sender, EventArgs e){
Font font = labelDescription.Font;
int descriptionLines = TextRenderer.MeasureText(labelDescription.Text, font, new Size(maxWidth, int.MaxValue), TextFormatFlags.WordBreak).Height/(font.Height-1);
int requiredLines = Math.Max(descriptionLines, 1+(string.IsNullOrEmpty(labelVersion.Text) ? 0 : 1)+(btnConfigure.Visible ? 1 : 0));
int requiredLines = Math.Max(descriptionLines, 1+(string.IsNullOrEmpty(labelVersion.Text) ? 0 : 1)+(isConfigurable ? 1 : 0));
switch(requiredLines){
case 1: nextHeight = MaximumSize.Height-2*(font.Height-1); break;
@ -111,7 +114,8 @@ private void UpdatePluginState(){
labelName.ForeColor = textColor;
labelDescription.ForeColor = textColor;
btnToggleState.Text = isEnabled ? "Disable" : "Enable";
btnConfigure.Visible = isEnabled && pluginManager.IsPluginConfigurable(plugin);
btnConfigure.Visible = isConfigurable;
btnConfigure.Enabled = isEnabled;
}
else{
labelName.ForeColor = Color.DarkRed;