Пример #1
0
        public fCamera()
        {
            InitializeComponent();
            // Sử dụng design pattern State
            // Khởi tạo context với trạng thái hiện tại là TakeAPhotoState.
            // Nếu muốn đổi sang trạng thái khác thì gọi
            // context.setState(new TakeAPhotoSpecialState());
            context = new StateContext();

            // Sử dụng thư viện AForge để hiển thị camera và cho phép chụp hình
            lstCamera = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            foreach (FilterInfo info in lstCamera)
            {
                cbbListCamera.Items.Add(info.Name);
            }
            // Chọn camera đầu tiên có trong danh sách
            if (cbbListCamera.Items.Count > 0)
            {
                cbbListCamera.SelectedIndex = 0;
            }

            btnTakeAPhoto.Enabled = false;
            btnClear.Enabled      = false;
        }
 // Ghi đè lên hàm TakeAPhoto ở IState chức năng chụp hình thường
 public Image TakeAPhoto(StateContext context, Image img)
 {
     return(img);
 }
Пример #3
0
 // Ghi đè lên hàm TakeAPhoto ở IState chức năng chụp hình đặc biệt
 public Image TakeAPhoto(StateContext context, Image img)
 {
     // Mở rộng cho chức năng chụp hình có filter khác.
     return(null);
 }