Octgn.Play.Gui.CardControl.OnPreviewMouseLeftButtonDown C# (CSharp) Method

OnPreviewMouseLeftButtonDown() protected method

protected OnPreviewMouseLeftButtonDown ( System.Windows.Input.MouseButtonEventArgs e ) : void
e System.Windows.Input.MouseButtonEventArgs
return void
        protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            base.OnPreviewMouseLeftButtonDown(e);
            if (Card == null)
            {
                return;
            }

            // Clear or modify selection
            if ((Keyboard.Modifiers & ModifierKeys.Control) != 0)
            {
                if (Program.GameEngine == null || Program.GameEngine.Table == null)
                {
                    return;
                }

                // Add/Remove from selection (currently only on table and hand)
                if (Card.Group == Program.GameEngine.Table || Card.Group is Hand)
                {
                    if (Card.Anchored == false)
                    {
                        if (Card.Selected)
                        {
                            mouseClickHandler.AutoFireNext();
                            Selection.Remove(Card);
                        }
                        else if (Card.Controller == Player.LocalPlayer)
                        {
                            mouseClickHandler.AutoFireNext();
                            Selection.Add(Card);
                        }
                    }
                }

                e.Handled = true;
            }
            else
            {
                if (!Card.Selected)
                {
                    Selection.Clear();
                }
            }

            // Targetting is always allowed
            if (Keyboard.Modifiers == ModifierKeys.Shift && img.IsMouseDirectlyOver)
            {
                mouseClickHandler.AutoFireNext();
                return;
            }

            // otherwise check controlship
            if (!Card.TryToManipulate())
            {
                //e.Handled = true;
            }
        }