private void OptionsDialog_FormClosing(object sender, FormClosingEventArgs e) { if (DialogResult != DialogResult.OK) { return; } //Try parsing the link try { applySettings(); //Test the link testLink(); } catch (Exception ex) { var dialog = new ErrorDialog(Strings.ErrorReadingIssuesListTitle, String.Format(Strings.ErrorReadingIssuesListMessage, Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine + Strings.ErrorConfirmContinue), ex, ErrorDialog.ButtonState.OkCancel); if (dialog.ShowDialog(Plugin.AppWindow) == DialogResult.Cancel) { e.Cancel = true; } } //Set url Parameter = lnkFeedUrl.Text; }
private void lnkFeedUrl_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { try { Process.Start(lnkFeedUrl.Text); } catch (Exception ex) { var dialog = new ErrorDialog(Strings.OptionsDialog_lnkFeedUrl_LinkClicked_Failed, Strings.OptionsDialog_lnkFeedUrl_LinkClicked_Unable_to_open_link + Environment.NewLine + ex.Message, ex, ErrorDialog.ButtonState.OkOnly); dialog.ShowDialog(Plugin.AppWindow); } }
/// <summary> /// Gets the ATOM Feed. /// </summary> internal void GetFeed() { try { _parser = new FeedParser(feedsUrl); } catch (Exception ex) { var dialog = new ErrorDialog(Strings.ErrorReadingIssuesListTitle, String.Format(Strings.ErrorReadingIssuesListMessage, Environment.NewLine + ex.Message), ex, ErrorDialog.ButtonState.CloseContinue); dialog.ShowDialog(AppWindow); FeedFailedToLoad = true; } }
private void btnTest_Click(object sender, EventArgs e) { toggleCursor(true); //Try parsing the link try { MessageBox.Show(string.Format(Strings.OptionsDialog_btnTest_Click_Successfully_read_atom_feed, testLink()), Strings.OptionsDialog_btnTest_Click_Success, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { var dialog = new ErrorDialog(Strings.ErrorReadingIssuesListTitle, String.Format(Strings.ErrorReadingIssuesListMessage, Environment.NewLine + ex.Message), ex, ErrorDialog.ButtonState.OkOnly); dialog.ShowDialog(Plugin.AppWindow); } toggleCursor(false); }
/// <summary> /// Gets the ATOM Feed. /// </summary> internal void GetFeed() { try { _parser = new FeedParser(feedsUrl); } catch (Exception ex) { var dialog = new ErrorDialog(Strings.ErrorReadingIssuesListTitle, String.Format(Strings.ErrorReadingIssuesListMessage, Environment.NewLine + ex.Message), ex, ErrorDialog.ButtonState.CloseContinue); dialog.ShowDialog(AppWindow); FeedFailedToLoad = true; } }
/// <summary> /// Gets the commit message. /// </summary> /// <param name="hParentWnd">Parent window for your provider's UI.</param> /// <param name="parameters">Parameters for your provider.</param> /// <param name="commonRoot">The common root.</param> /// <param name="pathList">The path list.</param> /// <param name="originalMessage">The text already present in the commit message. Your provider should include this text in the new message, where appropriate.</param> /// <returns>The new text for the commit message. This replaces the original message.</returns> /// <exception cref="Exception"><c>Exception</c>.</exception> public string GetCommitMessage(IntPtr hParentWnd, string parameters, string commonRoot, string[] pathList, string originalMessage) { try { feedsUrl = parameters; //Show form var form = new IssuesForm(this, originalMessage); //If don't click ok then return the original message. if (form.ShowDialog() != DialogResult.OK) { return originalMessage; } //If we click ok but no items are selected then return the original message. if (form.ItemsFixed.Count <= 0) { return originalMessage; } //Add issues to comment window var result = new StringBuilder(); var regexObj = new Regex(@"([Ii]ssues?:?(\s*(,|and)?\s*#\d+)+)", RegexOptions.IgnoreCase); if (regexObj.Matches(originalMessage).Count <= 0) { //Not found at all //Check if we include summary if (form.IncludeSummary) { if (originalMessage.Length > 0) { result.AppendLine(originalMessage); } //Add each checked issue foreach (var item in form.ItemsFixed) { result.AppendLine(string.Format("({0} #{1}) : {2}", Strings.IssueText, item.Number, item.Description)); } } else { if (originalMessage.Length > 0) { //Add Original message and "Issues" result.AppendFormat("{0} ({1}", originalMessage, Strings.IssueText); } else { //Add "Issues" result.AppendFormat("({0}", Strings.IssueText); } //Add each checked issue foreach (var item in form.ItemsFixed) { result.AppendFormat(" #{0},", item.Number); } //Remove trailing comma result.Remove(result.Length - 1, 1); result.Append(")"); } } else { //Found if (originalMessage.EndsWith(Environment.NewLine)) { result.Append(originalMessage); } else { result.AppendLine(originalMessage); } //Add each checked issue if not already there foreach (var item in form.ItemsFixed) { if (form.IncludeSummary) { if (originalMessage.Contains(string.Format("({0} #{1}) : {2}", Strings.IssueText, item.Number, item.Description))) { //Number and summary are already included so skip this issue number continue; } if (originalMessage.Contains(string.Format("#{0}", item.Number))) { //Issue number is included but not description so add the description on a new line if it is //not in the original comment somewhere else. if (!originalMessage.Contains(item.Description)) { result.AppendLine(item.Description); } continue; } //Got here which means this is a new issue so add it. result.AppendLine(string.Format("({0} #{1}) : {2}", Strings.IssueText, item.Number, item.Description)); } else { if (originalMessage.Contains(string.Format("#{0}", item.Number))) { //Issue is already in the original comment so skip adding continue; } //Got here which means this is a new issue so add it to the existing list. //Find (Issues #xxx in original message and append to it. var startpos = originalMessage.LastIndexOf( string.Format("{0} #", Strings.IssueText), StringComparison.CurrentCultureIgnoreCase); var endpos = originalMessage.IndexOf(")", startpos); //If can't find closing brace then add after the word issue and before the # if (endpos < 0) { endpos = startpos + Strings.IssueText.Length; result.Insert(endpos, string.Format(" #{0},", item.Number)); } else { result.Insert(endpos, string.Format(", #{0}", item.Number)); } } } } //If we have issues added to the list return them otherwise return just the original message (This is if all selected issues were already in the list). return result.ToString() != originalMessage + " ()" ? result.ToString() : originalMessage; } catch (Exception ex) { var dialog = new ErrorDialog(ex, ErrorDialog.ButtonState.CloseContinue); dialog.ShowDialog(AppWindow); return originalMessage; } }
/// <summary> /// Gets the commit message. /// </summary> /// <param name="hParentWnd">Parent window for your provider's UI.</param> /// <param name="parameters">Parameters for your provider.</param> /// <param name="commonRoot">The common root.</param> /// <param name="pathList">The path list.</param> /// <param name="originalMessage">The text already present in the commit message. Your provider should include this text in the new message, where appropriate.</param> /// <returns>The new text for the commit message. This replaces the original message.</returns> /// <exception cref="Exception"><c>Exception</c>.</exception> public string GetCommitMessage(IntPtr hParentWnd, string parameters, string commonRoot, string[] pathList, string originalMessage) { try { feedsUrl = parameters; //Show form var form = new IssuesForm(this, originalMessage); //If don't click ok then return the original message. if (form.ShowDialog() != DialogResult.OK) { return(originalMessage); } //If we click ok but no items are selected then return the original message. if (form.ItemsFixed.Count <= 0) { return(originalMessage); } //Add issues to comment window var result = new StringBuilder(); var regexObj = new Regex(@"([Ii]ssues?:?(\s*(,|and)?\s*#\d+)+)", RegexOptions.IgnoreCase); if (regexObj.Matches(originalMessage).Count <= 0) { //Not found at all //Check if we include summary if (form.IncludeSummary) { if (originalMessage.Length > 0) { result.AppendLine(originalMessage); } //Add each checked issue foreach (var item in form.ItemsFixed) { result.AppendLine(string.Format("({0} #{1}) : {2}", Strings.IssueText, item.Number, item.Description)); } } else { if (originalMessage.Length > 0) { //Add Original message and "Issues" result.AppendFormat("{0} ({1}", originalMessage, Strings.IssueText); } else { //Add "Issues" result.AppendFormat("({0}", Strings.IssueText); } //Add each checked issue foreach (var item in form.ItemsFixed) { result.AppendFormat(" #{0},", item.Number); } //Remove trailing comma result.Remove(result.Length - 1, 1); result.Append(")"); } } else { //Found if (originalMessage.EndsWith(Environment.NewLine)) { result.Append(originalMessage); } else { result.AppendLine(originalMessage); } //Add each checked issue if not already there foreach (var item in form.ItemsFixed) { if (form.IncludeSummary) { if (originalMessage.Contains(string.Format("({0} #{1}) : {2}", Strings.IssueText, item.Number, item.Description))) { //Number and summary are already included so skip this issue number continue; } if (originalMessage.Contains(string.Format("#{0}", item.Number))) { //Issue number is included but not description so add the description on a new line if it is //not in the original comment somewhere else. if (!originalMessage.Contains(item.Description)) { result.AppendLine(item.Description); } continue; } //Got here which means this is a new issue so add it. result.AppendLine(string.Format("({0} #{1}) : {2}", Strings.IssueText, item.Number, item.Description)); } else { if (originalMessage.Contains(string.Format("#{0}", item.Number))) { //Issue is already in the original comment so skip adding continue; } //Got here which means this is a new issue so add it to the existing list. //Find (Issues #xxx in original message and append to it. var startpos = originalMessage.LastIndexOf( string.Format("{0} #", Strings.IssueText), StringComparison.CurrentCultureIgnoreCase); var endpos = originalMessage.IndexOf(")", startpos); //If can't find closing brace then add after the word issue and before the # if (endpos < 0) { endpos = startpos + Strings.IssueText.Length; result.Insert(endpos, string.Format(" #{0},", item.Number)); } else { result.Insert(endpos, string.Format(", #{0}", item.Number)); } } } } //If we have issues added to the list return them otherwise return just the original message (This is if all selected issues were already in the list). return(result.ToString() != originalMessage + " ()" ? result.ToString() : originalMessage); } catch (Exception ex) { var dialog = new ErrorDialog(ex, ErrorDialog.ButtonState.CloseContinue); dialog.ShowDialog(AppWindow); return(originalMessage); } }