Skip to content

Commit

Permalink
Merge pull request #34 from beyluta/refactoring
Browse files Browse the repository at this point in the history
Refactor code and improve structure
  • Loading branch information
beyluta committed Jul 16, 2023
2 parents f60ebe0 + 1b8b158 commit e5c0f0e
Show file tree
Hide file tree
Showing 27 changed files with 438 additions and 408 deletions.
83 changes: 0 additions & 83 deletions Abstract/WidgetWindow.cs

This file was deleted.

3 changes: 1 addition & 2 deletions Assets/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"version": "1.2.0",
"remoteResources": "https://7xdeveloper.com/api/AccessEndpoint.php?endpoint=getappconfigs&id=resources"
"version": "1.2.1"
}
52 changes: 5 additions & 47 deletions Assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
<body>
<div class="half flex-row">
<div class="sidebar flex-column">
<div class="logo">
<img src="icon.png" />
<div class="logo-wrapper">
<div class="logo">
<img src="icon.png" />
</div>
<span class="version" id="version"></span>
</div>

<div class="sidebaricons flex-column">
Expand Down Expand Up @@ -98,54 +101,9 @@ <h3 id="nextwindowtitle">Browse Widgets</h3>
</div>

<div class="widgets flex-row" id="widgets">
<!-- <div class="widget flex-row">
<iframe
src="C:\Users\Beyluta\Documents\Widgets\clock.html'></iframe>"
></iframe>
<p>Clock Widget</p>
</div> -->
</div>

<div class="settings flex-row" id="options">
<div class="update flex-column" id="uptodate">
<svg
xmlns="http://www.w3.org/2000/svg"
width="50px"
viewBox="0 0 448 512"
>
<path
d="M438.6 105.4C451.1 117.9 451.1 138.1 438.6 150.6L182.6 406.6C170.1 419.1 149.9 419.1 137.4 406.6L9.372 278.6C-3.124 266.1-3.124 245.9 9.372 233.4C21.87 220.9 42.13 220.9 54.63 233.4L159.1 338.7L393.4 105.4C405.9 92.88 426.1 92.88 438.6 105.4H438.6z"
/>
</svg>
<h3 id="uptodatelabel">This Software is up-to-date</h3>
<p id="updatetime">Last checked today @ 11:54</p>
</div>

<div class="update flex-column" id="outdated">
<svg
xmlns="http://www.w3.org/2000/svg"
width="40px"
viewBox="0 0 320 512"
>
<path
d="M310.6 361.4c12.5 12.5 12.5 32.75 0 45.25C304.4 412.9 296.2 416 288 416s-16.38-3.125-22.62-9.375L160 301.3L54.63 406.6C48.38 412.9 40.19 416 32 416S15.63 412.9 9.375 406.6c-12.5-12.5-12.5-32.75 0-45.25l105.4-105.4L9.375 150.6c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0L160 210.8l105.4-105.4c12.5-12.5 32.75-12.5 45.25 0s12.5 32.75 0 45.25l-105.4 105.4L310.6 361.4z"
/>
</svg>
<h3>Newer versions of this software exists</h3>
<p id="newversion">Update to version 1.13.10</p>
<div class="updatechecker flex-row" id="updatebutton">
<svg
xmlns="http://www.w3.org/2000/svg"
width="20px"
viewBox="0 0 512 512"
>
<path
d="M480 352h-133.5l-45.25 45.25C289.2 409.3 273.1 416 256 416s-33.16-6.656-45.25-18.75L165.5 352H32c-17.67 0-32 14.33-32 32v96c0 17.67 14.33 32 32 32h448c17.67 0 32-14.33 32-32v-96C512 366.3 497.7 352 480 352zM432 456c-13.2 0-24-10.8-24-24c0-13.2 10.8-24 24-24s24 10.8 24 24C456 445.2 445.2 456 432 456zM233.4 374.6C239.6 380.9 247.8 384 256 384s16.38-3.125 22.62-9.375l128-128c12.49-12.5 12.49-32.75 0-45.25c-12.5-12.5-32.76-12.5-45.25 0L288 274.8V32c0-17.67-14.33-32-32-32C238.3 0 224 14.33 224 32v242.8L150.6 201.4c-12.49-12.5-32.75-12.5-45.25 0c-12.49 12.5-12.49 32.75 0 45.25L233.4 374.6z"
/>
</svg>
<p>Update now</p>
</div>
</div>
<div class="settingscard">
<h3>Application</h3>
<div class="setting flex-row">
Expand Down
28 changes: 5 additions & 23 deletions Assets/script.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
let fetchedVersion, isUpToDate, updateCheckTime, downloadUrl;
var version;

function setVersion(version) {
document.querySelector("#version").innerHTML = `v${version}`;
}

function filter(s) {
const children = document.getElementById("widgets").children;
Expand Down Expand Up @@ -56,28 +60,6 @@ function changeTab(element) {
document.getElementById("nextwindowtitle").style.display = "none";
document.getElementById("windowtitle").innerHTML = "Settings";
document.getElementById("development-container").style.display = "none";

if (isUpToDate) {
document.getElementById("outdated").style.display = "none";
document.getElementById("uptodate").style.display = "flex";
document.getElementById(
"uptodatelabel"
).innerText = `Software is up-to-date (v${fetchedVersion})`;
document.getElementById(
"updatetime"
).innerText = `Last checked on the ${updateCheckTime}`;
} else {
document.getElementById("outdated").style.display = "flex";
document.getElementById("uptodate").style.display = "none";
document.getElementById(
"newversion"
).innerText = `Update to new version ${
fetchedVersion ? fetchedVersion : "click below or check the website"
}`;
updatebutton.onclick = () => {
CefSharp.PostMessage("update");
};
}
break;
}
}
Expand Down
12 changes: 12 additions & 0 deletions Assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ svg {
padding-bottom: 30px;
}

.logo-wrapper {
display: flex;
flex-direction: column;
align-items: center;
gap: 10px;
}

.logo {
padding-top: 30px;
border-bottom: solid 1px rgba(1, 1, 1, 0.08);
Expand All @@ -65,6 +72,11 @@ svg {
width: 45px;
}

.version {
font-size: 12px;
color: var(--gray);
}

.maincontent {
width: 100%;
padding: 25px 30px;
Expand Down
39 changes: 0 additions & 39 deletions Classes/RemoteResources.cs

This file was deleted.

35 changes: 0 additions & 35 deletions Classes/WidgetAssets.cs

This file was deleted.

23 changes: 0 additions & 23 deletions Classes/WidgetList.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,48 +1,42 @@
using CefSharp;
using System;
using System.Windows.Forms;
using Widgets.Manager;
using Models;
using Services;

namespace Widgets
namespace Components
{
internal class WidgetMenuHandler : WindowEssentials, IContextMenuHandler
internal class MenuHandlerComponent : WindowModel, IContextMenuHandler
{
private Widget widget;
private WidgetComponent widgetComponent;
private MenuHandlerService menuHandlerService = new MenuHandlerService();
private WidgetService widgetService = new WidgetService();

public WidgetMenuHandler(Widget widget)
public MenuHandlerComponent(WidgetComponent widget)
{
this.widget = widget;
this.widgetComponent = widget;
}

public void OnBeforeContextMenu(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model)
{
model.Clear();
model.AddItem(0, "Toggle Move");
model.AddItem((CefMenuCommand)1, "Toggle Always on Top");
model.AddItem((CefMenuCommand)2, "Close Widget");
this.menuHandlerService.ClearModel(model);
this.menuHandlerService.AddOption("Toggle Move", 0, model);
this.menuHandlerService.AddOption("Toggle Always on Top", 1, model);
this.menuHandlerService.AddOption("Close Widget", 2, model);
}

public bool OnContextMenuCommand(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags)
{
switch (commandId)
{
case 0:
widget.moveModeEnabled = widget.moveModeEnabled ? false : true;
this.widgetService.ToggleMove(widgetComponent);
return true;

case (CefMenuCommand)1:
widget.window.Invoke(new MethodInvoker(delegate ()
{
widget.window.TopMost = widget.window.TopMost ? false : true;
}));
this.widgetService.ToggleTopMost(widgetComponent);
return true;

case (CefMenuCommand)2:
widget.window.BeginInvoke(new Action(() =>
{
widget.window.Close();
WidgetAssets.widgets.RemoveWidget(widget);
}));
this.widgetService.CloseWidget(widgetComponent);
return true;
}

Expand Down
Loading

0 comments on commit e5c0f0e

Please sign in to comment.