2 using System
.Collections
.Generic
;
4 using System
.Windows
.Forms
;
5 using System
.Runtime
.InteropServices
;
8 namespace ExampleCsPlugin
11 Guid("5870B3F1-8393-4c83-ACED-1D5E803A4F2B"),
12 ClassInterface(ClassInterfaceType
.None
)]
13 public class MyPlugin
: Interop
.BugTraqProvider
.IBugTraqProvider2
, Interop
.BugTraqProvider
.IBugTraqProvider
15 private List
<TicketItem
> selectedTickets
= new List
<TicketItem
>();
17 public bool ValidateParameters(IntPtr hParentWnd
, string parameters
)
22 public string GetLinkText(IntPtr hParentWnd
, string parameters
)
24 return "Choose Issue";
27 public string GetCommitMessage(IntPtr hParentWnd
, string parameters
, string commonRoot
, string[] pathList
,
28 string originalMessage
)
30 return GetCommitMessage2( hParentWnd
, parameters
, "", commonRoot
, pathList
, originalMessage
);
33 public string GetCommitMessage2( IntPtr hParentWnd
, string parameters
, string commonURL
, string commonRoot
, string[] pathList
,
34 string originalMessage
)
38 List
<TicketItem
> tickets
= new List
<TicketItem
>( );
39 tickets
.Add( new TicketItem( 12, "Service doesn't start on Windows Vista" ) );
40 tickets
.Add( new TicketItem( 19, "About box doesn't render correctly in large fonts mode" ) );
43 tickets.Add(new TicketItem(88, commonRoot));
44 foreach (string path in pathList)
45 tickets.Add(new TicketItem(99, path));
48 MyIssuesForm form
= new MyIssuesForm( tickets
);
49 if ( form
.ShowDialog( ) != DialogResult
.OK
)
50 return originalMessage
;
52 StringBuilder result
= new StringBuilder( originalMessage
);
53 if ( originalMessage
.Length
!= 0 && !originalMessage
.EndsWith( "\n" ) )
56 foreach ( TicketItem ticket
in form
.TicketsFixed
)
58 result
.AppendFormat( "Fixed #{0}: {1}", ticket
.Number
, ticket
.Summary
);
60 selectedTickets
.Add( ticket
);
63 return result
.ToString( );
65 catch ( Exception ex
)
67 MessageBox
.Show( ex
.ToString( ) );
72 public string OnCommitFinished( IntPtr hParentWnd
, string commonRoot
, string[] pathList
, string logMessage
, int revision
)
74 // we now could use the selectedTickets member to find out which tickets
75 // were assigned to this commit.
76 CommitFinishedForm form
= new CommitFinishedForm( selectedTickets
);
77 if ( form
.ShowDialog( ) != DialogResult
.OK
)
79 // just for testing, we return an error string
80 return "an error happened while closing the issue";
83 public bool HasOptions()
88 public string ShowOptionsDialog( IntPtr hParentWnd
, string parameters
)
90 OptionsForm form
= new OptionsForm( );
91 if ( form
.ShowDialog( ) != DialogResult
.OK
)
94 string options
= form
.checkBox1
.Checked
? "option1" : "";
95 options
+= form
.checkBox2
.Checked
? "option2" : "";