コード例 #1
0
        private async void buttonAutoFill_Click(object sender, RoutedEventArgs e)
        {
            ShowLoading("自动填写...");
            try
            {
                await JSCodeString.RunJs(
                    webViewMain,
                    JSCodeString.JsAutoFillTitle +
                    "AutoSetBrief(\"" + GetTransString(StorageManager.editSettings.strTitle2Brief) + "\");"); //.Replace("\\", "\\\\")

                await JSCodeString.RunJs(
                    webViewMain,
                    JSCodeString.JsAutoFillTools +
                    "AutoSetTools(\"" + GetTransString(StorageManager.editSettings.strTitle2Tool) + "\");"); //Replace("\n", "\\n").Replace("\r","\\n")

                await JSCodeString.RunJs(
                    webViewMain,
                    JSCodeString.JsAutoFillNotice +
                    "SetNoticeIndex(0, \"" + GetTransString(StorageManager.editSettings.StoreStrAttention) + "\");");

                await JSCodeString.RunJs2(
                    webViewMain,
                    JSCodeString.JsAutoSetCategory,
                    "AutoSetCategory(\"" + GetTransString(StorageManager.editSettings.strTitle2Category) + "\");"); //.Replace("\n", "\\n").Replace("\r", "\\n")

                if (StorageManager.editSettings.ifAddStep)
                {
                    await JSCodeString.RunJs2(
                        webViewMain,
                        JSCodeString.JsAutoAddStep,
                        "AddStep(" + StorageManager.editSettings.addStepCount.ToString() + ");");
                }

                if (StorageManager.editSettings.ifCheckOrigin)
                {
                    await JSCodeString.RunJs2(
                        webViewMain,
                        JSCodeString.JsAutoCheckOrigin,
                        "CheckOrigin(true)");
                }

                if (StorageManager.editSettings.ifSteps)
                {
                    await JSCodeString.RunJs2(
                        webViewMain,
                        JSCodeString.JsAutoFillSteps,
                        "SetSteps(\"" + GetTransString(StorageManager.editSettings.strSteps) + "\");"
                        );
                }
            }
            catch (Exception ee)
            {
                await ShowMessageDialog("自动填写出现问题", "当前页面可能不是编辑器页面,或者设置有问题(含有特殊字符,或者设置格式错误)");
            }
            HideLoading();
        }
コード例 #2
0
 private async void buttonBigPicture_Click(object sender, RoutedEventArgs e)
 {
     ShowLoading("运行JS...");
     try
     {
         await JSCodeString.RunJs(webViewMain, JSCodeString.JsAddPictureBox);
     }
     catch (Exception)
     {
         await ShowMessageDialog("添加失败", "当前页面可能不是编辑器页面");
     }
     HideLoading();
 }
コード例 #3
0
        private async void buttonAutoComplete_Click(object sender, RoutedEventArgs e)
        {
            ShowLoading("初始化...");
            try
            {
                await JSCodeString.AddScriptUri(webViewMain, "ms-appx-web:///Assets/code/jquery.autocompleter.js");

                await JSCodeString.AddCssUri(webViewMain, "ms-appx-web:///Assets/code/jquery.autocompleter.css");

                await JSCodeString.AddScriptUri(webViewMain, "ms-appx-web:///Assets/code/AutoComplete.js");

                ShowLoading("加载组件中...");
                string data = await StorageManager.ReadAutoCompleteData("");

                await Task.Delay(500);

                if (data == "")
                {
                    await JSCodeString.RunJs(webViewMain, "InitAutoComplete();");
                }
                else
                {
                    //希望执行js代码: InitAutoComplete("{...}"),
                    //data就是一个json字符串:"{...}"

                    await JSCodeString.RunJs(webViewMain,
                                             "InitAutoComplete(\""
                                             + GetTransString(data)
                                             + "\")"
                                             );

                    //"InitAutoComplete(\"\\\"ms-appdata:///local/AutoCompleteData/default.json\\\"\");");
                }
            }
            catch (Exception ee)
            {
                await ShowMessageDialog("加载 [自动补全] 出现问题", "当前页面可能不是编辑器页面。"); // ee.GetType().ToString() + '\n' +  ee.Message);
            }
            HideLoading();
        }
コード例 #4
0
        /// <summary>
        /// 尝试从存储读取Cookie,尝试更新Main。
        /// </summary>
        public async void SelfCheckAndInit()
        {
            gridMain.Visibility   = Visibility.Visible;
            gridSecond.Visibility = Visibility.Collapsed;

            JSCodeString.SetWebView(webViewMain);
            WebSetUpdate(true, false, false, false);

            ShowLoading("读取设置...");
            bool isSettingsRead = await StorageManager.ReadSettings();

            if (StorageManager.AppSettings.isFirstIn || StorageManager.AppSettings.version != "1.4.3")
            {
                ContentNewDialog    cnd  = new ContentNewDialog();
                ContentDialogResult cdr2 = await cnd.ShowAsync();

                if (cdr2 == ContentDialogResult.Secondary)
                {
                    StorageManager.AppSettings.isFirstIn = false;
                    StorageManager.AppSettings.version   = "1.4.3";
                }
                ShowLoading("更新设置...");

                await StorageManager.SaveSettings();
            }

            if (!isSettingsRead)
            {
                await StorageManager.SaveSettings();
            }

            ShowLoading("读取Edit设置...");
            await StorageManager.ReadEditSettings();

            if (Window.Current.Bounds.Width < 1100)
            {
                textUserName.Text = "您的窗口过窄";
            }
            Uri[] uris =
            {
                new Uri("ms-appx:///Assets/8-5-4.jpg"),
                new Uri("ms-appx:///Assets/8-5-5.jpg"),
                new Uri("ms-appx:///Assets/8-5-6.jpg"),
                new Uri("ms-appx:///Assets/8-5-1.jpg"),
                new Uri("ms-appx:///Assets/8-5-2.jpg"),
                new Uri("ms-appx:///Assets/8-5-3.jpg")
            };

            Random r = new Random();
            int    i = r.Next() % 6;

            ShowLoading("加载背景...");
            try
            {
                StorageFile file =
                    await StorageFile.GetFileFromApplicationUriAsync(uris[i]);

                IRandomAccessStream stream =
                    await file.OpenReadAsync(); //打开读取流


                BitmapImage img = new BitmapImage();
                await img.SetSourceAsync(stream);       //从流产生BitmapImage

                ImageBrush ib = new ImageBrush();       //新建ImageBrush画刷
                ib.ImageSource = img;
                ib.Stretch     = Stretch.UniformToFill; //设置拉伸样式


                this.Background = ib;

                //如上设置刚才创建的ImageBrush
                //Background是一个Brush类型属性


                stream.Dispose();
            }
            catch (Exception e)
            {
                await ShowMessageDialog("非关键异常", "自动背景图更换失败,请联系开发者\n" + e.Message);
            }



            isSelfChecked = true;
            ShowControls();
            HelpStoryboard.Begin();
            OpenFolderStoryboard.Begin();

            ShowLoading("读取Cookie...");
            string cookieGet = await StorageManager.GetCookieTry();

            if (cookieGet != null)
            {
                if (!ExpManager.SetCookie(cookieGet))
                {
                    return;
                }
                ShowLoading("尝试更新个人信息...");
                bool getSucceed = await UpdateMain();

                if (!getSucceed)
                {
                    await ShowMessageDialog("主页获取不成功", "如果不是网络问题,那可能是BDUSS已经失效。(是否有退出登录操作?)");
                }
                HideLoading();
            }
            else
            {
                buttonSetCookie_Click(null, null);
            }
        }