Inheritance: System.Windows.Controls.Control
Example #1
0
        void ButtonOnKnock(object sender, RoutedEventArgs args)
        {
            MedievalButton btn = args.Source as MedievalButton;

            MessageBox.Show("The button labeled \"" + btn.Text +
                            "\" has been knocked.", Title);
        }
Example #2
0
        public GetMedieval()
        {
            Title = "Get Medieval";
            MedievalButton btn = new MedievalButton();

            btn.Text                = "I am only button. Dont klick";
            btn.FontSize            = 24;
            btn.HorizontalAlignment = HorizontalAlignment.Center;
            btn.VerticalAlignment   = VerticalAlignment.Center;
            btn.Padding             = new Thickness(5, 20, 5, 20);
            btn.Knock              += ButtonOnKnock;
            Content = btn;
        }
Example #3
0
        public GetMedieval()
        {
            Title = "Get Medieval";
            MedievalButton btn = new MedievalButton(); // Новая "средневековая кнопка

            btn.Text                = "Click this button";
            btn.FontSize            = 24;
            btn.HorizontalAlignment = HorizontalAlignment.Center; //Центрирование по горизонтали, вертикали
            btn.VerticalAlignment   = VerticalAlignment.Center;
            btn.Padding             = new Thickness(5, 20, 5, 20);
            btn.Knock              += ButtonOnKnock; // Перехват нажатия на кнопку
            Content = btn;
        }
        public GetMedieval()
        {
            Title = "Get Medieval";

            MedievalButton btn = new MedievalButton();
            btn.Text = "Click this button";
            btn.FontSize = 24;
            btn.HorizontalAlignment = HorizontalAlignment.Center;
            btn.VerticalAlignment = VerticalAlignment.Center;
            btn.Padding = new Thickness(5, 20, 5, 20);
            btn.Knock += ButtonOnKnock;

            Content = btn;
        }
Example #5
0
        public GetMedieval()
        {
            Title = "Get Medieval";

            MedievalButton btn = new MedievalButton();

            btn.Text                = "Click this button";
            btn.FontSize            = 24;
            btn.HorizontalAlignment = HorizontalAlignment.Center; // Горизонтальное выравнивание
            btn.VerticalAlignment   = VerticalAlignment.Center;   // Вертикальное выравнивание
            btn.Padding             = new Thickness(5, 20, 5, 20);
            btn.Knock              += ButtonOnKnock;

            Content = btn;
        }
        protected override void OnStartup(StartupEventArgs args)
        {
            base.OnStartup(args);

            // Window ����.
            Window win = new Window();
            win.Title = "Examine Routed Events";

            // Grid�� �����ϰ�  Window �� content�� ����.
            Grid grid = new Grid();
            win.Content = grid;

            // 3���� �� ����
            RowDefinition rowdef = new RowDefinition();
            rowdef.Height = GridLength.Auto;
            grid.RowDefinitions.Add(rowdef);

            rowdef = new RowDefinition();
            rowdef.Height = GridLength.Auto;
            grid.RowDefinitions.Add(rowdef);

            rowdef = new RowDefinition();
            rowdef.Height = new GridLength(100, GridUnitType.Star);
            grid.RowDefinitions.Add(rowdef);

            // Button �����ϰ� Grid�� �߰�.
            MedievalButton btn = new MedievalButton();
            btn.HorizontalAlignment = HorizontalAlignment.Center;
            btn.Margin = new Thickness(24);
            btn.Padding = new Thickness(24);
            grid.Children.Add(btn);

            //  TextBlock�� �����ϰ� Button�� �߰�.
            TextBlock text = new TextBlock();
            text.FontSize = 24;
            text.Text = win.Title;
            btn.Text = text.Text;

            // ScrollViewer���� ���� ǥ���� ����.
            TextBlock textHeadings = new TextBlock();
            textHeadings.FontFamily = fontfam;
            textHeadings.Inlines.Add(new Underline(new Run(
                String.Format(strFormat,
                "Routed Event", "sender", "Source", "OriginalSource"))));
            grid.Children.Add(textHeadings);
            Grid.SetRow(textHeadings, 1);

            // ScrollViewer ����.
            ScrollViewer scroll = new ScrollViewer();
            grid.Children.Add(scroll);
            Grid.SetRow(scroll, 2);

            // �̺�Ʈ ����� ���� StackPanel ����.
            stackOutput = new StackPanel();
            scroll.Content = stackOutput;

            //�̺�Ʈ �ڵ鷯 �߰�.
            UIElement[] els = { win, grid, btn, text };

            foreach (UIElement el in els)
            {
                // Keyboard
                el.PreviewKeyDown += AllPurposeEventHandler;
                el.PreviewKeyUp += AllPurposeEventHandler;
                el.PreviewTextInput += AllPurposeEventHandler;
                el.KeyDown += AllPurposeEventHandler;
                el.KeyUp += AllPurposeEventHandler;
                el.TextInput += AllPurposeEventHandler;

                // Mouse
                el.MouseDown += AllPurposeEventHandler;
                el.MouseUp += AllPurposeEventHandler;
                el.PreviewMouseDown += AllPurposeEventHandler;
                el.PreviewMouseUp += AllPurposeEventHandler;

                // Stylus
                el.StylusDown += AllPurposeEventHandler;
                el.StylusUp += AllPurposeEventHandler;
                el.PreviewStylusDown += AllPurposeEventHandler;
                el.PreviewStylusUp += AllPurposeEventHandler;

                // Click
                //��� AddHandler�� ����� �ٸ� ������Ʈ�� click�̺�Ʈ �ڵ鷯��
                //��ġ�ϴ����� �����ش�.
                el.AddHandler(Button.ClickEvent,
                    new RoutedEventHandler(AllPurposeEventHandler));
            }
            // � ������.
            win.Show();
        }
Example #7
0
        void ButtonOnKnock(object sender, RoutedEventArgs args)
        {
            MedievalButton btn = args.Source as MedievalButton;

            MessageBox.Show("The button labeled  \"" + btn.Text + "\" has been knocked.", Title); // Отображение сообщения о том, что кнопка была нажата
        }