Inheriting from TimelineEvent

Feb 9, 2012 at 3:56 PM

I've created the following interface and update the relevant places in TimelineLibrary to work with objects that inherit from this

Makes for an easier integration with existing Data Models.

    public interface ITimelineEvent
    {
        string Id { getset; }
        string Title { getset; }
        string Description { getset; }
        DateTime StartDate { getset; }
        DateTime EndDate { getset; }
        string Link { getset; }
        bool IsDuration { getset; }
        string EventImage { getset; }
        string TeaserEventImage { getset; }
        string EventColor { getset; }
        int RowOverride { getset; }
        double WidthOverride { getset; }
        double HeightOverride { getset; }
        double TopOverride { getset; }
        object Tag { getset; }
        int Row { getset; }
        bool Selected { getset; }
        string this[string tagType] { get; }
        bool InRange(
            DateTime from,
            DateTime to
            );
 
        void AddTag(
            string tagType,
            string value
            );
 
        Dictionary<stringEventTag> EventTags { get; }
    }

Can I upload this?
Feb 9, 2012 at 6:18 PM

There was a suggestion to have this interface several times, but we still can have easy integration without it:

1) TimelineEvent class has minimal set of properties required (in most cases), to provide sufficient information about event. 

2) To extend it you can use Tag property, this is easy to attach your business object to it and reference it from your custom template line {Binding Tag.MyProperty}.

3) Yet, we cannot just live with interface, if timeline loaded from xml it needs concrete type.

While a go, I myself though of using interface, but fund that it is just replica of TimelineEvent class. 

Note: there may be though sense to have some part of TimelineEvent class methods/properties virtual (for instance if you want to implement persistence). 

Let me know.

 

 

Feb 9, 2012 at 6:59 PM
Edited Feb 10, 2012 at 9:01 AM

Ok,

Just been through the solution changing to use

List<ITimelineEvent>

instead of

List
<TimelineEvent>
and added a ToColor string extension so EventColor can be in the format #FFFFFF or #66FFFFFF

Tried all the Silverlight Examples, they all worked perfectly.


To now use in my projects (lots of historical data, lots of visualizations,
 playback through historical data)

My classes now inherit from TimelineEvent (as opposed to mvvmLights ViewModelBase)

load my data up as usual, couple of new properties to set (EventColor only really)
Timeline.ResetEvents(HistoricalData) once data loaded

That is it, nothing else to do, works so well.

Very simple, and what an impressive control

Quick questions as haven't really gone into the code in anymore detail than this;
1) DataContext - does this work?
2) clicking an event in any band - can it scroll to this event?
3) Is there a property (DateTime) that I can set so it scrolls to this time

Apologies if answers already available, but as I said, just been playing around,
 and not enough hours in the day to investigate :)


Can I zip and send you the solution so you can have a look at the changes
that have extended this so well for me
Feb 10, 2012 at 7:37 PM

I'd still recommend to use tag property. Making timeline events binding friendly (like using Observable collection and 2-way binding, would be a good thing, but I do not have time for it right now. My idea is to make control, actually control set, nuget friendly and prepare for parallel development in sl - winrt - winphone, yet, wish I have time to integrate and create sample which uses charts, map, and graphs together with timeline (kind-of started it, but not yet there).

As to your questions:

1) DataContext is not working (see above)

2) Clicking event is not scrolling to it (but could be done with CurrentDateTime property of Timeline)

3) CurrentDateTime