2016年1月26日 星期二

WPF: Change input language as en-US for bar-code scanner

1. ASUS X450J with Windows 10 Education x64 2. Add reference WindowsInput.DLL 2. Xaml 3. CS public MainWindow() { InitializeComponent(); //----將中文轉為英文輸入模式 文字方塊.KeyDown += 文字方塊_KeyDown; timer1.Interval = new TimeSpan(0, 0, 5); timer1.Tick += Timer1_Tick; timer1.Start(); /* Fail to change the input language in constructor method InputSimulator im = new InputSimulator(); this.Title = "開始掃描學生作業:"; 文字方塊.Focus(); im.Keyboard.ModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.SPACE); // Change the default zh-TW to en-US */ } 4. private void Timer1_Tick(object sender, EventArgs e) { timer1.Stop(); InputSimulator im = new InputSimulator(); this.Title = "開始掃描學生作業:"; 文字方塊.Focus(); im.Keyboard.ModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.SPACE); }

2016年1月9日 星期六

Docker for Windows - Hello World

Ref: https://docs.docker.com/windows/step_one/
1. ASUS X450J with Windows 10 x64 Educational version
2. Follow the steps in ref, it fail to run hello world and show error as ... lookup index.docker.io no DNS servers error
3. Shutdown the computer and Wait for a night. Start boot2docker.iso manually.
4. Start DockerQuickStartTerminal, the hello-world is work properly.
5. Shutdown the Boot2docker in VM and re-start, it still work. ??

2016年1月3日 星期日

Angularjs - 1

Ref: http://www.tutorialspoint.com/angularjs/index.htm
1. AngularJS is a very powerful JavaScript Framework. It is used in Single Page Application (SPA) projects. 
2. Definition:
AngularJS is a structural framework for dynamic web apps. It lets you use HTML as your template language and lets you extend HTML's syntax to express your application's components clearly and succinctly. Angular's data binding and dependency injection eliminate much of the code you currently have to write. And it all happens within the browser, making it an ideal partner with any server technology.
3.The AngularJS Components
The AngularJS framework can be divided into following three major parts −
ng-app − This directive defines and links an AngularJS application to HTML.
ng-model − This directive binds the values of AngularJS application data to HTML input controls.
ng-bind − This directive binds the AngularJS Application data to HTML tags.
Ex1.
<!doctype html>
<html ng-app>
   
   <head>
      <script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.min.js"></script>
   </head>
   
   <body>
      <div>
         <label>Name:</label>
         <input type = "text" ng-model = "yourName" placeholder = "Enter a name here">
         <hr />
         
         <h1>Hello {{yourName}}!</h1>
      </div>
      
   </body>
</html>

Ex2
<html>
   
   <head>
      <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular.min.js"></script>
   </head>
   
   <body ng-app="myapp">
      
      <div ng-controller="HelloController">
         <h2>
Welcome {{helloTo.title}} to the world of Tutorialspoint!</h2>
</div>
<script>
         angular.module("myapp", [])
         
         .controller("HelloController", function($scope) {
            $scope.helloTo = {};
            $scope.helloTo.title = "AngularJS";
         });
      </script>
      
   </body>
</html>
Include AngularJS
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
Point to AngularJS app
<body ng-app="myapp">
</body>
View
<script div ng-controller="HelloController">
<h2>
Welcome {{helloTo.title}} to the world of Tutorialspoint!</h2>
</div>
Controller
<script>
   angular.module("myapp", [])
   
   .controller("HelloController", function($scope) {
      $scope.helloTo = {};
      $scope.helloTo.title = "AngularJS";
   });
</script>