Exemplo n.º 1
0
        private void Button_PreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            _moving = true;
            Button btn = e.Source as Button;

            if (btn == null)
            {
                return;
            }
            Console.WriteLine(btn);
            m_startPos = e.GetPosition(gridArcBall);
            btn.AddHandler(Button.MouseMoveEvent, new RoutedEventHandler(Button_MouseMove), true);
            //计算控制按钮的平移
            GeneralTransform gt     = btn.TransformToVisual(gridArcBall);
            Point            center = gt.Transform(new Point(btn.ActualWidth / 2, btn.ActualHeight / 2));
            //获取旋转角度。
            double angle = getRotateAngle(center);
            //计算相对中心点偏移量。
            Point  refCenter = new Point(center.X - gridArcBall.ActualWidth / 2, center.Y - gridArcBall.ActualHeight / 2);
            double maxLen    = (gridArcBall.ActualHeight - btn.ActualHeight) / 2;

            TransformParam tp = (TransformParam)btnCtrlArrow.DataContext;

            tp.TranslateX  = center.X - btnCtrlArrow.ActualWidth / 2;
            tp.TranslateY  = center.Y - btnCtrlArrow.ActualHeight / 2;
            tp.RotateAngle = angle;

            if (!btn.Equals(btnCenter))
            {
                SetPTZSpeed(refCenter.X / maxLen, refCenter.Y / maxLen);
            }
            Console.WriteLine("MouseDown");
        }
Exemplo n.º 2
0
        public AddRuleWindow()
        {
            InitializeComponent();



            outputstatecontrol.SelectedValue = inputstateControl.SelectedValue = CountStateControl.SelectedValue = "Empty";
            outputstatecontrol.ItemsSource   = inputstateControl.ItemsSource = CountStateControl.ItemsSource = GlobalSettings.StatesName;
            OutputStateButton.Background     = GlobalSettings.StateColors[(int)GlobalSettings.States.Dead];
            OutputStateButton.Tag            = (byte)GlobalSettings.States.Dead;

            for (int y = 0; y < yDim; y++)
            {
                for (int x = 0; x < xDim; x++)
                {
                    Button butt = new Button
                    {
                        Content             = "Empty",
                        HorizontalAlignment = HorizontalAlignment.Stretch,
                        VerticalAlignment   = VerticalAlignment.Stretch,
                        Background          = GlobalSettings.StateColors[(int)GlobalSettings.States.Empty],
                        Tag = (byte)GlobalSettings.States.Empty
                    };

                    butt.AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(MatrixButtonClick));
                    _buttonList[y, x] = butt;



                    Grid.SetRow(butt, x);
                    Grid.SetColumn(butt, y);
                    PositionBasedButtonGrid.Children.Add(butt);
                }
            }
        }
        public void HandleNewClientList(Dictionary <int, string> _clients)
        {
            Application.Current.Dispatcher.Invoke((Action)(() =>
            {
                clients = _clients;
                clientListPannel.Children.Clear();
                foreach (KeyValuePair <int, string> entry in clients)
                {
                    int id = entry.Key;
                    string name = entry.Value;
                    Button button = new Button
                    {
                        Content = name
                    };
                    button.AddHandler(Button.ClickEvent, new RoutedEventHandler(OpenActionMenuButton));

                    clientListPannel.Children.Add(button);
                }
                if (clientListPannel.Children.Count == 0)
                {
                    clientListPannel.Children.Add(new TextBlock {
                        Text = "No clients found.", HorizontalAlignment = HorizontalAlignment.Center
                    });
                }
            }));
        }
Exemplo n.º 4
0
        public void PrintEffects(List <AEffect> aEffects, Item BaseItem)
        {
            EffectsChecks.Children.Clear();
            foreach (AEffect effect in aEffects)
            {
                Button ItemButton = new Button();
                ItemButton.Height     = 20;
                ItemButton.Content    = effect.Name;
                ItemButton.Tag        = effect;
                ItemButton.Background = Brushes.Gray;
                //color
                ItemButton.AddHandler(Button.ClickEvent, new RoutedEventHandler(ItemEffect_Click));

                if (BaseItem.Efects.Count() != 0)
                {
                    for (int i = 0; i < BaseItem.Efects.Count(); i++)
                    {
                        if (BaseItem.Efects[i].Description.Equals(effect.Description))
                        {
                            ItemButton.Background = Brushes.Orange;
                        }
                    }
                }


                EffectsChecks.Children.Add(ItemButton);
            }
        }
Exemplo n.º 5
0
        //----< add child to the child list >-------
        private void addChild(string key)
        {
            key = getFullFileSpec(key);
            if (childs.Contains(key))
            {
                return;
            }
            childs.Add(key);
            WrapPanel wp = new WrapPanel();

            wp.DataContext       = key;
            wp.Margin            = new Thickness(5, 5, 5, 5);
            wp.VerticalAlignment = VerticalAlignment.Center;
            wp.Background        = Brushes.White;
            TextBlock printTextBlock1 = new TextBlock();

            printTextBlock1.Text   = key;
            printTextBlock1.Height = 15;
            wp.Children.Add(printTextBlock1);
            Button btn1 = new Button();

            btn1.DataContext     = key;
            btn1.Height          = 15;
            btn1.Width           = 15;
            btn1.Margin          = new Thickness(2, 2, 2, 2);
            btn1.BorderThickness = new Thickness(0);
            btn1.Content         = "X";
            wp.Children.Add(btn1);
            children.Children.Add(wp);
            btn1.AddHandler(Button.ClickEvent, new RoutedEventHandler(remove_Click));
        }
Exemplo n.º 6
0
        //Init price
        private Grid InitCustomPrice(Food f)
        {
            Grid p = new Grid();

            p.SetValue(Grid.RowProperty, 1);
            p.SetValue(Grid.ColumnProperty, 1);

            Label price = new Label();

            price.Margin            = new Thickness(10, 10, 10, 100);
            price.Content           = f.Price;
            price.VerticalAlignment = VerticalAlignment.Bottom;
            p.Children.Add(price);
            this.RegisterName(f.Name + "price", price);
            price.Name = f.Name + "price";

            Button add = new Button();

            add.AddHandler(Button.ClickEvent, new RoutedEventHandler(AddClicked));
            add.Margin            = new Thickness(10, 10, 10, 10);
            add.VerticalAlignment = VerticalAlignment.Bottom;
            add.Content           = "Add to Order";
            add.DataContext       = f;
            add.Width             = 80;
            add.Height            = 30;

            p.Children.Add(add);

            return(p);
        }
Exemplo n.º 7
0
        public void LoadTestsList()
        {
            stackPanel.Children.Clear();
            testsList = new List <TestPreview>();

            SqlConnection connection = new SqlConnection("Data Source=DESKTOP-JOHEOHB\\SQLEXPRESS;Initial Catalog=dpl;User ID=sa;Password=12345");

            connection.Open();
            SqlDataReader reader = new SqlCommand("select * from Тесты", connection).ExecuteReader();

            while (reader.Read())
            {
                TestPreview preview = new TestPreview(reader.GetInt32(reader.GetOrdinal("Идентификатор")), reader.GetString(reader.GetOrdinal("Название")));
                testsList.Add(preview);
            }
            reader.Close();

            if (testsList.Count < 1)
            {
                Label label = new Label();
                label.FontSize = 24;
                label.Content  = "Не удалось загрузить тесты";
                stackPanel.Children.Add(label);
                return;
            }
            foreach (TestPreview test in testsList)
            {
                Button testButton = new Button();
                testButton.Content = test.Name;
                testButton.Height  = 40;
                testButton.Margin  = new Thickness(10);
                testButton.AddHandler(Button.ClickEvent, new RoutedEventHandler(StartTest));
                stackPanel.Children.Add(testButton);
            }
        }
Exemplo n.º 8
0
            public PlayerHUD(Player player, string id, Grid grid, int columnIndex, FinalQuestionWindow window, Dictionary <Button, string> idFromButtons)
            {
                Checked = false;

                NameLabel         = new Label();
                NameLabel.Style   = (Style)window.FindResource(_styleName);
                NameLabel.Content = player.Name;
                Grid.SetColumn(NameLabel, columnIndex);
                Grid.SetRow(NameLabel, 0);
                grid.Children.Add(NameLabel);

                ScoreLabel         = new Label();
                ScoreLabel.Style   = (Style)window.FindResource(_styleName);
                ScoreLabel.Content = player.Score.ToString();
                Grid.SetColumn(ScoreLabel, columnIndex);
                Grid.SetRow(ScoreLabel, 1);
                grid.Children.Add(ScoreLabel);

                AnswerLabel            = new Label();
                AnswerLabel.Style      = (Style)window.FindResource(_styleName);
                AnswerLabel.Visibility = Visibility.Hidden;
                Grid.SetColumn(AnswerLabel, columnIndex);
                Grid.SetRow(AnswerLabel, 2);
                grid.Children.Add(AnswerLabel);

                Grid             buttonGrid = new Grid();
                ColumnDefinition column0    = new ColumnDefinition();

                column0.Width = new GridLength(_answerButtonWidth, GridUnitType.Star);
                buttonGrid.ColumnDefinitions.Add(column0);
                ColumnDefinition column1 = new ColumnDefinition();

                column1.Width = new GridLength(1, GridUnitType.Star);
                buttonGrid.ColumnDefinitions.Add(column1);
                ColumnDefinition column2 = new ColumnDefinition();

                column2.Width = new GridLength(_answerButtonWidth, GridUnitType.Star);
                buttonGrid.ColumnDefinitions.Add(column2);
                Grid.SetColumn(buttonGrid, columnIndex);
                Grid.SetRow(buttonGrid, 3);
                grid.Children.Add(buttonGrid);

                RightAnswerButton            = new Button();
                RightAnswerButton.Style      = (Style)window.FindResource(_styleName);
                RightAnswerButton.Content    = _rightAnswerButtonText;
                RightAnswerButton.Visibility = Visibility.Hidden;
                Grid.SetColumn(RightAnswerButton, 0);
                RightAnswerButton.AddHandler(Button.ClickEvent, new RoutedEventHandler(window.RightAnswerButton_Click));
                buttonGrid.Children.Add(RightAnswerButton);
                idFromButtons.Add(RightAnswerButton, id);

                WrongAnswerButton            = new Button();
                WrongAnswerButton.Style      = (Style)window.FindResource(_styleName);
                WrongAnswerButton.Content    = _wrongAnswerButtonText;
                WrongAnswerButton.Visibility = Visibility.Hidden;
                Grid.SetColumn(WrongAnswerButton, 2);
                WrongAnswerButton.AddHandler(Button.ClickEvent, new RoutedEventHandler(window.WrongAnswerButton_Click));
                buttonGrid.Children.Add(WrongAnswerButton);
                idFromButtons.Add(WrongAnswerButton, id);
            }
        public GoodsButtonControl()
        {
            _template = (ControlTemplate)XamlReader.Parse("<ControlTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' TargetType=\"Button\"><Border Name=\"brdr\" BorderBrush=\"Black\" BorderThickness=\"1\"><Grid><Image x:Name=\"ibtn\" Stretch=\"None\" VerticalAlignment=\"Center\" HorizontalAlignment=\"Center\"><Image.Style><Style TargetType=\"{x:Type Image}\"></Style></Image.Style></Image><Label x:Name=\"tbtn\" VerticalAlignment=\"Top\" HorizontalAlignment=\"Right\" Margin=\"0,-4,-1,0\" /></Grid></Border><ControlTemplate.Triggers><Trigger Property=\"IsMouseOver\" Value=\"true\"><Setter TargetName=\"brdr\" Property=\"BorderThickness\" Value=\"2\" /><Setter TargetName=\"brdr\" Property=\"BorderBrush\" Value=\"Cyan\" /><Setter TargetName=\"tbtn\" Property=\"Margin\" Value=\"0,-5,-2,0\" /></Trigger></ControlTemplate.Triggers></ControlTemplate>");
            DrinksViewModel model = new DrinksViewModel(ResourceLoadHelper.GetLocalString("GoodsDescription")).BindToMainModel();
            int             count = model.Drinks.Count();

            ScrollableWidth = (count > 6 ? Math.Ceiling((double)count / 2) : 3) * 102;
            InitializeComponent();
            Drinks.Header = ResourceLoadHelper.GetLocalString("DrinksGroup");
            DataContext   = model;
            foreach (Product p in model.Drinks)
            {
                Button b = new Button();
                model.SetToolTip(p.id, p.quantity, p.price, ResourceLoadHelper.GetLocalName(p.locals), b);
                model.SetTemplate(p.id, _template);
                model.DrinkButton[p.id].PropertyChanged += Template_PropertyChanged;
                Binding toolTip = new Binding(string.Format("DrinkButton[{0}].ToolTip", p.id));
                toolTip.Source = model;
                toolTip.Mode   = BindingMode.OneWay;
                b.SetBinding(Button.ToolTipProperty, toolTip);
                Binding Visible = new Binding(string.Format("DrinkButton[{0}].Visible", p.id));
                Visible.Source = model;
                Visible.Mode   = BindingMode.OneWay;
                b.SetBinding(Button.VisibilityProperty, Visible);
                Binding Template = new Binding(string.Format("DrinkButton[{0}].Template", p.id));
                Template.Source = model;
                Template.Mode   = BindingMode.OneWay;
                b.SetBinding(Button.TemplateProperty, Template);
                b.CommandParameter = p.id;
                Binding cmd = new Binding();
                cmd.Source = model;
                cmd.Path   = new PropertyPath("PurchaseCommand");
                b.SetBinding(Button.CommandProperty, cmd);
                b.Width  = 100;
                b.Height = 100;
                b.Margin = new Thickness(0, 0, 2, 2);
                Image rimg = ResourceLoadHelper.GetDrinksButtonImage(new Size(96, 96), (Color)ColorConverter.ConvertFromString(p.color), p.type);
                b.AddHandler(LoadedEvent, new RoutedEventHandler((object s, RoutedEventArgs e) => {
                    Button btn = s as Button;
                    if (btn.Template != null)
                    {
                        Label text           = btn.Template.FindName("tbtn", btn) as Label;
                        text.Foreground      = new SolidColorBrush(p.parsedColor.R + p.parsedColor.G + p.parsedColor.B > 381 ? (Color)ColorConverter.ConvertFromString("Black") : (Color)ColorConverter.ConvertFromString("White"));
                        text.FontWeight      = FontWeights.Bold;
                        Binding quantityInfo = new Binding("quantity");
                        quantityInfo.Source  = p;
                        quantityInfo.Mode    = BindingMode.OneWay;
                        text.SetBinding(Label.ContentProperty, quantityInfo);
                        Image img  = btn.Template.FindName("ibtn", btn) as Image;
                        Style simg = new Style(typeof(Image));
                        img.Style.Setters.ToList().ForEach(x => simg.Setters.Add(x));
                        simg.Setters.Add(new Setter(Image.SourceProperty, rimg.Source));
                        img.Style = simg;
                    }
                }));
                DrinksContainer.Children.Add(b);
            }
            model.DisposeRequest += Dispose;
        }
        /// <summary>
        /// Default Constructor
        /// </summary>
        public ProgressBarWindowSettings()
        {
            BackgroundWorker                            = new BackgroundWorker();
            BackgroundWorker.DoWork                    += BackgroundWorkerOnDoWork;
            BackgroundWorker.ProgressChanged           += BackgroundWorkerOnProgressChanged;
            BackgroundWorker.RunWorkerCompleted        += BackgroundWorkerOnRunWorkerCompleted;
            BackgroundWorker.WorkerReportsProgress      = true;
            BackgroundWorker.WorkerSupportsCancellation = true;

            GridMain = new Grid
            {
                Height            = 150,
                RowDefinitions    = { new RowDefinition(), new RowDefinition(), new RowDefinition() },
                ColumnDefinitions = { new ColumnDefinition {
                                          Width = new GridLength(160)
                                      }, new ColumnDefinition(), new ColumnDefinition(), new ColumnDefinition{
                                          Width = new GridLength(160)
                                      } },
            };


            TextBlockFrom = new TextBlock();
            Grid.SetColumn(TextBlockFrom, 0);
            Grid.SetRow(TextBlockFrom, 0);
            Grid.SetColumnSpan(TextBlockFrom, 4);
            TextBlockFrom.FontSize     = 10;
            TextBlockFrom.FontWeight   = FontWeights.Bold;
            TextBlockFrom.TextWrapping = TextWrapping.Wrap;
            GridMain.Children.Add(TextBlockFrom);

            ProgressBarCopy = new ProgressBar();
            Grid.SetColumn(ProgressBarCopy, 0);
            Grid.SetRow(ProgressBarCopy, 1);
            Grid.SetColumnSpan(ProgressBarCopy, 4);
            ProgressBarCopy.Margin = new Thickness(5, 5, 5, 5);
            GridMain.Children.Add(ProgressBarCopy);

            ButtonPause = new Button();
            Grid.SetColumn(ButtonPause, 0);
            Grid.SetRow(ButtonPause, 2);
            ButtonPause.Margin     = new Thickness(5, 5, 5, 5);
            ButtonPause.Content    = "Pause";
            ButtonPause.Background = Brushes.BurlyWood;
            ButtonPause.Foreground = Brushes.White;
            ButtonPause.FontWeight = FontWeights.Bold;
            ButtonPause.AddHandler(Button.ClickEvent, new RoutedEventHandler(ButtonPauseOnClick));
            GridMain.Children.Add(ButtonPause);

            ButtonCancel = new Button();
            Grid.SetColumn(ButtonCancel, 3);
            Grid.SetRow(ButtonCancel, 2);
            ButtonCancel.Margin     = new Thickness(5, 5, 5, 5);
            ButtonCancel.Content    = "Cancel";
            ButtonCancel.Background = Brushes.BurlyWood;
            ButtonCancel.Foreground = Brushes.White;
            ButtonCancel.FontWeight = FontWeights.Bold;
            ButtonCancel.AddHandler(Button.ClickEvent, new RoutedEventHandler(ButtonCancelOnClick));
            GridMain.Children.Add(ButtonCancel);
        }
Exemplo n.º 11
0
        void InitializeContent()
        {
            ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.FullScreen;
#if DEBUG
            Canvas.SetZIndex(InputBorder, 3);
#endif
            Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown;
            Window.Current.CoreWindow.KeyUp   += CoreWindow_KeyUp;

            for (int i = 0; i < _piano.NoteCount; ++i)
            {
                string buttonName = "WhiteKey" + i;
                Button b          = FindName(buttonName) as Button;
                b.AddHandler(PointerPressedEvent, new PointerEventHandler(WhiteKey_PointerPressed), true);
                b.AddHandler(PointerReleasedEvent, new PointerEventHandler(WhiteKey_PointerReleased), true);
            }
        }
Exemplo n.º 12
0
        private void CreateGrid(int x)
        {
            Holder                     = new Grid();
            Holder.Height              = 50;
            Holder.Width               = 365;
            Holder.Margin              = new System.Windows.Thickness(0, 50 * (x + 1), 0, 0);
            Holder.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
            Holder.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            if (!Left)
            {
                Holder.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            }


            Delete        = new Button();
            Delete.Height = 20;
            Delete.Width  = 50;
            Delete.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            Delete.Margin  = new System.Windows.Thickness(10, 0, 0, 0);
            Delete.Content = "Delete";
            Delete.AddHandler(Button.ClickEvent, new RoutedEventHandler(DeleteClicked));

            SpellName        = new TextBox();
            SpellName.Height = 15;
            SpellName.Width  = 75;
            SpellName.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            SpellName.Margin = new System.Windows.Thickness(65, 0, 0, 0);
            SpellName.Text   = "SpellName";

            CoolDown        = new TextBox();
            CoolDown.Height = 15;
            CoolDown.Width  = 75;
            CoolDown.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            CoolDown.Margin = new System.Windows.Thickness(145, 0, 0, 0);
            CoolDown.Text   = "CoolDown";

            CountDown        = new TextBox();
            CountDown.Height = 15;
            CountDown.Width  = 75;
            CountDown.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            CountDown.Margin = new System.Windows.Thickness(225, 0, 0, 0);
            CountDown.Text   = "Count Down";

            Cast        = new Button();
            Cast.Height = 20;
            Cast.Width  = 50;
            Cast.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            Cast.Margin  = new System.Windows.Thickness(305, 0, 0, 0);
            Cast.Content = "Cast";
            Cast.AddHandler(Button.ClickEvent, new RoutedEventHandler(CastClick));

            Holder.Children.Add(Delete);
            Holder.Children.Add(SpellName);
            Holder.Children.Add(CoolDown);
            Holder.Children.Add(CountDown);
            Holder.Children.Add(Cast);
        }
Exemplo n.º 13
0
 public override void OnApplyTemplate()
 {
     base.OnApplyTemplate();
     _navigationButton = this.GetTemplateChild("PART_NavigationButton") as Button;
     if (_navigationButton != null)
     {
         _navigationButton.AddHandler(Button.ClickEvent, new RoutedEventHandler(this.OnNavigationButtonClick));
     }
 }
Exemplo n.º 14
0
        //Init a food in menu
        private void InitFood(Food f, int i)
        {
            Grid mg = new Grid();

            mg.DataContext = f;
            mg.Width       = double.NaN;
            mg.Height      = 150;
            mg.Margin      = new Thickness(10, 10, 10, 10);

            Border b = new Border();

            b.BorderBrush     = System.Windows.Media.Brushes.Black;
            b.BorderThickness = new Thickness(2);
            mg.Children.Add(b);

            Grid             g  = new Grid();
            ColumnDefinition c1 = new ColumnDefinition();

            c1.Width = new GridLength(5, GridUnitType.Star);
            ColumnDefinition c2 = new ColumnDefinition();

            c2.Width = new GridLength(10, GridUnitType.Star);
            ColumnDefinition c3 = new ColumnDefinition();

            c3.Width = new GridLength(5, GridUnitType.Star);
            ColumnDefinition c4 = new ColumnDefinition();

            c4.Width = new GridLength(2, GridUnitType.Star);
            g.ColumnDefinitions.Add(c1);
            g.ColumnDefinitions.Add(c2);
            g.ColumnDefinitions.Add(c3);
            g.ColumnDefinitions.Add(c4);


            g.Children.Add(InitFoodImg());
            g.Children.Add(InitFoodName(f));
            g.Children.Add(InitFoodPrice(f));

            //
            Label icon = new Label();

            this.RegisterName(f.Name + "Icon", icon);
            icon.Padding = new Thickness(10, 10, 10, 10);
            icon.SetValue(Grid.ColumnProperty, 3);
            icon.Content = "Up";
            g.Children.Add(icon);

            Button btn = new Button();

            btn.AddHandler(Button.ClickEvent, new RoutedEventHandler(MenuClicked));
            btn.Background = Brushes.Transparent;

            mg.Children.Add(g);
            mg.Children.Add(btn);
            Menu.Children.Add(mg);
        }
Exemplo n.º 15
0
 public override void OnApplyTemplate()
 {
     _border         = this.GetTemplateChild("border") as Border;
     _openAnimation  = this.GetTemplateChild("openAnimation") as DoubleAnimation;
     _closeAnimation = this.GetTemplateChild("closeAnimation") as DoubleAnimation;
     _closeButton    = this.GetTemplateChild("closeButton") as Button;
     if (_closeButton != null)
     {
         _closeButton.AddHandler(Button.ClickEvent, new RoutedEventHandler(this.OnCloseButtonClick));
     }
     this.SetTransformationDirection();
 }
Exemplo n.º 16
0
 public void PrintClassRooms()
 {
     ClassRooms.Children.Clear();
     for (int i = 0; i < SchClassRooms.Count(); i++)
     {
         Button button = new Button();
         button.Content = SchClassRooms[i].Name;
         button.Tag     = i;
         button.AddHandler(Button.ClickEvent, new RoutedEventHandler(Button_Click_ClassRoom_Select));
         ClassRooms.Children.Add(button);
     }
 }
Exemplo n.º 17
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            passwordBox = loginPw.Template.FindName("newpb", loginPw) as PasswordBox;
            Button button = loginPw.Template.FindName("btn", loginPw) as Button;

            if (passwordBox != null)
            {
                passwordBox.GotFocus        += passwordBox_GotFocus;
                passwordBox.PasswordChanged += passwordBox_PasswordChanged;
                passwordBox.LostFocus       += passwordBox_LostFocus;
            }
            if (button != null)
            {
                button.AddHandler(Button.MouseLeftButtonDownEvent, new MouseButtonEventHandler(button_MouseLeftButtonDown), true);
                button.AddHandler(Button.MouseLeftButtonUpEvent, new MouseButtonEventHandler(button_MouseLeftButtonUp), true);
            }

            if (IsSetFocus && passwordBox != null)
            {
                passwordBox.Focus();
            }
        }
Exemplo n.º 18
0
        protected void AddMouseHandler()
        {
            Button.AddHandler(MouseLeftButtonDownEvent, new MouseButtonEventHandler(Button_MouseLeftButtonDown), true);
            Button.AddHandler(MouseLeftButtonUpEvent, new MouseButtonEventHandler(Button_MouseLeftButtonUp), true);
            Button.AddHandler(MouseMoveEvent, new MouseEventHandler(Button_MouseMove), true);

            /*
             * PreviewMouseDownEvent required, because the
             * System.Windows.Controls.TextBox MouseLeftButtonUpEvent is buggy
             * -> e.ClickCount always stays at "1"
             */
            TextEdit.AddHandler(PreviewMouseDownEvent, new MouseButtonEventHandler(TextEdit_PreviewMouseDown), true);
        }
Exemplo n.º 19
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (this.DynamicButton != null)
     {
         this.grid.Children.Remove(this.DynamicButton);
     }
     this.DynamicButton = new Button();
     DynamicButton.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
     DynamicButton.VerticalAlignment   = System.Windows.VerticalAlignment.Center;
     DynamicButton.Content             = this.TextBoxMessage.Text;
     DynamicButton.AddHandler(Button.ClickEvent, new RoutedEventHandler(ButtonDynamic_Click));
     this.grid.Children.Add(DynamicButton);
 }
Exemplo n.º 20
0
        //Set KontextWindow Controls
        public void setWindowProperties()
        {
            txtBox_txtField_Text.Height = 100;
            txtBox_txtField_Text.Width  = 300;
            txtBox_txtField_Text.Text   = "";
            txtBox_txtField_Text.HorizontalAlignment = HorizontalAlignment.Left;
            txtBox_txtField_Text.VerticalAlignment   = VerticalAlignment.Top;
            txtBox_txtField_Text.AcceptsReturn       = true;
            txtBox_txtField_Text.Margin = new Thickness(10, 20, 0, 0);

            cmBox_fontMenu.Height = 25;
            cmBox_fontMenu.Width  = 120;
            cmBox_fontMenu.HorizontalAlignment = HorizontalAlignment.Left;
            cmBox_fontMenu.VerticalAlignment   = VerticalAlignment.Top;
            cmBox_fontMenu.Margin = new Thickness(10, 160, 0, 0);

            List <string> fonts = new List <string>();

            using (InstalledFontCollection fontsCollection = new InstalledFontCollection())
            {
                System.Drawing.FontFamily[] fontFamilies = fontsCollection.Families;
                foreach (System.Drawing.FontFamily font in fontFamilies)
                {
                    fonts.Add(font.Name);
                }
            }
            cmBox_fontMenu.ItemsSource   = fonts;
            cmBox_fontMenu.SelectedIndex = 0;

            cmBox_fontSize.Height = 25;
            cmBox_fontSize.Width  = 120;
            cmBox_fontSize.HorizontalAlignment = HorizontalAlignment.Left;
            cmBox_fontSize.VerticalAlignment   = VerticalAlignment.Top;
            cmBox_fontSize.Margin = new Thickness(160, 160, 0, 0);
            List <string> fontSizeList = new List <string>();

            for (int i = 4; i < 70; i++)
            {
                fontSizeList.Add(i.ToString());
            }
            cmBox_fontSize.ItemsSource   = fontSizeList;
            cmBox_fontSize.SelectedIndex = 0;

            btn_txtField_Apply.Height              = 25;
            btn_txtField_Apply.Width               = 90;
            btn_txtField_Apply.Content             = "Apply Changes";
            btn_txtField_Apply.HorizontalAlignment = HorizontalAlignment.Left;
            btn_txtField_Apply.VerticalAlignment   = VerticalAlignment.Top;
            btn_txtField_Apply.Margin              = new Thickness(10, 130, 0, 0);
            btn_txtField_Apply.AddHandler(Button.ClickEvent, new RoutedEventHandler(btn_txtField_Apply_Click));
        }
Exemplo n.º 21
0
        private void DrawQuestionGrid()
        {
            for (int i = 0; i < _settings.RoundSize.Value; i++)
            {
                RowDefinition row = new RowDefinition();
                QuestionGrid.RowDefinitions.Add(row);
            }

            ColumnDefinition namesColumn = new ColumnDefinition();

            namesColumn.Width = new GridLength(2, GridUnitType.Star);
            QuestionGrid.ColumnDefinitions.Add(namesColumn);

            for (int i = 0; i < _settings.ThemeSize.Value; i++)
            {
                ColumnDefinition column = new ColumnDefinition();
                column.Width = new GridLength(1, GridUnitType.Star);
                QuestionGrid.ColumnDefinitions.Add(column);
            }

            for (int i = 0; i < _settings.RoundSize.Value; i++)
            {
                TextBox themeName = new TextBox();
                _nameBoxes.Add(themeName, i);
                themeName.Style      = (Style)FindResource(_styleName);
                themeName.Foreground = Brushes.White;
                themeName.Text       = _round[i].Name;
                Grid.SetColumn(themeName, 0);
                Grid.SetRow(themeName, i);
                themeName.AddHandler(TextBox.LostFocusEvent, new RoutedEventHandler(ThemeName_LostFocus));
                QuestionGrid.Children.Add(themeName);
            }

            for (int i = 0; i < _settings.RoundSize.Value; i++)
            {
                for (int j = 0; j < _settings.ThemeSize.Value; j++)
                {
                    Button question = new Button();
                    _questionButtons.Add(question, new Coords(i, j));
                    question.Style   = (Style)FindResource(_styleName);
                    question.Content = _round[i].GetQuestionValue(j);
                    Grid.SetColumn(question, j + 1);
                    Grid.SetRow(question, i);
                    question.AddHandler(Button.ClickEvent, new RoutedEventHandler(QuestionButton_Click));
                    QuestionGrid.Children.Add(question);
                }
            }

            UpdateButtons();
        }
Exemplo n.º 22
0
        private Grid InitOrderDuplication(OrderItem order)
        {
            Grid dup = new Grid();

            dup.SetValue(Grid.RowProperty, 2);
            dup.SetValue(Grid.ColumnProperty, 0);
            dup.DataContext = order;

            ColumnDefinition cc1 = new ColumnDefinition();

            cc1.Width = new GridLength(1, GridUnitType.Star);
            ColumnDefinition cc2 = new ColumnDefinition();

            cc2.Width = new GridLength(1, GridUnitType.Star);
            ColumnDefinition cc3 = new ColumnDefinition();

            cc3.Width = new GridLength(1, GridUnitType.Star);
            dup.ColumnDefinitions.Add(cc1);
            dup.ColumnDefinitions.Add(cc2);
            dup.ColumnDefinitions.Add(cc3);

            Button plus = new Button();

            plus.SetValue(Grid.ColumnProperty, 0);
            plus.Content = "+";
            RegisterName(order.Name + "plus", plus);
            plus.DataContext = order;
            plus.AddHandler(Button.ClickEvent, new RoutedEventHandler(PlusClicked));
            dup.Children.Add(plus);

            Button minus = new Button();

            minus.SetValue(Grid.ColumnProperty, 2);
            minus.Content     = "-";
            minus.DataContext = order;
            minus.AddHandler(Button.ClickEvent, new RoutedEventHandler(MinusClicked));
            dup.Children.Add(minus);

            Label counter = new Label();

            counter.SetValue(Grid.ColumnProperty, 1);
            counter.Content = "1";
            this.RegisterName(order.Name + "counter", counter);
            counter.DataContext = order;
            dup.Children.Add(counter);


            return(dup);
        }
Exemplo n.º 23
0
 public void PrintItems()
 {
     Items.Children.Clear();
     for (int i = 0; i < SchItems.Count(); i++)
     {
         if (SchItems[i].IdClassRoom == SchClassRooms[SelectedClassRoom].Id)
         {
             Button button = new Button();
             button.Content = SchItems[i].Name + " | " + SchItems[i].Cost.ToString() + "Kč";
             button.Tag     = i;
             button.AddHandler(Button.ClickEvent, new RoutedEventHandler(Button_Click_Item_Select));
             Items.Children.Add(button);
         }
     }
 }
Exemplo n.º 24
0
 public void PrintItems(List <Item> items)
 {
     ItemButtons.Children.Clear();
     foreach (Item item in items)
     {
         Button ItemButton = new Button();
         ItemButton.Height     = 20;
         ItemButton.Content    = item.Name;
         ItemButton.Tag        = item;
         ItemButton.Background = Brushes.Gray;
         //color
         ItemButton.AddHandler(Button.ClickEvent, new RoutedEventHandler(ItemButton_Click));
         ItemButtons.Children.Add(ItemButton);
     }
 }
Exemplo n.º 25
0
            public Border ToElement()
            {
                var button = new Button {
                    Content = Symbol,
                    Style   = Application.Current.FindResource("KeyboardButtonStyle") as Style
                };

                button.AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler((x, o) => Callback(Symbol)), true);
                var border = new Border {
                    Child = button,
                    Style = Application.Current.FindResource("KeyboardButtonBorderStyle") as Style,
                };

                return(border);
            }
Exemplo n.º 26
0
        private Button CreateButton(MessageDialogDefaultButton buttonType, ICommand command)
        {
            var button = new Button
            {
                Content   = this.GetDefaultButtonContent(buttonType),
                Command   = command,
                Style     = this.DefaultButtonStyle,
                Tag       = buttonType,
                IsDefault = (buttonType == MessageDialogDefaultButton.Ok || buttonType == MessageDialogDefaultButton.Yes),
                IsCancel  = (buttonType == MessageDialogDefaultButton.Cancel || buttonType == MessageDialogDefaultButton.Close || buttonType == MessageDialogDefaultButton.No),
            };

            button.AddHandler(Button.ClickEvent, new RoutedEventHandler(this.OnDefaultButtonClicked));
            return(button);
        }
Exemplo n.º 27
0
        partial void InitTab()
        {
            Tab = new TabItem();
            // bind events for tab header
            Tab.Loaded += (s, e) => {
                Button    closeButton = UIHelper.FindChild <Button>(Tab);
                TextBlock header      = UIHelper.FindChild <TextBlock>(Tab);
                // close diagram event
                closeButton.AddHandler(UIElement.MouseDownEvent, new MouseButtonEventHandler(OnRemoveDiagramButton), true);
                header.MouseDown += OnDoubleClickTab_RenameDiagram;
#if DEBUG_ON
                System.Console.WriteLine("{0} Tab loaded", System.DateTime.Now.Millisecond);
#endif
            };
        }
Exemplo n.º 28
0
        private void InitializeComponent()
        {
            this.Width = this.Height = 300;
            this.Left  = this.Top = 300;
            this.Title = "Grid Test";

            #region Grid Define0
            var grid = new Grid();
            grid.AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(ButtonClickMethod));
            grid.ShowGridLines = true;

            var column1 = new ColumnDefinition();
            var column2 = new ColumnDefinition();

            grid.ColumnDefinitions.Add(column1);
            grid.ColumnDefinitions.Add(column2);

            var row1 = new RowDefinition();
            var row2 = new RowDefinition();

            grid.RowDefinitions.Add(row1);
            grid.RowDefinitions.Add(row2);
            #endregion

            var button1 = new Button();
            button1.Content = "Test Grid";

            button1.AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(ButtonClickMethod));

            Grid.SetColumn(button1, 0);
            Grid.SetRow(button1, 0);

            // 和上面两句一个意思
            //button1.SetValue(Grid.RowProperty, 0);
            //button1.SetValue(Grid.ColumnProperty, 0);

            grid.Children.Add(button1);

            this.Content = grid;

            //button1.RemoveHandler(ButtonBase.ClickEvent, new RoutedEventHandler(ButtonClickMethod));

            //FrameworkPropertyMetadata frameworkPropertyMetadata = new FrameworkPropertyMetadata();
            //frameworkPropertyMetadata.CoerceValueCallback = new CoerceValueCallback();

            //DependencyProperty.Register("Margin", typeof(Thickness), typeof(FrameworkElement),
            //    frameworkPropertyMetadata);
        }
Exemplo n.º 29
0
 private void OnLoaded(object sender, RoutedEventArgs e)
 {
     this.DetectFlipView();
     if (_flipView != null)
     {
         this.ShowNavigationButtonCore = (_flipView.Items.IndexOf(this) > 0 & this.ShowNavigationButton);
     }
     if (_navigationButton == null)
     {
         _navigationButton = ElementHelpers.GetVisualChild <NavigationButton>(this, "PART_NavigationButton");
         if (_navigationButton != null)
         {
             _navigationButton.AddHandler(Button.ClickEvent, new RoutedEventHandler(this.OnNavigationButtonClick));
         }
     }
 }
Exemplo n.º 30
0
 public override void OnApplyTemplate()
 {
     base.OnApplyTemplate();
     partPanel    = GetTemplateChild("PART_Panel") as Grid;
     upButton     = GetTemplateChild("PART_UpButton") as SwitchButton;
     downButton   = GetTemplateChild("PART_DownButton") as SwitchButton;
     switchButton = GetTemplateChild("PART_SwitchButton") as Button;
     upButton.AddHandler(RadioButton.CheckedEvent, new RoutedEventHandler(UpRadioChecked));
     downButton.AddHandler(RadioButton.CheckedEvent, new RoutedEventHandler(DownRadioChecked));
     switchButton.AddHandler(Button.ClickEvent, new RoutedEventHandler(ContentSwitchChanged));
     if (verticalSwitchButtonGroupStyle is null)
     {
         verticalSwitchButtonGroupStyle   = FindResource("VerticalSwitchButtonGroupStyle") as Style;
         horizontalSwitchButtonGroupStyle = FindResource("HorizontalSwitchButtonGroupStyle") as Style;
         ChangedMode();
     }
 }