[go: up one dir, main page]

Menu

[r91]: / frmDisplayMUs.cs  Maximize  Restore  History

Download this file

126 lines (111 with data), 4.5 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace RDPManager
{
public partial class frmDisplayMUs : Form
{
public frmDisplayMUs()
{
InitializeComponent();
#if DEBUG
this.Text = this.Text + " *";
#endif
}
private void DisplayMUs_Load(object sender, EventArgs e)
{
LoadListBox();
}
private void btnClose_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
Close();
}
private void btnClear_Click(object sender, EventArgs e)
{
if (lbMUs.SelectedIndex == -1) return;
String selMachName = (String)lbMUs.SelectedItem;
selMachName = selMachName.Substring(selMachName.IndexOf('\t') + 1);
var MUkeys = from MUKey in RdpManager.MostedUsedMachines orderby MUKey.Value descending select new KeyValuePair<Int32, Int32>(MUKey.Key, MUKey.Value);
foreach (KeyValuePair<Int32, Int32> kvp in MUkeys)
{
if (RdpManager.Machines.ContainsKey(kvp.Key) && RdpManager.Machines[kvp.Key].DisplayName == selMachName)
{
RdpManager.MostedUsedMachines.Remove(kvp.Key);
RdpManager.SaveMU();
RdpManager.reloadConfig();
LoadListBox();
break;
}
}
}
private void btnClearAll_Click(object sender, EventArgs e)
{
RdpManager.MostedUsedMachines.Clear();
RdpManager.SaveMU();
RdpManager.reloadConfig();
lbMUs.Items.Clear();
}
private void LoadListBox()
{
lbMUs.Items.Clear();
var MUkeys = from MUKey in RdpManager.MostedUsedMachines orderby MUKey.Value descending select new KeyValuePair<Int32, Int32>(MUKey.Key, MUKey.Value);
foreach (KeyValuePair<Int32, Int32> kvp in MUkeys)
{
// if machine in MU is not in the main machine list, delete it from list. This can happen from removing or changing an entry.
if (RdpManager.Machines.ContainsKey(kvp.Key))
{
lbMUs.Items.Add(String.Format(" {0}\t{1}", RdpManager.MostedUsedMachines[kvp.Key], RdpManager.Machines[kvp.Key].DisplayName));
}
#if DEBUG
else
{
lbMUs.Items.Add(String.Format("{0}\tKey: {1}", RdpManager.MostedUsedMachines[kvp.Key], kvp.Key));
}
#endif
}
}
private void btnEdit_Click(object sender, EventArgs e)
{
EditSelectedEntry();
}
private void lbMUs_MouseDoubleClick(object sender, MouseEventArgs e)
{
EditSelectedEntry();
}
private void EditSelectedEntry()
{
if (lbMUs.SelectedIndex == -1) return;
String selMachName = (String)lbMUs.SelectedItem;
selMachName = selMachName.Substring(selMachName.IndexOf('\t') + 1);
foreach (KeyValuePair<Int32, Int32> kvp in RdpManager.MostedUsedMachines)
{
if (RdpManager.Machines[kvp.Key].DisplayName == selMachName)
{
frmEditConnectionCount dlgConnCount = new frmEditConnectionCount();
dlgConnCount.txtMach.Text = selMachName;
dlgConnCount.txtCount.Text = kvp.Value.ToString();
dlgConnCount.ShowDialog();
int count = System.Convert.ToInt32(dlgConnCount.txtCount.Text);
if (count == 0)
{
RdpManager.MostedUsedMachines.Remove(kvp.Key);
}
else
{
RdpManager.MostedUsedMachines[kvp.Key] = System.Convert.ToInt32(dlgConnCount.txtCount.Text);
}
RdpManager.SaveMU();
RdpManager.reloadConfig();
LoadListBox();
break;
}
}
}
}
}