This commit is contained in:
Alexander
2022-10-18 17:22:15 +03:00
parent 7599819edb
commit 2300e68408
22 changed files with 378 additions and 338 deletions

View File

@@ -46,7 +46,7 @@ partial class InstallForm
this.actionPanel.Location = new System.Drawing.Point(0, 0);
this.actionPanel.Name = "actionPanel";
this.actionPanel.Padding = new System.Windows.Forms.Padding(10);
this.actionPanel.Size = new System.Drawing.Size(496, 91);
this.actionPanel.Size = new System.Drawing.Size(738, 91);
this.actionPanel.TabIndex = 5;
//
// progressBar
@@ -54,7 +54,7 @@ partial class InstallForm
this.progressBar.Dock = System.Windows.Forms.DockStyle.Fill;
this.progressBar.Location = new System.Drawing.Point(10, 59);
this.progressBar.Name = "progressBar";
this.progressBar.Size = new System.Drawing.Size(476, 22);
this.progressBar.Size = new System.Drawing.Size(718, 22);
this.progressBar.TabIndex = 1;
//
// statusLabel
@@ -62,7 +62,7 @@ partial class InstallForm
this.statusLabel.Dock = System.Windows.Forms.DockStyle.Top;
this.statusLabel.Location = new System.Drawing.Point(10, 10);
this.statusLabel.Name = "statusLabel";
this.statusLabel.Size = new System.Drawing.Size(476, 49);
this.statusLabel.Size = new System.Drawing.Size(718, 49);
this.statusLabel.TabIndex = 0;
this.statusLabel.Text = "&Начинаю установку...";
//
@@ -74,7 +74,7 @@ partial class InstallForm
this.logList.Location = new System.Drawing.Point(0, 0);
this.logList.Margin = new System.Windows.Forms.Padding(10);
this.logList.Name = "logList";
this.logList.Size = new System.Drawing.Size(496, 313);
this.logList.Size = new System.Drawing.Size(738, 442);
this.logList.TabIndex = 4;
//
// process
@@ -97,7 +97,7 @@ partial class InstallForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 21F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(496, 313);
this.ClientSize = new System.Drawing.Size(738, 442);
this.ControlBox = false;
this.Controls.Add(this.actionPanel);
this.Controls.Add(this.logList);
@@ -106,6 +106,7 @@ partial class InstallForm
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "InstallForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Установка обновлений";
this.Load += new System.EventHandler(this.InstallForm_Load);
this.actionPanel.ResumeLayout(false);

View File

@@ -1,28 +1,36 @@
namespace msoui.Forms;
public partial class InstallForm: Form
using msoui.Models;
namespace msoui.Forms;
public partial class InstallForm : Form
{
public InstallForm (List<string> fileList, string extractDir)
public InstallForm(InstallModel model)
{
FileList = fileList;
ExtractDir = extractDir;
Model = model;
InitializeComponent();
}
public List<string> FileList { get; set; }
public string ExtractDir { get; set; }
public InstallModel Model { get; set; }
private void LogIt(string message)
{
logList.Items.Add(message);
Application.DoEvents();
}
private void LogIt (string message, params object?[] args)
private void LogIt(string message, params object?[] args)
{
logList.Items.Add(string.Format(message, args));
Application.DoEvents();
}
public void StartProcess (string fileName)
private void AddStatus(string message, params object?[] args)
{
statusLabel.Text = string.Format(message, args);
Application.DoEvents();
}
public void StartProcess(string fileName)
{
process.StartInfo.FileName = fileName;
process.StartInfo.Arguments = "/q /norestart";
@@ -34,42 +42,69 @@ public partial class InstallForm: Form
}
public void InstallUpdates ()
public void InstallUpdates()
{
//Сообщение о начале установки
LogIt("Начинаю установку...");
int updatesCount = FileList.Count;
//Высчитываю максимальное число программ
int updatesCount = Model.FileList.Count;
//Вывожу сообщение о количестве элементов
LogIt("Выбрано {0} обновлений для установки...", updatesCount);
AddStatus("Выбрано {0} обновлений для установки...", updatesCount);
//Счётчик
int count = 0;
foreach (string? file in FileList)
//Устанавливаю индикатор прогресса
progressBar.Maximum = updatesCount;
progressBar.Value = 0;
//Запускаю программы установки
foreach (string? file in Model.FileList)
{
//Добавляю статусное сообщение
AddStatus("Устанавливается обновление: {0}", file);
//Прибавляю счётчик
count++;
decimal percentDone = Math.Round((decimal)count / updatesCount * 100);
//Считаю процент выполненного
decimal percentDone = Math.Round((decimal) count / updatesCount * 100);
//Заношу в лог информацию об устанавливаемом файле
LogIt(@"Устанавливается файл {0} [{1} из {2}, {3}%]...", file, count, updatesCount, percentDone);
StartProcess($"{ExtractDir}{file}");
//Запускаю файл установки
StartProcess($"{Model.FromDir}{file}");
Application.DoEvents();
//Увеличиваю прогресс
progressBar.Value++;
Application.DoEvents();
//Вывожу сообщение об установке
LogIt(@"Файл {0} установлен!", file);
}
//Вывожу сообщение об окончании установки
MessageBox.Show(@"Набор обновлений успешно установлен!", @"Установка завершена", MessageBoxButtons.OK,
MessageBoxIcon.Asterisk);
//Закрываю окно
DialogResult = DialogResult.OK;
}
private void startTimer_Tick (object sender, EventArgs e)
private void startTimer_Tick(object sender, EventArgs e)
{
startTimer.Enabled = false;
InstallUpdates();
}
private void InstallForm_Load (object sender, EventArgs e)
private void InstallForm_Load(object sender, EventArgs e)
{
startTimer.Enabled = true;
}
}
}

View File

@@ -30,52 +30,35 @@ sealed partial class MainForm
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
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.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.Size = new System.Drawing.Size(684, 207);
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.Location = new System.Drawing.Point(40, 109);
this.bitsSelector64.Name = "bitsSelector64";
this.bitsSelector64.Size = new System.Drawing.Size(179, 25);
this.bitsSelector64.TabIndex = 5;
@@ -88,7 +71,7 @@ sealed partial class MainForm
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.Location = new System.Drawing.Point(40, 78);
this.bitsSelector32.Name = "bitsSelector32";
this.bitsSelector32.Size = new System.Drawing.Size(179, 25);
this.bitsSelector32.TabIndex = 4;
@@ -96,32 +79,15 @@ sealed partial class MainForm
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.Location = new System.Drawing.Point(12, 45);
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;
@@ -138,7 +104,7 @@ sealed partial class MainForm
this.buttonsPanel.Controls.Add(this.exitButton);
this.buttonsPanel.Controls.Add(this.installButton);
this.buttonsPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
this.buttonsPanel.Location = new System.Drawing.Point(0, 214);
this.buttonsPanel.Location = new System.Drawing.Point(0, 146);
this.buttonsPanel.Name = "buttonsPanel";
this.buttonsPanel.Size = new System.Drawing.Size(684, 61);
this.buttonsPanel.TabIndex = 1;
@@ -163,17 +129,11 @@ sealed partial class MainForm
this.installButton.UseVisualStyleBackColor = true;
this.installButton.Click += new System.EventHandler(this.installButton_Click);
//
// 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.ClientSize = new System.Drawing.Size(684, 207);
this.ControlBox = false;
this.Controls.Add(this.buttonsPanel);
this.Controls.Add(this.contentPanel);
@@ -186,7 +146,6 @@ sealed partial class MainForm
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);
@@ -198,14 +157,10 @@ sealed partial class MainForm
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 OpenFileDialog dataFileDialog;
}

View File

@@ -1,57 +1,47 @@
using anbs_cp;
using msoui.Enums;
using msoui.Models;
namespace msoui.Forms;
public sealed partial class MainForm: Form
public sealed partial class MainForm : Form
{
public MainForm ()
public MainForm()
{
TempWorkDir = $@"{LikeDelphi.IncludeTrailingBackslash(Path.GetTempPath())}msoui\";
TempWorkDir = @".\msou\";
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)
private void exitButton_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void installButton_Click (object sender, EventArgs e)
private void installButton_Click(object sender, EventArgs e)
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (string.IsNullOrWhiteSpace(dataFileSelector.Text) || !File.Exists(dataFileSelector.Text))
{
MessageBox.Show($@"<22><><EFBFBD><EFBFBD> {dataFileSelector.Text} <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!", @"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!", MessageBoxButtons.OK, MessageBoxIcon.Error);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> tmp
string oldTempWorkDir = TempWorkDir;
return;
}
//<2F><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> tmp
TempWorkDir = bitsSelector64.Checked ? $@"{TempWorkDir}x64\" : $@"{TempWorkDir}x32\";
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UnPackModel model = new(dataFileSelector.Text, bitsSelector64.Checked ? EBits.Bit64 : EBits.Bit32, TempWorkDir);
ScanDirModel scanModel = new("*.exe", TempWorkDir, false);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UnPackForm unPackFrm = new(model);
ScanDirForm scanDirFrm = new(scanModel);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
unPackFrm.ShowDialog();
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
List<string> updatesList = unPackFrm.FileList;
scanDirFrm.ShowDialog();
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
unPackFrm.Dispose();
scanDirFrm.Dispose();
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ListModel updateListModel = new(scanDirFrm.Model.FoundList);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UpdatesListForm updatesListForm = new(updatesList);
UpdatesListForm updatesListForm = new(updateListModel);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
DialogResult ulDialogResult = updatesListForm.ShowDialog();
@@ -59,16 +49,19 @@ public sealed partial class MainForm: Form
//<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> -- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (ulDialogResult == DialogResult.Cancel)
{
//<2F><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
CleanThis(updatesList);
//<2F><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
TempWorkDir = oldTempWorkDir;
return;
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
updatesListForm.Dispose();
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
InstallModel installModel = new(updateListModel.OutList, TempWorkDir);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
InstallForm installForm = new (updatesList, TempWorkDir);
InstallForm installForm = new(installModel);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
installForm.ShowDialog();
@@ -76,28 +69,7 @@ public sealed partial class MainForm: Form
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
installForm.Dispose();
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>
CleanThis(updatesList);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> tmp
TempWorkDir = oldTempWorkDir;
}
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<string> fileList)
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
foreach (string file in fileList)
File.Delete(file);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
Directory.Delete(TempWorkDir, true);
}
}
}

View File

@@ -57,9 +57,6 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="dataFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>

View File

@@ -1,6 +1,6 @@
namespace msoui.Forms;
sealed partial class UnPackForm
sealed partial class ScanDirForm
{
/// <summary>
/// Required designer variable.
@@ -29,24 +29,24 @@ sealed partial class UnPackForm
private void InitializeComponent ()
{
this.components = new System.ComponentModel.Container();
this.waitLabel = new System.Windows.Forms.Label();
this.statusLabel = new System.Windows.Forms.Label();
this.progressBar = new System.Windows.Forms.ProgressBar();
this.startTimer = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout();
//
// waitLabel
// statusLabel
//
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;
this.statusLabel.AccessibleRole = System.Windows.Forms.AccessibleRole.Indicator;
this.statusLabel.AutoEllipsis = true;
this.statusLabel.Dock = System.Windows.Forms.DockStyle.Top;
this.statusLabel.Location = new System.Drawing.Point(0, 0);
this.statusLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.statusLabel.Name = "statusLabel";
this.statusLabel.Size = new System.Drawing.Size(530, 45);
this.statusLabel.TabIndex = 0;
this.statusLabel.Text = "&Пожалуйста, подождите. Идёт поиск файлов.";
this.statusLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.statusLabel.UseCompatibleTextRendering = true;
//
// progressBar
//
@@ -63,22 +63,22 @@ sealed partial class UnPackForm
this.startTimer.Interval = 1000;
this.startTimer.Tick += new System.EventHandler(this.startTimer_Tick);
//
// UnPackForm
// ScanDirForm
//
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.Controls.Add(this.statusLabel);
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.Name = "ScanDirForm";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Пожалуйста, подождите. Идёт распаковка файла данных обновлений...";
this.Text = "Поиск файлов";
this.Load += new System.EventHandler(this.UnPackForm_Load);
this.ResumeLayout(false);
@@ -86,7 +86,7 @@ sealed partial class UnPackForm
#endregion
private Label waitLabel;
private Label statusLabel;
private ProgressBar progressBar;
private System.Windows.Forms.Timer startTimer;
}

View File

@@ -0,0 +1,69 @@
using msoui.Models;
namespace msoui.Forms;
public sealed partial class ScanDirForm : Form
{
private const string SearchFile = "&Пожалуйста, подождите. Идёт поиск файлов. Найдено: {0} файлов...";
public ScanDirForm(ScanDirModel model)
{
Model = model;
InitializeComponent();
}
public ScanDirModel Model { get; set; }
private void AddStatus(string message, params object[] args)
{
statusLabel.Text = string.Format(message, args);
Application.DoEvents();
}
public void ScanForFiles()
{
//Счётчик найденных
int foundsCount = 0;
//Добавляю статусное сообщение
AddStatus(SearchFile, foundsCount);
//Осуществляю подсчёт файлов
foreach (string file in Directory.EnumerateFiles(Model.SearchDir, Model.Mask,
Model.ScanSubDirs ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly))
{
try
{
//Получаю информацию о файле
FileInfo info = new(file);
//Добавляю имя файла в список
Model.FoundList.Add(info.Name);
//Увеличиваю число найденных
foundsCount++;
//Добавляю статус
AddStatus(SearchFile, foundsCount);
}
catch
{
// ignored
}
}
//Выхожу из формы
DialogResult = DialogResult.OK;
}
private void startTimer_Tick(object sender, EventArgs e)
{
startTimer.Enabled = false;
ScanForFiles();
}
private void UnPackForm_Load(object sender, EventArgs e)
{
startTimer.Enabled = true;
}
}

View File

@@ -1,105 +0,0 @@
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<string> 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<Entry> 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($@"{Model.UnPackDir}{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;
}
}

View File

@@ -1,48 +1,53 @@
namespace msoui.Forms;
public sealed partial class UpdatesListForm: Form
using msoui.Models;
namespace msoui.Forms;
public sealed partial class UpdatesListForm : Form
{
public UpdatesListForm (List<string> updatesList)
private const string SelectionStatusLabel = "{0} выбрано из {1}";
public UpdatesListForm(ListModel model)
{
UpdatesList = updatesList;
Model = model;
InitializeComponent();
}
public List<string> UpdatesList { get; set; }
public ListModel Model { get; set; }
private const string SelectionStatusLabel = "{0} выбрано из {1}";
private void selectAllButton_Click (object sender, EventArgs e)
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)
private void UpdatesListForm_Load(object sender, EventArgs e)
{
updatesListBox.Items.Clear();
foreach (string item in UpdatesList)
foreach (string item in Model.InList)
updatesListBox.Items.Add(item, CheckState.Checked);
}
private void checkedUpdateTimer_Tick (object sender, EventArgs e)
private void checkedUpdateTimer_Tick(object sender, EventArgs e)
{
selectionStatus.Text = string.Format(SelectionStatusLabel, updatesListBox.CheckedItems.Count, updatesListBox.Items.Count);
selectionStatus.Text = string.Format(SelectionStatusLabel, updatesListBox.CheckedItems.Count,
updatesListBox.Items.Count);
}
private void installButton_Click (object sender, EventArgs e)
private void installButton_Click(object sender, EventArgs e)
{
UpdatesList.Clear();
Model.OutList.Clear();
foreach (object checkedItem in updatesListBox.CheckedItems)
{
if (checkedItem.ToString() != null)
UpdatesList.Add(checkedItem.ToString()!);
}
foreach (object checkedItem in updatesListBox.CheckedItems.Cast<object>()
.Where(static checkedItem => checkedItem.ToString() != null))
// ReSharper disable once NullableWarningSuppressionIsUsed
Model.OutList.Add(checkedItem.ToString()!);
DialogResult = DialogResult.OK;
}
private void cancelButton_Click (object sender, EventArgs e)
private void cancelButton_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
}
}