Skip to content

Commit

Permalink
#14 fixed
Browse files Browse the repository at this point in the history
#16 fixed
added and updated some doc images
  • Loading branch information
Hefaistos68 committed Oct 2, 2023
1 parent 4c7917a commit 21930cb
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 38 deletions.
11 changes: 6 additions & 5 deletions VSLXshared/DataModel/VisualStudioInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ private ProcessStartInfo BuildStartInfo(bool bAdmin = false, bool bShowSplash =
else
si.UseShellExecute = false;

BuildVisualStudioCommandline(bShowSplash, instance, command, projectOrSolution).ForEach(x => si.ArgumentList.Add(x));
var args = BuildVisualStudioCommandline(bShowSplash, instance, command, projectOrSolution); //.ForEach(x => si.ArgumentList.Add(x));
si.Arguments = string.Join(' ', args);

return si;
}
Expand All @@ -233,9 +234,9 @@ private List<string> BuildVisualStudioCommandline(bool bShowSplash = false, stri
{
List<string> list = new();

if(!string.IsNullOrEmpty(projectOrSolution))
if (!string.IsNullOrEmpty(instance))
{
list.Add(projectOrSolution);
list.Add($"/rootSuffix {instance}");
}

if (bShowSplash == false)
Expand All @@ -249,9 +250,9 @@ private List<string> BuildVisualStudioCommandline(bool bShowSplash = false, stri
list.Add(command);
}

if (!string.IsNullOrEmpty(instance))
if (!string.IsNullOrEmpty(projectOrSolution))
{
list.Add($"/rootSuffix {instance}");
list.Add($"\"{projectOrSolution}\"");
}

return list;
Expand Down
87 changes: 54 additions & 33 deletions VSLauncherX/Forms/dlgExecuteVisualStudio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ public partial class dlgExecuteVisualStudio : Form
public dlgExecuteVisualStudio(int index)
{
InitializeComponent();
this.cbxVisualStudioVersion.SelectedIndex = index; // that is always the same as in the main dialog

this.cbxVisualStudioVersion.SelectedIndex = 1 + index; // that is always the same as in the main dialog, but main has no default item

this.Item = new VsItem();
this.bIsListItem = false;
}

/// <summary>
Expand All @@ -41,8 +44,7 @@ public dlgExecuteVisualStudio(object item)
InitializeComponent();

this.Item = (VsItem)item;

SetupMultiMonitor();
this.bIsListItem = true;
}

/// <summary>
Expand All @@ -59,14 +61,15 @@ private void SetupMultiMonitor()
this.cbxMonitors.SelectedIndex = 0;

this.cbxMonitors.Enabled = monitors.Length > 1;
this.btnPingMonitor.Enabled = monitors.Length > 1;
}

/// <summary>
/// Updates the controls from data.
/// </summary>
private void UpdateControlsFromData()
{
if (this.Item is not null)
if (this.bIsListItem && this.Item is not null)
{
this.txtName.Text = this.Item.Name;
this.cbxVisualStudioVersion.SelectFromVersion(this.Item.VsVersion);
Expand All @@ -84,6 +87,9 @@ private void UpdateControlsFromData()
/// </summary>
public VisualStudioInstance VsVersion { get; private set; }

/// <summary>
/// Gets or sets the item.
/// </summary>
public VsItem? Item
{
get
Expand All @@ -97,6 +103,11 @@ public VsItem? Item
}
}

/// <summary>
/// Used internally to indicate that no list item is being executed, rather an arbitrary VS command is executed
/// </summary>
private readonly bool bIsListItem;

/// <summary>
/// Handles text changes
/// </summary>
Expand Down Expand Up @@ -244,7 +255,7 @@ private void btnBeforeAfter_Click(object sender, EventArgs e)

if (dlg.ShowDialog() == DialogResult.OK)
{

// the item is already updated
}
}

Expand All @@ -255,7 +266,7 @@ private void btnBeforeAfter_Click(object sender, EventArgs e)
/// <param name="e">The e.</param>
private void txtFoldername_TextChanged(object sender, EventArgs e)
{
btnBeforeAfter.Enabled = !string.IsNullOrWhiteSpace(txtFoldername.Text);
btnBeforeAfter.Enabled = this.bIsListItem ? !string.IsNullOrWhiteSpace(txtFoldername.Text) : false;
}

/// <summary>
Expand All @@ -273,40 +284,53 @@ private void dlgExecuteVisualStudio_Load(object sender, EventArgs e)
this.btnOk.Text = this.btnOk.Tag as string;
}

if (this.Item is VsProject p)
if (this.bIsListItem)
{
if (p.VsVersion == null)
if (this.Item is VsProject p)
{
version = p.GetRequiredVersion();
this.cbxVisualStudioVersion.SelectFromVersion(version);
if (p.VsVersion == null)
{
version = p.GetRequiredVersion();
this.cbxVisualStudioVersion.SelectFromVersion(version);
}
else
{
this.cbxVisualStudioVersion.SelectDefault();
}
}
else
else if (this.Item is VsSolution s)
{
this.cbxVisualStudioVersion.SelectDefault();
if (s.RequiredVersion == null)
{
version = s.GetRequiredVersion();
this.cbxVisualStudioVersion.SelectFromVersion(version);
}
// the required version can also be "", then it was set to be default instead of specific
else
{
this.cbxVisualStudioVersion.SelectDefault();
}
}
}
else if (this.Item is VsSolution s)
{
if(s.RequiredVersion == null)
else if (this.Item is VsFolder f)
{
// this.cbxVisualStudioVersion.Enabled = false;
this.cbxInstance.Enabled = false;
this.txtFoldername.Focus();
}
else if (this.Item is VsItem vsi && vsi.ItemType == ItemTypeEnum.Other)
{
version = s.GetRequiredVersion();
this.cbxVisualStudioVersion.SelectFromVersion(version);
}
// the required version can also be "", then it was set to be default instead of specific
else
{
this.cbxVisualStudioVersion.SelectDefault();
throw new ArgumentException("Unknown type of item");
}
}
else if (this.Item is VsFolder f)
{
// this.cbxVisualStudioVersion.Enabled = false;
this.cbxInstance.Enabled = false;
this.txtFoldername.Focus();
}
else
{
throw new ArgumentException("Unknown type of item");
txtName.Enabled = false;
btnOk.Text = "&Start";
txtFoldername.Focus();
txtFoldername.Select();
}

if (this.cbxVisualStudioVersion.SelectedIndex == -1)
Expand All @@ -320,11 +344,8 @@ private void dlgExecuteVisualStudio_Load(object sender, EventArgs e)
this.txtInfo.Text = $"VS {version} not found";
}
}
else
{

}

SetupMultiMonitor();
UpdateControlsFromData();
}

Expand All @@ -337,7 +358,7 @@ private void dlgExecuteVisualStudio_Load(object sender, EventArgs e)
static extern IntPtr GetDC(IntPtr hwnd);

/// <summary>
/// Releases the d c.
/// Releases a DC
/// </summary>
/// <param name="hwnd">The hwnd.</param>
/// <param name="dc">The dc.</param>
Expand All @@ -346,7 +367,7 @@ private void dlgExecuteVisualStudio_Load(object sender, EventArgs e)
static extern int ReleaseDC(IntPtr hwnd, IntPtr dc);

/// <summary>
/// btns the ping monitor_ click.
/// Handles the btnPingMonitor button click
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The e.</param>
Expand Down
Binary file modified docs/MainScreen-sample.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/VS-version-selector.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 21930cb

Please sign in to comment.