Example #1
0
        private void OnButtonClicked(object sender, RoutedEventArgs e)
        {
            ButtonSelector buttonSelector = new ButtonSelector();

            buttonSelector.SetFreeButtons(this.crate.free_buttons);
            if (buttonSelector.ShowDialog() == false)
            {
                return;
            }

            Button button = (Button)sender;
            string text   = (string)button.Content;

            if (text.ToLower().IndexOf("none") >= 0 && buttonSelector.selectedButton == null)
            {
                return;
            }
            int pin;

            int.TryParse(button.Name.Substring(3), out pin);
            if (text.ToLower().IndexOf("none") < 0)
            {
                CrateButton crateBut = this.crate.used_buttons.Find(but => but.name.Equals(text));
                this.crate.FreeButton(crateBut);
            }
            if (buttonSelector.selectedButton != null)
            {
                this.crate.Usebutton(buttonSelector.selectedButton, pin);
                button.Content = buttonSelector.selectedButton.name;
            }
            this.RenderLayout();
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button button = (Button)sender;
            string text   = (string)button.Content;

            if (text.ToLower().IndexOf("none") >= 0)
            {
                this.selectedButton = null;
            }
            else
            {
                this.selectedButton = buttons_list.Find(but => but.name.Equals(text));
            }
        }
Example #3
0
        private void OnMouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton != MouseButton.Middle || e.ButtonState != MouseButtonState.Pressed)
            {
                return;
            }
            Button button = (Button)sender;
            string text   = (string)button.Content;

            if (text.ToLower().IndexOf("none") >= 0)
            {
                return;
            }
            CrateButton usedBut = this.crate.used_buttons.Find(but => but.name.Equals(text));

            this.crate.FreeButton(usedBut);
            button.Content = "None";
        }
Example #4
0
 public bool Usebutton(CrateButton button, int pin)
 {
     if (button == null)
     {
         return(false);
     }
     if (!this.free_buttons.Contains(button))
     {
         return(false);
     }
     if (this.used_buttons.Contains(button))
     {
         return(false);
     }
     button.pin = pin;
     this.free_buttons.Remove(button);
     this.used_buttons.Add(button);
     return(true);
 }
Example #5
0
 public bool FreeButton(CrateButton button)
 {
     if (button == null)
     {
         return(false);
     }
     if (!used_buttons.Contains(button))
     {
         return(false);
     }
     if (free_buttons.Contains(button))
     {
         return(false);
     }
     button.pin = 0;
     used_buttons.Remove(button);
     free_buttons.Add(button);
     return(true);
 }
Example #6
0
        private void ButtonActivator_Click(object sender, RoutedEventArgs e)
        {
            ButtonSelector buttonSelector = new ButtonSelector();

            buttonSelector.SetFreeButtons(Crate.createCrateWithButtons().used_buttons);
            if (buttonSelector.ShowDialog() == false)
            {
                return;
            }
            CrateButton but = buttonSelector.selectedButton;

            if (but == null)
            {
                this.ButtonActivator.Content       = "None";
                this.current_Game_Config.activator = null;
                return;
            }
            this.ButtonActivator.Content       = but.name;
            this.current_Game_Config.activator = but;
        }