Esempio n. 1
0
        private static void Main(string[] args)
        {
            #region Test
            Log.WriteLine("Log");
            SqlLog.WriteLine("SqlLog");
            #endregion

            // 1. SystemExt
            Sample_SystemExt();

            // 2. Form Animaton
            FormAnimation frm = new FormAnimation();
            frm.ShowAsync();

            // 3. DeviceManager
            var dtUSBDevice    = DeviceManager.GetUSBDevices();
            var dtDriver       = DeviceManager.GetDriver();
            var dtDeviceDetail = DeviceManager.GetDeviceDetail();
            var dtBusInfo      = DeviceManager.GetBusInfo();

            // 4. NetWork Detect
            // Implement Delegate Event "AvailabilityChanged"
            NetworkStatus.AvailabilityChanged += NetworkStatus_AvailabilityChanged;
            Debug.WriteLine("The Network is " + (NetworkStatus.IsAvailable ? "Connect" : "DisConnect"));

            /* Output
             * The Network is Connect
             * //close wifi
             * The Network is DisConnect
             * //open wifi
             * The thread 0xa844 has exited with code 0 (0x0).
             * The Network is Connect
             */

            // 5. Set System Volume
            //SystemVoice.AuInit();
            Debug.WriteLine("The voice volume is " + SystemVoice.GetVolume());
            SystemVoice.SetVolume(0);
            Debug.WriteLine("The voice volume is " + SystemVoice.GetVolume());

            /* Output
             * The voice volume is 10
             * The voice volume is 0
             */

            // 6. Minimize Console UI
            SysUtil.HideApplication();
            SysUtil.KillProcessByName("Sample");

            // 7. Http Extension
            // Setup URL and Header(if neccesary)
            HttpExtension.URL = "http://192.168.100.235:9000/dev/api/v1/";
            var header = new Dictionary <string, string>();
            header.Add("Authorization", "Token 3c1fa688462c30c105df08326406d4fb");
            HttpExtension.Headers = header;

            var dtCity      = HttpExtension.Get <Cities>("lists/cascades?cascade-id=1");
            var dtCityAsync = HttpExtension.GetAsync <Cities>("lists/cascades?cascade-id=1").Result;
            var strCity     = HttpExtension.GetStrAsync("lists/cascades?cascade-id=1").Result;
            //var dtUser = HttpExtension.Post<User>("Users", "{\"ids\":[1,2,3]}");
            //var dtUserAsync = HttpExtension.PostAsync<User>("Users", "{\"ids\":[1,2,3]}").Result;
            //var strUser = HttpExtension.PostStrAsync("Users", "{\"ids\":[1,2,3]}").Result;

            // 8. Monitor Display's Brightness Get/Set
            Debug.WriteLine("The Brightness is " + Display.GetBrightness());
            Debug.WriteLine("Set Brightness to 20 ");
            Display.SetBrightness(20);
            System.Threading.Thread.Sleep(2000);
            Debug.WriteLine("Set Brightness to 100 ");
            Display.SetBrightness(100);

            while (true)
            {
                var result = Console.ReadLine();
                if (result.Equals("q"))
                {
                    break;
                }
            }
        }