示例#1
0
        public UICell(UICellLogic logic, BoardLogic boardLogic, FreeContextMenuStrip contextMenu, Position position)
        {
            this.logic       = logic;
            this.boardLogic  = boardLogic;
            this.contextMenu = contextMenu;
            this.position    = position;

            InitializeComponent();

            // Initial state
            labelNumber.Dock         = DockStyle.Fill;
            labelNumber.ForeColor    = (Color)logic.Foreground;
            BackColor                = (Color)logic.Background;
            labelNumber.Text         = logic.Number;
            labelPossibles.ForeColor = (Color)logic.PossiblesForeground;
            labelPossibles.Text      = logic.Possibles;

            // Draw borders
            tableLayoutPanelBorders.CellPaint += OnCellPaint;

            // Listen to logic changes
            logic.PropertyChanged += OnPropertyChanged;

            // Listen to mouse clicks
            panelCell.MouseDown   += OnMouseDown;
            labelNumber.MouseDown += OnMouseDown;
        }
示例#2
0
        public BoardLogic(IUIProvider uiProvider)
        {
            this.uiProvider = uiProvider;

            Undo        = new CommandBase(OnUndo, false);
            Redo        = new CommandBase(OnRedo, false);
            Reset       = new CommandBase(OnReset, false);
            Check       = new CommandBase(OnCheck, false);
            Hint        = new CommandBase(OnHint, false);
            Query       = new CommandBase(OnQuery, false);
            Stats       = new CommandBase(OnStats, true);
            KbdNumber   = new CommandBase(OnKbdNumber, true);
            KbdPossible = new CommandBase(OnKbdPossible, true);
            MoveRight   = new CommandBase(OnMoveRight, true);
            MoveLeft    = new CommandBase(OnMoveLeft, true);
            MoveUp      = new CommandBase(OnMoveUp, true);
            MoveDown    = new CommandBase(OnMoveDown, true);

            for (uint i = 0; i < UICells.Length; i++)
            {
                UICells[i] = new UICellLogic(uiProvider, i);
            }
        }