filePath=Path.Combine (CheckAndGetCurrentDirectory (), fileName.TrimStart (new [] { laquo ;, /})); (! File.Exists (filePath)) new FileSystemAccessDeniedException ();
File.GetLastWriteTime (filePath);
}
long GetFileSize (string fileName)
{(! _ userRights.CanDownload ()) new FileSystemAccessDeniedException ();
filePath=Path.Combine (CheckAndGetCurrentDirectory (), fileName.TrimStart (new [] { laquo ;, /})); (! File.Exists (filePath)) new FileSystemAccessDeniedException ();
{new FileInfo (filePath) .Length;
} (IOException ex)
{new FileSystemException (ex.Message.Replace (_rootDirectory, ));
}
}
string [] GetFileInfo (string fileName, bool onlyNames=false)
{(! _ userRights.CanDownload ()) new FileSystemAccessDeniedException ();
lt; FileInfo gt; files=new List lt; FileInfo gt; (); lt; DirectoryInfo gt; directories=new List lt; DirectoryInfo gt; ();
currentDirectory=CheckAndGetCurrentDirectory (); filePath=string.IsNullOrWhiteSpace (fileName)
? currentDirectory
: Path.Combine (currentDirectory, fileName.TrimStart (new [] { laquo ;, /}));
(File.Exists (filePath))
{. Add (new FileInfo (filePath));
} if (Directory.Exists (filePath))
{. AddRange (Directory.GetFiles (filePath) .Select (v= gt; new FileInfo (v))) ;. AddRange (Directory.GetDirectories (filePath) .Select (v= gt; new DirectoryInfo (v)));
}
{new FileSystemAccessDeniedException ();
}
lt; FileInfo, string gt; getFileInfo; lt; DirectoryInfo, string gt; getDirectoryInfo; (onlyNames)
{== gt; string.Format ( t {0} raquo ;, f.Name.Replace (_rootDirectory, )); == gt; string.Format ( dir t {0} raquo ;, d.Name.Replace (_rootDirectory, ));
}
{== gt; string.Format ( t {0} t {1} t {2} raquo ;, f.Name.Replace (_rootDirectory, ), f.Length, f.LastWriteTime); == gt ; string.Format ( dir t {0} t {1} t {2} raquo ;, d.Name.Replace (_rootDirectory, ), raquo ;, d.LastWriteTime);
}
lt; string gt; result=new List lt; string gt; () ;. AddRange (.Select (= gt; getFileInfo (v))) ;. AddRange (.Select (= gt; getDirectoryInfo (v)));
result.ToArray ();
}
private string CheckAndGetCurrentDirectory ()
{(! _ userRights.CanDownload ()) new FileSystemAccessDeniedException ();
currentDirectory=Directory.GetCurrentDirectory (); (! currentDirectory.StartsWith (_rootDirectory)) new Exception ( Incorrect working directory );
currentDirectory;
}
}
Лістинг класу DisplayManager
using System;System.Collections.Generic;System.Drawing;System.Drawing.Drawing2D;System.Linq;System.Text;System.Windows.Forms;BaldaClient.DisplayModel;BaldaGameLogic.GameLogic;BaldaGameLogic.GameModel;
BaldaClient.DisplayLogic
{class DisplayManager
{
# region Properties for bindingsGameLogicControls GameControls {get; set; }
# endregion
# region gameLogicFields
List lt; LogicCell gt; logicCells; List lt; DisplayCell gt; displayCells; DisplayCell previousSelectedCell;
Dictionary lt; LogicCell, DisplayCell gt; cellDictionary;
# endregion
# region forDisplayFields
int cellBackgroundOffset; int cellBackgroundSize; int cellTextOffset; PictureBox pb; Graphics gr; Pen pen; Brush primaryBrush; Brush lightBrush; Brush textBrush; Font font; Label selectedWordLabel; DisplaySettings displaySettings;
# endregionDisplayCell selectedCellForLetter;
LogicCell SelectedCellForLetter
{{return (selectedCellForLetter!=null)? selectedCellForLetter.LogicCell: null; }
}
DisplayManager (GameLogicControls gameLogicControls, DisplaySettings displaySettings, List lt; LogicCell gt; logiccells)
{. GameControls=gameLogicControls; .pb=gameLogicControls.pictureBox; .selectedWordLab...