Beispiel #1
0
        private void UpdateParking()
        {
            if (this.FormBorderStyle == FormBorderStyle.Fixed3D ||
                this.FormBorderStyle == FormBorderStyle.FixedDialog ||
                this.FormBorderStyle == FormBorderStyle.FixedSingle ||
                this.FormBorderStyle == FormBorderStyle.FixedToolWindow)
            {
                ISnapManagerHost ismh = this.Owner as ISnapManagerHost;

                if (ismh != null)
                {
                    SnapManager mySM = ismh.SnapManager;
                    mySM.ReparkObstacle(this);
                }
            }
        }
Beispiel #2
0
        private void SaveSettings()
        {
            Settings.CurrentUser.SetInt32(SettingNames.Width, this.Width);
            Settings.CurrentUser.SetInt32(SettingNames.Height, this.Height);
            Settings.CurrentUser.SetInt32(SettingNames.Top, this.Top);
            Settings.CurrentUser.SetInt32(SettingNames.Left, this.Left);
            Settings.CurrentUser.SetString(SettingNames.WindowState, this.WindowState.ToString());

            Settings.CurrentUser.SetBoolean(SettingNames.TranslucentWindows, PdnBaseForm.EnableOpacity);

            if (this.WindowState != FormWindowState.Minimized)
            {
                Settings.CurrentUser.SetBoolean(SettingNames.ToolsFormVisible, this.appWorkspace.Widgets.ToolsForm.Visible);
                Settings.CurrentUser.SetBoolean(SettingNames.ColorsFormVisible, this.appWorkspace.Widgets.ColorsForm.Visible);
                Settings.CurrentUser.SetBoolean(SettingNames.LayersFormVisible, this.appWorkspace.Widgets.LayerForm.Visible);
            }

            SnapManager.Save(Settings.CurrentUser);
            this.appWorkspace.SaveSettings();
        }
Beispiel #3
0
        protected override void OnMoving(MovingEventArgs mea)
        {
            ISnapManagerHost snapHost = this.Owner as ISnapManagerHost;

            if (snapHost != null)
            {
                SnapManager sm = snapHost.SnapManager;

                // Make sure the window titlebar always follows a constant distance from the mouse cursor
                // Otherwise the window may "slip" as it snaps and unsnaps
                if (!this.moving)
                {
                    this.movingCursorDelta = new Size(
                        Cursor.Position.X - mea.Rectangle.X,
                        Cursor.Position.Y - mea.Rectangle.Y);

                    this.moving = true;
                }

                mea.Rectangle = new Rectangle(
                    Cursor.Position.X - this.movingCursorDelta.Width,
                    Cursor.Position.Y - this.movingCursorDelta.Height,
                    mea.Rectangle.Width,
                    mea.Rectangle.Height);

                this.snapObstacle.SetBounds(mea.Rectangle);

                Point     pt      = mea.Rectangle.Location;
                Point     newPt   = sm.AdjustObstacleDestination(this.SnapObstacle, pt);
                Rectangle newRect = new Rectangle(newPt, mea.Rectangle.Size);

                this.snapObstacle.SetBounds(newRect);

                mea.Rectangle = newRect;
            }

            base.OnMoving(mea);
        }
Beispiel #4
0
        private void PositionFloatingForms()
        {
            this.appWorkspace.ResetFloatingForms();

            try
            {
                SnapManager.Load(Settings.CurrentUser);
            }

            catch
            {
                this.appWorkspace.ResetFloatingForms();
            }

            foreach (FloatingToolForm ftf in floaters)
            {
                this.AddOwnedForm(ftf);
            }

            if (Settings.CurrentUser.GetBoolean(SettingNames.ToolsFormVisible, true))
            {
                this.appWorkspace.Widgets.ToolsForm.Show();
            }

            if (Settings.CurrentUser.GetBoolean(SettingNames.ColorsFormVisible, true))
            {
                this.appWorkspace.Widgets.ColorsForm.Show();
            }

            if (Settings.CurrentUser.GetBoolean(SettingNames.LayersFormVisible, true))
            {
                this.appWorkspace.Widgets.LayerForm.Show();
            }

            // If the floating form is off screen somehow, reset it
            // We've been getting a lot of reports where people say their Colors window has disappeared
            Screen[] allScreens = Screen.AllScreens;

            foreach (FloatingToolForm ftf in this.floaters)
            {
                if (!ftf.Visible)
                {
                    continue;
                }

                bool reset = false;

                try
                {
                    bool foundAScreen = false;

                    foreach (Screen screen in allScreens)
                    {
                        Rectangle intersect = Rectangle.Intersect(screen.Bounds, ftf.Bounds);

                        if (intersect.Width > 0 && intersect.Height > 0)
                        {
                            foundAScreen = true;
                            break;
                        }
                    }

                    if (!foundAScreen)
                    {
                        reset = true;
                    }
                }

                catch (Exception)
                {
                    reset = true;
                }

                if (reset)
                {
                    this.appWorkspace.ResetFloatingForm(ftf);
                }
            }

            this.floaterOpacityTimer.Enabled = true;
        }