Exemplo n.º 1
0
        private void OnFixtureButtonSelected(MagicGridButton button, MagicGridControl parentGridControl)
        {
            //_grid1.Buttons.Where(b => b != button).ToList().ForEach(b => b.Unselect());
            _grid2.ClearButtons();
            //_grid3.ClearButtons();
            //_grid4.ClearButtons();

            _grid2.Title = "Intensity";

            for (int i = 0; i <= 100; i=i+10)
            {
                _grid2.AddButton(i.ToString() + "%");
            }
        }
Exemplo n.º 2
0
 private void OnFixtureButtonUnselected(MagicGridButton button, MagicGridControl parentGridControl)
 {
 }
Exemplo n.º 3
0
 private void OnSfxButtonSelected(MagicGridButton button, MagicGridControl parentGridControl)
 {
     System.IO.FileInfo fInfo = button.ActionInfo;
     System.Media.SoundPlayer sp = new System.Media.SoundPlayer(fInfo.FullName);
     sp.Play();
     System.Threading.ThreadPool.QueueUserWorkItem(o =>
     {
         System.Threading.Thread.Sleep(1000);
         this.Dispatcher.Invoke(new Action(() => { button.Unselect(); }));
     });
 }
Exemplo n.º 4
0
 private void OnChildButtonUnselected(MagicGridButton button, MagicGridControl parentGridControl)
 {
     if (ButtonUnselected != null) { ButtonUnselected(button, parentGridControl); }
 }
Exemplo n.º 5
0
        private void OnChildButtonSelected(MagicGridButton button, MagicGridControl parentGridControl)
        {
            if (ButtonSelected != null) { ButtonSelected(button, parentGridControl); }

            if (OnlyAllowSingleSelection)
            {
                foreach (var btn in Buttons)
                {
                    if (btn != button && btn.IsSelected) { btn.Unselect(true); }
                }
            }
        }
Exemplo n.º 6
0
        internal MagicGridButton AddButton(MagicGridButton button, int? gridSlotIndex)
        {
            if (_slotPlaceholders.Count == 0)
            {
                RecalculateGrid();
            }

            DLog("Adding button " + (button.Text ?? "(null title)"));
            button.ParentGridControl = this;

            button.ButtonSelected += OnChildButtonSelected;
            button.ButtonUnselected += OnChildButtonUnselected;

            string labelIndex = string.Empty;

            MagicGridButtonCanvasPlaceholder targetSlot = null;

            int highestIndex = 0;
            foreach (var slot in _slotPlaceholders.OrderBy(sp => sp.MagicGridSlotIndex))
            {
                if (slot.MagicGridSlotIndex > highestIndex)
                {
                    highestIndex = slot.MagicGridSlotIndex;
                }

                if (slot.Child == null)
                {
                    if (gridSlotIndex == null)
                    {
                        gridSlotIndex = slot.MagicGridSlotIndex;
                        targetSlot = slot;
                        break;
                    }
                }

                if (gridSlotIndex != null)
                {
                    if (slot.MagicGridSlotIndex == gridSlotIndex)
                    {
                        targetSlot = slot;
                    }
                }
            }

            if (targetSlot == null)
            {
                MagicGridButtonCanvasPlaceholder newPh = new MagicGridButtonCanvasPlaceholder() { MagicGridSlotIndex = highestIndex + 1 };
                _slotPlaceholders.Add(newPh);
                targetSlot = newPh;
                _queueResize = true;
            }

            targetSlot.Child = button;
            button.Width = double.NaN;
            button.Height = double.NaN;

            labelIndex = (targetSlot.MagicGridSlotIndex + 1).ToString();

            if (!ShowButtonIndexes)
            {
                labelIndex = string.Empty;
            }

            button.IndexLabelText = labelIndex.ToString();

            button.SelectedBackground = SelectedBackground;
            button.SelectedForeground = SelectedForeground;
            button.UnselectedBackground = UnselectedBackground;
            button.UnselectedForeground = UnselectedForeground;

            if (button.IsSelected)
            {
                button.Select(false);
            } else
            {
                button.Unselect(false);
            }

            //DLog("Button added");

            _buttons.Add(button);
            //_queueReloadButtons = true;
            //ReloadButtonsCanvas();
            return button;
        }
Exemplo n.º 7
0
 public MagicGridButton AddButton(MagicGridButton button)
 {
     return AddButton(button, null);
 }
Exemplo n.º 8
0
        public MagicGridButton AddButton(string text, int? gridSlotIndex)
        {
            var btn = new MagicGridButton() { Text = text };

            return AddButton(btn, gridSlotIndex);
        }