No cache version.

Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.

TodoControl.cs

Description du code

TodoControl.cs est un fichier du projet BiblioBrol.
Ce fichier est situé dans /var/www/bin/sniplets/bibliobrol/src/.

Projet BiblioBrol :

Gestion de media en CSharp.

Pour plus d'infos, vous pouvez consulter la brève analyse.

Code source ou contenu du fichier

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using be.gaudry.bibliobrol.model;
  9.  
  10. namespace be.gaudry.bibliobrol.view.controls
  11. {
  12. public partial class TodoControl : UserControl
  13. {
  14. private Task currentTask;
  15. private DataGridViewCellStyle[] styles;
  16. public TodoControl()
  17. {
  18. InitializeComponent();
  19. initTaskStyles();
  20. }
  21. private void initTasks()
  22. {
  23. currentTask = new Task();
  24. showEdition(false);
  25. infoCtrl.Visible = false;
  26. //enableTaskActions(false);
  27. tasksDGV.DataSource = ModelAdapter.getTasks();
  28. if (tasksDGV.Rows.Count > 0)
  29. {
  30. foreach (DataGridViewRow row in tasksDGV.Rows)
  31. {
  32. if ((!row.Cells["planDate"].Value.Equals(new DateTime(0L))) && row.Cells["endDate"].Value.Equals(new DateTime(0L)))
  33. {
  34. int i = ((DateTime)row.Cells["planDate"].Value).ToString("yyMMdd").CompareTo(DateTime.Now.ToString("yyMMdd"));
  35. switch (i)
  36. {
  37. case 0:
  38. row.DefaultCellStyle = styles[0];
  39. break;
  40. case -1:
  41. row.DefaultCellStyle = styles[1];
  42. break;
  43. case 1:
  44. row.DefaultCellStyle = styles[2];
  45. break;
  46. }
  47. }
  48. }
  49. infoCtrl.InfosTitleBackColor = tasksDGV.Rows[0].DefaultCellStyle.BackColor;
  50. infoCtrl.InfosTitleForeColor = tasksDGV.Rows[0].DefaultCellStyle.ForeColor;
  51. }
  52. }
  53.  
  54. private void initTaskStyles()
  55. {
  56. DataGridViewCellStyle nowStyle = new DataGridViewCellStyle();
  57. nowStyle.BackColor = System.Drawing.Color.Orange;
  58. nowStyle.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  59. nowStyle.ForeColor = System.Drawing.Color.Black;
  60. nowStyle.SelectionBackColor = System.Drawing.Color.DarkOrange;
  61. nowStyle.SelectionForeColor = System.Drawing.Color.Black;
  62. DataGridViewCellStyle warnStyle = new DataGridViewCellStyle();
  63. warnStyle.BackColor = System.Drawing.Color.OrangeRed;
  64. warnStyle.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  65. warnStyle.ForeColor = System.Drawing.Color.White;
  66. warnStyle.SelectionBackColor = System.Drawing.Color.Crimson;
  67. warnStyle.SelectionForeColor = System.Drawing.Color.White;
  68. DataGridViewCellStyle okStyle = new DataGridViewCellStyle();
  69. okStyle.BackColor = System.Drawing.Color.LimeGreen;
  70. okStyle.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  71. okStyle.ForeColor = System.Drawing.Color.White;
  72. okStyle.SelectionBackColor = System.Drawing.Color.DarkGreen;
  73. okStyle.SelectionForeColor = System.Drawing.Color.White;
  74. styles = new DataGridViewCellStyle[] { nowStyle, warnStyle, okStyle };
  75. }
  76.  
  77. private void tasksDGV_CellClick(object sender, DataGridViewCellEventArgs e)
  78. {
  79. showEdition(false);
  80. //enableTaskActions(true);
  81. //detailsBtn.Enabled = true;
  82. testNavButtons();
  83. }
  84.  
  85. private void enableTaskActions(bool enabled)
  86. {
  87. delTaskBtn.Enabled = enabled;
  88. editTaskBtn.Enabled = enabled;
  89. }
  90.  
  91. private void fillCurrentTaskFromDGV()
  92. {
  93. //DataGridViewRow row = tasksDGV.CurrentRow;
  94. DataGridViewRow row = tasksDGV.SelectedRows[0];
  95. currentTask.Id = (int)row.Cells["id"].Value;
  96. currentTask.TaskName = (String)row.Cells["taskName"].Value;
  97. currentTask.TaskInfo = (String)row.Cells["taskInfo"].Value;
  98. currentTask.StartDate = (DateTime)row.Cells["startDate"].Value;
  99. currentTask.EndDate = (DateTime)row.Cells["endDate"].Value;
  100. currentTask.PlanDate = (DateTime)row.Cells["planDate"].Value;
  101. }
  102.  
  103. private void fillCurrentTaskFromFormFields()
  104. {
  105. currentTask.TaskName = taskNameTB.Text;
  106. currentTask.TaskInfo = taskInfoCB.Text;
  107. currentTask.StartDate = startDateDTP.Value;
  108. currentTask.EndDate = (endDateDTP.Visible)?endDateDTP.Value:new DateTime(0L);
  109. currentTask.PlanDate = (planDateDTP.Visible) ? planDateDTP.Value : new DateTime(0L);
  110. }
  111.  
  112. private void fillTaskFormFields()
  113. {
  114. taskNameTB.Text = currentTask.TaskName;
  115. taskInfoCB.Text = currentTask.TaskInfo;
  116. if (!currentTask.StartDate.Equals(new DateTime(0L))) startDateDTP.Value = currentTask.StartDate;
  117. if (!currentTask.EndDate.Equals(new DateTime(0L))) endDateDTP.Value = currentTask.EndDate;
  118. if (!currentTask.PlanDate.Equals(new DateTime(0L))) planDateDTP.Value = currentTask.PlanDate;
  119. }
  120.  
  121. private void showEdition(bool visible)
  122. {
  123. startDateLbl.Visible = visible;
  124. endDateLbl.Visible = visible;
  125. planDateLbl.Visible = visible;
  126. taskNameLbl.Visible = visible;
  127. taskNameTB.Visible = visible;
  128. taskInfoLbl.Visible = visible;
  129. taskInfoCB.Visible = visible;
  130. startDateDTP.Visible = visible;
  131. endDateDTP.Visible = (visible && currentTask.EndDate != null && !currentTask.EndDate.Equals(new DateTime(0L)));
  132. endDateBtn.Visible = (visible && !endDateDTP.Visible);
  133. cleanEndDateBtn.Visible = endDateDTP.Visible;
  134. planDateDTP.Visible = (visible && currentTask.PlanDate != null && !currentTask.PlanDate.Equals(new DateTime(0L)));
  135. planDateBtn.Visible = (visible && !planDateDTP.Visible);
  136. cleanPlanDateBtn.Visible = planDateDTP.Visible;
  137. saveBtn.Visible = visible;
  138. }
  139.  
  140. private void endDateBtn_Click(object sender, EventArgs e)
  141. {
  142. showEndDateDTP(true);
  143. }
  144. private void showEndDateDTP(bool visible)
  145. {
  146. endDateBtn.Visible = !visible;
  147. endDateDTP.Visible = visible;
  148. cleanEndDateBtn.Visible = visible;
  149. }
  150.  
  151. private void planDateBtn_Click(object sender, EventArgs e)
  152. {
  153. showPlanDateDTP(true);
  154. }
  155. private void showPlanDateDTP(bool visible)
  156. {
  157. planDateBtn.Visible = !visible;
  158. planDateDTP.Visible = visible;
  159. cleanPlanDateBtn.Visible = visible;
  160. }
  161.  
  162. private void saveBtn_Click(object sender, EventArgs e)
  163. {
  164. fillCurrentTaskFromFormFields();
  165. ModelAdapter.updateTask(currentTask);
  166. initTasks();
  167. }
  168.  
  169. private void editTaskBtn_Click(object sender, EventArgs e)
  170. {
  171. fillCurrentTaskFromDGV();
  172. fillTaskFormFields();
  173. showEdition(true);
  174. showDetails(false);
  175. }
  176.  
  177. private void delTaskBtn_Click(object sender, EventArgs e)
  178. {
  179. fillCurrentTaskFromDGV();
  180. ModelAdapter.deleteTask(currentTask.Id);
  181. initTasks();
  182. }
  183.  
  184. private void addTaskBtn_Click(object sender, EventArgs e)
  185. {
  186. if (infoCtrl.Visible) showDetails(false);
  187. currentTask = new Task();
  188. fillTaskFormFields();
  189. showEdition(true);
  190. }
  191.  
  192.  
  193.  
  194. private void setDetails()
  195. {
  196. fillCurrentTaskFromDGV();
  197. infoCtrl.InfosTitle = currentTask.TaskName;
  198. infoCtrl.InfosRichTextBox.Text = "Détails :\n\n";
  199. infoCtrl.InfosRichTextBox.AppendText("\nDate de début de la tâche : ");
  200. infoCtrl.InfosRichTextBox.AppendText((currentTask.StartDate.Equals(new DateTime(0L))) ? "non définie" : currentTask.StartDate.ToLongDateString());
  201. infoCtrl.InfosRichTextBox.AppendText("\nDate de fin plannifiée de la tâche : ");
  202. infoCtrl.InfosRichTextBox.AppendText((currentTask.PlanDate.Equals(new DateTime(0L))) ? "non définie" : currentTask.PlanDate.ToLongDateString());
  203. infoCtrl.InfosRichTextBox.AppendText("\nDate de fin effective de la tâche : ");
  204. infoCtrl.InfosRichTextBox.AppendText((currentTask.EndDate.Equals(new DateTime(0L))) ? "non définie" : currentTask.EndDate.ToLongDateString());
  205. infoCtrl.InfosRichTextBox.AppendText("\n\nInformations : ");
  206. infoCtrl.InfosRichTextBox.AppendText(currentTask.TaskInfo);
  207. }
  208.  
  209. private void showDetails(bool shown)
  210. {
  211. infoCtrl.Visible = shown;
  212. detailsBtn.Image = (shown) ?
  213. global::be.gaudry.bibliobrol.Properties.Resources.brolDetailsHide
  214. : global::be.gaudry.bibliobrol.Properties.Resources.brolDetails;
  215. //enableTaskActions(!shown);
  216. }
  217. /// <summary>
  218. /// Test if previous task button and next task button are each enabled.
  219. /// Ensure to keep into index limits
  220. /// </summary>
  221. private void testNavButtons()
  222. {
  223. if (tasksDGV.Rows.Count > 0)
  224. {
  225. prevTaskBtn.Enabled = tasksDGV.SelectedRows[0].Index > 0;
  226. nextTaskBtn.Enabled = tasksDGV.SelectedRows[0].Index < (tasksDGV.RowCount - 1);
  227. firstTaskBtn.Enabled = prevTaskBtn.Enabled;
  228. lastTaskBtn.Enabled = nextTaskBtn.Enabled;
  229. }
  230. }
  231.  
  232. private void prevTaskBtn_Click(object sender, EventArgs e)
  233. {
  234. testNavButtons();
  235. if (prevTaskBtn.Enabled)
  236. {
  237. int i = tasksDGV.SelectedRows[0].Index - 1;
  238. tasksDGV.Rows[tasksDGV.CurrentRow.Index].Selected = false;
  239. tasksDGV.Rows[i].Selected = true;
  240. tasksDGV.FirstDisplayedScrollingRowIndex = i;
  241. setDetails();
  242. testNavButtons();
  243. }
  244. showEdition(false);
  245. }
  246.  
  247. private void nextTaskBtn_Click(object sender, EventArgs e)
  248. {
  249. testNavButtons();
  250. if (nextTaskBtn.Enabled)
  251. {
  252. int i = tasksDGV.SelectedRows[0].Index + 1;
  253. tasksDGV.Rows[tasksDGV.CurrentRow.Index].Selected = false;
  254. tasksDGV.Rows[i].Selected = true;
  255. tasksDGV.FirstDisplayedScrollingRowIndex = i;
  256. setDetails();
  257. testNavButtons();
  258. }
  259. showEdition(false);
  260. }
  261.  
  262. private void lastTaskBtn_Click(object sender, EventArgs e)
  263. {
  264. testNavButtons();
  265. if (lastTaskBtn.Enabled)
  266. {
  267. int i = tasksDGV.RowCount - 1;
  268. tasksDGV.Rows[tasksDGV.CurrentRow.Index].Selected = false;
  269. tasksDGV.Rows[i].Selected = true;
  270. tasksDGV.FirstDisplayedScrollingRowIndex = i;
  271. setDetails();
  272. testNavButtons();
  273. }
  274. showEdition(false);
  275. }
  276.  
  277. private void firstTaskBtn_Click(object sender, EventArgs e)
  278. {
  279. testNavButtons();
  280. if (firstTaskBtn.Enabled)
  281. {
  282. tasksDGV.Rows[tasksDGV.CurrentRow.Index].Selected = false;
  283. tasksDGV.Rows[0].Selected = true;
  284. tasksDGV.FirstDisplayedScrollingRowIndex = 0;
  285. setDetails();
  286. testNavButtons();
  287. }
  288. showEdition(false);
  289. }
  290. private void cleanEndDateBtn_Click(object sender, EventArgs e)
  291. {
  292. showEndDateDTP(false);
  293. }
  294.  
  295. private void cleanPlanDateBtn_Click(object sender, EventArgs e)
  296. {
  297. showPlanDateDTP(false);
  298. }
  299.  
  300. private void loadTasksBtn_Click(object sender, EventArgs e)
  301. {
  302. initTasks();
  303. loadTasksBtn.Enabled = false;
  304. bool dataPresent = (tasksDGV.RowCount > 0);
  305. addTaskBtn.Enabled = dataPresent;
  306. enableTaskActions(dataPresent);
  307. detailsBtn.Enabled = dataPresent;
  308. testNavButtons();
  309. }
  310.  
  311. private void detailsBtn_Click(object sender, EventArgs e)
  312. {
  313. if (!infoCtrl.Visible)
  314. {
  315. setDetails();
  316. showDetails(true);
  317. }
  318. else
  319. {
  320. showDetails(false);
  321. }
  322. showEdition(false);
  323. }
  324.  
  325. private void tasksDGV_SelectionChanged(object sender, EventArgs e)
  326. {
  327. if (tasksDGV.RowCount > 0 && tasksDGV.SelectedRows.Count > 0 &&
  328. (!tasksDGV.SelectedRows[0].Cells["planDate"].Value.Equals(new DateTime(0L))) &&
  329. (tasksDGV.SelectedRows[0].Cells["endDate"].Value.Equals(new DateTime(0L))))
  330. {
  331. infoCtrl.InfosTitleBackColor = tasksDGV.SelectedRows[0].DefaultCellStyle.BackColor;
  332. infoCtrl.InfosTitleForeColor = tasksDGV.SelectedRows[0].DefaultCellStyle.ForeColor;
  333. }
  334. else
  335. {
  336. infoCtrl.setDefaultColors();
  337. }
  338. }
  339. }
  340. }

Structure et Fichiers du projet

Afficher/masquer...


Répertoires contenus dans /var/www/bin/sniplets/bibliobrol/src/view/controls/ 
IcôneNomTailleModification
IcôneNomTailleModification
| _ Répertoire parent0 octets1716014615 18/05/2024 08:43:35
| _dao0 octets1541007199 31/10/2018 18:33:19
| _toolBars0 octets1541007200 31/10/2018 18:33:20
| _webInfo0 octets1541007201 31/10/2018 18:33:21
Fichiers contenus dans /var/www/bin/sniplets/bibliobrol/src/view/controls/ 
IcôneNomTailleModificationAction
IcôneNomTailleModificationAction
Afficher le fichier .cs|.csPersonSelectControl.cs4.89 Ko31/10/2018 18:32:57-refusé-
Afficher le fichier .cs|.csCreateStructureControl.cs7.49 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csDBSelectControl.cs3.23 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csPersonInfoControl.Designer.cs13.13 Ko31/10/2018 18:32:57-refusé-
Afficher le fichier .resx|.resxDirControl.resx5.68 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .resx|.resxBrolInfoControl.resx6.06 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csBrolEditControl.cs25.36 Ko31/10/2018 18:32:55-refusé-
Afficher le fichier .cs|.csPersonEditControl.cs15.67 Ko31/10/2018 18:32:57-refusé-
Afficher le fichier .cs|.csSearchControl.cs18.88 Ko31/10/2018 18:32:57-refusé-
Afficher le fichier .resx|.resxDBSelectControl.resx5.88 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csBrolInfoControl.Designer.cs22.81 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csInfoControl.cs2.04 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csDirControl.Designer.cs5.83 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csSelectConsoleVerboseControl.cs5.49 Ko31/10/2018 18:32:57-refusé-
Afficher le fichier .cs|.csPersonSelectedEventArgs.cs779 octets31/10/2018 18:32:57-refusé-
Afficher le fichier .resx|.resxSelectConsoleVerboseControl.resx5.68 Ko31/10/2018 18:32:57-refusé-
Afficher le fichier .cs|.csTodoControl.cs13.73 Ko31/10/2018 18:32:58-refusé-
Afficher le fichier .cs|.csSelectConsoleVerboseControl.Designer.cs45.29 Ko31/10/2018 18:32:57-refusé-
Afficher le fichier .cs|.csBrolEditControl.Designer.cs40.09 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csDBSelectControl.Designer.cs6.71 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csPersonEditControl.Designer.cs27.54 Ko31/10/2018 18:32:57-refusé-
Afficher le fichier .resx|.resxPersonInfoControl.resx6.42 Ko31/10/2018 18:32:57-refusé-
Afficher le fichier .cs|.csCreateStructureControl.Designer.cs5 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csDirPathModifiedEventArgs.cs871 octets31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csInfoControl.Designer.cs3.18 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csBrolInfoControl.cs5.14 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .resx|.resxBrolEditControl.resx6.04 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csPersonInfoControl.cs2.22 Ko31/10/2018 18:32:57-refusé-
Afficher le fichier .resx|.resxInfoControl.resx5.68 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csDirControl.cs4.51 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .resx|.resxCreateStructureControl.resx6.44 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csSerieEditControl.cs2.58 Ko31/10/2018 18:32:58-refusé-
Afficher le fichier .resx|.resxSerieEditControl.resx7.45 Ko31/10/2018 18:32:58-refusé-
Afficher le fichier .resx|.resxTodoControl.resx6.76 Ko31/10/2018 18:32:58-refusé-
Afficher le fichier .cs|.csTodoControl.Designer.cs28.27 Ko31/10/2018 18:32:58-refusé-
Afficher le fichier .resx|.resxSearchControl.resx6.43 Ko31/10/2018 18:32:57-refusé-
Afficher le fichier .cs|.csPersonSelectControl.Designer.cs14.74 Ko31/10/2018 18:32:57-refusé-
Afficher le fichier .cs|.csSearchControl.Designer.cs25.75 Ko31/10/2018 18:32:57-refusé-
Afficher le fichier .resx|.resxPersonEditControl.resx7.96 Ko31/10/2018 18:32:57-refusé-
Afficher le fichier .cs|.csSerieEditControl.Designer.cs6.65 Ko31/10/2018 18:32:58-refusé-
Afficher le fichier .resx|.resxPersonSelectControl.resx5.68 Ko31/10/2018 18:32:57-refusé-

Utilisation de l'explorateur de code

  • Navigation :
    • Un clic sur une icône de répertoire ouvre ce répertoire pour en afficher les fichiers.
    • Lorsque le répertoire en cours ne contient pas de sous-répertoires il est possible de remonter vers le répertoire parent.
    • La structure de répertoires en treetable (tableau en forme d'arborescence) n'est plus possibledans cette version.
    • Un clic sur une icône de fichier ouvre ce fichier pour en afficher le code avec la coloration syntaxique adaptée en fonction du langage principal utilisé dans le fichier.
  • Affichage :
    • Il est possible de trier les répertoires ou les fichiers selon certains critères (nom, taille, date).
  • Actions :
    • Les actions possible sur les fichiers dépendent de vos droits d'utilisateur sur le site. Veuillez activer le mode utilisateur pour activer les actions.

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 16/10/2009, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/cs-bibliobrol-source-rf-view/controls/TodoControl.cs.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.