Skip to content

Commit

Permalink
显示模块的错误/进一步适配.NET Core API/调整文件存储逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
zsh2401 committed May 19, 2020
1 parent 401a355 commit d0fcc6f
Show file tree
Hide file tree
Showing 24 changed files with 223 additions and 100 deletions.
4 changes: 3 additions & 1 deletion src/AutumnBox.ADBProvider/Win32AdbManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ public class Win32AdbManager : StandardAdbManager, IAdbManager
private static readonly string[] files = { "adb.exe", "AdbWinApi.dll", "AdbWinUsbApi.dll", "fastboot.exe", "libwinpthread-1.dll" };
private const string FILES_NAMESPACE = "AutumnBox.ADBProvider.adb_tools";

public static DirectoryInfo AdbToolsDirectory { get; set; } = null;

protected override DirectoryInfo InitializeClientFiles()
{
string temp = Environment.GetEnvironmentVariable("TEMP");
var toolsPath = Path.Combine(temp, "autumnbox_adb_tools/");
var toolsDir = new DirectoryInfo(toolsPath);
var toolsDir = AdbToolsDirectory ?? new DirectoryInfo(toolsPath);
if (!toolsDir.Exists) toolsDir.Create();
ExtractFilesTo(toolsDir);
return toolsDir;
Expand Down
2 changes: 1 addition & 1 deletion src/AutumnBox.Basic.Shared/ModuleInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ public static class ModuleInfo
/// 指示版本
/// </summary>
public static Version Version => Version.Parse(VERSION_STR);
const string VERSION_STR = "2020.5.18";
const string VERSION_STR = "2020.5.19";
}
}
37 changes: 37 additions & 0 deletions src/AutumnBox.Essentials/Extensions/ETest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* ==============================================================================
*
* Filename: ETest
* Description: 
*
* Version: 1.0
* Created: 2020/5/19 20:33:29
* Compiler: Visual Studio 2019
*
* Author: zsh2401
*
* ==============================================================================
*/
using AutumnBox.OpenFramework.Extension;
using AutumnBox.OpenFramework.Extension.Leaf;
using AutumnBox.OpenFramework.Open.LKit;
using System;
using System.Collections.Generic;
using System.Text;

namespace AutumnBox.Essentials.Extensions
{
[ExtName("test")]
[ExtDeveloperMode]
class ETest : LeafExtensionBase
{
[LMain]
public void EntryPoint(ILeafUI _ui)
{
using var ui = _ui;
ui.Show();
throw new Exception("test_error");
}
}
}
2 changes: 2 additions & 0 deletions src/AutumnBox.GUI/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
<ResourceDictionary Source="/Resources/Themes/ThemeLight.xaml"/>

<ResourceDictionary Source="/Resources/Converters.xaml"/>

<ResourceDictionary Source="/Resources/AppCommonResource.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Expand Down
6 changes: 6 additions & 0 deletions src/AutumnBox.GUI/Resources/AppCommonResource.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:AutumnBox.GUI.Resources">

<FontFamily x:Key="AutumnBox.Font">Microsoft YaHei UI Light</FontFamily>
</ResourceDictionary>
12 changes: 6 additions & 6 deletions src/AutumnBox.GUI/Resources/Languages/zh-CN.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,12 @@
<s:String x:Key="Dash.Boot.Time">开机时间</s:String>

<s:String x:Key="Version.AutumnBox">秋之盒版本</s:String>
<s:String x:Key="Version.GUI">图形界面</s:String>
<s:String x:Key="Version.CoreModules">核心模块</s:String>
<s:String x:Key="Version.Basic">ADB交互模块</s:String>
<s:String x:Key="Version.OpenFx">SDK</s:String>
<s:String x:Key="Version.ADB">ADB</s:String>
<s:String x:Key="Version.Basic">Basic封装库</s:String>
<s:String x:Key="Version.OpenFx">开放框架</s:String>
<s:String x:Key="Version.Logging">调试器</s:String>

<s:String x:Key="Version.OS">操作系统</s:String>
<s:String x:Key="Version.Net">.NET环境</s:String>
<s:String x:Key="Version.Net">.NET Core</s:String>

<s:String x:Key="QQGroup">QQ群</s:String>
<s:String x:Key="EMail">电子邮件</s:String>
Expand Down Expand Up @@ -239,6 +237,8 @@
<!--LoadingWindow-->
<s:String x:Key="LoadingWindowMessage">请耐心等待 :)</s:String>

<s:String x:Key="Uni.Copy">复制</s:String>

<!--LeafWindow-->
<s:String x:Key="LeafUITipRunning">运行中</s:String>
<s:String x:Key="LeafUICannotStop">这个模块无法中途停止</s:String>
Expand Down
28 changes: 28 additions & 0 deletions src/AutumnBox.GUI/Services/IStorageManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* ==============================================================================
*
* Filename: IStorageManager
* Description: 
*
* Version: 1.0
* Created: 2020/5/19 19:56:32
* Compiler: Visual Studio 2019
*
* Author: zsh2401
*
* ==============================================================================
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace AutumnBox.GUI.Services
{
interface IStorageManager
{
DirectoryInfo CacheDirectory { get; }
DirectoryInfo StorageDirectory { get; }
}
}
10 changes: 7 additions & 3 deletions src/AutumnBox.GUI/Services/Impl/AutumnBoxGuiBaseApiImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using AutumnBox.Logging;
using AutumnBox.Leafx.Container.Support;
using System.Threading.Tasks;
using System.IO;

namespace AutumnBox.GUI.Services.Impl
{
Expand Down Expand Up @@ -47,8 +48,6 @@ public Version Version

public bool ShouldDisplayCmdWindow => Settings.Default.DisplayCmdWindow;

public Version NewtonsoftJsonVersion => VersionInfos.JsonLib;

public Version AutumnBoxLoggingVersion => VersionInfos.Logging;

public Version AutumnBoxGUIVersion => VersionInfos.GUI;
Expand All @@ -57,6 +56,10 @@ public Version Version

public IRegisterableLake GlobalLake => (IRegisterableLake)App.Current.Lake;

public DirectoryInfo StorageDirectory => this.GetComponent<IStorageManager>().StorageDirectory;

public DirectoryInfo TempDirectory => this.GetComponent<IStorageManager>().CacheDirectory;

public void ShowDebugUI()
{
new LogWindow().Show();
Expand Down Expand Up @@ -128,7 +131,8 @@ public AutumnBoxGuiBaseApiImpl()
{
LanguageChanged?.Invoke(this, new EventArgs());
};
}
}

private static LoadingWindow loadingWindow;

public event EventHandler LanguageChanged;
Expand Down
41 changes: 41 additions & 0 deletions src/AutumnBox.GUI/Services/Impl/StorageManagerImpl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* ==============================================================================
*
* Filename: StorageManagerImpl
* Description: 
*
* Version: 1.0
* Created: 2020/5/19 19:57:18
* Compiler: Visual Studio 2019
*
* Author: zsh2401
*
* ==============================================================================
*/
using AutumnBox.Leafx.Container.Support;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace AutumnBox.GUI.Services.Impl
{
[Component(Type = typeof(IStorageManager))]
class StorageManagerImpl : IStorageManager
{
public StorageManagerImpl()
{
string temp = Environment.GetEnvironmentVariable("TEMP");
CacheDirectory = new DirectoryInfo(Path.Combine(temp, "autumnbox_temp"));
if (!CacheDirectory.Exists) CacheDirectory.Create();

string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
StorageDirectory = new DirectoryInfo(Path.Combine(appData, "autumnbox"));
if (!StorageDirectory.Exists) StorageDirectory.Create();
}
public DirectoryInfo CacheDirectory { get; }

public DirectoryInfo StorageDirectory { get; }
}
}
4 changes: 3 additions & 1 deletion src/AutumnBox.GUI/Util/Loader/GeneralAppLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using HandyControl.Data;
using HandyControl.Tools;
using System;
using System.IO;
using System.Linq;
using System.Management;

Expand Down Expand Up @@ -79,13 +80,14 @@ private void PrintInformations()
}

[Step(3)]
private void InitAutumnBoxBasic(IOperatingSystemService operatingSystemService)
private void InitAutumnBoxBasic(IOperatingSystemService operatingSystemService, IStorageManager storageManager)
{
try
{
Logger.Info("killing other adb processes");
operatingSystemService.KillProcess("adb.exe");
Logger.Info("autumnbox-adb-server is starting");
Win32AdbManager.AdbToolsDirectory = new DirectoryInfo(Path.Combine(storageManager.CacheDirectory.FullName, "adb_tools"));
BasicBooter.Use<Win32AdbManager>();
Logger.Info($"autumnbox-adb-server is started at {BasicBooter.ServerEndPoint}");
}
Expand Down
20 changes: 2 additions & 18 deletions src/AutumnBox.GUI/Util/VersionInfos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ static class VersionInfos
public static Version OS { get; }
public static string OSString => OS.ToString();

public static Version JsonLib { get; }
public static string JsonLibString => JsonLib.ToString();

public static Version HandyControl { get; }
public static string HandyControlString => HandyControl.ToString();

Expand All @@ -59,33 +56,20 @@ private static string GetAdbVersion()
return "unknown";
}
}
private static Version GetCoreLibVersion()
{
var libsManager = AutumnBox.OpenFramework.Management.OpenFx.Lake.Get<ILibsManager>();
var coreLibFilterResult = from lib in libsManager.Librarians
where lib.Name == "AutumnBox Core Modules"
select lib;
if (coreLibFilterResult.Count() == 0) return new Version(0, 0, 1);
var assemblyLib = coreLibFilterResult.First() as AssemblyLibrarian;
Assembly assembly = assemblyLib.ManagedAssembly;
return assembly.GetName().Version;
}

static VersionInfos()
{
Basic = typeof(BasicBooter).Assembly.GetName().Version;
Basic = AutumnBox.Basic.ModuleInfo.Version;
GUI = Self.Version;
OpenFx = typeof(OpenFramework.BuildInfo).Assembly.GetName().Version;
OpenFx = AutumnBox.OpenFramework.BuildInfo.SDK_VERSION;
Logging = typeof(Logging.SLogger).Assembly.GetName().Version;

JsonLib = new Version(1, 0, 0);
HandyControl = typeof(HandyControl.Controls.AnimationPath).Assembly.GetName().Version;
SharpZipLib = typeof(ICSharpCode.SharpZipLib.SharpZipBaseException).Assembly.GetName().Version;

DotNetFramework = Environment.Version;
OS = Environment.OSVersion.Version;
Adb = GetAdbVersion();
CoreLib = GetCoreLibVersion();
}
}
}
18 changes: 3 additions & 15 deletions src/AutumnBox.GUI/View/Panel/PanelAbout.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
mc:Ignorable="d"
xmlns:util="clr-namespace:AutumnBox.GUI.Util"
Foreground="{DynamicResource PrimaryTextBrush}"
FontFamily="{DynamicResource AutumnBox.Font}"
xmlns:viewmodel="clr-namespace:AutumnBox.GUI.ViewModel"
d:DesignHeight="450" d:DesignWidth="400">
<UserControl.DataContext>
Expand Down Expand Up @@ -47,27 +48,19 @@

<DockPanel Margin="30,10,30,0">
<TextBlock DockPanel.Dock="Right" Text="{x:Static util:VersionInfos.GUIString}"/>
<TextBlock DockPanel.Dock="Left" Text="{DynamicResource Version.GUI}"/>
<TextBlock DockPanel.Dock="Left" Text="{DynamicResource Version.AutumnBox}"/>
</DockPanel>

<DockPanel Margin="30,0,30,0">
<TextBlock DockPanel.Dock="Right" Text="{x:Static util:VersionInfos.BasicString}"/>
<TextBlock DockPanel.Dock="Left" Text="{DynamicResource Version.Basic}"/>
</DockPanel>
<DockPanel Margin="30,0,30,0">
<TextBlock DockPanel.Dock="Right" Text="{x:Static util:VersionInfos.LoggingString}"/>
<TextBlock DockPanel.Dock="Left" Text="{DynamicResource Version.Logging}"/>
</DockPanel>

<DockPanel Margin="30,0,30,0">
<TextBlock DockPanel.Dock="Right" Text="{x:Static util:VersionInfos.OpenFxString}"/>
<TextBlock DockPanel.Dock="Left" Text="{DynamicResource Version.OpenFx}"/>
</DockPanel>

<DockPanel Margin="30,0,30,0">
<TextBlock DockPanel.Dock="Right" Text="{x:Static util:VersionInfos.CoreLibString}"/>
<TextBlock DockPanel.Dock="Left" Text="{DynamicResource Version.CoreModules}"/>
</DockPanel>

<Grid Height="1" Margin="25,5,25,5" Background="LightGray"/>
<DockPanel Margin="30,0,30,0">
<TextBlock DockPanel.Dock="Right" Text="{x:Static util:VersionInfos.Adb}"/>
Expand All @@ -91,11 +84,6 @@
<TextBlock DockPanel.Dock="Left" Text="HandyControl"/>
</DockPanel>

<DockPanel Margin="30,0,30,0">
<TextBlock DockPanel.Dock="Right" Text="{x:Static util:VersionInfos.JsonLibString}"/>
<TextBlock DockPanel.Dock="Left" Text="Newtonsoft.Json"/>
</DockPanel>

<DockPanel Margin="30,0,30,0">
<TextBlock DockPanel.Dock="Right" Text="{x:Static util:VersionInfos.SharpZipLibString}"/>
<TextBlock DockPanel.Dock="Left" Text="SharpZipLib"/>
Expand Down
1 change: 1 addition & 0 deletions src/AutumnBox.GUI/View/Panel/PanelUpdateLogs.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
xmlns:local="clr-namespace:AutumnBox.GUI.View.Panel"
xmlns:viewmodel="clr-namespace:AutumnBox.GUI.ViewModel"
mc:Ignorable="d"
FontFamily="{DynamicResource AutumnBox.Font}"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.DataContext>
<viewmodel:VMUpdateLogs/>
Expand Down
7 changes: 4 additions & 3 deletions src/AutumnBox.GUI/View/Windows/ExceptionWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@
mc:Ignorable="d"
FontFamily="{DynamicResource AutumnBox.Font}"
WindowStartupLocation="CenterOwner"
MinHeight="300" MinWidth="500"
MinHeight="280" MinWidth="300"
ShowInTaskbar="False"
MouseDown="Window_MouseDown"
Title="{Binding MessageTitle}" Height="300" Width="500">
Title="{Binding MessageTitle}" Height="270" Width="350">
<Grid>
<DockPanel>
<StackPanel DockPanel.Dock="Top" Orientation="Vertical" Margin="10">
<TextBlock FontSize="30" Foreground="OrangeRed" Text="{Binding MessageTitle}" TextWrapping="Wrap"/>
<TextBlock FontSize="15" Text="{Binding Sketch}" TextWrapping="Wrap"/>
</StackPanel>
<Button Click="Button_Click" Width="100" Content="{DynamicResource Copy}" DockPanel.Dock="Top"></Button>
<Button Click="Button_Click" Width="100" Content="{DynamicResource Uni.Copy}" DockPanel.Dock="Top"></Button>
<TextBox TextWrapping="Wrap" IsReadOnly="True" DockPanel.Dock="Bottom" Style="{x:Null}" Margin="5" Text="{Binding ExceptionMessage}"/>
</DockPanel>
</Grid>
Expand Down
6 changes: 5 additions & 1 deletion src/AutumnBox.GUI/View/Windows/ExceptionWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ private void Window_MouseDown(object sender, MouseButtonEventArgs e)

private void Button_Click(object sender, RoutedEventArgs e)
{
Clipboard.SetText(ExceptionMessage);
try
{
Clipboard.SetText(ExceptionMessage);
}
catch { }
}
}
}
3 changes: 1 addition & 2 deletions src/AutumnBox.GUI/ViewModel/VMMainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ public VMMainMenu()
InstallExtension = new MVVMCommand(p => openFxManager.RunExtension("EExtensionInstaller"));
OpenExtFloder = new MVVMCommand(p =>
{
string path = Path.Combine(AppContext.BaseDirectory, BuildInfo.DEFAULT_EXTENSION_PATH);
Process.Start(new ProcessStartInfo(path)
Process.Start(new ProcessStartInfo(BuildInfo.ExtensionStore.FullName)
{
UseShellExecute = true,
Verb = "open"
Expand Down
Loading

0 comments on commit d0fcc6f

Please sign in to comment.