]> O.S.I.I.S - jp/crow.git/commitdiff
icon menuitem, PopWidth and PopHeight, commands
authorjpbruyere <jp.bruyere@hotmail.com>
Thu, 26 Jan 2017 23:21:48 +0000 (00:21 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Thu, 26 Jan 2017 23:21:48 +0000 (00:21 +0100)
22 files changed:
Crow.csproj
CrowIDE/CrowIDE.csproj
CrowIDE/Default.style [deleted file]
CrowIDE/src/CrowIDE.cs
CrowIDE/ui/IDE.style
CrowIDE/ui/MenuItem.template [new file with mode: 0644]
CrowIDE/ui/imlEditor.crow
Default.style
Icons/copy-file.svg [new file with mode: 0644]
Icons/exit-symbol.svg [new file with mode: 0644]
Icons/open-file.svg [new file with mode: 0644]
Icons/paste-on-document.svg [new file with mode: 0644]
Icons/question.svg [new file with mode: 0644]
Icons/scissors.svg [new file with mode: 0644]
Templates/DirectoryView.template
Templates/MenuItem.template
src/Command.cs
src/GraphicObjects/Button.cs
src/GraphicObjects/Image.cs
src/GraphicObjects/Menu.cs
src/GraphicObjects/MenuItem.cs
src/GraphicObjects/Popper.cs

index 25e7f10dc4d5e609580ed87d9f5bc277400c67ce..d74f12f222ac35f65c18899e40abb67bc5cf941e 100644 (file)
     <Folder Include="src\Input\" />
     <Folder Include="src\rsvg\" />
     <Folder Include="src\IML\" />
+    <Folder Include="Icons\" />
   </ItemGroup>
   <ItemGroup>
     <EmbeddedResource Include="Images\Icons\updown.svg" />
     <EmbeddedResource Include="Images\Icons\maximize.svg" />
     <EmbeddedResource Include="Images\Icons\minimize.svg" />
     <EmbeddedResource Include="Images\Icons\normalize.svg" />
+    <EmbeddedResource Include="Icons\open-file.svg"/>
+    <EmbeddedResource Include="Icons\scissors.svg"/>
+    <EmbeddedResource Include="Icons\copy-file.svg"/>
+    <EmbeddedResource Include="Icons\exit-symbol.svg"/>
+    <EmbeddedResource Include="Icons\paste-on-document.svg"/>
+    <EmbeddedResource Include="Icons\question.svg"/>
   </ItemGroup>
   <ItemGroup>
     <None Include="README.md" />
index ec173d3de8231608fce9f957d3aa06fb605a73e2..b144ccce5849cc92def1197c2a3e7605728f3d7c 100644 (file)
       <LogicalName>CrowIDE.MembersView.template</LogicalName>
     </EmbeddedResource>
     <EmbeddedResource Include="ui\LQIsExplorer.crow" />
-    <EmbeddedResource Include="Default.style" />
     <EmbeddedResource Include="ui\GTreeExplorer.crow" />
     <EmbeddedResource Include="ui\GTreeExpITemp.crow" />
     <EmbeddedResource Include="ui\MemberView.crow" />
+    <EmbeddedResource Include="ui\MenuItem.template">
+      <LogicalName>Crow.MenuItem.template</LogicalName>
+    </EmbeddedResource>
   </ItemGroup>
   <ItemGroup>
     <None Include="ui\test.crow">
diff --git a/CrowIDE/Default.style b/CrowIDE/Default.style
deleted file mode 100644 (file)
index 19be18b..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-TextBox {
-       Margin = 1;
-}
\ No newline at end of file
index afaab3a41ed5160f9597c956e2c0b7c74baee99e..55a907b234cd2d8c06be2a4b2778c222a539d60a 100644 (file)
@@ -31,6 +31,16 @@ namespace CrowIDE
 {
        class CrowIDE : OpenTKGameWindow
        {
+               public Command CMDLoad = new Command(new Action(() => System.Diagnostics.Debug.WriteLine("Open"))) { Caption = "Open", Icon = new SvgPicture("#Crow.Icons.open-file.svg")};
+               public Command CMDSave = new Command(new Action(() => System.Diagnostics.Debug.WriteLine("Save"))) { Caption = "Save", Icon = new SvgPicture("#Crow.Icons.open-file.svg")};
+               public Command CMDQuit = new Command(new Action(() => System.Diagnostics.Debug.WriteLine("Quit"))) { Caption = "Quit", Icon = new SvgPicture("#Crow.Icons.exit-symbol.svg")};
+//             public Command CMDSave = new Command(actionOpenFile) { Caption = "Open...", Icon = new SvgPicture("#Crow.Icons.open-file.svg")};
+//             public Command CMDQuit = new Command(actionOpenFile) { Caption = "Open...", Icon = new SvgPicture("#Crow.Icons.open-file.svg")};
+               public Command CMDCut = new Command(new Action(() => System.Diagnostics.Debug.WriteLine("Cut"))) { Caption = "Cut", Icon = new SvgPicture("#Crow.Icons.scissors.svg")};
+               public Command CMDCopy = new Command(new Action(() => System.Diagnostics.Debug.WriteLine("Copy"))) { Caption = "Copy", Icon = new SvgPicture("#Crow.Icons.copy-file.svg")};
+               public Command CMDPaste = new Command(new Action(() => System.Diagnostics.Debug.WriteLine("Paste"))) { Caption = "Paste", Icon = new SvgPicture("#Crow.Icons.paste-on-document.svg")};
+               public Command CMDHelp = new Command(new Action(() => System.Diagnostics.Debug.WriteLine("Help"))) { Caption = "Help", Icon = new SvgPicture("#Crow.Icons.question.svg")};
+
                [STAThread]
                static void Main ()
                {
@@ -87,8 +97,13 @@ namespace CrowIDE
                        if (g != null)
                                CrowInterface.DeleteWidget (g);
                }
+
                protected void onCommandSave(object sender, MouseButtonEventArgs e){
                        System.Diagnostics.Debug.WriteLine("save");
                }
+
+               void actionOpenFile(){
+                       System.Diagnostics.Debug.WriteLine ("OpenFile action");
+               }
        }
 }
\ No newline at end of file
index 5d39b25f0f5ced4dfb49ef63f4c05aac51971ff1..ec6f79b3d8f4b154d0d3749f439a22745b8f7798 100644 (file)
@@ -1,9 +1,4 @@
-icon {
-       Focusable=true;
-       Width=32;
-       Height=32;
-       Margin=2;
-       CornerRadius=5;
-       MouseEnter = {Background=UnitedNationsBlue;}
-       MouseLeave = {Background=Transparent;}
+Icon {
+       Width=16;
+       Height=16;
 }
diff --git a/CrowIDE/ui/MenuItem.template b/CrowIDE/ui/MenuItem.template
new file mode 100644 (file)
index 0000000..8a6dfba
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<Popper Font="{./Font}" Caption="{./Caption}"  Background="{./Background}" PopDirection="{./PopDirection}"
+       Foreground = "{./Foreground}" CanPop="{./HasChildren}" MouseClick="./onMI_Click"
+       IsPopped="{²./IsOpened}" PopWidth="{./PopWidth}" PopHeight="{./PopHeight}">
+       <Template>
+               <Border Name="border1"  Margin="4"
+                               MouseEnter="{Foreground=vgradient|0:White|0.2:Gray|0.9:Gray|1:Black}"
+                               MouseLeave="{Foreground=Transparent}"
+                               MouseDown="{Foreground=vgradient|0:Black|0.05:Gray|0.85:Gray|1:White}"
+                               MouseUp="{Foreground=vgradient|0:White|0.2:Gray|0.9:Gray|1:Black}"
+                               Foreground="Transparent"
+                               Background="{./Background}">
+                       <HorizontalStack>                               
+                               <Image MaximumSize="12,12" Picture="{../../../../Icon}"/>
+                               <Label Text="{./Caption}"
+                                       Foreground="{./Foreground}"
+                                       Margin="1" HorizontalAlignment="Left"
+                                       Font="{./Font}" />
+                       </HorizontalStack>
+               </Border>
+       </Template>
+       <Border Foreground="DimGray" Width="{../PopWidth}" Height="{../PopHeight}" Background="Onyx">
+               <VerticalStack Name="ItemsContainer"/>
+       </Border>
+</Popper>
index ad589bcb4651486eb3575a272d17da9ef4186768..97df6eb5e680011b251a1e8d16737b2c2dc0d564 100644 (file)
@@ -1,26 +1,26 @@
 <?xml version="1.0"?>
-<Window Height="99%" Width="99%" >
+<Window Height="Stretched" Width="Stretched" >
        <VerticalStack>
                <Menu>
-                       <MenuItem Caption="File">
-                               <MenuItem Caption="New"></MenuItem>
-                               <MenuItem Caption="Open"></MenuItem>
-                               <MenuItem Caption="Save"></MenuItem>
-                               <MenuItem Caption="Quit"></MenuItem>
+                       <MenuItem Caption="File" Fit="True" PopWidth="200">
+                               <MenuItem Command="{CMDLoad}"/>
+                               <MenuItem Command="{CMDLoad}"/>
+                               <MenuItem Command="{CMDSave}"/>
+                               <MenuItem Command="{CMDQuit}"/>
                        </MenuItem>
-                       <MenuItem Caption="Edit">
-                               <MenuItem Caption="Cut"/>
-                               <MenuItem Caption="Copy"/>
-                               <MenuItem Caption="Paste"/>
+                       <MenuItem Caption="Edit" Fit="true" PopWidth="150">
+                               <MenuItem Command="{CMDCut}" Width="Stretched"/>
+                               <MenuItem Command="{CMDCopy}" Width="Stretched"/>
+                               <MenuItem Command="{CMDPaste}" Width="Stretched"/>
                        </MenuItem>
-                       <MenuItem Caption="Help">
-                               <MenuItem Caption="Help"/>
-                               <MenuItem Caption="About"/>
+                       <MenuItem Caption="Help" Fit="true" PopWidth="150">
+                               <MenuItem Command="{CMDHelp}" Width="Stretched"/>
+                               <MenuItem Caption="About" Width="Stretched"/>
                        </MenuItem>
                </Menu>
-               <HorizontalStack Height="Fit" Margin="2">
+<!--           <HorizontalStack Height="Fit" Margin="2">
                        <Image Style="icon" Path="#CrowIDE.images.save.svg" MouseClick="onCommandSave"/>
-               </HorizontalStack>
+               </HorizontalStack>-->
                <Border Margin="1" Background="Onyx" Height="Fit">
                        <Label Width="Stretched" Margin="1" Text="{../../dv.SelectedItem}"/>
                </Border>
index c4a8279e05287ca3628ab1c96b8b83fe705850c8..89e54719ba8f5177034edb3890f5006b72d4c828 100644 (file)
@@ -22,12 +22,10 @@ Menu {
        VerticalAlignment = Top;
 }
 MenuItem {
-       Height = Fit;
-       Width = Fit;
        Background = Transparent;
        Foreground = LightGray;
-       Open = {Background = Mantis;Foreground=Jet;}
-       Close = {Foreground=LightGray;Background=Transparent;}
+       MouseEnter = {Background = vgradient|0:UnitedNationsBlue|1:Onyx;Foreground=White;}
+       MouseLeave = {Foreground=LightGray;Background=Transparent;}
 }
 MessageBox {
        Width=200;
diff --git a/Icons/copy-file.svg b/Icons/copy-file.svg
new file mode 100644 (file)
index 0000000..63c2dd3
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generated by IcoMoon.io -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16">
+<path fill="#FFFFFF" d="M13 3h-3l-3-3h-7v13h6v3h10v-10l-3-3zM7 1l2 2h-2v-2zM1 12v-11h5v3h3v8h-8zM15 15h-8v-2h3v-9h2v3h3v8zM13 6v-2l2 2h-2z"></path>
+</svg>
diff --git a/Icons/exit-symbol.svg b/Icons/exit-symbol.svg
new file mode 100644 (file)
index 0000000..3fbaa0d
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generated by IcoMoon.io -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16">
+<path fill="#FFFFFF" d="M14 6h-1.7c-0.2 0-0.4-0.1-0.6-0.2l-1.3-1.3c-0.2-0.3-0.6-0.5-1.1-0.5h-0.3c1.1 0 2-0.9 2-2s-0.9-2-2-2-2 0.9-2 2c0 0.7 0.4 1.4 1 1.7l-0.2 0.3h-2c-1.1 0-2.3 0.5-3 1.5l-0.6 0.8c-0.4 0.4-0.2 1 0.2 1.3 0.4 0.2 0.9 0.1 1.2-0.3l0.5-0.7c0.3-0.4 0.7-0.6 1.2-0.6h0.8l-0.7 1.6c-0.3 0.6-0.4 1.2-0.4 1.9v2c0 0.3-0.2 0.5-0.5 0.5h-2.5c-0.6 0-1 0.4-1 1s0.4 1 1 1h3.5c0.8 0 1.5-0.7 1.5-1.5v-2.5l3.8 4.5c0.6 0.9 1.7 1.5 2.8 1.5h0.9l-5.4-6.7c-0.3-0.4-0.2-0.8 0-1.3l0.6-1.5 0.7 0.8c0.4 0.4 1 0.7 1.6 0.7h2c0.6 0 1-0.4 1-1s-0.4-1-1-1z"></path>
+</svg>
diff --git a/Icons/open-file.svg b/Icons/open-file.svg
new file mode 100644 (file)
index 0000000..d5c6a84
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generated by IcoMoon.io -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16">
+<path fill="#FFFFFF" d="M 4.0527344 0.24023438 L 4.0527344 2.1777344 L 1.9316406 2.1777344 L 0.93164062 4.1777344 L -0.068359375 4.1777344 L -0.068359375 15.177734 L 13.931641 15.177734 L 15.931641 6.1777344 L 13.759766 6.1777344 L 13.759766 3.4746094 L 10.525391 0.24023438 L 4.0527344 0.24023438 z M 4.8613281 1.0488281 L 9.7148438 1.0488281 L 9.7148438 4.2851562 L 12.951172 4.2851562 L 12.951172 6.1777344 L 4.8613281 6.1777344 L 4.8613281 1.0488281 z M 10.525391 1.0488281 L 12.951172 3.4746094 L 10.525391 3.4746094 L 10.525391 1.0488281 z M 2.53125 3.1777344 L 4.0527344 3.1777344 L 4.0527344 6.1777344 L 2.9316406 6.1777344 L 0.93164062 12.078125 L 0.93164062 5.1777344 L 1.53125 5.1777344 L 2.53125 3.1777344 z M 3.6328125 7.1777344 L 14.832031 7.1777344 L 13.232422 14.177734 L 1.3320312 14.078125 L 3.6328125 7.1777344 z "/>
+</svg>
diff --git a/Icons/paste-on-document.svg b/Icons/paste-on-document.svg
new file mode 100644 (file)
index 0000000..b0a705e
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generated by IcoMoon.io -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16">
+<path fill="#FFFFFF" d="M13 4h-3v-4h-10v14h6v2h10v-9l-3-3zM3 1h4v1h-4v-1zM15 15h-8v-10h5v3h3v7zM13 7v-2l2 2h-2z"></path>
+</svg>
diff --git a/Icons/question.svg b/Icons/question.svg
new file mode 100644 (file)
index 0000000..fb8e3d3
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generated by IcoMoon.io -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16">
+<path fill="#FFFFFF" d="M9 11h-3c0-3 1.6-4 2.7-4.6 0.4-0.2 0.7-0.4 0.9-0.6 0.5-0.5 0.3-1.2 0.2-1.4-0.3-0.7-1-1.4-2.3-1.4-2.1 0-2.5 1.9-2.5 2.3l-3-0.4c0.2-1.7 1.7-4.9 5.5-4.9 2.3 0 4.3 1.3 5.1 3.2 0.7 1.7 0.4 3.5-0.8 4.7-0.5 0.5-1.1 0.8-1.6 1.1-0.9 0.5-1.2 1-1.2 2z"></path>
+<path fill="#FFFFFF" d="M9.5 14c0 1.105-0.895 2-2 2s-2-0.895-2-2c0-1.105 0.895-2 2-2s2 0.895 2 2z"></path>
+</svg>
diff --git a/Icons/scissors.svg b/Icons/scissors.svg
new file mode 100644 (file)
index 0000000..4b5a225
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generated by IcoMoon.io -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16">
+<path fill="#FFFFFF" d="M16 3.1c0 0-2.1-1.1-3.5-1-0.3 0-0.5 0.1-0.7 0.2l-4.3 3.4-1.8-1.5c0.1-0.3 0.2-0.6 0.3-1 0.1-1.8-1.4-3.4-3.3-3.2-1.2 0.1-2.3 1-2.6 2.2-0.3 1.3 0.2 2.5 1.2 3.2l3.3 2.6-3.3 2.6c-1 0.7-1.5 1.9-1.2 3.2 0.3 1.2 1.4 2 2.6 2.2 1.9 0.2 3.4-1.4 3.2-3.2 0-0.3-0.1-0.7-0.3-1l1.8-1.5 4.3 3.4c0.2 0.1 0.4 0.2 0.7 0.2 1.4 0.1 3.5-1 3.5-1l-5.7-4.9 5.8-4.9zM2.8 4.6c-0.9-0.1-1.6-0.9-1.5-1.8s0.9-1.6 1.8-1.5c0.9 0.1 1.6 0.9 1.5 1.8 0 0.9-0.9 1.6-1.8 1.5zM3.1 14.7c-0.9 0.1-1.7-0.6-1.8-1.5s0.6-1.7 1.5-1.8c0.9-0.1 1.7 0.6 1.8 1.5s-0.6 1.7-1.5 1.8zM12.4 3.2c0 0 0.1 0 0.2 0 0.4 0 0.9 0.1 1.4 0.2l-6.8 5.7-0.9-1.1 6.1-4.8zM14 12.6c-0.5 0.2-1 0.3-1.4 0.2-0.1 0-0.2 0-0.2 0l-4-3.2 1-0.9 4.6 3.9z"></path>
+</svg>
index 55d652a9b6bd40689baad8a79aabd1cac26e9eb5..f7c74a9d5922aba6efb6fbe1bbf056c78483d956 100755 (executable)
@@ -6,7 +6,7 @@
                        <Image Margin="2" Width="14" Height="14"
                                Path="#Crow.Images.Icons.file.svg"/>
                        <Label Text="{Name}" Width="Stretched"
-                               MouseEnter="{Background=hgradient|0:BlueCrayola|1:Transparent}"
+                               MouseEnter="{Background=vgradient|0:White|0.05:UnitedNationsBlue|1:Jet}"
                                MouseLeave="{Background=Transparent}"/>
                </HorizontalStack>
        </ItemTemplate>
@@ -15,7 +15,7 @@
                        <Template>
                                <VerticalStack>
                                        <HorizontalStack Spacing="1" Height="Fit" MouseDoubleClick="./onClickForExpand"
-                                                       MouseEnter="{Background=hgradient|0:BlueCrayola|1:Transparent}"
+                                                       MouseEnter="{Background=vgradient|0:White|0.05:UnitedNationsBlue|1:Jet}"
                                                        MouseLeave="{Background=Transparent}">
                                                <Container Margin="1" Width="10" Height="10" Focusable="true" MouseClick="./onClickForExpand"
                                                        MouseEnter="{Background=LightGray}"
index 2f4400ecb34a2558671200b3ce26fa683351c18b..311cd3ef375dbac486094a38960d1845d56ccbf8 100644 (file)
                                MinimumSize = "60,0"
                                Foreground="Transparent"
                                Background="{./Background}">
-                       <Label Text="{./Caption}"
-                               Foreground="{./Foreground}"
-                               Margin="1" HorizontalAlignment="Left"
-                               Font="{./Font}" />
+                       <HorizontalStack>
+                               <Image Style="Icon" Picture="{../../../../Icon}"/>
+                               <Label Text="{./Caption}"
+                                       Foreground="{./Foreground}"
+                                       Margin="3" HorizontalAlignment="Left"
+                                       Font="{./Font}" />
+                       </HorizontalStack>
                </Border>
        </Template>
        <Border Foreground="DimGray" Fit="true">
-               <VerticalStack Name="ItemsContainer" Margin="2" Fit="true" Background="Onyx"/>
+               <VerticalStack Name="ItemsContainer" Margin="0" Fit="true" Background="Onyx"/>
        </Border>
 </Popper>
index 35a7facc69e53c8064b04dbf16a3559dfe4fb078..f7a12465f623bc90664b0bce3d68b93d8f2d1a00 100644 (file)
@@ -35,16 +35,20 @@ namespace Crow
                #endregion
 
                #region CTOR
-               public Command ()
+               public Command (Action _executeAction)
                {
+                       execute = _executeAction;
                }
                #endregion
 
+               Action execute;
+
                string caption;
+               Picture icon;
                bool isEnabled;
 
-
-               [XmlAttributeAttribute()][DefaultValue(true)]
+               #region Public properties
+               [XmlAttributeAttribute][DefaultValue(true)]
                public virtual bool IsEnabled {
                        get { return isEnabled; }
                        set {
@@ -54,7 +58,7 @@ namespace Crow
                                NotifyValueChanged ("IsEnabled", isEnabled);
                        }
                }
-               [XmlAttributeAttribute()][DefaultValue("Unamed Command")]
+               [XmlAttributeAttribute][DefaultValue("Unamed Command")]
                public virtual string Caption {
                        get { return caption; }
                        set {
@@ -65,5 +69,27 @@ namespace Crow
 
                        }
                }
+               [XmlAttributeAttribute]
+               public Picture Icon {
+                       get { return icon; }
+                       set {
+                               if (icon == value)
+                                       return;
+                               icon = value;
+                               NotifyValueChanged ("Icon", icon);
+                       }
+               }
+               #endregion
+
+               public void Execute(){
+                       if (execute != null)
+                               execute ();
+               }
+               internal void raiseAllValuesChanged(){
+                       NotifyValueChanged ("IsEnabled", isEnabled);
+                       NotifyValueChanged ("Icon", icon);
+                       NotifyValueChanged ("Caption", caption);
+               }
+
        }
 }
index 1cfbe85c722272b798ca161c1295daf001b3fed7..c73062f0da5aa597040417f26705ca7e0877060e 100644 (file)
@@ -26,7 +26,6 @@ namespace Crow
 
                public event EventHandler Pressed;
                public event EventHandler Released;
-               public event EventHandler Clicked;
 
                #region TemplatedContainer overrides
                public override GraphicObject Content {
@@ -34,7 +33,7 @@ namespace Crow
                                return _contentContainer == null ? null : _contentContainer.Child;
                        }
                        set {
-                               if (_contentContainer != null)                                  
+                               if (_contentContainer != null)
                                        _contentContainer.SetChild(value);
                        }
                }
@@ -69,24 +68,24 @@ namespace Crow
 
                [XmlAttributeAttribute][DefaultValue("Button")]
                public string Caption {
-                       get { return caption; } 
+                       get { return caption; }
                        set {
                                if (caption == value)
                                        return;
-                               caption = value; 
+                               caption = value;
                                NotifyValueChanged ("Caption", caption);
                        }
-               }        
+               }
                [XmlAttributeAttribute][DefaultValue("#Crow.Images.button.svg")]
                public string Image {
-                       get { return image; } 
+                       get { return image; }
                        set {
                                if (image == value)
                                        return;
-                               image = value; 
+                               image = value;
                                NotifyValueChanged ("Image", image);
                        }
-               } 
+               }
                [XmlAttributeAttribute][DefaultValue(false)]
                public bool IsPressed
                {
index fa036b97f4cdd770a40a6810a37144b4589e09d4..281011ad886acd29131ea949bf7c5c405fd97864 100644 (file)
@@ -11,66 +11,81 @@ namespace Crow
        {
                Picture _pic;
                string _svgSub;
-               bool scaled;
-               [XmlAttributeAttribute()][DefaultValue(true)]
+               bool scaled, keepProps;
+
+               #region Public properties
+               [XmlAttributeAttribute][DefaultValue(true)]
                public virtual bool Scaled {
                        get { return scaled; }
                        set {
                                if (scaled == value)
                                        return;
-                               scaled = value; 
+                               scaled = value;
                                NotifyValueChanged ("Scaled", scaled);
                                if (_pic == null)
                                        return;
                                _pic.Scaled = scaled;
                                RegisterForGraphicUpdate ();
                        }
-               } 
-               bool keepProps;
-               [XmlAttributeAttribute()][DefaultValue(true)]
+               }
+               [XmlAttributeAttribute][DefaultValue(true)]
                public virtual bool KeepProportions {
                        get { return keepProps; }
                        set {
                                if (keepProps == value)
                                        return;
-                               keepProps = value; 
+                               keepProps = value;
                                NotifyValueChanged ("KeepProportions", keepProps);
                                if (_pic == null)
                                        return;
                                _pic.KeepProportions = keepProps;
                                RegisterForGraphicUpdate ();
                        }
-               } 
-        [XmlAttributeAttribute("Path")]        
+               }
+        [XmlAttributeAttribute]
                public string Path {
-                       get { return _pic == null ? null : _pic.Path; }
-                       set {   
+                       get { return _pic == null ? "" : _pic.Path; }
+                       set {
+                               if (value == Path)
+                                       return;
                                try {
-                                       if (string.IsNullOrEmpty(value)){
-                                               _pic = null;
-                                               return;
-                                       }
-                                       lock(CurrentInterface.LayoutMutex){
-                                               LoadImage (value);
-                                               _pic.Scaled = scaled;
-                                               _pic.KeepProportions = keepProps;
+                                       if (string.IsNullOrEmpty(value))
+                                               Picture = null;
+                                       else {
+                                               lock(CurrentInterface.LayoutMutex){
+                                                       LoadImage (value);
+                                               }
                                        }
                                } catch (Exception ex) {
                                        Debug.WriteLine (ex.Message);
                                        _pic = null;
                                }
+                               NotifyValueChanged ("Path", Path);
                        }
                }
-
-               [XmlAttributeAttribute()][DefaultValue(null)]
+               [XmlAttributeAttribute]
                public string SvgSub {
                        get { return _svgSub; }
                        set {
+                               if (_svgSub == value)
+                                       return;
                                _svgSub = value;
                                RegisterForGraphicUpdate ();
                        }
                }
-                       
+               [XmlAttributeAttribute]
+               public Picture Picture {
+                       get { return _pic; }
+                       set {
+                               if (_pic == value)
+                                       return;
+                               _pic = value;
+                               NotifyValueChanged ("Picture", _pic);
+                               RegisterForGraphicUpdate ();
+                       }
+               }
+               #endregion
+
                #region CTOR
                public Image () : base()
                {
@@ -80,14 +95,17 @@ namespace Crow
                #region Image Loading
                public void LoadImage (string path)
                {
+                       Picture pic;
+                       if (path.EndsWith (".svg", true, System.Globalization.CultureInfo.InvariantCulture))
+                               pic = new SvgPicture ();
+                       else
+                               pic = new BmpPicture ();
 
-                       if (path.EndsWith (".svg", true, System.Globalization.CultureInfo.InvariantCulture)) 
-                               _pic = new SvgPicture ();
-                       else 
-                               _pic = new BmpPicture ();
+                       pic.LoadImage (path);
+                       pic.Scaled = scaled;
+                       pic.KeepProportions = keepProps;
 
-                       _pic.LoadImage (path);
-                       RegisterForGraphicUpdate ();
+                       Picture = pic;
                }
                #endregion
 
@@ -95,12 +113,13 @@ namespace Crow
                protected override int measureRawSize (LayoutingType lt)
                {
                        if (_pic == null)
-                               _pic = "#Crow.Images.Icons.IconAlerte.svg";
+                               return 2 * Margin;
+                               //_pic = "#Crow.Images.Icons.IconAlerte.svg";
                        //TODO:take scalling in account
                        if (lt == LayoutingType.Width)
                                return _pic.Dimensions.Width + 2 * Margin;
                        else
-                               return _pic.Dimensions.Height + 2 * Margin;                     
+                               return _pic.Dimensions.Height + 2 * Margin;
                }
                protected override void onDraw (Context gr)
                {
index 1a7a3f95e2a3e5ce3d4600705a89158875d03f80..66d23194141d0a7604d3dfddd0c35d9ae305ad39 100644 (file)
@@ -31,8 +31,10 @@ namespace Crow
                #endregion
 
                Orientation orientation;
+               bool autoOpen = false;
 
-               [XmlAttributeAttribute()][DefaultValue(Orientation.Horizontal)]
+               #region Public properties
+               [XmlAttributeAttribute][DefaultValue(Orientation.Horizontal)]
                public Orientation Orientation {
                        get { return orientation; }
                        set {
@@ -42,12 +44,12 @@ namespace Crow
                                NotifyValueChanged ("Orientation", orientation);
                        }
                }
-               bool autoOpen = false;
                [XmlIgnore]public bool AutomaticOpenning
                {
                        get { return autoOpen; }
                        set     { autoOpen = value;     }
                }
+               #endregion
 
                public override void AddItem (GraphicObject g)
                {                       
index 80b5759da97bd5078e532dcaf47e39da29afda20..adec326f777bbb3d2d5bd3e7a0869941f831e538 100644 (file)
@@ -32,12 +32,14 @@ namespace Crow
 
                public event EventHandler Open;
                public event EventHandler Close;
-               public event EventHandler Execute;
 
                string caption;
-               Command command;//TODO
+               Command command;
+               Picture icon;
                bool isOpened;
+               Measure popWidth, popHeight;
 
+               #region Public properties
                [XmlAttributeAttribute][DefaultValue(false)]
                public bool IsOpened {
                        get { return isOpened; }
@@ -54,38 +56,87 @@ namespace Crow
                                        onClose (this, null);
                        }
                }
-
                [XmlAttributeAttribute][DefaultValue(null)]
                public virtual Command Command {
                        get { return command; }
                        set {
                                if (command == value)
                                        return;
+
+                               if (command != null) {
+                                       command.raiseAllValuesChanged ();
+                                       command.ValueChanged -= Command_ValueChanged;
+                               }
+
                                command = value;
+
+                               if (command != null) {
+                                       command.ValueChanged += Command_ValueChanged;
+                                       command.raiseAllValuesChanged ();
+                               }
+
                                NotifyValueChanged ("Command", command);
                        }
                }
-
                [XmlAttributeAttribute][DefaultValue("MenuItem")]
                public string Caption {
-                       get { return caption; }
+                       get { return Command == null ? caption : Command.Caption; }
                        set {
                                if (caption == value)
                                        return;
                                caption = value;
-                               NotifyValueChanged ("Caption", caption);
+
+                               if (command == null)//raise value changed only if not bound to a command
+                                       NotifyValueChanged ("Caption", caption);
+                       }
+               }
+               [XmlAttributeAttribute]
+               public Picture Icon {
+                       get { return Command == null ? icon : Command.Icon;; }
+                       set {
+                               if (icon == value)
+                                       return;
+                               icon = value;
+                               if (command == null)
+                                       NotifyValueChanged ("Icon", icon);
                        }
                }
-                       
+               [XmlAttributeAttribute()][DefaultValue("Fit")]
+               public virtual Measure PopWidth {
+                       get { return popWidth; }
+                       set {
+                               if (popWidth == value)
+                                       return;
+                               popWidth = value;
+                               NotifyValueChanged ("PopWidth", popWidth);
+                       }
+               }
+               [XmlAttributeAttribute()][DefaultValue("Fit")]
+               public virtual Measure PopHeight {
+                       get { return popHeight; }
+                       set {
+                               if (popHeight == value)
+                                       return;
+                               popHeight = value;
+                               NotifyValueChanged ("PopHeight", popHeight);
+                       }
+               }
+               #endregion
+
                public override void AddItem (GraphicObject g)
                {
                        base.AddItem (g);
                        g.NotifyValueChanged ("PopDirection", Alignment.Right);
                }
 
+               void Command_ValueChanged (object sender, ValueChangeEventArgs e)
+               {
+                       NotifyValueChanged (e.MemberName, e.NewValue);
+               }
                void onMI_Click (object sender, MouseButtonEventArgs e)
                {
-                       Execute.Raise (this, null);
+                       if (command != null)
+                               command.Execute ();
                        if(!IsOpened)
                                (LogicalParent as Menu).AutomaticOpenning = false;
                }
index 84088355e767bae43f18e0931c0ee3e4027f3b0d..8c79ce24f07ff60b99a47665c9f45719ede31733 100644 (file)
@@ -38,6 +38,7 @@ namespace Crow
                string caption;
                Alignment popDirection;
                GraphicObject _content;
+               Measure popWidth, popHeight;
 
                public event EventHandler Pop;
                public event EventHandler Unpop;
@@ -53,6 +54,26 @@ namespace Crow
                                NotifyValueChanged ("Caption", caption);
                        }
                }
+               [XmlAttributeAttribute()][DefaultValue("Fit")]
+               public virtual Measure PopWidth {
+                       get { return popWidth; }
+                       set {
+                               if (popWidth == value)
+                                       return;
+                               popWidth = value;
+                               NotifyValueChanged ("PopWidth", popWidth);
+                       }
+               }
+               [XmlAttributeAttribute()][DefaultValue("Fit")]
+               public virtual Measure PopHeight {
+                       get { return popHeight; }
+                       set {
+                               if (popHeight == value)
+                                       return;
+                               popHeight = value;
+                               NotifyValueChanged ("PopHeight", popHeight);
+                       }
+               }
                [XmlAttributeAttribute()][DefaultValue(false)]
                public bool IsPopped
                {
@@ -164,18 +185,6 @@ namespace Crow
                }
 
                #region GraphicObject overrides
-               public override void OnLayoutChanges (LayoutingType layoutType)
-               {
-                       base.OnLayoutChanges (layoutType);
-
-                       if (_content == null)
-                               return;
-
-                       if (layoutType == LayoutingType.Width)
-                               _content.MinimumSize = new Size (this.Slot.Width, _content.MinimumSize.Height);
-               }
-
-
                public override void onMouseClick (object sender, MouseButtonEventArgs e)
                {
                        if (_canPop)