Skip to content

Commit

Permalink
update status
Browse files Browse the repository at this point in the history
  • Loading branch information
kianzarrin committed Sep 28, 2021
1 parent f97981e commit 74e5e68
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 8 deletions.
1 change: 1 addition & 0 deletions LoadOrder/UI/AssetDataGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ public class AssetDataGrid : DataGridView {
} else {
Log.Error("unexpected column changed: " + Columns[e.ColumnIndex]?.Name);
}
LoadOrderWindow.Instance.UpdateStatus();
}


Expand Down
42 changes: 35 additions & 7 deletions LoadOrder/UI/LoadOrderWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ enum WSFilter {
var modTask = InitializeModTab();
var assetTask = InitializeAssetTab();
await Task.WhenAll(modTask, assetTask);
if(!LoadOrderToolSettings.Instace.LastProfileName.IsNullorEmpty())
LastProfileLabel.Text = $"last profile was '{LoadOrderToolSettings.Instace.LastProfileName}'";
TabContainer.Selected += (_, __) => UpdateStatus();

UpdateStatus();

menuStrip.tsmiAutoSave.CheckedChanged += TsmiAutoSave_CheckedChanged;
menuStrip.tsmiAutoSave.Click += TsmiAutoSave_Click;
Expand Down Expand Up @@ -176,6 +177,8 @@ enum WSFilter {
LoadOrderToolSettings.Instace.FormHeight = Height;
}



#region MenuBar
private async void TsmiResetSettings_Click(object sender, EventArgs e) => await TsmiResetSettings();
private async Task TsmiResetSettings() {
Expand All @@ -202,7 +205,7 @@ enum WSFilter {
public void UpdateLastProfileName(string fullPath) {
LoadOrderToolSettings.Instace.LastProfileName = Path.GetFileNameWithoutExtension(fullPath);
LoadOrderToolSettings.Instace.Serialize();
LastProfileLabel.Text = $"last profile was '{LoadOrderToolSettings.Instace.LastProfileName}'";
UpdateStatus();
}

private void Export_Click(object sender, EventArgs e) {
Expand All @@ -229,6 +232,7 @@ enum WSFilter {
bool replace = opd.DialogResult == OpenProfileDialog.RESULT_REPLACE;
ApplyProfile(profile, types: opd.ItemTypes, replace: replace);
if(replace) UpdateLastProfileName(ofd.FileName);
else UpdateStatus();
}
}
}
Expand Down Expand Up @@ -336,8 +340,7 @@ enum WSFilter {

dataGridMods.CellMouseClick += DataGridMods_CellMouseClick;

dataGridMods.VisibleChanged += (_, __) => ModCountLabel.Visible = dataGridMods.Visible;
ModCountLabel.Visible = true;
UpdateStatus();
}

private void RefreshModList(object sender, EventArgs e) {
Expand Down Expand Up @@ -477,7 +480,7 @@ enum WSFilter {

dataGridAssets.CellMouseClick += DataGridAssets_CellMouseClick;

dataGridAssets.VisibleChanged += (_, __) => AssetCountLabel.Visible = dataGridAssets.Visible;
UpdateStatus();
}

public async Task LoadAssetsAsync() {
Expand Down Expand Up @@ -577,7 +580,7 @@ enum WSFilter {
if (tagFilter == NO_TAGS) tagFilter = null;
var words = TextFilterAsset.Text?.Split(" ");
assetList.FilterItems(item => AssetPredicateFast(item, includedFilter, wsFilter, tagFilter, words));
AssetCountLabel.Text = $"showing {assetList.Filtered.Count}/{assetList.Original.Count} assets";
UpdateStatus();
}

bool AssetPredicateFast(
Expand Down Expand Up @@ -658,9 +661,34 @@ enum WSFilter {
}
#endregion

public void UpdateStatus() {
try {
ModCountLabel.Visible = TabContainer.SelectedTab == ModsTab;
if(dataGridMods.ModList is ModList modList) {
ModCountLabel.Text = $"mods " +
$"enabled:{modList.Count(mod => mod.IsEnabledPending)} " +
$"included:{modList.Count(mod => mod.IsIncludedPending)} " +
$"totlal:{modList.Count}";
}

AssetCountLabel.Visible = TabContainer.SelectedTab == AssetsTab;
if(dataGridAssets.AssetList is AssetList asseList) {
AssetCountLabel.Text = $"assets " +
$"included:{asseList.Original.Count(asset => asset.IsIncludedPending)} " +
$"totlal:{asseList.Original.Count}";
}


string lastProfileName = LoadOrderToolSettings.Instace?.LastProfileName;
LastProfileLabel.Visible = !lastProfileName.IsNullorEmpty();
LastProfileLabel.Text = $"Last profile was '{lastProfileName}'";
} catch(Exception ex) { ex.Log(); }
}

public void RefreshAll() {
dataGridMods.RefreshModList();
dataGridAssets.Refresh();
UpdateStatus();
}

public async Task ReloadAll() {
Expand Down
3 changes: 2 additions & 1 deletion LoadOrder/UI/ModDataGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ public class ModDataGrid : DataGridView {
} else {
return;
}
LoadOrderWindow.Instance.UpdateStatus();
} catch (Exception ex) {
Log.Exception(ex);
}
Expand Down Expand Up @@ -340,7 +341,7 @@ public class ModDataGrid : DataGridView {
}
ModList.FilterIn();
PopulateMods();
LoadOrderWindow.Instance.ModCountLabel.Text = $"showing {ModList.Filtered.Count}/{ModList.Count} mods";
LoadOrderWindow.Instance.UpdateStatus();
}

public DataGridViewRow GetRow(PluginManager.PluginInfo pluginInfo) {
Expand Down

0 comments on commit 74e5e68

Please sign in to comment.