Пример #1
0
        // "Decline transfer" feature removed, due to crashes
        // Also, it was useless anyway, since bots would re-add {{copy to Commons}} regardless
        //private void DeclineTransfer(object sender, EventArgs e)
        //{
        //    Action action = delegate()
        //    {
        //        string summary = frmPrompt.Prompt(Localization.GetString("DeclineReasonPrompt1") + "\n" + Localization.GetString("DeclineReasonPrompt2"));
        //        if (summary == null)
        //            return;
        //        EnableForm(false);
        //        StringDictionary enTokenQuery = new StringDictionary
        //        {
        //            { "action", "query" },
        //            { "prop", "info|revisions" },
        //            { "intoken", "edit" },
        //            { "titles", filename },  // old filename
        //            { "rvprop", "content" }
        //        };
        //        MorebitsDotNet.PostApi(Wiki.Local, enTokenQuery, delegate(XmlDocument enDoc)
        //        {
        //            if (enDoc.GetElementsByTagName("page")[0].Attributes["missing"] != null)
        //            {
        //                ErrorHandler(Localization.GetString("LocalFileDeleted"));
        //                return;
        //            }
        //            string enToken = enDoc.GetElementsByTagName("page")[0].Attributes["edittoken"].Value;
        //            string enText = enDoc.GetElementsByTagName("rev")[0].FirstChild.Value;
        //            string newText =  Regex.Replace(enText, LocalWikiData.CopyToCommonsRegex, "", RegexOptions.IgnoreCase | RegexOptions.Compiled);
        //            if (enText == newText)
        //            {
        //                ErrorHandler(Localization.GetString("CouldNotFindTag"));
        //                return;
        //            }
        //            StringDictionary enEditQuery = new StringDictionary
        //            {
        //                { "action", "edit" },
        //                { "token", enToken },
        //                { "title", filename },
        //                { "text", newText },
        //                { "summary", "Declining {{Copy to Commons}} request: " + summary + " ([[WP:FTCG|FtCG]])" },
        //                { "nocreate", "true" }
        //            };
        //            MorebitsDotNet.PostApi(Wiki.Local, enEditQuery, delegate(XmlDocument enInnerDoc)
        //            {
        //                EnableForm(true);
        //                string editResult = enInnerDoc.GetElementsByTagName("edit")[0].Attributes["result"].Value.ToLower();
        //                if (editResult == "success")
        //                    ShowWarningBox(true, "");
        //                else
        //                    ErrorHandler(Localization.GetString("FailedPlus") + " " + editResult, MessageBoxIcon.Information);
        //            }, ErrorHandler, true);
        //        }, ErrorHandler, true);
        //    };
        //    if (!MorebitsDotNet.LoginSessions[Wiki.Local].LoggedIn)
        //        MorebitsDotNet.LogIn(Wiki.Local, Settings.LocalUserName, Settings.LocalPassword,
        //            action, ErrorHandler);
        //    else
        //        action();
        //}
        // Misc. UI backing code
        // =====================
        private void btnSettings_Click(object sender, EventArgs e)
        {
            frmSettings set = new frmSettings(false, false);
            if (set.ShowDialog(this) == DialogResult.Cancel)
                return;
            foreach (Wiki w in MorebitsDotNet.LoginSessions.Keys)
                MorebitsDotNet.LoginSessions[w].LoggedIn = false;

            InitSettings();
        }
Пример #2
0
        public frmMain()
        {
            InitializeComponent();

            // nicer default height - we need to keep it at MinimumSize in design view
            // to stop the main text boxes from being cut off
            Height = 720;

            panStatus.Tag = Color.FromArgb(30, 144, 255);
            panWarning.Tag = Color.FromArgb(178, 34, 34);

            ZoomInCursor = new Cursor(new MemoryStream(Properties.Resources.zoomin_cur));
            CheckerBrush = new TextureBrush(Properties.Resources.Checker_16x16, System.Drawing.Drawing2D.WrapMode.Tile);

            // load language file, if any
            Localization.Init();

            lblOriginalFilename.Text = Localization.GetString("OriginalFileName_TextBox");
            btnGo.Text = Localization.GetString("Go_Button");
            btnRandomFile.Text = Localization.GetString("RandomFile_Button");
            optOther.Text = Localization.GetString("OtherSource_Option");
            btnSettings.Text = Localization.GetString("Settings_Button");
            lblCommonsFileDesc.Text = Localization.GetString("FilePageOnCommons_TextBox");
            btnLinkify.Text = Localization.GetString("MakeSelectedTextIntoWikilink_Hyperlink");
            btnPreview.Text = Localization.GetString("PreviewCommonsWikitext_Hyperlink");
            btnPastRevisions.Text = Localization.GetString("SelectVersion_Button");
            lblViewExif.Text = Localization.GetString("ContainsExifMetadata_Label");
            btnViewExif.Text = Localization.GetString("ViewMetadata_Button");
            lblFileLinks.Text = Localization.GetString("ImageUsage_Label");
            lnkGoToFileLink.Text = Localization.GetString("Go_Button") + " >";
            lblNormName.Text = Localization.GetString("NewFilenameOnCommons_TextBox");
            chkIgnoreWarnings.Text = Localization.GetString("IgnoreWarnings_CheckBox");
            chkDeleteAfter.Text = Localization.GetString("TagLocalFileWithNowCommons_Label");
            btnTransfer.Text = Localization.GetString("Transfer_Button");
            lnkCommonsFile.Text = Localization.GetString("ViewFilePageOnWikimediaCommons_Hyperlink");
            //lblCategoryHint.Text = Localization.GetString("DontForgetToCategorize_Label") + " " + Localization.GetString("HotcatHint_Label");
            lnkGoogleImageSearch.Text = Localization.GetString("GoogleCheck_Hyperlink");
            lblDeclineTransfer.Text = Localization.GetString("IfIneligibleEditManually_Label");
            lblExifNotice.Text = Localization.GetString("NoExifRotation_Label");
            lblStatus.Text = Localization.GetString("Loading");

            // prepare welcome text
            StringBuilder welcome = new StringBuilder();
            welcome.AppendLine("");
            welcome.AppendLine(" == " + Localization.GetString("WelcomeToFtcg_Title") + " ==");
            welcome.AppendLine("");
            welcome.AppendLine(" " + Localization.GetString("WelcomeToFtcg_IsGood1"));
            if (Localization.GetString("WelcomeToFtcg_IsGood2") != "")
                welcome.AppendLine(" " + Localization.GetString("WelcomeToFtcg_IsGood2"));
            welcome.AppendLine("");
            welcome.AppendLine(" " + Localization.GetString("WelcomeToFtcg_GetStarted1"));
            if (Localization.GetString("WelcomeToFtcg_GetStarted2") != "")
                welcome.AppendLine(" " + Localization.GetString("WelcomeToFtcg_GetStarted2"));
            if (Localization.GetString("WelcomeToFtcg_GetStarted3") != "")
                welcome.AppendLine("    " + Localization.GetString("WelcomeToFtcg_GetStarted3"));
            if (Localization.GetString("WelcomeToFtcg_GetStarted4") != "")
                welcome.AppendLine(" " + Localization.GetString("WelcomeToFtcg_GetStarted4"));
            if (Localization.GetString("WelcomeToFtcg_GetStarted5") != "")
                welcome.AppendLine("    " + Localization.GetString("WelcomeToFtcg_GetStarted5"));
            welcome.AppendLine("");
            welcome.AppendLine(" " + Localization.GetString("WelcomeToFtcg_NotABludge1"));
            if (Localization.GetString("WelcomeToFtcg_NotABludge2") != "")
                welcome.AppendLine(" " + Localization.GetString("WelcomeToFtcg_NotABludge2"));
            if (Localization.GetString("WelcomeToFtcg_NotABludge3") != "")
                welcome.AppendLine(" " + Localization.GetString("WelcomeToFtcg_NotABludge3"));
            if (Localization.GetString("WelcomeToFtcg_NotABludge4") != "")
                welcome.AppendLine(" " + Localization.GetString("WelcomeToFtcg_NotABludge4"));
            if (Localization.GetString("WelcomeToFtcg_NotABludge5") != "")
                welcome.AppendLine(" " + Localization.GetString("WelcomeToFtcg_NotABludge5"));
            welcome.AppendLine("");
            welcome.AppendLine(" " + Localization.GetString("WelcomeToFtcg_Enjoy"));
            txtLocalText.Text = welcome.ToString();

            toolBarLinks.Renderer = new SimpleToolStripRenderer();

            // time to load settings
            if (File.Exists("ForTheCommonGood.cfg"))
            {
                Settings.ReadSettings();
                if (Settings.SaveCreds == false)
                {
                    frmSettings set = new frmSettings(Settings.LocalUserName != "", true);
                    set.ShowDialog(this);
                }
            }
            else
            {
                MessageBox.Show(Localization.GetString("Welcome1") + "\n\n" + Localization.GetString("Welcome2"),
                    Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                new frmSettings(false, true).ShowDialog(this);
            }

            InitSettings();

            if (PlatformSpecific.IsMono())
            {
                tableLayoutPanel1.Resize += delegate(object sender, EventArgs e)
                {
                    tableLayoutPanel1.SuspendLayout();
                    txtLocalText.Height = panCommonsText.Height = 0;
                    tableLayoutPanel1.ResumeLayout(true);
                };
                btnViewExif.Visible = lblViewExif.Visible = btnPastRevisions.Visible =
                    lblPastRevisions.Visible = panWarning.Visible = true;
                Load += delegate(object sender, EventArgs e)
                {
                    btnViewExif.Visible = lblViewExif.Visible = btnPastRevisions.Visible =
                         lblPastRevisions.Visible = panWarning.Visible = false;
                };
            }
        }
Пример #3
0
        public frmMain()
        {
            InitializeComponent();

            panStatus.Tag = Color.FromArgb(30, 144, 255);
            panWarning.Tag = Color.FromArgb(178, 34, 34);

            ZoomInCursor = new Cursor(new MemoryStream(Properties.Resources.zoomin_cur));
            checker = new TextureBrush(Properties.Resources.Checker_16x16, System.Drawing.Drawing2D.WrapMode.Tile);

            // load language file, if any
            Localization.Init();

            lblOriginalFilename.Text = Localization.GetString("OriginalFileName_TextBox");
            btnGo.Text = Localization.GetString("Go_Button");
            btnRandomFile.Text = Localization.GetString("RandomFile_Button");
            optOther.Text = Localization.GetString("OtherSource_Option");
            btnSettings.Text = Localization.GetString("Settings_Button");
            lblCommonsFileDesc.Text = Localization.GetString("FilePageOnCommons_TextBox");
            lnkLinkify.Text = Localization.GetString("MakeSelectedTextIntoWikilink_Hyperlink");
            btnPastRevisions.Text = Localization.GetString("SelectVersion_Button");
            lblViewExif.Text = Localization.GetString("ContainsExifMetadata_Label");
            btnViewExif.Text = Localization.GetString("ViewMetadata_Button");
            lblFileLinks.Text = Localization.GetString("ImageUsage_Label");
            lnkGoToFileLink.Text = Localization.GetString("Go_Button") + " →";
            lblNormName.Text = Localization.GetString("NewFilenameOnCommons_TextBox");
            chkIgnoreWarnings.Text = Localization.GetString("IgnoreWarnings_CheckBox");
            chkDeleteAfter.Text = Localization.GetString("TagLocalFileWithNowCommons_Label");
            btnTransfer.Text = Localization.GetString("Transfer_Button");
            lnkCommonsFile.Text = Localization.GetString("ViewFilePageOnWikimediaCommons_Hyperlink");
            //lblCategoryHint.Text = Localization.GetString("DontForgetToCategorize_Label") + " " + Localization.GetString("HotcatHint_Label");
            lnkGoogleImageSearch.Text = Localization.GetString("GoogleCheck_Hyperlink");
            lblDeclineTransfer.Text = Localization.GetString("IfIneligibleEditManually_Label");
            lblExifNotice.Text = Localization.GetString("NoExifRotation_Label");
            lblStatus.Text = Localization.GetString("Loading");

            // time to load settings
            if (File.Exists("ForTheCommonGood.cfg"))
            {
                Settings.ReadSettings();
                if (Settings.SaveCreds == false)
                {
                    frmSettings set = new frmSettings(Settings.LocalUserName != "");
                    set.ShowDialog(this);
                }
            }
            else
            {
                MessageBox.Show(Localization.GetString("Welcome1") + "\n\n" + Localization.GetString("Welcome2"),
                    Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                btnSettings_Click(this, null);
            }

            InitSettings();
        }