Skip to content

Commit

Permalink
Update functions
Browse files Browse the repository at this point in the history
  • Loading branch information
YerongAI committed Jan 6, 2020
1 parent 146642c commit b3df594
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 90 deletions.
2 changes: 1 addition & 1 deletion Projects/OfficeToolPlus/OfficeToolPlus/Export/ExportIso.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace OTP.Export
namespace OfficeTool.Export
{
public class FinishEventArgs : System.EventArgs
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Title="{Binding MessageBoxTitle}" SizeToContent="Height" Loaded="Window_Loaded" MinHeight="230" UseLayoutRounding="True"
Activated="Window_Activated" Deactivated="Window_Deactivated" Icon="/Office Tool Plus;component/Image/FIRSTRUN 001.ico">
<WindowChrome.WindowChrome>
<WindowChrome GlassFrameThickness="1" CornerRadius="0" CaptionHeight="30"/>
<WindowChrome GlassFrameThickness="0,1,0,0" CornerRadius="0" CaptionHeight="35"/>
</WindowChrome.WindowChrome>
<Window.Resources>
<Style TargetType="{x:Type Button}" x:Key="HeaderButtonStyle">
Expand Down Expand Up @@ -174,14 +174,14 @@
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<WrapPanel Margin="25,30,25,5" Focusable="False">
<Path x:Name="IconPath" Width="25" MaxHeight="25" Stretch="Uniform"/>
<Path x:Name="IconPath" MaxHeight="30" Stretch="Uniform"/>
<TextBlock x:Name="MessageTitle" Text="{Binding MessageBoxTitle}" FontSize="18" Foreground="{Binding BorderBrush, ElementName=Window}" VerticalAlignment="Center" Margin="5,0,0,0"/>
</WrapPanel>
<ScrollViewer VerticalScrollBarVisibility="Auto" VerticalAlignment="Top" Grid.Row="1" Margin="0,10,0,30">
<TextBlock Text="{Binding MessageBoxText}" TextWrapping="Wrap" Margin="25,0"/>
<ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="1" Margin="0,10,0,30">
<TextBlock Text="{Binding MessageBoxText}" TextWrapping="Wrap" Margin="25,1"/>
</ScrollViewer>
<ScrollViewer VerticalScrollBarVisibility="Auto" VerticalAlignment="Top" Grid.Row="1" Margin="0,10,0,30" CanContentScroll="True">
<RichTextBox x:Name="richTextBox" Background="Transparent" Foreground="{Binding Foreground, ElementName=Window}" Margin="25,0" BorderThickness="0" IsReadOnly="True" IsDocumentEnabled="True" Visibility="Collapsed"/>
<ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="1" Margin="0,10,0,30" CanContentScroll="True">
<RichTextBox x:Name="richTextBox" Background="Transparent" Foreground="{Binding Foreground, ElementName=Window}" Margin="25,1" BorderThickness="0" IsReadOnly="True" IsDocumentEnabled="True" Visibility="Collapsed"/>
</ScrollViewer>
<WrapPanel Grid.Row="2" HorizontalAlignment="Right" ItemHeight="35">
<Button Content="{DynamicResource MsgButtonOK}" x:Name="OKButton" Click="OKButton_Click" Style="{StaticResource NormalButtonStyle}" Visibility="{Binding OKButtonVisibility, Mode=OneWay}"/>
Expand Down
4 changes: 2 additions & 2 deletions Projects/OfficeToolPlus/OfficeToolPlus/Functions/CheckHash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace OfficeTool.Functions
{
//Copyright © 2019 Landiannews | By Yerong | https://otp.landian.vip/ | 2019/7/26
//Copyright © 2020 Landiannews | By Yerong | https://otp.landian.vip/ | 2020/01/06
class CheckHash
{
private readonly string hashValue;
Expand Down Expand Up @@ -95,4 +95,4 @@ public enum HashType
SHA384 = 3,
SHA512 = 4,
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace OfficeTool.List
{
// Language Information List
// Copyright © 2019 Landiannews | By Yerong | https://otp.landian.vip/
// Copyright © 2020 蓝点网 | By Yerong | https://otp.landian.vip/
// For more information please visit: https://docs.microsoft.com/en-us/DeployOffice/overview-of-deploying-languages-in-office-365-proplus#languages-culture-codes-and-companion-proofing-languages
class LanguageList
{
Expand Down
11 changes: 6 additions & 5 deletions Projects/OfficeToolPlus/OfficeToolPlus/List/OfficeChannelList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace OfficeTool.List
{
// Channel Information List
// Copyright © 2019 Landiannews | By Yerong | https://otp.landian.vip/
// Copyright © 2020 蓝点网 | By Yerong | https://otp.landian.vip/
// For more information please visit: https://docs.microsoft.com/en-us/DeployOffice/overview-of-update-channels-for-office-365-proplus
// https://docs.microsoft.com/en-us/DeployOffice/office2019/update#update-channel-for-office-2019
class OfficeChannelList
Expand Down Expand Up @@ -81,13 +81,14 @@ public string GetVersion(string ffn)
/// <summary>
/// Set the create time of Channel
/// </summary>
/// <param name="name"></param>
/// <param name="createdTimeUTC"></param>
public void SetCreateTime(string name, string createdTimeUTC)
/// <param name="name">Channel Name</param>
/// <param name="version">Office Version</param>
/// <param name="createdTimeUTC">Create Time</param>
public void SetCreateTime(string name, string version, string createdTimeUTC)
{
foreach (ChannelInf channel in ChannelLists)
{
if (channel.ChannelName == name)
if (channel.ChannelName == name && channel.Version == version)
{
channel.CreatedTimeUTC = createdTimeUTC;
}
Expand Down
59 changes: 30 additions & 29 deletions Projects/OfficeToolPlus/OfficeToolPlus/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,51 +1,63 @@
using Microsoft.Win32;
using OfficeTool.Export;
using OfficeTool.Functions;
using OfficeTool.List;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Management;
using System.Net;
using System.Reflection;
using System.Runtime.InteropServices;
using System.ServiceProcess;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Shell;
using System.Windows.Threading;
using System.Xml;
using System.Xml.Linq;
using Zmy.Wpf.CMessageBox;
using static OfficeTool.CreateXML;
using static OfficeTool.OfficeConfiguration;

namespace OfficeToolPlus
namespace OfficeTool
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
public partial class OfficeToolPlus : Window
{
public MainWindow()
public OfficeToolPlus()
{
try
{
InitializeComponent();//初始化所有组件
InitializeComponent();
}
catch (Exception e)
{
MessageBox.Show(e.Message, Find("MsgError"));
InstallNetFramework();//初始化失败,触发Net安装
InstallNetFramework();
}
}

/// <summary>
/// 弹出询问安装 Net Framework 的窗口
/// </summary>
private void InstallNetFramework()
{
var Result = MessageBox.Show(Find("MsgNetFrameworkError"), Find("MsgError"), MessageBoxButton.YesNo, MessageBoxImage.Question);
Expand Down Expand Up @@ -215,7 +227,16 @@ private void ResetLicensingStatus_Click(object sender, RoutedEventArgs e)
{
if (CMessageBox.Show(Find("MsgResetLicensingStatus"), Find("MsgWarning"), CMessageBoxButton.YesNO, CMessageBoxImage.Question) == CMessageBoxResult.Yes)
{
BackgroundDoWork("files\\activate\\OSPPREARM.EXE", string.Empty);
if (File.Exists("files\\activate\\OSPPREARM.EXE"))
BackgroundDoWork("files\\activate\\OSPPREARM.EXE", string.Empty);
else
{
OfficeConfiguration office = new OfficeConfiguration();
if (office.HasOffice)
{
BackgroundDoWork(office.InstallPath + "\\Office16\\OSPPREARM.EXE", string.Empty);
}
}
}
}

Expand Down Expand Up @@ -427,27 +448,7 @@ private void ViewKMSCAH_Click(object sender, RoutedEventArgs e)
BackgroundDoWork(string.Empty, "dhistorykms");
}
#endregion

#region 设置页面
private void PowerControl(string flag)
{
ManagementClass mcWin32 = new ManagementClass("Win32_OperatingSystem");
mcWin32.Get();

mcWin32.Scope.Options.EnablePrivileges = true;
ManagementBaseObject mboShutdownParams = mcWin32.GetMethodParameters("Win32Shutdown");

//"0" 注销 "1" 关机, "2" 重启 "8" 关闭计算机电源
//"0" Log out "1" Shutdown, "2" Reboot "8" Shutdown power
mboShutdownParams["Flags"] = flag;
mboShutdownParams["Reserved"] = "0";
foreach (ManagementObject manObj in mcWin32.GetInstances())
{
ManagementBaseObject mboShutdown = manObj.InvokeMethod("Win32Shutdown", mboShutdownParams, null);
}
}
#endregion
}
}

//Copyright © 2019 Landiannews |By Yerong | https://otp.landian.vip/
//Copyright © 2020 Landiannews |By Yerong | https://otp.landian.vip/
54 changes: 10 additions & 44 deletions Projects/OfficeToolPlus/OfficeToolPlus/Office/CreateXML.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace OfficeTool
{
// Copyright © 2019 Landiannews | By Yerong | https://otp.landian.vip/
// Copyright © 2020 蓝点网 | By Yerong | https://otp.landian.vip/
// For more information please visit: https://docs.microsoft.com/en-us/DeployOffice/configuration-options-for-the-office-2016-deployment-tool

class CreateXML
Expand Down Expand Up @@ -74,7 +74,7 @@ public InstallArguments(bool rebuild)
/// <param name="LanguageID">产品的语言</param>
public void AddProduct(string ProductID, List<string> LanguageID)
{
InstallConfig arguments = new InstallConfig(ProductID, "", LanguageID, "", new List<string>());
InstallConfig arguments = new InstallConfig(ProductID, "", LanguageID, new List<string>());
ProductConfigList.Add(arguments);
}

Expand All @@ -86,19 +86,7 @@ public void AddProduct(string ProductID, List<string> LanguageID)
/// <param name="ExcludeApps">指定要排除的应用程序 ID</param>
public void AddProduct(string ProductID, string MAK, List<string> LanguageID, List<string> ExcludeApps)
{
InstallConfig arguments = new InstallConfig(ProductID, MAK, LanguageID, "", ExcludeApps);
ProductConfigList.Add(arguments);
}

/// <summary>
/// 添加新的产品
/// </summary>
/// <param name="ProductID">产品 ID</param>
/// <param name="LanguageID">产品的语言</param>
/// <param name="ExcludeApps">指定要排除的应用程序 ID</param>
public void AddProduct(string ProductID, string MAK, List<string> LanguageID, string FallbackLanguage, List<string> ExcludeApps)
{
InstallConfig arguments = new InstallConfig(ProductID, MAK, LanguageID, FallbackLanguage, ExcludeApps);
InstallConfig arguments = new InstallConfig(ProductID, MAK, LanguageID, ExcludeApps);
ProductConfigList.Add(arguments);
}

Expand Down Expand Up @@ -213,19 +201,9 @@ from el in AddElementTemp.Attributes()
// Language
if (LangID != null)
{
if (ProductConfigList[i].FallbackLanguage != string.Empty)
{
XElement LanguageElemtnt = new XElement("Language",
new XAttribute("ID", LangID),
new XAttribute("Fallback", ProductConfigList[i].FallbackLanguage));
LangElemtnt.Add(LanguageElemtnt);
}
else
{
XElement LanguageElemtnt = new XElement("Language",
new XAttribute("ID", LangID));
LangElemtnt.Add(LanguageElemtnt);
}
XElement LanguageElemtnt = new XElement("Language",
new XAttribute("ID", LangID));
LangElemtnt.Add(LanguageElemtnt);
}
}
// Product ID
Expand Down Expand Up @@ -350,19 +328,9 @@ from el in UpdateTempElemtnt.Attributes()
{
if (LangID != null)
{
if (ProductConfigList[i].FallbackLanguage != string.Empty)
{
XElement LanguageElemtnt = new XElement("Language",
new XAttribute("ID", LangID),
new XAttribute("Fallback", ProductConfigList[i].FallbackLanguage));
LangElemtnt.Add(LanguageElemtnt);
}
else
{
XElement LanguageElemtnt = new XElement("Language",
new XAttribute("ID", LangID));
LangElemtnt.Add(LanguageElemtnt);
}
XElement LanguageElemtnt = new XElement("Language",
new XAttribute("ID", LangID));
LangElemtnt.Add(LanguageElemtnt);
}
}
XElement ProductElemtnt = new XElement("Product",
Expand Down Expand Up @@ -570,19 +538,17 @@ public void LoadXMLFile(string filePath)

public class InstallConfig
{
public InstallConfig(string ProductID, string MAK, List<string> LanguageID, string FallbackLanguage, List<string> ExcludeApps)
public InstallConfig(string ProductID, string MAK, List<string> LanguageID, List<string> ExcludeApps)
{
this.ProductID = ProductID;
this.MAK = MAK;
this.LanguageID = LanguageID;
this.FallbackLanguage = FallbackLanguage;
this.ExcludeApps = ExcludeApps;
}

public string ProductID { get; set; }
public string MAK { get; set; }
public List<string> LanguageID { get; set; }
public string FallbackLanguage { get; set; }
public List<string> ExcludeApps { get; set; }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace OfficeTool
{
// Copyright © 2019 Landiannews | By Yerong | https://otp.landian.vip/
// Copyright © 2020 蓝点网 | By Yerong | https://otp.landian.vip/
/// <summary>
/// Check Office Installation
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace OfficeTool
{
// Copyright © 2019 Landiannews | By Yerong | https://otp.landian.vip/
// Copyright © 2020 蓝点网 | By Yerong | https://otp.landian.vip/
class OfficeConfiguration
{
internal List<InstalledProducts> InstalledProductsList { get; set; } = new List<InstalledProducts>(3);
Expand Down

0 comments on commit b3df594

Please sign in to comment.