]> O.S.I.I.S - jp/crow.git/commitdiff
Different temp items in Obj property tab depending on property type
authorjpbruyere <jp.bruyere@hotmail.com>
Tue, 18 Oct 2016 16:09:47 +0000 (18:09 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Tue, 18 Oct 2016 16:09:47 +0000 (18:09 +0200)
modifié :         CrowIDE/CrowIDE.csproj
modifié :         CrowIDE/src/MembersView.cs
modifié :         CrowIDE/ui/imlEditor.crow

CrowIDE/CrowIDE.csproj
CrowIDE/src/MembersView.cs
CrowIDE/ui/imlEditor.crow

index 8c8f4bf98774933f2142d8bca1279c2ce930bdfa..0320b3437cbb979f96f4eee24f3a58af8a921a07 100644 (file)
@@ -17,7 +17,7 @@
        <Command type="Execute" command="${TargetName}" workingdir="${SolutionDir}/build/${ProjectConfigName}" />
       </CustomCommands>
     </CustomCommands>
-    <ReleaseVersion>0.4</ReleaseVersion>
+    <ReleaseVersion>0.5</ReleaseVersion>
     <StartupObject>CrowIDE.CrowIDE</StartupObject>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -99,4 +99,4 @@
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
   </ItemGroup>
-</Project>
\ No newline at end of file
+</Project>
index 52f8da0413db23401c0638bb9cf9fcb24cc0f147..3f250dd96229adc2769cd4fb8b9fe909b59ae169 100644 (file)
@@ -27,12 +27,57 @@ using System.Collections.Generic;
 
 namespace CrowIDE
 {
-       public class PropertyContainer {
+       public class PropertyContainer : IBindable
+       {
+               public object DataSource {
+                       get {
+                               throw new NotImplementedException ();
+                       }
+                       set {
+                               throw new NotImplementedException ();
+                       }
+               }
+
+               #region IBindable implementation
+               List<Binding> bindings = new List<Binding> ();
+               public List<Binding> Bindings {
+                       get { return bindings; }
+               }
+               #endregion
+
                PropertyInfo pi;
                object instance;
 
                public string Name { get { return pi.Name; }}
-               public object Value { get { return pi.GetValue(instance); }}
+               public object Value {
+                       get { return pi.GetValue(instance); }
+                       set {
+                               try {
+                                       if (pi.PropertyType != value.GetType() && pi.PropertyType != typeof(string)){
+                                               if (pi.PropertyType.IsEnum) {
+                                                       pi.SetValue (instance, value);
+                                               } else {
+                                                       MethodInfo me = pi.PropertyType.GetMethod
+                                                               ("Parse", BindingFlags.Static | BindingFlags.Public,
+                                                                       System.Type.DefaultBinder, new Type [] {typeof (string)},null);
+                                                       pi.SetValue (instance, me.Invoke (null, new object[] { value }), null);
+                                               }
+                                       }else
+                                               pi.SetValue(instance, value);
+                               } catch (Exception ex) {
+                                       System.Diagnostics.Debug.WriteLine ("Error setting property:"+ ex.ToString());
+                               }
+
+                       }
+               }
+               public string Type { get { return pi.PropertyType.IsEnum ?
+                                       "System.Enum"
+                                       : pi.PropertyType.FullName; }}
+               public string[] Choices {
+                       get {
+                               return Enum.GetNames (pi.PropertyType);
+                       }
+               }
 
                public PropertyContainer(PropertyInfo prop, object _instance){
                        pi = prop;
index dae1c84ffa3c38be6349cf27ce78a8038a7adec7..984394f6f753971916a85db540b3368b0118c004 100644 (file)
                                </HorizontalStack>
                        </VerticalStack>
                        <Splitter/>
-                       <MembersView Width="20%" Instance="{../crowContainer.SelectedItem}">
-                               <ItemTemplate DataType="CrowIDE.PropertyContainer">
-                                       <HorizontalStack Focusable="true"  Height="Fit" Width="Stretched" Spacing="0"
+                       <MembersView Width="20%" Instance="{../crowContainer.SelectedItem}" DataTest="Type">
+                               <Template>
+                                       <Scroller  Name="scroller1" Margin="1" VerticalScrolling="true"
+                                               ValueChanged="./_scroller_ValueChanged">
+                                               <VerticalStack LayoutChanged="./_list_LayoutChanged" Spacing="0"
+                                                       Height="Fit" Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
+                                       </Scroller>
+                               </Template>
+                               <ItemTemplate>
+                                       <HorizontalStack Focusable="true"  Height="Fit" Spacing="0"
+                                                       MouseEnter="{Background=UnitedNationsBlue}"
+                                                       MouseLeave="{Background=Transparent}" >
+                                               <Label Margin="1" Text="{Name}" Height="Fit" Width="50%"/>
+                                               <TextBox Margin="1" Text="{²Value}" Height="Fit" Width="50%"/>
+                                       </HorizontalStack>
+                               </ItemTemplate>
+                               <ItemTemplate DataType="System.Boolean">
+                                       <HorizontalStack Focusable="true"  Height="Fit" Spacing="0"
+                                                       MouseEnter="{Background=UnitedNationsBlue}"
+                                                       MouseLeave="{Background=Transparent}" >
+                                               <Label Margin="1" Text="{Name}" Height="Fit" Width="50%"/>
+                                               <CheckBox Background="White" Margin="1" Caption="" IsChecked="{²Value}"/>
+                                       </HorizontalStack>
+                               </ItemTemplate>
+-                              <ItemTemplate DataType="System.Enum">
+                                       <HorizontalStack Focusable="true"  Height="Fit" Spacing="0"
                                                        MouseEnter="{Background=UnitedNationsBlue}"
                                                        MouseLeave="{Background=Transparent}" >
-                                               <Border Height="Fit" Width="50%" Foreground="DimGray">
-                                                       <Label Margin="1" Text="{Name}" Height="Stretched" Width="Stretched"/>
-                                               </Border>
-                                               <Border Height="Fit" Width="50%" Foreground="DimGray">
-                                                       <TextBox Margin="1" Text="{Value}" Height="Stretched" Width="Stretched"/>
-                                               </Border>
+                                               <Label Margin="1" Text="{Name}" Height="Fit" Width="50%"/>
+                                               <ComboBox Margin="1"  Height="Fit" Width="50%" Data="{Choices}"
+                                                               SelectedIndex="{²Value}">
+                                                       <Template>
+                                                               <Popper Name="popper" PopDirection="Bottom">
+                                                                       <Template>
+                                                                               <Border CornerRadius="0" Foreground="LightGray" Background="White">
+                                                                                       <HorizontalStack Margin="0" Spacing="1">
+                                                                                               <Label Width="Stretched" MinimumSize="80,10" Margin="1" Foreground="Black" Background="White"
+                                                                                                       Text="{../../../../SelectedItem}"/>
+                                                                                               <Button Width="12" Height="12" Focusable="false"
+                                                                                                       Template="#Crow.Templates.ArrowButTemplate.crow">
+                                                                                                       <Image Margin="1"  Path="#Crow.Images.Icons.updown.svg" SvgSub="down"/>
+                                                                                               </Button>
+                                                                                       </HorizontalStack>
+                                                                               </Border>
+                                                                       </Template>
+                                                                       <Border Background="White" BorderWidth="1" Margin="1" Foreground="Black"
+                                                                               MinimumSize="{../../MinimumPopupSize}" Fit="true">
+                                                                               <Scroller Name="scroller1" Margin="2" VerticalScrolling="true"
+                                                                                       MaximumSize="0,200"
+                                                                                       HorizontalAlignment="Left"
+                                                                                       ValueChanged="../../../_scroller_ValueChanged">
+                                                                                       <VerticalStack LayoutChanged="../../../../_list_LayoutChanged"
+                                                                                               MouseClick="../../../onMouseClick" Focusable="True"
+                                                                                               Height="Fit" Name="ItemsContainer" Margin="0"
+                                                                                               HorizontalAlignment="Left"
+                                                                                               VerticalAlignment="Top"/>
+                                                                               </Scroller>
+                                                                       </Border>
+                                                               </Popper>
+                                                       </Template>
+                                                       <ItemTemplate>
+                                                               <Container Fit="true" Margin="0" Focusable="true"
+                                                                               HorizontalAlignment="Left"
+                                                                               MouseEnter="{Background=SteelBlue}"
+                                                                               MouseLeave="{Background=Transparent}">
+                                                                       <Label Text="{}" Foreground="Black"/>
+                                                               </Container>
+                                                       </ItemTemplate>
+                                               </ComboBox>
                                        </HorizontalStack>
                                </ItemTemplate>
                        </MembersView>