2017-10-31 06:44:42 -07:00
|
|
|
|
/*
|
|
|
|
|
|
Copyright (c) 2017, Lars Brubaker, John Lewin
|
|
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
|
|
|
|
|
|
|
|
|
|
|
1. Redistributions of source code must retain the above copyright notice, this
|
|
|
|
|
|
list of conditions and the following disclaimer.
|
|
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
|
|
this list of conditions and the following disclaimer in the documentation
|
|
|
|
|
|
and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
|
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
|
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
|
|
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
|
|
|
|
The views and conclusions contained in the software and documentation are those
|
|
|
|
|
|
of the authors and should not be interpreted as representing official policies,
|
|
|
|
|
|
either expressed or implied, of the FreeBSD Project.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using MatterHackers.Agg;
|
|
|
|
|
|
using MatterHackers.Agg.UI;
|
|
|
|
|
|
using MatterHackers.Localizations;
|
|
|
|
|
|
using MatterHackers.MatterControl.Library;
|
2018-03-08 17:23:03 -08:00
|
|
|
|
using MatterHackers.VectorMath;
|
2017-10-31 06:44:42 -07:00
|
|
|
|
|
|
|
|
|
|
namespace MatterHackers.MatterControl
|
|
|
|
|
|
{
|
2017-12-21 10:39:17 -08:00
|
|
|
|
public class SaveAsPage : LibraryBrowserPage
|
2017-10-31 06:44:42 -07:00
|
|
|
|
{
|
2017-12-21 14:24:09 -08:00
|
|
|
|
public SaveAsPage(Action<string, ILibraryContainer> itemSaver, bool allowNameChange = true)
|
2020-05-25 09:54:50 -07:00
|
|
|
|
: base(itemSaver, "Save".Localize())
|
2017-10-31 06:44:42 -07:00
|
|
|
|
{
|
|
|
|
|
|
this.WindowTitle = "MatterControl - " + "Save As".Localize();
|
|
|
|
|
|
this.Name = "Save As Window";
|
2020-07-25 15:25:56 -07:00
|
|
|
|
this.WindowSize = new Vector2(480 *GuiWidget.DeviceScale, 500 * GuiWidget.DeviceScale);
|
2017-10-31 06:44:42 -07:00
|
|
|
|
this.HeaderText = "Save New Design".Localize() + ":";
|
|
|
|
|
|
|
|
|
|
|
|
// put in the area to type in the new name
|
2017-10-31 06:52:59 -07:00
|
|
|
|
if (allowNameChange)
|
2017-10-31 06:44:42 -07:00
|
|
|
|
{
|
2017-12-21 10:39:17 -08:00
|
|
|
|
var fileNameHeader = new TextWidget("Design Name".Localize(), pointSize: 12)
|
2017-10-31 06:44:42 -07:00
|
|
|
|
{
|
2018-11-03 09:13:07 -07:00
|
|
|
|
TextColor = theme.TextColor,
|
2017-10-31 06:44:42 -07:00
|
|
|
|
Margin = new BorderDouble(5),
|
|
|
|
|
|
HAnchor = HAnchor.Left
|
|
|
|
|
|
};
|
2018-11-03 10:12:27 -07:00
|
|
|
|
contentRow.AddChild(fileNameHeader);
|
2017-10-31 06:44:42 -07:00
|
|
|
|
|
2020-05-25 09:54:50 -07:00
|
|
|
|
// Adds text box and check box to the above container
|
2018-10-14 20:05:37 -07:00
|
|
|
|
itemNameWidget = new MHTextEditWidget("", theme, pixelWidth: 300, messageWhenEmptyAndNotSelected: "Enter a Design Name Here".Localize())
|
2017-10-31 06:44:42 -07:00
|
|
|
|
{
|
|
|
|
|
|
HAnchor = HAnchor.Stretch,
|
|
|
|
|
|
Margin = new BorderDouble(5)
|
|
|
|
|
|
};
|
2017-12-21 10:39:17 -08:00
|
|
|
|
itemNameWidget.ActualTextEditWidget.EnterPressed += (s, e) =>
|
2017-10-31 06:44:42 -07:00
|
|
|
|
{
|
2018-06-25 09:28:36 -07:00
|
|
|
|
acceptButton.InvokeClick();
|
2017-10-31 06:44:42 -07:00
|
|
|
|
};
|
2018-11-03 10:12:27 -07:00
|
|
|
|
contentRow.AddChild(itemNameWidget);
|
2017-10-31 06:44:42 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|