/// <summary> /// The meat and potatoes of the get icon functions above. Gets an icon based on the /// given path and flags. Will attempt to fetch icons from Image Lists if they use /// those (eg: .lnk/.url files). /// </summary> /// <param name="path">The path to get the icon for.</param> /// <param name="flags">A bitfield representing flags to pass to /// <see cref="Trampolines.ShellGetFileInfo(string, FileAttributes, uint)"/></param> /// <param name="attribs">FileAttributes of the given path.</param> /// <returns>The requested icon.</returns> private static SDIcon GetIcon(string path, uint flags, FileAttributes attribs = 0) { (SHFILEINFO info, IntPtr list) = Trampolines.ShellGetFileInfo(path, attribs, flags); SDIcon icon = null; if (info.hIcon != IntPtr.Zero) { icon = SDIcon.FromHandle(info.hIcon).Clone() as SDIcon; DestroyIcon(info.hIcon); return(icon); } else if (list != IntPtr.Zero && info.iIcon != IntPtr.Zero) { icon = Trampolines.GetIconFromList(list, info.iIcon.ToInt32()); } return(icon); }
private void MoveRobotTo(RobotCommand direction, Point destPos) { CellType destType = Cell.At(destPos); if (!destType.IsTraversible()) { throw new InvalidMoveException(RobotPosition, destPos); } if (!destType.IsEmpty()) { IsChanged = true; } if (destType.IsRock()) { if (direction == RobotCommand.Left && Cell.At(destPos.Left()).IsEmpty()) { Cell.Set(destPos.Left(), destType); Rocks.Remove(destPos); Rocks.Add(destPos.Left()); if (destType.IsHoRock()) { HoRocks.Remove(destPos); HoRocks.Add(destPos.Left()); } } else if (direction == RobotCommand.Right && Cell.At(destPos.Right()).IsEmpty()) { Cell.Set(destPos.Right(), destType); Rocks.Remove(destPos); Rocks.Add(destPos.Right()); if (destType.IsHoRock()) { HoRocks.Remove(destPos); HoRocks.Add(destPos.Right()); } } else { throw new InvalidMoveException(RobotPosition, destPos); } } if (destType.IsLambda()) { Lambdas.Remove(destPos); Score += 25; LambdasCollected++; } if (destType.IsOpenLift()) { State = MapState.Won; Score += LambdasCollected * 50 - 1; // minus one point for the final move } if (destType.IsTrampoline()) { Cell.Set(destPos, CellType.Empty); destPos = Trampolines[destPos]; // remove all trampolines that have the same target var remove = new List <Point>(); foreach (var trampoline in Trampolines) { if (trampoline.Value == destPos) { Cell.Set(trampoline.Key, CellType.Empty); remove.Add(trampoline.Key); } } foreach (Point point in remove) { Trampolines.Remove(point); } } if (destType.IsRazor()) { RazorCount++; Razors.Remove(destPos); } Cell.Set(RobotPosition, CellType.Empty); Cell.Set(destPos, CellType.Robot); RobotPosition = destPos; }