Example #1
0
        public override void CreateBender(BenderConfig config)
        {
            if (CreateUI == false)
            {
                return;
            }

            _benderConfig = config;

            _curveEditorWindow = new CurveEditorWindow
            {
                Top    = config.Top,
                Left   = config.Left,
                Width  = config.Width,
                Height = config.Height
            };

            _curveTreeViewModel                      = new CurveTreeViewModel(_curveEditorWindow.curveEditorControl);
            _curveEditorWindow.DataContext           = _curveEditorWindow.curveEditorControl.ControlsViewModel;
            _curveEditorWindow.curveTree.DataContext = _curveTreeViewModel;

            _curveEditorWindow.IsVisibleChanged += (sender, args) => _benderConfig.Visible = _curveEditorWindow.IsVisible;
            _curveEditorWindow.LocationChanged  += (sender, args) => _benderLocationJustChanged = true;
            _curveEditorWindow.SizeChanged      += (sender, args) => _benderLocationJustChanged = true;

            if (_benderConfig.Visible)
            {
                _curveEditorWindow.Show();
            }

            _windows.Add(_curveEditorWindow);

            WindowHelper.EnsureOnScreen(_curveEditorWindow);
        }
        private void CurveEditorButton_OnClick(object sender, RoutedEventArgs e)
        {
            var tag = ((Button)sender).Tag;

            if (tag is ICurveDataAccessor redcurve)
            {
                var curveEditorWindow = new CurveEditorWindow(redcurve);
                var r = curveEditorWindow.ShowDialog();
                if (r ?? true)
                {
                    var c = curveEditorWindow.GetCurve();
                    if (c is not null)
                    {
                        // set tag data
                        redcurve.SetInterpolationType(c.Type);
                        redcurve.SetCurvePoints(c.Points);
                    }
                }
            }
        }