OSDN Git Service

Align key "puttykeyfile" with gitextension
[tortoisegit/TortoiseGitJp.git] / contrib / issue-tracker-plugins / ExampleCsPlugin / MyPlugin.cs
1 using System;\r
2 using System.Collections.Generic;\r
3 using System.Text;\r
4 using System.Windows.Forms;\r
5 using System.Runtime.InteropServices;\r
6 using Microsoft.Win32;\r
7 \r
8 namespace ExampleCsPlugin\r
9 {\r
10     [ComVisible(true),\r
11         Guid("5870B3F1-8393-4c83-ACED-1D5E803A4F2B"),\r
12         ClassInterface(ClassInterfaceType.None)]\r
13     public class MyPlugin : Interop.BugTraqProvider.IBugTraqProvider2, Interop.BugTraqProvider.IBugTraqProvider\r
14     {\r
15                 private List<TicketItem> selectedTickets = new List<TicketItem>();\r
16 \r
17         public bool ValidateParameters(IntPtr hParentWnd, string parameters)\r
18         {\r
19             return true;\r
20         }\r
21 \r
22         public string GetLinkText(IntPtr hParentWnd, string parameters)\r
23         {\r
24             return "Choose Issue";\r
25         }\r
26 \r
27         public string GetCommitMessage(IntPtr hParentWnd, string parameters, string commonRoot, string[] pathList,\r
28                                        string originalMessage)\r
29         {\r
30                         return GetCommitMessage2( hParentWnd, parameters, "", commonRoot, pathList, originalMessage );\r
31         }\r
32 \r
33                 public string GetCommitMessage2( IntPtr hParentWnd, string parameters, string commonURL, string commonRoot, string[] pathList,\r
34                                                            string originalMessage )\r
35                 {\r
36                         try\r
37                         {\r
38                                 List<TicketItem> tickets = new List<TicketItem>( );\r
39                                 tickets.Add( new TicketItem( 12, "Service doesn't start on Windows Vista" ) );\r
40                                 tickets.Add( new TicketItem( 19, "About box doesn't render correctly in large fonts mode" ) );\r
41 \r
42                                 /*\r
43                                                                 tickets.Add(new TicketItem(88, commonRoot));\r
44                                                                 foreach (string path in pathList)\r
45                                                                         tickets.Add(new TicketItem(99, path));\r
46                                  */\r
47 \r
48                                 MyIssuesForm form = new MyIssuesForm( tickets );\r
49                                 if ( form.ShowDialog( ) != DialogResult.OK )\r
50                                         return originalMessage;\r
51 \r
52                                 StringBuilder result = new StringBuilder( originalMessage );\r
53                                 if ( originalMessage.Length != 0 && !originalMessage.EndsWith( "\n" ) )\r
54                                         result.AppendLine( );\r
55 \r
56                                 foreach ( TicketItem ticket in form.TicketsFixed )\r
57                                 {\r
58                                         result.AppendFormat( "Fixed #{0}: {1}", ticket.Number, ticket.Summary );\r
59                                         result.AppendLine( );\r
60                                         selectedTickets.Add( ticket );\r
61                                 }\r
62 \r
63                                 return result.ToString( );\r
64                         }\r
65                         catch ( Exception ex )\r
66                         {\r
67                                 MessageBox.Show( ex.ToString( ) );\r
68                                 throw;\r
69                         }\r
70                 }\r
71 \r
72                 public string OnCommitFinished( IntPtr hParentWnd, string commonRoot, string[] pathList, string logMessage, int revision )\r
73                 {\r
74                         // we now could use the selectedTickets member to find out which tickets\r
75                         // were assigned to this commit.\r
76                         CommitFinishedForm form = new CommitFinishedForm( selectedTickets );\r
77                         if ( form.ShowDialog( ) != DialogResult.OK )\r
78                                 return "";\r
79                         // just for testing, we return an error string\r
80                         return "an error happened while closing the issue";\r
81                 }\r
82 \r
83                 public bool HasOptions()\r
84                 {\r
85                         return true;\r
86                 }\r
87 \r
88                 public string ShowOptionsDialog( IntPtr hParentWnd, string parameters )\r
89                 {\r
90                         OptionsForm form = new OptionsForm( );\r
91                         if ( form.ShowDialog( ) != DialogResult.OK )\r
92                                 return "";\r
93 \r
94                         string options = form.checkBox1.Checked ? "option1" : "";\r
95                         options += form.checkBox2.Checked ? "option2" : "";\r
96                         return options;\r
97                 }\r
98 \r
99         }\r
100 }\r