private void RefreshSize() { this.TextBelt.Top = 15; // 15 this.TextBelt.Left = 5; // 5 this.TextBelt.AutoSize = true; this.TextAssembler.Top = 55; // 55 this.TextAssembler.Left = 5; // 5 this.TextAssembler.AutoSize = true; int StartLeft = 70; // 70 Size buttonsize = new Size(40, 40); // 40 40 int actualleft = StartLeft; foreach (Button b in this.listButtonBelt) { MOType mt = (MOType)(((object[])(b.Tag))[0]); FOType ft = (FOType)(((object[])(b.Tag))[1]); b.Left = actualleft; b.Top = 1; b.Size = buttonsize; //back color //// couleur d'arrière plan b.BackColor = Color.Gainsboro; bool isbelt = Utilz.IsBeltable(ft); if (!isbelt) { b.BackColor = Color.Crimson; } //next iteration actualleft += b.Width + 1; } actualleft = StartLeft; foreach (Button b in this.listButtonMachine) { MOType mt = (MOType)(((object[])(b.Tag))[0]); FOType ft = (FOType)(((object[])(b.Tag))[1]); b.Left = actualleft; b.Top = 1 + buttonsize.Height + 2; b.Size = buttonsize; //back color //// couleur d'arrière plan b.BackColor = Color.Gainsboro; bool ismachine = Utilz.IsRecipe(ft); if (!ismachine) { b.BackColor = Color.Crimson; } //next iteration actualleft += b.Width + 1; } }
private void AnyButton_MosueDown(object sender, MouseEventArgs e) { Button btn = (Button)sender; btn.Focus(); MOType mt = (MOType)(((object[])(btn.Tag))[0]); FOType ft = (FOType)(((object[])(btn.Tag))[1]); if (e.Button == MouseButtons.Left) { if (mt == MOType.Belt) { if (Utilz.IsBeltable(ft)) //we set addmode only if the item can be a belt { MapObject newmo = new MapObject(mt, ft); this.Editer.StartAddMode(newmo); } } if (mt == MOType.Machine) //we set addmode only if the item can be a machine { if (Utilz.IsRecipe(ft)) { MapObject newmo = new MapObject(mt, ft); this.Editer.StartAddMode(newmo); } } } if (e.Button == MouseButtons.Right) { FOType[] arrayOutputs = Utilz.GetRecipeOutputs(ft); FOType[] arrayInputs = Utilz.GetRecipeInputs(ft); oRightClick3 rc = new oRightClick3(); //rc.Width = 200; rc.AddChoice(ft.ToString()); rc.AddSeparator(); rc.AddSeparator(); //add every outputs and inputs for the user rc.AddChoice("Outputs :"); foreach (FOType subft in arrayOutputs) { rc.AddChoice("-" + subft.ToString()); } rc.AddChoice(""); rc.AddChoice("Inputs :"); foreach (FOType subft in arrayInputs) { rc.AddChoice("-" + subft.ToString()); } rc.ShowDialog(); } }