]> O.S.I.I.S - jp/crow.git/commitdiff
messageBox improvements
authorjpbruyere <jp.bruyere@hotmail.com>
Tue, 28 Feb 2017 13:26:21 +0000 (14:26 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Tue, 28 Feb 2017 13:26:21 +0000 (14:26 +0100)
Crow.csproj
Default.style
Templates/MessageBox.template
src/GraphicObjects/MessageBox.cs

index cd8a07b48f264f33e6ee298a981c0f41a367bdd3..20b38cf86c3aa7a8ae5408ada88f8b392fc06238 100644 (file)
     <EmbeddedResource Include="Images\Icons\member.svg" />
     <EmbeddedResource Include="Images\Icons\exit2.svg" />
     <EmbeddedResource Include="Images\button.svg" />
-    <EmbeddedResource Include="Images\Icons\iconInfo.svg" />
+    <EmbeddedResource Include="Images\Icons\iconInfo.svg">
+      <LogicalName>Crow.Images.Icons.Informations.svg</LogicalName>
+    </EmbeddedResource>
     <EmbeddedResource Include="Templates\tmpDirItem.goml" />
     <EmbeddedResource Include="Templates\ScrollingListBox.goml" />
     <EmbeddedResource Include="Templates\imgItemTemplate.goml" />
index a09c363db2887beabb1608a2b7a00c37da64687f..0db6a08abd4cb0604bdb1cadef7dc57f7e0d314c 100644 (file)
@@ -40,9 +40,11 @@ MenuItem {
        MouseLeave = {Foreground=LightGray;Background=Transparent;}
 }
 MessageBox {
-       Width=200;
+       Background = 0.3,0.3,0.3,0.3;
+       Width = Fit;
        Title=MessageBox;
-       MinimumSize=150,80;
+       Font = serif, 12;
+       MinimumSize = 200,120;
 }
 Slider {
        Background = vgradient|0:Black|0.1:Gray|0.9:Gray|1:LightGray;
index 8c58d61d5aa00d220d4308253c588990f1c97fc4..c33eb869970eecf811ff08189c67b210835aa078 100644 (file)
@@ -3,13 +3,13 @@
                                MouseEnter="./onBorderMouseEnter"
                                MouseLeave="./onBorderMouseLeave">
        <VerticalStack Background="{./Background}">
-               <Border BorderWidth="0" Foreground="White" Height="Fit" 
+               <Border BorderWidth="0" Foreground="White" Height="Fit" Width="Stretched" MinimumSize="200,0"
                                Background="vgradient|0:0.4,0.6,0.0,0.5|1:0.0,0.8,0.8,0.9">
                        <HorizontalStack Name="hs" Margin="2" Spacing="1" Height="Fit" >
                                <GraphicObject Width="5" Height="5"/>
                                <Image Margin="1" Width="12" Height="12" Path="{./Icon}"/>
                                <Label Width="Stretched" Foreground="White" Margin="1" TextAlignment="Center" Text="{./Caption}" />
-                               <Border CornerRadius="6" BorderWidth="1" Foreground="Transparent"  Height="12" Width="12"
+                               <Border CornerRadius="3" BorderWidth="1" Foreground="Transparent"  Height="12" Width="12"
                                        MouseEnter="{Foreground=White}" MouseLeave="{Foreground=Transparent}">
                                        <Image Focusable="true" Name="Image" Path="#Crow.Images.Icons.exit2.svg"
                                                 MouseClick="./butQuitPress"/>
                        </HorizontalStack>
                </Border>
                <HorizontalStack Margin="5">
-                       <Image Name="Image" Width="20%" Height="20" Path="#Crow.Images.Icons.iconInfo.svg" />
-                       <Label Margin="5" Font="serif, 10" Width="80%" Text="{./Message}"
+                       <Image Name="Image" Width="20%" Height="30" Path="{./MsgIcon}" />
+                       <Label Margin="5" Font="{./Font}" Width="Fit" Text="{./Message}"
                                TextAlignment="Left"
                                Multiline="true" />             
                </HorizontalStack>
                <HorizontalStack Margin="1" Spacing="0" Height="Fit" Width="60%" HorizontalAlignment="Right">
-                       <Button Width="50%" Caption="Ok" MouseClick="./onOkButtonClick" />
-                       <Button Width="50%" Caption="Cancel" MouseClick="./onCancelButtonClick" />
+                       <Button Width="50%" Caption="{./OkMessage}" MouseClick="./onOkButtonClick" />
+                       <Button Width="50%" Caption="{./CancelMessage}" MouseClick="./onCancelButtonClick" />
                </HorizontalStack>
        </VerticalStack>
 </Border>
index dbca769d31fd4caba8b8d62cdc436675e2b64bfd..65bb66c3750871dec2823219b1ed0f602c372edb 100644 (file)
@@ -25,9 +25,21 @@ namespace Crow
 {
        public class MessageBox : Window
        {
-               public MessageBox ():base(){}
+               public enum Type {
+                       Information,
+                       YesNo,
+                       Alert,
+                       Error
+               }
+               public MessageBox (): base(){}
 
-               string message;
+               protected override void loadTemplate (GraphicObject template)
+               {
+                       base.loadTemplate (template);
+                       NotifyValueChanged ("MsgIcon", "#Crow.Images.Icons.Informations.svg");
+               }
+               string message, okMessage, cancelMessage;
+               Type msgType = Type.Information;
 
                public event EventHandler Ok;
                public event EventHandler Cancel;
@@ -43,7 +55,65 @@ namespace Crow
                                NotifyValueChanged ("Message", message);
                        }
                }
-
+               [XmlAttributeAttribute][DefaultValue("Ok")]
+               public virtual string OkMessage
+               {
+                       get { return okMessage; }
+                       set {
+                               if (okMessage == value)
+                                       return;
+                               okMessage = value;
+                               NotifyValueChanged ("OkMessage", okMessage);
+                       }
+               }
+               [XmlAttributeAttribute][DefaultValue("Cancel")]
+               public virtual string CancelMessage
+               {
+                       get { return cancelMessage; }
+                       set {
+                               if (cancelMessage == value)
+                                       return;
+                               cancelMessage = value;
+                               NotifyValueChanged ("CancelMessage", cancelMessage);
+                       }
+               }
+               [XmlAttributeAttribute][DefaultValue("Information")]
+               public virtual Type MsgType
+               {
+                       get { return msgType; }
+                       set {
+                               if (msgType == value)
+                                       return;
+                               msgType = value;
+                               NotifyValueChanged ("MsgType", msgType);
+                               switch (msgType) {
+                               case Type.Information:
+                                       NotifyValueChanged ("MsgIcon", "#Crow.Images.Icons.Informations.svg");
+                                       Caption = "Informations";
+                                       OkMessage = "Ok";
+                                       CancelMessage = "Cancel";
+                                       break;
+                               case Type.YesNo:
+                                       NotifyValueChanged ("MsgIcon", "#Crow.Icons.question.svg");
+                                       Caption = "Choice";
+                                       OkMessage = "Yes";
+                                       CancelMessage = "No";
+                                       break;
+                               case Type.Alert:
+                                       NotifyValueChanged ("MsgIcon", "#Crow.Images.Icons.IconAlerte.svg");
+                                       Caption = "Alert";
+                                       OkMessage = "Ok";
+                                       CancelMessage = "Cancel";
+                                       break;
+                               case Type.Error:
+                                       NotifyValueChanged ("MsgIcon", "#Crow.Images.Icons.exit.svg");
+                                       Caption = "Error";
+                                       OkMessage = "Ok";
+                                       CancelMessage = "Cancel";
+                                       break;
+                               }
+                       }
+               }
                void onOkButtonClick (object sender, EventArgs e)
                {
                        Ok.Raise (this, null);
@@ -52,7 +122,20 @@ namespace Crow
                {
                        Cancel.Raise (this, null);
                }
-
+               public static MessageBox Show (Type msgBoxType, string message, string okMsg = "", string cancelMsg = ""){
+                       lock (Interface.CurrentInterface.UpdateMutex) {
+                               MessageBox mb = new MessageBox ();
+                               mb.Initialize ();
+                               mb.CurrentInterface.AddWidget (mb);
+                               mb.MsgType = msgBoxType;
+                               mb.Message = message;
+                               if (!string.IsNullOrEmpty(okMsg))
+                                       mb.OkMessage = okMsg;
+                               if (!string.IsNullOrEmpty(cancelMsg))
+                                       mb.CancelMessage = cancelMsg;
+                               return mb;
+                       }
+               }
        }
 }