コード例 #1
0
        /// <summary>
        /// Load parameter of a product when its button is clicked
        /// </summary>
        private void OnButtonClick(object sender, EventArgs e)
        {
            ParamButton button = sender as ParamButton;

            txtSaveName.Text = button.ProductParams.prodName;

            foreach (ParamButton btn in flowProductButtons.Controls)
            {
                btn.UseVisualStyleBackColor = true;
            }
            button.UseVisualStyleBackColor = false;

            try
            {
                loadParamOnIndexChange = false;
                this.ProductParams     = button.ProductParams;
                paramsToControls();
                loadParamOnIndexChange      = true;
                cbxOutletSide.SelectedIndex = button.parameter;
            }
            catch
            {
                filesystem.deleteFile(button.id);
                flowProductButtons.Controls.Remove(button);
            }
        }
コード例 #2
0
 public ParamButton(ProductParameter_t param, EventHandler handler, string name, string _id)
 {
     this.Width             = 100;
     this.Height            = 30;
     ProductParams          = param;
     ProductParams.prodName = name;
     this.Click            += new EventHandler(handler);
     this.Text      = name;
     this.BackColor = Color.FromKnownColor(KnownColor.Control);
     this.UseVisualStyleBackColor = true;
     this.id = _id;
 }
コード例 #3
0
        public CommandForm(ref ProductParameter_t[] defaultProducts, SerialComm.Packet_t p)
        {
            InitializeComponent();
            packet = p;
            defaultProductParams = defaultProducts;

            // load saved products
            files = filesystem.loadFromFiles();
            for (int i = 0; i < files.Length; i++)
            {
                if (files[i].id != null)
                {
                    files[i] = CompleteDataOfFile(files[i]);
                    nmbrOfCustomButtons++;
                    ParamButton dpb = new ParamButton(new ProductParameter_t(files[i].packet), OnButtonClick, files[i].name, files[i].id);
                    dpb.parameter = files[i].packet.message.parameter;
                    flowProductButtons.Controls.Add(dpb);
                }
            }

            // if there are no saved products load the default ones
            if (flowProductButtons.Controls.Count == 0)
            {
                ParamButton Espresso    = new ParamButton(defaultProductParams[(byte)ProductType_t.Espresso_e], OnButtonClick, "Espresso", "defEsp");
                ParamButton Coffee      = new ParamButton(defaultProductParams[(byte)ProductType_t.Coffee_e], OnButtonClick, "Coffee", "defCof");
                ParamButton Cappuccino  = new ParamButton(defaultProductParams[(byte)ProductType_t.Cappuccino_e], OnButtonClick, "Cappuccino", "defCap");
                ParamButton Americano   = new ParamButton(defaultProductParams[(byte)ProductType_t.Americano_e], OnButtonClick, "Americano", "defAmericano");
                ParamButton AutoSteam   = new ParamButton(defaultProductParams[(byte)ProductType_t.AutoSteam_e], OnButtonClick, "Auto steam", "defAutoSteam");
                ParamButton HotWater    = new ParamButton(defaultProductParams[(byte)ProductType_t.HotWater_e], OnButtonClick, "Hot water", "defHotWater");
                ParamButton Everfoam    = new ParamButton(defaultProductParams[(byte)ProductType_t.Everfoam_e], OnButtonClick, "Everfoam", "defEFoam");
                ParamButton Milk        = new ParamButton(defaultProductParams[(byte)ProductType_t.Milk_e], OnButtonClick, "Milk", "defMilk");
                ParamButton MilkFoam    = new ParamButton(defaultProductParams[(byte)ProductType_t.MilkFoam_e], OnButtonClick, "Milk foam", "defMilkFoam");
                ParamButton ManualSteam = new ParamButton(defaultProductParams[(byte)ProductType_t.ManualSteam_e], OnButtonClick, "Manual steam", "defManSteam");

                flowProductButtons.Controls.Add(Espresso);
                flowProductButtons.Controls.Add(Coffee);
                flowProductButtons.Controls.Add(Cappuccino);
                flowProductButtons.Controls.Add(Americano);
                flowProductButtons.Controls.Add(AutoSteam);
                flowProductButtons.Controls.Add(Everfoam);
                flowProductButtons.Controls.Add(Milk);
                flowProductButtons.Controls.Add(MilkFoam);
                flowProductButtons.Controls.Add(ManualSteam);
            }

            // select Espresso as default
            cbxOutletSide.SelectedIndex = 0;
            this.ProductParams          = defaultProductParams[(byte)ProductType_t.Espresso_e];
            paramsToControls();
        }
コード例 #4
0
        /// <summary>
        /// If singe changes to double or reversed, change the controls to the correct default values
        /// </summary>
        private void cbxSingleDouble_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (loadParamOnIndexChange)
            {
                if (cbxSingleDouble.SelectedIndex == 1)
                {
                    ProductParams = defaultProductParams[cbxProductType.SelectedIndex + 1 + (int)ProductType_t.Max_e];
                }
                else
                {
                    ProductParams = defaultProductParams[cbxProductType.SelectedIndex + 1];
                }

                paramsToControls();
            }
        }