public void buttonSave_Click(object sender, RoutedEventArgs e) { LogEntry log = new LogEntry(); log.Title = textBoxTitle.Text; log.Text = textBoxMainText.Text; log.EntryDate = DateTime.Now; log.Id = MainWindow.logEntries.Count + 1; MainWindow.logEntries.Add(log); Close(); }
private void button_Delete_Click(object sender, RoutedEventArgs e) { if (SelectedLogEntry != null) { currentLog.Entries.Remove(SelectedLogEntry); SelectedLogEntry = null; } }
public Window2(LogEntry name) : this() { this.tempObj = name; textBoxEntry.Text = tempObj.Text; textBoxTitle.Text = tempObj.Title; tempID = tempObj.Id; origText = tempObj.Text; origTitle = tempObj.Title; }
// Delete Entry Button private void DeleteEntry_button_Click(object sender, RoutedEventArgs e) { // the if statement confirms that something is selected if (SelectedLogEntry != null) { // the reference to the selection within the grid is removed logEntries.Remove(SelectedLogEntry); // the reference is nullified SelectedLogEntry = null; } }
private void button_Click(object sender, RoutedEventArgs e) { LogEntry newLog = new LogEntry(); newLog.EntryDate = DateTime.Now; newLog.Id = LogEntry.IdCounter; newLog.Title = textBoxTitle.Text; newLog.Text = textBoxText.Text; MainWindow.logEntries.Add(newLog); NewEntry.Close(); }
private void AddButton_Click(object sender, RoutedEventArgs e) { if (LogText.Text.Length > 0) { LogEntry log = new LogEntry(); log.ID = id; id = id + 1; log.dateTime = DateTime.Now; log.entry = LogText.Text; LogList.Add(log); LogText.Clear(); } }
private void Save_button_Click(object sender, RoutedEventArgs e) { // MainWindow window = (MainWindow)Owner; // input to an object LogEntry logEntry = new LogEntry(); logEntry.Id = MainWindow.logEntries.Count + 1; logEntry.EntryDate = DateTime.Now; logEntry.EntryTitle = EntryTitleInput.Text; logEntry.EntryText = EntryTextInput.Text; MainWindow.logEntries.Add(logEntry); }
private void SaveButton_Click(object sender, RoutedEventArgs e) { string text = textBox.Text; LogEntry log = new LogEntry(); string title = Title.Text; log.Id = MainWindow.logEntries.Count + 1; log.Title = title; log.Text = text; log.EntryDate = DateTime.Now; MainWindow.logEntries.Add(log); Close(); }
private void buttonAddEntry_Click(object sender, RoutedEventArgs e) { string title = "Seperation of Concerns?"; string text = "Seperate a program into sections.."; DateTime date = DateTime.Now; LogEntry log = new Core.LogEntry(); log.Id = logEntries.Count + 1; log.Title = title; log.Text = text; log.EntryDate = date; logEntries.Add(log); }
private void button_Click(object sender, RoutedEventArgs e) { //collect input from the user //validate the input (did the user enter enough text, etc) //add to the grid string title = textBox_Title.Text; string entry = textBox_Entry.Text; DateTime currentDate = DateTime.Now; LogEntry newLog = new LogEntry(); newLog.Id = currentLog.Entries.Count + 1; newLog.Title = title; newLog.Text = entry; newLog.EntryDate = currentDate; currentLog.Entries.Add(newLog); currentLog.Entries.Remove(SelectedLogEntry); }
private void buttonEntrySubmit_Click(object sender, RoutedEventArgs e) { var mainWindow = Owner as MainWindow; if (textBoxEntry.Text != origText || textBoxTitle.Text != origTitle) { CaptainsLog.Core.LogEntry log = new LogEntry(); log.Id = tempID; log.Title = textBoxTitle.Text; log.Text = textBoxEntry.Text; log.UpdateDate = DateTime.Now; mainWindow.UpdateLog(log); mainWindow.RefreshGrid(); this.Close(); } else { this.Close(); } }
private void _addEntry(object sender, RoutedEventArgs e) { // collect input // validate input // add to grid string title = "Title"; string text = "Hey! This is text"; DateTime date = DateTime.Now; // Object LogEntry log = new LogEntry(); log.Title = title; log.Text = text; log.EntryDate = date; logEntries.Add(log); log.Id = logEntries.Count + 1; }
private void buttonEntrySubmit_Click(object sender, RoutedEventArgs e) { var mainWindow = Owner as MainWindow; if (textBoxEntry.Text.Length > 0 && textBoxTitle.Text.Length > 0) { CaptainsLog.Core.LogEntry log = new LogEntry(); log.Id = mainWindow.logEntries.Count() + 1; log.Title = textBoxTitle.Text; log.Text = textBoxEntry.Text; log.EntryDate = DateTime.Now; log.UpdateDate = DateTime.Now; mainWindow.AddLog(log); this.Close(); } else { MessageBox.Show("Please ensure both fields are populated and try again."); } }
private void buttonAddEntry_Click(object sender, RoutedEventArgs e) { // collect the input from the user // validate the input (did the user enter enough text) // add to the grid // Cameron skipped the above and created a new object below string title = "Whatever title"; string text = "Whatever text"; DateTime date = DateTime.Now; LogEntry log = new LogEntry(); log.Id = logEntries.Count + 1; log.Title = title; log.Text = text; log.EntryDate = date; logEntries.Add(log); }
private void gridLogEntries_SelectionChanged(object sender, SelectionChangedEventArgs e) { SelectedLogEntry = (LogEntry)gridLogEntries.SelectedItem; }
//Public Methods so that Window1/2 can access/manipulate data on MainWindow public void AddLog(LogEntry log) { logEntries.Add(log); }
// Event of selection (when grid item clicked it is selected) private void gridLogEntries_SelectionChanged(object sender, SelectionChangedEventArgs e) { // row (selected item) within the data grid (gridLogEntries) cast within // the LogEntry class (adds functionality) SelectedLogEntry = (LogEntry)gridLogEntries.SelectedItem; }
public void UpdateLog(LogEntry log) { int identifier = log.Id; LogEntry obj = logEntries.FirstOrDefault(x => x.Id == identifier); obj.Title = log.Title; obj.Text = log.Text; obj.UpdateDate = log.UpdateDate; RefreshGrid(); }