Beispiel #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);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Event handler for the selection changed event of the mode combobox.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event arguments.</param>
        private void OnSelectedModeChanged(object sender, SelectionChangedEventArgs e)
        {
            lbControls.Items.Clear();

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

            Shift shift = (Shift)((ComboBoxItem)cbMode.SelectedItem).Tag;

            Controller controller = activeProfile.Controllers.GetControllerByIdentifier((Guid)((ComboBoxItem)cbDevice.SelectedItem).Tag);

            foreach (ClawControl control in controller.Controls)
            {
                if (!(control is ButtonControl))
                {
                    continue;
                }

                Assignment assignment = shift.Assignments.GetAssignmentForControl(control);
                AssignmentListBoxItemContent content = CreateContent(control, assignment);

                var item = new ListBoxItem();
                item.Content = content;
                lbControls.Items.Add(item);
            }

            lbControls.Items.SortDescriptions.Clear();
            lbControls.Items.SortDescriptions.Add(new SortDescription("Content", ListSortDirection.Ascending));
        }
Beispiel #3
0
        public void CommandNameChanged(Command command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

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

            OnSelectedControlChanged(lbControls, null);
        }
Beispiel #4
0
        private void OnSelectedControlChanged(object sender, SelectionChangedEventArgs e)
        {
            blockChangeEvent = true;
            if (lbControls.SelectedItem == null)
            {
                cbAssigned.IsEnabled    = false;
                cbAssigned.SelectedItem = null;
                tbSelectedControl.Text  = (string)Application.Current.FindResource(CONTROL_TEXT);
                blockChangeEvent        = false;
                return;
            }

            cbAssigned.IsEnabled = true;

            AssignmentListBoxItemContent content = (AssignmentListBoxItemContent)((ListBoxItem)lbControls.SelectedItem).Content;

            tbSelectedControl.Text = (string)Application.Current.FindResource(CONTROL_TEXT) + " " + content.ControlName;
            if (content.Command == null)
            {
                // The index 0 is always the empty item.
                cbAssigned.SelectedIndex = 0;
                blockChangeEvent         = false;
                return;
            }

            foreach (ComboBoxItem item in cbAssigned.Items)
            {
                Command tag = (Command)item.Tag;
                if (content.Command.Equals(tag))
                {
                    cbAssigned.SelectedItem = item;
                    break;
                }
            }
            blockChangeEvent = false;
        }