-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eb94d6d
commit 17c84b5
Showing
44 changed files
with
1,086 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:local="clr-namespace:SG_Net_Switcher" | ||
x:Class="SG_Net_Switcher.App"> | ||
<Application.Resources> | ||
<ResourceDictionary> | ||
|
||
<Color x:Key="PageBackgroundColor">#512bdf</Color> | ||
<Color x:Key="PrimaryTextColor">White</Color> | ||
|
||
<Style TargetType="Label"> | ||
<Setter Property="TextColor" Value="{DynamicResource PrimaryTextColor}" /> | ||
<Setter Property="FontFamily" Value="OpenSansRegular" /> | ||
</Style> | ||
|
||
<Style TargetType="Button"> | ||
<Setter Property="TextColor" Value="{DynamicResource PrimaryTextColor}" /> | ||
<Setter Property="FontFamily" Value="OpenSansRegular" /> | ||
<Setter Property="BackgroundColor" Value="#2b0b98" /> | ||
<Setter Property="Padding" Value="14,10" /> | ||
</Style> | ||
|
||
</ResourceDictionary> | ||
</Application.Resources> | ||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace SG_Net_Switcher | ||
{ | ||
public partial class App : Application | ||
{ | ||
public App() | ||
{ | ||
InitializeComponent(); | ||
|
||
MainPage = new MainPage(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
@inherits LayoutComponentBase | ||
<style> | ||
.container-bottom { | ||
min-height: 100vh; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-between; | ||
} | ||
</style> | ||
|
||
<div class="page container-bottom"> | ||
<main> | ||
<article class="content p-4"> | ||
@Body | ||
</article> | ||
</main> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
.page { | ||
position: relative; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
main { | ||
flex: 1; | ||
} | ||
|
||
.sidebar { | ||
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); | ||
} | ||
|
||
.top-row { | ||
background-color: #f7f7f7; | ||
border-bottom: 1px solid #d6d5d5; | ||
justify-content: flex-end; | ||
height: 3.5rem; | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.top-row ::deep a, .top-row ::deep .btn-link { | ||
white-space: nowrap; | ||
margin-left: 1.5rem; | ||
text-decoration: none; | ||
} | ||
|
||
.top-row ::deep a:hover, .top-row ::deep .btn-link:hover { | ||
text-decoration: underline; | ||
} | ||
|
||
.top-row ::deep a:first-child { | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
} | ||
|
||
@media (max-width: 640.98px) { | ||
.top-row { | ||
justify-content: space-between; | ||
} | ||
|
||
.top-row ::deep a, .top-row ::deep .btn-link { | ||
margin-left: 0; | ||
} | ||
} | ||
|
||
@media (min-width: 641px) { | ||
.page { | ||
flex-direction: row; | ||
} | ||
|
||
.sidebar { | ||
width: 250px; | ||
height: 100vh; | ||
position: sticky; | ||
top: 0; | ||
} | ||
|
||
.top-row { | ||
position: sticky; | ||
top: 0; | ||
z-index: 1; | ||
} | ||
|
||
.top-row.auth ::deep a:first-child { | ||
flex: 1; | ||
text-align: right; | ||
width: 0; | ||
} | ||
|
||
.top-row, article { | ||
padding-left: 2rem !important; | ||
padding-right: 1.5rem !important; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
@page "/" | ||
@using SG_Net_Switcher.Services | ||
@inject NetworkService _networkService | ||
|
||
<div class="row m-0 p-0"> | ||
<div class="col m-0 p-o"> | ||
<p class="my-1 mx-0">Статус WiFi: @{ | ||
if (_networkService.IsWifiConnected()) | ||
{ | ||
<span class="text-success">Подключен</span> | ||
} | ||
|
||
else | ||
{ | ||
<span class="text-danger">Не подключен</span>} | ||
} | ||
</p> | ||
<p class="my-1 mx-0">Router IP: @_networkService.GetRouterIp()</p> | ||
<p class="my-1 mx-0">My IP: @_networkService.GetMyIp()</p> | ||
</div> | ||
<div class="col-auto m-0 p-0"> | ||
<button class="btn btn-link" @onclick="UpdatePage">Обновить</button> | ||
</div> | ||
</div> | ||
<br /> | ||
<h3 class="display-3 text-center">Переключение интернета</h3> | ||
<br class="m-2" /> | ||
|
||
|
||
<h5 class="display-5 ms-1">Элина</h5> | ||
<div class="d-grid gap-2"> | ||
<button class="btn btn-lg btn-success" type="button" disabled="@DisableButtonCheck()" @onclick=@(x=>Sent("inet_elina_on"))>Включить</button> | ||
<button class="btn btn-lg btn-danger" type="button" disabled="@DisableButtonCheck()" @onclick=@(x=>Sent("inet_elina_off"))>Отключить</button> | ||
</div> | ||
|
||
<br /> | ||
<br /> | ||
|
||
<h5 class="display-5 ms-1">Елисей</h5> | ||
<div class="d-grid gap-2"> | ||
<button class="btn btn-lg btn-success" type="button" disabled="@DisableButtonCheck()" @onclick=@(x=>Sent("inet_seka_on"))>Включить</button> | ||
<button class="btn btn-lg btn-danger" type="button" disabled="@DisableButtonCheck()" @onclick=@(x=>Sent("inet_seka_off"))>Отключить</button> | ||
</div> | ||
|
||
<br class="m-2" /> | ||
@if (!string.IsNullOrEmpty(Result)) | ||
{ | ||
<figure class="text-center"> | ||
<blockquote class="blockquote"> | ||
@Result | ||
</blockquote> | ||
<figcaption class="blockquote-footer"> | ||
Результат | ||
</figcaption> | ||
</figure> | ||
} | ||
|
||
|
||
@code { | ||
public bool DisableButtonCheck() => !_networkService.IsWifiConnected(); | ||
public string Result = ""; | ||
|
||
public void UpdatePage() | ||
{ | ||
StateHasChanged(); | ||
} | ||
|
||
public void Sent(string ScriptName) | ||
{ | ||
Result = _networkService.SendCommand(ScriptName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:local="clr-namespace:SG_Net_Switcher" | ||
x:Class="SG_Net_Switcher.MainPage" | ||
BackgroundColor="{DynamicResource PageBackgroundColor}"> | ||
|
||
<BlazorWebView x:Name="blazorWebView" HostPage="wwwroot/index.html"> | ||
<BlazorWebView.RootComponents> | ||
<RootComponent Selector="#app" ComponentType="{x:Type local:Routes}" /> | ||
</BlazorWebView.RootComponents> | ||
</BlazorWebView> | ||
|
||
</ContentPage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace SG_Net_Switcher | ||
{ | ||
public partial class MainPage : ContentPage | ||
{ | ||
public MainPage() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Microsoft.Extensions.Logging; | ||
using SG_Net_Switcher.Services; | ||
|
||
namespace SG_Net_Switcher | ||
{ | ||
public static class MauiProgram | ||
{ | ||
public static MauiApp CreateMauiApp() | ||
{ | ||
var builder = MauiApp.CreateBuilder(); | ||
builder | ||
.UseMauiApp<App>() | ||
.ConfigureFonts(fonts => | ||
{ | ||
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); | ||
}); | ||
|
||
builder.Services.AddMauiBlazorWebView(); | ||
|
||
#if DEBUG | ||
builder.Services.AddBlazorWebViewDeveloperTools(); | ||
builder.Logging.AddDebug(); | ||
#endif | ||
builder.Services.AddSingleton<NetworkService>(); | ||
|
||
return builder.Build(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="2" android:versionName="PerUserSwitch"> | ||
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:supportsRtl="true" android:label="NetSwitcher"></application> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | ||
<uses-sdk /> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using Android.Content; | ||
using Android.Net; | ||
using Android.Net.Wifi; | ||
using Android.SE.Omapi; | ||
using Android.Text.Format; | ||
using SG_Net_Switcher.Platforms.Android; | ||
using SG_Net_Switcher.Services; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
[assembly: Dependency(typeof(DHCP_Service))] | ||
namespace SG_Net_Switcher.Platforms.Android | ||
{ | ||
public class DHCP_Service : IDHCP_Service | ||
{ | ||
public string GetGatewayIP() | ||
{ | ||
var dhcpInfo = GetDhcpInfo(); | ||
int gateway = dhcpInfo.Gateway; | ||
string gatewayIP = Formatter.FormatIpAddress(gateway); | ||
return gatewayIP; | ||
} | ||
|
||
public string GetMyIP() | ||
{ | ||
var dhcpInfo = GetDhcpInfo(); | ||
int MyIp = dhcpInfo.IpAddress; | ||
string MyIP = Formatter.FormatIpAddress(MyIp); | ||
return MyIP; | ||
} | ||
|
||
private DhcpInfo GetDhcpInfo() | ||
{ | ||
WifiManager wifiManager = (WifiManager)global::Android.App.Application.Context.GetSystemService(Context.WifiService); | ||
var dhcpInfo = wifiManager.DhcpInfo; | ||
return dhcpInfo; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Android.App; | ||
using Android.Content.PM; | ||
using Android.OS; | ||
|
||
namespace SG_Net_Switcher | ||
{ | ||
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)] | ||
public class MainActivity : MauiAppCompatActivity | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Android.App; | ||
using Android.Runtime; | ||
|
||
namespace SG_Net_Switcher | ||
{ | ||
[Application] | ||
public class MainApplication : MauiApplication | ||
{ | ||
public MainApplication(IntPtr handle, JniHandleOwnership ownership) | ||
: base(handle, ownership) | ||
{ | ||
} | ||
|
||
protected override MauiApp CreateMauiApp() | ||
{ | ||
var builder = MauiApp.CreateBuilder(); | ||
builder | ||
.UseMauiApp<App>() | ||
.ConfigureFonts(fonts => | ||
{ | ||
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); | ||
}); | ||
builder.Services.AddMauiBlazorWebView(); | ||
|
||
// Регистрация сервисов | ||
builder.Services.AddSingleton<Services.NetworkService>(); | ||
builder.Services.AddSingleton<Services.IDHCP_Service, Platforms.Android.DHCP_Service>(); | ||
return builder.Build(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="colorPrimary">#512BD4</color> | ||
<color name="colorPrimaryDark">#2B0B98</color> | ||
<color name="colorAccent">#2B0B98</color> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Foundation; | ||
|
||
namespace SG_Net_Switcher | ||
{ | ||
[Register("AppDelegate")] | ||
public class AppDelegate : MauiUIApplicationDelegate | ||
{ | ||
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<!-- See https://aka.ms/maui-publish-app-store#add-entitlements for more information about adding entitlements.--> | ||
<dict> | ||
<!-- App Sandbox must be enabled to distribute a MacCatalyst app through the Mac App Store. --> | ||
<key>com.apple.security.app-sandbox</key> | ||
<true/> | ||
<!-- When App Sandbox is enabled, this value is required to open outgoing network connections. --> | ||
<key>com.apple.security.network.client</key> | ||
<true/> | ||
</dict> | ||
</plist> | ||
|
Oops, something went wrong.