Skip to content

Commit

Permalink
Merge pull request #90 from hcmlab/develop
Browse files Browse the repository at this point in the history
complete undo/redo added
  • Loading branch information
tobiasbaur authored Nov 30, 2016
2 parents 7978695 + 29994e3 commit debcbba
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 105 deletions.
2 changes: 1 addition & 1 deletion app/Window1.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:view="clr-namespace:ssi;assembly=ssiview"
xmlns:local="clr-namespace:ssi"
Title="(NOn)Verbal Annotator | v0.9.9.2.6 | HCM-Lab, Augsburg University | http://openssi.net" WindowState="Maximized" Height="Auto" Width="Auto" AllowDrop="True" AllowsTransparency="False" Icon="ui.ico">
Title="(NOn)Verbal Annotator | v0.9.9.2.7 | HCM-Lab, Augsburg University | http://openssi.net" WindowState="Maximized" Height="Auto" Width="Auto" AllowDrop="True" AllowsTransparency="False" Icon="ui.ico">

<Grid>

Expand Down
2 changes: 1 addition & 1 deletion app_metro/Window1.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:view="clr-namespace:ssi;assembly=ssiview"
xmlns:local="clr-namespace:ssi"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
Title="(NOn)Verbal Annotator | v0.9.9.2.6| HCM-Lab, Augsburg University | http://openssi.net" WindowState="Maximized" Height="Auto" Width="Auto" AllowDrop="True" AllowsTransparency="False" Icon="ui.ico">
Title="(NOn)Verbal Annotator | v0.9.9.2.7| HCM-Lab, Augsburg University | http://openssi.net" WindowState="Maximized" Height="Auto" Width="Auto" AllowDrop="True" AllowsTransparency="False" Icon="ui.ico">

<Grid>

Expand Down
Binary file modified bin/nova.exe
Binary file not shown.
Binary file modified bin/nova_metro.exe
Binary file not shown.
22 changes: 10 additions & 12 deletions dll/AnnoTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -891,13 +891,14 @@ public void mouseMove(MouseEventArgs e)
if (selected_segment.is_resizeable_right)
{
double delta = point.X - selected_segment.ActualWidth;
double pos = GetLeft(selected_segment);

if (isMouseAlreadydown == false)
{
// Console.WriteLine("ResizeRight");
//TODO: Logic for Redo
isMouseAlreadydown = true;

ChangeRepresentationObject ChangeRepresentationObjectOfResize = UnDoObject.MakeChangeRepresentationObjectForResize(pos, (FrameworkElement)selected_segment);
UnDoObject.InsertObjectforUndoRedo(ChangeRepresentationObjectOfResize);
isMouseAlreadydown = true;
}


Expand All @@ -920,12 +921,11 @@ public void mouseMove(MouseEventArgs e)
// resize segment left
else if (selected_segment.is_resizeable_left)
{

double pos = GetLeft(selected_segment);
if (isMouseAlreadydown == false)
{
//TODO: Logic for Redo
// Console.WriteLine("ResizeLeft");

ChangeRepresentationObject ChangeRepresentationObjectOfResize = UnDoObject.MakeChangeRepresentationObjectForResize(pos, (FrameworkElement)selected_segment);
UnDoObject.InsertObjectforUndoRedo(ChangeRepresentationObjectOfResize);
isMouseAlreadydown = true;

}
Expand Down Expand Up @@ -955,12 +955,10 @@ public void mouseMove(MouseEventArgs e)
{
if (isMouseAlreadydown == false)
{
// Console.WriteLine("Move");
//TODO: Logic for Redo
// _PreviouMargin = new Point(Canvas.GetLeft(selected_segment),0);


// ChangeRepresentationObject ChangeRepresentationObjectOfMove = UnDoObject.MakeChangeRepresentationObjectForMove(_PreviouMargin, (FrameworkElement)selected_segment, selected_segment.Width, selected_segment.Item.Duration);
//UnDoObject.InsertObjectforUndoRedo(ChangeRepresentationObjectOfMove);
ChangeRepresentationObject ChangeRepresentationObjectOfMove = UnDoObject.MakeChangeRepresentationObjectForMove(pos, (FrameworkElement)selected_segment);
UnDoObject.InsertObjectforUndoRedo(ChangeRepresentationObjectOfMove);
isMouseAlreadydown = true;

}
Expand Down
149 changes: 58 additions & 91 deletions dll/UndoRedo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,57 +52,27 @@ public void Undo(int level)
((AnnoTrack)Container).deleteSegment((AnnoTrackSegment)Undostruct.UiElement);
this.RedoPushInUnDoForInsert(Undostruct.UiElement);
}
//else if (Undostruct.Action == ActionType.Resize)
//{
// if (_UndoActionsCollection.Count != 0)
// {
// Point previousMarginOfSelectedObject = new Point(((FrameworkElement)Undostruct.UiElement).Margin.Left, ((FrameworkElement)Undostruct.UiElement).Margin.Top);
// this.RedoPushInUnDoForResize(previousMarginOfSelectedObject, Undostruct.UiElement.Width, Undostruct.UiElement.Height, Undostruct.UiElement);
// Undostruct.UiElement.Margin = new Thickness(Undostruct.Margin.X, Undostruct.Margin.Y, 0, 0);
// Undostruct.UiElement.Height = Undostruct.height;
// Undostruct.UiElement.Width = Undostruct.Width;

// if(Undostruct.isresizeright)
// {
// ((AnnoTrackSegment)Undostruct.UiElement).resize_right(Undostruct.Margin.X - Undostruct.Width);
// }

// if (Undostruct.isresizeleft)
// {
// ((AnnoTrackSegment)Undostruct.UiElement).resize_left(Undostruct.Margin.X + Undostruct.Width);
// }

// if (Undostruct.ismoved)
// {
// ((AnnoTrackSegment)Undostruct.UiElement).move(Undostruct.Margin.X + Undostruct.Width);
// }

// }
//}
//else if (Undostruct.Action == ActionType.Move)
//{

// AnnoListItem ali = ((AnnoTrackSegment)Undostruct.UiElement).Item;
// ((AnnoTrack)Container).deleteSegment((AnnoTrackSegment)Undostruct.UiElement);
// ((AnnoTrack)Container).AnnoList.AddSorted(ali);
// AnnoTrackSegment at = ((AnnoTrack)Container).addSegment(ali);


// Point previousMarginOfSelectedObject = new Point(((FrameworkElement)Undostruct.UiElement).Margin.Left, ((FrameworkElement)Undostruct.UiElement).Margin.Top);
// this.RedoPushInUnDoForMove(previousMarginOfSelectedObject, Undostruct.UiElement);

//}
else if (Undostruct.Action == ActionType.Resize)
{
this.RedoPushInUnDoForResize(Canvas.GetLeft(Undostruct.UiElement), Undostruct.UiElement);
Canvas.SetLeft(Undostruct.UiElement, Undostruct.Margin.X);
Undostruct.UiElement.Width = Undostruct.Width;
((AnnoTrackSegment)Undostruct.UiElement).Item.Duration = Undostruct.Duration;
((AnnoTrackSegment)Undostruct.UiElement).Item.Start = Undostruct.Start;
((AnnoTrackSegment)Undostruct.UiElement).Item.Stop = Undostruct.Stop;


}

else if (Undostruct.Action == ActionType.Move)
{

Point previousMarginOfSelectedObject = new Point((Canvas.GetLeft((FrameworkElement)Undostruct.UiElement)), 0);
Canvas.SetLeft(Undostruct.UiElement,Undostruct.Margin.X);
this.RedoPushInUnDoForMove(Canvas.GetLeft(Undostruct.UiElement), Undostruct.UiElement);
Canvas.SetLeft(Undostruct.UiElement,Undostruct.Margin.X);
Undostruct.UiElement.Width = Undostruct.Width;


// ((AnnoTrackSegment)Undostruct.UiElement).Item.Duration = Undostruct.Duration;
this.RedoPushInUnDoForMove(previousMarginOfSelectedObject, Undostruct.UiElement, Undostruct.Width, Undostruct.Duration);
((AnnoTrackSegment)Undostruct.UiElement).Item.Duration = Undostruct.Duration;
((AnnoTrackSegment)Undostruct.UiElement).Item.Start = Undostruct.Start;
((AnnoTrackSegment)Undostruct.UiElement).Item.Stop = Undostruct.Stop;

}
}

Expand Down Expand Up @@ -135,37 +105,28 @@ public void Redo(int level)
ChangeRepresentationObject ChangeRepresentationObjectForInsert = this.MakeChangeRepresentationObjectForInsert(at);
_UndoActionsCollection.Push(ChangeRepresentationObjectForInsert);
}
//else if (Undostruct.Action == ActionType.Resize)
//{
// Point previousMarginOfSelectedObject = new Point(((FrameworkElement)Undostruct.UiElement).Margin.Left, ((FrameworkElement)Undostruct.UiElement).Margin.Top);
// ChangeRepresentationObject ChangeRepresentationObjectforResize = this.MakeChangeRepresentationObjectForResize(previousMarginOfSelectedObject, Undostruct.UiElement.Width, Undostruct.UiElement.Height, Undostruct.UiElement,false,false,false);
// _UndoActionsCollection.Push(ChangeRepresentationObjectforResize);
else if (Undostruct.Action == ActionType.Resize)
{
Canvas.SetLeft(Undostruct.UiElement, Undostruct.Margin.X);
Undostruct.UiElement.Width = Undostruct.Width;
Undostruct.Start = ((AnnoTrackSegment)Undostruct.UiElement).Item.Start;
Undostruct.Stop = ((AnnoTrackSegment)Undostruct.UiElement).Item.Stop;
Undostruct.Duration = ((AnnoTrackSegment)Undostruct.UiElement).Item.Duration;

// Undostruct.UiElement.Margin = new Thickness(Undostruct.Margin.X, Undostruct.Margin.Y, 0, 0);
// Undostruct.UiElement.Height = Undostruct.height;
// Undostruct.UiElement.Width = Undostruct.Width;
ChangeRepresentationObject ChangeRepresentationObjectForResize = this.MakeChangeRepresentationObjectForResize(Undostruct.Margin.X, Undostruct.UiElement);
_UndoActionsCollection.Push(ChangeRepresentationObjectForResize);

//}
}
else if (Undostruct.Action == ActionType.Move)
{

Point previousMarginOfSelectedObject = new Point((Canvas.GetLeft((FrameworkElement)Undostruct.UiElement)), 0);



Canvas.SetLeft(Undostruct.UiElement, Undostruct.Margin.X);
Undostruct.UiElement.Width = Undostruct.Width;
// ((AnnoTrackSegment)Undostruct.UiElement).Item.Duration = Undostruct.Duration;

Undostruct.Start = ((AnnoTrackSegment)Undostruct.UiElement).Item.Start;
Undostruct.Stop = ((AnnoTrackSegment)Undostruct.UiElement).Item.Stop;
Undostruct.Duration = ((AnnoTrackSegment)Undostruct.UiElement).Item.Duration;

AnnoListItem ali = ((AnnoTrackSegment)Undostruct.UiElement).Item;
((AnnoTrack)Container).deleteSegment((AnnoTrackSegment)Undostruct.UiElement);
((AnnoTrack)Container).AnnoList.AddSorted(ali);
AnnoTrackSegment at = ((AnnoTrack)Container).addSegment(ali);



ChangeRepresentationObject ChangeRepresentationObjectForMove = this.MakeChangeRepresentationObjectForMove(previousMarginOfSelectedObject, Undostruct.UiElement, Undostruct.Width, Undostruct.Duration);
ChangeRepresentationObject ChangeRepresentationObjectForMove = this.MakeChangeRepresentationObjectForMove(Undostruct.Margin.X, Undostruct.UiElement);
_UndoActionsCollection.Push(ChangeRepresentationObjectForMove);
}
}
Expand Down Expand Up @@ -205,27 +166,28 @@ public ChangeRepresentationObject MakeChangeRepresentationObjectForDelete(Framew
return dataobject;
}

public ChangeRepresentationObject MakeChangeRepresentationObjectForMove(Point margin, FrameworkElement UIelement, double Width, double duration)
public ChangeRepresentationObject MakeChangeRepresentationObjectForMove(double pos, FrameworkElement UIelement)
{
ChangeRepresentationObject MoveStruct = new ChangeRepresentationObject();
MoveStruct.Action = ActionType.Move;
MoveStruct.Margin = margin;
MoveStruct.Width = Width;
MoveStruct.Duration = duration;
MoveStruct.Margin.X = pos;
MoveStruct.Width = UIelement.Width;
MoveStruct.Start = ((AnnoTrackSegment)UIelement).Item.Start;
MoveStruct.Stop = ((AnnoTrackSegment)UIelement).Item.Stop;
MoveStruct.Duration = ((AnnoTrackSegment) UIelement).Item.Duration;
MoveStruct.UiElement = UIelement;
return MoveStruct;
}

public ChangeRepresentationObject MakeChangeRepresentationObjectForResize(Point margin, double width, double height, FrameworkElement UIelement, bool isresizeright, bool isresizeleft, bool ismoved)
public ChangeRepresentationObject MakeChangeRepresentationObjectForResize(double pos, FrameworkElement UIelement)
{
ChangeRepresentationObject ResizeStruct = new ChangeRepresentationObject();
ResizeStruct.Action = ActionType.Resize;
ResizeStruct.Margin = margin;
ResizeStruct.Width = width;
ResizeStruct.isresizeright = isresizeright;
ResizeStruct.isresizeleft = isresizeleft;
ResizeStruct.ismoved = ismoved;

ResizeStruct.Margin.X = pos;
ResizeStruct.Width = UIelement.Width;
ResizeStruct.Start = ((AnnoTrackSegment)UIelement).Item.Start;
ResizeStruct.Stop = ((AnnoTrackSegment)UIelement).Item.Stop;
ResizeStruct.Duration = ((AnnoTrackSegment)UIelement).Item.Duration;
ResizeStruct.UiElement = UIelement;
return ResizeStruct;
}
Expand Down Expand Up @@ -255,23 +217,29 @@ public void RedoPushInUnDoForDelete(FrameworkElement ApbOrDevice)
_RedoActionsCollection.Push(dataobject);
}

public void RedoPushInUnDoForMove(Point margin, FrameworkElement UIelement, double Width, double Duration)
public void RedoPushInUnDoForMove(double pos, FrameworkElement UIelement)
{
ChangeRepresentationObject MoveStruct = new ChangeRepresentationObject();
MoveStruct.Action = ActionType.Move;
MoveStruct.Margin = margin;
MoveStruct.Width = Width;
MoveStruct.Margin.X = pos;
MoveStruct.Width = UIelement.Width;
MoveStruct.Start = ((AnnoTrackSegment)UIelement).Item.Start;
MoveStruct.Stop = ((AnnoTrackSegment)UIelement).Item.Stop;
MoveStruct.Duration = ((AnnoTrackSegment)UIelement).Item.Duration;
MoveStruct.UiElement = UIelement;
_RedoActionsCollection.Push(MoveStruct);
}

public void RedoPushInUnDoForResize(Point margin, double width, double height, FrameworkElement UIelement, double Width)
public void RedoPushInUnDoForResize(double pos, FrameworkElement UIelement)
{
ChangeRepresentationObject ResizeStruct = new ChangeRepresentationObject();
ResizeStruct.Margin = margin;
ResizeStruct.Width = Width;
ResizeStruct.UiElement = UIelement;
ResizeStruct.Action = ActionType.Resize;
ResizeStruct.Margin.X = pos;
ResizeStruct.Width = UIelement.Width;
ResizeStruct.Start = ((AnnoTrackSegment)UIelement).Item.Start;
ResizeStruct.Stop = ((AnnoTrackSegment)UIelement).Item.Stop;
ResizeStruct.Duration = ((AnnoTrackSegment)UIelement).Item.Duration;
ResizeStruct.UiElement = UIelement;
_RedoActionsCollection.Push(ResizeStruct);
}

Expand Down Expand Up @@ -321,11 +289,10 @@ public enum ActionType
public class ChangeRepresentationObject
{
public ActionType Action;
public bool isresizeright;
public bool isresizeleft;
public bool ismoved;
public Point Margin;
public double Width;
public double Start;
public double Stop;
public double Duration;
public FrameworkElement UiElement;
}
Expand Down

0 comments on commit debcbba

Please sign in to comment.