Exemplo n.º 1
0
        /// <summary>
        /// 重置按钮1点击
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Reset_1_Click(object sender, RoutedEventArgs e)
        {
            reset_1.IsEnabled = false;
            ContentDialog msgDlg = new ContentDialog()
            {
                Title               = Package.Current.DisplayName,
                Content             = "重置将会清除ApiKey以及认证信息\r\n是否重置?",
                PrimaryButtonText   = "确定",
                SecondaryButtonText = "取消",
                FullSizeDesired     = false,
            };

            msgDlg.PrimaryButtonClick += (_s, _e) => { };
            int nResult = (int)await msgDlg.ShowAsync();

            if (nResult == 1)
            {
                UserConfig config = ((App)Application.Current).GetUserConfig();
                if (config.ResetConfig())
                {
                    await MessageAdapter.ShowMsgDlgAsync("重置成功");

                    apiKey.Password     = "";
                    userName.Text       = "";
                    password.Password   = "";
                    passRepeat.Password = "";
                }
                else
                {
                    await MessageAdapter.ShowMsgDlgAsync("重置失败");
                }
            }
            reset_1.IsEnabled = true;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 保存按钮1点击
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Save_1_Click(object sender, RoutedEventArgs e)
        {
            UserConfig config = ((App)Application.Current).GetUserConfig();

            if (!config.isLogin)
            {
                return;
            }
            if (password.Password != passRepeat.Password)
            {
                await MessageAdapter.ShowMsgDlgAsync("两次输入的密码不一致");

                return;
            }
            bool ret = config.SaveConfig(apiKey.Password, userName.Text, password.Password);

            if (ret)
            {
                await MessageAdapter.ShowMsgDlgAsync("保存成功");
            }
            else
            {
                await MessageAdapter.ShowMsgDlgAsync("保存失败");
            }
        }
Exemplo n.º 3
0
        private async void HyperlinkButton_Click(object sender, RoutedEventArgs e)
        {
            HyperlinkButton btnOper = (HyperlinkButton)sender;
            Uri             uri     = new Uri(btnOper.Content.ToString());
            bool            success = await Windows.System.Launcher.LaunchUriAsync(uri);

            if (!success)
            {
                await MessageAdapter.ShowMsgDlgAsync("打开浏览器失败");
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 确定按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void BtnConfirm_Click(object sender, RoutedEventArgs e)
        {
            UserConfig config = ((App)Application.Current).GetUserConfig();
            bool       ret    = config.Login(userName.Text, passWord.Password);

            if (!ret)
            {
                await MessageAdapter.ShowMsgDlgAsync("登录失败");

                return;
            }
            this.Frame.Navigate(typeof(MainPage));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 测试ApiKey的有效性
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Test_key_Click(object sender, RoutedEventArgs e)
        {
            test_key.IsEnabled = false;
            HttpAdapter adapter = new HttpAdapter();
            bool        ret     = await adapter.KeyValidAsync();

            if (ret)
            {
                await MessageAdapter.ShowMsgDlgAsync("ApiKey有效");
            }
            else
            {
                await MessageAdapter.ShowMsgDlgAsync("ApiKey无效");
            }
            test_key.IsEnabled = true;
        }
Exemplo n.º 6
0
        /// <summary>
        /// 执行重启
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Restart_Click(object sender, RoutedEventArgs e)
        {
            HyperlinkButton btnOper = (HyperlinkButton)sender;
            string          subid   = btnOper.Tag.ToString();
            HttpAdapter     adapter = new HttpAdapter();
            bool            ret     = await adapter.ServerRestart(subid);

            if (ret)
            {
                await MessageAdapter.ShowMsgDlgAsync("重启成功");
            }
            else
            {
                await MessageAdapter.ShowMsgDlgAsync("重启失败");
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 删除ISO
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Destroy_Click(object sender, RoutedEventArgs e)
        {
            HyperlinkButton btnOper = (HyperlinkButton)sender;
            string          isoid   = btnOper.Tag.ToString();
            int             nRet    = await MessageAdapter.ShowYesNoAsync("该操作将删除该ISO镜像\r\n是否进行操作?");

            if (nRet == 1)
            {
                HttpAdapter adapter = new HttpAdapter();
                bool        ret     = await adapter.IsoDestroy(isoid);

                if (ret)
                {
                    await MessageAdapter.ShowMsgDlgAsync("删除成功");
                }
                else
                {
                    await MessageAdapter.ShowMsgDlgAsync("删除失败");
                }
            }
        }
Exemplo n.º 8
0
        private void NavigationView_ItemInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args)
        {
            if (args.IsSettingsInvoked)
            {
                contentFrame.Navigate(typeof(SettingPage));
            }
            else
            {
                string ivkName = args.InvokedItem.ToString();
                switch (ivkName)
                {
                case "云服务器":
                    contentFrame.Navigate(typeof(CloudPage));
                    break;

                case "DNS":
                    MessageAdapter.NoSupportAsync();
                    break;

                case "消息":
                    MessageAdapter.NoSupportAsync();
                    break;

                case "帮助":
                    contentFrame.Navigate(typeof(HelpPage));
                    break;

                case "关于":
                    contentFrame.Navigate(typeof(AboutPage));
                    break;

                case "账号":
                    contentFrame.Navigate(typeof(AccountPage));
                    break;
                    // Annother selections
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// 销毁
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Destroy_Click(object sender, RoutedEventArgs e)
        {
            //WARNING
            //await MessageAdapter.ShowMsgDlgAsync("抱歉,作者不敢测试此单元");
            HyperlinkButton btnOper = (HyperlinkButton)sender;
            string          subid   = btnOper.Tag.ToString();
            int             nRet    = await MessageAdapter.ShowYesNoAsync("该操作将销毁服务器,请谨慎执行该操作\r\n是否进行操作?");

            if (nRet == 1)
            {
                HttpAdapter adapter = new HttpAdapter();
                bool        ret     = await adapter.ServerDestroy(subid);

                if (ret)
                {
                    await MessageAdapter.ShowMsgDlgAsync("销毁成功");
                }
                else
                {
                    await MessageAdapter.ShowMsgDlgAsync("销毁失败");
                }
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// 重装
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void ReInstall_Click(object sender, RoutedEventArgs e)
        {
            //WARNING
            //await MessageAdapter.ShowMsgDlgAsync("抱歉,作者不敢测试此单元");
            HyperlinkButton btnOper = (HyperlinkButton)sender;
            string          subid   = btnOper.Tag.ToString();
            int             nRet    = await MessageAdapter.ShowYesNoAsync("该操作将重装服务器系统,所有数据将被清空\r\n是否进行操作?");

            if (nRet == 1)
            {
                HttpAdapter adapter = new HttpAdapter();
                bool        ret     = await adapter.ServerReInstall(subid);

                if (ret)
                {
                    await MessageAdapter.ShowMsgDlgAsync("重装成功");
                }
                else
                {
                    await MessageAdapter.ShowMsgDlgAsync("重装失败");
                }
            }
        }