2014-01-29 19:09:30 -08:00
|
|
|
|
/*
|
2019-05-11 14:45:41 -07:00
|
|
|
|
Copyright (c) 2019, John Lewin
|
2017-05-26 11:23:41 -07:00
|
|
|
|
|
2014-01-29 19:09:30 -08:00
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
2015-04-08 15:20:10 -07:00
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
|
|
|
|
|
1. Redistributions of source code must retain the above copyright notice, this
|
2015-04-08 15:20:10 -07:00
|
|
|
|
list of conditions and the following disclaimer.
|
2014-01-29 19:09:30 -08:00
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
|
|
this list of conditions and the following disclaimer in the documentation
|
2015-04-08 15:20:10 -07:00
|
|
|
|
and/or other materials provided with the distribution.
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
|
|
|
|
|
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
|
2015-04-08 15:20:10 -07:00
|
|
|
|
of the authors and should not be interpreted as representing official policies,
|
2014-01-29 19:09:30 -08:00
|
|
|
|
either expressed or implied, of the FreeBSD Project.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
2017-05-31 12:42:44 -07:00
|
|
|
|
using System.Collections.Generic;
|
2019-06-17 12:12:41 -07:00
|
|
|
|
using System.Linq;
|
2019-06-12 17:15:19 -07:00
|
|
|
|
using MatterHackers.Agg.Image;
|
2017-12-19 16:57:59 -08:00
|
|
|
|
using MatterHackers.DataConverters3D;
|
2018-11-11 08:42:13 -08:00
|
|
|
|
using MatterHackers.MatterControl;
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
2017-05-26 11:23:41 -07:00
|
|
|
|
namespace MatterHackers.Agg.UI
|
2014-01-29 19:09:30 -08:00
|
|
|
|
{
|
2019-06-12 17:15:19 -07:00
|
|
|
|
public class SceneSelectionOperation
|
2017-12-04 10:35:24 -08:00
|
|
|
|
{
|
2019-02-01 16:12:12 -08:00
|
|
|
|
public Action<ISceneContext> Action { get; set; }
|
2019-05-11 14:45:41 -07:00
|
|
|
|
|
2020-05-30 08:59:32 -07:00
|
|
|
|
public Func<bool, ImageBuffer> Icon { get; set; }
|
2019-05-11 14:45:41 -07:00
|
|
|
|
|
2020-06-26 08:07:53 -07:00
|
|
|
|
public Func<ISceneContext, bool> IsEnabled { get; set; } = (sceneContext) => true;
|
2017-09-18 17:57:06 -07:00
|
|
|
|
|
2020-05-30 08:59:32 -07:00
|
|
|
|
public Func<string> HelpTextResolver { get; set; }
|
2019-06-12 17:15:19 -07:00
|
|
|
|
|
2020-05-30 08:59:32 -07:00
|
|
|
|
public string HelpText => this.HelpTextResolver?.Invoke();
|
2019-06-13 08:16:50 -07:00
|
|
|
|
|
2020-06-26 08:07:53 -07:00
|
|
|
|
public Func<string> TitleResolver { get; set; }
|
|
|
|
|
|
|
2020-05-30 08:59:32 -07:00
|
|
|
|
public string Title => this.TitleResolver?.Invoke();
|
2019-06-13 08:16:50 -07:00
|
|
|
|
|
2020-05-30 08:59:32 -07:00
|
|
|
|
public Type OperationType { get; set; }
|
2018-01-10 11:38:28 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-06-12 17:15:19 -07:00
|
|
|
|
public class SceneSelectionSeparator : SceneSelectionOperation
|
2017-05-31 12:42:44 -07:00
|
|
|
|
{
|
|
|
|
|
|
}
|
2019-06-13 08:16:50 -07:00
|
|
|
|
|
|
|
|
|
|
public class OperationGroup : SceneSelectionOperation
|
|
|
|
|
|
{
|
2019-06-13 08:28:09 -07:00
|
|
|
|
public OperationGroup(string groupName)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.GroupName = groupName;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-06-13 08:16:50 -07:00
|
|
|
|
public List<SceneSelectionOperation> Operations { get; set; } = new List<SceneSelectionOperation>();
|
|
|
|
|
|
|
|
|
|
|
|
public bool StickySelection { get; internal set; }
|
|
|
|
|
|
|
2019-06-13 08:28:09 -07:00
|
|
|
|
public string GroupName { get; }
|
2019-06-13 08:16:50 -07:00
|
|
|
|
|
2019-06-17 12:09:18 -07:00
|
|
|
|
public string GroupRecordId => $"ActiveButton_{this.GroupName}_Group";
|
|
|
|
|
|
|
2019-06-20 13:29:58 -07:00
|
|
|
|
public bool Collapse { get; set; }
|
|
|
|
|
|
|
2019-06-17 12:09:18 -07:00
|
|
|
|
public SceneSelectionOperation GetDefaultOperation()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.StickySelection)
|
|
|
|
|
|
{
|
|
|
|
|
|
int.TryParse(UserSettings.Instance.get(GroupRecordId), out int activeButtonID);
|
|
|
|
|
|
|
|
|
|
|
|
activeButtonID = agg_basics.Clamp(activeButtonID, 0, this.Operations.Count - 1);
|
|
|
|
|
|
|
|
|
|
|
|
return this.Operations[activeButtonID];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return this.Operations.FirstOrDefault();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|