public void SaveCanvasAsImage(string imageFileName)
        {
            double newWidth  = this._mainImage.Source.Width;
            double newHeight = this._mainImage.Source.Height;

            double widthAspectRatio  = newWidth / this._mainCanvas.ActualWidth;
            double heightAspectRatio = newHeight / this._mainCanvas.ActualHeight;

            PhotoCanvas saveCanvas = new PhotoCanvas(this._border, newWidth,
                                                     newHeight);

            saveCanvas.ChangeMainImage(this._mainImage.Source, false);

            foreach (InsetImage insetImage in this._imageDictionary.Values)
            {
                double newX = DynamicCanvas.GetLeft(insetImage.ImageCanvas) * widthAspectRatio;
                double newY = DynamicCanvas.GetTop(insetImage.ImageCanvas) * heightAspectRatio;

                double newImageWidth = insetImage.ImageCanvas.Width * widthAspectRatio;

                saveCanvas.AddInsetPhoto(insetImage.DisplayImage.Source, newImageWidth, this._border,
                                         newX, newY);
            }

            ImageUtils.SaveDynamicCanvas(saveCanvas._mainCanvas, 96, imageFileName);
        }
Example #2
0
        private void DragStarted()
        {
            _isDragging = true;
            var ui = (UIElement)MyVisualTreeHelper.GetParent <ContentPresenter>(_draggedDeviceVisual);

            _dragStartLeft = DynamicCanvas.GetLeft(ui);
            _dragStartTop  = DynamicCanvas.GetTop(ui);
            SelectElement(_draggedDeviceVisual);
            _overlayElement.IsDragging = true;
        }
Example #3
0
 internal static double GetLeft(UIElement element, PanelType panelType)
 {
     if (panelType == PanelType.Canvas)
     {
         return(Canvas.GetLeft(element));
     }
     else
     {
         return(DynamicCanvas.GetLeft(element));
     }
 }