Skip to content

Commit

Permalink
v1.4: Add option to resize title block, closes #4
Browse files Browse the repository at this point in the history
  • Loading branch information
Twometer committed Apr 19, 2021
1 parent 2722e82 commit f17f3b7
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 18 deletions.
26 changes: 18 additions & 8 deletions NoFences/FenceWindow.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 34 additions & 7 deletions NoFences/FenceWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace NoFences
{
public partial class FenceWindow : Form
{
private const int titleHeight = 35;
private int titleHeight;
private const int titleOffset = 3;
private const int itemWidth = 75;
private const int itemHeight = 32 + itemPadding + textHeight;
Expand All @@ -25,8 +25,8 @@ public partial class FenceWindow : Form

private readonly FenceInfo fenceInfo;

private readonly Font titleFont;
private readonly Font iconFont;
private Font titleFont;
private Font iconFont;

private string selectedItem;
private string hoveringItem;
Expand All @@ -42,17 +42,25 @@ public partial class FenceWindow : Form

private DateTime lastRedraw = DateTime.Now;

private void ReloadFonts()
{
var family = new FontFamily("Segoe UI");
titleFont = new Font(family, (int)Math.Floor(titleHeight / 2.0));
iconFont = new Font(family, 9);
}

public FenceWindow(FenceInfo fenceInfo)
{
InitializeComponent();
DropShadow.ApplyShadows(this);
BlurUtil.EnableBlur(Handle);
WindowUtil.HideFromAltTab(Handle);
DesktopUtil.GlueToDesktop(Handle);
this.titleHeight = fenceInfo.TitleHeight;
if (titleHeight < 16 || titleHeight > 100)
titleHeight = 35;

var family = new FontFamily("Segoe UI");
titleFont = new Font(family, 17);
iconFont = new Font(family, 9);
ReloadFonts();

AllowDrop = true;

Expand Down Expand Up @@ -83,7 +91,8 @@ protected override void WndProc(ref Message m)

// Mouse leave
var myrect = new Rectangle(Location, Size);
if (m.Msg == 0x02a2 && !myrect.IntersectsWith(new Rectangle(MousePosition, new Size(1, 1)))) {
if (m.Msg == 0x02a2 && !myrect.IntersectsWith(new Rectangle(MousePosition, new Size(1, 1))))
{
Minify();
}

Expand Down Expand Up @@ -410,6 +419,24 @@ private void FenceWindow_Load(object sender, EventArgs e)
{

}

private void titleSizeToolStripMenuItem_Click(object sender, EventArgs e)
{
var dialog = new HeightDialog(fenceInfo.TitleHeight);
if (dialog.ShowDialog(this) == DialogResult.OK)
{
fenceInfo.TitleHeight = dialog.TitleHeight;
titleHeight = dialog.TitleHeight;
ReloadFonts();
Minify();
if (isMinified)
{
Height = titleHeight;
}
Refresh();
Save();
}
}
}

}
Expand Down
2 changes: 2 additions & 0 deletions NoFences/Model/FenceInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class FenceInfo

public bool CanMinify { get; set; }

public int TitleHeight { get; set; } = 35;

public List<string> Files { get; set; } = new List<string>();

public FenceInfo()
Expand Down
9 changes: 9 additions & 0 deletions NoFences/NoFences.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@
<Compile Include="EditDialog.Designer.cs">
<DependentUpon>EditDialog.cs</DependentUpon>
</Compile>
<Compile Include="HeightDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="HeightDialog.Designer.cs">
<DependentUpon>HeightDialog.cs</DependentUpon>
</Compile>
<Compile Include="Model\FenceInfo.cs" />
<Compile Include="Model\FenceManager.cs" />
<Compile Include="FenceWindow.cs">
Expand All @@ -74,6 +80,9 @@
<EmbeddedResource Include="FenceWindow.resx">
<DependentUpon>FenceWindow.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="HeightDialog.resx">
<DependentUpon>HeightDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
Expand Down
6 changes: 3 additions & 3 deletions NoFences/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("NoFences")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyDescription("Open Source Alternative to 'Stardock Fences'")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NoFences")]
Expand All @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.0.0")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: AssemblyVersion("1.4.0.0")]
[assembly: AssemblyFileVersion("1.4.0.0")]

0 comments on commit f17f3b7

Please sign in to comment.