PageRenderTime 37ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/components/FeedbackControl.cs

https://github.com/moscrif/ide
C# | 117 lines | 92 code | 21 blank | 4 comment | 6 complexity | 9ede4ef007eff960e92d56047812ddd0 MD5 | raw file
  1. using System;
  2. using System.IO;
  3. using Gtk;
  4. using Gdk;
  5. using System.Linq;
  6. using System.Xml;
  7. using System.Xml.Serialization;
  8. using Moscrif.IDE.Iface.Entities;
  9. namespace Moscrif.IDE.Components
  10. {
  11. public class FeedbackControl: Gtk.Table
  12. {
  13. private Entry entrSubject;
  14. private TextView tvDescription;
  15. private ComboBox cbType;
  16. private ListStore projectModel;
  17. private TypFeedback typeFeedback;
  18. public FeedbackControl(TypFeedback type) : base(3,2,false)
  19. {
  20. typeFeedback = type;
  21. this.RowSpacing = 3;
  22. this.ColumnSpacing = 3;
  23. Label lblSubject = GetLabel("Subject");
  24. this.Attach(lblSubject,0,1,0,1,AttachOptions.Fill,AttachOptions.Fill,0,0);
  25. entrSubject = new Entry();
  26. this.Attach(entrSubject,1,2,0,1,AttachOptions.Fill|AttachOptions.Expand,AttachOptions.Fill,0,0);
  27. cbType = new ComboBox();
  28. projectModel = new ListStore(typeof(string), typeof(string));
  29. CellRendererText textRenderer = new CellRendererText();
  30. cbType.PackStart(textRenderer, true);
  31. cbType.AddAttribute(textRenderer, "text", 0);
  32. cbType.Model= projectModel;
  33. projectModel.AppendValues("IDE and Emulator","IDE and Emulator" );
  34. projectModel.AppendValues("Framework and Documentation","Framework and Documentation" );
  35. projectModel.AppendValues("Deployment, Devices and Publishing","Deployment, Devices and Publishing" );
  36. projectModel.AppendValues("Web moscrif.com","Web moscrif.com" );
  37. cbType.Active = 0;
  38. Label lblVersion = GetLabel("Product Group");
  39. this.Attach(lblVersion,0,1,1,2,AttachOptions.Fill,AttachOptions.Fill,0,0);
  40. this.Attach(cbType,1,2,1,2,AttachOptions.Fill|AttachOptions.Expand,AttachOptions.Fill,0,0);
  41. Label lblDescription = GetLabel("Description");
  42. this.Attach(lblDescription,0,1,2,3,AttachOptions.Fill,AttachOptions.Fill,0,0);
  43. tvDescription = new TextView();
  44. ScrolledWindow sw = new ScrolledWindow ();
  45. sw.ShadowType = ShadowType.Out;
  46. sw.Add(tvDescription);
  47. this.Attach(sw,1,2,2,3,AttachOptions.Fill|AttachOptions.Expand,AttachOptions.Fill|AttachOptions.Expand,0,0);
  48. this.ShowAll();
  49. }
  50. public string GetDescription(){
  51. return tvDescription.Buffer.Text;
  52. }
  53. private Label GetLabel(string text){
  54. Label label = new Label(text);
  55. label.Xpad = 5;
  56. label.Ypad = 5;
  57. label.UseUnderline = false;
  58. label.Selectable = false;
  59. label.Xalign = 0;
  60. return label;
  61. }
  62. public string GetData(){
  63. FeedbackData fd = new FeedbackData ();
  64. fd.Typ = (int)typeFeedback;
  65. fd.Subject = entrSubject.Text;
  66. fd.Product = cbType.ActiveText;
  67. if(MainClass.Platform.IsWindows){
  68. fd.System = "Windows 7 32bit";
  69. } else if(MainClass.Platform.IsMac) {
  70. fd.System = "Mac OS X 10.7 (Lion)";
  71. } else if(MainClass.Platform.IsX11) {
  72. fd.System = "X11";
  73. } else {
  74. fd.System = "Unknow";
  75. }
  76. string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
  77. string newVersion = MainClass.Tools.VersionConverter(version);
  78. fd.Version = newVersion; //"2012q3a";
  79. fd.Description =tvDescription.Buffer.Text;
  80. XmlSerializer x_serial = new XmlSerializer( fd.GetType());
  81. StringWriter textWriter = new StringWriter();
  82. x_serial.Serialize(textWriter, fd);
  83. return textWriter.ToString();
  84. }
  85. public enum TypFeedback{
  86. Issue = 2,
  87. Question = 3,
  88. FAQ = 4,
  89. Suggestion = 5
  90. }
  91. /* Issue = 2,
  92. Question = 3,
  93. FAQ = 4,
  94. Suggestion = 5*/
  95. }
  96. }