public CrossPlatformBorderWPF()
 {
     _thisDraw               = new SKElement();
     _thisBorder             = new BorderGraphics(this); //maybe this was correct.
     Content                 = _thisDraw;                // try this.
     _thisDraw.PaintSurface += ThisDraw_PaintSurface;
 }
        private void OnCaptureClicked(object sender, RoutedEventArgs e)
        {
            // get the screen scaling
            var source = PresentationSource.FromVisual(this);
            var m      = source.CompositionTarget.TransformToDevice;

            Hide();

            // capture the image
            capturedImage = CaptureRegion(
                (int)SystemParameters.VirtualScreenLeft,
                (int)SystemParameters.VirtualScreenTop,
                (int)(SystemParameters.VirtualScreenWidth * m.M11),
                (int)(SystemParameters.VirtualScreenHeight * m.M22));

            Show();

            // create the new painting surface
            var preview = new SKElement();

            preview.PaintSurface       += OnPaintSurface;
            preview.HorizontalAlignment = HorizontalAlignment.Stretch;
            preview.VerticalAlignment   = VerticalAlignment.Stretch;

            // create a popup
            var window = new Window
            {
                Content = preview,
            };

            window.ShowDialog();
        }
Exemplo n.º 3
0
        private void LensSelected(object sender, MouseButtonEventArgs e)
        {
            if (sender is SKElement)
            {
                if (!sender.Equals(selected))
                {
                    if (!(selected is null))
                    {
                        selected.Margin = new Thickness(0);
                    }

                    selected = sender as SKElement;

                    selected.Margin = new Thickness(5);

                    ToolBar.Visibility = Visibility.Visible;
                }
                else
                {
                    if (!(selected is null))
                    {
                        selected.Margin = new Thickness(0);

                        selected = null;
                    }

                    ToolBar.Visibility = Visibility.Collapsed;
                }
            }
        }
Exemplo n.º 4
0
 public MineSquareWPF(MineSquareCP thisSquare)
 {
     CommandParameter = thisSquare;
     Name             = nameof(MinesweeperMainViewModel.MakeMoveAsync);
     _thisSquare      = thisSquare;
     _thisDraw        = new SKElement();
     Content          = _thisDraw;
 }
 public GameboardWPF()
 {
     Element1                    = new SkiaSharpGameBoard();
     Element1.MouseUp           += ThisElement_MouseUp;
     Element1.PaintSurface      += ThisElement_PaintSurface;
     _otherElement               = new SKElement();
     _otherElement.PaintSurface += OtherPaint;
 }
Exemplo n.º 6
0
 public RummyDiceGraphicsWPF()
 {
     _thisDraw = new SKElement();
     _thisDraw.PaintSurface += ThisDraw_PaintSurface;
     HorizontalAlignment     = HorizontalAlignment.Left;
     VerticalAlignment       = VerticalAlignment.Top;
     Content = _thisDraw;
 }
Exemplo n.º 7
0
 public CategoryWPF()
 {
     _thisDraw = new SKElement();
     _thisDraw.PaintSurface += ThisDraw_PaintSurface;
     HorizontalAlignment     = HorizontalAlignment.Left;
     VerticalAlignment       = VerticalAlignment.Top;
     MouseUp += BaseGraphics_MouseUp;
     Content  = _thisDraw;
 }
 public LilyPadWPF(LilyPadCP lily)
 {
     _thisDraw = new SKElement();
     _thisDraw.PaintSurface += PaintSurface;
     CommandParameter        = lily; //has to be this way now.
     //MouseUp += LilyPadWPF_MouseUp;
     Name    = nameof(FroggiesMainViewModel.MakeMoveAsync);
     Content = _thisDraw;
     _lily   = lily;
 }
 public BaseFrameWPF()
 {
     ThisDraw = new SKElement();
     ThisDraw.PaintSurface += ThisDraw_PaintSurface;
     SizeChanged           += BaseFrameWPF_SizeChanged;
     ThisFrame              = new FrameGraphics(this);
     Text = ","; // default to that which will translate to blank.  since there seemed to be a weird problem and not sure why.
     HorizontalAlignment = HorizontalAlignment.Left;
     FirstSetUp();
 }
 public StandardDiceWPF()
 {
     _thisDraw = new SKElement();
     _thisDraw.PaintSurface += ThisDraw_PaintSurface;
     HorizontalAlignment     = HorizontalAlignment.Left;
     VerticalAlignment       = VerticalAlignment.Top;
     //MouseUp += BaseGraphics_MouseUp;
     MouseDoubleClick += BaseGraphics_MouseDoubleClick;
     Content           = _thisDraw;
 }
Exemplo n.º 11
0
        private void OnBrowse(object sender, RoutedEventArgs e)
        {
            var picker = new OpenFileDialog();

            if (picker.ShowDialog() == true)
            {
                SelectedFile = new FileInfo(picker.FileName);
                SKElement.InvalidateVisual();
            }
        }
Exemplo n.º 12
0
 public BlankBoardWPF(GameBoardWPF board)
 {
     _thisDraw = new SKElement();
     _thisDraw.PaintSurface += DrawPaint;
     _thisGrid           = new Grid();
     HorizontalAlignment = HorizontalAlignment.Left;
     VerticalAlignment   = VerticalAlignment.Top;
     _cPBoard            = Resolve <ConnectFourGraphicsCP>();
     _thisGrid.Children.Add(_thisDraw);
     _thisGrid.Children.Add(board);
     Content = _thisGrid;
 }
Exemplo n.º 13
0
 public SpaceWPF(FieldInfoCP field)
 {
     DataContext             = field; // needs to be this way so if somethign changes,can act accordingly
     _thisDraw               = new SKElement();
     _space                  = field.Vector;
     CommandParameter        = _space;
     _gameBoard1             = Resolve <GameBoardCP>();
     _thisDraw.PaintSurface += ThisDraw_PaintSurface;
     Name = nameof(BattleshipMainViewModel.MakeMoveAsync);
     GamePackageViewModelBinder.ManuelElements.Add(this); //just in case.  because i have seen patterns where ones i get later never get picked up.
     Width   = _gameBoard1.SpaceSize;
     Height  = _gameBoard1.SpaceSize;                     // used the idea from tic tac toe.
     Content = _thisDraw;
 }
 public BaseGraphicsWPF()
 {
     ThisDraw = new SKElement();
     ThisDraw.PaintSurface += ThisDraw_PaintSurface;
     HorizontalAlignment    = HorizontalAlignment.Left;
     VerticalAlignment      = VerticalAlignment.Top;
     Mains         = new G();
     Mains.PaintUI = this;
     ChangeActualHeightAtBeginning();
     MouseDoubleClick += BaseGraphics_MouseDoubleClick;
     MinHeight         = Mains.MinimumHeight;
     MinWidth          = Mains.MinimumWidth;
     SetContent();
 }
Exemplo n.º 15
0
        public WpfAppRunner(SKElement skElement, IDispatcher dispatcher, IUpdatablesService updatablesService, IInputPanel inputPanel, IApplicationStopwatch applicationStopwatch, IIoCFactory iocFactory)
            : base(dispatcher, updatablesService, applicationStopwatch, iocFactory)
        {
            winDispatcher  = skElement.Dispatcher;
            this.skElement = skElement;

            skElement.PaintSurface += (o, args) =>
            {
                inputPanel.Scale = new Vector2((float)(args.Info.Width / skElement.ActualWidth),
                                               (float)(args.Info.Height / skElement.ActualHeight));

                OnRender(args.Surface.Canvas, new Size(args.Info.Width, args.Info.Height));
            };
        }
Exemplo n.º 16
0
        private void OpenOnClick(object sender, RoutedEventArgs e)
        {
            var picker = new OpenFileDialog
            {
                Filter = "SVGs|*.svg|All Files|*"
            };

            if (picker.ShowDialog() == true)
            {
                Svg = new Extended.Svg.SKSvg();
                Svg.Load(picker.FileName);
                SKElement.InvalidateVisual();
            }
        }
Exemplo n.º 17
0
        private void OnOffsetChanged(object sender, TextChangedEventArgs e)
        {
            string text  = OffsetBox.Text;
            var    parts = text.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            if (parts.Length == 2 &&
                double.TryParse(parts[0], out double xValue) &&
                double.TryParse(parts[1], out double yValue))
            {
                Offset = new Point(xValue, yValue);
            }
            else
            {
                Offset = null;
            }
            SKElement.InvalidateVisual();
        }
Exemplo n.º 18
0
        public SpaceWPF(SpaceInfoCP space)
        {
            _thisDraw = new SKElement();
            _thisDraw.PaintSurface += DrawPaint;
            Name             = nameof(TicTacToeMainViewModel.MakeMoveAsync);
            CommandParameter = space;
            //_thisMod = Resolve<TicTacToeViewModel>();
            _gameBoard1 = Resolve <TicTacToeGraphicsCP>();
            EventAggregator thisE = Resolve <EventAggregator>();

            DataContext = space;
            Width       = _gameBoard1.SpaceSize;
            Height      = _gameBoard1.SpaceSize;
            thisE.Subscribe(this, EnumRepaintCategories.FromSkiasharpboard.ToString());
            GamePackageViewModelBinder.ManuelElements.Add(this); //hopefully this simple.
            //MouseUp += SpaceWPF_MouseUp;
            Content = _thisDraw;
        }
 public GameBoardWPF(IEventAggregator aggregator, FroggiesMainGameClass game, FroggiesMainView view)
 {
     _thisGrid = new Grid();
     10.Times(x =>
     {
         AddPixelColumn(_thisGrid, 64);
         AddPixelRow(_thisGrid, 64);
     });
     _thisDraw = new SKElement();
     _thisDraw.PaintSurface += ThisDraw_PaintSurface;
     _thisGrid.Children.Add(_thisDraw);
     Grid.SetRowSpan(_thisDraw, 10);
     Grid.SetColumnSpan(_thisDraw, 10);
     aggregator.Subscribe(this);
     Content     = _thisGrid;
     _aggregator = aggregator;
     _game       = game;
     _view       = view;
 }
        public WpfMouseInputSource(SKElement inputElement)
        {
            RightUp = RegisterEvent <MouseButtonEventArgs>
                          (inputElement, nameof(inputElement.MouseRightButtonUp)).ToMouseInputArgs(inputElement);
            RightDown = RegisterEvent <MouseButtonEventArgs>
                            (inputElement, nameof(inputElement.MouseRightButtonDown)).ToMouseInputArgs(inputElement);
            LeftUp = RegisterEvent <MouseButtonEventArgs>
                         (inputElement, nameof(inputElement.MouseLeftButtonUp)).ToMouseInputArgs(inputElement);
            LeftDown = RegisterEvent <MouseButtonEventArgs>
                           (inputElement, nameof(inputElement.MouseLeftButtonDown)).ToMouseInputArgs(inputElement);

            Move = RegisterEvent <MouseEventArgs>
                       (inputElement, nameof(inputElement.MouseMove)).ToMouseInputArgs(inputElement);

            Enter = RegisterEvent <MouseEventArgs>
                        (inputElement, nameof(inputElement.MouseEnter)).ToMouseInputArgs(inputElement);
            Leave = RegisterEvent <MouseEventArgs>
                        (inputElement, nameof(inputElement.MouseLeave)).ToMouseInputArgs(inputElement);

            Scroll = RegisterEvent <MouseWheelEventArgs>
                         (inputElement, nameof(inputElement.MouseWheel)).ToMouseZoomInputArgs(inputElement);
        }
Exemplo n.º 21
0
        public SpinnerWPF(IEventAggregator aggregator)
        {
            Element = new SpinnerCanvasWPF(aggregator);
            //_thisMod = Resolve<LifeBoardGameViewModel>();
            _thisBoard     = Resolve <SpinnerCP>();
            _gameContainer = Resolve <LifeBoardGameGameContainer>();
            Name           = nameof(SpinnerViewModel.SpinAsync); //hopefully this simple (?)
            //hopefully don't have to add to manuel list (?)
            //GlobalVariableClass thisG = Resolve<GlobalVariableClass>();
            //thisG.SpinnerCanvas = Element;
            //MouseUp += SpinnerWPF_MouseUp;
            Element.PaintSurface += ThisElement_PaintSurface;
            var thisSize = _thisBoard.SuggestedBoardSize;

            Width        = thisSize;
            Height       = thisSize;
            _mainElement = new SKElement();
            _mainElement.PaintSurface += MainElementPaint;
            Grid thisGrid = new Grid();

            thisGrid.Children.Add(_mainElement);
            thisGrid.Children.Add(Element);
            Content = thisGrid;
        }
 public static IObservable <MouseZoomArgs> ToMouseZoomInputArgs <T>(this IObservable <EventPattern <T> > t, SKElement control)
     where T : MouseWheelEventArgs
 {
     return(t.Select(e => {
         var position = e.EventArgs.GetPosition(control);
         var mouseInputArgs = new MouseInputArgs(
             (float)(position.X * control.CanvasSize.Width / control.ActualWidth),
             (float)(position.Y * control.CanvasSize.Height / control.ActualHeight)
             );
         return new MouseZoomArgs(mouseInputArgs, e.EventArgs.Delta / 120.0f);
     }));
 }
 public BlankBowlingBorderWPF()
 {
     _thisDraw = new SKElement();
     _thisDraw.PaintSurface += ThisDraw_PaintSurface;
     Content = _thisDraw;
 }
Exemplo n.º 24
0
 private void OnBlurChanged(object sender, TextChangedEventArgs e)
 {
     SKElement.InvalidateVisual();
 }