Beispiel #1
0
 private void btnChangeHexValue_Click(object sender, RoutedEventArgs e)
 {
     PocketPaintApplication.GetInstance().InputHexValueControl.setInputHexValueTextbox(tbArgbValue.Text.Substring(2, 6));
     ctrlInputHexValueSelectionControl.Visibility = Visibility.Visible;
 }
Beispiel #2
0
        private void setUcRecEllLayout()
        {
            var heightMultiplicator = PocketPaintApplication.GetInstance().size_height_multiplication;
            var widthMultiplicator  = PocketPaintApplication.GetInstance().size_width_multiplication;

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

            foreach (Object obj in gridMain.Children.Concat(GrdSelecectedBorderColor.Children.Concat(GrdSelectedFillColor.Children)))
            {
                if (obj.GetType() == typeof(TextBox))
                {
                    TextBox currentTextBox = ((TextBox)obj);
                    currentTextBox.Height *= heightMultiplicator;
                    currentTextBox.Width  *= widthMultiplicator;

                    currentTextBox.Margin = new Thickness(
                        currentTextBox.Margin.Left * widthMultiplicator,
                        currentTextBox.Margin.Top * heightMultiplicator,
                        currentTextBox.Margin.Right * widthMultiplicator,
                        currentTextBox.Margin.Bottom * heightMultiplicator);

                    currentTextBox.FontSize *= heightMultiplicator;
                }
                else if (obj.GetType() == typeof(Button))
                {
                    Button currentButton = ((Button)obj);
                    currentButton.Height *= heightMultiplicator;
                    currentButton.Width  *= widthMultiplicator;

                    currentButton.Margin = new Thickness(
                        currentButton.Margin.Left * widthMultiplicator,
                        currentButton.Margin.Top * heightMultiplicator,
                        currentButton.Margin.Right * widthMultiplicator,
                        currentButton.Margin.Bottom * heightMultiplicator);

                    currentButton.FontSize *= heightMultiplicator;
                }
                else if (obj.GetType() == typeof(Rectangle))
                {
                    Rectangle currentRectangle = ((Rectangle)(obj));
                    currentRectangle.Height *= heightMultiplicator;
                    currentRectangle.Width  *= widthMultiplicator;

                    currentRectangle.Margin = new Thickness(
                        currentRectangle.Margin.Left * widthMultiplicator,
                        currentRectangle.Margin.Top * heightMultiplicator,
                        currentRectangle.Margin.Right * widthMultiplicator,
                        currentRectangle.Margin.Bottom * heightMultiplicator);
                }
                else if (obj.GetType() == typeof(Slider))
                {
                    Slider currentSlider = ((Slider)(obj));
                    currentSlider.Height *= heightMultiplicator;
                    currentSlider.Width  *= widthMultiplicator;

                    currentSlider.Margin = new Thickness(
                        currentSlider.Margin.Left * widthMultiplicator,
                        currentSlider.Margin.Top * heightMultiplicator,
                        currentSlider.Margin.Right * widthMultiplicator,
                        currentSlider.Margin.Bottom * heightMultiplicator);
                }
                else if (obj.GetType() == typeof(Image))
                {
                    Image currentImage = ((Image)obj);
                    currentImage.Height *= heightMultiplicator;
                    currentImage.Width  *= widthMultiplicator;
                }
            }

            btnSelectedBorderColor.Background = PocketPaintApplication.GetInstance().PaintData.strokeColorSelected;
        }
Beispiel #3
0
        private void setColorPickerLayout()
        {
            var height = PocketPaintApplication.GetInstance().size_height_multiplication;
            var width  = PocketPaintApplication.GetInstance().size_width_multiplication;

            foreach (Object obj in GridColorButtons.Children.Concat(GridColorSlider.Children))
            {
                if (obj.GetType() == typeof(Button))
                {
                    Button currentButton = ((Button)obj);
                    currentButton.Height *= height;
                    currentButton.Width  *= width;

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

                    currentButton.FontSize *= height;

                    if (currentButton.Content != null && currentButton.Content.GetType() == typeof(Rectangle))
                    {
                        Rectangle currentRectangle = ((Rectangle)(currentButton.Content));
                        currentRectangle.Height *= height;
                        currentRectangle.Width  *= width;

                        currentRectangle.Margin = new Thickness(
                            currentRectangle.Margin.Left * width,
                            currentRectangle.Margin.Top * height,
                            currentRectangle.Margin.Right * width,
                            currentRectangle.Margin.Bottom * height);
                    }
                }
                else if (obj.GetType() == typeof(ColorPicker))
                {
                    ColorPicker colorPicker = ((ColorPicker)obj);
                    colorPicker.Height *= height;
                    colorPicker.Margin  = new Thickness(
                        colorPicker.Margin.Left * width,
                        colorPicker.Margin.Top * height,
                        colorPicker.Margin.Right * width,
                        colorPicker.Margin.Bottom * height);
                    colorPicker.Width *= width;
                }
                else if (obj.GetType() == typeof(Slider))
                {
                    Slider currentSlider = ((Slider)obj);
                    currentSlider.Width *= width;

                    currentSlider.Margin = new Thickness(
                        currentSlider.Margin.Left * width,
                        currentSlider.Margin.Top * height,
                        currentSlider.Margin.Right * width,
                        currentSlider.Margin.Bottom * height);
                }
                else if (obj.GetType() == typeof(TextBox))
                {
                    TextBox currentTextBox = ((TextBox)obj);
                    currentTextBox.Height *= height;
                    currentTextBox.Width  *= width;

                    currentTextBox.Margin = new Thickness(
                        currentTextBox.Margin.Left * width,
                        currentTextBox.Margin.Top * height,
                        currentTextBox.Margin.Right * width,
                        currentTextBox.Margin.Bottom * height);
                    currentTextBox.FontSize *= height;
                }
            }
            GrdButtonSelectedColor.Height *= height;
            GrdButtonSelectedColor.Width  *= width;

            ImgPredColorTransp.Height *= height;
            ImgPredColorTransp.Width  *= width;

            ImgTransparence.Height *= height;
            ImgTransparence.Width  *= width;
            ImgTransparence.Margin  = new Thickness(
                ImgTransparence.Margin.Left * width,
                ImgTransparence.Margin.Top * height,
                ImgTransparence.Margin.Right * width,
                ImgTransparence.Margin.Bottom * height);

            RecSelectedColor.Height *= height;
            RecSelectedColor.Width  *= width;
            RecSelectedColor.Margin  = new Thickness(
                RecSelectedColor.Margin.Left * width,
                RecSelectedColor.Margin.Top * height,
                RecSelectedColor.Margin.Right * width,
                RecSelectedColor.Margin.Bottom * height);

            TbFertig.Height *= height;
            TbFertig.Width  *= width;
            TbFertig.Margin  = new Thickness(
                TbFertig.Margin.Left * width,
                TbFertig.Margin.Top * height,
                TbFertig.Margin.Right * width,
                TbFertig.Margin.Bottom * height);
            TbFertig.FontSize *= height;
        }
 public override void ResetDrawingSpace()
 {
     PocketPaintApplication.GetInstance().EllipseSelectionControl.resetEllipseSelectionControl();
 }
Beispiel #5
0
        public override void ResetDrawingSpace()
        {
            var rotateTransform = new RotateTransform();

            PocketPaintApplication.GetInstance().angularDegreeOfWorkingSpaceRotation = 0;

            rotateTransform.Angle   = PocketPaintApplication.GetInstance().angularDegreeOfWorkingSpaceRotation;
            rotateTransform.CenterX = (PocketPaintApplication.GetInstance().GridWorkingSpace.Width) / 2;
            rotateTransform.CenterY = ((PocketPaintApplication.GetInstance().GridWorkingSpace.Height) / 2);
            PocketPaintApplication.GetInstance().PaintingAreaView.alignPositionOfGridWorkingSpace(null);
            PocketPaintApplication.GetInstance().PaintingAreaView.enableResetButtonRotate(PocketPaintApplication.GetInstance().PaintingAreaView.getRotationCounter() * (-1));
        }
        public bool FloodFill8(Point p, SolidColorBrush color)
        {
            try
            {
                string newColor = ColorToString(color);
                if (PocketPaintApplication.GetInstance().Bitmap == null)
                {
                    PocketPaintApplication.GetInstance().SaveAsWriteableBitmapToRam();
                }
                p = ConvertCoordinates(p);
                string oldColor = getPixelFromCanvas(p);
                if (oldColor == newColor)
                {
                    return(false);
                }

                Stack <Point> list = new Stack <Point>();
                list.Push(p);
                while (list.Count > 0)
                {
                    var p2 = list.Pop();
                    SetPixel(p2, newColor);
                    //left
                    if (p2.X > 1)
                    {
                        if (getPixelFromCanvas(new Point(p2.X - 1, p2.Y)) == oldColor)
                        {
                            list.Push(new Point(p2.X - 1, p2.Y));
                        }
                    }
                    //right
                    if (p2.X < pixelWidthCanvas)
                    {
                        if (getPixelFromCanvas(new Point(p2.X + 1, p2.Y)) == oldColor)
                        {
                            list.Push(new Point(p2.X + 1, p2.Y));
                        }
                    }
                    //above
                    if (p2.Y > 1)
                    {
                        if (getPixelFromCanvas(new Point(p2.X, p2.Y - 1)) == oldColor)
                        {
                            list.Push(new Point(p2.X, p2.Y - 1));
                        }
                    }
                    //below
                    if (p2.Y < pixelHeightCanvas)
                    {
                        if (getPixelFromCanvas(new Point(p2.X, p2.Y + 1)) == oldColor)
                        {
                            list.Push(new Point(p2.X, p2.Y + 1));
                        }
                    }
                    //left-above
                    if (p2.X > 1 && p2.Y > 1)
                    {
                        if (getPixelFromCanvas(new Point(p2.X - 1, p2.Y - 1)) == oldColor)
                        {
                            list.Push(new Point(p2.X - 1, p2.Y - 1));
                        }
                    }
                    //right-below
                    if (p2.X > 1 && p2.Y < pixelHeightCanvas)
                    {
                        if (getPixelFromCanvas(new Point(p2.X - 1, p2.Y + 1)) == oldColor)
                        {
                            list.Push(new Point(p2.X - 1, p2.Y + 1));
                        }
                    }
                    //right-above
                    if (p2.Y > 1 && p2.X < pixelWidthCanvas)
                    {
                        if (getPixelFromCanvas(new Point(p2.X + 1, p2.Y - 1)) == oldColor)
                        {
                            list.Push(new Point(p2.X + 1, p2.Y - 1));
                        }
                    }
                    //right-below
                    if (p2.X < pixelWidthCanvas && p2.Y < pixelHeightCanvas)
                    {
                        if (getPixelFromCanvas(new Point(p2.X + 1, p2.Y + 1)) == oldColor)
                        {
                            list.Push(new Point(p2.X + 1, p2.Y + 1));
                        }
                    }
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Beispiel #7
0
        public void ToolChangedHere(ToolBase tool)
        {
            ImageBrush img_front  = new ImageBrush();
            ImageBrush img_behind = new ImageBrush();

            img_behind.ImageSource = new BitmapImage(
                new Uri("ms-resource:/Files/Assets/ToolMenu/icon_menu_move.png", UriKind.Absolute));

            Visibility currentStateOfGridThicknessControl = PocketPaintApplication.GetInstance().GrdThicknessControlState;

            PocketPaintApplication.GetInstance().PaintingAreaView.GrdThicknessControlVisibility = Visibility.Collapsed;

            if (tool.GetToolType() == ToolType.Eraser && PocketPaintApplication.GetInstance().isBrushEraser == true)
            {
                tool = new BrushTool();
            }
            else
            {
                if (PocketPaintApplication.GetInstance().isToolPickerUsed)
                {
                    PocketPaintApplication.GetInstance().isBrushEraser = false;
                }
            }

            switch (tool.GetToolType())
            {
            case ToolType.Brush:
                img_front.ImageSource = new BitmapImage(GetToolImageUri(ToolType.Brush));
                PocketPaintApplication.GetInstance().PaintingAreaView.GrdThicknessControlVisibility
                    = currentStateOfGridThicknessControl;
                break;

            case ToolType.Crop:
                img_front.ImageSource = new BitmapImage(GetToolImageUri(ToolType.Crop));
                PocketPaintApplication.GetInstance().PaintingAreaView.GrdThicknessControlVisibility
                    = currentStateOfGridThicknessControl;
                break;

            case ToolType.Cursor:
                img_front.ImageSource = new BitmapImage(GetToolImageUri(ToolType.Cursor));
                break;

            case ToolType.Ellipse:
                img_front.ImageSource = new BitmapImage(GetToolImageUri(ToolType.Ellipse));
                break;

            case ToolType.Eraser:
                img_front.ImageSource = new BitmapImage(GetToolImageUri(ToolType.Eraser));
                break;

            case ToolType.Fill:
                img_front.ImageSource = new BitmapImage(GetToolImageUri(ToolType.Fill));
                PocketPaintApplication.GetInstance().PaintingAreaView.GrdThicknessControlVisibility
                    = currentStateOfGridThicknessControl;
                break;

            case ToolType.Flip:
                img_front.ImageSource = new BitmapImage(GetToolImageUri(ToolType.Flip));
                break;

            case ToolType.ImportPng:
                img_front.ImageSource = new BitmapImage(GetToolImageUri(ToolType.ImportPng));
                PocketPaintApplication.GetInstance().PaintingAreaView.GrdThicknessControlVisibility
                    = currentStateOfGridThicknessControl;
                break;

            case ToolType.Line:
                img_front.ImageSource = new BitmapImage(GetToolImageUri(ToolType.Line));
                PocketPaintApplication.GetInstance().PaintingAreaView.GrdThicknessControlVisibility
                    = currentStateOfGridThicknessControl;
                break;

            case ToolType.Move:
                img_front.ImageSource  = new BitmapImage(GetToolImageUri(ToolType.Move));
                img_behind.ImageSource = new BitmapImage(
                    GetToolImageUri(PocketPaintApplication.GetInstance().ToolWhileMoveTool.GetToolType()));
                break;

            case ToolType.Pipette:
                img_front.ImageSource = new BitmapImage(GetToolImageUri(ToolType.Pipette));
                break;

            case ToolType.Rect:
                img_front.ImageSource = new BitmapImage(GetToolImageUri(ToolType.Rect));
                break;

            case ToolType.Rotate:
                img_front.ImageSource = new BitmapImage(GetToolImageUri(ToolType.Rotate));
                break;

            case ToolType.Stamp:
                img_front.ImageSource = new BitmapImage(GetToolImageUri(ToolType.Stamp));
                break;

            case ToolType.Zoom:
                img_front.ImageSource = new BitmapImage(GetToolImageUri(ToolType.Zoom));
                break;

            default:
                // TODO: BtnMoveScreen.ImageSource = null;
                // TODO: BtnMoveScreen.Background = null;
                break;
            }

            ellipseTool_behind.Opacity = 0.1;
            ellipseTool_behind.Fill    = img_behind;
            ellipseTool_front.Fill     = img_front;
        }
Beispiel #8
0
        private void rectRectangleForMovement_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
        {
            Point centerCoordinate = getCenterCoordinateOfGridMain();

            PocketPaintApplication.GetInstance().ToolCurrent.Draw(centerCoordinate);
        }
 public void app_btnResetCursor_Click(object sender, RoutedEventArgs e)
 {
     ((AppBarButton)sender).IsEnabled = false;
     PocketPaintApplication.GetInstance().GridCursor.RenderTransform = _transforms = new TransformGroup();
 }
        public async override void HandleUp(object arg)
        {
            if (!(arg is Point))
            {
                return;
            }
            Point coordinates = (Point)arg;

            PixelData.PixelData myPixelData = new PixelData.PixelData();
            PocketPaintApplication.GetInstance().PaintData.colorSelected = await myPixelData.GetPixel(PocketPaintApplication.GetInstance().Bitmap, (int)coordinates.X, (int)coordinates.Y);


            //PocketPaintApplication.GetInstance().PaintData.ColorSelected =
            //  new SolidColorBrush(PocketPaintApplication.GetInstance().Bitmap.);
        }
Beispiel #11
0
 public void setSizeOfRecBar(double height, double width)
 {
     PocketPaintApplication.GetInstance().BarRecEllShape.setBtnHeightValue = height;
     PocketPaintApplication.GetInstance().BarRecEllShape.setBtnWidthValue = width;
 }
 public override bool ReDo()
 {
     ((FillTool)PocketPaintApplication.GetInstance().ToolCurrent).fillSpace(_coordinate, _solidColorBrush);
     return(true);
 }
Beispiel #13
0
        private void addRotationToCommandManager(RotateTransform rotateTransform, int rotationDirection)
        {
            TransformGroup rotationTransformGroupForCommand = new TransformGroup();

            rotationTransformGroupForCommand.Children.Add(rotateTransform);
            CommandManager.GetInstance().CommitCommand(new RotateCommand(rotationTransformGroupForCommand, PocketPaintApplication.GetInstance().angularDegreeOfWorkingSpaceRotation, rotationDirection));
        }
Beispiel #14
0
        public void RotateRight()
        {
            int rotationAngle = 90;

            proofBoundariesOfAngle(rotationAngle);
            RotateTransform rtRotationGridWorkingSpace = PocketPaintApplication.GetInstance().PaintingAreaView.CreateRotateTransform(PocketPaintApplication.GetInstance().angularDegreeOfWorkingSpaceRotation,
                                                                                                                                     new Point(PocketPaintApplication.GetInstance().GridWorkingSpace.Width / 2.0, PocketPaintApplication.GetInstance().GridWorkingSpace.Height / 2.0));

            PocketPaintApplication.GetInstance().PaintingAreaView.alignPositionOfGridWorkingSpace(rtRotationGridWorkingSpace);
            addRotationToCommandManager(rtRotationGridWorkingSpace, 1);
        }
Beispiel #15
0
        public override bool UnDo()
        {
            TransformGroup paintingAreaCheckeredTransformGroup = ((TransformGroup)PocketPaintApplication.GetInstance().GridWorkingSpace.RenderTransform);

            paintingAreaCheckeredTransformGroup.Children.Clear();

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

            PocketPaintApplication.GetInstance().angularDegreeOfWorkingSpaceRotation -= _angle;
            PocketPaintApplication.GetInstance().PaintingAreaView.alignPositionOfGridWorkingSpace(null);
            PocketPaintApplication.GetInstance().PaintingAreaView.enableResetButtonRotate(PocketPaintApplication.GetInstance().PaintingAreaView.getRotationCounter() * (-1));
            return(true);
        }
 public void setHeightWidth()
 {
     height = PocketPaintApplication.GetInstance().GridWorkingSpace.ActualHeight / 2.0;
     width  = PocketPaintApplication.GetInstance().GridWorkingSpace.ActualWidth / 2.0;
 }
        public bool FloodFill4(Point coordinate, SolidColorBrush color)
        {
            try
            {
                if (color.Color.A == 0)
                {
                    color = new SolidColorBrush(Color.FromArgb(0x00, 0x00, 0x00, 0x00));
                }

                if (PocketPaintApplication.GetInstance().Bitmap == null)
                {
                    PocketPaintApplication.GetInstance().SaveAsWriteableBitmapToRam();
                }

                string newColor = ColorToString(color);
                coordinate = ConvertCoordinates(coordinate);

                string oldColor = getPixelFromCanvas(coordinate);
                if (oldColor == newColor)
                {
                    return(false);
                }

                Stack <Point> stackWithCoordinates = new Stack <Point>();
                stackWithCoordinates.Push(coordinate);
                while (stackWithCoordinates.Count > 0)
                {
                    var currentCoordinate = stackWithCoordinates.Pop();
                    SetPixel(currentCoordinate, newColor);

                    if (currentCoordinate.X > 1)
                    {
                        if (ComparePixelsColorForFloddFill(new Point(currentCoordinate.X - 1, currentCoordinate.Y), oldColor))
                        {
                            stackWithCoordinates.Push(new Point(currentCoordinate.X - 1, currentCoordinate.Y));
                        }
                    }

                    if (currentCoordinate.X < pixelWidthCanvas)
                    {
                        if (ComparePixelsColorForFloddFill(new Point(currentCoordinate.X + 1, currentCoordinate.Y), oldColor))
                        {
                            stackWithCoordinates.Push(new Point(currentCoordinate.X + 1, currentCoordinate.Y));
                        }
                    }

                    if (currentCoordinate.Y > 1)
                    {
                        if (ComparePixelsColorForFloddFill(new Point(currentCoordinate.X, currentCoordinate.Y - 1), oldColor))
                        {
                            stackWithCoordinates.Push(new Point(currentCoordinate.X, currentCoordinate.Y - 1));
                        }
                    }

                    if (currentCoordinate.Y < pixelHeightCanvas)
                    {
                        if (ComparePixelsColorForFloddFill(new Point(currentCoordinate.X, currentCoordinate.Y + 1), oldColor))
                        {
                            stackWithCoordinates.Push(new Point(currentCoordinate.X, currentCoordinate.Y + 1));
                        }
                    }
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
 public override void ResetUsedElements()
 {
     PocketPaintApplication.GetInstance().GridCursor.RenderTransform = _transforms = new TransformGroup();
     PocketPaintApplication.GetInstance().cursorControl.setCursorLook(false);
 }
        public async Task <bool> PixelBufferToBitmap()
        {
            try
            {
                var bitmapPixels    = ConvertArray(pixelsCanvas, pixelWidthCanvas, pixelHeightCanvas);
                var wbCroppedBitmap = new WriteableBitmap(PocketPaintApplication.GetInstance().Bitmap.PixelWidth, PocketPaintApplication.GetInstance().Bitmap.PixelHeight);
                await wbCroppedBitmap.PixelBuffer.AsStream().WriteAsync(bitmapPixels, 0, bitmapPixels.Length);

                Image image = new Image();
                image.Source = wbCroppedBitmap;
                image.Height = wbCroppedBitmap.PixelHeight;
                image.Width  = wbCroppedBitmap.PixelWidth;
                PocketPaintApplication.GetInstance().PaintingAreaCanvas.Children.Clear();
                PocketPaintApplication.GetInstance().PaintingAreaCanvas.Children.Add(image);
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
 public override bool ReDo()
 {
     PocketPaintApplication.GetInstance().CropControl.CropImageForCropCommand(offsetX, offsetY, heightOfCroppedWorkingSpace, widthOfCroppedWorkingSpace);
     return(true);
 }
Beispiel #21
0
        private void setAppBarTopLayout()
        {
            double width_multiplicator  = PocketPaintApplication.GetInstance().size_width_multiplication;
            double height_multiplicator = PocketPaintApplication.GetInstance().size_width_multiplication;

            GrdLayoutRoot.Width  *= width_multiplicator;
            GrdLayoutRoot.Height *= height_multiplicator;

            foreach (Object obj in GrdLayoutRoot.Children)
            {
                if (obj.GetType() == typeof(AppBarButton))
                {
                    ((AppBarButton)obj).Height *= height_multiplicator;
                    ((AppBarButton)obj).Width  *= width_multiplicator;

                    ((AppBarButton)obj).Margin = new Thickness(
                        ((AppBarButton)obj).Margin.Left * width_multiplicator,
                        ((AppBarButton)obj).Margin.Top * height_multiplicator,
                        ((AppBarButton)obj).Margin.Right * width_multiplicator,
                        ((AppBarButton)obj).Margin.Bottom * height_multiplicator);
                }
                else if (obj.GetType() == typeof(Button))
                {
                    ((Button)obj).Height *= height_multiplicator;
                    ((Button)obj).Width  *= width_multiplicator;

                    ((Button)obj).Margin = new Thickness(
                        ((Button)obj).Margin.Left * width_multiplicator,
                        ((Button)obj).Margin.Top * height_multiplicator,
                        ((Button)obj).Margin.Right * width_multiplicator,
                        ((Button)obj).Margin.Bottom * height_multiplicator);
                }
                else if (obj.GetType() == typeof(Ellipse))
                {
                    ((Ellipse)obj).Height *= height_multiplicator;
                    ((Ellipse)obj).Width  *= width_multiplicator;

                    ((Ellipse)obj).Margin = new Thickness(
                        ((Ellipse)obj).Margin.Left * width_multiplicator,
                        ((Ellipse)obj).Margin.Top * height_multiplicator,
                        ((Ellipse)obj).Margin.Right * width_multiplicator,
                        ((Ellipse)obj).Margin.Bottom * height_multiplicator);
                }
                else if (obj.GetType() == typeof(Rectangle))
                {
                    ((Rectangle)obj).Height *= height_multiplicator;
                    ((Rectangle)obj).Width  *= width_multiplicator;

                    ((Rectangle)obj).Margin = new Thickness(
                        ((Rectangle)obj).Margin.Left * width_multiplicator,
                        ((Rectangle)obj).Margin.Top * height_multiplicator,
                        ((Rectangle)obj).Margin.Right * width_multiplicator,
                        ((Rectangle)obj).Margin.Bottom * height_multiplicator);
                }
            }

            ImgTransparence.Width  *= width_multiplicator;
            ImgTransparence.Height *= height_multiplicator;
            ImgTransparence.Margin  = new Thickness(
                ImgTransparence.Margin.Left * width_multiplicator,
                ImgTransparence.Margin.Top * height_multiplicator,
                ImgTransparence.Margin.Right * width_multiplicator,
                ImgTransparence.Margin.Bottom * height_multiplicator);

            RecSelectedColor.Width  *= width_multiplicator;
            RecSelectedColor.Height *= height_multiplicator;
            RecSelectedColor.Margin  = new Thickness(
                RecSelectedColor.Margin.Left * width_multiplicator,
                RecSelectedColor.Margin.Top * height_multiplicator,
                RecSelectedColor.Margin.Right * width_multiplicator,
                RecSelectedColor.Margin.Bottom * height_multiplicator);

            GrdBtnSelectedColor.Height *= height_multiplicator;
            GrdBtnSelectedColor.Width  *= width_multiplicator;

            BtnSelectedColor.Background = PocketPaintApplication.GetInstance().PaintData.colorSelected;
            PocketPaintApplication.GetInstance().PaintData.colorChanged += ColorChangedHere;
            PocketPaintApplication.GetInstance().PaintData.toolCurrentChanged += ToolChangedHere;
            this.GrdLayoutRoot.Background = new SolidColorBrush(Color.FromArgb(255, 25, 165, 184));
            PocketPaintApplication.GetInstance().AppbarTop = this;


            BtnUndo.Click          += PocketPaintApplication.GetInstance().ApplicationBarListener.BtnUndo_Click;
            BtnRedo.Click          += PocketPaintApplication.GetInstance().ApplicationBarListener.BtnRedo_Click;
            BtnTools.Click         += PocketPaintApplication.GetInstance().ApplicationBarListener.BtnTools_OnClick;
            BtnSelectedColor.Click += PocketPaintApplication.GetInstance().ApplicationBarListener.BtnColor_Click;
            //btnMoveScreen.Click += PocketPaintApplication.GetInstance().ApplicationBarListener.BtnMoveScreen_OnClick;
            BtnToolSelection.Click += PocketPaintApplication.GetInstance().ApplicationBarListener.BtnMoveScreenEllipse_OnClick;
            BtnUndo.IsEnabled       = false;
            BtnRedo.IsEnabled       = false;
        }
Beispiel #22
0
 private void btnWidthValue_Click(object sender, RoutedEventArgs e)
 {
     PocketPaintApplication.GetInstance().GridInputScopeControl.Visibility = Visibility.Visible;
     PocketPaintApplication.GetInstance().InputScopeControl.setTextOfInputValue(btnWidthValue.Content.ToString());
     PocketPaintApplication.GetInstance().InputScopeControl.setCurrentButton = btnWidthValue;
 }
 public void CleanUp()
 {
     _sut = null;
     _app = null;
 }
        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);
        }