예제 #1
0
        public void Init()
        {
            thisWindow = new XingKongWindow();
            string shutdownWindowJson = File.ReadAllText(@"AppForm.json");

            XingKongWindow.Entity windowEntity = JsonConvert.DeserializeObject <XingKongWindow.Entity>(shutdownWindowJson);
            thisWindow.SetEntity(windowEntity);

            btLaunch  = thisWindow.ControlsSet["btLaunch"] as XingKongButton;
            btBack    = thisWindow.ControlsSet["btBack"] as XingKongButton;
            pbIcon    = thisWindow.ControlsSet["pbIcon"] as XingKongImageBox;
            lbAllApps = thisWindow.ControlsSet["lbAllApps"] as XingKongLabel;
            lbApps    = thisWindow.ControlsSet["lbApps"] as XingKongListBox;

            lbApps.Refresh();

            pbIcon.SkipPreProceed = true;
            pbIcon.LoadPicture(Path.Combine("SystemUI", "appstore.png"));

            apps = AppFinder.GetAppList();
            if ((apps == null) || (apps.Count == 0))
            {
                XingKongMessageBox box1 = new XingKongMessageBox
                {
                    Caption = "提示",
                    Title   = "然而一个应用都没有。"
                };
                box1.btOk.IsChecked = true;
                box1.DialogStyle    = XingKongMessageBox.Style.OK;
                Console.WriteLine("user clicked: " + box1.ShowAsync().Result);
            }
            else
            {
                if (lbApps.Items == null)
                {
                    lbApps.Items = new List <string>();
                }
                foreach (AppInfo info in apps)
                {
                    lbApps.Items.Add(info.AppName);
                }
                lbApps.Refresh();
            }
            XingKongScreen.ClearScreen();
            thisWindow.HardworkDraw();
            XingKongScreen.FreshScreen();
            keyboard             = XingKongScreen.GetKeyboard();
            keyboard.KeyPressed += new Keyboard.KeyPressedHandler(Keyboard_KeyPressed);
        }
예제 #2
0
        private async void Keyboard_KeyPressed(System.Windows.Forms.Keys pressedKey)
        {
            switch (pressedKey)
            {
            case System.Windows.Forms.Keys.Left:
                buttonIndex = (--buttonIndex % 3);
                break;

            case System.Windows.Forms.Keys.Right:
                buttonIndex = (++buttonIndex % 3);
                break;

            default:
                break;
            }
            if (buttonIndex < 0)
            {
                buttonIndex += 3;
            }
            switch (pressedKey)
            {
            case System.Windows.Forms.Keys.Left:
            case System.Windows.Forms.Keys.Right:
                switchButton(buttonIndex);
                XingKongScreen.FreshScreen();
                break;

            case System.Windows.Forms.Keys.Enter:
                if (buttonIndex == 2)
                {
                    //用户选择并点击了了关机按钮
                    XingKongMessageBox mb = new XingKongMessageBox();
                    mb.Caption            = "提示";
                    mb.Title              = "确定要关机吗?";
                    mb.btOk.IsChecked     = false;
                    mb.btCancel.IsChecked = true;
                    Suspend();
                    XingKongMessageBox.DialogResult result = await mb.ShowAsync();

                    Console.WriteLine("user clicked: " + result.ToString());
                    switch (result)
                    {
                    case XingKongMessageBox.DialogResult.OK:
                        Thread t = new Thread(new ThreadStart(ShutdownComputer));
                        t.IsBackground = true;
                        t.Start();
                        break;

                    case XingKongMessageBox.DialogResult.Cancel:
                        Resume();
                        break;

                    default:
                        Resume();
                        break;
                    }
                }
                else if (buttonIndex == 1)
                {
                    //用户选择并点击了应用按钮
                    Suspend();
                    AppForm appForm = new AppForm();
                    appForm.QuitAction    = Resume;
                    appForm.LoadAppAction = LoadAppAction;

                    Thread t = new Thread(new ThreadStart(appForm.Init));
                    t.IsBackground = true;
                    t.Start();
                }
                break;

            case System.Windows.Forms.Keys.F5:
                XingKongScreen.ClearScreen();
                currentForm.HardworkDraw();
                XingKongScreen.FreshScreen();
                break;

            default:
                break;
            }
        }