コード例 #1
0
 private void RemoveEvent(TraceEvent ev)
 {
     AvailableEvents.Add(ev);
     SelectedEvents.Remove(ev);
     SelectedAvailableEvent = ev;
     SelectedSelectedEvent  = null;
 }
コード例 #2
0
        public EventSelectorVM(IEnumerable <EventClassType> events, Action <IEnumerable <EventClassType> > onSave, Action onClose)
        {
            CloseCommand = new DelegateCommand(
                o => true,
                o => onClose()
                );

            SaveCommand = new DelegateCommand(
                o => true,
                o => onSave(SelectedEvents.Select(x => x.EventClass))
                );

            AddEventCommand = new DelegateCommand(
                o => SelectedAvailableEvent != null,
                o => AddEvent(SelectedAvailableEvent)
                );

            RemoveEventCommand = new DelegateCommand(
                o => SelectedSelectedEvent != null,
                o => RemoveEvent(SelectedSelectedEvent)
                );

            ResetDefaultsCommand = new DelegateCommand(
                o => true,
                o => ResetDefaults()
                );

            SetEvents(events);
        }
コード例 #3
0
 private void DoDeleteSelectedEvents(Confirmation confirmation)
 {
     if (!confirmation.Confirmed)
     {
         return;
     }
     _cmdGen.FireDeleteEvents();
     Log.RemoveRange(SelectedEvents.Select(evm => evm.Event));
 }
コード例 #4
0
        private void DrawEvents(Graphics g)
        {
            foreach (
                TimelineEvent e in TimelineEvents.Where(x => x.Time >= ViewableWindow.X && x.Time <= ViewableWindow.Y))
            {
                Rectangle rect = HandleLocation(e);

                var colour = SelectedEvents.Contains(e) ? Brushes.MediumVioletRed : Brushes.DimGray;
                g.FillRectangle(colour, rect);
                Font f = new Font("Segoe UI", 15);

                g.DrawString(e.ToString(), f, new SolidBrush(Color.DarkGoldenrod), new PointF(rect.X, 0), new StringFormat(StringFormatFlags.DirectionVertical));
            }
        }
コード例 #5
0
        private void SetEvents(IEnumerable <EventClassType> selectedEventTypes)
        {
            AvailableEvents.Clear();
            foreach (var item in EventDefinition.Instance.Events)
            {
                AvailableEvents.Add(item);
            }

            SelectedEvents.Clear();
            foreach (var item in EventDefinition.Instance.Events.Where(x => selectedEventTypes.Contains(x.EventClass)))
            {
                AddEvent(item);
            }

            SelectedSelectedEvent = SelectedAvailableEvent = null;
        }
コード例 #6
0
        private async Task SelectedChangedAsync(Event _event)
        {
            if (SelectedEvents.All(e => e != _event))
            {
                foreach (var report in Reports.ToArray())
                {
                    if (report.Event.Id == _event.Id)
                    {
                        Reports.Remove(report);
                    }
                }
                foreach (var explosion in Explosions.ToArray())
                {
                    if (explosion.Event.Id == _event.Id)
                    {
                        Explosions.Remove(explosion);
                    }
                }
            }
            else
            {
                var reports = await MapModel.GetReports(_event.Id);

                var explosions = await MapModel.GetExplosions(_event.Id);

                foreach (var report in reports)
                {
                    Reports.Add(report);
                }
                foreach (var explosion in explosions)
                {
                    Explosions.Add(explosion);
                }
            }
            OnPropertyChanged(nameof(LocationList));
        }
コード例 #7
0
        private async Task SelectedChangedAsync(Event _event)
        {
            if (SelectedEvents.All(e => e != _event))
            {
                foreach (var report in Reports.ToArray())
                {
                    if (report.Event.Id == _event.Id)
                    {
                        Reports.Remove(report);
                    }
                }
                foreach (var Hit in Hits.ToArray())
                {
                    if (Hit.Event.Id == _event.Id)
                    {
                        Hits.Remove(Hit);
                    }
                }
            }
            else
            {
                var reports = await MapModel.GetReports(_event.Id);

                var hits = await MapModel.GetHits(_event.Id);

                foreach (var report in reports)
                {
                    Reports.Add(report);
                }
                foreach (var hit in hits)
                {
                    Hits.Add(hit);
                }
            }
            OnPropertyChanged(nameof(LocationList));
        }
コード例 #8
0
        protected override void DeleteCore()
        {
            // Contains the same references as in SelectedEvents,
            // these references can change when un-doing so keep a snapshot around
            List <Event> previousSelection = new List <Event>(SelectedEvents);

            // Contains instance copies of events, this will be the old data before the do is applied.
            List <Event> eventsCopy = SelectedEvents.Select(d => d.DuckCopy <Event>()).ToList();

            #region Do action

            Action doAction = delegate
            {
                // Get the view source of the events collection
                IEditableCollectionView eventsView = (IEditableCollectionView)EventsViewSource.View;

                foreach (Event calendarevent in SelectedEvents)
                {
                    // Edit the view source
                    eventsView.EditItem(calendarevent);

                    // Move the event to the trash
                    calendarevent.EventFolder = Folders.Trash;
                    ClientState.Current.DataService.Update(calendarevent, "EventFolder");

                    // Let the world know that an event is moved to the trash
                    EventBroker.Publish(AppEvents.UpdateEventState, calendarevent);

                    // Commit the changes to the view
                    eventsView.CommitEdit();
                }
            };

            #endregion

            #region Undo action

            Action undoAction = delegate
            {
                // Walk through all the events in the previous selection
                foreach (Event calendarevent in previousSelection)
                {
                    // Get the origional event from the copied list
                    var oldCalendarEvent = eventsCopy.Single(d => d.InternalEventId == calendarevent.InternalEventId);

                    // Set the folder to the origional folder
                    calendarevent.EventFolder = oldCalendarEvent.EventFolder;

                    // Update the event
                    ClientState.Current.DataService.Update(calendarevent, "EventFolder");

                    // Let the world know that an event is updated
                    EventBroker.Publish(AppEvents.UpdateEventState, calendarevent);
                }

                // We cannot use the IEditableObject appraoch here because the document in question
                // probably might not be in view anymore. So instead we will refresh the whole view.
                EventsViewSource.View.Refresh();
            };

            #endregion

            // Add the do and undo actions to the UndoManager
            ClientState.Current.UndoManager.Execute(new HistoryAction(doAction, undoAction));
        }