Skip to content
This repository has been archived by the owner on Jan 26, 2025. It is now read-only.

Commit

Permalink
feat: install local tooth by drag .tth file
Browse files Browse the repository at this point in the history
  • Loading branch information
Pd233 committed Jan 20, 2024
1 parent be000b4 commit 59565ad
Show file tree
Hide file tree
Showing 42 changed files with 209 additions and 246 deletions.
2 changes: 1 addition & 1 deletion src/LipUI/LipUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</ItemGroup>

<ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
<ProjectCapability Include="Msix"/>
<ProjectCapability Include="Msix" />
</ItemGroup>

<PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices;
using WinRT;
using static PInvoke.User32;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
BorderThickness="0"
Background="{x:Bind settings:PersonalizationSettingsView.MyRes.ApplicationBackgroundImage,Mode=TwoWay}"
x:Name="RootBorder"
CornerRadius="0">
CornerRadius="0"
AllowDrop="True"
Drop="RootBorder_Drop"
CanDrag="True"
DragOver="RootBorder_DragOver">

<Grid
x:Name="MainWondowRootGrid"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using LipUI.Models;
using LipUI.Models.Lip;
using LipUI.Models.Plugin;
using LipUI.Pages.LipExecutionPanel;
using LipUI.Pages.Settings;
using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using System;
using System.Threading;
using System.Threading.Tasks;
using Octokit;
using Windows.ApplicationModel.DataTransfer;
using Windows.Storage;
using Windows.System;

// To learn more about WinUI, the WinUI project structure,
Expand Down Expand Up @@ -148,4 +150,49 @@ void task(object? sender, object e)
mre.Dispose();
});
}

private async void RootBorder_Drop(object sender, DragEventArgs e)
{
if (e.DataView.Contains(StandardDataFormats.StorageItems) is false)
return;

foreach (var item in await e.DataView.GetStorageItemsAsync())
{
if (item is StorageFile file && Path.GetExtension(file.Path) is ".tth")
{
var lip = await Main.CreateLipConsole(RootBorder.XamlRoot);
if (lip is null)
{
InternalServices.ShowInfoBar(
"infobar$error".GetLocalized(),
Main.Config.SelectedServer is null ?
"lipExecution$nullServerPath".GetLocalized() :
"lipExecution$nullLipPath".GetLocalized(),
InfoBarSeverity.Error);

return;
}
var cmd = LipCommand.CreateCommand() + LipCommand.Install + file.Path;
var info = new List<string>();

ContentFrame.Navigate(
typeof(LipExecutionPanelPage),
new LipExecutionPanelPage.NavigationArgs(file.Path, info, lip, cmd));
}
else
{
await InternalServices.ShowInfoBarAsync(
"infobar$error".GetLocalized(),
@$"{item.Name} is not a '.tth' file.",
InfoBarSeverity.Error);
}
}
}

private void RootBorder_DragOver(object sender, DragEventArgs e)
{
e.AcceptedOperation = DataPackageOperation.Move;
e.DragUIOverride.IsCaptionVisible = false;
e.DragUIOverride.IsGlyphVisible = false;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using LipUI.Models.Plugin;
using LipUI.Models;
using LipUI.Models.Plugin;
using LipUI.Pages.Home;
using LipUI.Pages.Index;
using LipUI.Pages.LocalPackage;
Expand All @@ -8,10 +9,7 @@
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media.Animation;
using Microsoft.UI.Xaml.Navigation;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;

namespace LipUI;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using LipUI.Models.Plugin;
using LipUI.Models;
using LipUI.Models.Plugin;
using Microsoft.UI.Xaml.Controls;
using System;
using System.Collections.Generic;

namespace LipUI;

Expand Down
2 changes: 0 additions & 2 deletions src/LipUI/Models/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
using LipUI.Pages.Settings;
using Microsoft.UI;
using Microsoft.UI.Xaml;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Text.Json.Serialization;

namespace LipUI.Models;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media.Imaging;
using Microsoft.Windows.ApplicationModel.Resources;
using System;
using System.IO;
using System.Threading.Tasks;
using Windows.UI;

namespace LipUI;
namespace LipUI.Models;

internal static class ResourceExtensions
{
Expand Down
4 changes: 1 addition & 3 deletions src/LipUI/Models/Lip/LipCommand.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace LipUI.Models.Lip;
namespace LipUI.Models.Lip;

public class LipCommand
{
Expand Down
5 changes: 1 addition & 4 deletions src/LipUI/Models/Lip/LipCommandContext.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text;

namespace LipUI.Models.Lip;

Expand Down
3 changes: 1 addition & 2 deletions src/LipUI/Models/Lip/LipCommandOption.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using static LipUI.Models.Lip.LipCommand;
using static LipUI.Models.Lip.LipCommand;

namespace LipUI.Models.Lip;

Expand Down
5 changes: 1 addition & 4 deletions src/LipUI/Models/Lip/LipConsole.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Diagnostics;
using System.Diagnostics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace LipUI.Models.Lip;

Expand Down
5 changes: 1 addition & 4 deletions src/LipUI/Models/Lip/LipConsoleInstance.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Diagnostics;
using System.Text;
using System.Threading;

namespace LipUI.Models.Lip;

Expand Down
7 changes: 2 additions & 5 deletions src/LipUI/Models/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
using LipUI.Pages.LipExecutionPanel;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Threading.Tasks;

namespace LipUI.Models;

Expand Down Expand Up @@ -61,7 +58,7 @@ private static void InitializeConfig()
}
}

public static async ValueTask<LipConsole?> CreateLipConsole(XamlRoot xamlRoot)
public static async ValueTask<LipConsole?> CreateLipConsole(XamlRoot xamlRoot, string? workingDir = null)
{
var (success, path) = await TryGetLipConsolePathAsync(xamlRoot);
if (success is false)
Expand All @@ -71,7 +68,7 @@ private static void InitializeConfig()
if (server is null)
return null;

return new LipConsole(path!, server.WorkingDirectory);
return new LipConsole(path!, workingDir is null ? server.WorkingDirectory : workingDir);
}


Expand Down
4 changes: 1 addition & 3 deletions src/LipUI/Models/Plugin/ILipuiPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace LipUI.Models.Plugin;
namespace LipUI.Models.Plugin;

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)]
public sealed class LipUIModuleAttribute : Attribute
Expand Down
1 change: 0 additions & 1 deletion src/LipUI/Models/Plugin/ILipuiPluginModule.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using LipUI.Pages.Home.Modules;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Media;
using System;

namespace LipUI.Models.Plugin;

Expand Down
1 change: 0 additions & 1 deletion src/LipUI/Models/Plugin/ILipuiPluginUI.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.UI.Xaml.Controls;
using System;

namespace LipUI.Models.Plugin;

Expand Down
16 changes: 9 additions & 7 deletions src/LipUI/Models/Plugin/LipuiServices.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using LipUI.Models.Lip;
#pragma warning disable CA1822

using LipUI.Models.Lip;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using System;
using System.Threading.Tasks;

namespace LipUI.Models.Plugin;

Expand All @@ -18,23 +18,23 @@ public class LipuiServices
return null;
}

public static async ValueTask ShowInfoBarAsync(
public async ValueTask ShowInfoBarAsync(
string? title,
string? message = null,
InfoBarSeverity severity = InfoBarSeverity.Informational,
TimeSpan interval = default,
UIElement? barContent = null)
=> await InternalServices.ShowInfoBarAsync(title, message, severity, interval, barContent);

public static async ValueTask ShowInfoBarAsync(
public async ValueTask ShowInfoBarAsync(
Exception ex,
bool containsStacktrace = false,
InfoBarSeverity severity = InfoBarSeverity.Error,
TimeSpan interval = default,
UIElement? barContent = null)
=> await InternalServices.ShowInfoBarAsync(ex, containsStacktrace, severity, interval, barContent);

public static void ShowInfoBar(
public void ShowInfoBar(
string? title,
string? message = null,
InfoBarSeverity severity = InfoBarSeverity.Informational,
Expand All @@ -43,12 +43,14 @@ public static void ShowInfoBar(
Action? completed = null)
=> InternalServices.ShowInfoBar(title, message, severity, interval, barContent, completed);

public static void ShowInfoBar(
public void ShowInfoBar(
Exception ex,
bool containsStacktrace = false,
InfoBarSeverity severity = InfoBarSeverity.Error,
TimeSpan interval = default,
UIElement? barContent = null,
Action? completed = null)
=> InternalServices.ShowInfoBar(ex, containsStacktrace, severity, interval, barContent, completed);

public string? CurrentServerDirectory => Main.Config.SelectedServer?.WorkingDirectory;
}
5 changes: 0 additions & 5 deletions src/LipUI/Models/Plugin/PluginSystem.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
using LipUI.Pages.Home.Modules;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Loader;
using System.Threading.Tasks;
using guid_string = System.String;

namespace LipUI.Models.Plugin;
Expand Down
3 changes: 0 additions & 3 deletions src/LipUI/Models/ServerIcon.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Microsoft.UI.Xaml.Media.Imaging;
using System;
using System.IO;
using System.Threading.Tasks;

namespace LipUI.Models;

Expand Down
2 changes: 0 additions & 2 deletions src/LipUI/Pages/Home/HomePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Navigation;
using System;
using System.Diagnostics;
using System.IO;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
Expand Down
6 changes: 1 addition & 5 deletions src/LipUI/Pages/Home/Modules/BdsPropertiesEditorPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Windows.System;
using Windows.UI;
using static LipUI.InternalServices;
using static LipUI.Models.InternalServices;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
Expand Down
4 changes: 1 addition & 3 deletions src/LipUI/Pages/Home/Modules/ModuleIcon.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using LipUI.Models;
using LipUI.Models.Plugin;
using Microsoft.UI;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
Expand Down
4 changes: 1 addition & 3 deletions src/LipUI/Pages/Home/Modules/ModulesPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using LipUI.Models;
using LipUI.Models.Plugin;
using Microsoft.UI;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
Expand Down
5 changes: 0 additions & 5 deletions src/LipUI/Pages/Index/IndexPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
using LipUI.Protocol;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using static LipUI.Protocol.LipIndex.LipIndexData;

// To learn more about WinUI, the WinUI project structure,
Expand Down
Loading

0 comments on commit 59565ad

Please sign in to comment.