Kaynağa Gözat

Allowed for overriding image in DynamicMenuColumn

Kenric Nugteren 4 ay önce
ebeveyn
işleme
65fb6370b4

+ 0 - 1
InABox.Database/DbFactory.cs

@@ -65,7 +65,6 @@ public static class DbFactory
         set => SetStoreTypes(value);
     }
 
-    public static string? EmailAddress { get; set; }
     public static ICoreMailer? Mailer { get; set; }
 
     public static DateTime Expiry { get; set; }

+ 3 - 3
inabox.wpf/DynamicGrid/Columns/DynamicMenuColumn.cs

@@ -31,7 +31,7 @@ namespace InABox.DynamicGrid
 
         public delegate void BuildMenu(DynamicMenuColumn column, CoreRow? row);
 
-        public DynamicMenuColumn(BuildMenu build, Func<CoreRow, DynamicMenuStatus>? status = null) : base(r => null)
+        public DynamicMenuColumn(BuildMenu build, Func<CoreRow, DynamicMenuStatus>? status = null, GetImageDelegate? getImage = null) : base(r => null)
         {
             _menu = new ContextMenu();
 
@@ -39,7 +39,7 @@ namespace InABox.DynamicGrid
             _build = build;
             _status = status;
 
-            Image = row =>
+            Image = getImage ?? (row =>
             {
                 if (row == null)
                     return null;
@@ -51,7 +51,7 @@ namespace InABox.DynamicGrid
                 if (status == DynamicMenuStatus.Disabled)
                     return _disabled;
                 return null;
-            };
+            });
                 
             Action = r =>
             {

+ 7 - 9
inabox.wpf/DynamicGrid/Editors/EmbeddedImageEditor/EmbeddedImageEditorControl.cs

@@ -12,7 +12,7 @@ using Image = System.Drawing.Image;
 
 namespace InABox.DynamicGrid
 {
-    public class EmbeddedImageEditorControl : DynamicEditorControl<byte[], EmbeddedImageEditor>
+    public class EmbeddedImageEditorControl : DynamicEditorControl<byte[]?, EmbeddedImageEditor>
     {
         
         static EmbeddedImageEditorControl()
@@ -20,9 +20,9 @@ namespace InABox.DynamicGrid
             //DynamicEditorControlFactory.Register<EmbeddedImageEditorControl, EmbeddedImageEditor>();
         }
         
-        private byte[] data;
+        private byte[]? data;
 
-        private Button Select;
+        private Button Select = null!;
 
         public EmbeddedImageEditorControl()
         {
@@ -88,16 +88,14 @@ namespace InABox.DynamicGrid
                 var image = Image.FromFile(dlg.FileName);
                 var size = image.Size.Adjust(MaximumWidth, MaximumHeight);
                 image = new Bitmap(image, size);
-                data = (byte[])new ImageConverter().ConvertTo(image, typeof(byte[]));
+                data = new ImageConverter().ConvertTo(image, typeof(byte[])) as byte[];
                 CheckChanged();
             }
-
-            ;
         }
 
         private void View_Click(object sender, RoutedEventArgs e)
         {
-            if (data == null || !data.Any())
+            if (data == null || data.Length == 0)
                 return;
             var type = ImageUtils.GetImageType(data);
             var file = Path.ChangeExtension(Path.GetTempFileName(), type.ToString());
@@ -122,12 +120,12 @@ namespace InABox.DynamicGrid
             return 150;
         }
 
-        protected override byte[] RetrieveValue()
+        protected override byte[]? RetrieveValue()
         {
             return data;
         }
 
-        protected override void UpdateValue(byte[] value)
+        protected override void UpdateValue(byte[]? value)
         {
             data = value;
         }

+ 4 - 0
inabox.wpf/InABox.Wpf.csproj

@@ -59,6 +59,7 @@
         <None Remove="Resources\drag.png" />
         <None Remove="Resources\draw.png" />
         <None Remove="Resources\edit.png" />
+        <None Remove="Resources\email.png" />
         <None Remove="Resources\filter.png" />
         <None Remove="Resources\filter_active.png" />
         <None Remove="Resources\filter_set.png" />
@@ -442,6 +443,9 @@
         <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
       </Resource>
       <None Remove="Resources\splash.png" />
+      <Resource Include="Resources\email.png">
+        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+      </Resource>
       <Resource Include="Resources\splash.png">
         <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
       </Resource>

+ 10 - 0
inabox.wpf/Resources.Designer.cs

@@ -450,6 +450,16 @@ namespace InABox.Wpf {
             }
         }
         
+        /// <summary>
+        ///   Looks up a localized resource of type System.Drawing.Bitmap.
+        /// </summary>
+        public static System.Drawing.Bitmap email {
+            get {
+                object obj = ResourceManager.GetObject("email", resourceCulture);
+                return ((System.Drawing.Bitmap)(obj));
+            }
+        }
+        
         /// <summary>
         ///   Looks up a localized resource of type System.Drawing.Bitmap.
         /// </summary>

+ 3 - 0
inabox.wpf/Resources.resx

@@ -235,6 +235,9 @@
   <data name="edit" type="System.Resources.ResXFileRef, System.Windows.Forms">
     <value>Resources\edit.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
   </data>
+  <data name="email" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>Resources\email.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+  </data>
   <data name="filter" type="System.Resources.ResXFileRef, System.Windows.Forms">
     <value>Resources\filter.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
   </data>

BIN
inabox.wpf/Resources/email.png