/// <summary> /// Handles the even generated by selection of a new row in the <c>datagrid</c> of to-dos. /// </summary> /// <param name="sender">The parameter is not used.</param> /// <param name="e">The parameter is not used.</param> private void TodoList_SelectionChanged(object sender, SelectionChangedEventArgs e) { int selected = this.TodoList.SelectedIndex; if (selected < 0) { return; } if (this.IsModifyMode) { // In modify mode, it inhibits to change the selected cells this.TodoList.SelectedCells.Clear(); return; } IList <DataGridCellInfo> selectedRow = this.TodoList.SelectedCells; this.idToModify = ((ThingTodo)selectedRow[0].Item).Id; ThingTodo selectedTodo = ThingTodo.HavingId(this.idToModify); if (selectedTodo != null) { string todo = selectedTodo.Description; this.TodoToAdd.Text = todo; this.IsModifyMode = true; } }
/// <summary> /// Handles the event of click on the Delete button /// </summary> /// <param name="sender">The parameter is not used.</param> /// <param name="e">The parameter is not used.</param> private void Delete_Click(object sender, System.Windows.RoutedEventArgs e) { if (this.IsModifyMode) { this.TodoList.ItemsSource = null; ThingTodo.Delete(this.idToModify); this.TodoList.ItemsSource = ListToBeShown; this.TodoToAdd.Clear(); this.IsModifyMode = false; } }
/// <summary> /// Handles the event when the button is clicked on /// </summary> /// <param name="sender">The parameter is not used.</param> /// <param name="e">The parameter is not used</param> private void Button_Click(object sender, System.Windows.RoutedEventArgs e) { this.TodoList.ItemsSource = null; if (this.IsModifyMode) { ThingTodo.Modify(this.idToModify, this.TodoToAdd.Text); } else { ThingTodo.Add(false, this.TodoToAdd.Text); } this.TodoList.ItemsSource = ListToBeShown; this.TodoToAdd.Clear(); this.IsModifyMode = false; }
/// <summary> /// Processes each single line in the AssemblyInfo source code. /// </summary> /// <param name="writer">The writer where the new info file must be stored.</param> /// <param name="line">The line to be processed.</param> /// <param name="version">The new version number.</param> /// <param name="comment">The comment to add.</param> public override void ProcessLine(TextWriter writer, string line, AssemblyVersion version, string comment) { if (line.StartsWith(AssemblyVersionSignature)) { writer.Write(AssemblyVersionSignature); writer.Write('"'); writer.Write(version); writer.WriteLine("\")]"); } else if (line.StartsWith(AssemblyFileVersionSignature)) { writer.Write(AssemblyFileVersionSignature); writer.Write('"'); writer.Write(version); writer.WriteLine("\")]"); writer.WriteLine("//// " + version + " Compiled by [" + App.TheUser + "] " + DateTime.Now); if (comment != null) { foreach (string commentLine in comment.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)) { writer.WriteLine("//// " + commentLine); } } } else if (line.StartsWith(StartOfTodoSignature)) { writer.WriteLine(line); this.loadingTodoList = true; } else if (line.StartsWith(TodoParam)) { return; } else if (this.loadingTodoList) { if (line.StartsWith(EndOfTodos) || (!line.StartsWith(StartOfTodoFollowing))) { this.loadingTodoList = false; ThingTodo.ForEach((todo) => { string[] todoLines = todo.Description.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); writer.Write(StartOfTodoContent); writer.Write(todo.IsDone ? 'X' : ' '); writer.Write("] "); writer.WriteLine(todoLines[0]); if (todoLines.Length > 1) { for (int i = 1; i < todoLines.Length; i++) { writer.Write(StartOfTodoFollowing); writer.Write(' '); writer.WriteLine(todoLines[i]); } } }); writer.WriteLine(EndOfTodos); ProgramProperty.ForEach((property, value) => { writer.Write(TodoParam); writer.Write(' '); writer.Write(property); writer.Write('='); writer.WriteLine(value); }); } else { this.loadingTodoList = line.StartsWith(StartOfTodoFollowing); } } else { writer.WriteLine(line); } }
public override void ProcessLine(TextWriter writer, string line, AssemblyVersion version, string comment) { if (line.Trim().StartsWith(AssemblyVersionSignature)) { writer.WriteLine(string.Format("#define VER_FILEVERSION {0},{1},{2},{3}", version.Major, version.Minor, version.Build, version.Revision)); writer.WriteLine(string.Format("#define THEFILEVERSION \"{0}.{1}.{2}.{3}\\0\"", version.Major, version.Minor, version.Build, version.Revision)); } else if (line.StartsWith(StartOfTodoSignature)) { writer.WriteLine(line); this.loadingTodoList = true; } else if (line.StartsWith(TodoParam)) { return; } else if (line.StartsWith(AssemblyVersionSignatureString)) { return; } else if (this.loadingTodoList) { if (line.StartsWith(EndOfTodos) || (!line.StartsWith(StartOfTodoFollowing))) { this.loadingTodoList = false; ThingTodo.ForEach((todo) => { string[] todoLines = todo.Description.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); writer.Write(StartOfTodoContent); writer.Write(todo.IsDone ? 'X' : ' '); writer.Write("] "); writer.WriteLine(todoLines[0]); if (todoLines.Length > 1) { for (int i = 1; i < todoLines.Length; i++) { writer.Write(StartOfTodoFollowing); writer.Write(' '); writer.WriteLine(todoLines[i]); } } }); writer.WriteLine(EndOfTodos); ProgramProperty.ForEach((property, value) => { writer.Write(TodoParam); writer.Write(' '); writer.Write(property); writer.Write('='); writer.WriteLine(value); }); } else { this.loadingTodoList = line.StartsWith(StartOfTodoFollowing); } } else { if (!this.writtenComments && line.Contains("Compiled by [")) { writer.WriteLine("// " + version + " Compiled by [" + App.TheUser + "] " + DateTime.Now); if (comment != null) { foreach (string commentLine in comment.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)) { writer.WriteLine("// " + commentLine); } } this.writtenComments = true; } writer.WriteLine(line); } }