GetDescendantByName() 공개 정적인 메소드

public static GetDescendantByName ( FrameworkElement element, string name ) : Visual
element System.Windows.FrameworkElement
name string
리턴 Visual
예제 #1
0
        private void gamePad_ButtonPressed(object sender, EventArgs e)
        {
            Action callback = null;
            Action action2  = null;

            if (this.ActiveGame != null)
            {
                int num = (int)sender;
                if (num == Settings.Default.buttonOk)
                {
                    if (callback == null)
                    {
                        callback = delegate {
                            ListBoxItem element          = (ListBoxItem)this.lbGames.ItemContainerGenerator.ContainerFromItem(this.ActiveGame);
                            Image       descendantByName = (Image)Tools.GetDescendantByName(element, "btnPlay");
                            Image       image2           = (Image)Tools.GetDescendantByName(element, "btnInfo");
                            if (!this.gameSelected)
                            {
                                this.gameSelected    = true;
                                element.Tag          = "info";
                                descendantByName.Tag = "null";
                                image2.Tag           = "null";
                            }
                            else if (descendantByName.Tag.ToString() == "selected")
                            {
                                this.LaunchGame();
                            }
                            else if (image2.Tag.ToString() == "selected")
                            {
                                this.ShowInfo();
                            }
                        };
                    }
                    base.Dispatcher.Invoke(callback);
                }
                else if (num == Settings.Default.buttonCancel)
                {
                    if (action2 == null)
                    {
                        action2 = delegate {
                            ListBoxItem element          = (ListBoxItem)this.lbGames.ItemContainerGenerator.ContainerFromItem(this.ActiveGame);
                            Image       descendantByName = (Image)Tools.GetDescendantByName(element, "btnPlay");
                            Image       image2           = (Image)Tools.GetDescendantByName(element, "btnInfo");
                            if (this.gameSelected && !this.infoVisible)
                            {
                                descendantByName.RaiseEvent(this.MouseLeaveArgs());
                                image2.RaiseEvent(this.MouseLeaveArgs());
                                this.gameSelected = false;
                                element.Tag       = "null";
                            }
                            else if (this.gameSelected && this.infoVisible)
                            {
                                this.HideInfo();
                            }
                        };
                    }
                    base.Dispatcher.Invoke(action2);
                }
            }
        }
예제 #2
0
        private void gamePad_DirectionChanged(object sender, EventArgs e)
        {
            string dir = sender.ToString();

            base.Dispatcher.Invoke(delegate {
                if (this.gameSelected)
                {
                    ListBoxItem element    = (ListBoxItem)this.lbGames.ItemContainerGenerator.ContainerFromItem(this.ActiveGame);
                    Image descendantByName = (Image)Tools.GetDescendantByName(element, "btnPlay");
                    Image image2           = (Image)Tools.GetDescendantByName(element, "btnInfo");
                    if ((dir == "left") && !this.infoVisible)
                    {
                        descendantByName.Tag = "selected";
                        image2.Tag           = "null";
                        descendantByName.RaiseEvent(this.MouseEnterArgs());
                        image2.RaiseEvent(this.MouseLeaveArgs());
                    }
                    else if ((dir == "right") && !this.infoVisible)
                    {
                        image2.Tag           = "selected";
                        descendantByName.Tag = "null";
                        image2.RaiseEvent(this.MouseEnterArgs());
                        descendantByName.RaiseEvent(this.MouseLeaveArgs());
                    }
                    if (this.infoVisible)
                    {
                        if (dir == "up")
                        {
                            this.svDescription.LineUp();
                        }
                        else if (dir == "down")
                        {
                            this.svDescription.LineDown();
                        }
                    }
                }
                else
                {
                    switch (dir)
                    {
                    case "left":
                        this.NavigateItems(FocusNavigationDirection.Left);
                        break;

                    case "right":
                        this.NavigateItems(FocusNavigationDirection.Right);
                        break;

                    case "up":
                        this.NavigateItems(FocusNavigationDirection.Up);
                        break;

                    case "down":
                        this.NavigateItems(FocusNavigationDirection.Down);
                        break;
                    }
                }
            });
        }
예제 #3
0
        public void lbItemKeyDown(object sender, KeyEventArgs e)
        {
            ListBoxItem element = (ListBoxItem)this.lbGames.ItemContainerGenerator.ContainerFromItem(this.ActiveGame);

            if (this.gameSelected)
            {
                if (e.Key == Key.Left)
                {
                    Button descendantByName = (Button)Tools.GetDescendantByName(element, "btnPlay");
                }
                else if (e.Key == Key.Right)
                {
                    Button button2 = (Button)Tools.GetDescendantByName(element, "btnInfo");
                }
            }
            else if (e.Key == Key.Return)
            {
                this.gameSelected = true;
                element.Tag       = "info";
            }
        }