<Compile Include="src\GraphicObjects\TemplatedControl.cs" />\r
<Compile Include="src\GraphicObjects\Checkbox.cs" />\r
<Compile Include="src\GraphicObjects\RadioButton.cs" />\r
+ <Compile Include="src\GraphicObjects\Expandable.cs" />\r
+ <Compile Include="src\GraphicObjects\PrivateContainer.cs" />\r
</ItemGroup>\r
<ItemGroup>\r
<Reference Include="System" />\r
<EmbeddedResource Include="Templates\Spinner %28copier%29.goml" />\r
<EmbeddedResource Include="Templates\ItemTemplate.goml" />\r
<EmbeddedResource Include="Templates\ComboListOverlay.goml" />\r
+ <EmbeddedResource Include="Templates\Expandable.goml" />\r
+ <EmbeddedResource Include="Images\Icons\expandable.svg" />\r
</ItemGroup>\r
</Project>\r
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="68.136505mm"
- height="23.384127mm"
- viewBox="0 0 241.42856 82.857141"
+ width="241.42857"
+ height="87.85714"
+ viewBox="0 0 241.42858 87.857136"
id="svg6194"
version="1.1"
inkscape:version="0.91 r13725"
id="defs6196">
<linearGradient
inkscape:collect="always"
- xlink:href="#linearGradient6159"
- id="linearGradient6147"
- gradientUnits="userSpaceOnUse"
- gradientTransform="translate(-5.0507576,-7.0710656)"
- x1="-94.577568"
- y1="155.6501"
- x2="-94.577568"
- y2="239.49275" />
- <linearGradient
- id="linearGradient6159"
- inkscape:collect="always">
+ id="linearGradient5895">
<stop
- id="stop6161"
+ style="stop-color:#ffffff;stop-opacity:1"
offset="0"
- style="stop-color:#787878;stop-opacity:1" />
- <stop
- style="stop-color:#909090;stop-opacity:1;"
- offset="0.19879514"
- id="stop6165" />
+ id="stop4179" />
<stop
- id="stop6163"
+ style="stop-color:#a9a9a9;stop-opacity:1"
offset="1"
- style="stop-color:#a8a8a8;stop-opacity:1" />
+ id="stop4181" />
</linearGradient>
<radialGradient
inkscape:collect="always"
x2="-94.577568"
y2="239.49275"
gradientUnits="userSpaceOnUse"
- gradientTransform="translate(-5.0507576,-7.0710656)" />
+ gradientTransform="translate(216.17265,-155.05841)" />
<linearGradient
inkscape:collect="always"
- id="linearGradient5895">
- <stop
- style="stop-color:#ffffff;stop-opacity:1;"
- offset="0"
- id="stop5897" />
- <stop
- style="stop-color:#e4e4e4;stop-opacity:1"
- offset="1"
- id="stop5899" />
- </linearGradient>
+ xlink:href="#linearGradient5895"
+ id="linearGradient4185"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(216.17265,-155.05841)"
+ x1="-94.577568"
+ y1="155.6501"
+ x2="-94.577568"
+ y2="239.49275" />
</defs>
<sodipodi:namedview
id="base"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="0.35"
- inkscape:cx="-201.37781"
- inkscape:cy="-300.43329"
+ inkscape:zoom="1.979899"
+ inkscape:cx="34.707974"
+ inkscape:cy="28.122813"
inkscape:document-units="px"
- inkscape:current-layer="layer1"
+ inkscape:current-layer="svg6194"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
inkscape:window-height="984"
inkscape:window-x="0"
inkscape:window-y="16"
- inkscape:window-maximized="1" />
+ inkscape:window-maximized="1"
+ units="px" />
<metadata
id="metadata6199">
<rdf:RDF>
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
- inkscape:label="Calque 1"
- inkscape:groupmode="layer"
- id="layer1"
- transform="translate(219.33647,-149.07178)">
- <g
- id="normal">
- <rect
- ry="20.854177"
- y="150.58701"
- x="-219.33647"
- height="82.85714"
- width="241.42857"
- id="rect5893-7"
- style="opacity:1;fill:url(#radialGradient5944);fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <rect
- ry="20.854177"
- y="149.07178"
- x="-219.33647"
- height="82.85714"
- width="241.42857"
- id="rect5893"
- style="opacity:1;fill:url(#linearGradient5901);fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- </g>
- <g
- id="pressed">
- <rect
- ry="20.854177"
- y="150.58701"
- x="-219.33647"
- height="82.85714"
- width="241.42857"
- id="rect5893-7-4"
- style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <rect
- ry="20.854177"
- y="149.07178"
- x="-219.33647"
- height="82.85714"
- width="241.42857"
- id="rect5893-6"
- style="opacity:1;fill:url(#linearGradient6147);fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- </g>
+ id="normal">
+ <rect
+ ry="20.854177"
+ y="5"
+ x="0"
+ height="82.85714"
+ width="241.42857"
+ id="rect5893-7"
+ style="opacity:1;fill:url(#radialGradient5944);fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <rect
+ ry="20.854177"
+ y="0"
+ x="0"
+ height="82.85714"
+ width="241.42857"
+ id="rect5893"
+ style="opacity:1;fill:url(#linearGradient5901);fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ </g>
+ <g
+ id="pressed">
+ <rect
+ style="opacity:1;fill:#616161;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect4159"
+ width="241.42857"
+ height="82.85714"
+ x="0"
+ y="0"
+ ry="20.854177" />
+ <rect
+ style="opacity:1;fill:url(#linearGradient4185);fill-opacity:1.0;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect4161"
+ width="241.42857"
+ height="82.85714"
+ x="0"
+ y="2"
+ ry="20.854177" />
</g>
</svg>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="64"
+ height="64"
+ viewBox="0 0 64 64.000002"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.91 r13725"
+ sodipodi:docname="expandable.svg">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="6.6713043"
+ inkscape:cx="34.688233"
+ inkscape:cy="18.992144"
+ inkscape:document-units="px"
+ inkscape:current-layer="svg2"
+ showgrid="false"
+ units="px"
+ inkscape:window-width="1280"
+ inkscape:window-height="984"
+ inkscape:window-x="0"
+ inkscape:window-y="16"
+ inkscape:window-maximized="1" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ id="collapsed">
+ <rect
+ ry="8.8907347"
+ y="4.3914709"
+ x="4.4468598"
+ height="55.122551"
+ width="55.122551"
+ id="rect4136"
+ style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:8.89073467;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path4177"
+ d="m 32.008136,12.393132 0,39.11923"
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:8.89073467;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path4181"
+ d="m 12.448521,31.952746 39.119231,0"
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:8.89073467;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ </g>
+ <g
+ id="expanded">
+ <rect
+ style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:8.89073467;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:1"
+ id="rect4190"
+ width="55.122551"
+ height="55.122551"
+ x="4.4468598"
+ y="4.3914709"
+ ry="8.8907347" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:8.89073467;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 12.448521,31.952746 39.119231,0"
+ id="path4194"
+ inkscape:connector-curvature="0" />
+ </g>
+</svg>
--- /dev/null
+<?xml version="1.0"?>\r
+<Border BorderWidth="1" BorderColor="LightGray" Height="-1" Width="0" MouseClick="onMouseClick">\r
+ <VerticalStack MouseClick="onMouseClick" Height="-1" Width="0" Name="vsTemplateExpander">\r
+ <HorizontalStack Name="hsTemplateExpander" Spacing="1" Focusable="false" Height="-1" Width="0">\r
+ <Image Name="Image" Margin="3" Width="16" Height="16" Path="#go.Images.Icons.expandable.svg"/>\r
+ <Label Name="Caption"/>\r
+ </HorizontalStack>\r
+ <Container Name="Content" Visible="false"/>\r
+ </VerticalStack>\r
+</Border>
\ No newline at end of file
#region FPS\r
static int _fps = 0;\r
\r
- public static int fps {\r
+ public int fps {\r
get { return _fps; }\r
set {\r
+ if (_fps == value)\r
+ return;\r
+\r
+ int oldVal = _fps;\r
_fps = value;\r
- if (_fps > fpsMax)\r
+\r
+ if (_fps > fpsMax) {\r
fpsMax = _fps;\r
- else if (_fps < fpsMin)\r
+ ValueChanged.Raise(this, new ValueChangeEventArgs ("fpsMax", fpsMax, _fps));\r
+ } else if (_fps < fpsMin) {\r
+ ValueChanged.Raise(this, new ValueChangeEventArgs ("fpsMin", fpsMin, _fps));\r
fpsMin = _fps;\r
- }\r
+ }\r
\r
+ if (ValueChanged != null)\r
+ ValueChanged.Raise(this, new ValueChangeEventArgs ("fps", oldVal, _fps));\r
+\r
+ //ValueChanged.Raise (this, new ValueChangeEventArgs ("fps", oldVal, _fps));\r
+ }\r
}\r
\r
- public static int fpsMin = int.MaxValue;\r
+ public static int fpsMin = 0;\r
public static int fpsMax = 0;\r
\r
static void resetFps ()\r
\r
fps = (int)RenderFrequency;\r
\r
- labFps.Text = fps.ToString();\r
labUpdate.Text = this.updateTime.ElapsedMilliseconds.ToString() + " ms";\r
+\r
if (frameCpt > 200) {\r
- labFpsMin.Text = fpsMin.ToString();\r
- labFpsMax.Text = fpsMax.ToString();\r
resetFps ();\r
frameCpt = 0;\r
\r
--- /dev/null
+#define MONO_CAIRO_DEBUG_DISPOSE\r
+\r
+\r
+using System;\r
+using System.Runtime.InteropServices;\r
+using OpenTK;\r
+using OpenTK.Graphics.OpenGL;\r
+using OpenTK.Input;\r
+\r
+using System.Diagnostics;\r
+\r
+//using GGL;\r
+using go;\r
+using System.Threading;\r
+\r
+\r
+namespace test\r
+{\r
+ class GOLIBTest_Expandable : OpenTKGameWindow\r
+ {\r
+ public GOLIBTest_Expandable ()\r
+ : base(1024, 600,"test")\r
+ {}\r
+\r
+ Container g;\r
+\r
+ protected override void OnLoad (EventArgs e)\r
+ {\r
+ base.OnLoad (e);\r
+ LoadInterface("Interfaces/testExpandable.goml", out g);\r
+\r
+ }\r
+ protected override void OnRenderFrame (FrameEventArgs e)\r
+ {\r
+ GL.Clear (ClearBufferMask.ColorBufferBit);\r
+ base.OnRenderFrame (e);\r
+ SwapBuffers ();\r
+ }\r
+\r
+ protected override void OnUpdateFrame (FrameEventArgs e)\r
+ {\r
+ base.OnUpdateFrame (e);\r
+ }\r
+\r
+ [STAThread]\r
+ static void Main ()\r
+ {\r
+ Console.WriteLine ("starting example");\r
+\r
+ using (GOLIBTest_Expandable win = new GOLIBTest_Expandable( )) {\r
+ win.Run (30.0);\r
+ }\r
+ }\r
+ }\r
+}
\ No newline at end of file
WidgetSpacing="1" \r
VerticalAlignment="Top">\r
<VerticalStack Name="vs1" Spacing="5">\r
- <Slider Height="10" Width="300" BorderWidth="1" Background="Transparent" />\r
+ <Slider Height="10" Width="300" BorderWidth="1" Background="Transparent" />\r
<Label Name="labMouse" Text="MousePos"/>\r
<HorizontalStack WidgetSpacing="10">\r
<VerticalStack Width="100">\r
<VerticalStack Width="100">\r
<RadioButton IsChecked="true"/>\r
<RadioButton/>\r
- <RadioButton/>\r
+ <RadioButton> \r
+ <Template>\r
+ <HorizontalStack Background="Green" Margin="0" Spacing="1" Focusable="false">\r
+ <Image Name="Image" Width="16" Height="16" Path="#go.Images.Icons.radiobutton.svg"/>\r
+ <Label Name="Caption"/>\r
+ </HorizontalStack>\r
+ </Template>\r
+ </RadioButton>\r
<RadioButton/>\r
</VerticalStack>\r
- <Spinner Value="5"></Spinner>\r
+ <Spinner Width="50" Value="5"></Spinner>\r
</HorizontalStack>\r
<!-- <ListBox Data="{TestList}"></ListBox>-->\r
<HorizontalStack Name="hsPbar" Margin="5">\r
\r
</VerticalStack>\r
<VerticalStack Width="-1" Height="-1" BorderWidth="1" Margin="5" WidgetSpacing="4">\r
- <Button Margin="1" Width="150" Height="40">\r
+ <Button Margin="1" Width="150" Height="100">\r
<Image Path="#Tests.image.tetra.png"/>\r
</Button>\r
+ <Expandable Name="expander" Width="150" Height="-1">\r
+ <VerticalStack Name="vsExpanded" Width="100">\r
+ <Checkbox Name="chk1"/>\r
+ <Checkbox Name="chk2" IsChecked="true"/>\r
+ <Checkbox Name="chk3"/>\r
+ <Checkbox Name="chk4"/>\r
+ </VerticalStack> \r
+ </Expandable>\r
+ <Expandable Name="expander2" Width="150" Height="-1">\r
+ <VerticalStack Name="vsExpanded" Width="100">\r
+ <Checkbox Name="chk1"/>\r
+ <Checkbox Name="chk2" IsChecked="true"/>\r
+ </VerticalStack> \r
+ </Expandable>\r
+ <Expandable Name="expander3" Width="150" Height="-1">\r
+ <VerticalStack Name="vsExpanded" Width="100">\r
+ <Checkbox Name="chk1" IsChecked="true"/>\r
+ <Checkbox Name="chk2"/>\r
+ </VerticalStack> \r
+ </Expandable>\r
+\r
<HorizontalStack>\r
- <Label Text="Update" FontColor="White" VerticalAlignment="Center" />\r
+ <Label Text="Update" FontColor="White"/>\r
<Label Name="labUpdate" Text="xxxx" FontSize="16" Width="60" TextAlignment="Center" Background="DarkGreen"/>\r
</HorizontalStack>\r
<HorizontalStack>\r
- <Label Text="Fps:" Width = "30" VerticalAlignment="Center" TextAlignment="LeftCenter"/>\r
- <Label Name="labFps" Text="xxxx" Font="droid bold, 14"\r
+ <Label Text="Fps:" Width = "30"/>\r
+ <Label Name="labFps" Text="{fps}" Font="droid bold, 14"\r
TextAlignment="Center" Background="AoEnglish"/>\r
</HorizontalStack>\r
<HorizontalStack>\r
- <Label Text="Min:" Width = "30" />\r
- <Label Name="labFpsMin" Text="xxxx" Font="droid bold, 14"\r
+ <Label Text="Min:" Width = "30"/>\r
+ <Label Name="labFpsMin" Text="{fpsMin}" Font="droid bold, 14"\r
TextAlignment="Center" Background="AoEnglish"/>\r
</HorizontalStack>\r
<HorizontalStack>\r
<Label Text="Max:" Width = "30"/>\r
- <Label Name="labFpsMax" Text="xxxx" Font="droid bold, 14"\r
+ <Label Name="labFpsMax" Text="{fpsMax}" Font="droid bold, 14"\r
TextAlignment="Center" Background="AoEnglish"/>\r
</HorizontalStack>\r
</VerticalStack>\r
--- /dev/null
+<?xml version="1.0"?>\r
+<Container Name="TopContainer" Width="400" Height="-1"\r
+ Margin="20" Focusable="True" Background="Gray">\r
+\r
+ <Expandable Width="150" Background="Green" Margin="2">\r
+ <VerticalStack Width="100" Background="Red">\r
+ <Checkbox Name="chk1"/>\r
+ <Checkbox Name="chk2" IsChecked="true"/>\r
+ <Checkbox Name="chk3"/>\r
+ <Checkbox Name="chk4"/>\r
+ </VerticalStack> \r
+ </Expandable>\r
+</Container>
\ No newline at end of file
<OutputType>Exe</OutputType>
<RootNamespace>Tests</RootNamespace>
<AssemblyName>Tests</AssemblyName>
- <StartupObject>test.GOLIBTest_Spinner</StartupObject>
+ <StartupObject>test.GOLIBTest_4</StartupObject>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<OutputPath>..\bin\$(configuration)</OutputPath>
<IntermediateOutputPath>obj\$(configuration)</IntermediateOutputPath>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SynchReleaseVersion>false</SynchReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>..\bin\Debug</OutputPath>
<Compile Include="GOLIBTest_fps.cs" />
<Compile Include="GOLIBTest_Listbox.cs" />
<Compile Include="GOLIBTest_Spinner.cs" />
+ <Compile Include="GOLIBTest_Expandable.cs" />
</ItemGroup>
<ItemGroup>
<None Include="image\u.svg">
<None Include="Interfaces\testSpinner.goml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
+ <None Include="Interfaces\testExpandable.goml">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
</ItemGroup>
<ItemGroup>
<Folder Include="Interfaces\" />
MemberInfo miSrc = srcType.GetMember (binding.Value).FirstOrDefault();
//initialize target with actual value
+ object srcVal = null;
+ if (miSrc == null)
+ srcVal = _source;//if no member is provided for binding, source raw value is taken
+ else {
+ if (miSrc.MemberType == MemberTypes.Property)
+ srcVal = (miSrc as PropertyInfo).GetGetMethod ().Invoke (_source, null);
+ else if (miSrc.MemberType == MemberTypes.Field)
+ srcVal = (miSrc as FieldInfo).GetValue (_source);
+ else
+ throw new Exception ("unandled source member type for binding");
+ }
if (miDst.MemberType == MemberTypes.Property) {
- if (miSrc == null)//if no member is provided for binding, source raw value is taken
- (miDst as PropertyInfo).GetSetMethod ().Invoke (binding.Source, new object[] { _source });
- else if (miSrc.MemberType == MemberTypes.Property)
- (miDst as PropertyInfo).GetSetMethod ().Invoke (binding.Source, new object[] { (miSrc as PropertyInfo).GetGetMethod ().Invoke (_source, null) });
- else if (miSrc.MemberType == MemberTypes.Field)
- (miDst as PropertyInfo).GetSetMethod ().Invoke (binding.Source, new object[] { (miSrc as FieldInfo).GetValue (_source) });
+ PropertyInfo piDst = miDst as PropertyInfo;
+ //TODO: handle other dest type conversions
+ if (piDst.PropertyType == typeof(string))
+ srcVal = srcVal.ToString ();
+ piDst.GetSetMethod ().Invoke (binding.Source, new object[] { srcVal });
} else if (miDst.MemberType == MemberTypes.Field) {
- if (miSrc == null)//if no member is provided for binding, source raw value is taken
- (miDst as FieldInfo).SetValue (binding.Source, _source );
- else if (miSrc.MemberType == MemberTypes.Property)
- (miDst as FieldInfo).SetValue (binding.Source, (miSrc as PropertyInfo).GetGetMethod ().Invoke (_source, null));
- else if (miSrc.MemberType == MemberTypes.Field)
- (miDst as FieldInfo).SetValue (binding.Source, (miSrc as FieldInfo).GetValue (_source));
+ FieldInfo fiDst = miDst as FieldInfo;
+ if (fiDst.FieldType == typeof(string))
+ srcVal = srcVal.ToString ();
+ fiDst.SetValue (binding.Source, srcVal );
}else
throw new Exception("unandled destination member type for binding");
#region implemented abstract members of TemplatedControl
- protected override void loadTemplate ()
+ protected override void loadTemplate (GraphicObject template = null)
{
throw new NotImplementedException ();
}
{
Size raw = Bounds.Size;
- if (child != null) {
+ if (Child != null) {
if (Bounds.Width < 0)
- raw.Width = child.Slot.Width + 2 * (Margin+BorderWidth);
+ raw.Width = Child.Slot.Width + 2 * (Margin+BorderWidth);
if (Bounds.Height < 0)
- raw.Height = child.Slot.Height + 2 * (Margin+BorderWidth);
+ raw.Height = Child.Slot.Height + 2 * (Margin+BorderWidth);
}
return raw;
public string Text\r
{\r
get {\r
- Label l = child as Label;\r
+ Label l = Child as Label;\r
return l == null ? "" : l.Text; \r
}\r
set\r
{\r
- Label l = child as Label;\r
+ Label l = Child as Label;\r
if (l == null)\r
- this.setChild(new Label (value) \r
+ this.SetChild(new Label (value) \r
{ \r
TextAlignment = Alignment.Center,\r
Foreground = Color.Black\r
{\r
} \r
\r
- protected override void loadTemplate()\r
- {\r
- this.setChild (Interface.Load ("#go.Templates.Checkbox.goml"));\r
+ protected override void loadTemplate(GraphicObject template = null)\r
+ { \r
+ if (template == null)\r
+ this.SetChild (Interface.Load ("#go.Templates.Checkbox.goml", this));\r
+ else\r
+ this.SetChild (template);\r
+\r
_caption = this.child.FindByName ("Caption") as Label;\r
_image = this.child.FindByName ("Image") as Image;\r
_image.SvgSub = "unchecked";\r
\r
[XmlAttributeAttribute()][DefaultValue("Checkbox")]\r
public string Caption {\r
- get { return _caption.Text; } \r
+ get { return _caption == null ? "" : _caption.Text; } \r
set { \r
+ if (_caption == null)\r
+ return;\r
_caption.Text = value; \r
}\r
}\r
IsChecked = !IsChecked;\r
base.onMouseClick (sender, e);\r
}\r
+\r
+ public override void ReadXml (System.Xml.XmlReader reader)\r
+ {\r
+ base.ReadXml (reader);\r
+ }\r
}\r
}\r
\r
namespace go\r
{\r
- public class Container : GraphicObject, IXmlSerializable\r
+ public class Container : PrivateContainer, IXmlSerializable\r
{\r
#region CTOR\r
public Container()\r
}\r
#endregion\r
\r
- public GraphicObject child;\r
-\r
- public T setChild<T>(T _child)\r
- {\r
-\r
- if (child != null) {\r
- this.RegisterForLayouting ((int)LayoutingType.Sizing);\r
- child.Parent = null;\r
- }\r
-\r
- child = _child as GraphicObject;\r
-\r
- if (child != null) {\r
- child.Parent = this;\r
- child.RegisterForLayouting ((int)LayoutingType.Sizing);\r
- }\r
-\r
- return (T)_child;\r
- }\r
-\r
- #region GraphicObject Overrides\r
- //check if not causing problems\r
- [XmlAttributeAttribute()][DefaultValue(true)]\r
- public override bool Focusable\r
- {\r
- get { return base.Focusable; }\r
- set { base.Focusable = value; }\r
- }\r
-\r
- public override GraphicObject FindByName (string nameToFind)\r
- {\r
- if (Name == nameToFind)\r
- return this;\r
-\r
- return child == null ? null : child.FindByName (nameToFind);\r
- }\r
- public override bool Contains (GraphicObject goToFind)\r
- {\r
- return child == goToFind ? true : \r
- child == null ? false : child.Contains(goToFind);\r
- }\r
- protected override Size measureRawSize ()\r
- { \r
- return child == null ? Bounds.Size : new Size(child.Slot.Width + 2 * Margin, child.Slot.Height + 2 * (Margin));\r
+ [XmlIgnore]\r
+ public GraphicObject Child {\r
+ get { return child; }\r
+ set { child = value; }\r
}\r
-\r
- protected override void OnLayoutChanges (LayoutingType layoutType)\r
+ public T SetChild<T> (T _child)\r
{\r
- switch (layoutType) {\r
- case LayoutingType.Width: \r
- base.OnLayoutChanges (layoutType);\r
- if (child != null) {\r
- if (child.getBounds ().Width == 0)\r
- child.RegisterForLayouting ((int)LayoutingType.Width);\r
- else\r
- child.RegisterForLayouting ((int)LayoutingType.X);\r
- }\r
- break;\r
- case LayoutingType.Height:\r
- base.OnLayoutChanges (layoutType);\r
- if (child != null) {\r
- if (child.getBounds ().Height == 0)\r
- child.RegisterForLayouting ((int)LayoutingType.Height);\r
- else\r
- child.RegisterForLayouting ((int)LayoutingType.Y);\r
- }\r
- break;\r
- } \r
+ return base.SetChild (_child);\r
}\r
\r
-// public override void RegisterForLayouting(int layoutType)\r
-// {\r
-// Interface.LayoutingQueue.RemoveAll (lq => lq.GraphicObject == this && (layoutType & (int)lq.LayoutType) > 0);\r
-//\r
-// if ((layoutType & (int)LayoutingType.Width) > 0) {\r
-// if (Bounds.Width == 0) //stretch in parent\r
-// Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Width, this);\r
-// else //fit ou fixed\r
-// Interface.LayoutingQueue.Enqueue (LayoutingType.Width, this);\r
-// }\r
-//\r
-// if ((layoutType & (int)LayoutingType.Height) > 0) {\r
-// if (Bounds.Height == 0) //stretch in parent\r
-// Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Height, this);\r
-// else//fit ou fixed\r
-// Interface.LayoutingQueue.Enqueue (LayoutingType.Height, this);\r
-// }\r
-//\r
-// if ((layoutType & (int)LayoutingType.X) > 0)\r
-// //for x positionning, sizing of parent and this have to be done\r
-// Interface.LayoutingQueue.EnqueueAfterThisAndParentSizing (LayoutingType.X, this);\r
-//\r
-// if ((layoutType & (int)LayoutingType.Y) > 0)\r
-// //for x positionning, sizing of parent and this have to be done\r
-// Interface.LayoutingQueue.EnqueueAfterThisAndParentSizing (LayoutingType.Y, this);\r
-//\r
-// }\r
-\r
- public override Rectangle ContextCoordinates (Rectangle r)\r
- {\r
- return\r
- Parent.ContextCoordinates(r) + getSlot().Position + ClientRectangle.Position;\r
-\r
- }\r
- public override void Paint(ref Cairo.Context ctx, Rectangles clip = null)\r
- {\r
- if (!Visible)//check if necessary??\r
- return;\r
-\r
- ctx.Save();\r
-\r
-// ctx.Rectangle(ContextCoordinates(Slot));\r
-// ctx.Clip();\r
-//\r
- if (clip != null)\r
- clip.clip(ctx);\r
-\r
- base.Paint(ref ctx, clip);\r
-\r
- //clip to client zone\r
- ctx.Rectangle(Parent.ContextCoordinates(ClientRectangle + Slot.Position));\r
- ctx.Clip();\r
-\r
-// if (clip != null)\r
-// clip.Rebase(this);\r
-\r
- if (child != null)\r
- child.Paint(ref ctx, clip);\r
-\r
- ctx.Restore(); \r
- }\r
- #endregion\r
-\r
- #region Mouse handling\r
- public override void onMouseMove (object sender, MouseMoveEventArgs e)\r
- {\r
- base.onMouseMove (sender, e);\r
-\r
- if (child != null) \r
- if (child.MouseIsIn (e.Position)) \r
- child.onMouseMove (sender, e);\r
- \r
- }\r
- #endregion\r
-\r
#region IXmlSerializable\r
\r
public override System.Xml.Schema.XmlSchema GetSchema()\r
}\r
public override void ReadXml(System.Xml.XmlReader reader)\r
{\r
+ //only read attributes in GraphicObject IXmlReader implementation\r
base.ReadXml(reader);\r
\r
+\r
using (System.Xml.XmlReader subTree = reader.ReadSubtree())\r
{\r
subTree.Read(); //skip current node\r
\r
(go as IXmlSerializable).ReadXml(subTree);\r
\r
- setChild(go);\r
-\r
- subTree.Read();\r
-\r
- if (!subTree.IsStartElement())\r
- return;\r
+ SetChild(go);\r
\r
+ subTree.Read();//closing tag\r
}\r
}\r
public override void WriteXml(System.Xml.XmlWriter writer)\r
{\r
base.WriteXml(writer);\r
\r
- if (child == null)\r
+ if (Child == null)\r
return;\r
\r
- writer.WriteStartElement(child.GetType().Name);\r
- (child as IXmlSerializable).WriteXml(writer);\r
+ writer.WriteStartElement(Child.GetType().Name);\r
+ (Child as IXmlSerializable).WriteXml(writer);\r
writer.WriteEndElement();\r
}\r
\r
--- /dev/null
+using System;\r
+\r
+\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+//using OpenTK.Graphics.OpenGL;\r
+\r
+using Cairo;\r
+\r
+using winColors = System.Drawing.Color;\r
+using System.Diagnostics;\r
+using System.Xml.Serialization;\r
+using OpenTK.Input;\r
+using System.ComponentModel;\r
+using System.Xml;\r
+using System.IO;\r
+\r
+namespace go\r
+{\r
+ public class Expandable : TemplatedControl\r
+ { \r
+ bool _isExpanded;\r
+ Label _caption;\r
+\r
+ public Container Content;\r
+\r
+ public event EventHandler Expand;\r
+ public event EventHandler Collapse;\r
+\r
+ public Expandable() : base()\r
+ {\r
+ } \r
+\r
+ protected override void loadTemplate(GraphicObject template = null)\r
+ {\r
+ if (template == null)\r
+ this.SetChild (Interface.Load ("#go.Templates.Expandable.goml",this));\r
+ else\r
+ this.SetChild (template);\r
+\r
+ _caption = this.child.FindByName ("Caption") as Label;\r
+ Content = this.child.FindByName ("Content") as Container;\r
+ }\r
+ \r
+\r
+ [XmlAttributeAttribute()][DefaultValue("Expandable")]\r
+ public string Title {\r
+ get { return _caption.Text; } \r
+ set {\r
+ if (_caption == null)\r
+ return;\r
+ _caption.Text = value; \r
+ }\r
+ } \r
+ \r
+ [XmlAttributeAttribute()][DefaultValue(false)]\r
+ public bool IsExpanded\r
+ {\r
+ get { return _isExpanded; }\r
+ set\r
+ {\r
+ if (value == _isExpanded)\r
+ return;\r
+\r
+ _isExpanded = value;\r
+\r
+ if (_isExpanded)\r
+ onExpand (this, null);\r
+ else\r
+ onCollapse (this, null);\r
+\r
+ registerForGraphicUpdate();\r
+ }\r
+ }\r
+\r
+ public virtual void onExpand(object sender, EventArgs e)\r
+ {\r
+ Content.Visible = true;\r
+ Expand.Raise (this, e);\r
+ }\r
+ public virtual void onCollapse(object sender, EventArgs e)\r
+ {\r
+ Content.Visible = false;\r
+ Collapse.Raise (this, e);\r
+ }\r
+ \r
+ public override void onMouseClick (object sender, MouseButtonEventArgs e)\r
+ {\r
+ IsExpanded = !IsExpanded;\r
+ base.onMouseClick (sender, e);\r
+ }\r
+\r
+ public override void ReadXml(System.Xml.XmlReader reader)\r
+ {\r
+ using (System.Xml.XmlReader subTree = reader.ReadSubtree ()) {\r
+ subTree.Read ();\r
+ string tmp = subTree.ReadOuterXml ();\r
+\r
+ //seek for template tag\r
+ using (XmlReader xr = new XmlTextReader (tmp, XmlNodeType.Element, null)) {\r
+ xr.Read ();\r
+ base.ReadXml (xr); \r
+ }\r
+ //process content\r
+ using (XmlReader xr = new XmlTextReader (tmp, XmlNodeType.Element, null)) {\r
+ xr.Read (); //skip current node\r
+\r
+ while (!xr.EOF) {\r
+ xr.Read (); //read first child\r
+\r
+ if (!xr.IsStartElement ())\r
+ continue;\r
+ if (xr.Name == "Template")\r
+ continue;\r
+\r
+ Type t = Type.GetType ("go." + xr.Name);\r
+ GraphicObject go = (GraphicObject)Activator.CreateInstance (t); \r
+\r
+ (go as IXmlSerializable).ReadXml (xr);\r
+\r
+ Content.SetChild (go);\r
+\r
+ xr.Read (); //closing tag\r
+ }\r
+ \r
+ }\r
+ }\r
+ }\r
+ public override void WriteXml(System.Xml.XmlWriter writer)\r
+ {\r
+ base.WriteXml(writer);\r
+\r
+ if (Content == null)\r
+ return;\r
+ if (Content.Child == null)\r
+ return;\r
+ //TODO: if template is not the default one, we have to save it\r
+ writer.WriteStartElement(Content.Child.GetType().Name);\r
+ (Content.Child as IXmlSerializable).WriteXml(writer);\r
+ writer.WriteEndElement();\r
+ }\r
+ }\r
+}\r
Size tmp = new Size ();\r
\r
if (Orientation == Orientation.Horizontal) {\r
- foreach (GraphicObject c in Children) {\r
+ foreach (GraphicObject c in Children.Where(ch=>ch.Visible)) {\r
tmp.Width += c.Slot.Width + Spacing;\r
tmp.Height = Math.Max (tmp.Height, c.Slot.Bottom);\r
}\r
if (tmp.Width > 0)\r
tmp.Width -= Spacing;\r
} else {\r
- foreach (GraphicObject c in Children) {\r
+ foreach (GraphicObject c in Children.Where(ch=>ch.Visible)) {\r
tmp.Width = Math.Max (tmp.Width, c.Slot.Right);\r
tmp.Height += c.Slot.Height + Spacing;\r
}\r
{\r
int d = 0;\r
if (Orientation == Orientation.Horizontal) {\r
- foreach (GraphicObject c in Children) {\r
+ foreach (GraphicObject c in Children.Where(ch=>ch.Visible)) {\r
c.Slot.X = d;\r
d += c.Slot.Width + Spacing;\r
c.RegisterForLayouting ((int)LayoutingType.Y);\r
}\r
} else {\r
- foreach (GraphicObject c in Children) {\r
+ foreach (GraphicObject c in Children.Where(ch=>ch.Visible)) {\r
c.Slot.Y = d;\r
d += c.Slot.Height + Spacing;\r
c.RegisterForLayouting ((int)LayoutingType.X);\r
//this child will occupy remaining space\r
if (Orientation == Orientation.Horizontal) {\r
if (Width >= 0) {\r
- GraphicObject[] gobjs = Children.Where (c => c.Width == 0).ToArray();\r
+ GraphicObject[] gobjs = Children.Where (c => c.Width == 0 && c.Visible).ToArray();\r
if (gobjs.Length > 1)\r
throw new Exception ("Only one child in stack may have size to stretched");\r
else if (gobjs.Length == 1) {\r
- int sz = Children.Except (gobjs).Sum (g => g.Slot.Width);\r
+ int sz = Children.Where(ch=>ch.Visible).Except (gobjs).Sum (g => g.Slot.Width);\r
if (sz < Slot.Width) {\r
gobjs [0].Slot.Width = Slot.Width - sz - Spacing;\r
int idx = Children.IndexOf (gobjs [0]);\r
} \r
} else {\r
if (Height >= 0) {\r
- GraphicObject[] gobjs = Children.Where (c => c.Height == 0).ToArray();\r
+ GraphicObject[] gobjs = Children.Where(ch=>ch.Visible).Where (c => c.Height == 0).ToArray();\r
if (gobjs.Length > 1)\r
throw new Exception ("Only one child in stack may have size to stretched");\r
else if (gobjs.Length == 1) {\r
- int sz = Children.Except (gobjs).Sum (g => g.Slot.Height);\r
+ int sz = Children.Where(ch=>ch.Visible).Except (gobjs).Sum (g => g.Slot.Height);\r
if (sz < Slot.Height) {\r
gobjs [0].Slot.Height = Slot.Height - sz;\r
int idx = Children.IndexOf (gobjs [0]);\r
\r
_isVisible = value;\r
\r
+ if (TopContainer == null)\r
+ return;\r
//add slot to clipping to redraw\r
TopContainer.gobjsToRedraw.Add (this);\r
\r
//ensure main win doesn't keep hidden childrens ref\r
if (this.Contains (TopContainer.hoverWidget))\r
TopContainer.hoverWidget = null;\r
-// if (Parent != null)\r
+ if (Parent is GenericStack)\r
+ Parent.RegisterForLayouting ((int)LayoutingType.Sizing | (int)LayoutingType.PositionChildren);\r
// Parent.InvalidateLayout ();\r
//else\r
// registerForRedraw();\r
}\r
\r
#region IXmlSerializable\r
-\r
public virtual System.Xml.Schema.XmlSchema GetSchema ()\r
{\r
return null;\r
}\r
\r
}\r
-\r
public virtual void WriteXml (System.Xml.XmlWriter writer)\r
{\r
foreach (PropertyInfo pi in this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)) {\r
} \r
}\r
}\r
+ #endregion\r
\r
- #endregion \r
}\r
}\r
{\r
Size tmp = new Size ();\r
\r
- foreach (GraphicObject c in Children) {\r
+ foreach (GraphicObject c in Children.Where(ch=>ch.Visible)) {\r
tmp.Width = Math.Max (tmp.Width, c.Slot.Right);\r
tmp.Height = Math.Max (tmp.Height, c.Slot.Bottom);\r
}\r
case LayoutingType.Width: \r
if (Width < 0) {\r
int crw = ClientRectangle.Width;\r
- foreach (GraphicObject c in Children.Where(ch => ch.Slot.Width != crw))\r
+ foreach (GraphicObject c in Children.Where(ch => ch.Slot.Width != crw && ch.Visible))\r
c.RegisterForLayouting ((int)LayoutingType.X); \r
}\r
break;\r
case LayoutingType.Height:\r
if (Height < 0) {\r
int crh = ClientRectangle.Height;\r
- foreach (GraphicObject c in Children.Where(ch => ch.Slot.Height != crh))\r
+ foreach (GraphicObject c in Children.Where(ch => ch.Slot.Height != crh && ch.Visible))\r
c.RegisterForLayouting ((int)LayoutingType.Y); \r
}\r
break;\r
CairoHelpers.CairoRectangle(gr,rBack,CornerRadius);\r
gr.Fill ();\r
\r
- foreach (GraphicObject g in Children) {\r
+ foreach (GraphicObject g in Children.Where(ch=>ch.Visible)) {\r
g.Paint (ref gr);\r
}\r
}\r
#if DEBUG_CLIP_RECTANGLE\r
clip.stroke (gr, Color.Amaranth.AdjustAlpha (0.8));\r
#endif\r
- foreach (GraphicObject c in Children) {\r
+ foreach (GraphicObject c in Children.Where(ch=>ch.Visible)) {\r
Rectangles childClip = clip.intersectingRects (ContextCoordinates(c.Slot));\r
if (!c.DrawingIsValid || childClip.count > 0)\r
c.Paint (ref gr,childClip);//, localClip);\r
}
#region implemented abstract members of TemplatedControl
- protected override void loadTemplate ()
+ protected override void loadTemplate (GraphicObject template = null)
{
- this.setChild (Interface.Load ("#go.Templates.Listbox.goml"));
+ if (template == null)
+ this.SetChild (Interface.Load ("#go.Templates.Listbox.goml"));
+ else
+ this.SetChild (template);
+
_list = this.child.FindByName ("List") as Group;
}
#endregion
--- /dev/null
+//
+// PrivateContainer.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+// Copyright (c) 2015 jp
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+using System;
+using System.Xml.Serialization;
+using System.ComponentModel;
+using OpenTK.Input;
+
+namespace go
+{
+ /// <summary>
+ /// Implement drawing and layouting for a single child, but
+ /// does not implement IXmlSerialisation to allow reuse of container
+ /// behaviour for widgets that have other xml hierarchy: example
+ /// TemplatedControl may have 3 children (template,templateItem,content) but
+ /// behave exactely as a container for layouting and drawing
+ /// </summary>
+ public class PrivateContainer : GraphicObject
+ {
+ #region CTOR
+ public PrivateContainer()
+ : base()
+ {
+ }
+ public PrivateContainer(Rectangle _bounds)
+ : base(_bounds)
+ {
+ }
+ #endregion
+
+ protected GraphicObject child;
+
+ protected virtual T SetChild<T>(T _child)
+ {
+
+ if (child != null) {
+ this.RegisterForLayouting ((int)LayoutingType.Sizing);
+ child.Parent = null;
+ }
+
+ child = _child as GraphicObject;
+
+ if (child != null) {
+ child.Parent = this;
+ child.RegisterForLayouting ((int)LayoutingType.Sizing);
+ }
+
+ return (T)_child;
+ }
+
+ #region GraphicObject Overrides
+ //check if not causing problems
+ [XmlAttributeAttribute()][DefaultValue(true)]
+ public override bool Focusable
+ {
+ get { return base.Focusable; }
+ set { base.Focusable = value; }
+ }
+
+ public override GraphicObject FindByName (string nameToFind)
+ {
+ if (Name == nameToFind)
+ return this;
+
+ return child == null ? null : child.FindByName (nameToFind);
+ }
+ public override bool Contains (GraphicObject goToFind)
+ {
+ return child == goToFind ? true :
+ child == null ? false : child.Contains(goToFind);
+ }
+ protected override Size measureRawSize ()
+ {
+ return child == null ? Bounds.Size : new Size(child.Slot.Width + 2 * Margin, child.Slot.Height + 2 * (Margin));
+ }
+
+ protected override void OnLayoutChanges (LayoutingType layoutType)
+ {
+ switch (layoutType) {
+ case LayoutingType.Width:
+ base.OnLayoutChanges (layoutType);
+ if (child != null) {
+ if (child.getBounds ().Width == 0)
+ child.RegisterForLayouting ((int)LayoutingType.Width);
+ else
+ child.RegisterForLayouting ((int)LayoutingType.X);
+ }
+ break;
+ case LayoutingType.Height:
+ base.OnLayoutChanges (layoutType);
+ if (child != null) {
+ if (child.getBounds ().Height == 0)
+ child.RegisterForLayouting ((int)LayoutingType.Height);
+ else
+ child.RegisterForLayouting ((int)LayoutingType.Y);
+ }
+ break;
+ }
+ }
+
+ public override Rectangle ContextCoordinates (Rectangle r)
+ {
+ return
+ Parent.ContextCoordinates(r) + getSlot().Position + ClientRectangle.Position;
+ }
+ public override void Paint(ref Cairo.Context ctx, Rectangles clip = null)
+ {
+ if (!Visible)//check if necessary??
+ return;
+
+ ctx.Save();
+
+ // ctx.Rectangle(ContextCoordinates(Slot));
+ // ctx.Clip();
+ //
+ if (clip != null)
+ clip.clip(ctx);
+
+ base.Paint(ref ctx, clip);
+
+ //clip to client zone
+ ctx.Rectangle(Parent.ContextCoordinates(ClientRectangle + Slot.Position));
+ ctx.Clip();
+
+ // if (clip != null)
+ // clip.Rebase(this);
+
+ if (child != null)
+ child.Paint(ref ctx, clip);
+
+ ctx.Restore();
+ }
+ #endregion
+
+ #region Mouse handling
+ public override void onMouseMove (object sender, MouseMoveEventArgs e)
+ {
+ base.onMouseMove (sender, e);
+
+ if (child != null)
+ if (child.MouseIsIn (e.Position))
+ child.onMouseMove (sender, e);
+
+ }
+ #endregion
+ }
+}
+
{\r
} \r
\r
- protected override void loadTemplate()\r
+ protected override void loadTemplate(GraphicObject template = null)\r
{\r
- this.setChild (Interface.Load ("#go.Templates.RadioButton.goml"));\r
+ if (template == null)\r
+ this.SetChild (Interface.Load ("#go.Templates.RadioButton.goml"));\r
+ else\r
+ this.SetChild (template);\r
+\r
_caption = this.child.FindByName ("Caption") as Label;\r
_image = this.child.FindByName ("Image") as Image;\r
_image.SvgSub = "unchecked";\r
// if (MouseWheelChanged!=null)\r
// MouseWheelChanged (this, e);\r
\r
- if (child == null)\r
+ if (Child == null)\r
return;\r
\r
if (VerticalScrolling )\r
\r
if (scrollY > 0)\r
scrollY = 0;\r
- else if (scrollY < -child.Slot.Height + ClientRectangle.Height)\r
- scrollY = -child.Slot.Height + ClientRectangle.Height;\r
+ else if (scrollY < -Child.Slot.Height + ClientRectangle.Height)\r
+ scrollY = -Child.Slot.Height + ClientRectangle.Height;\r
\r
}\r
if (HorizontalScrolling )\r
\r
if (scrollX > 0)\r
scrollX = 0;\r
- else if (scrollX < -child.Slot.Width + ClientRectangle.Width)\r
- scrollX = -child.Slot.Width + ClientRectangle.Width;\r
+ else if (scrollX < -Child.Slot.Width + ClientRectangle.Width)\r
+ scrollX = -Child.Slot.Width + ClientRectangle.Width;\r
}\r
\r
\r
// if (clip != null)\r
// clip.Rebase(this);\r
\r
- if (child != null)\r
- child.Paint(ref ctx, clip);\r
+ if (Child != null)\r
+ Child.Paint(ref ctx, clip);\r
\r
ctx.Restore(); \r
}\r
\r
#region implemented abstract members of TemplatedControl\r
\r
- protected override void loadTemplate ()\r
+ protected override void loadTemplate (GraphicObject template = null)\r
{\r
\r
}\r
#region implemented abstract members of TemplatedControl
- protected override void loadTemplate ()
+ protected override void loadTemplate (GraphicObject template = null)
{
- this.setChild (Interface.Load ("#go.Templates.Spinner.goml", this));
+ if (template == null)
+ this.SetChild (Interface.Load ("#go.Templates.Spinner.goml", this));
+ else
+ this.SetChild (template);
+
labCpt = this.child.FindByName ("labCpt") as Label;
}
using System;
using System.Xml.Serialization;
using System.ComponentModel;
+using System.IO;
+using System.Xml;
namespace go
{
- public abstract class TemplatedControl : Container, IXmlSerializable
+ public abstract class TemplatedControl : PrivateContainer, IXmlSerializable
{
public TemplatedControl () : base()
{
// }
- protected abstract void loadTemplate();
+ protected abstract void loadTemplate(GraphicObject template = null);
protected override void loadDefaultValues ()
{
- loadTemplate ();
+ if (child == null)//trigger loading of default template if child is empty
+ loadTemplate ();
base.loadDefaultValues ();
this.Focusable = true;
}
}
public override void ReadXml(System.Xml.XmlReader reader)
{
- base.ReadXml(reader);
+ using (System.Xml.XmlReader subTree = reader.ReadSubtree())
+ {
+ subTree.Read ();
+ string tmp = subTree.ReadOuterXml ();
-// using (System.Xml.XmlReader subTree = reader.ReadSubtree())
-// {
-// subTree.Read(); //skip current node
-// subTree.Read(); //read first child
-//
-// if (!subTree.IsStartElement())
-// return;
-//
-// Type t = Type.GetType("go." + subTree.Name);
-// GraphicObject go = (GraphicObject)Activator.CreateInstance(t);
-//
-// (go as IXmlSerializable).ReadXml(subTree);
-//
-// setChild(go);
-//
-// subTree.Read();
-//
-// if (!subTree.IsStartElement())
-// return;
-//
-// }
+ //seek for template tag first
+ using (XmlReader xr = new XmlTextReader (tmp, XmlNodeType.Element, null)) {
+ //load template first if inlined
+
+ xr.Read (); //skip current node
+
+ while (!xr.EOF) {
+ xr.Read (); //read first child
+ if (!xr.IsStartElement ())
+ continue;
+ if (xr.Name == "Template") {
+ xr.Read ();
+
+ Type t = Type.GetType ("go." + xr.Name);
+ GraphicObject go = (GraphicObject)Activator.CreateInstance (t);
+ (go as IXmlSerializable).ReadXml (xr);
+
+ loadTemplate (go);
+
+ xr.Read ();//go close tag
+ xr.Read ();//Template close tag
+ } else {
+ xr.ReadInnerXml ();
+ }
+ }
+ }
+ using (XmlReader xr = new XmlTextReader (tmp, XmlNodeType.Element, null)) {
+ xr.Read ();
+ base.ReadXml(xr);
+ }
+ }
}
public override void WriteXml(System.Xml.XmlWriter writer)
{
#region Load/Save
- internal static List<DynAttribute> EventsToResolve;
+ internal static Stack<List<DynAttribute>> EventsResolutionStack = new Stack<List<DynAttribute>>();
+ internal static List<DynAttribute> EventsToResolve
+ {
+ get { return EventsResolutionStack.Peek ();}
+ }
internal static List<DynAttribute> Bindings;
+
public static void Save<T>(string file, T graphicObject)
{
XmlSerializerNamespaces xn = new XmlSerializerNamespaces();
{
//result = (T)(Load (file, hostClass) as object);
- EventsToResolve = new List<DynAttribute>();
+ EventsResolutionStack.Push(new List<DynAttribute>());
Bindings = new List<DynAttribute> ();
XmlSerializerNamespaces xn = new XmlSerializerNamespaces();
if (hostClass == null)
return;
- foreach (DynAttribute es in EventsToResolve)
- {
- if (string.IsNullOrEmpty(es.Value))
- continue;
+ resolveEvents (hostClass);
- if (es.Value.StartsWith ("{")) {
- CompilerServices.CompileEventSource (es);
- } else {
- MethodInfo mi = hostClass.GetType ().GetMethod (es.Value, BindingFlags.NonPublic | BindingFlags.Public
- | BindingFlags.Instance);
-
- if (mi == null) {
- Debug.WriteLine ("Handler Method not found: " + es.Value);
- continue;
- }
-
- FieldInfo fi = CompilerServices.getEventHandlerField (es.Source.GetType (), es.MemberName);
- Delegate del = Delegate.CreateDelegate(fi.FieldType, hostClass, mi);
- fi.SetValue(es.Source, del);
- }
- }
while (Bindings.Count > 0) {
DynAttribute binding = Bindings [0];
Bindings.RemoveAt (0);
// }
// Bindings.Clear ();
}
+
public static GraphicObject Load(Stream stream, Type type, object hostClass = null)
{
GraphicObject result;
- EventsToResolve = new List<DynAttribute>();
+ EventsResolutionStack.Push(new List<DynAttribute>());
XmlSerializerNamespaces xn = new XmlSerializerNamespaces();
xn.Add("", "");
if (hostClass == null)
return result;
+ resolveEvents (hostClass);
+
+ while (Bindings.Count > 0) {
+ DynAttribute binding = Bindings [0];
+ Bindings.RemoveAt (0);
+ CompilerServices.ResolveBinding (binding, hostClass);
+ }
+
+// foreach (DynAttribute binding in Bindings) {
+// // Type tSource = binding.Source.GetType ();
+// // if (!tSource.GetInterfaces ().Any (i => i.Name == "IValueChange")){
+// // Debug.WriteLine ("Binding source does not implement IValueChange.");
+// // continue;
+// // }
+// //MemberInfo mi = binding.Source.GetType ().GetMember (binding.MemberName);
+// CompilerServices.CreateBinding (binding, hostClass);
+// }
+// Bindings.Clear ();
+
+
+ return result;
+ }
+
+ static void resolveEvents(object hostClass)
+ {
foreach (DynAttribute es in EventsToResolve)
{
if (string.IsNullOrEmpty(es.Value))
fi.SetValue(es.Source, del);
}
}
- while (Bindings.Count > 0) {
- DynAttribute binding = Bindings [0];
- Bindings.RemoveAt (0);
- CompilerServices.ResolveBinding (binding, hostClass);
- }
-
-// foreach (DynAttribute binding in Bindings) {
-// // Type tSource = binding.Source.GetType ();
-// // if (!tSource.GetInterfaces ().Any (i => i.Name == "IValueChange")){
-// // Debug.WriteLine ("Binding source does not implement IValueChange.");
-// // continue;
-// // }
-// //MemberInfo mi = binding.Source.GetType ().GetMember (binding.MemberName);
-// CompilerServices.CreateBinding (binding, hostClass);
-// }
-// Bindings.Clear ();
- return result;
+ EventsResolutionStack.Pop();
}
-
#endregion
}
}
}
public void ProcessLayouting()
{
- Debug.WriteLine ("Layouting => " + this.ToString ());
+ //Debug.WriteLine ("Layouting => " + this.ToString ());
try {
GraphicObject.UpdateLayout (LayoutType);
} catch (Exception ex) {