scale change improved and now annotations can not recover any of them.
--- a/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs Fri Oct 02 18:49:07 2009 +0200
+++ b/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs Mon Oct 05 15:56:27 2009 +0200
@@ -94,7 +94,7 @@
public UserControlTimeLine()
- {
+ {
this.InitializeComponent();
// Insert code required on object creation below this point.
@@ -116,7 +116,7 @@
//AnnotList.Add(new Annotation(100 - (3 * AnnotWidth), 20, "Saut 4"));
//AnnotList.Add(new Annotation(120 - (4 * AnnotWidth), 50, "Saut 5"));
Cutting cut = new Cutting("titre de cutting", AnnotList);
- CuttingVM = new CuttingViewModel(cut);
+ CuttingVM = new CuttingViewModel(cut, AnnotWidth);
tv.DataContext = CuttingVM;
slider_ContactTapGesture(this,null);
@@ -126,7 +126,7 @@
void UserControlTimeLine_SizeChanged(object sender, SizeChangedEventArgs e)
{
// When scaleX = 1, 1 second = 1 pixel. To calculate the new scale, we take the real width in account.
- Double futurScale = this.ActualWidth / (totalmilliseconds / 1000);
+ Double futurScale = (this.ActualWidth-30) / (totalmilliseconds / 1000);
//Double futurScale = this.ActualWidth / ((totalmilliseconds<30000) ? (totalmilliseconds/10) : (totalmilliseconds / 1000)); // TEMP FOR SHORT CONTENTS
tv.RenderTransform = new ScaleTransform(futurScale,1);
//Console.WriteLine("futurScale = " + futurScale);
@@ -202,32 +202,68 @@
public void addAnnotation()
{
+ Boolean annotOk = true;
// We open a new annotation
if (CuttingVM != null && AnnotWaiting == false)
{
- AnnotTcBegin = (float)slider.Value;
- lastAnnotVM = new AnnotationViewModel(new Annotation((AnnotTcBegin / 1000) - (CuttingVM.AnnotList.Count * AnnotWidth), 0, CuttingVM.AnnotList.Count.ToString()));
- //lastAnnotVM = new AnnotationViewModel(new Annotation((AnnotTcBegin / 1000), 0, CuttingVM.AnnotList.Count.ToString()));
- //lastAnnotVM = new AnnotationViewModel(new Annotation(0, 0, CuttingVM.AnnotList.Count.ToString()));
- CuttingVM.AnnotList.Add(lastAnnotVM);
- Console.WriteLine("BEGIN currentTimecode = " + (AnnotTcBegin / 1000) + ", nb = " + CuttingVM.AnnotList.Count + ", res = " + ((AnnotTcBegin / 1000) - (CuttingVM.AnnotList.Count * AnnotWidth)));
- tv.DataContext = null;
- tv.DataContext = CuttingVM;
- AnnotWaiting = true;
+ AnnotTcBegin = (float)slider.Value / 1000;
+
+ // First we check if the new annotation will not cover any
+ foreach (Annotation a in AnnotList)
+ {
+ Console.WriteLine("a.TcBegin = " + a.TcBegin + ", AnnotTcBegin = " + AnnotTcBegin + ", tcOut = " + (a.TcBegin + a.Dur));
+ if (a.TcBegin <= AnnotTcBegin && AnnotTcBegin <= (a.TcBegin + a.Dur))
+ {
+ annotOk = false;
+ }
+ }
+ // if not, we mark the beginning
+ if (annotOk == true)
+ {
+ AnnotList.Add(new Annotation(AnnotTcBegin, 0, AnnotList.Count.ToString()));
+ //AnnotList.Add(new Annotation(AnnotTcBegin, 0, AnnotList.Count.ToString()));
+ //AnnotList.Add(new Annotation(0, 0, AnnotList.Count.ToString()));
+
+ CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth);
+ //Console.WriteLine("BEGIN currentTimecode = " + AnnotTcBegin + ", nb = " + AnnotList.Count + ", res = " + (AnnotTcBegin - (AnnotList.Count * AnnotWidth)));
+ tv.DataContext = null;
+ tv.DataContext = CuttingVM;
+ AnnotWaiting = true;
+ }
+
}
// We close the current opened annotation...
else if (CuttingVM != null && AnnotWaiting == true && ((float)slider.Value>AnnotTcBegin))
{
// ... by setting setting the good beginning and the good duration
- float currentDuration = ((float)slider.Value - AnnotTcBegin) / 1000;
- CuttingVM.AnnotList.RemoveAt(CuttingVM.AnnotList.Count - 1);
- CuttingVM.AnnotList.Add(new AnnotationViewModel(new Annotation((AnnotTcBegin / 1000) - (CuttingVM.AnnotList.Count * AnnotWidth), currentDuration, CuttingVM.AnnotList.Count.ToString())));
- //CuttingVM.AnnotList.Add(new AnnotationViewModel(new Annotation((AnnotTcBegin / 1000), currentDuration, CuttingVM.AnnotList.Count.ToString())));
- //CuttingVM.AnnotList.Add(new AnnotationViewModel(new Annotation(0, currentDuration, CuttingVM.AnnotList.Count.ToString())));
- Console.WriteLine("currentTimecode = " + (AnnotTcBegin / 1000) + ", curDur = " + currentDuration + ", nb = " + CuttingVM.AnnotList.Count + ", res = " + ((AnnotTcBegin / 1000) - (CuttingVM.AnnotList.Count * AnnotWidth)));
- tv.DataContext = null;
- tv.DataContext = CuttingVM;
- AnnotWaiting = false;
+ float currentTC = (float)slider.Value / 1000;
+ float currentDuration = currentTC - AnnotTcBegin;
+
+ // First we check if the new annotation will not cover any (AnnotTcBegin was already checked)
+ foreach (Annotation a in AnnotList)
+ {
+ Console.WriteLine("a.TcBegin = " + a.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur) + ", AnnotTcBegin = " + AnnotTcBegin + ", currentTC = " + currentTC);
+ if (a.TcBegin <= currentTC && currentTC <= (a.TcBegin + a.Dur) || (AnnotTcBegin < a.TcBegin && (a.TcBegin + a.Dur) < currentTC))
+ {
+ annotOk = false;
+ }
+ }
+
+ if (annotOk == true)
+ {
+ AnnotList.RemoveAt(AnnotList.Count - 1);
+ AnnotList.Add(new Annotation(AnnotTcBegin, currentDuration, AnnotList.Count.ToString()));
+ //AnnotList.Add(new Annotation(AnnotTcBegin - (AnnotList.Count * AnnotWidth), currentDuration, AnnotList.Count.ToString()));
+ //AnnotList.Add(new Annotation((AnnotTcBegin / 1000), currentDuration, CuttingVM.AnnotList.Count.ToString()));
+ //AnnotList.Add(new Annotation(0, currentDuration, CuttingVM.AnnotList.Count.ToString()));
+
+
+ CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth);
+ //Console.WriteLine("currentTimecode = " + AnnotTcBegin + ", curDur = " + currentDuration + ", nb = " + AnnotList.Count + ", res = " + (AnnotTcBegin - (AnnotList.Count * AnnotWidth)));
+ tv.DataContext = null;
+ tv.DataContext = CuttingVM;
+ AnnotWaiting = false;
+ }
}
}
--- a/src/FingersDance.ViewModel/AnnotationViewModel.cs Fri Oct 02 18:49:07 2009 +0200
+++ b/src/FingersDance.ViewModel/AnnotationViewModel.cs Mon Oct 05 15:56:27 2009 +0200
@@ -13,10 +13,15 @@
private float _dur;
private String _gestureType;
- public AnnotationViewModel(Annotation a) {
+ private float _marginLeft;
+
+ public AnnotationViewModel(Annotation a, float marginLeft) {
this._tcBegin = a.TcBegin;
this._dur = a.Dur;
this._gestureType = a.GestureType;
+ this._marginLeft = marginLeft;
+
+ Console.WriteLine("_tcBegin = " + _tcBegin + ", _marginLeft = " + _marginLeft);
}
public float TcBegin
@@ -51,6 +56,17 @@
base.OnPropertyChanged("GestureType");
}
}
+ public float MarginLeft
+ {
+ get { return _marginLeft; }
+ set
+ {
+ if (value == _marginLeft || float.IsNaN(value))
+ return;
+ _marginLeft = value;
+ base.OnPropertyChanged("MarginLeft");
+ }
+ }
}
}
--- a/src/FingersDance.ViewModel/CuttingViewModel.cs Fri Oct 02 18:49:07 2009 +0200
+++ b/src/FingersDance.ViewModel/CuttingViewModel.cs Mon Oct 05 15:56:27 2009 +0200
@@ -12,12 +12,16 @@
private string _title;
private List<AnnotationViewModel> _annotList = new List<AnnotationViewModel>();
- public CuttingViewModel(Cutting c) {
+ public CuttingViewModel(Cutting c, float annotWidth) {
this._title = c.Title;
this._annotList = new List<AnnotationViewModel>();
+ int i = 0;
foreach (Annotation annot in c.AnnotList)
- this._annotList.Add(new AnnotationViewModel(annot));
+ {
+ this._annotList.Add(new AnnotationViewModel(annot, annot.TcBegin - (i * annotWidth)));
+ i++;
+ }
}
@@ -41,5 +45,18 @@
base.OnPropertyChanged("AnnotList");
}
}
+
+ public void setListFromAnnotations(List<Annotation> annotList, float annotWidth)
+ {
+
+ this._annotList = new List<AnnotationViewModel>();
+ int i = 0;
+ foreach (Annotation annot in annotList)
+ {
+ this._annotList.Add(new AnnotationViewModel(annot, annot.TcBegin - (i * annotWidth)));
+ i++;
+ }
+
+ }
}
}
--- a/src/FingersDance.Views/TimelineAnnotationView.xaml Fri Oct 02 18:49:07 2009 +0200
+++ b/src/FingersDance.Views/TimelineAnnotationView.xaml Mon Oct 05 15:56:27 2009 +0200
@@ -13,7 +13,7 @@
<vw:ThicknessSingleValueConverter x:Name="myThicknessSingleValueConverter" x:Key="myThicknessSingleValueConverter"/>
<vw:VisibilityConverter x:Name="myVisibilityConverter" x:Key="myVisibilityConverter"/>
</UserControl.Resources>
- <Custom:SurfaceUserControl x:Name="LayoutRoot" Margin="{Binding Path=TcBegin, Converter={StaticResource myThicknessSingleValueConverter}}"
+ <Custom:SurfaceUserControl x:Name="LayoutRoot" Margin="{Binding Path=MarginLeft, Converter={StaticResource myThicknessSingleValueConverter}}"
>
<Grid>
<Rectangle Fill="Black" HorizontalAlignment="Left" VerticalAlignment="Top" Width="{Binding Path=Dur}" Height="40" Opacity="0.0"/>