void LoadFromEventList(Rect windowSize) { if (eventList.majorEvents.Count > 0) { eventWindows.Clear(); for (int i = 0; i < eventList.majorEvents.Count; i++) { EventWindow newWindow = CreateInstance <EventWindow>(); newWindow.windowRect = new Rect(250, 0, windowSize.width - 250, windowSize.height); newWindow.EventName = eventList.majorEvents[i].eventName; newWindow.Description = eventList.majorEvents[i].eventDescription; if (eventList.majorEvents[i].choices.Count > 0) { for (int j = 0; j < eventList.majorEvents[i].choices.Count; j++) { ChoiceWindow newChoice = CreateInstance <ChoiceWindow>(); newChoice.Init(new Rect(6, 160, 252, 280)); newChoice.choiceName = eventList.majorEvents[i].choices[j].choiceName; newChoice.changeStatBy = eventList.majorEvents[i].choices[j].statChanges; newChoice.statsToChange = eventList.majorEvents[i].choices[j].statsToChange; newChoice.LoadFromFile(); newWindow.choices.Add(newChoice); } } eventWindows.Add(newWindow); } currentWindow = eventWindows[0]; } }
private void OnGUI() { if (!eventList) { eventList = AssetDatabase.LoadAssetAtPath <MajorEventDetails>("Assets/Scripts/Events/MajorEvents.asset"); LoadFromEventList(position); } if (eventWindows.Count == 0) { currentWindow = null; } EventSidebar(position); if (currentWindow != null) { DrawEditorWindow(); } else if (currentWindow == null && eventWindows.Count != 0) { currentWindow = eventWindows[SelectedEvent]; DrawEditorWindow(); } }
public void Add_and_complete_multiple_event_types_moves_to_completed() { EventWindow window = new EventWindow(DateTime.MinValue); int eventIdA = 1; int eventIdB = 2; int eventIdC = 3; Guid instanceIdA1 = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); Guid instanceIdB1 = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2); Guid instanceIdB2 = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3); Guid instanceIdC1 = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4); Guid instanceIdC2 = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5); Guid instanceIdC3 = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6); window.Add(eventIdA, instanceIdA1); window.Add(eventIdB, instanceIdB1); window.Add(eventIdB, instanceIdB2); window.Add(eventIdC, instanceIdC1); window.Add(eventIdC, instanceIdC2); window.Add(eventIdC, instanceIdC3); window.Complete(eventIdA, instanceIdA1); window.Complete(eventIdB, instanceIdB2); window.Complete(eventIdC, instanceIdC2); window.Complete(eventIdC, instanceIdC3); Assert.Equal(0, window.GetPendingCount(eventIdA)); Assert.Equal(1, window.GetPendingCount(eventIdB)); Assert.Equal(1, window.GetPendingCount(eventIdC)); Assert.Equal(1, window.GetCompletedCount(eventIdA)); Assert.Equal(1, window.GetCompletedCount(eventIdB)); Assert.Equal(2, window.GetCompletedCount(eventIdC)); }
public void PointsOnEventWindowAreCorrectColors() { var window = new EventWindow(GetMultiColoredScreen(), GetWindowFinder(), Substitute.For <IInputDevice>(), Substitute.For <ISettingsStore>()); AssertPixelsOnControlAreCorrect(window); AssertGettingOutOfBoundsPixelsThrows(window); }
public void Copy_construct_deep_copies_instance() { DateTime startTime = new DateTime(2000, 1, 2, 3, 4, 5, 6); EventWindow window = new EventWindow(startTime); Assert.Equal(startTime, window.StartTime); int eventIdA = 1; int eventIdB = 2; Guid instanceIdA = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); Guid instanceIdB = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2); window.Add(eventIdA, instanceIdA); window.Complete(eventIdA, instanceIdA); window.Add(eventIdB, instanceIdB); DateTime newStartTime = new DateTime(2001, 2, 3, 4, 5, 6, 7); EventWindow copiedWindow = new EventWindow(window, newStartTime); Assert.Equal(newStartTime, copiedWindow.StartTime); Assert.Equal(1, copiedWindow.GetCompletedCount(eventIdA)); copiedWindow.Complete(eventIdB, instanceIdB); Assert.Equal(1, window.GetPendingCount(eventIdB)); Assert.Equal(0, window.GetCompletedCount(eventIdB)); window.ClearCompleted(); Assert.Equal(1, copiedWindow.GetCompletedCount(eventIdA)); }
private void AddEvent() { EventViewModel evm = new EventViewModel(); if (SelectedItem == null) { evm.DateYear = DateTime.Now.Year; evm.DateMonth = DateTime.Now.Month; evm.DateDay = DateTime.Now.Day; } else { evm.DateYear = SelectedItem.Year; evm.DateMonth = SelectedItem.Month; evm.DateDay = SelectedItem.DayInMonth; } EventWindow window = new EventWindow() { DataContext = evm }; evm.OnRequestClose += (s, e) => window.Close(); window.ShowDialog(); }
private void Details() { EventWindow ew = new EventWindow(); ew.DataContext = this; ew.Show(); }
private void CreateWindow() { GameObject createObj = Instantiate(AssetBundleEx.Load <GameObject>(EVENTWINDOW_PATH)) as GameObject; createObj.transform.localPosition = Vector3.zero; createObj.transform.localScale = Vector3.one; m_eventWindow = createObj.GetComponent <EventWindow>(); }
public void Complete_no_existing_event_does_nothing() { EventWindow window = new EventWindow(DateTime.MinValue); int eventId = 1; Guid instanceId = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); window.Complete(eventId, instanceId); Assert.Equal(0, window.GetCompletedCount(eventId)); }
public void Add_adds_operation_to_pending() { EventWindow window = new EventWindow(DateTime.MinValue); int eventId = 1; Guid instanceId = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); window.Add(eventId, instanceId); Assert.Equal(1, window.GetPendingCount(eventId)); }
private void CreateEvent(object sender, RoutedEventArgs e) { EventWindow eventWindow = new EventWindow { Owner = ((MainWindow)Application.Current.MainWindow) }; if (true == eventWindow.ShowDialog()) { this.fetchData(); } }
public void Add_same_type_twices_adds_2_operations_to_pending() { EventWindow window = new EventWindow(DateTime.MinValue); int eventId = 1; Guid instanceId1 = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); Guid instanceId2 = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2); window.Add(eventId, instanceId1); window.Add(eventId, instanceId2); Assert.Equal(2, window.GetPendingCount(eventId)); }
public void Complete_pending_event_with_same_type_and_ID_moves_to_completed() { EventWindow window = new EventWindow(DateTime.MinValue); int eventId = 1; Guid instanceId = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); window.Add(eventId, instanceId); window.Complete(eventId, instanceId); Assert.Equal(0, window.GetPendingCount(eventId)); Assert.Equal(1, window.GetCompletedCount(eventId)); }
public bool AddButton_Click() { EventModel newModel; EventWindow addEventWindow = new EventWindow(); if (addEventWindow.ShowDialog(out newModel) == true) { EventDB.insert(newModel); Console.WriteLine("newModel inserted to LiteDB"); return(true); } return(false); }
public void Add_different_types_adds_2_separate_operations_to_pending() { EventWindow window = new EventWindow(DateTime.MinValue); int eventId1 = 1; Guid instanceId1 = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); int eventId2 = 2; Guid instanceId2 = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2); window.Add(eventId1, instanceId1); window.Add(eventId2, instanceId2); Assert.Equal(1, window.GetPendingCount(eventId1)); Assert.Equal(1, window.GetPendingCount(eventId2)); }
private void EditEvent(object sender, RoutedEventArgs e) { if (EventListBox.SelectedItem != null) { EventWindow eventWindow = new EventWindow((Models.Event)EventListBox.SelectedItem) { Owner = ((MainWindow)Application.Current.MainWindow) }; if (true == eventWindow.ShowDialog()) { this.fetchData(); } } }
public void Add_same_type_same_ID_throws_InvalidOperation() { EventWindow window = new EventWindow(DateTime.MinValue); int eventId = 1; Guid instanceId = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); window.Add(eventId, instanceId); InvalidOperationException ioe = Assert.Throws <InvalidOperationException>(() => window.Add(eventId, instanceId)); Assert.Contains("00000000-0000-0000-0000-000000000001", ioe.Message, StringComparison.Ordinal); Assert.Equal(1, window.GetPendingCount(eventId)); }
public static void X() { // Create a new session, turn on some events, and get the stream of events var session = new TraceEventSession("MySession"); session.EnableProvider(TraceEventProviders.GetEventSourceGuidFromName("MyEventSource")); var eventStream = session.Source; // Create an in memory GENERIC list of parsed (basically string) records that can hold the results GenericEventSource eventSource = new GenericEventSource(); // Hook up the ETW eventStream to the generic in memory event source. var dynamicParser = new DynamicTraceEventParser(eventStream); Action <TraceEvent> sendToEventStore = delegate(TraceEvent data) { var processName = data.ProcessName; if (!processName.StartsWith("(")) { processName += " (" + data.ProcessID + ")"; } var fieldNames = data.PayloadNames; var fields = new string[fieldNames.Length]; for (int i = 0; i < fields.Length; i++) { fields[i] = data.PayloadString(i); } var genericRecord = new GenericEventRecord(data.EventName, data.ProcessName, data.TimeStampRelativeMSec, fieldNames, fields); eventSource.Records.AddRecord(genericRecord); }; dynamicParser.All += sendToEventStore; var registeredParser = new RegisteredTraceEventParser(eventStream); registeredParser.All += sendToEventStore; eventStream.UnhandledEvents += sendToEventStore; // Start processing ETW events and filling the in-memory list (which the GUI is observing). var thread = new Thread(delegate() { session.Source.Process(); }); thread.Start(); var window = new EventWindow(GuiApp.MainWindow, eventSource); window.Show(); }
public void Known_event_IDs_returns_all_completed_and_pending() { EventWindow window = new EventWindow(DateTime.MinValue); int eventIdA = 1; int eventIdB = 2; Guid instanceIdA = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); Guid instanceIdB = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2); window.Add(eventIdB, instanceIdB); window.Add(eventIdA, instanceIdA); window.Complete(eventIdA, instanceIdA); int[] eventIds = window.KnownEventIds.ToArray(); Array.Sort(eventIds); Assert.Equal(new int[] { eventIdA, eventIdB }, eventIds); }
void EventSidebar(Rect windowRect) { Vector2 scrollPos = new Vector2(); Handles.BeginGUI(); GUILayout.BeginArea(new Rect(0, 0, 240, windowRect.height), GUIContent.none, EditorStyles.textArea); GUILayout.BeginHorizontal(); if (GUILayout.Button("Add Event")) { EventWindow temp = CreateInstance <EventWindow>(); temp.windowRect = new Rect(250, 0, position.width - 250, position.height); eventWindows.Add(temp); eventList.majorEvents.Add(new MajorEvents() { eventName = eventWindows[eventWindows.Count - 1].EventName, eventDescription = eventWindows[eventWindows.Count - 1].Description, choices = new List <MajorEventChoices>() }); } if (GUILayout.Button("Delete All")) { eventWindows.Clear(); eventList.majorEvents.Clear(); } GUILayout.EndHorizontal(); GUILayout.BeginVertical(); if (eventList.majorEvents.Count != 0) { for (int i = 0; i < eventList.majorEvents.Count; i++) { EventSidebar(i, windowRect); } } GUILayout.EndVertical(); GUILayout.EndArea(); Handles.EndGUI(); }
private void PushEvent(OperationItem operation) { lock (Lock) { Dispatcher.Invoke((Action)(() => { if (_eventWindow == null) { _eventWindow = new EventWindow(); _eventWindow.Closed += EventWindow_Closed; _eventWindow.Show(); } // Call the event window on this operation _eventWindow.PushEvent(operation.ToOperation()); })); } }
public void Clear_completed_resets_completed_counts() { EventWindow window = new EventWindow(DateTime.MinValue); int eventIdA = 1; int eventIdB = 2; Guid instanceIdA = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); Guid instanceIdB = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2); window.Add(eventIdA, instanceIdA); window.Complete(eventIdA, instanceIdA); window.Add(eventIdB, instanceIdB); window.ClearCompleted(); Assert.Equal(0, window.GetPendingCount(eventIdA)); Assert.Equal(1, window.GetPendingCount(eventIdB)); Assert.Equal(0, window.GetCompletedCount(eventIdA)); }
public bool EditButton_Click() { EventModel newModel; EventWindow editEventWindow = new EventWindow(eventModel); if (editEventWindow.ShowDialog(out newModel) == true) { eventModel.Subject = newModel.Subject; eventModel.EmailToRecall = newModel.EmailToRecall; eventModel.StartDateTime = newModel.StartDateTime; eventModel.Description = newModel.Description; eventModel.EmailSentSuccessful = newModel.EmailSentSuccessful; Refresh(); EventDB.update(eventModel); Console.WriteLine("eventModel (Subject = " + eventModel.Subject + ") updated"); return(true); } return(false); }
private void OpenEventWindow() { if (!_eventWindowOpened) { _eventWindowOpened = true; var eventWindow = new EventWindow(); var eventWindowViewModel = new EventWindowViewModel(_connectionHandler); eventWindowViewModel.ExitButtonClicked += (sender, args) => { eventWindow.Close(); _eventWindowOpened = false; }; eventWindow.DataContext = eventWindowViewModel; eventWindow.Show(); } }
private void Update() { string oldName = Entity.Name; string oldType = Entity.Type; string oldOrganizer = Entity.Organizer; DateTime?oldDate = Entity.Date; string oldLocation = Entity.Location; int? oldTickets = Entity.Tickets; double? oldPrice = Entity.Price; string oldDescription = Entity.Description; Entity.Name = Name; Entity.Type = Type; Entity.Organizer = Organizer; Entity.Date = Date; Entity.Location = Location; Entity.Tickets = Tickets; Entity.Price = Price; Entity.Description = Description; _eventRequester.Update(Id, Entity); UpdateCommand.RaiseCanExecuteChanged(); if (!_eventRequester.Update(Id, Entity)) { Entity.Name = oldName; Entity.Type = oldType; Entity.Organizer = oldOrganizer; Entity.Date = oldDate; Entity.Location = oldLocation; Entity.Tickets = oldTickets; Entity.Price = oldPrice; Entity.Description = oldDescription; } EventWindow eventWindow = App.Current.Windows.OfType <EventWindow>().FirstOrDefault(); eventWindow.Close(); //ew.Close(); }
public void Add_many_types_adds_separate_operations_to_pending() { EventWindow window = new EventWindow(DateTime.MinValue); int eventIdA = 1; Guid instanceIdA1 = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); int eventIdB = 2; Guid instanceIdB1 = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2); Guid instanceIdB2 = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3); int eventIdC = 3; Guid instanceIdC1 = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4); Guid instanceIdC2 = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5); Guid instanceIdC3 = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6); window.Add(eventIdA, instanceIdA1); window.Add(eventIdB, instanceIdB1); window.Add(eventIdB, instanceIdB2); window.Add(eventIdC, instanceIdC1); window.Add(eventIdC, instanceIdC2); window.Add(eventIdC, instanceIdC3); Assert.Equal(1, window.GetPendingCount(eventIdA)); Assert.Equal(2, window.GetPendingCount(eventIdB)); Assert.Equal(3, window.GetPendingCount(eventIdC)); }
private void EventWindow_Closed(object sender, System.EventArgs e) { _eventWindow = null; }
public void Add_same_type_same_ID_throws_InvalidOperation() { EventWindow window = new EventWindow(DateTime.MinValue); int eventId = 1; Guid instanceId = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); window.Add(eventId, instanceId); InvalidOperationException ioe = Assert.Throws<InvalidOperationException>(() => window.Add(eventId, instanceId)); Assert.Contains("00000000-0000-0000-0000-000000000001", ioe.Message, StringComparison.Ordinal); Assert.Equal(1, window.GetPendingCount(eventId)); }
public void Get_pending_count_missing_type_returns_0() { EventWindow window = new EventWindow(DateTime.MinValue); Assert.Equal(0, window.GetPendingCount(1)); }
private void EventSidebar(int index, Rect windowRect) { bool isActive = false; GUIContent labelContent = new GUIContent(eventList.majorEvents[index].eventName, eventList.majorEvents[index].eventDescription); GUIStyle labelStyle = GUI.skin.label; labelStyle.normal.textColor = Color.grey; if (index == SelectedEvent) { isActive = true; } if (isActive) { currentWindow = eventWindows[index]; labelStyle.normal.textColor = Color.green; if (currentWindow.ChoiceAdded) { eventList.majorEvents[index].choices.Add(new MajorEventChoices() { choiceName = "Input Name Here", statChanges = new List <float>(), statsToChange = new List <string>() }); currentWindow.ChoiceAdded = false; } if (currentWindow.AllRemoved) { eventList.majorEvents[index].choices.Clear(); currentWindow.AllRemoved = false; } eventList.majorEvents[index].eventName = currentWindow.EventName; eventList.majorEvents[index].eventDescription = currentWindow.Description; for (int i = 0; i < currentWindow.choices.Count; i++) { eventList.majorEvents[index].choices[i].choiceName = currentWindow.choices[i].choiceName; eventList.majorEvents[index].choices[i].statChanges = currentWindow.choices[i].changeStatBy; eventList.majorEvents[index].choices[i].statsToChange = currentWindow.choices[i].statsToChange; eventList.majorEvents[index].choices[i].statChangesAsString = currentWindow.choices[i].statChangesAsString; eventList.majorEvents[index].choices[i].statChangesToDisplay = currentWindow.choices[i].statChangesToDisplay; } } int offset = 0; if (eventList.majorEvents[index].choices.Count != 0) { eventList.majorEvents[index].showChoices = EditorGUILayout.Foldout(eventList.majorEvents[index].showChoices, "", false); offset = 12; } else { GUILayout.Label("", GUILayout.Height(15)); } Rect areaRect = GUILayoutUtility.GetLastRect(); areaRect.x += offset; areaRect.width -= offset; bool selected = GUI.Toggle(areaRect, isActive, labelContent, GUI.skin.label); if (eventList.majorEvents[index].showChoices) { for (int i = 0; i < eventList.majorEvents[index].choices.Count; i++) { GUIContent childContent = new GUIContent("".PadLeft(3) + eventList.majorEvents[index].choices[i].choiceName, eventList.majorEvents[index].choices[i].statChangesAsString); GUILayout.Label(childContent); } } if (selected && !isActive) { GUI.FocusControl(null); SelectedEvent = index; currentWindow = eventWindows[SelectedEvent]; } }
public AudioEventCreatorGUI(EventWindow window) : base(window) { }