2015-04-08 15:20:10 -07:00
|
|
|
|
using MatterHackers.Agg;
|
2014-10-05 16:07:06 -07:00
|
|
|
|
using MatterHackers.Agg.UI;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Diagnostics;
|
2014-10-05 16:07:06 -07:00
|
|
|
|
|
|
|
|
|
|
namespace MatterHackers.MatterControl
|
|
|
|
|
|
{
|
2015-04-08 15:20:10 -07:00
|
|
|
|
public class SlideWidget : GuiWidget
|
|
|
|
|
|
{
|
|
|
|
|
|
private Stopwatch timeHasBeenChanging = new Stopwatch();
|
|
|
|
|
|
|
|
|
|
|
|
public SlideWidget()
|
|
|
|
|
|
: base(0.0, 0.0)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
2014-10-05 16:07:06 -07:00
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
public override void OnDraw(Graphics2D graphics2D)
|
|
|
|
|
|
{
|
|
|
|
|
|
base.OnDraw(graphics2D);
|
|
|
|
|
|
if (this.Width != TargetWidth)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetSlidePosition();
|
|
|
|
|
|
Invalidate();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2014-10-05 16:07:06 -07:00
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
private double OriginalWidth { get; set; }
|
2014-10-05 16:07:06 -07:00
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
private double TargetWidth { get; set; }
|
2014-10-05 16:07:06 -07:00
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
public void SlideIn()
|
|
|
|
|
|
{
|
|
|
|
|
|
this.Visible = true;
|
|
|
|
|
|
if (OriginalWidth == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.OriginalWidth = this.Width;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.TargetWidth = this.OriginalWidth;
|
|
|
|
|
|
this.Width = 0.1;
|
|
|
|
|
|
timeHasBeenChanging.Restart();
|
|
|
|
|
|
SetSlidePosition();
|
|
|
|
|
|
Invalidate();
|
|
|
|
|
|
}
|
2014-10-05 16:07:06 -07:00
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
public void SlideOut()
|
|
|
|
|
|
{
|
|
|
|
|
|
this.Visible = true;
|
|
|
|
|
|
if (OriginalWidth == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.OriginalWidth = this.Width;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.TargetWidth = 0;
|
|
|
|
|
|
timeHasBeenChanging.Restart();
|
|
|
|
|
|
SetSlidePosition();
|
|
|
|
|
|
Invalidate();
|
|
|
|
|
|
}
|
2014-10-05 16:07:06 -07:00
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
private void SetSlidePosition()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (TargetWidth == 0 && this.Width == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.Visible = false;
|
|
|
|
|
|
this.Width = this.OriginalWidth;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.TargetWidth != this.Width)
|
|
|
|
|
|
{
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
double maxOffsetPerDraw = timeHasBeenChanging.ElapsedMilliseconds * 3;
|
2014-10-05 16:07:06 -07:00
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
double currentWidth = this.Width;
|
|
|
|
|
|
double delta = TargetWidth - currentWidth;
|
|
|
|
|
|
if (delta < 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
delta = Math.Max(-maxOffsetPerDraw, delta);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
delta = Math.Min(maxOffsetPerDraw, delta);
|
|
|
|
|
|
}
|
2014-10-05 16:07:06 -07:00
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
double offsetThisDraw = currentWidth + delta;
|
|
|
|
|
|
this.Width = offsetThisDraw;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|