/// <summary>
        /// A form for token
        /// </summary>
        /// <returns>bool true if OK was pressed, false if cancel</returns>
        public bool ShowConfigDialog()
        {
            SettingsForm settingsForm;
            ILanguage    lang = Language.GetInstance();

            BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(DropboxPlugin.Attributes.Name, lang.GetString(LangKey.communication_wait));

            try {
                settingsForm = new SettingsForm(this);
            } finally {
                backgroundForm.CloseDialog();
            }
            settingsForm.AuthToken                  = this.DropboxAccessToken;
            settingsForm.UploadFormat               = this.UploadFormat.ToString();
            settingsForm.AfterUploadOpenHistory     = this.AfterUploadOpenHistory;
            settingsForm.AfterUploadLinkToClipBoard = this.AfterUploadLinkToClipBoard;
            DialogResult result = settingsForm.ShowDialog();

            if (result == DialogResult.OK)
            {
                this.DropboxAccessToken = settingsForm.AuthToken;
                this.UploadFormat       = (OutputFormat)Enum.Parse(typeof(OutputFormat), settingsForm.UploadFormat.ToLower());

                this.AfterUploadOpenHistory     = settingsForm.AfterUploadOpenHistory;
                this.AfterUploadLinkToClipBoard = settingsForm.AfterUploadLinkToClipBoard;
                IniConfig.Save();

                // Save DropboxAccessToken from file
                DropboxUtils.SaveAccessToken();

                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
        private void button_Save_Click(object sender, RoutedEventArgs e)
        {
            IniConfig ini = MainSave.ConfigMain;

            ini.Object["OrderDIY"]["LoliConPic"]       = new IValue(text_LoliConPic.Text);
            ini.Object["OrderDIY"]["ClearLimit"]       = new IValue(text_ClearLimit.Text);
            ini.Object["OrderDIY"]["PIDSearch"]        = new IValue(text_PIDSearch.Text);
            ini.Object["OrderDIY"]["HotSearch"]        = new IValue(text_HotSearch.Text);
            ini.Object["OrderDIY"]["SauceNao"]         = new IValue(text_SauceNao.Text);
            ini.Object["OrderDIY"]["TraceMoeSearch"]   = new IValue(text_TraceMoeSearch.Text);
            ini.Object["OrderDIY"]["YandereIDSearch"]  = new IValue(text_YandereIDSearch.Text);
            ini.Object["OrderDIY"]["YandereTagSearch"] = new IValue(text_YandereTagSearch.Text);

            foreach (var uiitem in stackpanel_AnwDIY.Children)
            {
                var textboxTemp = uiitem as TextBox;
                try
                {
                    if (uiitem.GetType().Name == "TextBox")
                    {
                        ini.Object["AnswerDIY"][textboxTemp.Name.Replace("text_", "")] = new IValue(textboxTemp.Text.Replace("\n", @"\n"));
                    }
                }
                catch { }
            }
            ini.Save();
        }
Exemplo n.º 3
0
        private void button_SettingsSave_Click(object sender, RoutedEventArgs e)
        {
            ini.Object["Config"]["ApiSwitch"] = new IValue(togglebutton_ApiKey.IsChecked.GetValueOrDefault() ? 1 : 0);
            if (togglebutton_ApiKey.IsChecked.GetValueOrDefault())
            {
                ini.Object["Config"]["ApiKey"] = new IValue(textbox_ApiKey.Text);
            }
            ini.Object["Config"]["MaxofPerson"] = new IValue((IsPureInteger(textbox_PersonLimit.Text)) ? textbox_PersonLimit.Text : "5");
            ini.Object["Config"]["MaxofGroup"]  = new IValue((IsPureInteger(textbox_GroupLimit.Text)) ? textbox_GroupLimit.Text : "30");
            int count = 0;
            List <BindingGroup> group = (List <BindingGroup>)ItemControl_Group.DataContext;

            foreach (var item in group)
            {
                if (item.IsChecked)
                {
                    ini.Object["GroupList"][$"Index{count}"] = new IValue(item.GroupId.ToString());
                    count++;
                }
            }
            ini.Object["GroupList"]["Count"] = new IValue(count.ToString());
            count = 0;
            foreach (var item in listbox_Admin.Items)
            {
                ini.Object["Admin"][$"Index{count}"] = new IValue(item.ToString());
                count++;
            }
            ini.Object["Admin"]["Count"] = new IValue(count.ToString());
            ini.Save();
            SnackbarMessage_Show("更改已保存", 2);
        }
Exemplo n.º 4
0
        public static void loadConfig(CQEventArgs e)
        {
            String iniFile = e.CQApi.AppDirectory + "config.ini";

            if (!File.Exists(iniFile))
            {
                File.Create(iniFile).Close();
                IniConfig iniConfig = new IniConfig(iniFile);
                iniConfig.Object["Master"] = new ISection("Master")
                {
                    { "MasterQQ", 0 }
                };
                iniConfig.Save();
                e.CQLog.Info("工会战排刀器", "生成了config.ini,请更新其中的信息。");
            }
            else
            {
                IniConfig iniConfig = new IniConfig(iniFile);
                try {
                    iniConfig.Load();
                    iniConfig.Object["Master"].TryGetValue("MasterQQ", out IValue value);
                    e.CQLog.Info("Debug", value.ToString());
                    ConfigHandler.master_qq = value.ToInt64();
                    e.CQLog.Info("工会战排刀器", "配置已加载,master是" + master_qq.ToString());
                } catch {
                    e.CQLog.Error("工会战排刀器", "读取config.ini时发生错误");
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Save with showing a dialog
        /// </summary>
        /// <param name="surface"></param>
        /// <param name="captureDetails"></param>
        /// <returns>Path to filename</returns>
        public static string SaveWithDialog(ISurface surface, ICaptureDetails captureDetails)
        {
            string returnValue = null;

            using (SaveImageFileDialog saveImageFileDialog = new SaveImageFileDialog(captureDetails))
            {
                DialogResult dialogResult = saveImageFileDialog.ShowDialog();
                if (dialogResult.Equals(DialogResult.OK))
                {
                    try
                    {
                        string fileNameWithExtension         = saveImageFileDialog.FileNameWithExtension;
                        SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(FormatForFilename(fileNameWithExtension));
                        if (conf.OutputFilePromptQuality)
                        {
                            QualityDialog qualityDialog = new QualityDialog(outputSettings);
                            qualityDialog.ShowDialog();
                        }
                        // TODO: For now we always overwrite, should be changed
                        Save(surface, fileNameWithExtension, true, outputSettings, conf.OutputFileCopyPathToClipboard);
                        returnValue = fileNameWithExtension;
                        IniConfig.Save();
                    }
                    catch (ExternalException)
                    {
                        MessageBox.Show(Language.GetFormattedString("error_nowriteaccess", saveImageFileDialog.FileName).Replace(@"\\", @"\"), Language.GetString("error"));
                    }
                }
            }
            return(returnValue);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Upload the capture to imgur
        /// </summary>
        /// <param name="captureDetails">ICaptureDetails</param>
        /// <param name="surfaceToUpload">ISurface</param>
        /// <param name="uploadUrl">out string for the url</param>
        /// <returns>true if the upload succeeded</returns>
        public bool Upload(ICaptureDetails captureDetails, ISurface surfaceToUpload, out string uploadUrl)
        {
            SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(_config.UploadFormat, _config.UploadJpegQuality, _config.UploadReduceColors);

            try {
                string    filename  = Path.GetFileName(FilenameHelper.GetFilenameFromPattern(_config.FilenamePattern, _config.UploadFormat, captureDetails));
                ImgurInfo imgurInfo = null;

                // Run upload in the background
                new PleaseWaitForm().ShowAndWait("Imgur plug-in", Language.GetString("imgur", LangKey.communication_wait),
                                                 delegate
                {
                    imgurInfo = ImgurUtils.UploadToImgur(surfaceToUpload, outputSettings, captureDetails.Title, filename);
                    if (imgurInfo != null && _config.AnonymousAccess)
                    {
                        Log.InfoFormat("Storing imgur upload for hash {0} and delete hash {1}", imgurInfo.Hash, imgurInfo.DeleteHash);
                        _config.ImgurUploadHistory.Add(imgurInfo.Hash, imgurInfo.DeleteHash);
                        _config.runtimeImgurHistory.Add(imgurInfo.Hash, imgurInfo);
                        CheckHistory();
                    }
                }
                                                 );

                if (imgurInfo != null)
                {
                    // TODO: Optimize a second call for export
                    using (Image tmpImage = surfaceToUpload.GetImageForExport()) {
                        imgurInfo.Image = ImageHelper.CreateThumbnail(tmpImage, 90, 90);
                    }
                    IniConfig.Save();

                    if (_config.UsePageLink)
                    {
                        uploadUrl = imgurInfo.Page;
                    }
                    else
                    {
                        uploadUrl = imgurInfo.Original;
                    }
                    if (!string.IsNullOrEmpty(uploadUrl) && _config.CopyLinkToClipboard)
                    {
                        try
                        {
                            ClipboardHelper.SetClipboardData(uploadUrl);
                        }
                        catch (Exception ex)
                        {
                            Log.Error("Can't write to clipboard: ", ex);
                            uploadUrl = null;
                        }
                    }
                    return(true);
                }
            } catch (Exception e) {
                Log.Error("Error uploading.", e);
                MessageBox.Show(Language.GetString("imgur", LangKey.upload_failure) + " " + e.Message);
            }
            uploadUrl = null;
            return(false);
        }
Exemplo n.º 7
0
 /// <summary>
 /// The user wants to apply the changes
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OK_Click(object sender, RoutedEventArgs e)
 {
     coreProxy.Commit();
     Apply(treeItems, true);
     IniConfig.Save();
     this.Close();
 }
Exemplo n.º 8
0
        private void button_Save_Click(object sender, EventArgs e)
        {
            string path = CQSave.AppDirectory + "Config.ini";

            ini.Object["ExtraConfig"]["TextGacha"]   = new IValue((checkBox_TextGacha.Checked) ? "1" : "0");
            ini.Object["ExtraConfig"]["ExecuteSql"]  = new IValue((checkBox_Sql.Checked) ? "1" : "0");
            ini.Object["ExtraConfig"]["ImageFormat"] = new IValue((radioButton_Picjpg.Checked) ? "jpg" : "png");

            ini.Object["ExtraConfig"]["SwitchBP1"]        = new IValue((checkBox_SwBP1.Checked) ? "1" : "0");
            ini.Object["ExtraConfig"]["SwitchBP10"]       = new IValue((checkBox_SwBP10.Checked) ? "1" : "0");
            ini.Object["ExtraConfig"]["SwitchJZA1"]       = new IValue((checkBox_SwJZA1.Checked) ? "1" : "0");
            ini.Object["ExtraConfig"]["SwitchJZA10"]      = new IValue((checkBox_SwJZA10.Checked) ? "1" : "0");
            ini.Object["ExtraConfig"]["SwitchJZB1"]       = new IValue((checkBox_SwJZB1.Checked) ? "1" : "0");
            ini.Object["ExtraConfig"]["SwitchJZB10"]      = new IValue((checkBox_SwJZB10.Checked) ? "1" : "0");
            ini.Object["ExtraConfig"]["SwitchKC1"]        = new IValue((checkBox_SwKC1.Checked) ? "1" : "0");
            ini.Object["ExtraConfig"]["SwitchKC10"]       = new IValue((checkBox_SwKC10.Checked) ? "1" : "0");
            ini.Object["ExtraConfig"]["SwitchQueDiamond"] = new IValue((checkBox_SwQueDiamond.Checked) ? "1" : "0");
            ini.Object["ExtraConfig"]["SwitchResSign"]    = new IValue((checkBox_SwResSign.Checked) ? "1" : "0");
            ini.Object["ExtraConfig"]["SwitchGetHelp"]    = new IValue((checkBox_SwGetHelp.Checked) ? "1" : "0");
            ini.Object["ExtraConfig"]["SwitchGetPool"]    = new IValue((checkBox_SwGetPool.Checked) ? "1" : "0");
            ini.Object["ExtraConfig"]["SwitchKaKin"]      = new IValue((checkBox_SwKaKin.Checked) ? "1" : "0");
            ini.Object["ExtraConfig"]["SwitchOpenGroup"]  = new IValue((checkBox_SwOpenGroup.Checked) ? "1" : "0");
            ini.Object["ExtraConfig"]["SwitchCloseGroup"] = new IValue((checkBox_SwCloseGroup.Checked) ? "1" : "0");
            ini.Object["ExtraConfig"]["SwitchOpenAdmin"]  = new IValue((checkBox_SwOpenAdmin.Checked) ? "1" : "0");

            ini.Save();

            MessageBox.Show("更改已保存");
        }
Exemplo n.º 9
0
        public SearchPageViewModel()
        {
            ViewModelManager.SearchPageViewModel = this;
            SearchProgressVisibility             = Visibility.Visible;
            DataVisibility      = Visibility.Hidden;
            NoResultVisibility  = Visibility.Hidden;
            ClickBackCommand    = new DelegateCommand(new Action(() => PageManager.SearchPage.NavigationService.GoBack()));
            ClickNeteaseCommand = new DelegateCommand <object>(new Action <object>(ClickNeteaseExecute));
            ClickKugouCommand   = new DelegateCommand <object>(new Action <object>(ClickKugouExecute));
            ClickTencentCommand = new DelegateCommand <object>(new Action <object>(ClickTencentExecute));
            PrePlayCommand      = new DelegateCommand <object>(new Action <object>(PrePlayExecute));

            //搜索选项加载
            IniConfig ini = new IniConfig("Config.ini");

            ini.Load();
            try
            {
                SearchOption = ini.GetObject <SearchOptionModel>();
            }
            catch (ArgumentException)
            {
                SearchOption = new SearchOptionModel {
                    Kugou = true, Netease = true, Tencent = true
                };
                ini.SetObject(SearchOption);
                ini.Save();
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Save with showing a dialog
        /// </summary>
        /// <param name="surface"></param>
        /// <param name="captureDetails"></param>
        /// <returns>Path to filename</returns>
        public static string SaveWithDialog(ISurface surface, ICaptureDetails captureDetails)
        {
            string returnValue = null;

            using (SaveImageFileDialog saveImageFileDialog = new SaveImageFileDialog(captureDetails))
            {
                DialogResult dialogResult = saveImageFileDialog.ShowDialog();
                if (dialogResult.Equals(DialogResult.OK))
                {
                    try
                    {
                        string fileNameWithExtension         = saveImageFileDialog.FileNameWithExtension;
                        SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(FormatForFilename(fileNameWithExtension));
                        if (conf.OutputFilePromptQuality)
                        {
                            QualityDialog qualityDialog = new QualityDialog(outputSettings);
                            qualityDialog.ShowDialog();
                        }
                        // For now we always overwrite, should be changed
                        Save(surface, fileNameWithExtension, true, outputSettings, conf.OutputFileCopyPathToClipboard);
                        returnValue = fileNameWithExtension;
                        IniConfig.Save();
                    }
                    catch (ExternalException)
                    {
                        MessageBox.Show(string.Format("Cannot save file to {0}.\r\nPlease check write accessibility of the selected storage location.",
                                                      saveImageFileDialog.FileName).Replace(@"\\", @"\"), "Error");
                    }
                }
            }
            return(returnValue);
        }
Exemplo n.º 11
0
        private static bool Authorize()
        {
            string authorizeUrl = string.Format("{0}?client_id={1}&response_type=code&state=dropboxplugin&redirect_uri={2}", AuthorizeUri, BoxCredentials.ClientId, RedirectUri);

            OAuthLoginForm loginForm = new OAuthLoginForm("Box Authorize", new Size(1060, 600), authorizeUrl, RedirectUri);

            loginForm.ShowDialog();
            if (!loginForm.isOk)
            {
                return(false);
            }
            var callbackParameters = loginForm.CallbackParameters;

            if (callbackParameters == null || !callbackParameters.ContainsKey("code"))
            {
                return(false);
            }

            string authorizationResponse = PostAndReturn(new Uri(TokenUri), string.Format("grant_type=authorization_code&code={0}&client_id={1}&client_secret={2}", callbackParameters["code"], BoxCredentials.ClientId, BoxCredentials.ClientSecret));
            var    authorization         = JsonSerializer.Deserialize <Authorization>(authorizationResponse);

            Config.BoxToken = authorization.AccessToken;
            IniConfig.Save();
            return(true);
        }
Exemplo n.º 12
0
 private void Button_okClick(object sender, EventArgs e)
 {
     // update config
     coreConfiguration.OutputPrintPromptOptions = !checkbox_dontaskagain.Checked;
     IniConfig.Save();
     DialogResult = DialogResult.OK;
 }
Exemplo n.º 13
0
        /// <summary>
        /// Implementation of the IPlugin.Configure
        /// </summary>
        public virtual void Configure()
        {
            ConfluenceConfiguration     clonedConfig = _config.Clone();
            ConfluenceConfigurationForm configForm   = new ConfluenceConfigurationForm(clonedConfig);
            string url          = _config.Url;
            bool?  dialogResult = configForm.ShowDialog();

            if (dialogResult.HasValue && dialogResult.Value)
            {
                // copy the new object to the old...
                clonedConfig.CloneTo(_config);
                IniConfig.Save();
                if (_confluenceConnector != null)
                {
                    if (!url.Equals(_config.Url))
                    {
                        if (_confluenceConnector.IsLoggedIn)
                        {
                            _confluenceConnector.Logout();
                        }
                        _confluenceConnector = null;
                    }
                }
            }
        }
Exemplo n.º 14
0
        public bool Upload(ICaptureDetails captureDetails, Image image)
        {
            using (MemoryStream stream = new MemoryStream())
            {
                BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(Attributes.Name, lang.GetString(LangKey.communication_wait));

                host.SaveToStream(image, stream, config.UploadFormat, config.UploadJpegQuality);
                byte[] buffer = stream.GetBuffer();

                try
                {
                    string     filename    = Path.GetFileName(host.GetFilename(config.UploadFormat, captureDetails));
                    string     contentType = "image/" + config.UploadFormat.ToString();
                    PicasaInfo picasaInfo  = PicasaUtils.UploadToPicasa(buffer, captureDetails.DateTime.ToString(), filename, contentType);
                    if (config.PicasaUploadHistory == null)
                    {
                        config.PicasaUploadHistory = new Dictionary <string, string>();
                    }

                    if (picasaInfo.ID != null)
                    {
                        LOG.InfoFormat("Storing Picasa upload for id {0}", picasaInfo.ID);

                        config.PicasaUploadHistory.Add(picasaInfo.ID, picasaInfo.ID);
                        config.runtimePicasaHistory.Add(picasaInfo.ID, picasaInfo);
                    }

                    picasaInfo.Image = PicasaUtils.CreateThumbnail(image, 90, 90);
                    // Make sure the configuration is save, so we don't lose the deleteHash
                    IniConfig.Save();
                    // Make sure the history is loaded, will be done only once
                    PicasaUtils.LoadHistory();

                    // Show
                    if (config.AfterUploadOpenHistory)
                    {
                        PicasaHistory.ShowHistory();
                    }

                    if (config.AfterUploadLinkToClipBoard)
                    {
                        Clipboard.SetText(picasaInfo.LinkUrl(config.PictureDisplaySize));
                    }
                    return(true);
                }
                catch (Google.GData.Client.InvalidCredentialsException eLo)
                {
                    MessageBox.Show(lang.GetString(LangKey.InvalidCredentials));
                }
                catch (Exception e)
                {
                    MessageBox.Show(lang.GetString(LangKey.upload_failure) + " " + e.ToString());
                }
                finally
                {
                    backgroundForm.CloseDialog();
                }
            }
            return(false);
        }
Exemplo n.º 15
0
        public TitleFixProcessor()
        {
            List <string> corruptKeys = new List <string>();

            foreach (string key in config.ActiveTitleFixes)
            {
                if (!config.TitleFixMatcher.ContainsKey(key))
                {
                    LOG.WarnFormat("Key {0} not found, configuration is broken! Disabling this key!");
                    corruptKeys.Add(key);
                }
            }

            // Fix configuration if needed
            if (corruptKeys.Count > 0)
            {
                foreach (string corruptKey in corruptKeys)
                {
                    // Removing any reference to the key
                    config.ActiveTitleFixes.Remove(corruptKey);
                    config.TitleFixMatcher.Remove(corruptKey);
                    config.TitleFixReplacer.Remove(corruptKey);
                }
                config.IsDirty = true;
            }
            if (config.IsDirty)
            {
                IniConfig.Save();
            }
        }
Exemplo n.º 16
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            IniConfig ini = new IniConfig(Common.CQApi.AppDirectory + "config.ini");

            ini.Load();
            ini.Object["System"]["Master"] = txtMaster.Text;
            ini.Save();
            MessageBox.Show("保存成功!");
        }
Exemplo n.º 17
0
        private void button_Save_Click(object sender, EventArgs e)
        {
            string path = $@"{MainSave.AppDirectory}Config.ini";

            ini.Object["Order"]["KC1"]   = new IValue(textBox_OrderKC1.Text);
            ini.Object["Order"]["KC10"]  = new IValue(textBox_OrderKC10.Text);
            ini.Object["Order"]["JZA1"]  = new IValue(textBox_OrderJZA1.Text);
            ini.Object["Order"]["JZA10"] = new IValue(textBox_OrderJZA10.Text);
            ini.Object["Order"]["JZB1"]  = new IValue(textBox_OrderJZB1.Text);
            ini.Object["Order"]["JZB10"] = new IValue(textBox_OrderJZB10.Text);
            ini.Object["Order"]["BP1"]   = new IValue(textBox_OrderBP1.Text);
            ini.Object["Order"]["BP10"]  = new IValue(textBox_OrderBP10.Text);

            ini.Object["Order"]["Register"]     = new IValue(textBox_OrderRegiter.Text);
            ini.Object["Order"]["Sign"]         = new IValue(textBox_OrderSign.Text);
            ini.Object["Order"]["SignReset"]    = new IValue(textBox_OrderSignReset.Text);
            ini.Object["Order"]["QueryDiamond"] = new IValue(textBox_OrderQueryDiamond.Text);
            ini.Object["Order"]["Help"]         = new IValue(textBox_OrderHelp.Text);
            ini.Object["Order"]["GetPool"]      = new IValue(textBox_OrderGetPool.Text);
            ini.Object["Order"]["OpenGacha"]    = new IValue(textBox_OrderOpenGacha.Text);
            ini.Object["Order"]["CloseGacha"]   = new IValue(textBox_OrderCloseGacha.Text);

            ini.Object["Answer"]["KC1"]   = new IValue(textBox_AnsKC1.Text);
            ini.Object["Answer"]["KC10"]  = new IValue(textBox_AnsKC10.Text);
            ini.Object["Answer"]["JZA1"]  = new IValue(textBox_AnsJZA1.Text);
            ini.Object["Answer"]["JZA10"] = new IValue(textBox_AnsJZA10.Text);
            ini.Object["Answer"]["JZB1"]  = new IValue(textBox_AnsJZB1.Text);
            ini.Object["Answer"]["JZB10"] = new IValue(textBox_AnsJZB10.Text);
            ini.Object["Answer"]["BP1"]   = new IValue(textBox_AnsBP1.Text);
            ini.Object["Answer"]["BP10"]  = new IValue(textBox_AnsBP10.Text);

            ini.Object["Answer"]["Register"]     = new IValue(textBox_AnsRegister.Text);
            ini.Object["Answer"]["MutiRegister"] = new IValue(textBox_AnsMutiRegister.Text);
            ini.Object["Answer"]["Sign1"]        = new IValue(textBox_AnsSign1.Text);
            ini.Object["Answer"]["Sign2"]        = new IValue(textBox_AnsSign2.Text);
            ini.Object["Answer"]["MutiSign"]     = new IValue(textBox_AnsMutiSign.Text);
            ini.Object["Answer"]["QueryDiamond"] = new IValue(textBox_AnsQueryDiamond.Text);
            ini.Object["Answer"]["NoReg"]        = new IValue(textBox_AnsNoReg.Text);
            ini.Object["Answer"]["LowDiamond"]   = new IValue(textBox_AnsLowDiamond.Text);

            ini.Object["Answer"]["Reset1"] = new IValue(textBox_SignReset1.Text);
            ini.Object["Answer"]["Reset2"] = new IValue(textBox_SignReset2.Text);
            ini.Object["Answer"]["Reset3"] = new IValue(textBox_SignReset3.Text);
            ini.Object["Answer"]["Reset4"] = new IValue(textBox_SignReset4.Text);
            ini.Object["Answer"]["Reset5"] = new IValue(textBox_SignReset5.Text);
            ini.Object["Answer"]["Reset6"] = new IValue(textBox_SignReset6.Text);

            ini.Object["Answer"]["Help"] = new IValue(@textBox_AnsHelp.Text);

            ini.Object["GetDiamond"]["RegisterMin"] = new IValue(textBox_ResisterMin.Text);
            ini.Object["GetDiamond"]["RegisterMax"] = new IValue(textBox_RegisterMax.Text);
            ini.Object["GetDiamond"]["SignMin"]     = new IValue(textBox_SignMin.Text);
            ini.Object["GetDiamond"]["SignMax"]     = new IValue(textBox_SignMax.Text);

            ini.Save();
            MessageBox.Show("更改已保存,重载插件后生效");
        }
Exemplo n.º 18
0
        public static void LoadHistory()
        {
            if (config.runtimeBoxHistory == null)
            {
                return;
            }
            if (config.BoxUploadHistory == null)
            {
                return;
            }

            if (config.runtimeBoxHistory.Count == config.BoxUploadHistory.Count)
            {
                return;
            }
            // Load the Box history
            List <string> hashes = new List <string>();

            foreach (string hash in config.BoxUploadHistory.Keys)
            {
                hashes.Add(hash);
            }

            bool saveNeeded = false;

            foreach (string hash in hashes)
            {
                if (config.runtimeBoxHistory.ContainsKey(hash))
                {
                    // Already loaded
                    continue;
                }
                try {
                    long id = 0;
                    id = long.Parse(hash);
                    BoxInfo imgurInfo = BoxUtils.RetrieveBoxInfo(id);
                    if (imgurInfo != null)
                    {
                        BoxUtils.RetrieveBoxThumbnail(imgurInfo);
                        config.runtimeBoxHistory.Add(hash, imgurInfo);
                    }
                    else
                    {
                        LOG.DebugFormat("Deleting not found Box {0} from config.", hash);
                        config.BoxUploadHistory.Remove(hash);
                        saveNeeded = true;
                    }
                } catch (Exception e) {
                    LOG.Error("Problem loading Box history for hash " + hash, e);
                }
            }
            if (saveNeeded)
            {
                // Save needed changes
                IniConfig.Save();
            }
        }
Exemplo n.º 19
0
        private void button_Save_Click(object sender, EventArgs e)
        {
            File.WriteAllText(CQSave.AppDirectory + "AbyssHelper.json", JsonConvert.SerializeObject(abyssTimers));
            AbyssTimerHelper.Start();
            IniConfig ini = new IniConfig(CQSave.AppDirectory + "Config.ini"); ini.Load();

            ini.Object["ExtraConfig"]["TimerInterval"] = textBox_timerInterval.Text;
            ini.Save();
            MessageBox.Show("保存成功");
        }
Exemplo n.º 20
0
        public void ClickTencentExecute(object parameter)
        {
            SearchOption.Tencent = (bool)parameter;
            var ini = new IniConfig("Config.ini");

            ini.SetObject(SearchOption);
            ini.Save();
            MusicInfos.Where(t => t.Origin == MusicSource.Tencent).ToList().ForEach(item => MusicInfos.Remove(item));
            PlayerList.SetPreList(MusicInfos, "搜索");
        }
Exemplo n.º 21
0
 void Button_okClick(object sender, System.EventArgs e)
 {
     Quality = this.trackBarJpegQuality.Value;
     if (this.checkbox_dontaskagain.Checked)
     {
         conf.OutputFileJpegQuality       = Quality;
         conf.OutputFilePromptJpegQuality = false;
         IniConfig.Save();
     }
 }
Exemplo n.º 22
0
        public LoginWindow()
        {
            IniConfig ini = new IniConfig(Directory.GetCurrentDirectory() + "\\bot.config.ini");

            ini.Load();
            ini.Clear();
            ini.Save();
            ResizeMode = ResizeMode.CanMinimize;
            InitializeComponent();
        }
Exemplo n.º 23
0
        /// <summary>
        /// Do the actual upload to Box
        /// For more details on the available parameters, see: http://developers.box.net/w/page/12923951/ApiFunction_Upload%20and%20Download
        /// </summary>
        /// <param name="image">Image for box upload</param>
        /// <param name="title">Title of box upload</param>
        /// <param name="filename">Filename of box upload</param>
        /// <returns>url to uploaded image</returns>
        public static string UploadToBox(SurfaceContainer image, string title, string filename)
        {
            // Fill the OAuth2Settings
            var settings = new OAuth2Settings
            {
                AuthUrlPattern     = "https://app.box.com/api/oauth2/authorize?client_id={ClientId}&response_type=code&state={State}&redirect_uri={RedirectUrl}",
                TokenUrl           = "https://api.box.com/oauth2/token",
                CloudServiceName   = "Box",
                ClientId           = BoxCredentials.ClientId,
                ClientSecret       = BoxCredentials.ClientSecret,
                RedirectUrl        = "https://www.box.com/home/",
                BrowserSize        = new Size(1060, 600),
                AuthorizeMode      = OAuth2AuthorizeMode.EmbeddedBrowser,
                RefreshToken       = Config.RefreshToken,
                AccessToken        = Config.AccessToken,
                AccessTokenExpires = Config.AccessTokenExpires
            };


            // Copy the settings from the config, which is kept in memory and on the disk

            try {
                var webRequest = OAuth2Helper.CreateOAuth2WebRequest(HTTPMethod.POST, UploadFileUri, settings);
                IDictionary <string, object> parameters = new Dictionary <string, object>();
                parameters.Add("file", image);
                parameters.Add("parent_id", Config.FolderId);

                NetworkHelper.WriteMultipartFormData(webRequest, parameters);

                var response = NetworkHelper.GetResponseAsString(webRequest);

                Log.DebugFormat("Box response: {0}", response);

                var upload = JsonSerializer.Deserialize <Upload>(response);
                if (upload?.Entries == null || upload.Entries.Count == 0)
                {
                    return(null);
                }

                if (Config.UseSharedLink)
                {
                    string filesResponse = HttpPut(string.Format(FilesUri, upload.Entries[0].Id), "{\"shared_link\": {\"access\": \"open\"}}", settings);
                    var    file          = JsonSerializer.Deserialize <FileEntry>(filesResponse);
                    return(file.SharedLink.Url);
                }
                return($"http://www.box.com/files/0/f/0/1/f_{upload.Entries[0].Id}");
            } finally {
                // Copy the settings back to the config, so they are stored.
                Config.RefreshToken       = settings.RefreshToken;
                Config.AccessToken        = settings.AccessToken;
                Config.AccessTokenExpires = settings.AccessTokenExpires;
                Config.IsDirty            = true;
                IniConfig.Save();
            }
        }
Exemplo n.º 24
0
        public static void LoadHistory()
        {
            if (config.runtimeTfsHistory == null)
            {
                return;
            }
            if (config.TfsUploadHistory == null)
            {
                return;
            }

            if (config.runtimeTfsHistory.Count == config.TfsUploadHistory.Count)
            {
                return;
            }
            // Load the TFS history
            List <string> hashes = new List <string>();

            foreach (string hash in config.TfsUploadHistory.Keys)
            {
                hashes.Add(hash);
            }

            bool saveNeeded = false;

            foreach (string hash in hashes)
            {
                if (config.runtimeTfsHistory.ContainsKey(hash))
                {
                    // Already loaded
                    continue;
                }
                try {
                    TFSInfo tfsInfo = TFSUtils.RetrieveTFSInfo(hash);
                    if (tfsInfo != null)
                    {
                        //TFSUtils.RetrieveTFSThumbnail(imgurInfo);
                        config.runtimeTfsHistory.Add(hash, tfsInfo);
                    }
                    else
                    {
                        LOG.DebugFormat("Deleting not found TFS {0} from config.", hash);
                        config.TfsUploadHistory.Remove(hash);
                        saveNeeded = true;
                    }
                } catch (Exception e) {
                    LOG.Error("Problem loading TFS history for hash " + hash, e);
                }
            }
            if (saveNeeded)
            {
                // Save needed changes
                IniConfig.Save();
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// Internal login which catches the exceptions
        /// </summary>
        /// <returns>true if login was done sucessfully</returns>
        private bool doLogin(string user, string password, bool suppressBackgroundForm)
        {
            // This is what needs to be done
            ThreadStart jiraLogin = delegate {
                LOG.DebugFormat("Loggin in");
                try {
                    this.credentials = jira.login(user, password);
                } catch (Exception) {
                    if (!url.EndsWith("wsdl"))
                    {
                        url = url + "/rpc/soap/jirasoapservice-v2?wsdl";
                        // recreate the service with the new url
                        createService();
                        this.credentials = jira.login(user, password);
                        // Worked, store the url in the configuration
                        config.Url = url;
                        IniConfig.Save();
                    }
                    else
                    {
                        throw;
                    }
                }

                LOG.DebugFormat("Logged in");
                this.loggedInTime = DateTime.Now;
                this.loggedIn     = true;
            };

            // Here we do it
            try {
                if (!suppressBackgroundForm)
                {
                    new PleaseWaitForm().ShowAndWait(JiraPlugin.Instance.JiraPluginAttributes.Name, Language.GetString("jira", LangKey.communication_wait), jiraLogin);
                }
                else
                {
                    jiraLogin.Invoke();
                }
            } catch (Exception e) {
                // check if auth failed
                if (e.Message.Contains(AUTH_FAILED_EXCEPTION_NAME))
                {
                    return(false);
                }
                // Not an authentication issue
                this.loggedIn    = false;
                this.credentials = null;
                e.Data.Add("user", user);
                e.Data.Add("url", url);
                throw;
            }
            return(true);
        }
Exemplo n.º 26
0
        private void QuickSettingBoolItemChanged(object sender, EventArgs e)
        {
            ToolStripMenuSelectListItem item = ((ItemCheckedChangedEventArgs)e).Item;
            IniValue iniValue = item.Data as IniValue;

            if (iniValue != null)
            {
                iniValue.Value = item.Checked;
                IniConfig.Save();
            }
        }
Exemplo n.º 27
0
        public static void Init()
        {
            try
            {
                IniConfig ini;
                ini = new IniConfig(Path.Combine(MainSave.AppDirectory, "Config.ini"));
                ini.Load();
                if (ini == null || ini.Object.Count == 0)
                {
                    ini.Object["OCR"].Add("app_id", "");
                    ini.Object["OCR"].Add("app_key", "");
                    ini.Save();
                }
                string temp = ini.Object["OCR"]["app_id"].GetValueOrDefault("");
                if (temp == "")
                {
                    ini.Object["OCR"]["app_id"]  = new IValue("");
                    ini.Object["OCR"]["app_key"] = new IValue("");
                }
                ini.Save();

                if (!File.Exists($@"{MainSave.AppDirectory}装备卡\框\抽卡背景.png"))
                {
                    QMLog.CurrentApi.Info("数据包未安装,插件无法运行,请仔细阅读论坛插件说明安装数据包,之后重载插件");
                }
                else
                {
                    SQLHelper.Init(Path.Combine(MainSave.AppDirectory, "data.db"));
                    if (!File.Exists(Path.Combine(MainSave.AppDirectory, "data.db")))
                    {
                        SQLHelper.CreateDB();
                    }
                }
                AbyssTimerHelper.Start();
                MainGacha.Init();
            }
            catch (Exception exc)
            {
                QMLog.CurrentApi.Info(exc.Message + exc.StackTrace);
            }
        }
Exemplo n.º 28
0
 private void Button_okClick(object sender, EventArgs e)
 {
     Settings.JPGQuality   = trackBarJpegQuality.Value;
     Settings.ReduceColors = checkBox_reduceColors.Checked;
     if (checkbox_dontaskagain.Checked)
     {
         conf.OutputFileJpegQuality   = Settings.JPGQuality;
         conf.OutputFilePromptQuality = false;
         conf.OutputFileReduceColors  = Settings.ReduceColors;
         IniConfig.Save();
     }
 }
Exemplo n.º 29
0
        private void ClearHistoryButtonClick(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show(Language.GetString("imgur", LangKey.clear_question), "Imgur", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                Config.runtimeImgurHistory.Clear();
                Config.ImgurUploadHistory.Clear();
                IniConfig.Save();
                Redraw();
            }
        }
Exemplo n.º 30
0
        /// <summary>
        /// Do the actual upload to Box
        /// For more details on the available parameters, see: http://developers.box.net/w/page/12923951/ApiFunction_Upload%20and%20Download
        /// </summary>
        /// <param name="image">Image for box upload</param>
        /// <param name="title">Title of box upload</param>
        /// <param name="filename">Filename of box upload</param>
        /// <returns>url to uploaded image</returns>
        public static string UploadToBox(SurfaceContainer image, string title, string filename)
        {
            while (true)
            {
                const string folderId = "0";
                if (string.IsNullOrEmpty(Config.BoxToken))
                {
                    if (!Authorize())
                    {
                        return(null);
                    }
                }

                IDictionary <string, object> parameters = new Dictionary <string, object>();
                parameters.Add("filename", image);
                parameters.Add("parent_id", folderId);

                var response = "";
                try {
                    response = HttpPost(UploadFileUri, parameters);
                } catch (WebException ex) {
                    if (ex.Status == WebExceptionStatus.ProtocolError)
                    {
                        Config.BoxToken = null;
                        continue;
                    }
                }

                LOG.DebugFormat("Box response: {0}", response);

                // Check if the token is wrong
                if ("wrong auth token".Equals(response))
                {
                    Config.BoxToken = null;
                    IniConfig.Save();
                    continue;
                }
                var upload = JsonSerializer.Deserialize <Upload>(response);
                if (upload == null || upload.Entries == null || upload.Entries.Count == 0)
                {
                    return(null);
                }

                if (Config.UseSharedLink)
                {
                    string filesResponse = HttpPut(string.Format(FilesUri, upload.Entries[0].Id), "{\"shared_link\": {\"access\": \"open\"}}");
                    var    file          = JsonSerializer.Deserialize <FileEntry>(filesResponse);
                    return(file.SharedLink.Url);
                }
                return(string.Format("http://www.box.com/files/0/f/0/1/f_{0}", upload.Entries[0].Id));
            }
        }