상속: CustomPanel
예제 #1
0
        public SelectionTool()
        {
            Brush = new LayeredGameObject();
            Brush.Font = Settings.Config.ScreenFont;

            var animation = new AnimatedTextSurface(AnimationSingle, 1, 1, Settings.Config.ScreenFont);
            animation.CreateFrame()[0].GlyphIndex = 42;
            animation.Frames[0][0].Background = Color.Black;
            Brush.Animations.Add(animation.Name, animation);

            animation = new AnimatedTextSurface(AnimationSelection, 1, 1, Settings.Config.ScreenFont);
            Brush.Animations.Add(animation.Name, animation);

            _frameEffect = new SadConsole.Effects.Fade()
            {
                UseCellBackground = true,
                FadeForeground = true,
                FadeDuration = 1f,
                AutoReverse = true
            };

            _panel = new SelectionToolPanel(LoadBrush, SaveBrush);
            _panel.StateChangedHandler = PanelStateChanged;
            _panel.State = SelectionToolPanel.CloneState.SelectingPoint1;

            _altPanel = new SelectionToolAltPanel();

            ControlPanels = new CustomPanel[] { _panel, _altPanel };

            _pulseAnimation = new SadConsole.Effects.Fade()
            {
                FadeBackground = true,
                UseCellBackground = false,
                DestinationBackground = Color.Transparent,
                FadeDuration = 2d,
                CloneOnApply = false,
                AutoReverse = true,
                Repeat = true,
            };
        }
예제 #2
0
        private void PanelStateChanged(SelectionToolPanel.CloneState state)
        {
            if (state == SelectionToolPanel.CloneState.SelectingPoint1)
            {
                Brush.ShowSelectedSurface = false;
                Brush.IsVisible = false;
                Brush.Animation = Brush.Animations[AnimationSingle];

            }
            else if (state == SelectionToolPanel.CloneState.Move)
            {
                var animation = Brush.Animation;
                Brush.ShowSelectedSurface = false;
                ClearBrush(Brush.Position.X, Brush.Position.Y, _previousSurface);
                animation.Center = new Point(animation.Width / 2, animation.Height / 2);
                Brush.Position += animation.Center;

            }
            else if (state == SelectionToolPanel.CloneState.Clear)
            {
                var animation = Brush.Animation;
                Brush.ShowSelectedSurface = false;
                ClearBrush(Brush.Position.X, Brush.Position.Y, _previousSurface);
                _panel.State = SelectionToolPanel.CloneState.SelectingPoint1;
            }
            else if (state == SelectionToolPanel.CloneState.Clone)
            {
                var animation = Brush.Animation;
                Brush.ShowSelectedSurface = true;
                animation.Center = new Point(animation.Width / 2, animation.Height / 2);
                Brush.Position += animation.Center;
            }
        }