Skip to content

Commit

Permalink
- Some improvements to minimize the frequency of #22
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-shilo committed Feb 4, 2023
1 parent 5342cbe commit 4a472ca
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions shell-x/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ protected override ContextMenuStrip CreateMenu()
var menu = new ContextMenuStrip();
menu.Items.AddRange(items);

// DisposeLastMenu();
// lastOpenedMenu = menu;
DisposeLastMenu();
lastOpenedMenu = menu;

return menu;
}
Expand All @@ -276,8 +276,8 @@ void DisposeLastMenu()
}
catch { }
}
// lastOpenedMenu.Close();
// lastOpenedMenu.Dispose();
lastOpenedMenu.Close();
lastOpenedMenu.Dispose();
}
}

Expand Down Expand Up @@ -329,7 +329,7 @@ internal static ToolStripItem[] BuildMenuFrom(string configDir, string invokeArg
try
{
var size = parentMenu.ContentRectangle.Height.ToStandardIconSize();
parentMenu.Image = parentMenu.Image?.Resize(size, size, dispose: true);
parentMenu.Image = parentMenu.Image?.Resize(size, size);
}
catch { }

Expand Down Expand Up @@ -358,7 +358,7 @@ internal static ToolStripItem[] BuildMenuFrom(string configDir, string invokeArg
{
var size = menu.ContentRectangle.Height.ToStandardIconSize();

menu.Image = menu.Image?.Resize(size, size, dispose: true);
menu.Image = menu.Image?.Resize(size, size);
}
catch { }

Expand Down Expand Up @@ -539,7 +539,7 @@ public static Image ReadImage(this string file)
}
}

public static Bitmap Resize(this Image image, int width, int height, bool dispose)
public static Bitmap Resize(this Image image, int width, int height)
{
var destRect = new Rectangle(0, 0, width, height);
var destImage = new Bitmap(width, height);
Expand All @@ -561,8 +561,6 @@ public static Bitmap Resize(this Image image, int width, int height, bool dispos
}
}

if (dispose)
image.Dispose();
return destImage;
}
}

0 comments on commit 4a472ca

Please sign in to comment.