Permalink
Browse files

* Fixed typo in UIElement

* Enable pdb & xml doc for Debug configuration
* TextElement : update layout when Size changed
  • Loading branch information...
1 parent 73bef22 commit 9b685594796d6c3eda5b413b0bd5331fce6cc6c7 @mogikanin mogikanin committed Feb 9, 2013
Showing with 42 additions and 10 deletions.
  1. +3 −1 Fleux/Core/FleuxApplication.cs
  2. +5 −4 Fleux/Fleux.csproj
  3. +33 −4 Fleux/UIElements/TextElement.cs
  4. +1 −1 Fleux/UIElements/UIElement.cs
@@ -78,11 +78,13 @@ public static void ApplyGraphicsSettings(Graphics gr)
#endif
}
+
+ private static readonly Rectangle _dummyDrawingGraphicsRect = new Rectangle(0, 0, 1, 1);
public static IDrawingGraphics DummyDrawingGraphics
{
get
{
- return DrawingGraphics.FromGraphicsAndRect(DummyGraphics, DummyImage, new Rectangle(0, 0, 1, 1));
+ return DrawingGraphics.FromGraphicsAndRect(DummyGraphics, DummyImage, _dummyDrawingGraphicsRect);
}
}
View
@@ -62,9 +62,10 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;WIN32;$(PlatformFamilyName)</DefineConstants>
- <DebugType>none</DebugType>
- <DebugSymbols>false</DebugSymbols>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
<NoStdLib>false</NoStdLib>
+ <DocumentationFile>bin\Debug\Fleux.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
@@ -76,8 +77,8 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|WINCE' ">
<OutputPath>bin\Debug_ce\</OutputPath>
<DefineConstants>DEBUG;TRACE;$(PlatformFamilyName);WINCE</DefineConstants>
- <DebugType>none</DebugType>
- <DebugSymbols>false</DebugSymbols>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
<NoStdLib>false</NoStdLib>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|WINCE' ">
@@ -10,22 +10,36 @@ public class TextElement : UIElement
{
protected string text;
protected bool needUpdate = true;
+ private bool _inRelayout;
public TextElement(string text)
{
this.text = text;
this.Style = MetroTheme.PhoneTextNormalStyle;
+ SizeChanged += delegate
+ {
+ if (_inRelayout) return; // to avoid creating FleuxApplication.DummyDrawingGraphics
+ DoRelayout(FleuxApplication.DummyDrawingGraphics);
+ };
}
public enum AutoSizeModeOptions
{
+ /// <summary>
/// Fixed size
+ /// </summary>
None,
+ /// <summary>
/// Both height and width are calculated
+ /// </summary>
OneLineAutoHeight,
- /// auto height, fixed width
+ /// <summary>
+ /// Auto height, fixed width
+ /// </summary>
OneLineAutoHeightFixedWidth,
+ /// <summary>
/// Wrap text over fixed width
+ /// </summary>
WrapText,
}
@@ -36,7 +50,7 @@ public enum AutoSizeModeOptions
}
set{
_AutoSizeMode = value;
- Relayout(FleuxApplication.DummyDrawingGraphics);
+ DoRelayout(FleuxApplication.DummyDrawingGraphics);
}
}
@@ -64,7 +78,7 @@ public override void ResizeForWidth(int width)
this.Size = new Size(width, 10); // Height will be calculated later
try
{
- this.Relayout(FleuxApplication.DummyDrawingGraphics);
+ DoRelayout(FleuxApplication.DummyDrawingGraphics);
}
catch (Exception)
{
@@ -77,7 +91,7 @@ public override void Draw(IDrawingGraphics drawingGraphics)
{
if (this.needUpdate)
{
- this.Relayout(drawingGraphics);
+ DoRelayout(drawingGraphics);
this.needUpdate = false;
}
@@ -96,6 +110,21 @@ public override void Draw(IDrawingGraphics drawingGraphics)
}
}
+ private void DoRelayout(IDrawingGraphics drawingGraphics)
+ {
+ if (_inRelayout) return;
+
+ _inRelayout = true;
+ try
+ {
+ Relayout(drawingGraphics);
+ }
+ finally
+ {
+ _inRelayout = false;
+ }
+ }
+
protected virtual void Relayout(IDrawingGraphics dg)
{
if (this.AutoSizeMode != AutoSizeModeOptions.None)
@@ -96,7 +96,7 @@ public int Height
}
set{
- this.Size = new Size(Size.Height, value);
+ this.Size = new Size(Size.Width, value);
}
}

0 comments on commit 9b68559

Please sign in to comment.