Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion samples/Clock/Clock/Clock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ public class Clock
readonly Color BackColor = new Color (0xDD, 0xDD, 0xDD);
readonly Color FaceColor = new Color (0xCC, 0xCC, 0xCC);
readonly Color BorderColor = new Color (0x66, 0x66, 0x66);
readonly Font LabelFont = Font.SystemFontOfSize (16);
readonly Color RedColor = new Color (0xFF, 0x0, 0x0);
readonly Font LabelFont = Font.SystemFontOfSize (16);

//Custom Font Test
readonly Font CustomFont = Font.FromName("BILLY ARGEL FONT", "BILLY ARGEL TRIAL___.otf", "BILLY ARGEL FONT", 30);

public void Draw (IGraphics g)
{
Expand Down Expand Up @@ -47,6 +51,13 @@ public void Draw (IGraphics g)
var textWidth = g.GetFontMetrics ().StringWidth ("Cross Graphics");
g.DrawString ("Cross Graphics", center.X - textWidth / 2, center.Y + 0.25f * r);

//Custom Font Test
g.SetFont(CustomFont);
g.SetColor(RedColor);
var myString = "Custom Font Test";
textWidth = g.GetFontMetrics().StringWidth(myString);
g.DrawString(myString, center.X - textWidth / 2, center.Y - 0.25f * r);

//
// Draw the hour hand
//
Expand Down
32 changes: 25 additions & 7 deletions samples/Clock/ClockAndroid/Activity1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Android.OS;
using Android.Views;
using CrossGraphics.Android;
using Android.Util;

namespace Clock.Android
{
Expand All @@ -17,7 +18,9 @@ protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);

_view = new ClockView (this);
System.Diagnostics.Debug.WriteLine ("Density: " + Resources.DisplayMetrics.Density + ", DensityDpi: " + Resources.DisplayMetrics.DensityDpi + ", HeightPixels: " + Resources.DisplayMetrics.HeightPixels + ", ScaledDensity: " + Resources.DisplayMetrics.ScaledDensity + ", WidthPixels: " + Resources.DisplayMetrics.WidthPixels + ", Xdpi: " + Resources.DisplayMetrics.Xdpi + ", Ydpi: " + Resources.DisplayMetrics.Ydpi);

_view = new ClockView (this, 2.5f);
SetContentView (_view);

var timer = new Timer (1);
Expand All @@ -33,19 +36,34 @@ class ClockView : View
{
Clock _clock = new Clock ();

public ClockView (Context context)
: base (context)
public ClockView (Context context, float scaledDensity) : base (context)
{

}

public ClockView (Context context, float scaledDensity, IAttributeSet attrs) : base (context, attrs)
{

}

public ClockView (Context context, float scaledDensity, IAttributeSet attrs, int defStyle) : base (context, attrs, defStyle)
{

}


//protected View(IntPtr javaReference, JniHandleOwnership transfer);
//[Register(".ctor", "(Landroid/content/Context;Landroid/util/AttributeSet;I)V", "")]



public override void Draw (global::Android.Graphics.Canvas canvas)
{
base.Draw (canvas);

var g = new AndroidGraphics (canvas);

_clock.Width = Width;
_clock.Height = Height;
var g = new AndroidGraphics (canvas, Context);
_clock.Width = Width / Resources.DisplayMetrics.ScaledDensity;
_clock.Height = Height / Resources.DisplayMetrics.ScaledDensity;

_clock.Draw (g);
}
Expand Down
Binary file not shown.
10 changes: 8 additions & 2 deletions samples/Clock/ClockAndroid/ClockAndroid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<AndroidApplication>true</AndroidApplication>
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<TargetFrameworkVersion>v2.3</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -24,7 +26,6 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>
<AndroidLinkMode>None</AndroidLinkMode>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
Expand All @@ -35,7 +36,6 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
</PropertyGroup>
<ItemGroup>
<Reference Include="Mono.Android" />
Expand Down Expand Up @@ -63,6 +63,9 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<AndroidAsset Include="Assets\BILLY ARGEL TRIAL___.otf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</AndroidAsset>
<None Include="Resources\AboutResources.txt" />
<None Include="Assets\AboutAssets.txt" />
</ItemGroup>
Expand All @@ -75,6 +78,9 @@
<ItemGroup>
<AndroidResource Include="Resources\Drawable\Icon.png" />
</ItemGroup>
<ItemGroup>
<Content Include="Properties\AndroidManifest.xml" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
5 changes: 5 additions & 0 deletions samples/Clock/ClockAndroid/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="ClockAndroid.ClockAndroid" android:versionCode="1" android:versionName="1.0">
<uses-sdk />
<application android:label="ClockAndroid" android:icon="@drawable/Icon"></application>
</manifest>
185 changes: 112 additions & 73 deletions samples/Clock/ClockAndroid/Resources/Resource.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions samples/Clock/ClockSilverlight/Backup/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="Clock.Silverlight.App"
>
<Application.Resources>

</Application.Resources>
</Application>
65 changes: 65 additions & 0 deletions samples/Clock/ClockSilverlight/Backup/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Clock.Silverlight
{
public partial class App : Application
{

public App ()
{
this.Startup += this.Application_Startup;
this.Exit += this.Application_Exit;
this.UnhandledException += this.Application_UnhandledException;

InitializeComponent ();
}

private void Application_Startup (object sender, StartupEventArgs e)
{
this.RootVisual = new MainPage ();
}

private void Application_Exit (object sender, EventArgs e)
{

}

private void Application_UnhandledException (object sender, ApplicationUnhandledExceptionEventArgs e)
{
// If the app is running outside of the debugger then report the exception using
// the browser's exception mechanism. On IE this will display it a yellow alert
// icon in the status bar and Firefox will display a script error.
if (!System.Diagnostics.Debugger.IsAttached) {

// NOTE: This will allow the application to continue running after an exception has been thrown
// but not handled.
// For production applications this error handling should be replaced with something that will
// report the error to the website and stop the application.
e.Handled = true;
Deployment.Current.Dispatcher.BeginInvoke (delegate { ReportErrorToDOM (e); });
}
}

private void ReportErrorToDOM (ApplicationUnhandledExceptionEventArgs e)
{
try {
string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace;
errorMsg = errorMsg.Replace ('"', '\'').Replace ("\r\n", @"\n");

System.Windows.Browser.HtmlPage.Window.Eval ("throw new Error(\"Unhandled Error in Silverlight Application " + errorMsg + "\");");
}
catch (Exception) {
}
}
}
}
Loading