Exemplo n.º 1
0
        /// <summary>
        /// Constructor
        /// </summary>
        internal PrintImageBoxControl(PrintViewImageBox imageBox, Rectangle parentRectangle)
        {
            _imageBox = imageBox;

            this.ParentRectangle = parentRectangle;

            InitializeComponent();

            _imageScrollerVisible        = _imageScroller.Visible;
            _imageScroller.MouseDown    += ImageScrollerMouseDown;
            _imageScroller.MouseUp      += ImageScrollerMouseUp;
            _imageScroller.ValueChanged += ImageScrollerValueChanged;

            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.BackColor = Color.Black;
            this.Dock      = DockStyle.None;
            this.Anchor    = AnchorStyles.None;

            _imageBox.Drawing          += OnDrawing;
            _imageBox.SelectionChanged += OnImageBoxSelectionChanged;
            _imageBox.LayoutCompleted  += OnLayoutCompleted;
            this.Margin  = new Padding(0);
            this.Padding = new Padding(0);

            foreach (var extension in Extensions)
            {
                AttachExtension(extension);
            }
        }
        private void DeleteCurrentPage(object sender, EventArgs args)
        {
            if (this.Context.Viewer == null || this.Context.Viewer.SelectedImageBox == null || this.Context.Viewer.SelectedImageBox.DisplaySet == null)
            {
                return;
            }
            PrintViewImageBox imageBox = this.ImageViewer.SelectedImageBox as PrintViewImageBox;
            var memorableCommand       = new MemorableUndoableCommand(imageBox)
            {
                BeginState = CreateMemento()
            };
            var printImageViewer = Context.Viewer as PrintImageViewerComponent;

            foreach (PrintViewTile tile in imageBox.Tiles)
            {
                if (tile.PresentationImage == null)
                {
                    int number1 = imageBox.TotleImageCount - imageBox.DisplaySet.PresentationImages.Count;
                    if (number1 > 0)
                    {
                        imageBox.TotleImageCount = imageBox.TotleImageCount - 1;
                    }
                    tile.Deselect();
                    continue;
                }

                if (imageBox.DisplaySet.PresentationImages.Contains(tile.PresentationImage))
                {
                    if (printImageViewer.SelectPresentationImages.Contains(tile.PresentationImage as PresentationImage))
                    {
                        var pi = tile.PresentationImage as PresentationImage;
                        pi.Selected = false;
                        printImageViewer.SelectPresentationImages.Remove(pi);
                    }
                    imageBox.DisplaySet.PresentationImages.Remove(tile.PresentationImage);
                    //tile.PresentationImage.Dispose();
                    tile.PresentationImage = null;
                    tile.Deselect();
                }
            }

            imageBox.TopLeftPresentationImageIndex = imageBox.TopLeftPresentationImageIndex - imageBox.Tiles.Count;
            imageBox.Draw();
            imageBox.SelectDefaultTile();
            memorableCommand.EndState = CreateMemento();
            var historyCommand = new DrawableUndoableCommand(imageBox)
            {
                Name = SR.CommandPrintPreviewDeleteImage
            };

            historyCommand.Enqueue(memorableCommand);
            this.Context.Viewer.CommandHistory.AddCommand(historyCommand);
            PropertyChanged();
        }
Exemplo n.º 3
0
        private void AddTileControls(PrintViewImageBox imageBox)
        {
            this.SuspendLayout();

            foreach (PrintViewTile tile in imageBox.Tiles)
            {
                AddTileControl(tile);
            }

            // keep the image scroller at the forefront
            _imageScroller.BringToFront();

            this.ResumeLayout(false);
        }
        private void CreateEmptyPage(object sender, EventArgs args)
        {
            if (Context.Viewer.SelectedImageBox == null)
            {
                return;
            }

            PrintViewImageBox imageBox = Context.Viewer.SelectedImageBox as PrintViewImageBox;

            imageBox.TotleImageCount += imageBox.Tiles.Count;
            imageBox.TopLeftPresentationImageIndex = imageBox.TotleImageCount - imageBox.Tiles.Count;
            imageBox.Draw();
            imageBox.SelectDefaultTile();
        }
        private void AddImageBoxControl(PrintViewImageBox imageBox)
        {
            PrintImageBoxView view = ViewFactory.CreateAssociatedView(typeof(PrintViewImageBox)) as PrintImageBoxView;

            view.ImageBox        = imageBox;
            view.ParentRectangle = this._layoutImages.ClientRectangle;

            PrintImageBoxControl control = view.GuiElement as PrintImageBoxControl;

            control.Dock = DockStyle.None;
            control.SuspendLayout();
            this._layoutImages.Controls.Add(control);
            control.ResumeLayout(false);
        }
        private void AddImageBoxControls(PrintViewImageBox rootImageBox)
        {
            if (rootImageBox == null)
            {
                return;
            }

            AddImageBoxControl(rootImageBox);
            PrintViewImageBox printViewImageBox = rootImageBox;

            if (printViewImageBox.ChildImageBox.Count > 0)
            {
                foreach (PrintViewImageBox imageBox in printViewImageBox.ChildImageBox)
                {
                    AddImageBoxControls(imageBox);
                }
            }
        }
        public override bool Start(InputManagement.IMouseInformation mouseInformation)
        {
            if (mouseInformation.ClickCount < 2)
            {
                return(false);
            }

            PrintImageViewerComponent printImageViewer = this.Context.Viewer as PrintImageViewerComponent;

            if (printImageViewer == null || printImageViewer.SelectPresentationImages == null)
            {
                return(false);
            }

            foreach (var item in printImageViewer.SelectPresentationImages)
            {
                PresentationImage image = item as PresentationImage;
                image.Selected = false;
            }
            printImageViewer.SelectPresentationImages.Clear();

            foreach (PrintViewTile tile in this.Context.Viewer.SelectedImageBox.Tiles)
            {
                if (tile.PresentationImage == null)
                {
                    tile.Deselect();
                    continue;
                }
                PresentationImage image = tile.PresentationImage as PresentationImage;
                image.Selected = true;
                printImageViewer.SelectPresentationImages.Add(image);
            }

            if (printImageViewer.SelectPresentationImages.Count > 0)
            {
                PrintViewImageBox imageBox = printImageViewer.SelectedImageBox as PrintViewImageBox;
                imageBox.SelectedTile = printImageViewer.SelectPresentationImages[0].Tile;
            }
            this.Context.Viewer.SelectedImageBox.Draw();

            return(true);
        }
        private void SelectRever(object sender, EventArgs args)
        {
            PrintImageViewerComponent printImageViewer = Context.Viewer as PrintImageViewerComponent;

            if (printImageViewer == null || printImageViewer.SelectPresentationImages == null)
            {
                return;
            }

            foreach (PrintViewTile tile in this.Context.Viewer.SelectedImageBox.Tiles)
            {
                if (tile.PresentationImage == null)
                {
                    tile.Deselect();
                }
            }

            List <PresentationImage> temp = new List <PresentationImage>();

            foreach (var tile in printImageViewer.DisplaySet.PresentationImages)
            {
                PresentationImage image = tile as PresentationImage;
                if (printImageViewer.SelectPresentationImages.Contains(image))
                {
                    image.Selected = false;
                }
                else
                {
                    image.Selected = true;
                    temp.Add(image);
                }
            }
            printImageViewer.SelectPresentationImages.Clear();
            printImageViewer.SelectPresentationImages.AddRange(temp);

            if (printImageViewer.SelectPresentationImages.Count > 0)
            {
                PrintViewImageBox imageBox = printImageViewer.SelectedImageBox as PrintViewImageBox;
                imageBox.SelectedTile = printImageViewer.SelectPresentationImages[0].Tile;
            }
            this.Context.Viewer.SelectedImageBox.Draw();
        }
Exemplo n.º 9
0
        private void PerformDispose()
        {
            DisposeExtensions();

            if (_imageBox != null)
            {
                _imageBox.Drawing          -= OnDrawing;
                _imageBox.SelectionChanged -= OnImageBoxSelectionChanged;
                _imageBox.LayoutCompleted  -= OnLayoutCompleted;
                _imageBox = null;
            }

            if (_imageScroller != null)
            {
                _imageScroller.ValueChanged -= ImageScrollerValueChanged;
                _imageScroller.MouseDown    -= ImageScrollerMouseDown;
                _imageScroller.MouseUp      -= ImageScrollerMouseUp;
            }

            DisposeControls(new List <PrintTileControl>(this.TileControls));
        }
Exemplo n.º 10
0
        private void JumpToEnd()
        {
            if (Context.Viewer.SelectedTile == null)
            {
                return;
            }

            PrintViewImageBox imageBox = Context.Viewer.SelectedTile.ParentImageBox as PrintViewImageBox;

            if (imageBox.DisplaySet == null)
            {
                return;
            }

            CaptureBeginState(imageBox);

            imageBox.TopLeftPresentationImageIndex = imageBox.TotleImageCount - imageBox.Tiles.Count;
            if (CaptureEndState())
            {
                imageBox.Draw();
            }
        }
        private void SelectAll(object sender, EventArgs args)
        {
            PrintImageViewerComponent printImageViewer = Context.Viewer as PrintImageViewerComponent;

            if (printImageViewer == null || printImageViewer.SelectPresentationImages == null)
            {
                return;
            }

            foreach (PrintViewTile tile in this.Context.Viewer.SelectedImageBox.Tiles)
            {
                if (tile.PresentationImage == null)
                {
                    tile.Deselect();
                }
            }

            foreach (var item in printImageViewer.SelectPresentationImages)
            {
                PresentationImage image = item as PresentationImage;
                image.Selected = false;
            }
            printImageViewer.SelectPresentationImages.Clear();

            foreach (var tile in printImageViewer.DisplaySet.PresentationImages)
            {
                PresentationImage image = tile as PresentationImage;
                image.Selected = true;
                printImageViewer.SelectPresentationImages.Add(image);
            }

            if (printImageViewer.SelectPresentationImages.Count > 0)
            {
                PrintViewImageBox imageBox = printImageViewer.SelectedImageBox as PrintViewImageBox;
                imageBox.SelectedTile = printImageViewer.SelectPresentationImages[0].Tile;
            }
            this.Context.Viewer.SelectedImageBox.Draw();
        }