Ejemplo n.º 1
0
        private void PreviewHandler(Action <PowerPoint.ShapeRange> previewAction, int minNoOfSelectedShapes)
        {
            Focus();
            _previewCallBack = delegate
            {
                var selectedShapes = GetSelectedShapes();

                ModifySelectionAspectRatio();
                Preview(selectedShapes, previewAction, minNoOfSelectedShapes);
                _isPreviewed = true;
            };
            if (IsPreviewKeyPressed())
            {
                _previewCallBack.Invoke();
            }
        }
Ejemplo n.º 2
0
        private void PreviewHandler(Action <PowerPoint.ShapeRange, float, float, bool> previewAction)
        {
            Focus();
            _previewCallBack = delegate
            {
                var selectedShapes = GetSelectedShapes();
                var slideWidth     = this.GetCurrentPresentation().SlideWidth;
                var slideHeight    = this.GetCurrentPresentation().SlideHeight;

                ModifySelectionAspectRatio();
                Preview(selectedShapes, slideWidth, slideHeight, previewAction);
                _isPreviewed = true;
            };
            if (IsPreviewKeyPressed())
            {
                _previewCallBack.Invoke();
            }
        }
Ejemplo n.º 3
0
 private void Btn_MouseLeave(object sender, MouseEventArgs e)
 {
     TryReset();
     _previewCallBack = null;
 }
 private void SnapAwayButton_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
 {
     Action<List<Shape>> positionsAction = (shapes) => PositionsLabMain.SnapAway(shapes);
     _previewCallBack = delegate
     {
         ExecutePositionsAction(positionsAction, true);
     };
     PreviewHandler();
 }
        // Align right, bottom, vertical center, horizontal center
        public void ExecutePositionsAction(Action<PowerPoint.ShapeRange, float> positionsAction, float dimension, bool isPreview)
        {
            if (this.GetCurrentSelection().Type != PowerPoint.PpSelectionType.ppSelectionShapes)
            {
                if (!isPreview)
                {
                    ShowErrorMessageBox(ErrorMessageNoSelection);
                }
                return;
            }

            PowerPoint.ShapeRange simulatedShapes = null;

            try
            {
                var selectedShapes = this.GetCurrentSelection().ShapeRange;

                if (isPreview)
                {
                    SaveSelectedShapePositions(selectedShapes, allShapePos);
                }
                else
                {
                    UndoPreview();
                    _previewCallBack = null;
                    this.StartNewUndoEntry();
                }

                simulatedShapes = DuplicateShapes(selectedShapes);
                if (PositionsLabMain.AlignReference == PositionsLabMain.AlignReferenceObject.PowerpointDefaults)
                {
                    positionsAction.Invoke(selectedShapes, dimension);
                }
                else
                {
                    var simulatedPPShapes = ConvertShapeRangeToPPShapeList(simulatedShapes, 1);
                    var initialPositions = SaveOriginalPositions(simulatedPPShapes);

                    positionsAction.Invoke(simulatedShapes, dimension);

                    SyncShapes(selectedShapes, simulatedShapes, initialPositions);
                }
                if (isPreview)
                {
                    _previewIsExecuted = true;
                }
            }
            catch (Exception ex)
            {
                if (!isPreview)
                {
                    ShowErrorMessageBox(ex.Message, ex);
                }
            }
            finally
            {
                if (simulatedShapes != null)
                {
                    simulatedShapes.Delete();
                    GC.Collect();
                }
            }
        }
 private void DistributeCenterButton_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
 {
     var slideWidth = this.GetCurrentPresentation().SlideWidth;
     var slideHeight = this.GetCurrentPresentation().SlideHeight;
     Action<List<PPShape>, float, float> positionsAction = (shapes, width, height) => PositionsLabMain.DistributeCenter(shapes, width, height);
     _previewCallBack = delegate
     {
         ExecutePositionsAction(positionsAction, slideWidth, slideHeight, true);
     };
     PreviewHandler();
 }
 private void SwapPositionsButton_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
 {
     Action<List<PPShape>, bool> positionsAction = (shapes, isPreview) => PositionsLabMain.Swap(shapes, isPreview);
     _previewCallBack = delegate
     {
         ExecutePositionsAction(positionsAction, true, true);
     };
     PreviewHandler();
 }
 private void AdjoinHorizontalButton_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
 {
     PositionsLabMain.AdjoinWithoutAligning();
     Action<List<PPShape>> positionsAction = (shapes) => PositionsLabMain.AdjoinHorizontal(shapes);
     _previewCallBack = delegate
     {
         ExecutePositionsAction(positionsAction, true);
     };
     PreviewHandler();
 }
 private void AdjoinVerticalWithAlignButton_MouseEnter(object sender, MouseEventArgs e)
 {
     PositionsLabMain.AdjoinWithAligning();
     Action<List<PPShape>> positionsAction = (shapes) => PositionsLabMain.AdjoinVertical(shapes);
     _previewCallBack = delegate
     {
         ExecutePositionsAction(positionsAction, true);
     };
     PreviewHandler();
 }
 private void AlignTopButton_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
 {
     Action<PowerPoint.ShapeRange> positionsAction = shapes => PositionsLabMain.AlignTop(shapes);
     _previewCallBack = delegate
     {
         ExecutePositionsAction(positionsAction, true);
     };
     PreviewHandler();
 }
 private void AlignCenterButton_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
 {
     var slideHeight = this.GetCurrentPresentation().SlideHeight;
     var slideWidth = this.GetCurrentPresentation().SlideWidth;
     Action<PowerPoint.ShapeRange, float, float> positionsAction = (shapes, height, width) => PositionsLabMain.AlignCenter(shapes, height, width);
     _previewCallBack = delegate
     {
         ExecutePositionsAction(positionsAction, slideHeight, slideWidth, true);
     };
     PreviewHandler();
 }
 private void UndoPreview(object sender, System.Windows.Input.MouseEventArgs e)
 {
     UndoPreview();
     _previewCallBack = null;
 }
        public void ExecutePositionsAction(Action<List<Shape>> positionsAction, bool isPreview)
        {
            if (this.GetCurrentSelection().Type != PowerPoint.PpSelectionType.ppSelectionShapes)
            {
                if (!isPreview)
                {
                    ShowErrorMessageBox(ErrorMessageNoSelection);
                }
                return;
            }

            try
            {
                var selectedShapes = this.GetCurrentSelection().ShapeRange;

                if (isPreview)
                {
                    SaveSelectedShapePositions(selectedShapes, allShapePos);
                }
                else
                {
                    UndoPreview();
                    _previewCallBack = null;
                    this.StartNewUndoEntry();
                }

                positionsAction.Invoke(ConvertShapeRangeToShapeList(selectedShapes, 1));

                GC.Collect();

                if (isPreview)
                {
                    _previewIsExecuted = true;
                }
            }
            catch (Exception ex)
            {
                if (!isPreview)
                {
                    ShowErrorMessageBox(ex.Message, ex);
                }
            }
        }
        private void PreviewHandler(Action<PowerPoint.ShapeRange, float, float, bool> previewAction)
        {
            Focus();
            _previewCallBack = delegate
            {
                var selectedShapes = GetSelectedShapes();
                var slideWidth = this.GetCurrentPresentation().SlideWidth;
                var slideHeight = this.GetCurrentPresentation().SlideHeight;

                ModifySelectionAspectRatio();
                Preview(selectedShapes, slideWidth, slideHeight, previewAction);
                _isPreviewed = true;
            };
            if (IsPreviewKeyPressed())
            {
                _previewCallBack.Invoke();
            }
        }
        private void PreviewHandler(Action<PowerPoint.ShapeRange> previewAction, int minNoOfSelectedShapes)
        {
            Focus();
            _previewCallBack = delegate
            {
                var selectedShapes = GetSelectedShapes();

                ModifySelectionAspectRatio();
                Preview(selectedShapes, previewAction, minNoOfSelectedShapes);
                _isPreviewed = true;
            };
            if (IsPreviewKeyPressed())
            {
                _previewCallBack.Invoke();
            }
        }
 private void Btn_MouseLeave(object sender, MouseEventArgs e)
 {
     TryReset();
     _previewCallBack = null;
 }