コード例 #1
0
            public void ShowSelected(bool draw)
            {
                foreach (ImageOverlay overlay in _overlays)
                {
                    overlay.ShowIfSelected();
                }

                if (draw)
                {
                    _image.Draw();
                }
            }
コード例 #2
0
        private void DoFlash(IPresentationImage image, SynchronizationContext syncContext, string message)
        {
            if (!(image is IOverlayGraphicsProvider))
            {
                return;
            }

            GraphicCollection overlayGraphics = ((IOverlayGraphicsProvider)image).OverlayGraphics;

            // Prevent multiple flash graphics per image.
            var existing = overlayGraphics.OfType <FlashOverlayGraphic>().FirstOrDefault(g => g.Controller == this);

            if (existing != null)
            {
                return;
            }

            // Very little utility in flashing if nobody's looking at it.
            if (syncContext == null)
            {
                return;
            }

            var flashOverlayGraphic = new FlashOverlayGraphic(this, message);

            overlayGraphics.Add(flashOverlayGraphic);
            image.Draw();

            ThreadPool.QueueUserWorkItem(
                delegate
            {
                Thread.Sleep(FlashSpeed);
                syncContext.Post(delegate
                {
                    if (flashOverlayGraphic.IsDisposed)
                    {
                        return;
                    }

                    overlayGraphics.Remove(flashOverlayGraphic);
                    image.Draw();
                }, null);
            }, null);
        }
コード例 #3
0
        private void RemovePinwheelGraphic()
        {
            if (_currentPinwheelGraphic != null)
            {
                IPresentationImage image = _currentPinwheelGraphic.ParentPresentationImage;
                ((CompositeGraphic)_currentPinwheelGraphic.ParentGraphic).Graphics.Remove(_currentPinwheelGraphic);
                image.Draw();

                _currentPinwheelGraphic.Dispose();
            }

            _currentPinwheelGraphic = null;
        }
コード例 #4
0
        public override void Cancel()
        {
            if (_graphicBuilder != null)
            {
                _graphicBuilder.Cancel();
                _graphicBuilder = null;
            }

            if (_primitiveGraphic != null)
            {
                IPresentationImage image = _primitiveGraphic.ParentPresentationImage;
                RemoveDrawShutterGraphic();
                image.Draw();
            }
        }
コード例 #5
0
ファイル: ResliceToolGroup.cs プロジェクト: bangush/server-1
        /// <summary>
        /// Moves the graphic from where ever it is to the target image.
        /// </summary>
        private static void TranslocateGraphic(IGraphic graphic, IPresentationImage targetImage)
        {
            IPresentationImage oldImage = graphic.ParentPresentationImage;

            if (oldImage != targetImage)
            {
                IApplicationGraphicsProvider imageOnUnexecute = oldImage as IApplicationGraphicsProvider;
                if (imageOnUnexecute != null)
                {
                    imageOnUnexecute.ApplicationGraphics.Remove(graphic);
                }

                IApplicationGraphicsProvider imageOnExecute = targetImage as IApplicationGraphicsProvider;
                if (imageOnExecute != null)
                {
                    imageOnExecute.ApplicationGraphics.Add(graphic);
                }

                if (oldImage != null)
                {
                    oldImage.Draw();
                }
            }
        }
コード例 #6
0
ファイル: FlashOverlayController.cs プロジェクト: nhannd/Xian
        private void DoFlash(IPresentationImage image, SynchronizationContext syncContext)
        {
            if (!(image is IOverlayGraphicsProvider))
                return;

            GraphicCollection overlayGraphics = ((IOverlayGraphicsProvider) image).OverlayGraphics;
            //Prevent multiple flash graphics per image.
            var existing = overlayGraphics.OfType<FlashOverlayGraphic>().Where(g => g.Controller == this).FirstOrDefault();
            if (existing != null)
                return;

            //Very little utility in flashing if nobody's looking at it.
            if (syncContext == null)
                return;

            var flashOverlayGraphic = new FlashOverlayGraphic(this);
            overlayGraphics.Add(flashOverlayGraphic);
            image.Draw();

            ThreadPool.QueueUserWorkItem(
                delegate
                    {
                        Thread.Sleep(FlashSpeed);
                        syncContext.Post(delegate
                                             {
                                                 if (flashOverlayGraphic.IsDisposed)
                                                     return;

                                                 overlayGraphics.Remove(flashOverlayGraphic);
                                                 image.Draw();
                                             }, null);
                    }, null);
        }