private void Window_Loaded(object sender, RoutedEventArgs e) { try { var wa = PNStatic.AllScreensBounds(); switch (DockDirection) { case DockArrow.LeftUp: case DockArrow.TopLeft: this.SetLocation(new Point(wa.Left, wa.Top)); break; case DockArrow.LeftDown: case DockArrow.BottomLeft: this.SetLocation(new Point(wa.Left, wa.Bottom - ActualHeight)); break; case DockArrow.RightUp: case DockArrow.TopRight: this.SetLocation(new Point(wa.Right - ActualWidth, wa.Top)); break; case DockArrow.RightDown: case DockArrow.BottomRight: this.SetLocation(new Point(wa.Right - ActualWidth, wa.Bottom - ActualHeight)); break; } } catch (Exception ex) { PNStatic.LogException(ex); } }
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 }); } } }