Пример #1
0
        /// <summary>
        /// 所有要打印的图像都保存在这个<see cref="DisplaySet"/>中
        /// </summary>

        public static void AddPresentationImage(IPresentationImage presentationImage)
        {
            if (presentationImage == null)
            {
                return;
            }
            var clonPi = ImageExporter.ClonePresentationImage(presentationImage);

            if (clonPi != null)
            {
                PresentationImage image = clonPi as PresentationImage;
                if (_imageViewerComponent != null)
                {
                    _imageViewerComponent.DisplaySet.PresentationImages.Add(image);
                    image.Selected = false;
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Creates a deep copy of the <see cref="IPresentationImage"/>.
        /// </summary>
        /// <remarks>
        /// <see cref="IPresentationImage"/>s should never return null from this method.
        /// </remarks>
        public IPresentationImage Clone()
        {
            try
            {
                PresentationImage clone = CloneBuilder.Clone(this) as PresentationImage;
                if (clone != null)
                {
                    clone.SceneGraph.SetParentPresentationImage(clone);
                    if (ImageViewer != null)
                    {
                        ImageViewer.EventBroker.OnCloneCreated(new CloneCreatedEventArgs(this, clone));
                    }
                }

                return(clone);
            }
            catch (Exception e)
            {
                throw new PresentationImageCloningException(this, e);
            }
        }
Пример #3
0
 /// <summary>
 /// Called when a <see cref="PresentationImage"/> has been removed from the display set.
 /// </summary>
 /// <param name="image">The image that was removed from the display set.</param>
 protected virtual void OnPresentationImageRemoved(PresentationImage image)
 {
     image.ParentDisplaySet = null;
     image.ImageViewer      = null;
 }
Пример #4
0
 /// <summary>
 /// Called when a <see cref="PresentationImage"/> has been added to the display set.
 /// </summary>
 /// <param name="image">The image that was added to the display set.</param>
 protected virtual void OnPresentationImageAdded(PresentationImage image)
 {
     image.ParentDisplaySet = this;
     image.ImageViewer      = this.ImageViewer;
 }
Пример #5
0
        /// <summary>
        /// Selects the <see cref="Tile"/>.
        /// </summary>
        /// <remarks>
        /// Selecting a <see cref="Tile"/> also selects the containing <see cref="ImageBox"/>
        /// and deselects any other currently seleccted <see cref="Tile"/>
        /// and <see cref="ImageBox"/>.
        /// </remarks>
        public void Select(XKeys key = XKeys.None, XMouseButtons button = XMouseButtons.Left)
        {
            //if (!this.Selected)
            //{
            Platform.CheckMemberIsSet(this.ParentImageBox, "Tile.ParentImageBox");
            Platform.CheckMemberIsSet(this.ImageViewer, "Tile.ImageViewer");

            if (button == XMouseButtons.Right)
            {
                if (_presentationImage == null)
                {
                    return;
                }
                if (!_parentImageBox.SelectPresentationImages.Contains(_presentationImage))
                {
                    foreach (var presentationImage in _parentImageBox.SelectPresentationImages)
                    {
                        presentationImage.Selected = false;
                    }
                    _parentImageBox.SelectPresentationImages.Clear();
                    _presentationImage.Selected = true;
                    _parentImageBox.SelectPresentationImages.Add(_presentationImage);
                }

                this.Selected = true;
                _parentImageBox.SelectedTile = this;
                this.ImageViewer.EventBroker.OnTileSelected(new TileSelectedEventArgs(this));
                return;
            }

            if (key == XKeys.None && _parentImageBox.SelectedTile != null)
            {
                var tile = _parentImageBox.SelectedTile as PrintViewTile;
                tile.Selected = false;
                if (_parentImageBox.SelectTiles.Contains(tile))
                {
                    _parentImageBox.SelectTiles.Remove(tile);
                }
            }

            if (key == XKeys.None)
            {
                foreach (var presentationImage in _parentImageBox.SelectPresentationImages)
                {
                    presentationImage.Selected = false;
                }
                _parentImageBox.SelectPresentationImages.Clear();
                foreach (var tile in _parentImageBox.SelectTiles)
                {
                    tile.Selected = false;
                }
                _parentImageBox.SelectTiles.Clear();

                if (_presentationImage != null)
                {
                    _presentationImage.Selected = true;
                    _parentImageBox.SelectPresentationImages.Add(_presentationImage);
                }
                this.Selected = true;
                _parentImageBox.SelectTiles.Add(this);
                _parentImageBox.SelectedTile = this;
            }
            else if (key == XKeys.Control)
            {
                if (_presentationImage != null)
                {
                    if (_parentImageBox.SelectPresentationImages.Contains(_presentationImage))
                    {
                        _presentationImage.Selected = false;
                        _parentImageBox.SelectPresentationImages.Remove(_presentationImage);
                        this.Selected = false;
                        if (_parentImageBox.SelectTiles.Contains(this))
                        {
                            _parentImageBox.SelectTiles.Remove(this);
                        }

                        if (_parentImageBox.SelectPresentationImages.Count == 0)
                        {
                            var title = _parentImageBox.Tiles[0] as PrintViewTile;
                            if (title._presentationImage != null)
                            {
                                title._presentationImage.Selected = true;
                                _parentImageBox.SelectPresentationImages.Add(title._presentationImage);
                            }
                            title.Selected = true;
                            _parentImageBox.SelectedTile = title;
                            if (!_parentImageBox.SelectTiles.Contains(title))
                            {
                                _parentImageBox.SelectTiles.Add(title);
                            }
                        }
                        else
                        {
                            foreach (var image in _parentImageBox.SelectPresentationImages)
                            {
                                if (image.Tile != null && _parentImageBox.SelectedTile != image.Tile)
                                {
                                    var title = image.Tile as PrintViewTile;
                                    title.Selected = true;
                                    _parentImageBox.SelectedTile = title;
                                    if (!_parentImageBox.SelectTiles.Contains(title))
                                    {
                                        _parentImageBox.SelectTiles.Add(title);
                                    }
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        _presentationImage.Selected = true;
                        _parentImageBox.SelectPresentationImages.Add(_presentationImage);
                        this.Selected = true;
                        _parentImageBox.SelectedTile = this;
                        if (!_parentImageBox.SelectTiles.Contains(this))
                        {
                            _parentImageBox.SelectTiles.Add(this);
                        }
                    }
                }
                else
                {
                    if (_parentImageBox.SelectTiles.Contains(this))
                    {
                        this.Selected = false;
                        _parentImageBox.SelectTiles.Remove(this);
                        if (_parentImageBox.SelectTiles.Count > 0)
                        {
                            _parentImageBox.SelectedTile = _parentImageBox.SelectTiles[0];
                        }
                        else
                        {
                            var title = _parentImageBox.Tiles[0] as PrintViewTile;
                            title.Selected = true;
                            _parentImageBox.SelectedTile = title;
                            if (!_parentImageBox.SelectTiles.Contains(title))
                            {
                                _parentImageBox.SelectTiles.Add(title);
                            }
                        }
                    }
                    else
                    {
                        this.Selected = true;
                        if (!_parentImageBox.SelectTiles.Contains(this))
                        {
                            _parentImageBox.SelectTiles.Add(this);
                        }
                        _parentImageBox.SelectedTile = this;
                    }
                }
            }
            else if (key == XKeys.Shift)
            {
                if (_presentationImage != null)
                {
                    if (_parentImageBox.SelectPresentationImages.Count == 0)
                    {
                        _presentationImage.Selected = true;
                        _parentImageBox.SelectPresentationImages.Add(_presentationImage);
                    }
                    else
                    {
                        int start =
                            _parentImageBox.DisplaySet.PresentationImages.IndexOf(
                                _parentImageBox.SelectPresentationImages[
                                    _parentImageBox.SelectPresentationImages.Count - 1]);
                        int end = _parentImageBox.DisplaySet.PresentationImages.IndexOf(_presentationImage);

                        if (start > end)
                        {
                            int temp = start;
                            start = end;
                            end   = temp;
                        }

                        for (int i = start; i <= end; i++)
                        {
                            PresentationImage pimage = _parentImageBox.DisplaySet.PresentationImages[i] as PresentationImage;
                            if (!_parentImageBox.SelectPresentationImages.Contains(pimage))
                            {
                                pimage.Selected = true;
                                _parentImageBox.SelectPresentationImages.Add(pimage);
                            }
                            if (pimage.Tile != null)
                            {
                                var mytitle = pimage.Tile as PrintViewTile;
                                mytitle.Selected = true;
                                if (!_parentImageBox.SelectTiles.Contains(mytitle))
                                {
                                    _parentImageBox.SelectTiles.Add(mytitle);
                                }
                            }
                        }
                    }
                    Selected = true;
                    _parentImageBox.SelectedTile = this;
                    if (!_parentImageBox.SelectTiles.Contains(this))
                    {
                        _parentImageBox.SelectTiles.Add(this);
                    }
                }
                else
                {
                    if (_parentImageBox.SelectTiles.Count == 0)
                    {
                        this.Selected = true;
                        _parentImageBox.SelectTiles.Add(this);
                        _parentImageBox.SelectedTile = this;
                    }
                    else
                    {
                        int start =
                            _parentImageBox.Tiles.IndexOf(_parentImageBox.SelectTiles[_parentImageBox.SelectTiles.Count - 1]);
                        int end = _parentImageBox.Tiles.IndexOf(this);
                        if (start > end)
                        {
                            int temp = start;
                            start = end;
                            end   = temp;
                        }

                        for (int i = start; i <= end; i++)
                        {
                            var tile = _parentImageBox.Tiles[i] as PrintViewTile;
                            tile.Selected = true;
                            if (!_parentImageBox.SelectTiles.Contains(tile))
                            {
                                _parentImageBox.SelectTiles.Add(tile);
                            }
                        }

                        this.Selected = true;
                        _parentImageBox.SelectedTile = this;
                    }
                }
            }



            //if (_presentationImage != null)
            //{
            //    if (key == XKeys.None)
            //    {
            //        foreach (var presentationImage in _parentImageBox.SelectPresentationImages)
            //        {
            //            presentationImage.Selected = false;
            //        }
            //        _parentImageBox.SelectPresentationImages.Clear();
            //        _presentationImage.Selected = true;
            //        _parentImageBox.SelectPresentationImages.Add(_presentationImage);
            //        this.Selected = true;
            //        _parentImageBox.SelectedTile = this;
            //    }
            //    else if (key == XKeys.Control)
            //    {
            //        if (_parentImageBox.SelectPresentationImages.Contains(_presentationImage))
            //        {
            //            _presentationImage.Selected = false;
            //            _parentImageBox.SelectPresentationImages.Remove(_presentationImage);
            //            this.Selected = false;
            //            if (_parentImageBox.SelectPresentationImages.Count == 0)
            //            {
            //                _parentImageBox.SelectDefaultTile();
            //            }
            //            else
            //            {
            //                foreach (var image in _parentImageBox.SelectPresentationImages)
            //                {
            //                    if (image.Tile != null && _parentImageBox.SelectedTile != image.Tile)
            //                    {
            //                        _parentImageBox.SelectedTile = image.Tile;
            //                        break;
            //                    }
            //                }
            //            }
            //        }
            //        else
            //        {
            //            _presentationImage.Selected = true;
            //            _parentImageBox.SelectPresentationImages.Add(_presentationImage);
            //            this.Selected = true;
            //            _parentImageBox.SelectedTile = this;
            //        }
            //    }
            //    else if (key == XKeys.Shift)
            //    {
            //        if (_parentImageBox.SelectPresentationImages.Count == 0)
            //        {
            //            _presentationImage.Selected = true;
            //            _parentImageBox.SelectPresentationImages.Add(_presentationImage);
            //        }
            //        else
            //        {
            //            int start =
            //                _parentImageBox.DisplaySet.PresentationImages.IndexOf(
            //                    _parentImageBox.SelectPresentationImages[
            //                        _parentImageBox.SelectPresentationImages.Count - 1]);
            //            int end = _parentImageBox.DisplaySet.PresentationImages.IndexOf(_presentationImage);

            //            if (start > end)
            //            {
            //                int temp = start;
            //                start = end;
            //                end = temp;
            //            }

            //            for (int i = start; i <= end; i++)
            //            {
            //                PresentationImage pimage = _parentImageBox.DisplaySet.PresentationImages[i] as PresentationImage;
            //                if (!_parentImageBox.SelectPresentationImages.Contains(pimage))
            //                {
            //                    pimage.Selected = true;
            //                    _parentImageBox.SelectPresentationImages.Add(pimage);
            //                }
            //            }
            //        }

            //        this.Selected = true;
            //        _parentImageBox.SelectedTile = this;
            //    }

            //}
            //else
            //{
            //    if (key == XKeys.None)
            //    {
            //        foreach (var presentationImage in _parentImageBox.SelectPresentationImages)
            //        {
            //            presentationImage.Selected = false;
            //        }
            //        _parentImageBox.SelectPresentationImages.Clear();
            //    }

            //}


            this.ImageViewer.EventBroker.OnTileSelected(new TileSelectedEventArgs(this));
            //}
        }