Skip to content

Commit 4844499

Browse files
authored
Merge pull request #66 from beyluta/development
Feat: Widget Drop Shadow & InnoSetup Script
2 parents 68868b5 + 0e7db7e commit 4844499

File tree

7 files changed

+129
-42
lines changed

7 files changed

+129
-42
lines changed

Assets/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ <h3>&#8226; Append the meta tags for the widget window</h3>
230230
&lt;meta name="windowOpacity" content="255"&gt;
231231
</div>
232232

233+
<div class="code">
234+
&lt;meta name="windowDropShadow" content="true"&gt;
235+
</div>
236+
233237
<div class="code">
234238
&lt;meta name="topMost" content="true"&gt;
235239
</div>

Components/Widget.Component.cs

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,26 +75,22 @@ public override void AppendWidget(Form window, string path)
7575

7676
double scale = Int32.Parse((string)Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ThemeManager", "LastLoadedDPI", "96")) / 96.0;
7777

78-
string sizeString = this.htmlDocService.GetMetaTagValue("windowSize", htmlPath);
79-
string radiusString = this.htmlDocService.GetMetaTagValue("windowBorderRadius", htmlPath);
80-
string locationString = this.htmlDocService.GetMetaTagValue("windowLocation", htmlPath);
81-
string topMostString = this.htmlDocService.GetMetaTagValue("topMost", htmlPath);
82-
string opacityString = this.htmlDocService.GetMetaTagValue("windowOpacity", htmlPath);
83-
int roundess = radiusString != null ? (int)(int.Parse(radiusString) * scale) : 0;
84-
this.width = sizeString != null ? (int)(int.Parse(sizeString.Split(' ')[0]) * scale) : (int)(width * scale);
85-
this.height = sizeString != null ? (int)(int.Parse(sizeString.Split(' ')[1]) * scale) : (int)(height * scale);
86-
int locationX = locationString != null ? int.Parse(locationString.Split(' ')[0]) : mousePos.X;
87-
int locationY = locationString != null ? int.Parse(locationString.Split(' ')[1]) : mousePos.Y;
88-
byte opacity = (byte)(opacityString != null ? byte.Parse(opacityString.Split(' ')[0]) : 255);
89-
bool topMost = topMostString != null ? bool.Parse(topMostString.Split(' ')[0]) : false;
78+
WidgetHtmlTags tags = GetWidgetHtmlTags(htmlPath);
79+
int roundess = tags.Radius != null ? (int)(int.Parse(tags.Radius) * scale) : 0;
80+
this.width = tags.Size != null ? (int)(int.Parse(tags.Size.Split(' ')[0]) * scale) : (int)(width * scale);
81+
this.height = tags.Size != null ? (int)(int.Parse(tags.Size.Split(' ')[1]) * scale) : (int)(height * scale);
82+
int locationX = tags.Location != null ? int.Parse(tags.Location.Split(' ')[0]) : mousePos.X;
83+
int locationY = tags.Location != null ? int.Parse(tags.Location.Split(' ')[1]) : mousePos.Y;
84+
byte opacity = (byte)(tags.Opacity != null ? byte.Parse(tags.Opacity.Split(' ')[0]) : 255);
85+
bool dropShadow = tags.DropShadow != null ? bool.Parse(tags.DropShadow.Split(' ')[0]) : false;
86+
bool topMost = tags.TopMost != null ? bool.Parse(tags.TopMost.Split(' ')[0]) : false;
9087
topMost = alwaysOnTop.HasValue ? (bool)alwaysOnTop : topMost;
9188

92-
window = new WidgetForm();
89+
window = new WidgetForm(dropShadow);
9390
window.Size = new Size(this.width, this.height);
9491
window.StartPosition = FormStartPosition.Manual;
95-
window.Location = locationString == null ? new Point(position.X, position.Y) : new Point(locationX, locationY);
92+
window.Location = tags.Location == null ? new Point(position.X, position.Y) : new Point(locationX, locationY);
9693
window.Text = title;
97-
// window.TopMost = topMost; delayed, because it causes a FormActivate event to be dispatched prematurely
9894
window.FormBorderStyle = FormBorderStyle.None;
9995
window.ShowInTaskbar = false;
10096
window.Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, this.width, this.height, roundess, roundess)); // Border radius
@@ -117,6 +113,19 @@ public override void AppendWidget(Form window, string path)
117113
}).Start();
118114
}
119115

116+
private WidgetHtmlTags GetWidgetHtmlTags(string htmlPath)
117+
{
118+
return new WidgetHtmlTags
119+
{
120+
Size = this.htmlDocService.GetMetaTagValue("windowSize", htmlPath),
121+
Radius = this.htmlDocService.GetMetaTagValue("windowBorderRadius", htmlPath),
122+
Location = this.htmlDocService.GetMetaTagValue("windowLocation", htmlPath),
123+
TopMost = this.htmlDocService.GetMetaTagValue("topMost", htmlPath),
124+
Opacity = this.htmlDocService.GetMetaTagValue("windowOpacity", htmlPath),
125+
DropShadow = this.htmlDocService.GetMetaTagValue("windowDropShadow", htmlPath)
126+
};
127+
}
128+
120129
private void OnBrowserInitialized(object sender, EventArgs e)
121130
{
122131
this.timerService.CreateTimer(1, OnBrowserUpdateTick, true, true);

Models/Configuration.Model.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ internal struct WidgetConfiguration
1818
public bool alwaysOnTop { get; set; }
1919
}
2020

21+
internal struct WidgetHtmlTags
22+
{
23+
public string Size { get; set; }
24+
public string Radius { get; set; }
25+
public string Location { get; set; }
26+
public string TopMost { get; set; }
27+
public string Opacity { get; set; }
28+
public string DropShadow { get; set; }
29+
}
30+
2131
internal struct Configuration
2232
{
2333
/// <summary>

Modules/WidgetForm.Module.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,29 @@ namespace Modules
66
{
77
internal class WidgetForm : Form
88
{
9-
private bool isWidget;
9+
private readonly bool isWidget;
10+
private readonly bool enableDropShadow;
1011

1112
/// <summary>
1213
/// Constructs a new instance of the WidgetForm class
1314
/// </summary>
1415
/// <param name="isWidget">Is the form a widget</param>
15-
public WidgetForm(bool isWidget = true) : base()
16+
public WidgetForm(bool enableDropShadow = false, bool isWidget = true) : base()
1617
{
1718
this.isWidget = isWidget;
19+
this.enableDropShadow = enableDropShadow;
20+
}
21+
22+
protected override CreateParams CreateParams
23+
{
24+
get
25+
{
26+
const int CS_DROPSHADOW = 0x20000;
27+
CreateParams cp = base.CreateParams;
28+
if (enableDropShadow)
29+
cp.ClassStyle |= CS_DROPSHADOW;
30+
return cp;
31+
}
1832
}
1933

2034
protected override void OnFormClosing(FormClosingEventArgs e)

README.md

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<p align="center">
44
<a href="https://github.com/beyluta/WinWidgets">
5-
<img src="https://img.shields.io/badge/Version-1.4.0-green" alt="WinWidgets version" />
5+
<img src="https://img.shields.io/badge/Version-1.5.0-green" alt="WinWidgets version" />
66
</a>
77
</p>
88

@@ -31,7 +31,7 @@
3131

3232
## About The Project
3333

34-
WinWidgets offers the possibility to create desktop widgets using HTML, CSS, and JavaScript for your Windows 10 or Windows 11 machine.
34+
**WinWidgets** makes web-based desktop widgets easy to develop. Using `HTML`, `CSS`, and `JavaScript` create your own Windows 11 widgets on the fly.
3535

3636
This is what makes this project interesting:
3737

@@ -40,10 +40,19 @@ This is what makes this project interesting:
4040
- 🖱️ Develop your widgets from anywhere then simply drag and drop to easily port it over
4141
- ⌨️ Have better control over your widget's window with built-in front-end tags
4242

43-
## Download
44-
You can find the latest version of WinWidgets on the [release page](https://github.com/beyluta/WinWidgets/releases) of the official GitHub repository.
43+
<!-- GETTING STARTED -->
44+
45+
## Prerequisites
46+
*As of `>= v1.5.0` all dependencies are automatically installed through the official installer.*
4547

46-
<i>Versions of WinWidgets < v1.3.0 requires Visual Studio and some .NET packages to be preinstalled. Newer versions of the Software (>= 1.3.0) do not have this dependency.</i>
48+
List of dependencies required for `< v1.5.0`. Make sure all of these are installed:
49+
50+
- .NET Framework 4.7.2
51+
- [Microsoft Visual C++ 2015-2019](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#visual-studio-2015-2017-2019-and-2022)
52+
53+
54+
## Download
55+
Download the latest version of WinWidgets through the [release page](https://github.com/beyluta/WinWidgets/releases) of this repository.
4756

4857
## Screenshots and usage
4958

@@ -56,14 +65,17 @@ You can find the latest version of WinWidgets on the [release page](https://gith
5665
#### Develop your own widgets easily. Find out more by navigating to the development panel
5766
<br><img src="Assets/Images/dev-widget.gif">
5867

59-
<!-- GETTING STARTED -->
68+
<!-- Development -->
6069

61-
## Prerequisites
70+
## Development
6271

63-
List of software required. Make sure all of these are installed.
72+
Simply fork or clone the project then open the solution file. Go ahead and build then run the Software.
73+
If you want to make your own installers for distribution: There is a script called `SETUP.iss` to help package the Software as an installer.
6474

65-
- .NET Framework 4.7.2
66-
- [Microsoft Visual C++ 2015-2019](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#visual-studio-2015-2017-2019-and-2022)
75+
- Visual Studio Community 2022 (or equivalent)
76+
- InnoSetup (Optional - for generating the installer)
77+
78+
*Note: I will not accept installer files. Make your PRs and I will personally compile it for distribution.*
6779

6880
<!-- CONTRIBUTING -->
6981

@@ -76,20 +88,6 @@ List of software required. Make sure all of these are installed.
7688
5. Add yourself to the CONTRIBUTORS.txt file
7789
6. Open a Pull Request
7890

79-
<!-- LICENSE -->
80-
81-
## License
82-
83-
Distributed under the MIT License. See `LICENSE.txt` for more information.
84-
85-
<!-- CONTACT -->
86-
87-
## Contact
88-
89-
📎 Pedro Ribeiro - <a href="https://pedroribeiro.site">Portfolio</a>
90-
<br>
91-
📫 Email: [email protected]
92-
9391
<!-- ACKNOWLEDGMENTS -->
9492

9593
## Acknowledgments
@@ -102,3 +100,4 @@ Many thanks to these projects for their super useful resources 😄
102100
- [Chromium](https://www.chromium.org/)
103101
- [CefSharp](https://cefsharp.github.io/)
104102
- [Json.NET](https://www.newtonsoft.com/json)
103+
- [Narod's FullscreenDetector](https://github.com/NarodGaming/gamedetector)

SETUP.iss

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#define MyAppName "WinWidgets"
2+
#define MyAppVersion "1.5.0"
3+
#define MyAppPublisher "Beyluta"
4+
#define MyAppURL "https://github.com/beyluta/WinWidgets"
5+
#define MyAppExeName "WidgetsDotNet.exe"
6+
7+
#define MyAppPath ".\bin\x64\Release"
8+
#define MyAppOutDir GetEnv("USERPROFILE") + "\\Downloads"
9+
#define MyRedistPath MyAppPath + "\VC_redist.x64.exe"
10+
11+
[Setup]
12+
AppId={{F8F9EED5-BFA1-4ACD-89D8-2639A711905F}
13+
AppName={#MyAppName}
14+
AppVersion={#MyAppVersion}
15+
AppPublisher={#MyAppPublisher}
16+
AppPublisherURL={#MyAppURL}
17+
AppSupportURL={#MyAppURL}
18+
AppUpdatesURL={#MyAppURL}
19+
DefaultDirName={autopf}\{#MyAppName}
20+
UninstallDisplayIcon={app}\{#MyAppExeName}
21+
ArchitecturesAllowed=x64compatible
22+
ArchitecturesInstallIn64BitMode=x64compatible
23+
DefaultGroupName={#MyAppName}
24+
DisableProgramGroupPage=yes
25+
PrivilegesRequiredOverridesAllowed=dialog
26+
OutputDir={#MyAppOutDir}
27+
OutputBaseFilename=WinWidgets_Installer
28+
SetupIconFile={#MyAppPath}\Assets\favicon.ico
29+
SolidCompression=yes
30+
WizardStyle=modern
31+
32+
[Languages]
33+
Name: "english"; MessagesFile: "compiler:Default.isl"
34+
35+
[Tasks]
36+
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
37+
38+
[Files]
39+
Source: "{#MyAppPath}\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
40+
Source: "{#MyAppPath}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
41+
Source: "{#MyRedistPath}"; DestDir: {tmp}
42+
43+
[Icons]
44+
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
45+
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
46+
47+
[Run]
48+
Filename: "{tmp}\VC_redist.x64.exe"; Parameters: "/quiet /norestart"; \
49+
Flags: waituntilterminated; \
50+
StatusMsg: "Installing VC++ 2015-2022 Redistributable..."
51+
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

Services/Asset.Service.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static class AssetService
3737
/// <summary>
3838
/// Semantic version of the application
3939
/// </summary>
40-
static private string version = "1.3.2";
40+
static private string version = "1.5.0";
4141

4242
/// <summary>
4343
/// Gets the path where the HTML files (widgets) of the project are stored

0 commit comments

Comments
 (0)