Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 33 additions & 7 deletions RemoteApplicationPublisher/RemoteAppEditWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,16 @@ public RemoteApp EditRemoteApp(RemoteApp selectedRemoteApp)
return RemoteApp;
}

public RemoteApp CreateRemoteApp(bool advanced = false)
public RemoteApp CreateRemoteApp()
{
Text = "New RemoteApp";
Size = MinimumSize;
HelpSystem.SetupTips(this);
CommandLineOptionCombo.SelectedIndex = 1;

if (advanced)
if (DoBrowsePath() == true)
{
ShowDialog();
}
else if (DoBrowsePath() == true)
{
SaveAndCloseOrWindow();
SaveAndEditWindow();
}

Dispose();
Expand Down Expand Up @@ -162,6 +158,36 @@ private void SaveButton_Click(object sender, EventArgs e)
SaveAndClose();
}

private void SaveAndEditWindow()
{
if (string.IsNullOrEmpty(ShortNameText.Text))
{
MessageBox.Show("Name must not be blank.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
else if (string.IsNullOrEmpty(FullNameText.Text))
{
MessageBox.Show("Full name must not be blank.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
else if (string.IsNullOrEmpty(PathText.Text))
{
MessageBox.Show("Path must not be blank.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
else if (!((ShortNameText.Text ?? "") == (RemoteApp.Name ?? "")) & DoesAppExist(ShortNameText.Text))
{
MessageBox.Show("A RemoteApp with the same name already exists.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
else if (Text == "New RemoteApp" & DoesAppExist(ShortNameText.Text))
{
MessageBox.Show("A RemoteApp with the same name already exists.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
else
{
SaveRemoteApp(ShortNameText.Text.Trim(), FullNameText.Text, PathText.Text, PathText.Text, CommandLineText.Text, CommandLineOptionCombo.SelectedIndex, PathText.Text, 0, 0);
Text = "Properties of " + FullNameText.Text;
ShowDialog();
}
}

private void SaveAndCloseOrWindow()
{
if (string.IsNullOrEmpty(ShortNameText.Text))
Expand Down
311 changes: 141 additions & 170 deletions RemoteApplicationPublisher/RemoteAppMainWindow.Designer.cs

Large diffs are not rendered by default.

184 changes: 109 additions & 75 deletions RemoteApplicationPublisher/RemoteAppMainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ public partial class RemoteAppMainWindow : Form
public RemoteAppMainWindow()
{
InitializeComponent();
this.dataGrid.ColumnCount = 3;
this.dataGrid.Columns[0].Name = "Application Name";
this.dataGrid.Columns[1].Name = "Path";
this.dataGrid.Columns[2].Name = "Command Line";

this.dataGrid.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
this.dataGrid.MultiSelect = false;
}

private void RemoteAppMainWindow_Disposed(object sender, EventArgs e)
Expand All @@ -32,114 +25,89 @@ private void RemoteAppMainWindow_Load(object sender, EventArgs e)
var sra = new SystemRemoteApps();
sra.Init();

Text = Application.ProductName + " " + Application.ProductVersion + " (" + System.Net.Dns.GetHostName() + ")";
Text = "Remote Application Publisher " + Application.ProductVersion + " (" + System.Net.Dns.GetHostName() + ")";
HelpSystem.SetupTips(this);
ReloadApps();
}


public void ReloadApps()
{
// AppList.Clear();
AppList.Items.Clear();

var systemApps = new SystemRemoteApps();
var apps = systemApps.GetAll();

this.dataGrid.Rows.Clear();

foreach (RemoteApp app in apps)
{
var columns = new string[3];
columns[0] = app.Name;
columns[1] = app.Path;
columns[2] = app.CommandLine;
this.dataGrid.Rows.Add(columns);
// SmallIcons.Images.RemoveByKey(app.Name);
// var iconBitmap = RemoteAppFunction.GetAppBitmap(app.Name);
// var appItem = new ListViewItem(app.Name);
// appItem.ToolTipText = app.FullName;
// appItem.ImageIndex = 0;
// SmallIcons.Images.Add(app.Name, iconBitmap);
// appItem.ImageKey = app.Name;
// AppList.Items.Add(appItem);
SmallIcons.Images.RemoveByKey(app.Name);
var iconBitmap = RemoteAppFunction.GetAppBitmap(app.Name);
var appItem = new ListViewItem(app.Name);
appItem.ToolTipText = app.FullName;
appItem.ImageIndex = 0;
SmallIcons.Images.Add(app.Name, iconBitmap);
appItem.ImageKey = app.Name;
appItem.SubItems.Add(app.FullName);
appItem.SubItems.Add("||"+app.Name);
appItem.SubItems.Add(app.CommandLine);
AppList.Items.Add(appItem);
}


if (apps.Count == 0)
{
NoAppsLabel.Visible = true;
buttonRemove.Enabled = false;
buttonEdit.Enabled = false;
}
else
{
this.dataGrid.ClearSelection();
NoAppsLabel.Visible = false;
buttonRemove.Enabled = false;
buttonEdit.Enabled = false;
}

// buttonRemove.Enabled = false;
// buttonEdit.Enabled = false;
buttonRemove.Enabled = false;
buttonEdit.Enabled = false;
}

//private void AppList_DoubleClick(object sender, EventArgs e)
//{
// if (AppList.SelectedItems.Count == 1)
// {
// EditRemoteApp(AppList.SelectedItems[0].Text);
// }
//}

string SelectedApplicationName;

private void dataGrid_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex >= 0)
{
DataGridViewRow row = this.dataGrid.Rows[e.RowIndex];
SelectedApplicationName = row.Cells["Application Name"].Value.ToString();
this.buttonEdit.Enabled = true;
this.buttonRemove.Enabled = true;
}

private void AppList_DoubleClick(object sender, EventArgs e)
{
if (AppList.SelectedItems.Count == 1)
{
EditRemoteApp(AppList.SelectedItems[0].Text);
}
}

//private void AppList_SelectedIndexChanged(object sender, EventArgs e)
//{
// if (AppList.SelectedItems.Count == 1)
// {
// buttonRemove.Enabled = true;
// buttonEdit.Enabled = true;
// }
// else
// {
// buttonRemove.Enabled = false;
// buttonEdit.Enabled = false;
// }
//}
private void AppList_SelectedIndexChanged(object sender, EventArgs e)
{
if (AppList.SelectedItems.Count == 1)
{
buttonRemove.Enabled = true;
buttonEdit.Enabled = true;
}
else
{
buttonRemove.Enabled = false;
buttonEdit.Enabled = false;
}
}

private void EditButton_Click(object sender, EventArgs e)
{
EditRemoteApp(this.SelectedApplicationName);

//if (AppList.SelectedItems.Count == 1)
//{
// EditRemoteApp(AppList.SelectedItems[0].Text);
//}
if (AppList.SelectedItems.Count == 1)
{
EditRemoteApp(AppList.SelectedItems[0].Text);
}
}

private void EditRemoteApp(string AppName)
{
var sra = new SystemRemoteApps();
var remoteAppEditWindow = new RemoteAppEditWindow(this);
remoteAppEditWindow.EditRemoteApp(sra.GetApp(AppName));
ReloadApps();
}

private void DeleteButton_Click(object sender, EventArgs e)
{
DeleteRemoteApp(this.SelectedApplicationName);
DeleteRemoteApp(AppList.SelectedItems[0].Text);
ReloadApps();
}

private void DeleteRemoteApp(string AppName)
Expand All @@ -149,7 +117,6 @@ private void DeleteRemoteApp(string AppName)
var sra = new SystemRemoteApps();
sra.DeleteApp(AppName);
}
ReloadApps();
}

private void CreateButton_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -180,7 +147,7 @@ private void ExitToolStripMenuItem_Click(object sender, EventArgs e)
private void NewRemoteAppadvancedToolStripMenuItem_Click(object sender, EventArgs e)
{
var remoteAppEditWindow = new RemoteAppEditWindow(this);
remoteAppEditWindow.CreateRemoteApp(true);
remoteAppEditWindow.CreateRemoteApp();
ReloadApps();
}

Expand All @@ -199,7 +166,74 @@ private void BackupAllRemoteAppsToolStripMenuItem_Click(object sender, EventArgs
Process.Start(StartInfo);
}

}
}

private void buttonSettingsMenu_Click(object sender, EventArgs e)
{
Point screenPoint = buttonSettingsMenu.PointToScreen(new Point(buttonSettingsMenu.Left, buttonSettingsMenu.Bottom));
if (screenPoint.Y + contextSettingsMenuStrip.Size.Height > Screen.PrimaryScreen.WorkingArea.Height) {
contextSettingsMenuStrip.Show(buttonSettingsMenu, new Point(0, -contextSettingsMenuStrip.Size.Height));
} else {
contextSettingsMenuStrip.Show(buttonSettingsMenu, new Point(0, buttonSettingsMenu.Height));
}
}

private void backupApplicationsToolStripMenuItem_Click(object sender, EventArgs e)
{
BackupSaveFileDialog.FileName = System.Net.Dns.GetHostName() + " RemoteApps Backup " + DateTime.Now.ToString("yyyy-MM-dd") + ".reg";
DialogResult = BackupSaveFileDialog.ShowDialog();

if (DialogResult == DialogResult.OK)
{
string RemoteAppRegPath = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Terminal Server\TSAppAllowList\Applications";
string BackupSavePath = BackupSaveFileDialog.FileName;

var StartInfo = new ProcessStartInfo("reg.exe", "export \"" + RemoteAppRegPath + "\" \"" + BackupSavePath + "\" /y");
StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(StartInfo);
}
}

private void aboutToolStripMenuItem1_Click(object sender, EventArgs e)
{
var remoteAppAboutWindow = new RemoteAppAboutWindow(this);
remoteAppAboutWindow.ShowDialog();
}

private void AppList_MouseClick(object sender, MouseEventArgs e)
{
// if (e.Button == MouseButtons.Right)
// {
// var item = AppList.HitTest(e.Location).Item;
// if (item != null)
// {
// AppList.FocusedItem = item;
// listViewContextMenuStrip.Show(AppList, e.Location);
// }
// }
}

private void copyToClipboardToolStripMenuItem_Click(object sender, EventArgs e)
{
if (AppList.FocusedItem != null)
{
var clipboardText = AppList.FocusedItem.Text;
Clipboard.SetText(clipboardText);
}
}

private void AppList_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
var hittest = AppList.HitTest(e.Location);
var item = AppList.HitTest(e.Location).Item;
if (item != null)
{
AppList.FocusedItem = item;
listViewContextMenuStrip.Show(AppList, e.Location);
}
}
}
}
}
Loading