public TodoForm() { this.persistence = new Persistence(); this.listState = new ListState(persistence); InitializeComponent(); }
public void setListState(ListState state) { this.state = state; addNameTextBox(); fillPanelWithItems(); }
private void loadStateButton_Click(object sender, EventArgs e) { if (DebugMode) { addText(persistence.getDebugInfo()); } listState = new ListState(persistence); listState.loadFromPersistence(); refreshTodoListPanel(); }
private List<IEvent> removeRedundantEvents(List<IEvent> events) { List<IEvent> returnList = new List<IEvent>(); ListState finalState = new ListState(); //Load the normal final state of all the events. finalState.LoadList(allPreviousEvents); finalState.LoadList(events); foreach (IEvent @event in events) { if (@event == null) break; returnList.Add(@event); ListState checkState = new ListState(); checkState.LoadList(allPreviousEvents); // Load a stat without the current event. IEnumerable<IEvent> without = events.Where(e => !(e.Equals(@event))); List<IEvent> withoutList = without.ToList(); checkState.LoadList(without.ToList()); // Check if it is the same as the final state. if (checkState.Equals(finalState)) { Debug.WriteLine("Redundant operation found!!!"); returnList.Remove(@event); } } return returnList; }
public AddTodoItem(ListState currentState) { InitializeComponent(); this.state = currentState; }
private bool loadIfPossible(ListState currentState, EventMessage @event) { return loadIfPossible(currentState, @event.Body); }
private bool loadIfPossible(ListState currentState, object @event) { IEvent currentEvent = (IEvent) @event; if (currentState.currentList.id == currentEvent.aggregateId) { currentState.Load(currentEvent); return true; } if (currentState.currentList.todoItems.Any(e => e.id == currentEvent.aggregateId)) { currentState.Load(currentEvent); return true; } return false; }
/// <summary> /// Checks if two of events(Transformations) commute locally. /// </summary> /// <returns> Boolean saying they commute locally. </returns> private bool commuteLocally(IEvent leftSideEvent, IEvent rightSideEvent, List<IEvent> previousEvents) { ListState currentState = new ListState(); ListState checkState = new ListState(); // Load all current events to the states. foreach (IEvent @event in previousEvents) { currentState.Load(@event); checkState.Load(@event); } // Load one way currentState.Load(leftSideEvent); currentState.Load(rightSideEvent); // Load other way around. checkState.Load(rightSideEvent); checkState.Load(leftSideEvent); // Now check if the two states are the same. return currentState.Equals(checkState); }
/// <summary> /// Checks if two arrays of events(Transformations) commute locally. /// </summary> /// <returns> Boolean saying they commute locally. </returns> private bool commuteLocally(List<IEvent> leftEvents, List<IEvent> rightEvents, List<IEvent> previousEvents) { ListState currentState = new ListState(); ListState firstCheckState = new ListState(); ListState secondCheckState = new ListState(); // Load all current events to the states. foreach (IEvent @event in previousEvents) { currentState.Load(@event); firstCheckState.Load(@event); secondCheckState.Load(@event); } // Load all left side events on first check. foreach (IEvent message in leftEvents) { //firstCheckState.Load(message.Body); loadIfPossible(firstCheckState, message); } //Load all right side events on first check. foreach (IEvent @event in rightEvents) { loadIfPossible(firstCheckState, @event); //firstCheckState.Load(@event); } // Do it the other way around for the second check. foreach (IEvent @event in rightEvents) { //secondCheckState.Load(@event); loadIfPossible(secondCheckState, @event); } foreach (IEvent message in leftEvents) { //secondCheckState.Load(message.Body); loadIfPossible(secondCheckState, message); } // Now check if the two states are the same. return firstCheckState.Equals(secondCheckState); }
private ListState calculateOfflineListState() { ListState newState = new ListState(); newState.LoadList(allPreviousEvents); newState.LoadList(generatedEvents); return newState; }
private ListState calculateOnlineListState() { ListState currState = new ListState(); foreach (IEvent @event in generatedEvents) { currState.Load(@event); } return currState; }
public void addTodoItem(ListState state, TodoItemAggregate todoItem) { this.state = state; this.todoItem = todoItem; // Set the correct positions. int adjustedYPos = offset + ((height + offset) * (todoItem.index-1)); this.SetBounds(offset, adjustedYPos, width, height); this.BackColor = Color.White; nameLabel.Text = nameHeader; nameLabel.Font = standardFont; descriptionLabel.Text = descriptionHeader; descriptionLabel.Font = standardFont; priorityLabel.Text = priorityHeader; priorityLabel.Font = standardFont; indexLabel.Text = indexHeader; indexLabel.Font = standardFont; this.nameTextBox.Text= todoItem.name; this.descriptionTextBox.Text = todoItem.description; this.priorityTextBox.Text = todoItem.priority.ToString(); this.indexTextBox.Text = todoItem.index.ToString(); this.nameTextBox.Width = 190; this.nameTextBox.Font = standardFont; this.descriptionTextBox.Width = 190; this.descriptionTextBox.Font = standardFont; this.priorityTextBox.Width = 190; this.priorityTextBox.Font = standardFont; this.indexTextBox.Width = 190; this.indexTextBox.Font = standardFont; this.deleteButton.Text = "X"; this.deleteButton.Width = 20; this.priorityUpButton.Text = "+"; this.priorityUpButton.Width = 20; this.priorityUpButton.Height = 20; this.priorityDownButten.Text = "-"; this.priorityDownButten.Width = 20; this.priorityDownButten.Height = 20; this.Controls.Add(nameLabel,0,0); this.Controls.Add(descriptionLabel,0,1); this.Controls.Add(priorityLabel, 0, 2); this.Controls.Add(nameTextBox,1,0); this.Controls.Add(descriptionTextBox,1,1); this.Controls.Add(priorityTextBox, 1, 2); this.Controls.Add(deleteButton, 2, 0); this.Controls.Add(priorityUpButton, 2, 2); this.Controls.Add(priorityDownButten, 3, 2); this.Controls.Add(indexLabel, 0, 3); this.Controls.Add(indexTextBox, 1, 3); nameTextBox.LostFocus += nameTextBox_LostFocus; nameTextBox.TextChanged += nameTextBox_TextChanged; descriptionTextBox.LostFocus += descriptionTextBox_LostFocus; descriptionTextBox.TextChanged += descriptionTextBox_TextChanged; priorityTextBox.TextChanged += priorityTextBox_TextChanged; priorityTextBox.LostFocus += priorityTextBox_LostFocus; indexTextBox.TextChanged += indexTextBox_TextChanged; indexTextBox.LostFocus += indexTextBox_LostFocus; deleteButton.Click += deleteButton_Click; priorityDownButten.Click += priorityDownButten_Click; priorityUpButton.Click += priorityUpButton_Click; }