Exemplo n.º 1
0
        public void ControlAssociationChanged(Shift shift, ClawControl control, Command command)
        {
            if (cbMode.SelectedItem == null)
            {
                return;
            }

            if (!((ComboBoxItem)cbMode.SelectedItem).Tag.Equals(shift))
            {
                return;
            }

            foreach (ListBoxItem item in lbControls.Items)
            {
                AssignmentListBoxItemContent content = (AssignmentListBoxItemContent)item.Content;
                if (content.Control.Equals(control))
                {
                    content.Command = command;
                }
            }

            if (((AssignmentListBoxItemContent)(((ListBoxItem)lbControls.SelectedItem).Content)).Control.Equals(control))
            {
                OnSelectedControlChanged(lbControls, null);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates the content for an item that shall be inserted into the Control, Command listbox.
        /// </summary>
        /// <param name="control">The control.</param>
        /// <param name="assignment">The assignment for the control.</param>
        /// <returns>The created AssignmentListBoxItemContent.</returns>
        private AssignmentListBoxItemContent CreateContent(ClawControl control, Assignment assignment)
        {
            if (assignment == null)
            {
                return(new AssignmentListBoxItemContent(control, null));
            }

            ButtonAssignment buttonAssignment = assignment as ButtonAssignment;

            if (buttonAssignment == null)
            {
                throw new InvalidOperationException("An assignment to a ButtonControl is not allowed to be something else than a ButtonAssignment! Got: " + assignment.GetType());
            }

            if (buttonAssignment.Bands.Count == 0)
            {
                return(new AssignmentListBoxItemContent(control, null));
            }

            // Currently there is alway only one node bound so looking at the first item is sufficient.
            Band    band    = buttonAssignment.Bands.First();
            Command command = activeProfile.Commands.GetCommandForBand(band);

            return(new AssignmentListBoxItemContent(control, command));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Event handler for the selection changed event of the assigned command combobox.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event arguments.</param>
        private void OnAssignedCommandChanged(object sender, SelectionChangedEventArgs e)
        {
            if (blockChangeEvent)
            {
                return;
            }

            if (lbControls.SelectedItem == null)
            {
                return;
            }

            if (cbMode.SelectedItem == null)
            {
                return;
            }

            object      tag      = ((ComboBoxItem)cbAssigned.SelectedItem).Tag;
            Command     selected = tag == null ? null : (Command)tag;
            ClawControl control  = ((AssignmentListBoxItemContent)((ListBoxItem)lbControls.SelectedItem).Content).Control;
            Shift       shift    = (Shift)((ListBoxItem)cbMode.SelectedItem).Tag;

            presenter.OnAssociateCommandRequested(shift, control, selected);
        }