コード例 #1
0
ファイル: Board.cs プロジェクト: ejantura/Thermometers
 public Board(BoardConfig boardConfig, Canvas myCanvas, Label myLabel, ImageManager imageManager)
 {
     this.myCanvas     = myCanvas;
     this.myLabel      = myLabel;
     this.dest         = boardConfig.Dest;
     this.cellSize     = boardConfig.CellSize;
     this.rowCount     = boardConfig.RowCount;
     this.colCount     = boardConfig.ColCount;
     this.marginPerc   = boardConfig.MarginPerc;
     this.imageManager = imageManager;
     for (int col = 0; col < colCount; col++)
     {
         for (int row = 0; row < rowCount; row++)
         {
             stats[row * colCount + col]                = rnd.Next(0, 2);
             rect[row * colCount + col]                 = new Rectangle();
             rect[row * colCount + col].Width           = cellSize;
             rect[row * colCount + col].Height          = cellSize;
             rect[row * colCount + col].Stroke          = Brushes.Black;
             rect[row * colCount + col].StrokeThickness = 1;
             myCanvas.Children.Add(rect[row * colCount + col]);
             Canvas.SetTop(rect[row * colCount + col], row * cellSize * marginPerc);
             Canvas.SetLeft(rect[row * colCount + col], col * cellSize * marginPerc);
             rect[row * colCount + col].MouseLeftButtonDown += new MouseButtonEventHandler(boardHandler);
         }
     }
 }
コード例 #2
0
        public MainWindow()
        {
            InitializeComponent();

            ImageManager imageManager = new ImageManager();
            ImagePattern imagePattern = new ImagePattern(DEFAULT_CELL_SIZE, myCanvas, imageManager);

            BoardConfig boardConfig = new BoardConfig();

            boardConfig.CellSize   = DEFAULT_CELL_SIZE;
            boardConfig.ColCount   = 3;
            boardConfig.RowCount   = 3;
            boardConfig.MarginPerc = 1.0f;
            boardConfig.Dest       = imagePattern.getDest();

            Board myBoard = new Board(boardConfig, myCanvas, label, imageManager);

            myBoard.redraw();
        }