Ejemplo n.º 1
0
        // TODO: refactor into FloatingToolForm class somehow
        private void FloaterOpacityTimer_Tick(object sender, System.EventArgs e)
        {
            if (this.WindowState == FormWindowState.Minimized ||
                this.floaters == null ||
                !PdnBaseForm.EnableOpacity ||
                this.appWorkspace.ActiveDocumentWorkspace == null)
            {
                return;
            }

            // Here's the behavior we want for our floaters:
            // 1. If the mouse is within a floaters rectangle, it should transition to fully opaque
            // 2. If the mouse is outside the floater's rectangle, it should transition to partially
            //    opaque
            // 3. However, if the floater is outside where the document is visible on screen, it
            //    should always be fully opaque.
            Rectangle screenDocRect;

            try
            {
                screenDocRect = this.appWorkspace.ActiveDocumentWorkspace.VisibleDocumentBounds;
            }

            catch (ObjectDisposedException)
            {
                return; // do nothing, we are probably in the process of shutting down the app
            }

            for (int i = 0; i < floaters.Length; ++i)
            {
                FloatingToolForm ftf = floaters[i];

                Rectangle intersect = Rectangle.Intersect(screenDocRect, ftf.Bounds);
                double    opacity   = -1.0;

                try
                {
                    if (intersect.Width == 0 ||
                        intersect.Height == 0 ||
                        (ftf.Bounds.Contains(Control.MousePosition) &&
                         !appWorkspace.ActiveDocumentWorkspace.IsMouseCaptured()) ||
                        Utility.DoesControlHaveMouseCaptured(ftf))
                    {
                        opacity = Math.Min(1.0, ftf.Opacity + 0.125);
                    }
                    else
                    {
                        opacity = Math.Max(0.75, ftf.Opacity - 0.0625);
                    }

                    if (opacity != ftf.Opacity)
                    {
                        ftf.Opacity = opacity;
                    }
                }

                catch (System.ComponentModel.Win32Exception)
                {
                    // We just eat the exception. Chris Strahl was having some problem where opacity was 0.7
                    // and we were trying to set it to 0.7 and it said "the parameter is incorrect"
                    // ... which is stupid. Bad NVIDIA drivers for his GeForce Go?
                }
            }
        }
Ejemplo n.º 2
0
        public void ResetFloatingForm(FloatingToolForm ftf)
        {
            SnapManager sm = SnapManager.FindMySnapManager(this);

            if (ftf == Widgets.ToolsForm)
            {
                sm.ParkObstacle(Widgets.ToolsForm, this, HorizontalSnapEdge.Top, VerticalSnapEdge.Left);
            }
            else if (ftf == Widgets.HistoryForm)
            {
                sm.ParkObstacle(Widgets.HistoryForm, this, HorizontalSnapEdge.Top, VerticalSnapEdge.Right);
            }
            else if (ftf == Widgets.LayerForm)
            {
                sm.ParkObstacle(Widgets.LayerForm, this, HorizontalSnapEdge.Bottom, VerticalSnapEdge.Right);
            }
            else if (ftf == Widgets.ColorsForm)
            {
                sm.ParkObstacle(Widgets.ColorsForm, this, HorizontalSnapEdge.Bottom, VerticalSnapEdge.Left);
            }
            else
            {
                throw new ArgumentException();
            }
        }