Beispiel #1
0
        public KeymapOutputItem(KeymapOutput output)
        {
            InitializeComponent();
            this.output      = output;
            this.tbName.Text = output.Name;

            this.border.Background = new SolidColorBrush(KeymapColors.GetColor(output.Type));
            //this.adorner.Visibility = Visibility.Hidden;
        }
Beispiel #2
0
        public void SetConfig(KeymapOutConfig config)
        {
            this.config = config;
            //this.connection_output_name.Text = config.Output.Name;
            this.connection_output_stack.Children.Clear();

            for (int i = 0; i < config.Stack.Count; i++)
            {
                KeymapOutput     output = config.Stack[i];
                KeymapOutputItem item   = new KeymapOutputItem(output);
                item.AllowDrop    = true;
                item.OnDragStart += item_OnDragStart;
                item.OnDragStop  += item_OnDragStop;
                item.Drop        += output_Drop;
                item.DragEnter   += output_DragEnter;
                item.DragLeave   += output_DragLeave;
                item.Tag          = i;
                this.connection_output_stack.Children.Add(item);
            }

            if (config.Inherited)
            {
                this.connection_output_stack.Opacity = 0.6;
                this.rAdd.Visibility   = Visibility.Hidden;
                this.rClear.Visibility = Visibility.Hidden;
            }
            else
            {
                this.connection_output_stack.Opacity = 1.0;
                this.rAdd.Visibility   = Visibility.Visible;
                this.rClear.Visibility = Visibility.Visible;
            }

            /*
             * if (config.Inherited)
             * {
             *  Color color = KeymapColors.GetColor(config.Output.Type);
             *  color.A = 60;
             *  this.connection_output_border.Background = new SolidColorBrush(color);
             *  this.rClear.Visibility = Visibility.Hidden;
             * }
             * else
             * {
             *  this.connection_output_border.Background = new SolidColorBrush(KeymapColors.GetColor(config.Output.Type));
             *  this.rClear.Visibility = Visibility.Visible;
             * }
             */
            /*if (fromDefault)
             * {
             *  this.rClear.Visibility = Visibility.Hidden;
             * }*/

            if (OnConfigChanged != null)
            {
                OnConfigChanged(this.input, this.config);
            }
        }
Beispiel #3
0
        public KeymapOutputRow(KeymapOutput output)
        {
            InitializeComponent();

            KeymapOutputItem item = new KeymapOutputItem(output);

            item.OnDragStart += item_OnDragStart;
            item.OnDragStop  += item_OnDragStop;

            this.mainGrid.Children.Add(item);
        }
Beispiel #4
0
 private void output_Drop(object sender, DragEventArgs e)
 {
     if (!this.connection_output_stack.Children.Contains(((KeymapOutputItem)e.Data.GetData("KeymapOutputItem"))))
     {
         if (e.Data.GetDataPresent("KeymapOutput"))
         {
             KeymapOutput newOutput = (KeymapOutput)e.Data.GetData("KeymapOutput");
             if (this.input.canHandle(newOutput))
             {
                 if (this.config.Inherited)
                 {
                     this.SetConfig(new KeymapOutConfig(newOutput, false));
                 }
                 else
                 {
                     if (sender is FrameworkElement && (sender as FrameworkElement).Tag is int)
                     {
                         this.config.Stack[(int)(sender as FrameworkElement).Tag] = newOutput;
                         this.config.Inherited = false;
                         this.SetConfig(this.config);
                     }
                 }
             }
             if (e.Data.GetDataPresent("KeymapOutputItem"))
             {
                 ((KeymapOutputItem)e.Data.GetData("KeymapOutputItem")).DropDone();
             }
         }
         else
         {
             if (e.Data.GetDataPresent("KeymapOutputItem"))
             {
                 ((KeymapOutputItem)e.Data.GetData("KeymapOutputItem")).DropDone();
             }
         }
     }
 }
Beispiel #5
0
 private void output_DragEnter(object sender, DragEventArgs e)
 {
     if (!this.connection_output_stack.Children.Contains(((KeymapOutputItem)e.Data.GetData("KeymapOutputItem"))))
     {
         if (e.Data.GetDataPresent("KeymapOutput"))
         {
             KeymapOutput newOutput = (KeymapOutput)e.Data.GetData("KeymapOutput");
             if (this.input.canHandle(newOutput))
             {
                 if (e.Data.GetDataPresent("KeymapOutputItem"))
                 {
                     UIElement target;
                     if (this.config.Inherited)
                     {
                         target = this.connection_output_stack;
                     }
                     else
                     {
                         target = sender as UIElement;
                     }
                     ((KeymapOutputItem)e.Data.GetData("KeymapOutputItem")).DropAccepted(target);
                 }
             }
             else
             {
                 if (e.Data.GetDataPresent("KeymapOutputItem"))
                 {
                     if (!this.connection_output_stack.Children.Contains(((KeymapOutputItem)e.Data.GetData("KeymapOutputItem"))))
                     {
                         ((KeymapOutputItem)e.Data.GetData("KeymapOutputItem")).DropRejected();
                     }
                 }
             }
         }
     }
 }
Beispiel #6
0
 public bool canStack(KeymapOutput other)
 {
     return(this.Stackable && other.Stackable);
 }
Beispiel #7
0
 public bool canHandle(KeymapOutput output)
 {
     return(((this.Button == output.Button || this.Continous == output.Continous) && this.Cursor == output.Cursor) || output.Type == KeymapOutputType.DISABLE);
 }
Beispiel #8
0
 public void addOutput(KeymapOutput output)
 {
     this.Stack.Add(output);
 }
Beispiel #9
0
 public KeymapOutConfig(KeymapOutput output, bool inherited)
 {
     this.Stack = new List <KeymapOutput>();
     this.Stack.Add(output);
     this.Inherited = inherited;
 }