async public Task <int> preparePaintingAreaCanvasForEraser()
        {
            RenderTargetBitmap retarbi      = new RenderTargetBitmap();
            Canvas             eraserCanvas = PocketPaintApplication.GetInstance().EraserCanvas;

            try
            {
                if (eraserCanvas.Visibility == Visibility.Collapsed)
                {
                    eraserCanvas.Visibility = Visibility.Visible;
                }
                await retarbi.RenderAsync(eraserCanvas);

                Windows.Storage.Streams.IBuffer buffer = await(retarbi.GetPixelsAsync());
                pixelsCanvasEraser = WindowsRuntimeBufferExtensions.ToArray(buffer);

                this.pixelHeightCanvas = retarbi.PixelHeight;
                this.pixelWidthCanvas  = retarbi.PixelWidth;
            }
            catch
            {
                return(1);
            }
            return(0);
        }
        public void BtnMoveScreenEllipse_OnClick(object sender, RoutedEventArgs e)
        {
            ToolType currentTooltype = PocketPaintApplication.GetInstance().ToolCurrent.GetToolType();

            if (currentTooltype != ToolType.Move)
            {
                //PocketPaintApplication.GetInstance().PaintingAreaView.setVisibilityGrdSliderThickness(Visibility.Collapsed);
                PocketPaintApplication.GetInstance().SwitchTool(ToolType.Move);
                PocketPaintApplication.GetInstance().PaintingAreaView.changeVisibilityOfSelectionsControls(Visibility.Collapsed);
                PocketPaintApplication.GetInstance().PaintingAreaView.changeBackgroundColorAndOpacityOfPaintingAreaCanvas(Colors.Transparent, 1.0);
            }
            else if (currentTooltype == ToolType.Move)
            {
                if (PocketPaintApplication.GetInstance().ToolWhileMoveTool == null)
                {
                    return;
                }

                ToolType newSelectedTooltype = PocketPaintApplication.GetInstance().ToolWhileMoveTool.GetToolType();
                PocketPaintApplication.GetInstance().SwitchTool(newSelectedTooltype);
                PocketPaintApplication.GetInstance().PaintingAreaView.changeVisibilityOfActiveSelectionControl(Visibility.Visible);
                if (newSelectedTooltype == ToolType.Ellipse || newSelectedTooltype == ToolType.ImportPng || newSelectedTooltype == ToolType.Rect)
                {
                    PocketPaintApplication.GetInstance().PaintingAreaView.changeBackgroundColorAndOpacityOfPaintingAreaCanvas(Colors.Black, 0.5);
                }
                PocketPaintApplication.GetInstance().PaintingAreaView.resetActiveSelectionControl();
            }
        }
예제 #3
0
        /// <summary>
        /// Wird aufgerufen, wenn diese Seite in einem Frame angezeigt werden soll.
        /// </summary>
        /// <param name="e">Ereignisdaten, die beschreiben, wie diese Seite erreicht wurde.
        /// Dieser Parameter wird normalerweise zum Konfigurieren der Seite verwendet.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            SolidColorBrush fill_color;

            if (PocketPaintApplication.GetInstance().is_border_color)
            {
                fill_color = PocketPaintApplication.GetInstance().PaintData.strokeColorSelected;
            }
            else
            {
                fill_color = PocketPaintApplication.GetInstance().PaintData.colorSelected;
            }

            double fill_color_opacity = Convert.ToDouble(fill_color.Color.A);


            if (PocketPaintApplication.GetInstance().PaintData.colorSelected != null)
            {
                Color selected_color;
                if (PocketPaintApplication.GetInstance().is_border_color)
                {
                    selected_color = ((SolidColorBrush)PocketPaintApplication.GetInstance().PaintData.strokeColorSelected).Color;
                }
                else
                {
                    selected_color = ((SolidColorBrush)PocketPaintApplication.GetInstance().PaintData.colorSelected).Color;
                }

                changeValuesOfColourSliders(selected_color.R, selected_color.G, selected_color.B, (byte)fill_color_opacity);
                changeColorOfBtnSelectedColor(selected_color);
            }
        }
        private async Task <SolidColorBrush> GetPixelColor()
        {
            RenderTargetBitmap retarbi = new RenderTargetBitmap();
            await retarbi.RenderAsync(PocketPaintApplication.GetInstance().PaintingAreaCanvas,
                                      (int)PocketPaintApplication.GetInstance().PaintingAreaCanvas.ActualWidth,
                                      (int)PocketPaintApplication.GetInstance().PaintingAreaCanvas.ActualHeight);

            Windows.Storage.Streams.IBuffer buffer = await(retarbi.GetPixelsAsync());
            var pixels = WindowsRuntimeBufferExtensions.ToArray(buffer);

            var width  = retarbi.PixelWidth;
            var height = retarbi.PixelHeight;

            double NormfactorX = (double)width / (double)PocketPaintApplication.GetInstance().Bitmap.PixelWidth;
            double NormfactorY = (double)height / (double)PocketPaintApplication.GetInstance().Bitmap.PixelHeight;

            double doubleY = ((double)Y) * NormfactorY;
            double doubleX = ((double)X) * NormfactorX;

            int intX = (int)Math.Round(doubleX, 0);
            int intY = (int)Math.Round(doubleY, 0);

            int intTemp  = intY * width;
            int intXTemp = intTemp + intX;
            int intValue = intXTemp * 4;

            var a = pixels[intValue + 3];
            var r = pixels[intValue + 2];
            var g = pixels[intValue + 1];
            var B = pixels[intValue];

            return(new SolidColorBrush(Windows.UI.Color.FromArgb(a, r, g, B)));
        }
예제 #5
0
        private void sldSlidersChanged_ValueChanged(object sender, RangeBaseValueChangedEventArgs e)
        {
            int strokeThickness = (int)sldStrokeThickness.Value;

            tbStrokeThicknessValue.Text = strokeThickness.ToString();
            PocketPaintApplication.GetInstance().PaintData.strokeThickness = strokeThickness;

            if (PocketPaintApplication.GetInstance().BarRecEllShape != null)
            {
                if (PocketPaintApplication.GetInstance().ToolCurrent.GetToolType() == Tool.ToolType.Rect)
                {
                    PocketPaintApplication.GetInstance().RectangleSelectionControl.StrokeThicknessOfRectangleToDraw = strokeThickness;
                }
                else if (PocketPaintApplication.GetInstance().ToolCurrent.GetToolType() == Tool.ToolType.Ellipse)
                {
                    PocketPaintApplication.GetInstance().EllipseSelectionControl.StrokeThicknessOfEllipseToDraw = strokeThickness;
                }
                else
                {
                    PocketPaintApplication.GetInstance().ImportImageSelectionControl.setStrokeThicknessOfDrawingShape = strokeThickness;
                }
            }

            if (strokeThickness > 0)
            {
                btnSelectedBorderColor.IsEnabled = true;
            }
            else
            {
                btnSelectedBorderColor.IsEnabled = false;
            }
        }
예제 #6
0
        public ViewColorPicker()
        {
            this.InitializeComponent();
            PocketPaintApplication.GetInstance().ViewColorPicker      = this;
            PocketPaintApplication.GetInstance().InputHexValueControl = ctrlInputHexValueSelectionControl;
            Color  selected_color;
            double color_opacity;

            if (PocketPaintApplication.GetInstance().is_border_color&& PocketPaintApplication.GetInstance().PaintData.strokeColorSelected != null)
            {
                selected_color = ((SolidColorBrush)PocketPaintApplication.GetInstance().PaintData.strokeColorSelected).Color;
                color_opacity  = Convert.ToDouble(((SolidColorBrush)PocketPaintApplication.GetInstance().PaintData.strokeColorSelected).Color.A);

                changeValuesOfColourSliders(selected_color.R, selected_color.G, selected_color.B, (byte)color_opacity);
                changeColorOfBtnSelectedColor(selected_color);
            }
            else if (!PocketPaintApplication.GetInstance().is_border_color&& PocketPaintApplication.GetInstance().PaintData.colorSelected != null)
            {
                selected_color = ((SolidColorBrush)PocketPaintApplication.GetInstance().PaintData.colorSelected).Color;
                color_opacity  = Convert.ToDouble(((SolidColorBrush)PocketPaintApplication.GetInstance().PaintData.colorSelected).Color.A);

                changeValuesOfColourSliders(selected_color.R, selected_color.G, selected_color.B, (byte)color_opacity);
                changeColorOfBtnSelectedColor(selected_color);
            }
            setColorPickerLayout();
        }
        public override void HandleUp(object arg)
        {
            if (PocketPaintApplication.GetInstance().cursorControl.isDrawingActivated())
            {
                if (!(arg is Point))
                {
                    return;
                }
                setHeightWidth();

                var coordinate = new Point(width + _transforms.Value.OffsetX, height + _transforms.Value.OffsetY);

                // only a point/dot is drawn, no movement of finger on screen
                if (_lastPoint.Equals(coordinate))
                {
                    var qbs = new QuadraticBezierSegment
                    {
                        Point1 = _lastPoint,
                        Point2 = coordinate
                    };

                    _pathSegmentCollection.Add(qbs);

                    PocketPaintApplication.GetInstance().PaintingAreaLayoutRoot.InvalidateMeasure();
                    _path.InvalidateArrange();
                }
                CommandManager.GetInstance().CommitCommand(new CursorCommand(_path));
            }
        }
예제 #8
0
        async public void fillSpace(Point coordinate, SolidColorBrush solidColorBrush)
        {
            try
            {
                PocketPaintApplication.GetInstance().ProgressRing.IsActive = true;
                PixelData.PixelData pixelData = new PixelData.PixelData();
                await pixelData.preparePaintingAreaCanvasPixel();

                Catrobat.Paint.WindowsPhone.Ui.Spinner.StartSpinning();
                if (pixelData.FloodFill4(coordinate, solidColorBrush) == false)
                {
                    return;
                }
                Catrobat.Paint.WindowsPhone.Ui.Spinner.StopSpinning();
                await pixelData.PixelBufferToBitmap();
            }
            catch (Exception exception)
            {
                System.Diagnostics.Debug.WriteLine(exception.StackTrace);
            }
            finally
            {
                Catrobat.Paint.WindowsPhone.Ui.Spinner.StopSpinning();
                PocketPaintApplication.GetInstance().ProgressRing.IsActive = false;
            }
        }
예제 #9
0
        public void CommitCommand(CommandBase command)
        {
            if (_undoCommands.Count == 0)
            {
                PocketPaintApplication.GetInstance().SaveAsWriteableBitmapToRam();
                var w = PocketPaintApplication.GetInstance().Bitmap.PixelWidth;
                var h = PocketPaintApplication.GetInstance().Bitmap.PixelHeight;
                _commandBitmapDict.Add(command, new WriteableBitmap(w, h));
            }

            if (HasNext())
            {
                _redoCommands.Clear();
                UndoRedoActionbarManager.GetInstance().Update(UndoRedoActionbarManager.UndoRedoButtonState.DisableRedo);
            }

            if (_undoCommands.Count != 0 && command is EraserCommand)
            {
                var c = _undoCommands.Last();
                if (c.ToolType != ToolType.Eraser)
                {
                    //PocketPaintApplication.GetInstance().SaveAsWriteableBitmapToRam();
                    // TODO: _commandBitmapDict.Add(command, new WriteableBitmap(PocketPaintApplication.GetInstance().Bitmap));
                    var w = PocketPaintApplication.GetInstance().Bitmap.PixelWidth;
                    var h = PocketPaintApplication.GetInstance().Bitmap.PixelHeight;
                    _commandBitmapDict.Add(command, new WriteableBitmap(w, h));
                }
            }

            _undoCommands.AddLast(command);
            UndoRedoActionbarManager.GetInstance().Update(UndoRedoActionbarManager.UndoRedoButtonState.EnableUndo);
            PocketPaintApplication.GetInstance().UnsavedChangesMade = true;
        }
        public override bool UnDo()
        {
            TransformGroup transformGroup = ((TransformGroup)PocketPaintApplication.GetInstance().PaintingAreaCanvas.RenderTransform);

            for (int i = 0; i < transformGroup.Children.Count; i++)
            {
                if (transformGroup.Children[i].GetType() == typeof(ScaleTransform))
                {
                    transformGroup.Children.RemoveAt(i);
                }
            }

            ScaleTransform defaultRenderTransform = new ScaleTransform();

            defaultRenderTransform.CenterX = _renderTransform.CenterX;
            defaultRenderTransform.CenterY = _renderTransform.CenterY;
            defaultRenderTransform.ScaleX  = 1;
            defaultRenderTransform.ScaleY  = 1;

            transformGroup.Children.Add(defaultRenderTransform);

            PocketPaintApplication.GetInstance().PaintingAreaCanvas.RenderTransform = transformGroup;
            PocketPaintApplication.GetInstance().PaintingAreaCanvas.UpdateLayout();
            PocketPaintApplication.GetInstance().PaintingAreaCanvas.InvalidateArrange();
            PocketPaintApplication.GetInstance().PaintingAreaCanvas.InvalidateMeasure();

            return(true);
        }
예제 #11
0
        public void FlipVertical()
        {
            var flipTransform = new ScaleTransform();

            if (PocketPaintApplication.GetInstance().angularDegreeOfWorkingSpaceRotation == 90 ||
                PocketPaintApplication.GetInstance().angularDegreeOfWorkingSpaceRotation == 270)
            {
                _flipX *= -1;
            }
            else
            {
                _flipY *= -1;
            }

            flipTransform.CenterY = DISPLAY_HEIGHT_HALF;
            flipTransform.CenterX = DISPLAY_WIDTH_HALF;

            flipTransform.ScaleY = _flipY;
            flipTransform.ScaleX = _flipX;

            PocketPaintApplication.GetInstance().flipX = this._flipX;
            PocketPaintApplication.GetInstance().flipY = this._flipY;

            PaintingAreaCanvasSettings(flipTransform);
            CommandManager.GetInstance().CommitCommand(new FlipCommand(flipTransform));
        }
        public void ResetRectangleShapeBaseControl()
        {
            GridMainSelection.Width  = m_DefaultGridMainSize;
            GridMainSelection.Height = m_DefaultGridMainSize;
            GridMainSelection.Margin = new Thickness(0.0, 0.0, 0.0, 0.0);

            MovementRectangle.Width  = m_DefaultRectangleForMovementSize;
            MovementRectangle.Height = m_DefaultRectangleForMovementSize;

            AreaToDrawGrid.Width  = m_DefaultAreaToDrawSize;
            AreaToDrawGrid.Height = m_DefaultAreaToDrawSize;
            PocketPaintApplication.GetInstance().BarRecEllShape.setBtnHeightValue = m_DefaultAreaToDrawSize;
            PocketPaintApplication.GetInstance().BarRecEllShape.setBtnWidthValue = m_DefaultAreaToDrawSize;

            m_TransformGridMain.Children.Clear();
            m_RotationAngle = 0;

            m_CenterPointRotation.X = GridMainSelection.Width / 2;
            m_CenterPointRotation.Y = GridMainSelection.Height / 2;

            ResetAppBarButtonRectangleSelectionControl(false);
            IsModifiedRectangleForMovement = false;

            // TODO: evaluate if the outcommented code is needed
            //PocketPaintApplication.GetInstance().PaintingAreaManipulationListener.lastPoint = new Point(0.0, 0.0);
            //RotateTransform rotate = new RotateTransform();
            //var angle = PocketPaintApplication.GetInstance().angularDegreeOfWorkingSpaceRotation;
            //rotate.Angle = -angle;
            //Point point = new Point(0.5, 0.5);
            //PocketPaintApplication.GetInstance().RectangleSelectionControl.RenderTransformOrigin = point;
            //PocketPaintApplication.GetInstance().RectangleSelectionControl.RenderTransform = rotate;

            //PocketPaintApplication.GetInstance().EllipseSelectionControl.RenderTransformOrigin = point;
            //PocketPaintApplication.GetInstance().EllipseSelectionControl.RenderTransform = rotate;
        }
예제 #13
0
        async public override void HandleDown(object arg)
        {
            if (!(arg is Point))
            {
                return;
            }
            _lastPointSet = false;
            points        = new List <Point>();
            var coordinate = (Point)arg;
            await pixelData.preparePaintingAreaCanvasPixel();

            initPathInstances();
            initPathStrokeSettings();

            _pathFigure.StartPoint = coordinate;
            _pathFigure.Segments   = _pathSegmentCollection;
            _pathFigureCollection.Add(_pathFigure);
            _pathGeometry.Figures = _pathFigureCollection;
            _lastPoint            = coordinate;
            _path.Data            = _pathGeometry;

            PocketPaintApplication.GetInstance().PaintingAreaView.addElementToEraserCanvas(_path);

            var rectangleGeometry = new RectangleGeometry
            {
                Rect = new Rect(0, 0, PocketPaintApplication.GetInstance().PaintingAreaCanvas.ActualWidth,
                                PocketPaintApplication.GetInstance().PaintingAreaCanvas.ActualHeight)
            };

            _path.Clip = rectangleGeometry;
            _path.InvalidateArrange();
            _path.InvalidateMeasure();
        }
        private void setToolPickerLayout()
        {
            var height = PocketPaintApplication.GetInstance().size_height_multiplication;
            var width  = PocketPaintApplication.GetInstance().size_width_multiplication;

            GrdToolPickerButtonInner.Width *= width;
            GrdToolPickerButtonOuter.Width *= width;
            foreach (Object obj in GrdToolPickerButtonInner.Children)
            {
                if (obj.GetType() == typeof(Button))
                {
                    ((Button)obj).Height *= height;
                    ((Button)obj).Width  *= width;

                    ((Button)obj).Margin = new Thickness(
                        ((Button)obj).Margin.Left * width,
                        ((Button)obj).Margin.Top * height,
                        ((Button)obj).Margin.Right * width,
                        ((Button)obj).Margin.Bottom * height);

                    ((Button)obj).Padding = new Thickness(
                        ((Button)obj).Padding.Left * width,
                        ((Button)obj).Padding.Top * height,
                        ((Button)obj).Padding.Right * width,
                        ((Button)obj).Padding.Bottom * height);

                    ((Button)obj).FontSize *= height;
                }
            }
        }
        public async Task <bool> WriteBitmapToPngMediaLibrary(string filename)
        {
            //Canvas tempCanvas = PocketPaintApplication.GetInstance().PaintingAreaCanvas;
            //Size canvasSize = tempCanvas.RenderSize;
            //Point defaultPoint = tempCanvas.RenderTransformOrigin;

            PocketPaintApplication.GetInstance().PaintingAreaCanvas.Measure(PocketPaintApplication.GetInstance().PaintingAreaCanvas.RenderSize);
            PocketPaintApplication.GetInstance().PaintingAreaCanvas.UpdateLayout();
            PocketPaintApplication.GetInstance().PaintingAreaCanvas.Arrange(new Rect(new Point(0, 0), PocketPaintApplication.GetInstance().PaintingAreaCanvas.RenderSize));

            RenderTargetBitmap retarbi = new RenderTargetBitmap();
            await retarbi.RenderAsync(PocketPaintApplication.GetInstance().PaintingAreaCanvas);

            Windows.Storage.Streams.IBuffer buffer = await(retarbi.GetPixelsAsync());
            var pixels = await retarbi.GetPixelsAsync();

            StorageFile outputFile = await KnownFolders.PicturesLibrary.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);

            using (var writeStream = await outputFile.OpenAsync(FileAccessMode.ReadWrite))
            {
                var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, writeStream);

                encoder.SetPixelData(BitmapPixelFormat.Bgra8,
                                     BitmapAlphaMode.Straight,
                                     (uint)retarbi.PixelWidth,
                                     (uint)retarbi.PixelHeight,
                                     DisplayInformation.GetForCurrentView().LogicalDpi,
                                     DisplayInformation.GetForCurrentView().LogicalDpi,
                                     pixels.ToArray());
                await encoder.FlushAsync();
            }
            return(true);
        }
        public override void HandleUp(object arg)
        {
            if (!(arg is Point))
            {
                return;
            }

            var coordinate = (Point)arg;

            // only a point/dot is drawn, no movement of finger on screen
            if (_lastPoint.Equals(coordinate))
            {
                var qbs = new QuadraticBezierSegment
                {
                    Point1 = _lastPoint,
                    Point2 = coordinate
                };

                _pathSegmentCollection.Add(qbs);

                PocketPaintApplication.GetInstance().PaintingAreaLayoutRoot.InvalidateMeasure();
                _path.InvalidateArrange();
            }
            CommandManager.GetInstance().CommitCommand(new BrushCommand(_path));
        }
예제 #17
0
        public override bool ReDo()
        {
            TransformGroup transformGroupWithAllKindOfTransforms = ((TransformGroup)PocketPaintApplication.GetInstance().GridWorkingSpace.RenderTransform);

            if (_transformGroup.Children.Count == 0)
            {
                transformGroupWithAllKindOfTransforms.Children.Clear();
                PocketPaintApplication.GetInstance().PaintingAreaView.alignPositionOfGridWorkingSpace(null);
                PocketPaintApplication.GetInstance().PaintingAreaView.changeEnableOfAppBarButtonResetZoom(false);
            }
            else
            {
                for (int i = 0; i < _transformGroup.Children.Count; i++)
                {
                    transformGroupWithAllKindOfTransforms.Children.Add(_transformGroup.Children[i]);
                }
                PocketPaintApplication.GetInstance().PaintingAreaView.changeEnableOfAppBarButtonResetZoom(true);
            }
            PocketPaintApplication.GetInstance().GridWorkingSpace.RenderTransform = transformGroupWithAllKindOfTransforms;
            PocketPaintApplication.GetInstance().GridWorkingSpace.UpdateLayout();
            PocketPaintApplication.GetInstance().GridWorkingSpace.InvalidateArrange();
            PocketPaintApplication.GetInstance().GridWorkingSpace.InvalidateMeasure();

            return(true);
        }
예제 #18
0
        public override bool UnDo()
        {
            TransformGroup transformGroup = ((TransformGroup)PocketPaintApplication.GetInstance().GridWorkingSpace.RenderTransform);

            for (int i = 0; i < transformGroup.Children.Count; i++)
            {
                if (transformGroup.Children[i].GetType() == typeof(TranslateTransform))
                {
                    transformGroup.Children.RemoveAt(i);
                }
            }

            double offsetX = transformGroup.Value.OffsetX;
            double offsetY = transformGroup.Value.OffsetY;

            var defaultTranslateTransform = new TranslateTransform();

            defaultTranslateTransform.X -= offsetX - 48;
            defaultTranslateTransform.Y -= offsetY - 69;

            transformGroup.Children.Add(defaultTranslateTransform);

            PocketPaintApplication.GetInstance().GridWorkingSpace.RenderTransform = transformGroup;
            PocketPaintApplication.GetInstance().GridWorkingSpace.UpdateLayout();
            PocketPaintApplication.GetInstance().GridWorkingSpace.InvalidateArrange();
            PocketPaintApplication.GetInstance().GridWorkingSpace.InvalidateMeasure();

            return(true);
        }
        public override void HandleMove(object arg)
        {
            if (!(arg is Point))
            {
                return;
            }

            var coordinate = (Point)arg;

            System.Diagnostics.Debug.WriteLine("BrushTool Coord: " + coordinate.X + " " + coordinate.Y);

            if (!_lastPointSet)
            {
                _lastPoint    = coordinate;
                _lastPointSet = true;
                return;
            }
            if (_lastPointSet && !_lastPoint.Equals(coordinate))
            {
                var qbs = new QuadraticBezierSegment
                {
                    Point1 = _lastPoint,
                    Point2 = coordinate
                };

                _pathSegmentCollection.Add(qbs);


                PocketPaintApplication.GetInstance().PaintingAreaLayoutRoot.InvalidateMeasure();
                _lastPointSet = false;
            }
        }
        public ImportImageSelectionControl()
        {
            this.InitializeComponent();

            GridEllCenterBottom.RenderTransform = _transformGridEllipsCenterBottom = new TransformGroup();
            GridEllCenterTop.RenderTransform    = _transfomrGridEllipseCenterTop = new TransformGroup();
            GridEllRightCenter.RenderTransform  = _transformGridEllipseRightCenter = new TransformGroup();
            GridEllLeftBottom.RenderTransform   = _transformGridEllipseLeftBottom = new TransformGroup();
            GridEllLeftCenter.RenderTransform   = _transformGridEllipseLeftCenter = new TransformGroup();
            GridEllLeftTop.RenderTransform      = _transformGridEllipseLeftTop = new TransformGroup();
            GridEllRightBottom.RenderTransform  = _transformGridEllipseRightBottom = new TransformGroup();
            GridEllRightTop.RenderTransform     = _transformGridEllipseRightTop = new TransformGroup();
            GridMain.RenderTransform            = _transformGridMain = new TransformGroup();
            rectRectangleToDraw.Fill            = PocketPaintApplication.GetInstance().PaintData.colorSelected;
            rectRectangleToDraw.Stroke          = PocketPaintApplication.GetInstance().PaintData.strokeColorSelected;
            rectRectangleToDraw.StrokeThickness = PocketPaintApplication.GetInstance().PaintData.strokeThickness;
            PocketPaintApplication.GetInstance().ImportImageSelectionControl = this;
            setIsModifiedRectangleMovement = false;

            ImageBrush fillBrush = new ImageBrush();

            fillBrush.ImageSource =
                new BitmapImage(
                    new Uri("ms-resource:/Files/Assets/logoPocketPaint.jpg", UriKind.Absolute)
                    );
            rectRectangleToDraw.Fill = fillBrush;
        }
        public void changeWidthOfDrawingSelection(double newWidth, bool changeTbValues)
        {
            double moveValue = newWidth - rectRectangleToDraw.Width;

            if ((rectRectangleForMovement.Width + moveValue) >= MIN_RECTANGLE_MOVE_WIDTH)
            {
                var moveX  = createTranslateTransform(moveValue, 0.0);
                var moveX2 = createTranslateTransform(moveValue / 2.0, 0.0);

                changeWidthOfUiElements(moveX.X);
                changeMarginRightOfUiElements(moveValue);

                setGridTransformsOfEllipses(moveX2, moveX2, moveX, null,
                                            null, null, moveX, moveX);
                if (changeTbValues)
                {
                    PocketPaintApplication.GetInstance().BarRecEllShape.setBtnHeightValue = rectRectangleToDraw.Height;
                    PocketPaintApplication.GetInstance().BarRecEllShape.setBtnWidthValue = rectRectangleToDraw.Width;
                }
                resetAppBarButtonRectangleSelectionControl(true);
                setIsModifiedRectangleMovement = true;
            }

            PocketPaintApplication.GetInstance().BarRecEllShape.updateSldStrokeThickness(Convert.ToInt32(rectRectangleToDraw.Height), Convert.ToInt32(rectRectangleToDraw.Width));
        }
예제 #22
0
 private void btnOK_Click(object sender, RoutedEventArgs e)
 {
     PocketPaintApplication.GetInstance().InfoxBasicBoxControl.Visibility = Visibility.Collapsed;
     PocketPaintApplication.GetInstance().InfoAboutAndConditionOfUseBox.Visibility = Visibility.Collapsed;
     PocketPaintApplication.GetInstance().PaintingAreaView.changeVisibilityOfAppBars(Visibility.Visible);
     PocketPaintApplication.GetInstance().PaintingAreaView.setActivityOfToolsControls(true);
 }
 public MoveZoomTool(bool zoom = true)
 {
     if (zoom)
     {
         ToolType = ToolType.Zoom;
     }
     else
     {
         ToolType = ToolType.Move;
     }
     ResetCanvas();
     if (PocketPaintApplication.GetInstance().GridWorkingSpace.RenderTransform.GetType() == typeof(TransformGroup))
     {
         _transforms = PocketPaintApplication.GetInstance().GridWorkingSpace.RenderTransform as TransformGroup;
     }
     if (_transforms == null)
     {
         PocketPaintApplication.GetInstance().GridWorkingSpace.RenderTransform = _transforms = new TransformGroup();
     }
     _tempTransforms     = new TransformGroup();
     DISPLAY_WIDTH_HALF  = PocketPaintApplication.GetInstance().GridWorkingSpace.ActualWidth / 2.0;
     DISPLAY_HEIGHT_HALF = PocketPaintApplication.GetInstance().GridWorkingSpace.ActualHeight / 2.0;
     startScale.X        = _transforms.Value.M11;
     startScale.Y        = _transforms.Value.M22;
 }
예제 #24
0
        private void setCursorControlLayout()
        {
            double heightMultiplicator = PocketPaintApplication.GetInstance().size_width_multiplication;
            double widthMultiplicator  = PocketPaintApplication.GetInstance().size_width_multiplication;

            GridMain.Width  *= widthMultiplicator;
            GridMain.Height *= heightMultiplicator;

            foreach (Object obj in GridMain.Children)
            {
                if (obj.GetType() == typeof(Button))
                {
                    Button currentButton = (Button)obj;
                    currentButton.Height *= heightMultiplicator;
                    currentButton.Width  *= widthMultiplicator;
                    Thickness currentButtonThickness = currentButton.BorderThickness;
                    currentButtonThickness.Bottom *= heightMultiplicator;
                    currentButtonThickness.Left   *= heightMultiplicator;
                    currentButtonThickness.Right  *= heightMultiplicator;
                    currentButtonThickness.Top    *= heightMultiplicator;
                    currentButton.BorderThickness  = currentButtonThickness;
                }
                else if (obj.GetType() == typeof(TextBox))
                {
                    TextBox currentTextbox = (TextBox)obj;
                    currentTextbox.Height *= heightMultiplicator;
                    currentTextbox.Width  *= widthMultiplicator;
                }
            }
        }
예제 #25
0
 public void PaintingAreaCanvasSettings(ScaleTransform renderTransform)
 {
     addFlipTransformToPaintingAreaView(renderTransform);
     PocketPaintApplication.GetInstance().PaintingAreaCanvas.UpdateLayout();
     PocketPaintApplication.GetInstance().PaintingAreaCanvas.InvalidateArrange();
     PocketPaintApplication.GetInstance().PaintingAreaCanvas.InvalidateMeasure();
 }
예제 #26
0
 public override void ResetDrawingSpace()
 {
     PocketPaintApplication.GetInstance().GridImportImageSelectionControl.Children.Clear();
     PocketPaintApplication.GetInstance().GridImportImageSelectionControl.Children.Add(new ImportImageSelectionControl());
     PocketPaintApplication.GetInstance().BarRecEllShape.setBtnHeightValue = 160.0;
     PocketPaintApplication.GetInstance().BarRecEllShape.setBtnWidthValue = 160.0;
     // TODO: David PocketPaintApplication.GetInstance().RectangleSelectionControl.isModifiedRectangleMovement = false;
 }
 public override bool ReDo()
 {
     if (!PocketPaintApplication.GetInstance().PaintingAreaCanvas.Children.Contains(Path))
     {
         PocketPaintApplication.GetInstance().PaintingAreaCanvas.Children.Add(Path);
     }
     return(true);
 }
 public override void ResetDrawingSpace()
 {
     _transforms.Children.Clear();
     PocketPaintApplication.GetInstance().PaintingAreaView.alignPositionOfGridWorkingSpace(null);
     // TODO: If you reset the working-space then it should be generated a removecommand
     // TODO: Write a ResetMoveZoomCommand
     CommandManager.GetInstance().CommitCommand(new ZoomCommand(new TransformGroup()));
 }
        public void TriangleButton_OnClick(object sender, RoutedEventArgs e)
        {
            var penLineCap = PenLineCap.Triangle;

            PocketPaintApplication.GetInstance().PaintData.penLineCapSelected = penLineCap;
            PocketPaintApplication.GetInstance().cursorControl.changeCursorType(penLineCap);
            checkAndSetPenLineCap(penLineCap);
        }
예제 #30
0
 private void initPathStrokeSettings()
 {
     _path.StrokeLineJoin     = PenLineJoin.Round;
     _path.Stroke             = new SolidColorBrush(Color.FromArgb(0xff, 0xff, 0xff, 0xff));
     _path.StrokeThickness    = PocketPaintApplication.GetInstance().PaintData.thicknessSelected;
     _path.StrokeStartLineCap = PocketPaintApplication.GetInstance().PaintData.penLineCapSelected;
     _path.StrokeEndLineCap   = PocketPaintApplication.GetInstance().PaintData.penLineCapSelected;
 }