public ControlBox() { instance = this; InitializeComponent(); formTitle = AssemblyTitle + " Configuration"; //Add XML servers config = XmlHandler.Deserialize(); //not interfering with anything the server might use. for (int i = 0; i < config.ServerList.Count; i++) { // Read from config and fill in the provided info int outerHeight = GBServer.outerHeight; //20 + (GBServer.innerHeight * 4) + 40; int y = i * outerHeight; //outer y offset GBServer server = new GBServer(i, config.ServerList[i].Name, config.ServerList[i].FilePath, config.ServerList[i].AllowInput); server.SetLocation(0, y); ListServerBox.Add(server); ServerBox.Controls.Add(server.gbServer); } UpdateScrollHeight(); this.Text = MCDaemon.ControlBox.Instance.formTitle; toolTip1.SetToolTip(this.buttonAdd, "Add server"); toolTip1.SetToolTip(this.buttonApply, "Save config"); TbHost.Text = config.Host; NumPort.Value = config.Port; TbHost.TextChanged += GBServer.Config_Changed; NumPort.ValueChanged += GBServer.Config_Changed; }
public static void Swap(IList <GBServer> list, int indexA, int indexB) { GBServer tmp = list[indexA]; list[indexA] = list[indexB]; list[indexB] = tmp; }
private void buttonAdd_Click(object sender, EventArgs e) { GBServer server = new GBServer(ListServerBox.Count, "", ""); server.SetNumberLocation(ListServerBox.Count); ListServerBox.Add(server); ServerBox.Controls.Add(server.gbServer); UpdateScrollHeight(); GBServer.gbServer_change(); }
private void gbServer_MouseMove(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { //gbServer.Left = e.X + gbServer.Left - mouseDownLocation.X; gbServer.Top = e.Y + gbServer.Top - mouseDownLocation.Y; //pos is gbServer.Top /outer height, where Min and Max is to prevent out of bound error int pos = GetPosition(); if (pos != serverNumber) { GBServer gs = MCDaemon.ControlBox.Instance.ListServerBox[pos]; Swap(MCDaemon.ControlBox.Instance.ListServerBox, pos, serverNumber); gs.SetNumberLocation(serverNumber); this.SetNumber(pos); gbServer_change(); MCDaemon.ControlBox.Instance.Refresh(); } } }