From 7264e888e587d71a26557498d192046195b947de Mon Sep 17 00:00:00 2001 From: Alexander Date: Sat, 15 Oct 2022 16:14:26 +0300 Subject: [PATCH] 20221015 --- MSOUI.sln | 10 +- MSOUI.sln.DotSettings | 2 + msou_installer/Enums/EBits.cs | 17 ++ msou_installer/Forms/ExecuterForm.Designer.cs | 50 ++++ msou_installer/Forms/ExecuterForm.cs | 18 ++ msou_installer/Forms/ExecuterForm.resx | 60 +++++ msou_installer/Forms/MainForm.Designer.cs | 221 ++++++++++++++++++ msou_installer/Forms/MainForm.cs | 90 +++++++ msou_installer/Forms/MainForm.resx | 63 +++++ msou_installer/Forms/UnPackForm.Designer.cs | 92 ++++++++ msou_installer/Forms/UnPackForm.cs | 105 +++++++++ msou_installer/Forms/UnPackForm.resx | 63 +++++ .../Forms/UpdatesListForm.Designer.cs | 140 +++++++++++ msou_installer/Forms/UpdatesListForm.cs | 37 +++ msou_installer/Forms/UpdatesListForm.resx | 63 +++++ msou_installer/Models/UnPackModel.cs | 38 +++ msou_installer/Program.cs | 18 ++ msou_installer/msou_installer.csproj | 17 ++ 18 files changed, 1102 insertions(+), 2 deletions(-) create mode 100644 MSOUI.sln.DotSettings create mode 100644 msou_installer/Enums/EBits.cs create mode 100644 msou_installer/Forms/ExecuterForm.Designer.cs create mode 100644 msou_installer/Forms/ExecuterForm.cs create mode 100644 msou_installer/Forms/ExecuterForm.resx create mode 100644 msou_installer/Forms/MainForm.Designer.cs create mode 100644 msou_installer/Forms/MainForm.cs create mode 100644 msou_installer/Forms/MainForm.resx create mode 100644 msou_installer/Forms/UnPackForm.Designer.cs create mode 100644 msou_installer/Forms/UnPackForm.cs create mode 100644 msou_installer/Forms/UnPackForm.resx create mode 100644 msou_installer/Forms/UpdatesListForm.Designer.cs create mode 100644 msou_installer/Forms/UpdatesListForm.cs create mode 100644 msou_installer/Forms/UpdatesListForm.resx create mode 100644 msou_installer/Models/UnPackModel.cs create mode 100644 msou_installer/Program.cs create mode 100644 msou_installer/msou_installer.csproj diff --git a/MSOUI.sln b/MSOUI.sln index 63b9146..d494f7a 100644 --- a/MSOUI.sln +++ b/MSOUI.sln @@ -1,10 +1,12 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31424.327 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32929.385 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MSOUI", "MSOUI.csproj", "{B7E4991D-99A9-4189-BCD9-557E04CA4473}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "msou_installer", "msou_installer\msou_installer.csproj", "{E86E8BBF-8830-4259-9DEE-6F3EFC284443}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +17,10 @@ Global {B7E4991D-99A9-4189-BCD9-557E04CA4473}.Debug|Any CPU.Build.0 = Debug|Any CPU {B7E4991D-99A9-4189-BCD9-557E04CA4473}.Release|Any CPU.ActiveCfg = Release|Any CPU {B7E4991D-99A9-4189-BCD9-557E04CA4473}.Release|Any CPU.Build.0 = Release|Any CPU + {E86E8BBF-8830-4259-9DEE-6F3EFC284443}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E86E8BBF-8830-4259-9DEE-6F3EFC284443}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E86E8BBF-8830-4259-9DEE-6F3EFC284443}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E86E8BBF-8830-4259-9DEE-6F3EFC284443}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/MSOUI.sln.DotSettings b/MSOUI.sln.DotSettings new file mode 100644 index 0000000..e41268c --- /dev/null +++ b/MSOUI.sln.DotSettings @@ -0,0 +1,2 @@ + + True \ No newline at end of file diff --git a/msou_installer/Enums/EBits.cs b/msou_installer/Enums/EBits.cs new file mode 100644 index 0000000..1977492 --- /dev/null +++ b/msou_installer/Enums/EBits.cs @@ -0,0 +1,17 @@ +namespace msoui.Enums; + +/// +/// Перечисление разрядности +/// +public enum EBits +{ + /// + /// 32-разрядная версия + /// + Bit32 = 0, + + /// + /// 64-разрядная версия + /// + Bit64 = 1 +} diff --git a/msou_installer/Forms/ExecuterForm.Designer.cs b/msou_installer/Forms/ExecuterForm.Designer.cs new file mode 100644 index 0000000..5d22ff0 --- /dev/null +++ b/msou_installer/Forms/ExecuterForm.Designer.cs @@ -0,0 +1,50 @@ +namespace msoui.Forms; + +partial class ExecuterForm +{ + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose (bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent () + { + this.SuspendLayout(); + // + // ExecuterForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 21F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(496, 180); + this.ControlBox = false; + this.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ExecuterForm"; + this.Text = "Установка обновлений"; + this.ResumeLayout(false); + + } + + #endregion +} \ No newline at end of file diff --git a/msou_installer/Forms/ExecuterForm.cs b/msou_installer/Forms/ExecuterForm.cs new file mode 100644 index 0000000..621f8c4 --- /dev/null +++ b/msou_installer/Forms/ExecuterForm.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace msoui.Forms; +public partial class ExecuterForm: Form +{ + public ExecuterForm () + { + InitializeComponent(); + } +} diff --git a/msou_installer/Forms/ExecuterForm.resx b/msou_installer/Forms/ExecuterForm.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/msou_installer/Forms/ExecuterForm.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/msou_installer/Forms/MainForm.Designer.cs b/msou_installer/Forms/MainForm.Designer.cs new file mode 100644 index 0000000..0dba9ef --- /dev/null +++ b/msou_installer/Forms/MainForm.Designer.cs @@ -0,0 +1,221 @@ +namespace msoui.Forms; + +sealed partial class MainForm +{ + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose (bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent () + { + this.contentPanel = new System.Windows.Forms.Panel(); + this.viewButton = new System.Windows.Forms.Button(); + this.bitsSelector64 = new System.Windows.Forms.RadioButton(); + this.bitsSelector32 = new System.Windows.Forms.RadioButton(); + this.dataFileSelector = new System.Windows.Forms.TextBox(); + this.bitsSelectorLabel = new System.Windows.Forms.Label(); + this.dataFileLabel = new System.Windows.Forms.Label(); + this.titleLabel = new System.Windows.Forms.Label(); + this.buttonsPanel = new System.Windows.Forms.Panel(); + this.exitButton = new System.Windows.Forms.Button(); + this.installButton = new System.Windows.Forms.Button(); + this.settingsButton = new System.Windows.Forms.Button(); + this.dataFileDialog = new System.Windows.Forms.OpenFileDialog(); + this.contentPanel.SuspendLayout(); + this.buttonsPanel.SuspendLayout(); + this.SuspendLayout(); + // + // contentPanel + // + this.contentPanel.Controls.Add(this.viewButton); + this.contentPanel.Controls.Add(this.bitsSelector64); + this.contentPanel.Controls.Add(this.bitsSelector32); + this.contentPanel.Controls.Add(this.dataFileSelector); + this.contentPanel.Controls.Add(this.bitsSelectorLabel); + this.contentPanel.Controls.Add(this.dataFileLabel); + this.contentPanel.Controls.Add(this.titleLabel); + this.contentPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.contentPanel.Location = new System.Drawing.Point(0, 0); + this.contentPanel.Name = "contentPanel"; + this.contentPanel.Size = new System.Drawing.Size(684, 275); + this.contentPanel.TabIndex = 0; + // + // viewButton + // + this.viewButton.Location = new System.Drawing.Point(574, 59); + this.viewButton.Name = "viewButton"; + this.viewButton.Size = new System.Drawing.Size(96, 29); + this.viewButton.TabIndex = 6; + this.viewButton.Text = "&Обзор"; + this.viewButton.UseVisualStyleBackColor = true; + this.viewButton.Click += new System.EventHandler(this.viewButton_Click); + // + // bitsSelector64 + // + this.bitsSelector64.AutoSize = true; + this.bitsSelector64.Cursor = System.Windows.Forms.Cursors.Hand; + this.bitsSelector64.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.bitsSelector64.Location = new System.Drawing.Point(32, 173); + this.bitsSelector64.Name = "bitsSelector64"; + this.bitsSelector64.Size = new System.Drawing.Size(179, 25); + this.bitsSelector64.TabIndex = 5; + this.bitsSelector64.Text = "&64-разрядная версия"; + this.bitsSelector64.UseVisualStyleBackColor = true; + // + // bitsSelector32 + // + this.bitsSelector32.AutoSize = true; + this.bitsSelector32.Checked = true; + this.bitsSelector32.Cursor = System.Windows.Forms.Cursors.Hand; + this.bitsSelector32.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.bitsSelector32.Location = new System.Drawing.Point(32, 142); + this.bitsSelector32.Name = "bitsSelector32"; + this.bitsSelector32.Size = new System.Drawing.Size(179, 25); + this.bitsSelector32.TabIndex = 4; + this.bitsSelector32.TabStop = true; + this.bitsSelector32.Text = "&32-разрядная версия"; + this.bitsSelector32.UseVisualStyleBackColor = true; + // + // dataFileSelector + // + this.dataFileSelector.Location = new System.Drawing.Point(12, 59); + this.dataFileSelector.Name = "dataFileSelector"; + this.dataFileSelector.Size = new System.Drawing.Size(556, 29); + this.dataFileSelector.TabIndex = 3; + // + // bitsSelectorLabel + // + this.bitsSelectorLabel.AutoSize = true; + this.bitsSelectorLabel.Location = new System.Drawing.Point(12, 107); + this.bitsSelectorLabel.Name = "bitsSelectorLabel"; + this.bitsSelectorLabel.Size = new System.Drawing.Size(454, 21); + this.bitsSelectorLabel.TabIndex = 2; + this.bitsSelectorLabel.Text = "&Выберете разрядность установленной версии MS Office 2016:"; + // + // dataFileLabel + // + this.dataFileLabel.AutoSize = true; + this.dataFileLabel.Location = new System.Drawing.Point(12, 35); + this.dataFileLabel.Name = "dataFileLabel"; + this.dataFileLabel.Size = new System.Drawing.Size(270, 21); + this.dataFileLabel.TabIndex = 1; + this.dataFileLabel.Text = "&Выберете файл данных обновлений:"; + this.dataFileLabel.TextAlign = System.Drawing.ContentAlignment.TopCenter; + // + // titleLabel + // + this.titleLabel.Dock = System.Windows.Forms.DockStyle.Top; + this.titleLabel.Location = new System.Drawing.Point(0, 0); + this.titleLabel.Margin = new System.Windows.Forms.Padding(5); + this.titleLabel.Name = "titleLabel"; + this.titleLabel.Size = new System.Drawing.Size(684, 30); + this.titleLabel.TabIndex = 0; + this.titleLabel.Text = "Добро пожаловать в Мастер установки обновлений для Microsoft Office 2016!"; + this.titleLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // buttonsPanel + // + this.buttonsPanel.Controls.Add(this.exitButton); + this.buttonsPanel.Controls.Add(this.installButton); + this.buttonsPanel.Controls.Add(this.settingsButton); + this.buttonsPanel.Dock = System.Windows.Forms.DockStyle.Bottom; + this.buttonsPanel.Location = new System.Drawing.Point(0, 214); + this.buttonsPanel.Name = "buttonsPanel"; + this.buttonsPanel.Size = new System.Drawing.Size(684, 61); + this.buttonsPanel.TabIndex = 1; + // + // exitButton + // + this.exitButton.Location = new System.Drawing.Point(560, 13); + this.exitButton.Name = "exitButton"; + this.exitButton.Size = new System.Drawing.Size(110, 33); + this.exitButton.TabIndex = 2; + this.exitButton.Text = "В&ыход"; + this.exitButton.UseVisualStyleBackColor = true; + this.exitButton.Click += new System.EventHandler(this.exitButton_Click); + // + // installButton + // + this.installButton.Location = new System.Drawing.Point(444, 13); + this.installButton.Name = "installButton"; + this.installButton.Size = new System.Drawing.Size(110, 33); + this.installButton.TabIndex = 1; + this.installButton.Text = "&Установить"; + this.installButton.UseVisualStyleBackColor = true; + this.installButton.Click += new System.EventHandler(this.installButton_Click); + // + // settingsButton + // + this.settingsButton.Location = new System.Drawing.Point(12, 13); + this.settingsButton.Name = "settingsButton"; + this.settingsButton.Size = new System.Drawing.Size(110, 33); + this.settingsButton.TabIndex = 0; + this.settingsButton.Text = "&Настройки"; + this.settingsButton.UseVisualStyleBackColor = true; + // + // dataFileDialog + // + this.dataFileDialog.DefaultExt = "data"; + this.dataFileDialog.Filter = "Файл данных обновлений|*.data"; + this.dataFileDialog.Title = "Выберете файл данных обновлений"; + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 21F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(684, 275); + this.ControlBox = false; + this.Controls.Add(this.buttonsPanel); + this.Controls.Add(this.contentPanel); + this.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; + this.Margin = new System.Windows.Forms.Padding(4); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "MainForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Установка обновлений для Microsoft Office 2016"; + this.Load += new System.EventHandler(this.StartForm_Load); + this.contentPanel.ResumeLayout(false); + this.contentPanel.PerformLayout(); + this.buttonsPanel.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private Panel contentPanel; + private Panel buttonsPanel; + private Button viewButton; + private RadioButton bitsSelector64; + private RadioButton bitsSelector32; + private TextBox dataFileSelector; + private Label bitsSelectorLabel; + private Label dataFileLabel; + private Label titleLabel; + private Button exitButton; + private Button installButton; + private Button settingsButton; + private OpenFileDialog dataFileDialog; +} \ No newline at end of file diff --git a/msou_installer/Forms/MainForm.cs b/msou_installer/Forms/MainForm.cs new file mode 100644 index 0000000..971632d --- /dev/null +++ b/msou_installer/Forms/MainForm.cs @@ -0,0 +1,90 @@ +using anbs_cp; + +using msoui.Enums; +using msoui.Models; + +namespace msoui.Forms; +public sealed partial class MainForm: Form +{ + public MainForm () + { + TempWorkDir = $@"{LikeDelphi.IncludeTrailingBackslash(Path.GetTempPath())}msoui\"; + InitializeComponent(); + } + + public string TempWorkDir { get; set; } + + private void viewButton_Click (object sender, EventArgs e) + { + if (dataFileDialog.ShowDialog() == DialogResult.OK) + dataFileSelector.Text = dataFileDialog.FileName; + } + + private void exitButton_Click (object sender, EventArgs e) + { + Application.Exit(); + } + + private void installButton_Click (object sender, EventArgs e) + { + // + if (string.IsNullOrWhiteSpace(dataFileSelector.Text) || !File.Exists(dataFileSelector.Text)) + { + MessageBox.Show($@" {dataFileSelector.Text} !", @"!", MessageBoxButtons.OK, MessageBoxIcon.Error); + + return; + } + + // + UnPackModel model = new(dataFileSelector.Text, bitsSelector64.Checked ? EBits.Bit64 : EBits.Bit32, TempWorkDir); + + // + UnPackForm unPackFrm = new(model); + + // + unPackFrm.ShowDialog(); + + // - + List updatesList = unPackFrm.FileList; + + // + unPackFrm.Dispose(); + + // + UpdatesListForm updatesListForm = new UpdatesListForm(updatesList); + + // + DialogResult ulDialogResult = updatesListForm.ShowDialog(); + + // -- + if (ulDialogResult == DialogResult.Cancel) + { + // + CleanThis(updatesList); + return; + } + + // + } + + private void StartForm_Load (object sender, EventArgs e) + { + if (!string.IsNullOrWhiteSpace(dataFileSelector.Text) || !File.Exists(dataFileSelector.Text)) + return; + + string dataFileSeek = $"{Application.StartupPath}\\msou.data"; + + if (File.Exists(dataFileSeek)) + dataFileSelector.Text = dataFileSeek; + } + + private void CleanThis(List fileList) + { + // + foreach (string file in fileList) + File.Delete(file); + + // + Directory.Delete(TempWorkDir, true); + } +} diff --git a/msou_installer/Forms/MainForm.resx b/msou_installer/Forms/MainForm.resx new file mode 100644 index 0000000..084584e --- /dev/null +++ b/msou_installer/Forms/MainForm.resx @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/msou_installer/Forms/UnPackForm.Designer.cs b/msou_installer/Forms/UnPackForm.Designer.cs new file mode 100644 index 0000000..98f2c90 --- /dev/null +++ b/msou_installer/Forms/UnPackForm.Designer.cs @@ -0,0 +1,92 @@ +namespace msoui.Forms; + +sealed partial class UnPackForm +{ + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose (bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent () + { + this.components = new System.ComponentModel.Container(); + this.waitLabel = new System.Windows.Forms.Label(); + this.progressBar = new System.Windows.Forms.ProgressBar(); + this.startTimer = new System.Windows.Forms.Timer(this.components); + this.SuspendLayout(); + // + // waitLabel + // + this.waitLabel.AccessibleRole = System.Windows.Forms.AccessibleRole.Indicator; + this.waitLabel.AutoEllipsis = true; + this.waitLabel.Dock = System.Windows.Forms.DockStyle.Top; + this.waitLabel.Location = new System.Drawing.Point(0, 0); + this.waitLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.waitLabel.Name = "waitLabel"; + this.waitLabel.Size = new System.Drawing.Size(530, 45); + this.waitLabel.TabIndex = 0; + this.waitLabel.Text = "&Открытие файла данных..."; + this.waitLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.waitLabel.UseCompatibleTextRendering = true; + // + // progressBar + // + this.progressBar.Dock = System.Windows.Forms.DockStyle.Fill; + this.progressBar.Location = new System.Drawing.Point(0, 45); + this.progressBar.Margin = new System.Windows.Forms.Padding(10); + this.progressBar.Name = "progressBar"; + this.progressBar.Size = new System.Drawing.Size(530, 20); + this.progressBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous; + this.progressBar.TabIndex = 1; + // + // startTimer + // + this.startTimer.Interval = 1000; + this.startTimer.Tick += new System.EventHandler(this.startTimer_Tick); + // + // UnPackForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 21F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(530, 65); + this.ControlBox = false; + this.Controls.Add(this.progressBar); + this.Controls.Add(this.waitLabel); + this.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; + this.Margin = new System.Windows.Forms.Padding(4); + this.MaximizeBox = false; + this.Name = "UnPackForm"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Пожалуйста, подождите. Идёт распаковка файла данных обновлений..."; + this.Load += new System.EventHandler(this.UnPackForm_Load); + this.ResumeLayout(false); + + } + + #endregion + + private Label waitLabel; + private ProgressBar progressBar; + private System.Windows.Forms.Timer startTimer; +} \ No newline at end of file diff --git a/msou_installer/Forms/UnPackForm.cs b/msou_installer/Forms/UnPackForm.cs new file mode 100644 index 0000000..b6c6212 --- /dev/null +++ b/msou_installer/Forms/UnPackForm.cs @@ -0,0 +1,105 @@ +using msoui.Enums; +using msoui.Models; + +using SevenZipExtractor; + +namespace msoui.Forms; +public sealed partial class UnPackForm: Form +{ + public UnPackForm (UnPackModel model) + { + Model = model; + FileList = new(); + InitializeComponent(); + } + + private const string MessageUnPackFile = "Распаковывается файл {0}..."; + + public UnPackModel Model { get; set; } + + public List FileList { get; set; } + + + private void UnPackThis() + { + //Создаю папку + Directory.CreateDirectory(Model.UnPackDir); + + //Папка, которая отсеивается + string unFolderName = Model.Bits == EBits.Bit32 ? "x64" : "x32"; + + //Открываю архив + using ArchiveFile archiveFile = new(Model.DataFile); + + //Создаю список на извлечение + List extractList = new(); + + //Обхожу список и отсеиваю ненужные + foreach (Entry entry in archiveFile.Entries) + { + //Если папка + if (entry.IsFolder) + { + //то проверяем нужную разрядность + if (entry.FileName != unFolderName) + //если да, то добавляем в список для извлечения + extractList.Add(entry); + } + else + { + //если это файл, то проверяем на нахождение в нужной папке + if (entry.FileName[..3] == unFolderName) + continue; + + //и добавляем в список, если нужной + extractList.Add(entry); + } + } + + //Устанавливаю максимальное значение индикатора прогресса + progressBar.Maximum = extractList.Count; + + //Извлекаю архив + foreach (Entry entry in extractList) + { + //Формирую имя файла назначения + string unPackFileName; + try + { + unPackFileName = entry.FileName[4..]; + } + catch (Exception) + { + unPackFileName = "UnNamed"; + } + + //Вывожу сообщение + waitLabel.Text = string.Format(MessageUnPackFile, unPackFileName); + Application.DoEvents(); + + //Распаковываю файл + //entry.Extract($@"{unPackTo}{unPackFileName}"); + + //Добавляю в список файлов + if (File.Exists($@"{Model.UnPackDir}{unPackFileName}")) + FileList.Add(unPackFileName); + + //Добавляю деление в индикатор прогресса + progressBar.Value++; + } + + //Выхожу + DialogResult = DialogResult.OK; + } + + private void startTimer_Tick (object sender, EventArgs e) + { + startTimer.Enabled = false; + UnPackThis(); + } + + private void UnPackForm_Load (object sender, EventArgs e) + { + startTimer.Enabled = true; + } +} diff --git a/msou_installer/Forms/UnPackForm.resx b/msou_installer/Forms/UnPackForm.resx new file mode 100644 index 0000000..f853226 --- /dev/null +++ b/msou_installer/Forms/UnPackForm.resx @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/msou_installer/Forms/UpdatesListForm.Designer.cs b/msou_installer/Forms/UpdatesListForm.Designer.cs new file mode 100644 index 0000000..a1e18d3 --- /dev/null +++ b/msou_installer/Forms/UpdatesListForm.Designer.cs @@ -0,0 +1,140 @@ +namespace msoui.Forms; + +sealed partial class UpdatesListForm +{ + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose (bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent () + { + this.components = new System.ComponentModel.Container(); + this.updatesListBox = new System.Windows.Forms.CheckedListBox(); + this.introLabel = new System.Windows.Forms.Label(); + this.selectAllButton = new System.Windows.Forms.Button(); + this.installButton = new System.Windows.Forms.Button(); + this.cancelButton = new System.Windows.Forms.Button(); + this.selectionStatus = new System.Windows.Forms.Label(); + this.checkedUpdateTimer = new System.Windows.Forms.Timer(this.components); + this.SuspendLayout(); + // + // updatesListBox + // + this.updatesListBox.FormattingEnabled = true; + this.updatesListBox.Location = new System.Drawing.Point(17, 41); + this.updatesListBox.Margin = new System.Windows.Forms.Padding(4); + this.updatesListBox.Name = "updatesListBox"; + this.updatesListBox.Size = new System.Drawing.Size(607, 412); + this.updatesListBox.TabIndex = 0; + // + // introLabel + // + this.introLabel.Location = new System.Drawing.Point(15, 9); + this.introLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.introLabel.Name = "introLabel"; + this.introLabel.Size = new System.Drawing.Size(421, 21); + this.introLabel.TabIndex = 1; + this.introLabel.Text = "&Выберете доступные обновленияиз списка:"; + this.introLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // selectAllButton + // + this.selectAllButton.Location = new System.Drawing.Point(496, 4); + this.selectAllButton.Name = "selectAllButton"; + this.selectAllButton.Size = new System.Drawing.Size(128, 30); + this.selectAllButton.TabIndex = 2; + this.selectAllButton.Text = "Выбрать &всё"; + this.selectAllButton.UseVisualStyleBackColor = true; + this.selectAllButton.Click += new System.EventHandler(this.selectAllButton_Click); + // + // installButton + // + this.installButton.Location = new System.Drawing.Point(496, 467); + this.installButton.Name = "installButton"; + this.installButton.Size = new System.Drawing.Size(128, 41); + this.installButton.TabIndex = 3; + this.installButton.Text = "&Установить >"; + this.installButton.UseVisualStyleBackColor = true; + // + // cancelButton + // + this.cancelButton.Location = new System.Drawing.Point(362, 467); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.Size = new System.Drawing.Size(128, 41); + this.cancelButton.TabIndex = 4; + this.cancelButton.Text = "< &Отмена"; + this.cancelButton.UseVisualStyleBackColor = true; + this.cancelButton.Click += new System.EventHandler(this.button2_Click); + // + // selectionStatus + // + this.selectionStatus.AutoSize = true; + this.selectionStatus.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point); + this.selectionStatus.Location = new System.Drawing.Point(17, 457); + this.selectionStatus.Name = "selectionStatus"; + this.selectionStatus.Size = new System.Drawing.Size(110, 20); + this.selectionStatus.TabIndex = 5; + this.selectionStatus.Text = "0 из 0 выбрано"; + this.selectionStatus.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // checkedUpdateTimer + // + this.checkedUpdateTimer.Enabled = true; + this.checkedUpdateTimer.Tick += new System.EventHandler(this.checkedUpdateTimer_Tick); + // + // UpdatesListForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 21F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(637, 512); + this.ControlBox = false; + this.Controls.Add(this.selectionStatus); + this.Controls.Add(this.cancelButton); + this.Controls.Add(this.installButton); + this.Controls.Add(this.selectAllButton); + this.Controls.Add(this.introLabel); + this.Controls.Add(this.updatesListBox); + this.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.Margin = new System.Windows.Forms.Padding(4); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "UpdatesListForm"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Список доступных обновлений"; + this.Load += new System.EventHandler(this.UpdatesListForm_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private CheckedListBox updatesListBox; + private Label introLabel; + private Button selectAllButton; + private Button installButton; + private Button cancelButton; + private Label selectionStatus; + private System.Windows.Forms.Timer checkedUpdateTimer; +} \ No newline at end of file diff --git a/msou_installer/Forms/UpdatesListForm.cs b/msou_installer/Forms/UpdatesListForm.cs new file mode 100644 index 0000000..5d555b4 --- /dev/null +++ b/msou_installer/Forms/UpdatesListForm.cs @@ -0,0 +1,37 @@ +namespace msoui.Forms; +public sealed partial class UpdatesListForm: Form +{ + public UpdatesListForm (List updatesList) + { + UpdatesList = updatesList; + InitializeComponent(); + } + + public List UpdatesList { get; set; } + + private const string SelectionStatusLabel = "{0} выбрано из {1}"; + + private void button2_Click (object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void selectAllButton_Click (object sender, EventArgs e) + { + for (int index = 0; index < updatesListBox.Items.Count; index++) + updatesListBox.SetItemCheckState(index, CheckState.Checked); + } + + private void UpdatesListForm_Load (object sender, EventArgs e) + { + updatesListBox.Items.Clear(); + + foreach (string item in UpdatesList) + updatesListBox.Items.Add(item, CheckState.Checked); + } + + private void checkedUpdateTimer_Tick (object sender, EventArgs e) + { + selectionStatus.Text = string.Format(SelectionStatusLabel, updatesListBox.CheckedItems.Count, updatesListBox.Items.Count); + } +} diff --git a/msou_installer/Forms/UpdatesListForm.resx b/msou_installer/Forms/UpdatesListForm.resx new file mode 100644 index 0000000..aac8597 --- /dev/null +++ b/msou_installer/Forms/UpdatesListForm.resx @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/msou_installer/Models/UnPackModel.cs b/msou_installer/Models/UnPackModel.cs new file mode 100644 index 0000000..a73ba7d --- /dev/null +++ b/msou_installer/Models/UnPackModel.cs @@ -0,0 +1,38 @@ +using msoui.Enums; + +namespace msoui.Models; + +/// +/// Модель для распаковки +/// +public class UnPackModel +{ + public UnPackModel(string dataFile, EBits bits, string unPackDir) + { + DataFile = dataFile; + Bits = bits; + UnPackDir = unPackDir; + } + + public UnPackModel () + { + DataFile = ""; + Bits = EBits.Bit32; + UnPackDir = @".\"; + } + + /// + /// Файл-данных обновлений + /// + public string DataFile { get; set; } + + /// + /// Разрядность MS Office 2016 + /// + public EBits Bits { get; set; } + + /// + /// Каталог распаковки + /// + public string UnPackDir { get; set; } +} \ No newline at end of file diff --git a/msou_installer/Program.cs b/msou_installer/Program.cs new file mode 100644 index 0000000..cb558be --- /dev/null +++ b/msou_installer/Program.cs @@ -0,0 +1,18 @@ +using msoui.Forms; + +namespace msoui; + +internal static class Program +{ + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main () + { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + Application.Run(new MainForm()); + } +} \ No newline at end of file diff --git a/msou_installer/msou_installer.csproj b/msou_installer/msou_installer.csproj new file mode 100644 index 0000000..484e10d --- /dev/null +++ b/msou_installer/msou_installer.csproj @@ -0,0 +1,17 @@ + + + + WinExe + net6.0-windows + enable + true + enable + msoui + + + + + + + + \ No newline at end of file