Ejemplo n.º 1
0
        private static void ValueChangedCallback(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            FloatBox fb = obj as FloatBox;

            fb.Text      = e.NewValue.ToString();
            fb.TempValue = (float)e.NewValue;
        }
Ejemplo n.º 2
0
        void FB_ValueChanged(object sender, EventArgs e)
        {
            if (!(DataContext is MatrixSetting))
            {
                return;
            }
            MatrixSetting MS  = DataContext as MatrixSetting;
            FloatBox      FB  = sender as FloatBox;
            int           row = Grid.GetRow(FB);
            int           col = Grid.GetColumn(FB);

            skipNext     = true;
            MS[row, col] = FB.Value;
            skipNext     = false;
        }
Ejemplo n.º 3
0
        private void UserControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (!(DataContext is MatrixSetting))
            {
                return;
            }

            MatrixSetting MS = DataContext as MatrixSetting;

            Table = new FloatBox[MS.Rows, MS.Columns];
            GMatrix.RowDefinitions.Clear();
            for (int i = 0; i < MS.Rows; i++)
            {
                GMatrix.RowDefinitions.Add(new RowDefinition()
                {
                    Height = GridLength.Auto
                });
            }

            GMatrix.ColumnDefinitions.Clear();
            for (int i = 0; i < MS.Columns; i++)
            {
                GMatrix.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(1d, GridUnitType.Star)
                });
            }

            for (int r = 0; r < MS.Rows; r++)
            {
                for (int c = 0; c < MS.Columns; c++)
                {
                    FloatBox FB = new FloatBox();
                    FB.Margin        = new Thickness(3);
                    FB.Value         = MS.Value[r, c];
                    FB.TextAlignment = TextAlignment.Center;
                    FB.ValueChanged += FB_ValueChanged;
                    GMatrix.Children.Add(FB);
                    Grid.SetRow(FB, r);
                    Grid.SetColumn(FB, c);
                    Table[r, c] = FB;
                }
            }

            MS.ValueChanged += MS_ValueChanged;
        }