Skip to content

Commit

Permalink
Рефакторинг основного окна.
Browse files Browse the repository at this point in the history
Вкладка обновления БД - предзагрузка натсроек tfs - в "фоне"
  • Loading branch information
ChernenkoAV committed Oct 14, 2022
1 parent e78c5c5 commit 3fda972
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 141 deletions.
25 changes: 2 additions & 23 deletions src/Arcas.UI/ArcasMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 15 additions & 16 deletions src/Arcas.UI/ArcasMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,37 @@ public partial class ArcasMain : Form
public ArcasMain()
{
InitializeComponent();
#pragma warning disable CS0618 // Тип или член устарел
tsVersion.Text = Updater.CurrentVersion();
#pragma warning restore CS0618 // Тип или член устарел

foreach (var tb in Locator.GetInstances<TabControlBase>())
Text = "Аркас " + Updater.CurrentVersion();

tabs.AddRange(Locator.GetInstances<TabControlBase>());

foreach (var tb in tabs)
{
var ts = new TabPage();

ts.Controls.Add(tb);
ts.Name = tb.Name;
ts.Text = tb.Text;
ts.UseVisualStyleBackColor = true;
refreshTabAction.Add(tb.RefreshTab);
rcloseAppAction.Add(tb.CloseApp);
tb.StateProgress += savbl_StatusMessages;
tb.Dock = DockStyle.Fill;
tcTabs.TabPages.Add(ts);
}
}

private List<Action> refreshTabAction = new List<Action>();
private List<Action> rcloseAppAction = new List<Action>();
private List<TabControlBase> tabs = new List<TabControlBase>();

private void выходToolStripMenuItem_Click(object sender, EventArgs e) =>
Close();

private void tabPageDBVer_Enter(object sender, EventArgs e)
private void arcasMain_Load(object sender, EventArgs e)
{
foreach (var item in refreshTabAction)
foreach (var item in tabs)
{
try
{
item.Invoke();
item.RefreshTab();
}
catch (Exception ex)
{
Expand All @@ -54,6 +53,7 @@ private void tabPageDBVer_Enter(object sender, EventArgs e)

Dialogs.ErrorF(this, msg);
}
}
}

private void savbl_StatusMessages(string message)
Expand All @@ -64,12 +64,14 @@ private void savbl_StatusMessages(string message)

private void arcasMainMindow_FormClosing(object sender, FormClosingEventArgs e)
{
foreach (var closeTab in rcloseAppAction)
foreach (var item in tabs)
{
try
{
closeTab();
item.CloseApp();
}
catch { }
}

Config.Instance.Save();

Expand All @@ -79,8 +81,5 @@ private void arcasMainMindow_FormClosing(object sender, FormClosingEventArgs e)
}
catch { }
}

private void arcasMain_Load(object sender, EventArgs e) =>
tabPageDBVer_Enter(null, null);
}
}
Loading

0 comments on commit 3fda972

Please sign in to comment.