Work on the ActionBar UI
Changed behavior of 'Skip' button.
This commit is contained in:
parent
f41f136f19
commit
95b2efb48c
5 changed files with 160 additions and 73 deletions
|
|
@ -21,7 +21,7 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
public ActionBarPlus()
|
||||
: base(FlowDirection.TopToBottom)
|
||||
{
|
||||
{
|
||||
this.Create();
|
||||
}
|
||||
|
||||
|
|
@ -42,8 +42,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
// Add Child Elements
|
||||
this.AddChild(new ActionBar.PrinterActionRow());
|
||||
this.AddChild(new PrintStatusRow());
|
||||
this.AddChild(new MessageActionRow());
|
||||
this.AddChild(new PrintStatusRow());
|
||||
|
||||
// Add Handlers
|
||||
ActiveTheme.Instance.ThemeChanged.RegisterEvent(onThemeChanged, ref unregisterEvents);
|
||||
|
|
@ -74,7 +73,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
protected override void Initialize()
|
||||
{
|
||||
this.Margin = new BorderDouble(6, 6);
|
||||
this.Margin = new BorderDouble(0,3,0,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -51,8 +51,8 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
}
|
||||
|
||||
protected override void AddChildElements()
|
||||
{
|
||||
addButton = (TooltipButton)textImageButtonFactory.GenerateTooltipButton(new LocalizedString("Add").Translated, "icon_circle_plus.png");
|
||||
{
|
||||
addButton = (TooltipButton)textImageButtonFactory.GenerateTooltipButton(new LocalizedString("Add").Translated, "icon_circle_plus.png");
|
||||
addButton.tooltipText = new LocalizedString("Add a file to be printed").Translated;
|
||||
addButton.Margin = new BorderDouble(0, 6, 6, 3);
|
||||
|
||||
|
|
@ -250,7 +250,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
{
|
||||
if (PrintQueueControl.Instance.Count > 1)
|
||||
{
|
||||
PrintQueueControl.Instance.MoveSelectedToBottom();
|
||||
PrintQueueControl.Instance.MoveToNext();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
}
|
||||
|
||||
override protected void AddChildElements()
|
||||
{
|
||||
{
|
||||
activePrintPreviewImage = new PartThumbnailWidget(null, "part_icon_transparent_100x100.png", "building_thumbnail_100x100.png", new Vector2(115, 115));
|
||||
activePrintPreviewImage.VAnchor = VAnchor.ParentTop;
|
||||
activePrintPreviewImage.Padding = new BorderDouble(0);
|
||||
|
|
@ -136,8 +136,9 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
container.AddChild(topRow);
|
||||
container.AddChild(activePrintName);
|
||||
container.AddChild(activePrintStatus);
|
||||
container.AddChild(activePrintInfo);
|
||||
//container.AddChild(activePrintInfo);
|
||||
container.AddChild(printActionRow);
|
||||
container.AddChild(new MessageActionRow());
|
||||
|
||||
return container;
|
||||
}
|
||||
|
|
@ -197,62 +198,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
{
|
||||
if (PrinterCommunication.Instance.ActivePrintItem != null)
|
||||
{
|
||||
int secondsPrinted = PrinterCommunication.Instance.SecondsPrinted;
|
||||
int hoursPrinted = (int)(secondsPrinted / (60 * 60));
|
||||
int minutesPrinted = (int)(secondsPrinted / 60 - hoursPrinted * 60);
|
||||
secondsPrinted = secondsPrinted % 60;
|
||||
string timePrintedText;
|
||||
if (hoursPrinted > 0)
|
||||
{
|
||||
timePrintedText = string.Format("Print Time: {0}:{1:00}:{2:00}",
|
||||
hoursPrinted,
|
||||
minutesPrinted,
|
||||
secondsPrinted);
|
||||
}
|
||||
else
|
||||
{
|
||||
timePrintedText = string.Format("Print Time: {0:00}:{1:00}",
|
||||
minutesPrinted,
|
||||
secondsPrinted);
|
||||
}
|
||||
|
||||
int secondsRemaining = PrinterCommunication.Instance.SecondsRemaining;
|
||||
int hoursRemaining = (int)(secondsRemaining / (60 * 60));
|
||||
int minutesRemaining = (int)(secondsRemaining / 60 - hoursRemaining * 60);
|
||||
secondsRemaining = secondsRemaining % 60;
|
||||
string timeRemainingText;
|
||||
if (secondsRemaining > 0)
|
||||
{
|
||||
if (hoursRemaining > 0)
|
||||
{
|
||||
timeRemainingText = string.Format("Remaining (est): {0}:{1:00}:{2:00}",
|
||||
hoursRemaining,
|
||||
minutesRemaining,
|
||||
secondsRemaining);
|
||||
}
|
||||
else
|
||||
{
|
||||
timeRemainingText = string.Format("Remaining (est): {0:00}:{1:00}",
|
||||
minutesRemaining,
|
||||
secondsRemaining);
|
||||
}
|
||||
}
|
||||
else if (PrinterCommunication.Instance.PrintIsFinished)
|
||||
{
|
||||
timeRemainingText = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
timeRemainingText = string.Format("Remaining (est): --:--",
|
||||
secondsPrinted / 60,
|
||||
secondsPrinted % 60);
|
||||
}
|
||||
|
||||
string printTimeInfoText = timePrintedText;
|
||||
if (timeRemainingText != "")
|
||||
{
|
||||
printTimeInfoText += ", " + timeRemainingText;
|
||||
}
|
||||
|
||||
//GC.WaitForFullGCComplete();
|
||||
|
||||
string printPercentRemainingText;
|
||||
|
|
@ -270,7 +216,6 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
{
|
||||
activePrintLabel.Text = PrinterCommunication.Instance.PrintingStateString;
|
||||
ActivePrintStatusText = printPercentRemainingText;
|
||||
activePrintInfo.Text = printTimeInfoText;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -278,14 +223,12 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
{
|
||||
activePrintLabel.Text = "Printing Paused:";
|
||||
ActivePrintStatusText = printPercentRemainingText;
|
||||
activePrintInfo.Text = printTimeInfoText;
|
||||
}
|
||||
break;
|
||||
|
||||
case PrinterCommunication.CommunicationStates.FinishedPrint:
|
||||
activePrintLabel.Text = "Done Printing:";
|
||||
ActivePrintStatusText = printPercentRemainingText;
|
||||
activePrintInfo.Text = printTimeInfoText;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -13,22 +13,55 @@ namespace MatterHackers.MatterControl
|
|||
public class PrintProgressBar : GuiWidget
|
||||
{
|
||||
double currentPercent = 0;
|
||||
Stopwatch timeSinceLastUpdate = new Stopwatch();
|
||||
RGBA_Bytes completeColor = new RGBA_Bytes(255, 255, 255);
|
||||
TextWidget printTimeRemaining;
|
||||
TextWidget printTimeElapsed;
|
||||
|
||||
|
||||
public PrintProgressBar()
|
||||
{
|
||||
MinimumSize = new Vector2(0, 10);
|
||||
MinimumSize = new Vector2(0, 30);
|
||||
HAnchor = HAnchor.ParentLeftRight;
|
||||
BackgroundColor = ActiveTheme.Instance.SecondaryAccentColor;
|
||||
Margin = new BorderDouble(0);
|
||||
|
||||
FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.LeftToRight);
|
||||
container.AnchorAll();
|
||||
container.Padding = new BorderDouble(7,0);
|
||||
|
||||
RGBA_Bytes labelColor = ActiveTheme.Instance.PrimaryAccentColor;
|
||||
//labelColor.alpha = 220;
|
||||
|
||||
printTimeElapsed = new TextWidget("2:30:00");
|
||||
printTimeElapsed.VAnchor = Agg.UI.VAnchor.ParentCenter;
|
||||
printTimeElapsed.TextColor = labelColor;
|
||||
|
||||
|
||||
printTimeRemaining = new TextWidget("4:50:30");
|
||||
printTimeRemaining.VAnchor = Agg.UI.VAnchor.ParentCenter;
|
||||
printTimeRemaining.TextColor = labelColor;
|
||||
|
||||
GuiWidget spacer = new GuiWidget();
|
||||
spacer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
|
||||
|
||||
container.AddChild(printTimeElapsed);
|
||||
container.AddChild(spacer);
|
||||
container.AddChild(printTimeRemaining);
|
||||
|
||||
AddChild(container);
|
||||
AddHandlers();
|
||||
UpdatePrintStatus();
|
||||
UiThread.RunOnIdle(OnIdle);
|
||||
}
|
||||
|
||||
|
||||
event EventHandler unregisterEvents;
|
||||
void AddHandlers()
|
||||
{
|
||||
PrinterCommunication.Instance.WroteLine.RegisterEvent(Instance_WroteLine, ref unregisterEvents);
|
||||
PrinterCommunication.Instance.ActivePrintItemChanged.RegisterEvent(Instance_PrintItemChanged, ref unregisterEvents);
|
||||
PrinterCommunication.Instance.ConnectionStateChanged.RegisterEvent(Instance_PrintItemChanged, ref unregisterEvents);
|
||||
ActiveTheme.Instance.ThemeChanged.RegisterEvent(onThemeChanged, ref unregisterEvents);
|
||||
}
|
||||
|
||||
|
|
@ -44,11 +77,18 @@ namespace MatterHackers.MatterControl
|
|||
private void onThemeChanged(object sender, EventArgs e)
|
||||
{
|
||||
//Set background color to new theme
|
||||
this.printTimeElapsed.TextColor = ActiveTheme.Instance.PrimaryAccentColor;
|
||||
this.printTimeRemaining.TextColor = ActiveTheme.Instance.PrimaryAccentColor;
|
||||
this.BackgroundColor = ActiveTheme.Instance.SecondaryAccentColor;
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
Stopwatch timeSinceLastUpdate = new Stopwatch();
|
||||
|
||||
void Instance_PrintItemChanged(object sender, EventArgs e)
|
||||
{
|
||||
UpdatePrintStatus();
|
||||
}
|
||||
|
||||
void Instance_WroteLine(object sender, EventArgs e)
|
||||
{
|
||||
if (!timeSinceLastUpdate.IsRunning)
|
||||
|
|
@ -56,17 +96,106 @@ namespace MatterHackers.MatterControl
|
|||
timeSinceLastUpdate.Start();
|
||||
}
|
||||
|
||||
if (timeSinceLastUpdate.ElapsedMilliseconds > 5000)
|
||||
if (timeSinceLastUpdate.ElapsedMilliseconds > 999)
|
||||
{
|
||||
timeSinceLastUpdate.Restart();
|
||||
currentPercent = PrinterCommunication.Instance.PercentComplete;
|
||||
UpdatePrintStatus();
|
||||
this.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDraw(Graphics2D graphics2D)
|
||||
void OnIdle(object state)
|
||||
{
|
||||
if (!timeSinceLastUpdate.IsRunning)
|
||||
{
|
||||
timeSinceLastUpdate.Start();
|
||||
}
|
||||
|
||||
if (timeSinceLastUpdate.ElapsedMilliseconds > 999)
|
||||
{
|
||||
timeSinceLastUpdate.Restart();
|
||||
currentPercent = PrinterCommunication.Instance.PercentComplete;
|
||||
UpdatePrintStatus();
|
||||
|
||||
}
|
||||
UiThread.RunOnIdle(OnIdle);
|
||||
}
|
||||
|
||||
private void UpdatePrintStatus()
|
||||
{
|
||||
if (PrinterCommunication.Instance.ActivePrintItem == null)
|
||||
{
|
||||
printTimeElapsed.Text = string.Format("");
|
||||
printTimeRemaining.Text = string.Format("");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
int secondsPrinted = PrinterCommunication.Instance.SecondsPrinted;
|
||||
int hoursPrinted = (int)(secondsPrinted / (60 * 60));
|
||||
int minutesPrinted = (int)(secondsPrinted / 60 - hoursPrinted * 60);
|
||||
secondsPrinted = secondsPrinted % 60;
|
||||
|
||||
if (secondsPrinted > 0)
|
||||
{
|
||||
if (hoursPrinted > 0)
|
||||
{
|
||||
printTimeElapsed.Text = string.Format("{0}:{1:00}:{2:00}",
|
||||
hoursPrinted,
|
||||
minutesPrinted,
|
||||
secondsPrinted);
|
||||
}
|
||||
else
|
||||
{
|
||||
printTimeElapsed.Text = string.Format("{0}:{1:00}",
|
||||
minutesPrinted,
|
||||
secondsPrinted);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printTimeElapsed.Text = string.Format("");
|
||||
}
|
||||
|
||||
int secondsRemaining = PrinterCommunication.Instance.SecondsRemaining;
|
||||
int hoursRemaining = (int)(secondsRemaining / (60 * 60));
|
||||
int minutesRemaining = (int)(secondsRemaining / 60 - hoursRemaining * 60);
|
||||
secondsRemaining = secondsRemaining % 60;
|
||||
|
||||
if (secondsRemaining > 0)
|
||||
{
|
||||
if (hoursRemaining > 0)
|
||||
{
|
||||
printTimeRemaining.Text = string.Format("{0}:{1:00}:{2:00}",
|
||||
hoursRemaining,
|
||||
minutesRemaining,
|
||||
secondsRemaining);
|
||||
}
|
||||
else
|
||||
{
|
||||
printTimeRemaining.Text = string.Format("{0}:{1:00}",
|
||||
minutesRemaining,
|
||||
secondsRemaining);
|
||||
}
|
||||
}
|
||||
else if (PrinterCommunication.Instance.PrintIsFinished)
|
||||
{
|
||||
printTimeRemaining.Text = "Done!";
|
||||
}
|
||||
else
|
||||
{
|
||||
printTimeRemaining.Text = string.Format("");
|
||||
}
|
||||
}
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
public override void OnDraw(Graphics2D graphics2D)
|
||||
{
|
||||
graphics2D.FillRectangle(0, 0, Width * currentPercent / 100, Height, completeColor);
|
||||
base.OnDraw(graphics2D);
|
||||
graphics2D.FillRectangle(0, 0, Width * currentPercent / 100, Height, completeColor);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,6 +108,22 @@ namespace MatterHackers.MatterControl.PrintQueue
|
|||
}
|
||||
}
|
||||
|
||||
public void MoveToNext()
|
||||
{
|
||||
if (SelectedIndex >= 0 && SelectedIndex < Count)
|
||||
{
|
||||
if (this.SelectedIndex == Count - 1)
|
||||
{
|
||||
this.SelectedIndex = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.SelectedIndex++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveSelectedToBottom()
|
||||
{
|
||||
if (SelectedIndex >= 0 && SelectedIndex < Count)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue