コード例 #1
0
        /// <summary>
        /// Creates a new timeline entry
        /// </summary>
        /// <param name="entry">Timeline Entry</param>
        /// <returns>Timeline Entry with filled id</returns>
        public async Task <TimelineEntry> CreateTimelineEntry(TimelineEntry entry)
        {
            entry.Id = Guid.NewGuid().ToString();
            await _TimelineCollection.InsertOneAsync(entry);

            return(entry);
        }
コード例 #2
0
        private void EntryChanged_Event(object sender, System.Windows.RoutedEventArgs e)
        {
            object[] entries = e.OriginalSource as object[];

            TimelineEntry oldEntry = entries[0] as TimelineEntry;
            TimelineEntry newEntry = entries[1] as TimelineEntry;

            RouteTimeTableEntry oEntry = (RouteTimeTableEntry)oldEntry.Source;

            RouteTimeTable      rt     = new RouteTimeTable(oEntry.TimeTable.Route);
            RouteTimeTableEntry nEntry = new RouteTimeTableEntry(rt, (DayOfWeek)newEntry.StartTime.Days, newEntry.StartTime, oEntry.Destination);

            nEntry.Airliner = this.Airliner;
            rt.addEntry(nEntry);

            List <RouteTimeTableEntry> tEntries = new List <RouteTimeTableEntry>(this.Entries);

            tEntries.Remove(oEntry);

            if (!TimeTableHelpers.IsTimeTableValid(rt, this.Airliner, tEntries))
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2706"), Translator.GetInstance().GetString("MessageBox", "2706", "message"), WPFMessageBoxButtons.Ok);
            }
            else
            {
                this.Entries.Remove(oEntry);

                this.Entries.Add(nEntry);
            }
        }
コード例 #3
0
        private void EntryDeleted_Event(object sender, System.Windows.RoutedEventArgs e)
        {
            TimelineEntry entry = (TimelineEntry)e.OriginalSource;

            RouteTimeTableEntry rEntry = (RouteTimeTableEntry)entry.Source;

            this.Entries.Remove(rEntry);
        }
コード例 #4
0
        public ITimelineEntry Add(ICFunc coroutineFunction, object owner = null)
        {
            TimelineEntry entry = new TimelineEntry(coroutineFunction);

            _entries.Add(entry);
            UpdateEntry(entry);
            return(entry);
        }
コード例 #5
0
    void HandleCharacterCommandEntryInserted(Timeline<string> timeline, TimelineEntry<string> entry)
    {
        Debug.Log("Character command recieved");

        // the various parts of the command are separated by commas
        string[]tokens = entry.Value.Split(',');
        string action = tokens[0];
    }
コード例 #6
0
ファイル: SearchOperations.cs プロジェクト: jenyayel/rgroup
 public static Task IndexTimelineMessageAsync(
     TimelineEntry entry)
 {
     return(IndexItemAsync(
                new MessageIndexEntry
     {
         ItemId = "timeline-" + entry.TimelineEntryId,
         Content = entry.Message.Content,
         TimelineEntryId = entry.TimelineEntryId
     }));
 }
コード例 #7
0
        /// <summary>
        /// Liefert das TimelineEvent zurück dass sich an der Position position befindet
        /// </summary>
        /// <param name="position">Position auf dem Control</param>
        /// <param name="onlySelectedEntry">nur auf dem selektierten TimelineEntry suchen, oder auch auf den anderen</param>
        /// <returns>das TimelineEvent auf welches geklickt wurde, oder null falls es kein solches gibt</returns>
        public TimelineEvent GetTimelineEventAtControlPosition(Point position, Boolean onlySelectedEntry)
        {
            TimelineEntry entry = GetTimelineEntryAtControlPosition(position);

            if (entry != null && (!onlySelectedEntry || entry == selectedEntry))
            {
                double time = GetTimeAtControlPosition(position, false);
                return(entry.GetEventAtTime(time));
            }
            return(null);
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: xnamahx/JanusLiteNetLib
 static void OnEntryInserted(Timeline <float> timeline, TimelineEntry <float> entry)
 {
     Console.WriteLine("Inserted " + timeline.StringID + " " + entry.Time + " " + entry.Value);
     if (timeline.StringID == "a")
     {
         testTL = TimelineManager.Default.Get <float>("Anew");
     }
     else
     {
         TimelineManager.Default.Remove(testTL);
     }
     Console.WriteLine("pass " + timeline.StringID + " " + entry.Time + " " + entry.Value);
 }
コード例 #9
0
        private static void ExtractRegisteredTIDsFromEntry(TimelineEntry entry, HashSet <Tuple <int, int, int> > registeredTIDs)
        {
            registeredTIDs.Add(new Tuple <int, int, int>(
                                   entry.NodeId,
                                   entry.ThreadAffinity.ThreadId,
                                   entry.ThreadAffinity.ThreadId
                                   ));

            foreach (TimelineEntry child in entry.ChildEntries)
            {
                ExtractRegisteredTIDsFromEntry(child, registeredTIDs);
            }
        }
コード例 #10
0
 void UpdateEntry(TimelineEntry entry)
 {
     if (entry._coroutineFunction.HasUpdater && entry.Parent == null)
     {
         TimelineEntry parent = Find(tle => entry._coroutineFunction.IsUpdatedBy(tle._coroutineFunction));
         if (parent != null)
         {
             if (_entries.Contains(entry))
             {
                 _entries.Remove(entry);
             }
             if (!parent.Children.Contains(entry))
             {
                 parent.AddChild(entry);
             }
         }
     }
 }
コード例 #11
0
    public List <TimelineEntry> GetHistory()
    {
        List <TimelineEntry> entries     = new List <TimelineEntry>();
        List <string>        dateStrings = new List <string>(this.timeline.Keys);

        foreach (string dateString in dateStrings)
        {
            DateTime      dateTime = DateParser.parse(dateString);
            int           value    = timeline[dateString];
            TimelineEntry entry    = new TimelineEntry();
            entry.date  = dateTime;
            entry.value = value;
            entries.Add(entry);
        }
        List <TimelineEntry> SortedList = entries.OrderBy(o => o.date).ToList();

        return(entries);
    }
コード例 #12
0
        /// <summary>
        /// The ith value in a timeline
        /// </summary>
        public TimelineEntry <T> this[int i]
        {
            get
            {
                TimelineEntry <T> target = null;

                for (int j = 0; j < i; j++)
                {
                    if (target == null)
                    {
                        target = _next;
                    }
                    else
                    {
                        target = target._next;
                    }

                    if (target == null)
                    {
                        return(null);
                    }
                }

                for (int j = 0; j > i; j--)
                {
                    if (target == null)
                    {
                        target = _prev;
                    }
                    else
                    {
                        target = target._prev;
                    }

                    if (target == null)
                    {
                        return(null);
                    }
                }

                return(target);
            }
        }
コード例 #13
0
ファイル: MoviesController.cs プロジェクト: Grigann/PopWeb
        /// <summary>
        /// Saves a new watching session and creates a new movie if necessary
        /// </summary>
        /// <param name="movieEntry">A movie entry</param>
        /// <returns>A JSON representation of a timeline entry</returns>
        public JsonResult QuickSave(MovieEntry movieEntry)
        {
            // Used to emulate a failure
            if (movieEntry.Director == "FAIL") {
                throw new Exception("Une erreur");
            }

            WatchingSession watchingSession;
            using (var uow = new UnitOfWork(true)) {
                var movie = uow.Movies.FindByTitle(movieEntry.Title) ??
                            new Movie() { Title = movieEntry.Title, Director = movieEntry.Director };

                watchingSession = new WatchingSession() { Date = DateTime.ParseExact(movieEntry.EntryDate, "dd/MM/yyyy", null) };
                movie.AddWatchingSession(watchingSession);

                uow.Movies.SaveOrUpdate(movie);
                uow.Commit();
            }

            var timelineEntry = new TimelineEntry(watchingSession, this);
            return Json(timelineEntry);
        }
コード例 #14
0
        /// <summary>
        /// gibt die Koordinaten der linken oberen Ecke des TimelineEntries te zurück
        /// </summary>
        /// <param name="te">TimelineEntry, wessen Position berechnet werden soll</param>
        /// <returns>Koordinaten der linken oberen Ecke des Balkens, der te repräsentiert oder null, falls te nicht in m_entries</returns>
        public Point GetClientPositionForTimelineEntry(TimelineEntry te)
        {
            int y = 0;

            foreach (TimelineGroup tg in steuerung.groups)
            {
                y += totalRowHeight;
                if (!tg.collapsed)
                {
                    foreach (TimelineEntry foo in tg.entries)
                    {
                        if (foo == te)
                        {
                            return(new Point(totalRowHeight, y));
                        }
                        y += totalRowHeight;
                    }
                }
            }

            return(new Point(0, 0));
        }
コード例 #15
0
        public static async Task <HttpStatusCode> AddOrRemoveTimelineEntryLikeAsync(
            ApplicationDbContext dbContext,
            string userId,
            int entryId,
            LikeRequest like)
        {
            TimelineEntry entryEntity = await dbContext.TimelineEntries
                                        .SingleOrDefaultAsync(te => te.TimelineEntryId == entryId);

            if (entryEntity == null)
            {
                // The entry id is part of the URL, so return a 404.
                return(HttpStatusCode.NotFound);
            }

            return(await LikeOperations.AddOrRemoveLikeAsync(
                       dbContext,
                       userId,
                       entryId,
                       le => le.UserTextId,
                       like));
        }
コード例 #16
0
        public static async Task <HttpStatusCode> AddTimelineEntryCommentAsync(
            ApplicationDbContext dbContext,
            string userId,
            int entryId,
            CommentRequest comment)
        {
            TimelineEntry entryEntity = await dbContext.TimelineEntries
                                        .SingleOrDefaultAsync(te => te.TimelineEntryId == entryId);

            if (entryEntity == null)
            {
                // The entry id is part of the URL, so return a 404.
                return(HttpStatusCode.NotFound);
            }

            return(await CommentOperations.AddCommentAsync(
                       dbContext,
                       userId,
                       new CommentItemIds { TimelineEntryId = entryId },
                       e => e.CommentThread,
                       entryEntity,
                       comment));
        }
コード例 #17
0
        private static async Task <HttpStatusCode> RemoveLikeAsync(
            ApplicationDbContext dbContext, string userId, int entryId, LikeKind kind)
        {
            TimelineEntry entryEntity = await dbContext.TimelineEntries
                                        .SingleOrDefaultAsync(te => te.TimelineEntryId == entryId);

            if (entryEntity == null)
            {
                return(HttpStatusCode.NotFound);
            }

            var likeEntity = new Like
            {
                UserId     = userId,
                Kind       = kind,
                UserTextId = entryEntity.MessageUserTextId
            };

            dbContext.Likes.Add(likeEntity);

            await dbContext.SaveChangesAsync();

            return(HttpStatusCode.OK);
        }
コード例 #18
0
        TimelineEntry Find(Func <TimelineEntry, bool> predicate)
        {
            Stack <TimelineEntry> stack = new Stack <TimelineEntry>();

            foreach (TimelineEntry entry in _entries)
            {
                stack.Push(entry);
            }

            while (stack.Count > 0)
            {
                TimelineEntry entry = stack.Pop();
                if (predicate(entry))
                {
                    return(entry);
                }
                foreach (TimelineEntry child in entry.Children)
                {
                    stack.Push(child);
                }
            }

            return(null);
        }
コード例 #19
0
 /// <summary>
 /// Updates a new timeline entry
 /// </summary>
 /// <param name="entry">Timeline Entry</param>
 /// <returns>Timeline Entry with filled id</returns>
 public async Task UpdateTimelineEntry(TimelineEntry entry)
 {
     ReplaceOneResult result = await _TimelineCollection.ReplaceOneAsync(p => p.Id == entry.Id, entry);
 }
コード例 #20
0
        public static async Task <HttpStatusCode> AddTimelineEntryAsync(
            CreateTimelineEntry createMessage,
            ApplicationDbContext dbContext,
            UserInfo userEntity)
        {
            if (string.IsNullOrWhiteSpace(createMessage?.Message))
            {
                return(HttpStatusCode.BadRequest);
            }

            var text = await TextOperations.CreateTextAsync(dbContext, createMessage.Message);

            var timelineEntity = new TimelineEntry
            {
                UserId  = userEntity.UserInfoId,
                Message = text
            };

            if (createMessage.MediaIds != null && createMessage.MediaIds.Count > 0)
            {
                MediaAlbum timelineAlbum = await EnsureTimelinePhotoAlbumExistsAsync(dbContext, userEntity);

                timelineEntity.Media = new List <TimelineEntryMedia>();
                int sequence      = 0;
                var includedMedia = new List <UserMedia>();
                foreach (int id in createMessage.MediaIds)
                {
                    UserMedia mediaEntity = await dbContext.UserMedias
                                            .SingleAsync(um => um.UserMediaId == id);

                    if (mediaEntity.UserId != userEntity.UserInfoId)
                    {
                        // Only allowed to post your own images here
                        return(HttpStatusCode.BadRequest);
                    }
                    includedMedia.Add(mediaEntity);
                    mediaEntity.MediaAlbum = timelineAlbum;
                    var mediaEntry =
                        new TimelineEntryMedia
                    {
                        Media         = mediaEntity,
                        Sequence      = sequence++,
                        TimelineEntry = timelineEntity
                    };
                    dbContext.TimelineEntryMedia.Add(mediaEntry);
                    timelineEntity.Media.Add(mediaEntry);
                }
                foreach (UserMedia media in includedMedia)
                {
                    if (media.State == UserMediaState.UploadedButUnused)
                    {
                        media.State = UserMediaState.InUse;
                    }
                }
            }

            dbContext.UserTexts.Add(text);
            dbContext.TimelineEntries.Add(timelineEntity);
            await dbContext.SaveChangesAsync();

            await UserOperations.NotifyMentionsAsync(
                dbContext, "Timeline Entry", userEntity.UserInfoId, text);

            await SearchOperations.IndexTimelineMessageAsync(timelineEntity);

            return(HttpStatusCode.OK);
        }
コード例 #21
0
ファイル: TvSeriesController.cs プロジェクト: Grigann/PopWeb
        /// <summary>
        /// Saves a new watching session session and creates a new series/season/episode if necessary
        /// </summary>
        /// <param name="episodeEntry">Aen episode entry</param>
        /// <returns>A JSON representation of a timeline entry</returns>
        public JsonResult QuickSave(TvSerieEpisodeEntry episodeEntry)
        {
            // Used to emulate a failure
            if (episodeEntry.EpisodeTitle == "FAIL") {
                throw new Exception("Une erreur");
            }

            TvWatchingSession watchingSession;
            using (var uow = new UnitOfWork(true)) {
                var serie = uow.TvSeries.FindByTitle(episodeEntry.Title) ?? new TvSerie() { Title = episodeEntry.Title };

                var season = serie.Seasons.SingleOrDefault(x => x.Number == episodeEntry.SeasonNb);
                if (season == null) {
                    season = new TvSerieSeason() { Number = episodeEntry.SeasonNb };
                    serie.AddSeason(season);
                }

                var episode = season.Episodes.SingleOrDefault(x => x.Number == episodeEntry.EpisodeNb);
                if (episode == null) {
                    episode = new TvSerieEpisode() { Number = episodeEntry.EpisodeNb, Title = episodeEntry.EpisodeTitle };
                    season.AddEpisode(episode);
                }

                watchingSession = new TvWatchingSession() { Date = DateTime.ParseExact(episodeEntry.EntryDate, "dd/MM/yyyy", null) };
                episode.AddWatchingSession(watchingSession);

                uow.TvSeries.SaveOrUpdate(serie);
                uow.Commit();
            }

            var timelineEntry = new TimelineEntry(watchingSession, this);
            return Json(timelineEntry);
        }
コード例 #22
0
ファイル: ExportImport.cs プロジェクト: wolfspelz/galdev
        private bool CompareGoodEnough(TimelineEntry e1, TimelineEntry e2)
        {
            var x = e1;
            var y = e2;

            if (y == null)
            {
                return(false);
            }
            if (x.Name != y.Name)
            {
                return(false);
            }
            if (x.Year != y.Year)
            {
                return(false);
            }
            if (x.Title != y.Title)
            {
                return(false);
            }
            if (x.Short != y.Short)
            {
                return(false);
            }
//            if (x.Summary != y.Summary) return false;
            if (x.Headline != y.Headline)
            {
                return(false);
            }
            if (x.Image != y.Image)
            {
                return(false);
            }
            if (x.Smallimage != y.Smallimage)
            {
                return(false);
            }
            //if (x.Twitter != y.Twitter) return false;
            //if (x.Twitterimage != y.Twitterimage) return false;
            //if (x.Facebook != y.Facebook) return false;
            //if (x.Facebook2 != y.Facebook2) return false;
            //if (x.Facebook3 != y.Facebook3) return false;
            //if (x.Facebookimage != y.Facebookimage) return false;
            if (x.Post != y.Post)
            {
                return(false);
            }
            if (x.Postimage != y.Postimage)
            {
                return(false);
            }
            if (x.Author != y.Author)
            {
                return(false);
            }
            if (x.Translation != y.Translation)
            {
                return(false);
            }
            if (string.Join("", x.Tags) != string.Join("", y.Tags))
            {
                return(false);
            }
            if (string.Join("", x.Topics) != string.Join("", y.Topics))
            {
                return(false);
            }
            if (string.Join("", x.Text) != string.Join("", y.Text))
            {
                return(false);
            }
            return(true);
        }
コード例 #23
0
ファイル: BooksController.cs プロジェクト: Grigann/PopWeb
        /// <summary>
        /// Saves a new reading session and creates a new book if necessary
        /// </summary>
        /// <param name="bookEntry">A book entry</param>
        /// <returns>A JSON representation of a timeline entry</returns>
        public JsonResult QuickSave(BookEntry bookEntry)
        {
            // Used to emulate a failure
            if (bookEntry.Writer == "FAIL") {
                throw new Exception("Une erreur");
            }

            ReadingSession readingSession;
            using (var uow = new UnitOfWork(true)) {
                var book = uow.Books.FindByTitle(bookEntry.Title) ??
                           new Book() { Title = bookEntry.Title, Writer = bookEntry.Writer };

                readingSession = new ReadingSession() {
                    Date = DateTime.ParseExact(bookEntry.EntryDate, "dd/MM/yyyy", null),
                    Note = bookEntry.Note };
                book.AddReadingSession(readingSession);

                uow.Books.SaveOrUpdate(book);
                uow.Commit();
            }

            var timelineEntry = new TimelineEntry(readingSession, this);
            return Json(timelineEntry);
        }
コード例 #24
0
        private static string ExtractEventColor(TimelineBuildEntry timelineBuildEntry, TimelineEntry timelineEntry)
        {
            if (timelineBuildEntry != null)
            {
                BuildFinishedEvent endEvent = timelineBuildEntry.BuildEntry.EndEvent as BuildFinishedEvent;
                if (endEvent != null)
                {
                    return(endEvent.Succeeded ? s_BuildSucceededColor : s_BuildFailedColor);
                }
            }

            return(null);
        }
コード例 #25
0
 public static int Compare(TimelineEntry a, TimelineEntry b)
 {
     return a.TimeStamp.CompareTo(b.TimeStamp);
 }
コード例 #26
0
        private static void ExtractEventsIntoTrace(TimelineEntry timelineEntry, DateTime buildStartTimestamp, List <ChromeTracingEvent> events)
        {
            Debug.Assert(timelineEntry.ThreadAffinity.Calculated);

            TimelineBuildEntry timelineBuildEntry = timelineEntry as TimelineBuildEntry;

            // skip instantaneous entries
            if (timelineEntry.ElapsedTime == TimeSpan.Zero)
            {
                return;
            }

            Dictionary <string, string> args = new Dictionary <string, string>();

            // Guid
            args.Add("GUID", timelineEntry.GUID.ToString());
            if (timelineEntry.Parent != null)
            {
                args.Add("Parent GUID", timelineEntry.Parent.GUID.ToString());
            }

            // start
            if (timelineBuildEntry != null)
            {
                args.Add("Start event", timelineBuildEntry.BuildEntry.StartEvent.Message);
            }

            events.Add(new ChromeTracingEvent()
            {
                ph   = 'B',
                pid  = timelineEntry.NodeId,
                tid  = timelineEntry.ThreadAffinity.ThreadId,
                ts   = (timelineEntry.StartTimestamp - buildStartTimestamp).TotalMilliseconds * 1000.0d,
                name = timelineEntry.Name,
            });

            // child events
            foreach (TimelineEntry child in timelineEntry.ChildEntries)
            {
                ExtractEventsIntoTrace(child, buildStartTimestamp, events);
            }

            if (timelineBuildEntry != null)
            {
                // messages within this entry
                List <Event> messageEvents = timelineBuildEntry.BuildEntry.ChildEvents.Where(_ => _.GetType() == typeof(MessageEvent)).ToList();
                for (int i = 0; i < messageEvents.Count(); ++i)
                {
                    double millisecondsSinceStart = (messageEvents[i].Timestamp - buildStartTimestamp).TotalMilliseconds;
                    args.Add($"Message #{i}", $"[{millisecondsSinceStart:0.###} ms] {messageEvents[i].Message}");
                }

                // warnings within this entry
                List <Event> warningEvents = timelineBuildEntry.BuildEntry.ChildEvents.Where(_ => _.GetType() == typeof(WarningEvent)).ToList();
                for (int i = 0; i < warningEvents.Count(); ++i)
                {
                    double millisecondsSinceStart = (warningEvents[i].Timestamp - buildStartTimestamp).TotalMilliseconds;
                    args.Add($"Warning #{i}", $"[{millisecondsSinceStart:0.###} ms] {warningEvents[i].Message}");
                }

                // errors within this entry
                List <Event> errorEvents = timelineBuildEntry.BuildEntry.ChildEvents.Where(_ => _.GetType() == typeof(ErrorEvent)).ToList();
                for (int i = 0; i < errorEvents.Count(); ++i)
                {
                    double millisecondsSinceStart = (errorEvents[i].Timestamp - buildStartTimestamp).TotalMilliseconds;
                    args.Add($"Error #{i}", $"[{millisecondsSinceStart:0.###} ms] {errorEvents[i].Message}");
                }
            }

            // end
            if (timelineBuildEntry != null)
            {
                args.Add("End event", timelineBuildEntry.BuildEntry.EndEvent.Message);
            }

            events.Add(new ChromeTracingEvent()
            {
                ph    = 'E',
                pid   = timelineEntry.NodeId,
                tid   = timelineEntry.ThreadAffinity.ThreadId,
                ts    = (timelineEntry.EndTimestamp - buildStartTimestamp).TotalMilliseconds * 1000.0d,
                name  = timelineEntry.Name,
                args  = args,
                cname = ExtractEventColor(timelineBuildEntry, timelineEntry)
            });
        }
コード例 #27
0
ファイル: GamesController.cs プロジェクト: Grigann/PopWeb
        /// <summary>
        /// Saves a new gaming session and creates a new game if necessary
        /// </summary>
        /// <param name="gameEntry">A game entry</param>
        /// <returns>A JSON representation of a timeline entry</returns>
        public JsonResult QuickSave(GameEntry gameEntry)
        {
            // Used to emulate a failure
            if (gameEntry.Developper == "FAIL") {
                throw new Exception("Une erreur");
            }

            GamingSession gamingSession;
            using (var uow = new UnitOfWork(true)) {
                var game = uow.Games.FindByTitle(gameEntry.Title) ??
                           new Game() { Title = gameEntry.Title, Developper = gameEntry.Developper };

                gamingSession = new GamingSession() {
                    Date = DateTime.ParseExact(gameEntry.EntryDate, "dd/MM/yyyy", null),
                    Note = gameEntry.Note };
                game.AddGamingSession(gamingSession);

                uow.Games.SaveOrUpdate(game);
                uow.Commit();
            }

            var timelineEntry = new TimelineEntry(gamingSession, this);
            return Json(timelineEntry);
        }
コード例 #28
0
 /// <summary>
 /// Erstellt ein neues SelectionChangedEventArgs
 /// </summary>
 /// <param name="te">ausgewähltes TimelineEntry</param>
 /// <param name="ev">ausgewähltes TimelineEvent</param>
 /// <param name="dragAction">Art des Drag and Drop-Vorganges</param>
 public EventChangedEventArgs(TimelineEntry te, TimelineEvent ev, DragNDrop dragAction)
 {
     this.m_selectedEntry = te;
     this.m_handeledEvent = ev;
     this.m_dragAction    = dragAction;
 }
コード例 #29
0
 /// <summary>
 /// Erstellt ein neues SelectionChangedEventArgs
 /// </summary>
 /// <param name="tg">ausgewählte TimelineGroup</param>
 /// <param name="te">ausgewählte TimelineGroup</param>
 public SelectionChangedEventArgs(TimelineGroup tg, TimelineEntry te)
 {
     this.m_selectedGroup = tg;
     this.m_selectedEntry = te;
 }
コード例 #30
0
        /// <summary>
        /// Eventhandler beim Drücken der Maustaste
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TimelineControl_MouseDown(object sender, MouseEventArgs e)
        {
            // wurde der Zeitschieber angeklickt?
            if ((e.Button == MouseButtons.Left) && (Math.Abs(e.X - GetHorizontalClientPositionAtCurrentTime()) < 2))
            {
                // Drag'n'Drop Modus setzen
                howToDrag = DragNDrop.MOVE_TIMELINE_BAR;
            }

            // wurde ein Plus-/Minussysmbol einer Gruppe angeklickt?
            else if (e.X < rowHeight && GetGroupAtClientPosition(e.Location, true) != null)
            {
                TimelineGroup tg = GetGroupAtClientPosition(e.Location, true);
                tg.collapsed = !tg.collapsed;
            }

            // wurde vielleicht was anderes wichtiges angeklickt?
            else
            {
                TimelineEntry newEntry = GetTimelineEntryAtControlPosition(e.Location);
                TimelineGroup newGroup = GetGroupAtClientPosition(e.Location, false);

                if (newEntry != m_selectedEntry || newGroup != m_selectedGroup)
                {
                    m_selectedGroup = newGroup;
                    m_selectedEntry = newEntry;
                    OnSelectionChanged();
                }

                // wurde ein TimelineEntry angeklickt?
                if (m_selectedEntry != null)
                {
                    // gucken, ob es sich bei te um ein TrafficLight handelt
                    TrafficLight tl = m_selectedEntry as TrafficLight;
                    if (tl != null)
                    {
                        switch (e.Button)
                        {
                        case MouseButtons.Left:
                            #region TimelineEvent hinzufügen
                            if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
                            {
                                double time = GetTimeAtControlPosition(e.Location, true);

                                // Event hinzufügen, welches die Ampel umschaltet
                                TimelineEvent eventToAdd = new TimelineEvent(time, Math.Min(1, (m_selectedEntry.GetTimeOfNextEvent(time) - time) / 2), Color.Green, tl.SwitchToGreen, tl.SwitchToRed);
                                m_selectedEntry.AddEvent(eventToAdd, true, false);

                                howToDrag   = DragNDrop.MOVE_EVENT_END;
                                eventToDrag = eventToAdd;
                                this.Cursor = Cursors.SizeWE;
                                Invalidate();
                            }
                            #endregion

                            #region TimelineEntry selektieren
                            else
                            {
                                // Drag'n'Drop für Events initialisieren
                                TimelineEvent theEvent = GetTimelineEventAtControlPosition(e.Location, true);
                                if (theEvent != null)
                                {
                                    if (Math.Abs(GetClientPositionForTimelineEvent(theEvent).X - e.Location.X) < 3)
                                    {
                                        howToDrag   = DragNDrop.MOVE_EVENT_START;
                                        eventToDrag = theEvent;
                                    }
                                    else if (Math.Abs(GetClientPositionForTimelineEvent(theEvent).X + theEvent.eventLength * zoom - e.Location.X) < 3)
                                    {
                                        howToDrag   = DragNDrop.MOVE_EVENT_END;
                                        eventToDrag = theEvent;
                                    }
                                    else
                                    {
                                        mouseDownPosition = e.Location;
                                        eventToDragOffset = GetClientPositionForTimelineEvent(theEvent).X - e.Location.X;
                                        howToDrag         = DragNDrop.MOVE_EVENT;
                                        eventToDrag       = theEvent;
                                    }
                                }
                            }
                            #endregion
                            break;

                        case MouseButtons.Right:
                            #region TimelineEvent entfernen
                            if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
                            {
                                double time = GetTimeAtControlPosition(e.Location, false);

                                TimelineEvent eventToRemove = tl.GetEventAtTime(time);
                                tl.RemoveEvent(eventToRemove);
                            }
                            #endregion
                            break;
                        }
                    }
                }

                Invalidate();
            }
        }
コード例 #31
0
 public static int Compare(TimelineEntry a, TimelineEntry b)
 {
     return(a.TimeStamp.CompareTo(b.TimeStamp));
 }