Beispiel #1
0
        internal static void PlaceOnScreen(this PNote note)
        {
            var size = PNStatic.AllScreensSize();
            var rect = PNStatic.AllScreensBounds();

            if (PNStatic.Settings.Behavior.RelationalPositioning)
            {
                note.Dialog.SetLocation(new Point((int)Math.Floor(size.Width * note.XFactor),
                                                  (int)Math.Floor(size.Height * note.YFactor)));

                while (note.Dialog.Left + note.Dialog.Width > size.Width)
                {
                    note.Dialog.Left--;
                }
                if (rect.X >= 0)
                {
                    while (note.Dialog.Left < 0)
                    {
                        note.Dialog.Left++;
                    }
                }
                while (note.Dialog.Top + note.Dialog.Height > size.Height)
                {
                    note.Dialog.Top--;
                }
                if (rect.Y >= 0)
                {
                    while (note.Dialog.Top < 0)
                    {
                        note.Dialog.Top++;
                    }
                }
            }
            else
            {
                if (rect.IntersectsWith(new Rect(note.NoteLocation, note.NoteSize)))
                {
                    note.Dialog.SetLocation(note.NoteLocation);
                }
                else
                {
                    PNNotesOperations.CentralizeNotes(new[] { note });
                }
            }
        }