Skip to content

Commit

Permalink
Added column for VS version #7
Browse files Browse the repository at this point in the history
Added saving/restoring of folder expansion state
  • Loading branch information
Andreas Saurwein committed Sep 6, 2023
1 parent 2b6c27f commit dfdd5f4
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 10 deletions.
5 changes: 5 additions & 0 deletions VSLXshared/DataModel/VisualStudioInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public string ShortName
/// </summary>
public string Version { get; }

/// <summary>
/// Gets the short version number, only major and minor version
/// </summary>
public string ShortVersion { get { return String.Join('.', this.Version.Split('.').Take(2)); } }

/// <summary>
/// Gets the release year/version
/// </summary>
Expand Down
8 changes: 6 additions & 2 deletions VSLXshared/DataModel/VisualStudioInstanceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@ public VisualStudioInstance GetByIdentifier(string identifier)
if (string.IsNullOrEmpty(name))
return HighestVersion();

return this.allInstances.Where(x => x.ShortName.Equals(name, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
var vsi = this.allInstances.Where(x => x.ShortName.Equals(name, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();

return vsi is null ? HighestVersion() : vsi;
}

/// <summary>
Expand All @@ -276,7 +278,9 @@ public VisualStudioInstance GetByIdentifier(string identifier)
if (string.IsNullOrEmpty(version))
return HighestVersion();

return this.allInstances.Where(x => x.Version.StartsWith(version, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
var vsi = this.allInstances.Where(x => x.Version.StartsWith(version, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();

return vsi is null ? HighestVersion() : vsi;
}

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion VSLXshared/DataModel/VsFolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ public VsItemList Items
/// <summary>
/// Gets or sets a value indicating whether this folder is expanded
/// </summary>
[JsonIgnore]
public bool Expanded { get; set; }

/// <summary>
Expand Down
24 changes: 20 additions & 4 deletions VSLauncherX/MainDialog.Designer.cs

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

46 changes: 43 additions & 3 deletions VSLauncherX/MainDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,24 @@ private void InitializeListview()
// setup the Date column
this.olvColumnDate.AspectGetter = ColumnHelper.GetAspectForDate;

// setup the Version column
this.olvColumnVersion.AspectGetter = delegate (object rowObject)
{
if (rowObject is VsItem item)
{
if(item.VsVersion is null)
{
return "<default>";
}

var vs = visualStudioInstances.GetByVersion(item.VsVersion);
string s = $"{vs.Year} ({vs.ShortVersion})";
return s;
}

return null;
};

// setup the Options column
this.olvColumnOptions.AspectGetter = ColumnHelper.GetAspectForOptions;
this.olvColumnOptions.ToolTipText = "";
Expand Down Expand Up @@ -166,9 +184,6 @@ private void InitializeListview()
/// </summary>
public MainDialog()
{
LoadSolutionData();

this.solutionGroups.Items.OnChanged += SolutionData_OnChanged;

InitializeComponent();
InitializeListview();
Expand All @@ -190,6 +205,9 @@ public MainDialog()

this.bInUpdate = false;

LoadSolutionData();

this.solutionGroups.Items.OnChanged += SolutionData_OnChanged;
UpdateList();
}
/// <summary>
Expand Down Expand Up @@ -246,6 +264,8 @@ private void MainDialog_FormClosing(object sender, FormClosingEventArgs e)

// don't forget to save the settings
Properties.Settings.Default.Save();

SaveSolutionData();
}

/// <summary>
Expand Down Expand Up @@ -1196,8 +1216,28 @@ private void UpdateList()
{
// TODO: must verify items before loading, indicate missing items through warning icon
this.olvFiles.SetObjects(this.solutionGroups.Items);

IterateAndExpandItems();
// this.olvFiles.ExpandAll();
}

private void IterateAndExpandItems()
{
foreach (var item in this.olvFiles.Objects)
{
if (item is VsFolder folder)
{
if (folder.Expanded)
{
this.olvFiles.Expand(item);
}
else
{
this.olvFiles.Collapse(item);
}
}
}
}
#endregion

#region Main VS Execution Buttons handling
Expand Down

0 comments on commit dfdd5f4

Please sign in to comment.