Improving design editor
Moving files around
This commit is contained in:
parent
ce0d8a5bac
commit
618fabf894
18 changed files with 474 additions and 43 deletions
|
|
@ -1732,7 +1732,7 @@ namespace MatterHackers.MatterControl
|
|||
// loading animation stuff
|
||||
LightingData lighting = new LightingData();
|
||||
|
||||
var logoPath = AggContext.StaticData.MapPath(Path.Combine("OEMSettings", "SampleParts", "MH Logo.stl"));
|
||||
var logoPath = AggContext.StaticData.MapPath(Path.Combine("Stls", "MH Logo.stl"));
|
||||
var logoMesh = MeshFileIo.Load(logoPath, CancellationToken.None).Mesh;
|
||||
|
||||
// Position
|
||||
|
|
|
|||
49
DesignTools/Attributes/IconsAttribute.cs
Normal file
49
DesignTools/Attributes/IconsAttribute.cs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
Copyright (c) 2018, 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;
|
||||
|
||||
namespace MatterHackers.MatterControl.DesignTools
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public class IconsAttribute : Attribute
|
||||
{
|
||||
public bool Item0IsNone { get; private set; }
|
||||
public string[] IconPaths { get; private set; }
|
||||
public int Width { get; set; }
|
||||
public int Height { get; set; }
|
||||
public IconsAttribute(string[] iconPaths, int width = 16, int height = 16, bool item0IsNone = true)
|
||||
{
|
||||
Width = width;
|
||||
Height = height;
|
||||
this.IconPaths = iconPaths;
|
||||
Item0IsNone = item0IsNone;
|
||||
}
|
||||
}
|
||||
}
|
||||
38
DesignTools/Attributes/SortableAttribute.cs
Normal file
38
DesignTools/Attributes/SortableAttribute.cs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
Copyright (c) 2018, 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;
|
||||
|
||||
namespace MatterHackers.MatterControl.DesignTools
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public class SortableAttribute : Attribute
|
||||
{
|
||||
}
|
||||
}
|
||||
45
DesignTools/Attributes/UnlockLinkAttribute.cs
Normal file
45
DesignTools/Attributes/UnlockLinkAttribute.cs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
Copyright (c) 2018, 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;
|
||||
|
||||
namespace MatterHackers.MatterControl.DesignTools
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class UnlockLinkAttribute : Attribute
|
||||
{
|
||||
public static string DetailPageBaseUrl => "https://www.matterhackers.com/store/l/";
|
||||
|
||||
public string DetailsPageLink { get; private set; }
|
||||
public UnlockLinkAttribute(string detailsPageLink)
|
||||
{
|
||||
DetailsPageLink = detailsPageLink;
|
||||
}
|
||||
}
|
||||
}
|
||||
95
DesignTools/ImageAsset.cs
Normal file
95
DesignTools/ImageAsset.cs
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
Copyright (c) 2018, 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.IO;
|
||||
using MatterHackers.Agg.Image;
|
||||
using MatterHackers.Agg.ImageProcessing;
|
||||
using MatterHackers.Agg.Platform;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MatterHackers.MatterControl.DesignTools
|
||||
{
|
||||
public class ImageAsset
|
||||
{
|
||||
private string _assetPath;
|
||||
private ImageBuffer _image;
|
||||
private bool _invert;
|
||||
|
||||
public string AssetPath
|
||||
{
|
||||
get { return _assetPath; }
|
||||
set
|
||||
{
|
||||
if (_assetPath != value)
|
||||
{
|
||||
_assetPath = value;
|
||||
_image = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public ImageBuffer Image
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_image == null)
|
||||
{
|
||||
if (File.Exists(AssetPath))
|
||||
{
|
||||
_image = AggContext.ImageIO.LoadImage(AssetPath);
|
||||
if (Invert)
|
||||
{
|
||||
_image = InvertLightness.DoInvertLightness(_image);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _image;
|
||||
}
|
||||
|
||||
private set
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public bool Invert
|
||||
{
|
||||
get { return _invert; }
|
||||
set
|
||||
{
|
||||
if (_invert != value)
|
||||
{
|
||||
_invert = value;
|
||||
_image = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
37
DesignTools/Interfaces/IPropertyGridModifier.cs
Normal file
37
DesignTools/Interfaces/IPropertyGridModifier.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
Copyright (c) 2018, 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.
|
||||
*/
|
||||
|
||||
|
||||
namespace MatterHackers.MatterControl.DesignTools
|
||||
{
|
||||
public interface IPropertyGridModifier
|
||||
{
|
||||
void UpdateControls(PublicPropertyEditor editor);
|
||||
}
|
||||
}
|
||||
37
DesignTools/Interfaces/IRebuildable.cs
Normal file
37
DesignTools/Interfaces/IRebuildable.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
Copyright (c) 2018, 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.
|
||||
*/
|
||||
|
||||
|
||||
namespace MatterHackers.MatterControl.DesignTools
|
||||
{
|
||||
public interface IRebuildable
|
||||
{
|
||||
void Rebuild();
|
||||
}
|
||||
}
|
||||
|
|
@ -30,57 +30,24 @@ either expressed or implied, of the FreeBSD Project.
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Image;
|
||||
using MatterHackers.Agg.Platform;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
using MatterHackers.MatterControl.DesignTools.Operations;
|
||||
using MatterHackers.MatterControl.Library;
|
||||
using MatterHackers.MatterControl.PartPreviewWindow;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using MatterHackers.VectorMath;
|
||||
|
||||
namespace MatterHackers.MatterControl.DesignTools
|
||||
{
|
||||
public interface IRebuildable
|
||||
{
|
||||
void Rebuild();
|
||||
}
|
||||
|
||||
public interface IPropertyGridModifier
|
||||
{
|
||||
void UpdateControls(PublicPropertyEditor editor);
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public class SortableAttribute : Attribute
|
||||
{
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public class IconsAttribute : Attribute
|
||||
{
|
||||
public string[] IconPaths { get; private set; }
|
||||
public IconsAttribute(string[] iconPaths)
|
||||
{
|
||||
this.IconPaths = iconPaths;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class UnlockLinkAttribute : Attribute
|
||||
{
|
||||
public static string DetailPageBaseUrl => "https://www.matterhackers.com/store/l/";
|
||||
|
||||
public string DetailsPageLink { get; private set; }
|
||||
public UnlockLinkAttribute(string detailsPageLink)
|
||||
{
|
||||
DetailsPageLink = detailsPageLink;
|
||||
}
|
||||
}
|
||||
|
||||
public class PublicPropertyEditor : IObject3DEditor
|
||||
{
|
||||
|
|
@ -90,11 +57,12 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
|
||||
public bool Unlocked { get; } = true;
|
||||
|
||||
private static Type[] allowedTypes =
|
||||
private static Type[] allowedTypes =
|
||||
{
|
||||
typeof(double), typeof(int), typeof(string), typeof(bool),
|
||||
typeof(Vector2), typeof(Vector3),
|
||||
typeof(DirectionVector), typeof(DirectionAxis)
|
||||
typeof(DirectionVector), typeof(DirectionAxis),
|
||||
typeof(ImageAsset)
|
||||
};
|
||||
|
||||
public const BindingFlags OwnedPropertiesOnly = BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly;
|
||||
|
|
@ -187,9 +155,10 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
|
||||
AddUnlockLinkIfRequired(editControlsContainer, theme);
|
||||
|
||||
GuiWidget rowContainer = null;
|
||||
foreach (var property in editableProperties)
|
||||
{
|
||||
GuiWidget rowContainer = null;
|
||||
|
||||
// create a double editor
|
||||
if (property.Value is double doubleValue)
|
||||
{
|
||||
|
|
@ -451,6 +420,14 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
theme);
|
||||
editControlsContainer.AddChild(rowContainer);
|
||||
}
|
||||
// create an image asset editor
|
||||
else if(property.Value is ImageAsset imageAsset)
|
||||
{
|
||||
rowContainer = CreateImageEditor(rebuildable,
|
||||
imageAsset,
|
||||
theme);
|
||||
editControlsContainer.AddChild(rowContainer);
|
||||
}
|
||||
|
||||
// remember the row name and widget
|
||||
editRows.Add(property.PropertyInfo.Name, rowContainer);
|
||||
|
|
@ -488,10 +465,141 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
}
|
||||
}
|
||||
|
||||
private GuiWidget CreateImageEditor(IRebuildable item,
|
||||
ImageAsset imageAsset,
|
||||
ThemeConfig theme)
|
||||
{
|
||||
var column = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
||||
{
|
||||
HAnchor = HAnchor.Stretch
|
||||
};
|
||||
|
||||
var imageSection = new SectionWidget(
|
||||
"Image".Localize(),
|
||||
new FlowLayoutWidget(FlowDirection.TopToBottom),
|
||||
theme).ApplyBoxStyle(margin: 0);
|
||||
|
||||
column.AddChild(imageSection);
|
||||
|
||||
ImageBuffer thumbnailImage = SetImage(theme, imageAsset);
|
||||
|
||||
ImageWidget thumbnailWidget;
|
||||
imageSection.ContentPanel.AddChild(thumbnailWidget = new ImageWidget(thumbnailImage)
|
||||
{
|
||||
Margin = new BorderDouble(bottom: 5),
|
||||
HAnchor = HAnchor.Center
|
||||
});
|
||||
|
||||
var changeImageButton = new TextButton("Change".Localize(), theme)
|
||||
{
|
||||
BackgroundColor = theme.MinimalShade
|
||||
};
|
||||
changeImageButton.Click += (sender, e) =>
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
// we do this using to make sure that the stream is closed before we try and insert the Picture
|
||||
AggContext.FileDialogs.OpenFileDialog(
|
||||
new OpenFileDialogParams(
|
||||
"Select an image file|*.jpg;*.png;*.bmp;*.gif;*.pdf",
|
||||
multiSelect: false,
|
||||
title: "Add Image".Localize()),
|
||||
(openParams) =>
|
||||
{
|
||||
if (!File.Exists(openParams.FileName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
imageAsset.AssetPath = openParams.FileName;
|
||||
thumbnailWidget.Image = SetImage(theme, imageAsset);
|
||||
|
||||
item?.Rebuild();
|
||||
|
||||
column.Invalidate();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var row = new FlowLayoutWidget()
|
||||
{
|
||||
HAnchor = HAnchor.Stretch,
|
||||
VAnchor = VAnchor.Fit,
|
||||
};
|
||||
imageSection.ContentPanel.AddChild(row);
|
||||
|
||||
// Invert checkbox
|
||||
var invertCheckbox = new CheckBox(new CheckBoxViewText("Invert".Localize(), textColor: theme.Colors.PrimaryTextColor))
|
||||
{
|
||||
Checked = imageAsset.Invert,
|
||||
Margin = new BorderDouble(0),
|
||||
};
|
||||
invertCheckbox.CheckedStateChanged += (s, e) =>
|
||||
{
|
||||
imageAsset.Invert = invertCheckbox.Checked;
|
||||
thumbnailWidget.Image = SetImage(theme, imageAsset);
|
||||
item?.Rebuild();
|
||||
};
|
||||
row.AddChild(invertCheckbox);
|
||||
|
||||
row.AddChild(new HorizontalSpacer());
|
||||
|
||||
row.AddChild(changeImageButton);
|
||||
|
||||
return column;
|
||||
}
|
||||
|
||||
private ImageBuffer SetImage(ThemeConfig theme, ImageAsset imageAsset)
|
||||
{
|
||||
var image = imageAsset.Image;
|
||||
// Show image load error if needed
|
||||
if (image == null)
|
||||
{
|
||||
image = new ImageBuffer(185, 185).SetPreMultiply();
|
||||
var graphics2D = image.NewGraphics2D();
|
||||
|
||||
graphics2D.FillRectangle(0, 0, 185, 185, theme.MinimalShade);
|
||||
graphics2D.Rectangle(0, 0, 185, 185, theme.SlightShade);
|
||||
graphics2D.DrawString("Error Loading Image".Localize() + "...", 10, 185 / 2, baseline: Agg.Font.Baseline.BoundsCenter, color: Color.Red, pointSize: theme.DefaultFontSize, drawFromHintedCach: true);
|
||||
}
|
||||
|
||||
return (image.Height <= 185) ? image : ScaleThumbnailImage(185, image);
|
||||
}
|
||||
|
||||
private ImageBuffer ScaleThumbnailImage(int height, ImageBuffer imageBuffer)
|
||||
{
|
||||
if (imageBuffer.Height != height)
|
||||
{
|
||||
var factor = (double)height / imageBuffer.Height;
|
||||
|
||||
int width = (int)(imageBuffer.Width * factor);
|
||||
|
||||
var scaledImageBuffer = new ImageBuffer(width, height);
|
||||
scaledImageBuffer.NewGraphics2D().Render(imageBuffer, 0, 0, width, height);
|
||||
return scaledImageBuffer;
|
||||
}
|
||||
|
||||
return imageBuffer;
|
||||
}
|
||||
|
||||
private ImageBuffer ScaleThumbnailImage(int width, int height, ImageBuffer imageBuffer)
|
||||
{
|
||||
if (imageBuffer.Width != width)
|
||||
{
|
||||
var scaledImageBuffer = new ImageBuffer(width, height);
|
||||
scaledImageBuffer.NewGraphics2D().Render(imageBuffer, 0, 0, scaledImageBuffer.Width, scaledImageBuffer.Height);
|
||||
imageBuffer = scaledImageBuffer;
|
||||
}
|
||||
|
||||
return imageBuffer;
|
||||
}
|
||||
|
||||
private GuiWidget CreateEnumEditor(IRebuildable item,
|
||||
PropertyInfo propertyInfo, Type propertyType, object value, string displayName,
|
||||
ThemeConfig theme)
|
||||
{
|
||||
var propertyGridModifier = item as IPropertyGridModifier;
|
||||
|
||||
// Enum keyed on name to friendly name
|
||||
var enumItems = Enum.GetNames(propertyType).Select(enumName =>
|
||||
{
|
||||
|
|
@ -511,12 +619,25 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
foreach (var enumItem in enumItems)
|
||||
{
|
||||
var localIndex = index;
|
||||
var iconImage = AggContext.StaticData.LoadIcon(iconsAttribute.IconPaths[localIndex], 16, 16);
|
||||
ImageBuffer iconImage = null;
|
||||
if (iconsAttribute.Width > 0)
|
||||
{
|
||||
iconImage = AggContext.StaticData.LoadIcon(iconsAttribute.IconPaths[localIndex], iconsAttribute.Width, iconsAttribute.Height);
|
||||
}
|
||||
else
|
||||
{
|
||||
iconImage = AggContext.StaticData.LoadIcon(iconsAttribute.IconPaths[localIndex]);
|
||||
}
|
||||
var radioButton = new RadioButton(new ImageWidget(iconImage));
|
||||
// set it if checked
|
||||
if(enumItem.Value == value.ToString())
|
||||
{
|
||||
radioButton.Checked = true;
|
||||
if (localIndex != 0
|
||||
|| !iconsAttribute.Item0IsNone)
|
||||
{
|
||||
radioButton.BackgroundColor = new Color(Color.Black, 100);
|
||||
}
|
||||
}
|
||||
|
||||
rowContainer.AddChild(radioButton);
|
||||
|
|
@ -530,7 +651,9 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
this.item,
|
||||
new Object[] { Enum.Parse(propertyType, localItem.Key) });
|
||||
item?.Rebuild();
|
||||
if (localIndex != 0)
|
||||
propertyGridModifier?.UpdateControls(this);
|
||||
if (localIndex != 0
|
||||
|| !iconsAttribute.Item0IsNone)
|
||||
{
|
||||
radioButton.BackgroundColor = new Color(Color.Black, 100);
|
||||
}
|
||||
|
|
@ -561,6 +684,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
this.item,
|
||||
new Object[] { Enum.Parse(propertyType, localOredrItem.Key) });
|
||||
item?.Rebuild();
|
||||
propertyGridModifier?.UpdateControls(this);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,6 +86,10 @@
|
|||
<Compile Include="ApplicationView\OemProfileDictionary.cs" />
|
||||
<Compile Include="ApplicationView\WindowsPlatformsFeatures.cs" />
|
||||
<Compile Include="DataStorage\ApplicationDataStorage.cs" />
|
||||
<Compile Include="DesignTools\Attributes\IconsAttribute.cs" />
|
||||
<Compile Include="DesignTools\ImageAsset.cs" />
|
||||
<Compile Include="DesignTools\Interfaces\IPropertyGridModifier.cs" />
|
||||
<Compile Include="DesignTools\Interfaces\IRebuildable.cs" />
|
||||
<Compile Include="DesignTools\Operations\ArrangeObject3D.cs" />
|
||||
<Compile Include="DesignTools\Operations\ArrayAdvancedObject3D.cs" />
|
||||
<Compile Include="DesignTools\Operations\ArrayLinearObject3D.cs" />
|
||||
|
|
@ -115,6 +119,8 @@
|
|||
<Compile Include="DesignTools\Operations\SetCenter.cs" />
|
||||
<Compile Include="DesignTools\Operations\Package.cs" />
|
||||
<Compile Include="DesignTools\Operations\Translate.cs" />
|
||||
<Compile Include="DesignTools\Attributes\SortableAttribute.cs" />
|
||||
<Compile Include="DesignTools\Attributes\UnlockLinkAttribute.cs" />
|
||||
<Compile Include="Library\Providers\FileSystem\McxContainer.cs" />
|
||||
<Compile Include="Library\Providers\GraphConfig.cs" />
|
||||
<Compile Include="CustomWidgets\InlineTitleEdit.cs" />
|
||||
|
|
|
|||
BIN
StaticData/Icons/ch_image.png
Normal file
BIN
StaticData/Icons/ch_image.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2 KiB |
BIN
StaticData/Icons/ch_image_text.png
Normal file
BIN
StaticData/Icons/ch_image_text.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
BIN
StaticData/Icons/ch_text.png
Normal file
BIN
StaticData/Icons/ch_text.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.5 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 11 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 637 KiB |
BIN
StaticData/Stls/MH Logo.stl
Normal file
BIN
StaticData/Stls/MH Logo.stl
Normal file
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
Subproject commit c966cd82c471da08a7ac3b5cfd201c95381a1a14
|
||||
Subproject commit aa02e60a6c33efb0c35606a794e2f9acc1514b1b
|
||||
Loading…
Add table
Add a link
Reference in a new issue