tag:blogger.com,1999:blog-29552469507584548412024-03-13T14:57:31.363+00:00Developer GoodiesResources for DevelopersUnknownnoreply@blogger.comBlogger21125tag:blogger.com,1999:blog-2955246950758454841.post-51899155170791529132013-01-07T12:33:00.002+00:002013-02-13T15:30:09.868+00:00Detect (And Cancel) Windows Phone Back KeyTo detect when the user presses the back key, you just have to override the OnBackKeyPress function.<br />
<br />
Just like this:<br />
<pre name=code" class="brush:csharp">protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
// to cancel the event
e.Cancel = true;
}</pre>You can optionally cancel the navigation or allow it to occur.<br />
<br />
You cancel the navigation by calling the instruction on line four.<br />
<br />
Obviously you can code any logic to conditionally cancel the navigation.<br />
<br />
Another use is to catch the event just to persist any information and then letting the navigation occur. Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2955246950758454841.post-10941283506000477082013-01-07T12:04:00.000+00:002013-01-07T12:04:30.018+00:00Detect (And Cancel) Android Back KeyTo detect when the user presses the back key, you just have to override the onBackPressed function.<br />
<br />
Just like this:<br />
<pre name=code" class="brush:java">@Override
public void onBackPressed() {
super.onBackPressed();
}</pre>You can optionally cancel the navigation or allow it to occur.<br />
<br />
You cancel the navigation by not calling the instruction on like two.<br />
<br />
Obviously you can code any logic to conditionally cancel the navigation.<br />
<br />
Another use is to catch the event just to persist any information and then letting the navigation occur. Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2955246950758454841.post-14281034674222879602012-12-22T17:56:00.000+00:002012-12-22T17:56:02.765+00:00Create Android User ControlThere are several ways for creating reusable UI components in Android.<br />
<br />
The one described here is creating a new view made with other views (much like a usercontrol in .Net).<br />
<br />
Creating an Android user control requires a layout and a class just like creating an activity.<br />
<br />
The layout can be whatever you want and the relevant aspect is the layout root you choose.<br />
<br />
In this example, the layout root is a Framelayout (but can be any other):<br />
<pre name=code" class="brush:html"><?xml version="1.0" encoding="utf-8"?>
<Framelayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layoutroot" >
<!-- Your user control UI -->
</FrameLayout>
</pre>Then, you must create a class to handle the logic of your user control.<br />
<br />
The base class must be the same class of the layout root.<br />
<br />
In the example, the class extends FrameLayout as it is the layout root of the previous example:<br />
<pre name=code" class="brush:java">package YourPackage;
public class YourUserControl extends FrameLayout {
public YourUserControl(Context context) {
super(context);
}
public YourUserControl(Context context, AttributeSet attrs) {
super(context, attrs);
LayoutInflater inflater = LayoutInflater.from(context);
inflater.inflate(R.layout.yourusercontrollayoutid, this);
//more code if needed
}
//more code
}
</pre>You reference your new UI component in xml just like any Android view by referencing the package and class name:<br />
<pre name=code" class="brush:text"><YourPackage.YourUserControl />
</pre>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2955246950758454841.post-70339859186127373822012-12-19T12:37:00.003+00:002012-12-19T12:37:39.672+00:00Prevent Screen Saver In WPF ApplicationSometimes we want your application to be always visible, preventing the screen saver (or monitor off) to happen.<br />
<br />
We can achieve this by calling an API of the OS.<br />
<br />
First we have to declare the OS API:<br />
<pre name=code" class="brush:csharp">[DllImport("kernel32.dll")]
private static extern uint SetThreadExecutionState(uint esFlags);
private const uint ES_CONTINUOUS = 0x80000000;
private const uint ES_SYSTEM_REQUIRED = 0x00000001;
private const uint ES_DISPLAY_REQUIRED = 0x00000002;
</pre><br />
When the application starts (or any time you want to disable the screen saver):<br />
<pre name=code" class="brush:csharp">SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
</pre><br />
When the application ends (or any time you want to enable the screen saver):<br />
<pre name=code" class="brush:csharp">SetThreadExecutionState(ES_CONTINUOUS);
</pre>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2955246950758454841.post-60873326309433438052012-12-11T10:49:00.000+00:002012-12-11T10:53:28.946+00:00Detect Windows Phone Application In Edit ModeSometimes we have to know when your code is running in the editor.<br />
<br />
When authoring a control, it's common to include code that must run outside the editor, otherwise it would cause an exception in edit mode.<br />
<br />
The following code shows how to do it:<br />
<pre name=code" class="brush:csharp">public partial class YourControl: UserControl
{
public YourControl()
{
InitializeComponent();
if (!DesignerProperties.IsInDesignTool)
{
//code to run outside the editor
}
}
}
</pre>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2955246950758454841.post-68826197334458746662012-12-11T10:43:00.000+00:002012-12-11T10:53:23.886+00:00Detect Android Application In Edit ModeSometimes we have to know when your code is running in the editor.<br />
<br />
When authoring a control, it's common to include code that must run outside the editor, otherwise it would cause an exception in edit mode.<br />
<br />
The following code shows how to do it:<br />
<pre name=code" class="brush:java">public class YourControl extends FrameLayout {
public YourControl (Context context, AttributeSet attrs) {
super(context, attrs);
if (!isInEditMode()) {
//code to run outside the editor
}
}
</pre>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2955246950758454841.post-17340057278412647052012-12-04T16:57:00.000+00:002012-12-05T09:57:29.454+00:00Speed Up Android EmulatorThe android emulator runs an actual ROM of a physical device.<br />
<br />
If the device is based on the ARM architecture lots of translation must be done to run it on a x86 system.<br />
<br />
However, we can choose an x86 ROM when available.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyne7NUulDFHDbdmK5-v1GxPAXYLnLRImlSD8bNM-kyqVvXKHDmt7lnGIzf7KPhdm7R6bmHBg1uYGpvFdrK-xmQVFWV4foixvQqyguyqNPeNRn95OvvFewBPX0hejrdIIdJuVV1X-B5cw/s1600/CreateNewAndroidVirtualDevice.jpg" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="257" width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyne7NUulDFHDbdmK5-v1GxPAXYLnLRImlSD8bNM-kyqVvXKHDmt7lnGIzf7KPhdm7R6bmHBg1uYGpvFdrK-xmQVFWV4foixvQqyguyqNPeNRn95OvvFewBPX0hejrdIIdJuVV1X-B5cw/s400/CreateNewAndroidVirtualDevice.jpg" /></a></div><br />
We don't have to, but it's a good option to use the host GPU to speed the rendering.<br />
<br />
Don't activate this option when targeting Intel Atom x86 System Image (Intel Corporation) - API Level 10. In my case this prevents the emulator to open.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSEdfthZRxMEiMszd_2hm2mhDShJDuwQTAGmQznqHGgU1FM-aIUvEZIBvmtPAcuZ89xP_hyphenhyphenn5vbtRoz1rZuDu3jRBxR_Lr6pGyByCjnjVcJC26Amt9dH9om6-uBXf3RiYbYwxhE13Nm8s/s1600/CreateNewAndroidVirtualDevice1.jpg" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="257" width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSEdfthZRxMEiMszd_2hm2mhDShJDuwQTAGmQznqHGgU1FM-aIUvEZIBvmtPAcuZ89xP_hyphenhyphenn5vbtRoz1rZuDu3jRBxR_Lr6pGyByCjnjVcJC26Amt9dH9om6-uBXf3RiYbYwxhE13Nm8s/s400/CreateNewAndroidVirtualDevice1.jpg" /></a></div><br />
In the Android SDK Manager download the Intel x86 Emulator Accelerator (HAXM) package.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiB2neCZY3-pHi0aR-EWPiPz8Iq2auibyzLjIzX9pxB07SvQyrHFENGfLY55rGp3z5KPJKYaJ8jzR-EAT4-3ZaM8YcMVtfC8vvnEsr5avnmN1yY7QtC35wJl9uKeofyehChZWWJTNZl4L0/s1600/CreateNewAndroidVirtualDevice2.jpg" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="301" width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiB2neCZY3-pHi0aR-EWPiPz8Iq2auibyzLjIzX9pxB07SvQyrHFENGfLY55rGp3z5KPJKYaJ8jzR-EAT4-3ZaM8YcMVtfC8vvnEsr5avnmN1yY7QtC35wJl9uKeofyehChZWWJTNZl4L0/s400/CreateNewAndroidVirtualDevice2.jpg" /></a></div><br />
The Android SDK Manager downloads the Intel x86 Emulator Accelerator (HAXM) package but doesn't run the installation, you must do it yourself.<br />
<br />
Failing to do so, you will get the following message when starting a virtual device:<br />
<pre name=code" class="brush:html">emulator: Failed to open the HAX device!
HAX is not working and emulator runs in emulation mode
emulator: Open HAX device failed
</pre>Locate and run the file IntelHaxm.exe.<br />
<br />
In my case it can be found at C:\Program Files (x86)\Android\android-sdk\extras\intel\Hardware_Accelerated_Execution_Manager.Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-2955246950758454841.post-61449372297001409992012-11-29T11:38:00.000+00:002012-11-30T09:49:04.704+00:00Copy Windows Phone Content To Isolated StorageSome times a database is deployed with the application as a content file.<br />
<br />
However, the database can't be used directly, it must be copied to the storage first.<br />
<br />
In this sample code, the content file is copied to the isolated storage if it isn't copied yet.<br />
<pre name=code" class="brush:csharp">IsolatedStorageFile ISF = IsolatedStorageFile.GetUserStoreForApplication();
String DBFile = "DB.sqlite";
if (!ISF.FileExists(DBFile)) CopyFromContentToStorage(ISF, "Database/DB.sqlite", DBFile);
private void CopyFromContentToStorage(IsolatedStorageFile ISF, String SourceFile, String DestinationFile)
{
Stream Stream = Application.GetResourceStream(new Uri(SourceFile, UriKind.Relative)).Stream;
IsolatedStorageFileStream ISFS = new IsolatedStorageFileStream(DestinationFile, System.IO.FileMode.Create, System.IO.FileAccess.Write, ISF);
CopyStream(Stream, ISFS);
ISFS.Flush();
ISFS.Close();
Stream.Close();
ISFS.Dispose();
}
private void CopyStream(Stream Input, IsolatedStorageFileStream Output)
{
Byte[] Buffer = new Byte[5120];
Int32 ReadCount = Input.Read(Buffer, 0, Buffer.Length);
while (ReadCount > 0)
{
Output.Write(Buffer, 0, ReadCount);
ReadCount = Input.Read(Buffer, 0, Buffer.Length);
}
}
</pre>The code assumes that the file to be copied is named 'DB.sqlite' that resides in a folder named 'database' and was added to the project as a content file.<br />
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2955246950758454841.post-35436262993019363552012-11-29T11:12:00.002+00:002012-11-29T16:36:42.544+00:00Copy Android Asset To Internal StorageSome times a database is deployed with the application as an asset.<br />
<br />
However, the database can't be used directly, it must be copied to the storage first.<br />
<br />
In this sample code, the asset is copied to the internal storage if it isn't copied yet.<br />
<pre name=code" class="brush:java">Context Context = getApplicationContext();
String DestinationFile = Context.getFilesDir().getPath() + File.separator + "DB.sqlite";
if (!new File(DestinationFile).exists()) {
try {
CopyFromAssetsToStorage(Context, "Database/DB.sqlite", DestinationFile);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void CopyFromAssetsToStorage(Context Context, String SourceFile, String DestinationFile) throws IOException {
InputStream IS = Context.getAssets().open(SourceFile);
OutputStream OS = new FileOutputStream(DestinationFile);
CopyStream(IS, OS);
OS.flush();
OS.close();
IS.close();
}
private void CopyStream(InputStream Input, OutputStream Output) throws IOException {
byte[] buffer = new byte[5120];
int length = Input.read(buffer);
while (length > 0) {
Output.write(buffer, 0, length);
length = Input.read(buffer);
}
}</pre>The code assumes that the file to be copied is named 'DB.sqlite' and it resides in a folder named 'database' in the assets.Unknownnoreply@blogger.com3tag:blogger.com,1999:blog-2955246950758454841.post-49758716791198400062012-11-28T15:31:00.001+00:002012-11-28T15:41:26.679+00:00Start Thread On AndroidYou can start a new thread by extending the Thread class or implementing the Runnable interface.<br />
<br />
Extending the Thread class:<br />
<pre name=code" class="brush:java">Thread T = new NewThread();
T.start();
private class NewThread extends Thread {
@Override
public void run() {
//Your asynchronous code
}
}
</pre>Implementing the Runnable interface:<br />
<pre name=code" class="brush:java">Thread T = new Thread(new NewRunnable());
T.start();
private class NewRunnable implements Runnable {
public void run() {
//Your asynchronous code
}
}
</pre>Your activity may implement the Runnable interface directly.<br />
In this case, when creating the Thread object you must pass the activity (this) as the parameter.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2955246950758454841.post-8116387978486483252012-11-21T15:59:00.002+00:002012-12-24T15:49:41.891+00:00Prevent Android UI Resize When Keyboard OpensAn android activity may be resized when the soft keyboard opens.<br />
<br />
Sometimes that's not the behavior we want.<br />
<br />
To disable the resizing, add the following line to the activity declaration on the manifest:<br />
<pre name=code" class="brush:xml"><activity
android:windowSoftInputMode="adjustPan" />
</pre>If the UI contains a ScrollView, then you can also add the following to the view declaration to prevent the resizing:<br />
<pre name=code" class="brush:xml">android:isScrollContainer="false"
</pre>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2955246950758454841.post-48400613963381602282012-11-08T16:09:00.000+00:002012-11-13T23:06:09.489+00:00Update Android UI From Other ThreadsAsynchronous functions are useful to run code in background so the UI will not freeze.<br />
<br />
Those functions can't access the UI directly because they aren't running in the UI thread.<br />
<br />
If you try to access the UI from those threads you will get the error:<br />
"Only the original thread that created a view hierarchy can touch its views."<br />
<br />
The solutions is to use Handlers.<br />
<pre name=code" class="brush:java">private Handler YOURHANDLER = new Handler() {
@Override
public void handleMessage(Message msg) {
//do some code in the UI thread
}
};
public void ASYNCHRONOUSFUNCTION() {
Message Msg = new Message();
Msg.obj = "SOME TEXT"; //can be any object
YOURHANDLER.sendMessage(Msg);
}
</pre>In the example, the ASYNCHRONOUSFUNCTION function runs in another thread.<br />
<br />
The Message object will contain any information in it's obj property that you want to send to the handler.<br />
<br />
Finally, you invoke the sendMessage method of the YOURHANDLER handler.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2955246950758454841.post-53925917427032906692012-11-08T14:17:00.001+00:002012-11-19T11:27:47.747+00:00Programmatically Hide Android SIPSome times we want to programmatically hide the virtual keyboard (SIP, soft input panel).<br />
<br />
This is how you do it:<br />
<pre name=code" class="brush:java">InputMethodManager IMM = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
IMM.hideSoftInputFromWindow(v.getWindowToken(), 0);
</pre>In the code, the V variable may represent any view of the activity.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2955246950758454841.post-34001359957041399562012-10-26T13:35:00.001+01:002012-10-26T14:36:19.789+01:00Force Windows Phone ThemeWindows Phone applications inherits the theme of the OS on launch.<br />
<br />
When the UI is designed specially for the dark theme it won't look well on the light theme, or vice versa.<br />
<br />
To prevent this the application can force the default dark or light theme.<br />
<br />
In the application class' constructor put this code to force the dark theme:<br />
<pre name=code" class="brush:csharp">if ((Visibility)Application.Current.Resources["PhoneLightThemeVisibility"] == Visibility.Visible) MergeCustomColors("/Themes/DarkStyles.xaml");
</pre>Or this code to force the light theme:<br />
<pre name=code" class="brush:csharp">if ((Visibility)Application.Current.Resources["PhoneDarkThemeVisibility"] == Visibility.Visible) MergeCustomColors("/Themes/LightStyles.xaml");
</pre>Anywhere in your project put this method:<br />
<pre name=code" class="brush:csharp">private void MergeCustomColors(String Theme)
{
ResourceDictionary Dictionaries = new ResourceDictionary();
String source = String.Format(Theme);
var themeStyles = new ResourceDictionary { Source = new Uri(source, UriKind.Relative) };
Dictionaries.MergedDictionaries.Add(themeStyles);
ResourceDictionary appResources = Current.Resources;
foreach (DictionaryEntry entry in Dictionaries.MergedDictionaries[0])
{
SolidColorBrush ColorBrush = entry.Value as SolidColorBrush;
SolidColorBrush ExistingBrush = appResources[entry.Key] as SolidColorBrush;
if (ExistingBrush != null && ColorBrush != null) { ExistingBrush.Color = ColorBrush.Color; }
}
}
</pre>The code assumes that the projects contains the files DarkStyles.xaml and LightStyles.xaml in a folder named Themes.<br />
<br />
A demo project can be found <a href="http://www.mediafire.com/?oc98zcxi5k6miah">here</a>.Unknownnoreply@blogger.com8tag:blogger.com,1999:blog-2955246950758454841.post-46009113566707134162012-10-26T12:07:00.000+01:002012-10-26T12:08:14.657+01:00Get Windows Phone Accent ColorSome times an application needs to know which accent color is currently in use on the device so it can adjust it's UI.<br />
<br />
The PhoneAccentColor key indicates the accent color as a Color object.<br />
The PhoneAccentBrush key indicates the accent color as a Brush object.<br />
<br />
In XAML you can do something like:<br />
<pre name="code" class="brush:xml"><TextBlock Foreground="{StaticResource PhoneAccentBrush}" />
<Border>
<Border.Background>
<SolidColorBrush Color="{StaticResource PhoneAccentColor}" />
</Border.Background>
</Border>
</pre>In C#:<br />
<pre name="code" class="brush:csharp">Color AccentColor = (Color)Resources["PhoneAccentColor"];
Brush AccentBrush = (Brush)Resources["PhoneAccentBrush"];
</pre>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2955246950758454841.post-76798149252785635652012-10-26T11:50:00.000+01:002012-10-26T11:55:48.173+01:00Detect Windows Phone ThemeSome times an application needs to know which theme is currently in use on the device so it can adjust it's UI.<br />
<br />
The PhoneLightThemeVisibility key indicates the visibility of the light theme.<br />
The PhoneDarkThemeVisibility key indicates the visibility of the dark theme.<br />
<br />
In XAML you can do something like:<br />
<pre name="code" class="brush:xml"><TextBlock Visibility="{StaticResource PhoneLightThemeVisibility}" />
<TextBlock Visibility="{StaticResource PhoneDarkThemeVisibility}" />
</pre>You can use a converter to manipulate other properties that are not of type Visibility.<br />
<br />
In C#:<br />
<pre name="code" class="brush:csharp">Visibility LightThemeVisibility = (Visibility)Resources["PhoneLightThemeVisibility"];
Visibility DarkThemeVisibility = (Visibility)Resources["PhoneDarkThemeVisibility"];
</pre>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2955246950758454841.post-23588831392500235452012-10-25T12:25:00.000+01:002012-10-25T15:31:39.044+01:00Windows Phone Flip AnimationYou can use the Projection class to produce the flip animation of a control.<br />
<br />
The following XAML ilustrates this:<br />
<pre class="brush:xml" name="code"><UserControl.Resources>
<Storyboard x:FieldModifier="private" x:Name="SBStartAnimation">
<DoubleAnimation Storyboard.TargetName="SPPanel" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)" From="-90" To="0" Duration="0:0:0.150" />
</Storyboard>
</UserControl.Resources>
<Border x:FieldModifier="private" x:Name="BShade" Background="#aa000000">
<StackPanel x:FieldModifier="private" x:Name="SPPanel" VerticalAlignment="Top" Background="#222222">
<StackPanel.Projection>
<PlaneProjection CenterOfRotationY="0.5" RotationX="0" />
</StackPanel.Projection>
<Image Source="/Background.png" HorizontalAlignment="Center" Stretch="None" />
<LC:ProgressLine x:FieldModifier="private" x:Name="PLProgress" Margin="0,-5,0,10" />
<TextBlock Text="Working, please wait..." HorizontalAlignment="Center" Margin="0,0,0,20" />
</StackPanel>
</Border>
</pre>The SPPanel Stackpanel is flipped as defined in the SBStartAnimation Storyboard.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2955246950758454841.post-83924639479574121932012-10-25T12:09:00.001+01:002012-10-25T15:35:00.726+01:00Windows Phone Backgound Color AnimationIn Silverlight for Windows Phone you can't animate a Brush so you can't animate the Background of a control.<br />
<br />
However, you can use the ColorAnimation class to animate the color of a Brush.<br />
<br />
The following XAML shows an example:<br />
<pre name="code" class="brush:xml"><UserControl.Resources>
<Storyboard x:FieldModifier="private" x:Name="SBStartAnimation">
<ColorAnimation Storyboard.TargetName="BShade" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" From="#00000000" To="#aa000000" Duration="0:0:0.150" />
</Storyboard>
</UserControl.Resources>
<Border x:FieldModifier="private" x:Name="BShade" Background="#aa000000" />
</pre>The BShade object must have it's Background property initialized.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2955246950758454841.post-18200066436924797312012-10-25T11:51:00.000+01:002012-10-25T17:18:23.377+01:00Windows Phone Margin AnimationIn Silverlight for Windows Phone the ThicknessAnimation class isn't available.<br />
<br />
You have two solutions:<br />
<ul><li>Place a transparent object on the left/top and animate it's Width/Height properties;</li>
<li>Place the object you want to animate in a Canvas and animate the object Left/Top properties. </li>
</ul>If you choose the second options, the XAML can look like this:<br />
<pre class="brush:xml" name="code"><UserControl.Resources>
<Storyboard x:FieldModifier="private" x:Name="SBUndeterminedAnimation">
<DoubleAnimation x:FieldModifier="private" x:Name="DAUndeterminedAnimation" AutoReverse="True" RepeatBehavior="Forever" Duration="0:0:2.000" From="0" Storyboard.TargetName="BProgress" Storyboard.TargetProperty="(Canvas.Left)" />
</Storyboard>
</UserControl.Resources>
<Grid>
<Canvas x:FieldModifier="private" x:Name="CTrack" Background="#19ff0000" Height="5" HorizontalAlignment="Stretch">
<Border x:FieldModifier="private" x:Name="BProgress" Background="#ffff0000" Height="5" Width="50" />
</Canvas>
</Grid>
</pre>This XAML is actually a custom ProgressBar that has both determined and undetermined behavior.<br />
<br />
The To property of the DAUndeterminedAnimation DoubleAnimation is set in code-behind.<span style="font-size: x-small;"><br />
</span>Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-2955246950758454841.post-39553115442435325132012-10-21T22:18:00.001+01:002012-10-21T23:41:36.509+01:00Cross-Platform Native Code GeneratorWhen creating an application for different platforms, you can create an HTML application that will fit every deployment or create a native application for each platform you want to traget.<br />
<br />
Creating an HTML application sure means less work, since the code (HTML+JavaScript+CSS) is fairly supported across web browsers.<br />
<br />
Of course, the User Interface (UI) will not match every system where the application will be deployed.<br />
<br />
Developing the application nativelly will allow the UI to be fully integrated with the OS.<br />
<br />
But a native application means a software project for each platform and this can be unmanageable.<br />
<br />
There are several solutions to this problem that minimize the coding of logic that is common to all of those software projects (business logic).<br />
<br />
One of them is AppDevPoint.<br />
<br />
This tool centralizes the business logic so that it's coded only once in one place.<br />
<br />
There must be native project for each platform since the UI is created natively this way being truly integrated with the OS.<br />
<br />
This methodology completely separates the UI from code. <br />
<br />
If the business logic has to be changed, simply code it in the AppDevPoint, regenerate the builds and all of your native projects will be updated in a single action.<br />
<br />
The binaries produced by the native compiler runs directly on the OS as this framework doesn't requires VMs or additional run-times to be installed.<br />
<br />
This tool is free and open-source.<br />
<br />
For more details, please visit:<br />
<a href="http://appdevpoint.webs.com/">http://appdevpoint.webs.com</a><br />
<a href="http://appdevpoint.codeplex.com/">http://appdevpoint.codeplex.com/</a>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2955246950758454841.post-47418299604554887432012-10-20T17:05:00.000+01:002012-10-21T22:33:31.309+01:00 Windows Phone Stateful FrameworkFor an windows phone application to pass the Microsoft certification, it must implement the tombstone state.<br />
<br />
In concept this is easy to achieve, but in practice we must be careful.<br />
<br />
This framework wraps the OnNavigatedTo and OnNavigatedFrom events of the page, exposing a set of methods one can override.<br />
<br />
There are two types of methods: navigation methods and state manipulation methods.<br />
<br />
The navigation methods allows the page to react to navigation events for initialization, clean-up, etc.<br />
<br />
The state manipulation methods is where the code to persist and restore the state must be implemented.<br />
<br />
A special state manipulation method is available for restoring the global state of the application.<br />
<br />
The state can be immutable if it doesn’t change throughout the page life-cycle, or changeable if otherwise.<br />
<br />
A page can be marked as transient this way optimizing the state manipulation methods.<br />
<br />
For source code, please visit <a href="http://wpstatefulframework.codeplex.com/">http://wpstatefulframework.codeplex.com/</a>Unknownnoreply@blogger.com0