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

3
.gitignore vendored
View File

@ -399,4 +399,5 @@ FodyWeavers.xsd
*.sln.iml
# Releases Temporary Dir
releases/
releases/
msou/

5
MSOUI.sln.DotSettings Normal file
View File

@ -0,0 +1,5 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=msou/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=msoui/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0421_0447_0451_0442_0447_0438_043A/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=_043F_043E_0434_0441_0447_0451_0442/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@ -1,17 +0,0 @@
namespace msoui.Enums;
/// <summary>
/// Перечисление разрядности
/// </summary>
public enum EBits
{
/// <summary>
/// 32-разрядная версия
/// </summary>
Bit32 = 0,
/// <summary>
/// 64-разрядная версия
/// </summary>
Bit64 = 1
}

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)
{
//Ïðîâåðÿþ âõîäíûå ïàðàìåòðû
if (string.IsNullOrWhiteSpace(dataFileSelector.Text) || !File.Exists(dataFileSelector.Text))
{
MessageBox.Show($@"Ôàéë {dataFileSelector.Text} íå ñóùåñòâóåò!", @"Îøèáêà!", MessageBoxButtons.OK, MessageBoxIcon.Error);
//Ñòàðàÿ ïàïêà tmp
string oldTempWorkDir = TempWorkDir;
return;
}
//Íîâàÿ ïàïêà tmp
TempWorkDir = bitsSelector64.Checked ? $@"{TempWorkDir}x64\" : $@"{TempWorkDir}x32\";
//Ñîçäàþ ìîäåëü ðàñïàêîâêè
UnPackModel model = new(dataFileSelector.Text, bitsSelector64.Checked ? EBits.Bit64 : EBits.Bit32, TempWorkDir);
ScanDirModel scanModel = new("*.exe", TempWorkDir, false);
//Ñîçäàþ ôîðìó ðàñïàêîâêè
UnPackForm unPackFrm = new(model);
ScanDirForm scanDirFrm = new(scanModel);
//Ïîêàçûâàþ å¸
unPackFrm.ShowDialog();
//Ïîëó÷àþ ñïèñîê ôàéëîâ-îáíîâëåíèé
List<string> updatesList = unPackFrm.FileList;
scanDirFrm.ShowDialog();
//Îñâîáîæäàþ å¸
unPackFrm.Dispose();
scanDirFrm.Dispose();
//Ñîçäàþ ìîäåëü ñïèñêà ôàéëîâ
ListModel updateListModel = new(scanDirFrm.Model.FoundList);
//Ñîçäàþ ôîðìó ñïèñêà îáíîâëåíèé
UpdatesListForm updatesListForm = new(updatesList);
UpdatesListForm updatesListForm = new(updateListModel);
//Ïîêàçûâàþ å¸
DialogResult ulDialogResult = updatesListForm.ShowDialog();
@ -59,16 +49,19 @@ public sealed partial class MainForm: Form
//Åñëè ðåçóëüòàò -- îòìåíà
if (ulDialogResult == DialogResult.Cancel)
{
//Òî î÷èùàåì âñ¸ è âûõîäèì ê ãëàâíîìó îêíó
CleanThis(updatesList);
//Òî âûõîäèì ê ãëàâíîìó îêíó
TempWorkDir = oldTempWorkDir;
return;
}
//Îñâîáîæäàþ å¸
updatesListForm.Dispose();
//Ñîçäàþ ìîäåëü óñòàíîâêè
InstallModel installModel = new(updateListModel.OutList, TempWorkDir);
//Ñîçäàþ ôîðìó ñïèñêà îáíîâëåíèé
InstallForm installForm = new (updatesList, TempWorkDir);
InstallForm installForm = new(installModel);
//Ïîêàçûâàþ å¸
installForm.ShowDialog();
@ -76,28 +69,7 @@ public sealed partial class MainForm: Form
//Îñâîáîæäàþ å¸
installForm.Dispose();
//Î÷èùàþ êýø
CleanThis(updatesList);
//Âîçâðàùàåì ñòàðóþ ïàïêó 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)
{
//Î÷èùàþ ôàéëû
foreach (string file in fileList)
File.Delete(file);
//Óäàëÿþ âðåìåííóþ ïàïêó
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;
}
}
}

View File

@ -0,0 +1,23 @@
namespace msoui.Models;
/// <summary>
/// Модель для установки
/// </summary>
public class InstallModel
{
public InstallModel(List<string> fileList, string fromDir)
{
FileList = fileList;
FromDir = fromDir;
}
/// <summary>
/// Каталог с файлами
/// </summary>
public string FromDir { get; set; }
/// <summary>
/// Список файлов
/// </summary>
public List<string> FileList { get; set; }
}

View File

@ -0,0 +1,23 @@
namespace msoui.Models;
/// <summary>
/// Модель для списка
/// </summary>
public class ListModel
{
public ListModel(List<string> inList)
{
InList = inList;
OutList = new List<string>();
}
/// <summary>
/// Входящий список файлов
/// </summary>
public List<string> InList { get; set; }
/// <summary>
/// Исходящий список файлов
/// </summary>
public List<string> OutList { get; set; }
}

View File

@ -0,0 +1,35 @@
namespace msoui.Models;
/// <summary>
/// Модель для сканирования
/// </summary>
public class ScanDirModel
{
public ScanDirModel(string mask, string searchDir, bool scanSubDirs)
{
Mask = mask;
SearchDir = searchDir;
ScanSubDirs = scanSubDirs;
FoundList = new List<string>();
}
/// <summary>
/// Маска для поиска
/// </summary>
public string Mask { get; set; }
/// <summary>
/// Каталог поиска
/// </summary>
public string SearchDir { get; set; }
/// <summary>
/// Сканировать поддиректории
/// </summary>
public bool ScanSubDirs { get; set; }
/// <summary>
/// Список найденных файлов
/// </summary>
public List<string> FoundList { get; set; }
}

View File

@ -1,38 +0,0 @@
using msoui.Enums;
namespace msoui.Models;
/// <summary>
/// Модель для распаковки
/// </summary>
public class UnPackModel
{
public UnPackModel(string dataFile, EBits bits, string unPackDir)
{
DataFile = dataFile;
Bits = bits;
UnPackDir = unPackDir;
}
public UnPackModel ()
{
DataFile = "";
Bits = EBits.Bit32;
UnPackDir = @".\";
}
/// <summary>
/// Файл-данных обновлений
/// </summary>
public string DataFile { get; set; }
/// <summary>
/// Разрядность MS Office 2016
/// </summary>
public EBits Bits { get; set; }
/// <summary>
/// Каталог распаковки
/// </summary>
public string UnPackDir { get; set; }
}

View File

@ -5,10 +5,10 @@ namespace msoui;
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main ()
private static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.

View File

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MSOUI.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- Параметры манифеста UAC
Если вы хотите изменить уровень контроля учетных записей Windows, замените узел
requestedExecutionLevel на один из следующих.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
При указании элемента requestedExecutionLevel будет отключена виртуализация файлов и реестра.
Удалите этот элемент, если виртуализация требуется приложению для обратной
совместимости.
-->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Список версий Windows, на которых это приложение было протестировано
и будет работать. Раскомментируйте соответствующие элементы, чтобы ОС Windows
автоматически выбрала наиболее совместимое окружение. -->
<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />
<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
</application>
</compatibility>
<!-- Указывает, что приложение поддерживает определение DPI и не будет автоматически масштабироваться Windows при более высоких
значениях DPI. Приложения Windows Presentation Foundation (WPF) по умолчанию поддерживают определение DPI, им не нужно
специально включать параметр для этого. Для приложений Windows Forms на платформе .NET Framework 4.6, для которых задан этот параметр, необходимо
также задать для "EnableWindowsFormsHighDpiAutoResizing" значение "true" в файле app.config.
При этом приложение начинает учитывать длинные пути. Дополнительные сведения см. на странице https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation.-->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
</windowsSettings>
</application>
-->
<!-- Включите темы для общих элементов управления и диалоговых окон Windows (Windows XP и более поздние версии) -->
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -8,16 +8,16 @@
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>msoui</RootNamespace>
<StartupObject>msoui.Program</StartupObject>
<ApplicationIcon>arrow-down-square.ico</ApplicationIcon>
<ApplicationIcon>app_icon.ico</ApplicationIcon>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Content Include="arrow-down-square.ico" />
<Content Include="app_icon.ico" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ANBSoftware.ComponentsPack" Version="1.2022.723" />
<PackageReference Include="SevenZipExtractor" Version="1.0.17" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=msou/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>