コード例 #1
0
        private void btnInsert_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int index = 0;
                if (!int.TryParse(txtInsertIndex.Text, out index))
                {
                    MessageBox.Show("Couldn't parse insert index as an integer", TITLE, MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }
                else if (index < 0 || index > pnlForces.Children.Count)
                {
                    MessageBox.Show("Insert index is out of range", TITLE, MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }

                ForceEntry entry = new ForceEntry(_isLinear);
                entry.ValueChanged += new EventHandler(Entry_ValueChanged);
                pnlForces.Children.Insert(index, entry);

                txtInsertIndex.Text = pnlForces.Children.Count.ToString();

                OnValueChanged();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), TITLE, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #2
0
        public static ForceEntry GetNewEntry_Orientation(ChaseDirectionType direction, double value, bool isAccel = true, bool isSpring = false, GradientEntry[] gradient = null)
        {
            ForceEntry retVal = new ForceEntry(false);

            SetDirectionInCombobox(retVal.cboDirection, direction);

            retVal.trkValue.Value   = value;
            retVal.trkValue.Maximum = value * 4;

            retVal.chkIsAccel.IsChecked  = isAccel;
            retVal.chkIsSpring.IsChecked = isSpring;

            retVal.StoreGradient(gradient);

            return(retVal);
        }
コード例 #3
0
        public ForceCollection(bool isLinear)
        {
            InitializeComponent();

            _isLinear = isLinear;

            this.DataContext = this;

            // Adding initial values, because these are pretty much the minimum required
            if (_isLinear)
            {
                ForceEntry entry = ForceEntry.GetNewEntry_Linear(ChaseDirectionType.Attract_Direction, 80);        // 80 attract
                entry.ValueChanged += new EventHandler(Entry_ValueChanged);
                pnlForces.Children.Add(entry);

                entry = ForceEntry.GetNewEntry_Linear(ChaseDirectionType.Drag_Velocity_Orth, 8);        // 8 drag orth
                entry.ValueChanged += new EventHandler(Entry_ValueChanged);
                pnlForces.Children.Add(entry);

                entry = ForceEntry.GetNewEntry_Linear(ChaseDirectionType.Drag_Velocity_AlongIfVelocityAway, 25);        // 25 drag when away
                entry.ValueChanged += new EventHandler(Entry_ValueChanged);
                pnlForces.Children.Add(entry);
            }
            else
            {
                ForceEntry entry = ForceEntry.GetNewEntry_Orientation(ChaseDirectionType.Attract_Direction, .1, gradient: new[] { new GradientEntry(0d, 0d), new GradientEntry(10d, 1d) });        // toward .1, gradient {0,0} {10,1}
                entry.ValueChanged += new EventHandler(Entry_ValueChanged);
                pnlForces.Children.Add(entry);

                entry = ForceEntry.GetNewEntry_Orientation(ChaseDirectionType.Drag_Velocity_Any, .03, gradient: new[] { new GradientEntry(0d, 0d), new GradientEntry(5d, 1d) });        // drag .03
                entry.ValueChanged += new EventHandler(Entry_ValueChanged);
                pnlForces.Children.Add(entry);

                entry = ForceEntry.GetNewEntry_Orientation(ChaseDirectionType.Drag_Velocity_AlongIfVelocityAway, .02);      // extra torque when away
                entry.ValueChanged += new EventHandler(Entry_ValueChanged);
                pnlForces.Children.Add(entry);
            }

            txtInsertIndex.Text = pnlForces.Children.Count.ToString();
        }
コード例 #4
0
        public static ForceEntry GetNewEntry_Orientation(ChaseDirectionType direction, double value, bool isAccel = true, bool isSpring = false, Tuple<double, double>[] gradient = null)
        {
            ForceEntry retVal = new ForceEntry(false);

            SetDirectionInCombobox(retVal.cboDirection, direction);

            retVal.trkValue.Value = value;
            retVal.trkValue.Maximum = value * 4;

            retVal.chkIsAccel.IsChecked = isAccel;
            retVal.chkIsSpring.IsChecked = isSpring;

            retVal.StoreGradient(gradient);

            return retVal;
        }
コード例 #5
0
        public GradientStopsPreset()
        {
            InitializeComponent();

            this.DataContext = this;

            #region cboPreset

            const double WIDTH  = 50;
            const double HEIGHT = WIDTH / 1.618;

            //Brush rowBackground = new SolidColorBrush(UtilityWPF.ColorFromHex("30000000"));
            //Brush borderFill = Brushes.White;
            Brush borderBrush = new SolidColorBrush(UtilityWPF.ColorFromHex("201F1F1E"));
            //Color graphFill = UtilityWPF.ColorFromHex("10262221");
            Color graphFill = Colors.Transparent;
            Color graphLine = UtilityWPF.ColorFromHex("647A5D");

            Grid.SetIsSharedSizeScope(cboPreset, true);

            foreach (Preset preset in Enum.GetValues(typeof(Preset)))
            {
                // Grid
                Grid row = new Grid()
                {
                    //Background = rowBackground,
                };
                row.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(1, GridUnitType.Star), SharedSizeGroup = "PresetText"
                });
                row.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(1, GridUnitType.Auto), SharedSizeGroup = "PresetGraph"
                });

                // Text
                TextBlock text = new TextBlock()
                {
                    Text                = preset.ToString().Replace('_', ' '),
                    Foreground          = Brushes.Black,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center,
                };

                Grid.SetColumn(text, 0);
                row.Children.Add(text);

                // Graph
                Border border = new Border()
                {
                    //Background = borderFill,
                    BorderBrush = borderBrush,
                    Margin      = new Thickness(6, 3, 6, 3),
                };

                Canvas canvas = new Canvas()
                {
                    Width  = WIDTH,
                    Height = HEIGHT,
                };

                canvas.Children.AddRange(ForceEntry.GetGradientGraph(WIDTH, HEIGHT, GetPreset(preset, 12), graphFill, graphLine));

                border.Child = canvas;
                Grid.SetColumn(border, 1);
                row.Children.Add(border);

                // Add to combo
                cboPreset.Items.Add(row);
            }

            cboPreset.SelectedIndex = 0;

            #endregion
        }
コード例 #6
0
        private void btnInsert_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int index = 0;
                if (!int.TryParse(txtInsertIndex.Text, out index))
                {
                    MessageBox.Show("Couldn't parse insert index as an integer", TITLE, MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }
                else if (index < 0 || index > pnlForces.Children.Count)
                {
                    MessageBox.Show("Insert index is out of range", TITLE, MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }

                ForceEntry entry = new ForceEntry(_isLinear);
                entry.ValueChanged += new EventHandler(Entry_ValueChanged);
                pnlForces.Children.Insert(index, entry);

                txtInsertIndex.Text = pnlForces.Children.Count.ToString();

                OnValueChanged();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), TITLE, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }