diff --git a/Arma.Studio.Data/ArmA.Studio.Data.csproj b/Arma.Studio.Data/ArmA.Studio.Data.csproj index 765d191..cc66da3 100644 --- a/Arma.Studio.Data/ArmA.Studio.Data.csproj +++ b/Arma.Studio.Data/ArmA.Studio.Data.csproj @@ -142,6 +142,7 @@ + diff --git a/Arma.Studio.Data/UI/Converters/EnumSourceConverter.cs b/Arma.Studio.Data/UI/Converters/EnumSourceConverter.cs new file mode 100644 index 0000000..35fd5a7 --- /dev/null +++ b/Arma.Studio.Data/UI/Converters/EnumSourceConverter.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Reflection; +using System.Resources; +using System.Windows; +using System.Windows.Data; + +namespace Arma.Studio.Data.UI.Converters +{ + /// + /// Converts the passed value to the corresponding representing its name. + /// Requires the parameter to be the of the enum to convert. + /// Can convert backwards. + /// + public class EnumSourceConverter : IValueConverter + { + public static EnumSourceConverter Instance { get => _Instance; set => _Instance = value; } + private static EnumSourceConverter _Instance; + + static EnumSourceConverter() + { + _Instance = new EnumSourceConverter(); + } + /// + /// Converts a value + /// + /// The value produced by the binding source. + /// The type of the binding target property. + /// The converter parameter to use. + /// The culture to use in the converter. + /// A converted value. If the method returns null, the valid null value is used. + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is Type t && t.IsEnum) + { + return Enum.GetValues(t); + } + return null; + } + + /// + /// Converts a value. + /// + /// The value that is produced by the binding target. + /// The type to convert to. + /// The converter parameter to use. + /// The culture to use in the converter. + /// A converted value. If the method returns null, the valid null value is used. + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Arma.Studio.UiEditor/ArmA.Studio.UiEditor.csproj b/Arma.Studio.UiEditor/ArmA.Studio.UiEditor.csproj index 5616a5f..5038da1 100644 --- a/Arma.Studio.UiEditor/ArmA.Studio.UiEditor.csproj +++ b/Arma.Studio.UiEditor/ArmA.Studio.UiEditor.csproj @@ -172,6 +172,9 @@ + + + + /// Looks up a localized string similar to Background. + /// + public static string UiEditor_Background { + get { + return ResourceManager.GetString("UiEditor_Background", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The Background displayed in the canvas area.. + /// + public static string UiEditor_Background_ToolTip { + get { + return ResourceManager.GetString("UiEditor_Background_ToolTip", resourceCulture); + } + } + /// /// Looks up a localized string similar to Gridsize. /// diff --git a/Arma.Studio.UiEditor/Properties/Language.resx b/Arma.Studio.UiEditor/Properties/Language.resx index f42d10a..c93920c 100644 --- a/Arma.Studio.UiEditor/Properties/Language.resx +++ b/Arma.Studio.UiEditor/Properties/Language.resx @@ -294,4 +294,10 @@ UI-Editor + + Background + + + The Background displayed in the canvas area. + \ No newline at end of file diff --git a/Arma.Studio.UiEditor/UI/CanvasManager.cs b/Arma.Studio.UiEditor/UI/CanvasManager.cs index 570e305..9eab3c7 100644 --- a/Arma.Studio.UiEditor/UI/CanvasManager.cs +++ b/Arma.Studio.UiEditor/UI/CanvasManager.cs @@ -29,6 +29,13 @@ public class CanvasManager : INotifyPropertyChanged, IOnDrop { + public enum EBackgroundMode + { + NA, + Grid, + Arma + } + public event PropertyChangedEventHandler PropertyChanged; protected void RaisePropertyChanged([CallerMemberName]string callee = "") => this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(callee)); #region Collection: SelectedNodes (System.Collections.ObjectModel.ObservableCollection) @@ -143,6 +150,7 @@ public CanvasManager(UiEditorDataContext owner) this.Height = 1080; this.Zoom = 0.5; this.Cursor = Cursors.Arrow; + this.BackgroundMode = EBackgroundMode.Grid; } private readonly UiEditorDataContext Owner; @@ -224,6 +232,18 @@ public double Width } private double _Width; #endregion + #region Property: BackgroundMode (EBackgroundMode) + public EBackgroundMode BackgroundMode + { + get => this._BackgroundMode; + set + { + this._BackgroundMode = value; + this.RaisePropertyChanged(); + } + } + private EBackgroundMode _BackgroundMode; + #endregion #region Property: Height (System.Double) public double Height { diff --git a/Arma.Studio.UiEditor/UI/UiEditor.xaml b/Arma.Studio.UiEditor/UI/UiEditor.xaml index a2d2a1f..29ac1d3 100644 --- a/Arma.Studio.UiEditor/UI/UiEditor.xaml +++ b/Arma.Studio.UiEditor/UI/UiEditor.xaml @@ -45,28 +45,35 @@ Cursor="{Binding CanvasManager.Cursor}"> @@ -117,6 +124,22 @@ + + + + + + + + + + + + + + + diff --git a/Arma.Studio/App.xaml b/Arma.Studio/App.xaml index cf26eee..7009651 100644 --- a/Arma.Studio/App.xaml +++ b/Arma.Studio/App.xaml @@ -24,6 +24,8 @@ + +