public virtual void SwapAction(PointOffset offset) { if (SelectedIndices.Count != 1) { return; } Int32 index = SelectedIndices[0]; switch (offset) { case PointOffset.Up: if (!IndexInItems(index - 1)) { return; } SwapItems(index, index - 1); break; case PointOffset.Down: if (!IndexInItems(index + 1)) { return; } SwapItems(index, index + 1); break; default: break; } }
public Point <T> Offset(PointOffset offset, T count) { return(offset switch { PointOffset.None => this, PointOffset.Up => this - new Point <T>(0, count), PointOffset.Down => this + new Point <T>(0, count), PointOffset.Left => this - new Point <T>(count, 0), PointOffset.Right => this + new Point <T>(count, 0), PointOffset.UpLeft => this - new Point <T>(count, count), PointOffset.DownLeft => this + new Point <T>(MathUnsafe.Negative(count), count), PointOffset.UpRight => this - new Point <T>(MathUnsafe.Negative(count), count), PointOffset.DownRight => this + new Point <T>(count, count), _ => throw new ArgumentOutOfRangeException(nameof(offset), offset, null) });
public CharPoint Offset(PointOffset offset, Char count = (Char)1) { return(offset switch { PointOffset.None => this, PointOffset.Up => (this - new CharPoint((Char)0, count)), PointOffset.Down => (this + new CharPoint((Char)0, count)), PointOffset.Left => (this - new CharPoint(count, (Char)0)), PointOffset.Right => (this + new CharPoint(count, (Char)0)), PointOffset.UpLeft => (this - new CharPoint(count, count)), PointOffset.DownLeft => (this + new CharPoint((Char)0, count) - new CharPoint(count, (Char)0)), PointOffset.UpRight => (this - new CharPoint((Char)0, count) + new CharPoint(count, (Char)0)), PointOffset.DownRight => (this + new CharPoint(count, count)), _ => throw new ArgumentOutOfRangeException(nameof(offset), offset, null) });
public SBytePoint Offset(PointOffset offset, SByte count = 1) { return(offset switch { PointOffset.None => this, PointOffset.Up => (this - new SBytePoint(0, count)), PointOffset.Down => (this + new SBytePoint(0, count)), PointOffset.Left => (this - new SBytePoint(count, 0)), PointOffset.Right => (this + new SBytePoint(count, 0)), PointOffset.UpLeft => (this - new SBytePoint(count, count)), PointOffset.DownLeft => (this + new SBytePoint(0, count) - new SBytePoint(count, 0)), PointOffset.UpRight => (this - new SBytePoint(0, count) + new SBytePoint(count, 0)), PointOffset.DownRight => (this + new SBytePoint(count, count)), _ => throw new ArgumentOutOfRangeException(nameof(offset), offset, null) });
public Point <T> Offset(PointOffset offset) { return(Offset(offset, (T)Convert.ChangeType(1, typeof(T)))); }
public Point <T> Offset(PointOffset offset) { return(Offset(offset, (T)(Object)1)); }
public static T SetPosition <T>([NotNull] this T control, [NotNull] Control relative, PointOffset offset, Int32 distance = GUIUtils.Distance) where T : Control { if (control is null) { throw new ArgumentNullException(nameof(control)); } if (relative is null) { throw new ArgumentNullException(nameof(relative)); } if (relative is Form form) { return(SetPositionInner(control, form, offset, distance)); } return(SetPositionOuter(control, relative, offset, distance)); }
public static T SetPositionOuter <T>([NotNull] this T control, [NotNull] Control relative, PointOffset offset, HorizontalAlignment alignment, Int32 distance = GUIUtils.Distance) where T : Control { if (control is null) { throw new ArgumentNullException(nameof(control)); } if (relative is null) { throw new ArgumentNullException(nameof(relative)); } control.Location = offset switch { PointOffset.None => control.Location, PointOffset.Up => alignment switch { HorizontalAlignment.Left => new Point(relative.Location.X, relative.Location.Y - control.Size.Height - distance), HorizontalAlignment.Right => new Point(relative.Location.X + relative.Size.Width - control.Size.Width, relative.Location.Y - control.Size.Height - distance), HorizontalAlignment.Center => new Point(relative.Location.X + (relative.Size.Width - control.Size.Width) / 2, relative.Location.Y - control.Size.Height - distance), _ => throw new NotSupportedException() },
public static T SetPositionOuter <T>([NotNull] this T control, [NotNull] Control relative, PointOffset offset, Int32 distance = GUIUtils.Distance) where T : Control { if (control is null) { throw new ArgumentNullException(nameof(control)); } if (relative is null) { throw new ArgumentNullException(nameof(relative)); } control.Location = offset switch { PointOffset.None => control.Location, PointOffset.Up => new Point(relative.Location.X, relative.Location.Y - control.Size.Height - distance), PointOffset.Down => new Point(relative.Location.X, relative.Location.Y + relative.Size.Height + distance), PointOffset.Left => new Point(relative.Location.X - control.Size.Width - distance, relative.Location.Y), PointOffset.Right => new Point(relative.Location.X + relative.Size.Width + distance, relative.Location.Y), PointOffset.UpLeft => new Point(relative.Location.X - control.Size.Width - distance, relative.Location.Y - control.Size.Height - distance), PointOffset.DownLeft => new Point(relative.Location.X - control.Size.Width - distance, relative.Location.Y + relative.Size.Height + distance), PointOffset.UpRight => new Point(relative.Location.X + relative.Size.Width + distance, relative.Location.Y - control.Size.Height - distance), PointOffset.DownRight => new Point(relative.Location.X + relative.Size.Width + distance, relative.Location.Y + relative.Size.Height + distance), _ => throw new NotSupportedException() }; return(control); }
public static T SetPositionInner <T>([NotNull] this T control, [NotNull] Control relative, PointOffset offset, Int32 distanceX, Int32 distanceY) where T : Control { if (control is null) { throw new ArgumentNullException(nameof(control)); } if (relative is null) { throw new ArgumentNullException(nameof(relative)); } control.Location = offset switch { PointOffset.None => control.Location, PointOffset.Up => new Point((relative.ClientSize.Width - control.Size.Width) / 2 + distanceX, distanceY), PointOffset.Down => new Point((relative.ClientSize.Width - control.Size.Width) / 2 + distanceX, relative.ClientSize.Height - control.Size.Height - distanceY), PointOffset.Left => new Point(distanceX, (relative.ClientSize.Height - control.Size.Height) / 2 - distanceY), PointOffset.Right => new Point(relative.ClientSize.Width - control.Size.Width - distanceX, (relative.ClientSize.Height - control.Size.Height) / 2 - distanceY), PointOffset.UpLeft => new Point(distanceX, distanceY), PointOffset.DownLeft => new Point(distanceX, relative.ClientSize.Height - control.Size.Height - distanceY), PointOffset.UpRight => new Point(relative.ClientSize.Width - control.Size.Width - distanceX, distanceY), PointOffset.DownRight => new Point(relative.ClientSize.Width - control.Size.Width - distanceX, relative.ClientSize.Height - control.Size.Height - distanceY), _ => throw new NotSupportedException() }; return(control); }
public static T SetPositionInner <T>([NotNull] this T control, [NotNull] Control relative, PointOffset offset, Int32 distance = GUIUtils.Distance) where T : Control { return(SetPositionInner(control, relative, offset, distance, distance)); }