/// <summary> /// Updates the specified row. /// </summary> /// <param name="row">DataGridRow</param> private void UpdateRow(DataGridRow row) { BugTraceObject loadingItem = (BugTraceObject)row.DataContext; BugTraceObject selectedItem = null; string selectedHeader = null; if (this.BugTraceView.CurrentCell != null && this.BugTraceView.CurrentCell.Item is BugTraceObject) { selectedItem = (BugTraceObject)this.BugTraceView.CurrentCell.Item; selectedHeader = (string)this.BugTraceView.CurrentCell.Column.Header; } if (this.SearchTextBox.Text.Length > 0 && this.SearchQueryCache.ContainsKey(this.SearchTextBox.Text)) { int rowId = row.GetIndex(); if (this.SearchQueryCache[this.SearchTextBox.Text].Contains(rowId)) { this.RestoreRow(row); } else { this.FadeRow(row); } } else if (selectedItem != null && selectedHeader != null && ((selectedHeader.Equals("Type") && !loadingItem.Type.Equals(selectedItem.Type)) || (selectedHeader.Equals("Machine") && !loadingItem.Machine.Equals(selectedItem.Machine)) || (selectedHeader.Equals("State") && !loadingItem.MachineState.Equals(selectedItem.MachineState)) || (selectedHeader.Equals("Action") && !loadingItem.Action.Equals(selectedItem.Action)) || (selectedHeader.Equals("Target Machine") && !loadingItem.TargetMachine.Equals(selectedItem.TargetMachine)))) { if (this.IsTraceViewCollapsed) { this.CollapseRow(row); } else { this.FadeRow(row); } } else { this.RestoreRow(row); } }
private void MenuItem_Collapse_Click(object sender, EventArgs e) { if (this.IsTraceViewCollapsed) { this.MenuItem__Collapse.Header = "_Collapse"; this.RestoreTraceViewStyle(); return; } this.MenuItem__Collapse.Header = "_Expand"; this.IsTraceViewCollapsed = true; BugTraceObject selectedItem = null; string selectedHeader = null; if (this.BugTraceView.CurrentCell != null && this.BugTraceView.CurrentCell.Item is BugTraceObject) { selectedItem = (BugTraceObject)this.BugTraceView.CurrentCell.Item; selectedHeader = (string)this.BugTraceView.CurrentCell.Column.Header; } if (selectedItem != null && selectedHeader != null) { for (int i = 0; i < this.BugTraceView.Items.Count; i++) { DataGridRow row = (DataGridRow)this.BugTraceView.ItemContainerGenerator.ContainerFromIndex(i); if (row == null) { continue; } BugTraceObject item = (BugTraceObject)row.DataContext; if ((selectedHeader.Equals("Type") && !item.Type.Equals(selectedItem.Type)) || (selectedHeader.Equals("Machine") && !item.Machine.Equals(selectedItem.Machine)) || (selectedHeader.Equals("State") && !item.MachineState.Equals(selectedItem.MachineState)) || (selectedHeader.Equals("Action") && !item.Action.Equals(selectedItem.Action)) || (selectedHeader.Equals("Target Machine") && !item.TargetMachine.Equals(selectedItem.TargetMachine))) { this.CollapseRow(row); } } } }
private void TraceView_CurrentCellChanged(object sender, EventArgs e) { this.RestoreTraceViewStyle(); if (this.BugTraceView.CurrentColumn != null && this.BugTraceView.CurrentCell != null && this.BugTraceView.CurrentColumn.Header is string && this.BugTraceView.CurrentCell.Item is BugTraceObject) { string header = (string)this.BugTraceView.CurrentColumn.Header; BugTraceObject item = (BugTraceObject)this.BugTraceView.CurrentCell.Item; for (int i = 0; i < this.BugTraceView.Items.Count; i++) { DataGridRow row = (DataGridRow)this.BugTraceView.ItemContainerGenerator.ContainerFromIndex(i); if (row == null) { continue; } this.UpdateRow(row); } } }
/// <summary> /// Restores the specified row to its defalt style. /// </summary> /// <param name="row">DataGridRow</param> private void RestoreRow(DataGridRow row) { BugTraceObject context = row.DataContext as BugTraceObject; if (context.Type.Equals("CreateMachine")) { row.Foreground = new SolidColorBrush(Colors.White); row.Background = new SolidColorBrush(Colors.Teal); } else if (context.Type.Equals("CreateMonitor")) { row.Foreground = new SolidColorBrush(Colors.White); row.Background = new SolidColorBrush(Colors.DarkSlateGray); } else if (context.Type.Equals("SendEvent")) { row.Foreground = new SolidColorBrush(Colors.White); row.Background = new SolidColorBrush(Colors.RoyalBlue); } else if (context.Type.Equals("DequeueEvent")) { row.Foreground = new SolidColorBrush(Colors.White); row.Background = new SolidColorBrush(Colors.SteelBlue); } else if (context.Type.Equals("RaiseEvent")) { row.Foreground = new SolidColorBrush(Colors.Black); row.Background = new SolidColorBrush(Colors.LightSalmon); } else if (context.Type.Equals("GotoState")) { row.Foreground = new SolidColorBrush(Colors.Black); row.Background = new SolidColorBrush(Colors.Khaki); } else if (context.Type.Equals("InvokeAction")) { row.Foreground = new SolidColorBrush(Colors.Black); row.Background = new SolidColorBrush(Colors.BurlyWood); } else if (context.Type.Equals("WaitToReceive")) { row.Foreground = new SolidColorBrush(Colors.White); row.Background = new SolidColorBrush(Colors.DarkOrchid); } else if (context.Type.Equals("ReceiveEvent")) { row.Foreground = new SolidColorBrush(Colors.White); row.Background = new SolidColorBrush(Colors.DarkOrchid); } else if (context.Type.Equals("RandomChoice")) { row.Foreground = new SolidColorBrush(Colors.White); row.Background = new SolidColorBrush(Colors.BlueViolet); } else if (context.Type.Equals("Halt")) { row.Foreground = new SolidColorBrush(Colors.White); row.Background = new SolidColorBrush(Colors.DimGray); } row.Visibility = Visibility.Visible; }