diff --git a/samples/Clock/Clock/Clock.cs b/samples/Clock/Clock/Clock.cs index 308e2ef..b9ec81c 100644 --- a/samples/Clock/Clock/Clock.cs +++ b/samples/Clock/Clock/Clock.cs @@ -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) { @@ -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 // diff --git a/samples/Clock/ClockAndroid/Activity1.cs b/samples/Clock/ClockAndroid/Activity1.cs index 3356952..2291923 100644 --- a/samples/Clock/ClockAndroid/Activity1.cs +++ b/samples/Clock/ClockAndroid/Activity1.cs @@ -5,6 +5,7 @@ using Android.OS; using Android.Views; using CrossGraphics.Android; +using Android.Util; namespace Clock.Android { @@ -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); @@ -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); } diff --git a/samples/Clock/ClockAndroid/Assets/BILLY ARGEL TRIAL___.otf b/samples/Clock/ClockAndroid/Assets/BILLY ARGEL TRIAL___.otf new file mode 100644 index 0000000..e084a2a Binary files /dev/null and b/samples/Clock/ClockAndroid/Assets/BILLY ARGEL TRIAL___.otf differ diff --git a/samples/Clock/ClockAndroid/ClockAndroid.csproj b/samples/Clock/ClockAndroid/ClockAndroid.csproj index 78e366f..df89c74 100644 --- a/samples/Clock/ClockAndroid/ClockAndroid.csproj +++ b/samples/Clock/ClockAndroid/ClockAndroid.csproj @@ -15,6 +15,8 @@ true Resources\Resource.Designer.cs Off + Properties\AndroidManifest.xml + v2.3 true @@ -24,7 +26,6 @@ DEBUG;TRACE prompt 4 - True None @@ -35,7 +36,6 @@ prompt 4 False - SdkOnly @@ -63,6 +63,9 @@ + + PreserveNewest + @@ -75,6 +78,9 @@ + + + + + v3.5 + + + true + full + false + Bin\Debug + DEBUG;TRACE;SILVERLIGHT + true + true + prompt + 4 + + + pdbonly + true + Bin\Release + TRACE;SILVERLIGHT + true + true + prompt + 4 + + + + + + + + + + + + + Graphics.cs + + + SilverlightGraphics.cs + + + System.Drawing.cs + + + Clock.cs + + + App.xaml + + + MainPage.xaml + + + + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/Clock/ClockSilverlight/Backup/ClockSilverlight.sln b/samples/Clock/ClockSilverlight/Backup/ClockSilverlight.sln new file mode 100644 index 0000000..11acecb --- /dev/null +++ b/samples/Clock/ClockSilverlight/Backup/ClockSilverlight.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClockSilverlight", "ClockSilverlight.csproj", "{97636F78-8852-4E21-9D3A-8931FCD43C7C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {97636F78-8852-4E21-9D3A-8931FCD43C7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {97636F78-8852-4E21-9D3A-8931FCD43C7C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {97636F78-8852-4E21-9D3A-8931FCD43C7C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {97636F78-8852-4E21-9D3A-8931FCD43C7C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/samples/Clock/ClockSilverlight/Backup/Graphics.cs b/samples/Clock/ClockSilverlight/Backup/Graphics.cs new file mode 100644 index 0000000..57819d4 --- /dev/null +++ b/samples/Clock/ClockSilverlight/Backup/Graphics.cs @@ -0,0 +1,559 @@ +// +// Copyright (c) 2010-2012 Frank A. Krueger +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +using System; +using System.Collections.Generic; +using System.Drawing; + +namespace CrossGraphics +{ + public interface IGraphics + { + void BeginEntity(object entity); + + void SetFont(Font f); + + void SetColor(Color c); + + void Clear (Color c); + + void FillPolygon(Polygon poly); + + void DrawPolygon(Polygon poly,float w); + + void FillRect(float x,float y,float width, float height); + + void DrawRect(float x, float y, float width, float height, float w); + + void FillRoundedRect(float x, float y, float width, float height, float radius); + + void DrawRoundedRect(float x, float y, float width, float height, float radius, float w); + + void FillOval(float x, float y, float width, float height); + + void DrawOval(float x, float y, float width, float height, float w); + + void BeginLines(bool rounded); + + void DrawLine(float sx, float sy, float ex, float ey, float w); + + void EndLines(); + + void FillArc(float cx, float cy, float radius, float startAngle, float endAngle); + + void DrawArc(float cx, float cy, float radius, float startAngle, float endAngle, float w); + + void DrawImage(IImage img, float x, float y, float width, float height); + + void DrawString(string s, float x, float y, float width, float height, LineBreakMode lineBreak, TextAlignment align); + + void DrawString(string s, float x, float y); + + void SaveState(); + + void SetClippingRect (float x, float y, float width, float height); + + void Translate(float dx, float dy); + + void Scale(float sx, float sy); + + void RestoreState(); + + IFontMetrics GetFontMetrics(); + + IImage ImageFromFile(string path); + } + + public enum LineBreakMode { + None, + Clip, + WordWrap, + } + + public enum TextAlignment { + Left, + Center, + Right, + Justified + } + + public static class GraphicsEx + { + public static void DrawString (this IGraphics g, string s, PointF p) + { + g.DrawString(s, p.X, p.Y); + } + + public static void DrawString(this IGraphics g, string s, PointF p, Font f) + { + g.SetFont (f); + g.DrawString (s, p.X, p.Y); + } + + public static void DrawString(this IGraphics g, string s, RectangleF p, Font f, LineBreakMode lineBreak, TextAlignment align) + { + g.SetFont (f); + g.DrawString (s, p.Left, p.Top, p.Width, p.Height, lineBreak, align); + } + + public static void DrawLine(this IGraphics g, PointF s, PointF e, float w) + { + g.DrawLine (s.X, s.Y, e.X, e.Y, w); + } + + public static void DrawRoundedRect(this IGraphics g, RectangleF r, float radius, float w) + { + g.DrawRoundedRect (r.Left, r.Top, r.Width, r.Height, radius, w); + } + + public static void DrawRoundedRect(this IGraphics g, Rectangle r, float radius, float w) + { + g.DrawRoundedRect(r.Left, r.Top, r.Width, r.Height, radius, w); + } + + public static void FillRoundedRect(this IGraphics g, RectangleF r, float radius) + { + g.FillRoundedRect (r.Left, r.Top, r.Width, r.Height, radius); + } + + public static void FillRoundedRect(this IGraphics g, Rectangle r, float radius) + { + g.FillRoundedRect (r.Left, r.Top, r.Width, r.Height, radius); + } + + public static void FillRect(this IGraphics g, RectangleF r) + { + g.FillRect (r.Left, r.Top, r.Width, r.Height); + } + + public static void FillRect(this IGraphics g, Rectangle r) + { + g.FillRect(r.Left, r.Top, r.Width, r.Height); + } + + public static void DrawRect(this IGraphics g, RectangleF r, float w) + { + g.DrawRect (r.Left, r.Top, r.Width, r.Height, w); + } + + public static void DrawRect(this IGraphics g, Rectangle r, float w) + { + g.DrawRect(r.Left, r.Top, r.Width, r.Height, w); + } + + public static void FillOval(this IGraphics g, RectangleF r) + { + g.FillOval (r.Left, r.Top, r.Width, r.Height); + } + + public static void DrawOval(this IGraphics g, RectangleF r, float w) + { + g.DrawOval (r.Left, r.Top, r.Width, r.Height, w); + } + } + + public interface IImage + { + } + + [Flags] + public enum FontOptions + { + None = 0, + Bold = 1 + } + + public class Font + { + public string FontFamily { get; private set; } + + public string FontFilename { get; private set; } + + public FontOptions Options { get; private set; } + + public int Size { get; private set; } + + public object Tag { get; set; } + + public bool IsBold { get { return (Options & FontOptions.Bold) != 0; } } + + public Font (string fontFileName, string fontFamily, FontOptions options, int size) + { + FontFilename = fontFileName; + FontFamily = fontFamily; + Options = options; + Size = size; + } + + static Font[] _boldSystemFonts = new Font[0]; + static Font[] _systemFonts = new Font[0]; + static Font[] _userFixedPitchFonts = new Font[0]; + static Font[] _boldUserFixedPitchFonts = new Font[0]; + + public static Font BoldSystemFontOfSize (int size) { + if (size >= _boldSystemFonts.Length) { + return new Font ("", "SystemFont", FontOptions.Bold, size); + } + else { + var f = _boldSystemFonts[size]; + if (f == null) { + f = new Font ("", "SystemFont", FontOptions.Bold, size); + _boldSystemFonts[size] = f; + } + return f; + } + } + public static Font SystemFontOfSize (int size) { + if (size >= _systemFonts.Length) { + return new Font ("", "SystemFont", FontOptions.None, size); + } + else { + var f = _systemFonts[size]; + if (f == null) { + f = new Font ("", "SystemFont", FontOptions.None, size); + _systemFonts[size] = f; + } + return f; + } + } + public static Font UserFixedPitchFontOfSize (int size) { + if (size >= _userFixedPitchFonts.Length) { + return new Font ("", "Monospace", FontOptions.None, size); + } + else { + var f = _userFixedPitchFonts[size]; + if (f == null) { + f = new Font ("", "Monospace", FontOptions.None, size); + _userFixedPitchFonts[size] = f; + } + return f; + } + } + public static Font BoldUserFixedPitchFontOfSize (int size) { + if (size >= _boldUserFixedPitchFonts.Length) { + return new Font ("", "Monospace", FontOptions.Bold, size); + } + else { + var f = _boldUserFixedPitchFonts[size]; + if (f == null) { + f = new Font ("", "Monospace", FontOptions.Bold, size); + _boldUserFixedPitchFonts[size] = f; + } + return f; + } + } + + + //Customs Fonts + //iOS: + //You have to modify your info.plist and add the entry 'Fonts provided by application' UIAppFonts for your custom fonts and copy the fonts to your Bundle as BundleResource + //Not all fonts seem to work and I couldn't find out why + // + //Android: + //Copy the fonts to your Assets folder as AndroidAsset; remember to use the full filename to load the font like Font.FromName("UniversLTStd-LightCn.otf", "Univers LT Std", 18); + // + //Windows Phone/Store: + //According to + //http://stackoverflow.com/questions/14085818/custom-font-usage-in-windows-phone-8 + //you have to set the real font name not only the filename for windows phone like Font.FromName("UniversLTStd-LightCn.otf", "Univers LT Std", 18); + //The fonts should be copied inside a 'Fonts' folder. The custom fonts should be as type 'Content' + + public static Font FromName(string fontFileName, string name, int size) + { + return new Font(fontFileName, name, FontOptions.None, size); + } + + public override string ToString() + { + return string.Format ("[Font: FontFamily={0}, Options={1}, Size={2}, Tag={3}]", FontFamily, Options, Size, Tag); + } + } + + public interface IFontMetrics + { + int StringWidth(string s, int startIndex, int length); + + int Height { get; } + + int Ascent { get; } + + int Descent { get; } + } + + public static class FontMetricsEx + { + public static int StringWidth (this IFontMetrics fm, string s) + { + return fm.StringWidth (s, 0, s.Length); + } + } + + public class Color + { + public readonly int Red, Green, Blue, Alpha; + public object Tag; + + public float RedValue { + get { return Red / 255.0f; } + } + + public float GreenValue { + get { return Green / 255.0f; } + } + + public float BlueValue { + get { return Blue / 255.0f; } + } + + public float AlphaValue { + get { return Alpha / 255.0f; } + } + + public Color (int red, int green, int blue) + { + Red = red; + Green = green; + Blue = blue; + Alpha = 255; + } + + public Color (int red, int green, int blue, int alpha) + { + Red = red; + Green = green; + Blue = blue; + Alpha = alpha; + } + + public Color(float red, float green, float blue) + { + Red = (int)(red * 255); + Green = (int)(green * 255); + Blue = (int)(blue * 255); + Alpha = 255; + } + + public Color(float red, float green, float blue, float alpha) + { + Red = (int)(red * 255); + Green = (int)(green * 255); + Blue = (int)(blue * 255); + Alpha = (int)(alpha * 255); + } + + public int Intensity { get { return (Red + Green + Blue) / 3; } } + + public Color GetInvertedColor() + { + return new Color (255 - Red, 255 - Green, 255 - Blue, Alpha); + } + + public static bool AreEqual(Color a, Color b) + { + if (a == null && b == null) + return true; + if (a == null && b != null) + return false; + if (a != null && b == null) + return false; + return (a.Red == b.Red && a.Green == b.Green && a.Blue == b.Blue && a.Alpha == b.Alpha); + } + + public bool IsWhite { + get { return (Red == 255) && (Green == 255) && (Blue == 255); } + } + + public bool IsBlack { + get { return (Red == 0) && (Green == 0) && (Blue == 0); } + } + + public Color WithAlpha(int aa) + { + return new Color (Red, Green, Blue, aa); + } + + public override bool Equals (object obj) + { + var o = obj as Color; + return (o != null) && (o.Red == Red) && (o.Green == Green) && (o.Blue == Blue) && (o.Alpha == Alpha); + } + + public override int GetHashCode () + { + return (Red + Green + Blue + Alpha).GetHashCode (); + } + + public override string ToString() + { + return string.Format ("[Color: RedValue={0}, GreenValue={1}, BlueValue={2}, AlphaValue={3}]", RedValue, GreenValue, BlueValue, AlphaValue); + } + } + + public static class Colors + { + public static readonly Color Yellow = new Color (255, 255, 0); + public static readonly Color Red = new Color (255, 0, 0); + public static readonly Color Green = new Color (0, 255, 0); + public static readonly Color Blue = new Color (0, 0, 255); + public static readonly Color White = new Color (255, 255, 255); + public static readonly Color Cyan = new Color (0, 255, 255); + public static readonly Color Black = new Color (0, 0, 0); + public static readonly Color LightGray = new Color (212, 212, 212); + public static readonly Color Gray = new Color (127, 127, 127); + public static readonly Color DarkGray = new Color (64, 64, 64); + } + + public class Polygon + { + public readonly List Points; + + public object Tag { get; set; } + + public int Version { get; set; } + + public Polygon () + { + Points = new List (); + } + + public Polygon (int[] xs, int[] ys, int c) + { + Points = new List (c); + for (var i = 0; i < c; i++) { + Points.Add (new PointF (xs [i], ys [i])); + } + } + + public int Count { + get { return Points.Count; } + } + + public void Clear() + { + Points.Clear (); + Version++; + } + + public void AddPoint(PointF p) + { + Points.Add (p); + Version++; + } + + public void AddPoint(float x, float y) + { + Points.Add (new PointF (x, y)); + Version++; + } + } + + public struct Transform2D + { + public float M11, M12, M13; + public float M21, M22, M23; + //public float M31, M32, M33; + + public void Apply (float x, float y, out float xp, out float yp) + { + xp = M11 * x + M12 * y + M13; + yp = M21 * x + M22 * y + M23; + } + + public static Transform2D operator * (Transform2D l, Transform2D r) + { + var t = new Transform2D (); + + t.M11 = l.M11 * r.M11 + l.M12 * r.M21;// +l.M13 * r.M31; + t.M12 = l.M11 * r.M12 + l.M12 * r.M22;// +l.M13 * r.M32; + t.M13 = l.M11 * r.M13 + l.M12 * r.M23 + l.M13;// *r.M33; + + t.M21 = l.M21 * r.M11 + l.M22 * r.M21;// +l.M23 * r.M31; + t.M22 = l.M21 * r.M12 + l.M22 * r.M22;// +l.M23 * r.M32; + t.M23 = l.M21 * r.M13 + l.M22 * r.M23 + l.M23;// *r.M33; + + //t.M31 = l.M31 * r.M11 + l.M32 * r.M21 + l.M33 * r.M31; + //t.M32 = l.M31 * r.M12 + l.M32 * r.M22 + l.M33 * r.M32; + //t.M33 = l.M31 * r.M13 + l.M32 * r.M23 + l.M33 * r.M33; + + return t; + } + + public static Transform2D Identity () + { + var t = new Transform2D (); + t.M11 = 1; + t.M22 = 1; + //t.M33 = 1; + return t; + } + + public static Transform2D Translate (float x, float y) + { + var t = new Transform2D (); + t.M11 = 1; + t.M22 = 1; + //t.M33 = 1; + t.M13 = x; + t.M23 = y; + return t; + } + public static Transform2D Scale (float x, float y) + { + var t = new Transform2D (); + t.M11 = x; + t.M22 = y; + //t.M33 = 1; + return t; + } + } + + public static class RectangleEx + { + public static RectangleF ToRectangleF (this System.Drawing.Rectangle r) + { + return new RectangleF (r.X, r.Y, r.Width, r.Height); + } + + public static System.Drawing.Point GetCenter (this System.Drawing.Rectangle r) + { + return new System.Drawing.Point (r.Left + r.Width / 2, + r.Top + r.Height / 2); + } + + public static System.Drawing.PointF GetCenter (this System.Drawing.RectangleF r) + { + return new System.Drawing.PointF (r.X + r.Width / 2.0f, + r.Y + r.Height / 2.0f); + } + + public static List GetIntersections (this List boxes, RectangleF box) + { + var r = new List (); + foreach (var b in boxes) { + if (b.IntersectsWith (box)) { + r.Add (b); + } + } + return r; + } + } +} + diff --git a/samples/Clock/ClockSilverlight/Backup/MainPage.xaml b/samples/Clock/ClockSilverlight/Backup/MainPage.xaml new file mode 100644 index 0000000..81f7661 --- /dev/null +++ b/samples/Clock/ClockSilverlight/Backup/MainPage.xaml @@ -0,0 +1,12 @@ + + + + + + diff --git a/samples/Clock/ClockSilverlight/Backup/MainPage.xaml.cs b/samples/Clock/ClockSilverlight/Backup/MainPage.xaml.cs new file mode 100644 index 0000000..41e16bc --- /dev/null +++ b/samples/Clock/ClockSilverlight/Backup/MainPage.xaml.cs @@ -0,0 +1,53 @@ +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; +using CrossGraphics.SilverlightGraphics; +using System.Windows.Threading; + +namespace Clock.Silverlight +{ + public partial class MainPage : UserControl + { + Clock _clock; + SilverlightGraphics _graphics; + + public MainPage () + { + InitializeComponent (); + _clock = new Clock (); + } + + private void UserControl_Loaded (object sender, RoutedEventArgs e) + { + _graphics = new SilverlightGraphics (LayoutRoot); + + var timer = new DispatcherTimer { + Interval = TimeSpan.FromSeconds (1), + }; + timer.Tick += delegate { + Draw (); + }; + timer.Start (); + } + + void Draw () + { + _clock.Width = (float)LayoutRoot.ActualWidth; + _clock.Height = (float)LayoutRoot.ActualHeight; + + _graphics.BeginDrawing (); + + _clock.Draw (_graphics); + + _graphics.EndDrawing (); + } + } +} diff --git a/samples/Clock/ClockWP7/Properties/AppManifest.xml b/samples/Clock/ClockSilverlight/Backup/Properties/AppManifest.xml similarity index 100% rename from samples/Clock/ClockWP7/Properties/AppManifest.xml rename to samples/Clock/ClockSilverlight/Backup/Properties/AppManifest.xml diff --git a/samples/Clock/ClockSilverlight/Backup/Properties/AssemblyInfo.cs b/samples/Clock/ClockSilverlight/Backup/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..8661553 --- /dev/null +++ b/samples/Clock/ClockSilverlight/Backup/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle ("ClockSilverlight")] +[assembly: AssemblyDescription ("")] +[assembly: AssemblyConfiguration ("")] +[assembly: AssemblyCompany ("")] +[assembly: AssemblyProduct ("ClockSilverlight")] +[assembly: AssemblyCopyright ("Copyright © 2012")] +[assembly: AssemblyTrademark ("")] +[assembly: AssemblyCulture ("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible (false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid ("53cf5958-6765-428d-a3b8-69790d7eee9f")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion ("1.0.0.0")] +[assembly: AssemblyFileVersion ("1.0.0.0")] diff --git a/samples/Clock/ClockSilverlight/Backup/System.Drawing.cs b/samples/Clock/ClockSilverlight/Backup/System.Drawing.cs new file mode 100644 index 0000000..64e6e2a --- /dev/null +++ b/samples/Clock/ClockSilverlight/Backup/System.Drawing.cs @@ -0,0 +1,189 @@ +// +// Copyright (c) 2010 Frank A. Krueger +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +using System; + +namespace System.Drawing +{ + public struct RectangleF + { + public float X, Y, Width, Height; + + public float Left { get { return X; } } + public float Top { get { return Y; } } + + public float Right { get { return X + Width; } } + public float Bottom { get { return Y + Height; } } + + public RectangleF (float left, float top, float width, float height) + { + X = left; + Y = top; + Width = width; + Height = height; + } + + public void Inflate (float width, float height) + { + Inflate (new SizeF (width, height)); + } + + public void Inflate (SizeF size) + { + X -= size.Width; + Y -= size.Height; + Width += size.Width * 2; + Height += size.Height * 2; + } + + public bool IntersectsWith(RectangleF rect) + { + return !((Left >= rect.Right) || (Right <= rect.Left) || + (Top >= rect.Bottom) || (Bottom <= rect.Top)); + } + + public bool Contains(PointF loc) + { + return (X <= loc.X && loc.X < (X + Width) && Y <= loc.Y && loc.Y < (Y + Height)); + } + + public override string ToString() + { + return string.Format("[RectangleF: Left={0} Top={1} Width={2} Height={3}]", Left, Top, Width, Height); + } + } + + public struct Rectangle + { + public int X, Y, Width, Height; + + public int Left { get { return X; } } + + public int Top { get { return Y; } } + + public int Bottom { get { return Top + Height; } } + + public int Right { get { return Left + Width; } } + + public Rectangle (int left, int top, int width, int height) + { + X = left; + Y = top; + Width = width; + Height = height; + } + + public void Offset (int dx, int dy) + { + X += dx; + Y += dy; + } + + public bool Contains (int x, int y) + { + return (x >= X && x < X + Width) && (y >= Y && y < Y + Height); + } + + public static Rectangle Union (Rectangle a, Rectangle b) + { + var left = Math.Min (a.Left, b.Left); + var top = Math.Min (a.Top, b.Top); + return new Rectangle (left, + top, + Math.Max (a.Right, b.Right) - left, + Math.Max (a.Bottom, b.Bottom) - top); + } + + public bool IntersectsWith (Rectangle rect) + { + return !((Left >= rect.Right) || (Right <= rect.Left) || + (Top >= rect.Bottom) || (Bottom <= rect.Top)); + } + + public void Inflate (int width, int height) + { + Inflate (new Size (width, height)); + } + + public void Inflate (Size size) + { + X -= size.Width; + Y -= size.Height; + Width += size.Width * 2; + Height += size.Height * 2; + } + + public override string ToString () + { + return string.Format ("[Rectangle: Left={0} Top={1} Width={2} Height={3}]", Left, Top, Width, Height); + } + } + + public struct PointF + { + public float X, Y; + + public PointF (float x, float y) + { + X = x; + Y = y; + } + + public override string ToString() + { + return string.Format("({0}, {1})", X, Y); + } + } + + public struct Point + { + public int X, Y; + + public Point (int x, int y) + { + X = x; + Y = y; + } + } + + public struct Size + { + public int Width, Height; + + public Size (int width, int height) + { + Width = width; + Height = height; + } + } + + public struct SizeF + { + public float Width, Height; + + public SizeF (float width, float height) + { + Width = width; + Height = height; + } + } +} + diff --git a/samples/Clock/ClockSilverlight/ClockSilverlight.csproj b/samples/Clock/ClockSilverlight/ClockSilverlight.csproj index 33281b5..a081ad6 100644 --- a/samples/Clock/ClockSilverlight/ClockSilverlight.csproj +++ b/samples/Clock/ClockSilverlight/ClockSilverlight.csproj @@ -1,5 +1,5 @@  - + Debug AnyCPU @@ -12,7 +12,7 @@ Clock.Silverlight ClockSilverlight Silverlight - v4.0 + v5.0 $(TargetFrameworkVersion) true @@ -31,6 +31,11 @@ true + + + + + 4.0 + \ No newline at end of file diff --git a/samples/Clock/ClockSvg/Backup/ClockSvg.sln b/samples/Clock/ClockSvg/Backup/ClockSvg.sln new file mode 100644 index 0000000..82cb361 --- /dev/null +++ b/samples/Clock/ClockSvg/Backup/ClockSvg.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClockSvg", "ClockSvg.csproj", "{69365CC0-8B33-450F-8344-F710DBCFCF5B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {69365CC0-8B33-450F-8344-F710DBCFCF5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {69365CC0-8B33-450F-8344-F710DBCFCF5B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {69365CC0-8B33-450F-8344-F710DBCFCF5B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {69365CC0-8B33-450F-8344-F710DBCFCF5B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/samples/Clock/ClockSvg/Backup/Default.aspx b/samples/Clock/ClockSvg/Backup/Default.aspx new file mode 100644 index 0000000..f213c80 --- /dev/null +++ b/samples/Clock/ClockSvg/Backup/Default.aspx @@ -0,0 +1,36 @@ +<%@ Page Language="C#" AutoEventWireup="true" %> + + + + CrossGraphics Clock SVG Sample + + +
+ + <% + Func GetClockSvg = delegate { + var rect = new System.Drawing.RectangleF (0, 0, 400, 400); + var clock = new Clock.Clock (); + using (var w = new System.IO.StringWriter ()) { + var g = new CrossGraphics.Svg.SvgGraphics (w, rect) { + IncludeXmlAndDoctype = false, + }; + g.BeginDrawing (); + clock.Width = rect.Width; + clock.Height = rect.Height; + clock.Draw (g); + g.EndDrawing (); + return w.ToString (); + } + }; + %> + + <%=GetClockSvg() %> + + + + + + diff --git a/samples/Clock/ClockSvg/Backup/Graphics.cs b/samples/Clock/ClockSvg/Backup/Graphics.cs new file mode 100644 index 0000000..57819d4 --- /dev/null +++ b/samples/Clock/ClockSvg/Backup/Graphics.cs @@ -0,0 +1,559 @@ +// +// Copyright (c) 2010-2012 Frank A. Krueger +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +using System; +using System.Collections.Generic; +using System.Drawing; + +namespace CrossGraphics +{ + public interface IGraphics + { + void BeginEntity(object entity); + + void SetFont(Font f); + + void SetColor(Color c); + + void Clear (Color c); + + void FillPolygon(Polygon poly); + + void DrawPolygon(Polygon poly,float w); + + void FillRect(float x,float y,float width, float height); + + void DrawRect(float x, float y, float width, float height, float w); + + void FillRoundedRect(float x, float y, float width, float height, float radius); + + void DrawRoundedRect(float x, float y, float width, float height, float radius, float w); + + void FillOval(float x, float y, float width, float height); + + void DrawOval(float x, float y, float width, float height, float w); + + void BeginLines(bool rounded); + + void DrawLine(float sx, float sy, float ex, float ey, float w); + + void EndLines(); + + void FillArc(float cx, float cy, float radius, float startAngle, float endAngle); + + void DrawArc(float cx, float cy, float radius, float startAngle, float endAngle, float w); + + void DrawImage(IImage img, float x, float y, float width, float height); + + void DrawString(string s, float x, float y, float width, float height, LineBreakMode lineBreak, TextAlignment align); + + void DrawString(string s, float x, float y); + + void SaveState(); + + void SetClippingRect (float x, float y, float width, float height); + + void Translate(float dx, float dy); + + void Scale(float sx, float sy); + + void RestoreState(); + + IFontMetrics GetFontMetrics(); + + IImage ImageFromFile(string path); + } + + public enum LineBreakMode { + None, + Clip, + WordWrap, + } + + public enum TextAlignment { + Left, + Center, + Right, + Justified + } + + public static class GraphicsEx + { + public static void DrawString (this IGraphics g, string s, PointF p) + { + g.DrawString(s, p.X, p.Y); + } + + public static void DrawString(this IGraphics g, string s, PointF p, Font f) + { + g.SetFont (f); + g.DrawString (s, p.X, p.Y); + } + + public static void DrawString(this IGraphics g, string s, RectangleF p, Font f, LineBreakMode lineBreak, TextAlignment align) + { + g.SetFont (f); + g.DrawString (s, p.Left, p.Top, p.Width, p.Height, lineBreak, align); + } + + public static void DrawLine(this IGraphics g, PointF s, PointF e, float w) + { + g.DrawLine (s.X, s.Y, e.X, e.Y, w); + } + + public static void DrawRoundedRect(this IGraphics g, RectangleF r, float radius, float w) + { + g.DrawRoundedRect (r.Left, r.Top, r.Width, r.Height, radius, w); + } + + public static void DrawRoundedRect(this IGraphics g, Rectangle r, float radius, float w) + { + g.DrawRoundedRect(r.Left, r.Top, r.Width, r.Height, radius, w); + } + + public static void FillRoundedRect(this IGraphics g, RectangleF r, float radius) + { + g.FillRoundedRect (r.Left, r.Top, r.Width, r.Height, radius); + } + + public static void FillRoundedRect(this IGraphics g, Rectangle r, float radius) + { + g.FillRoundedRect (r.Left, r.Top, r.Width, r.Height, radius); + } + + public static void FillRect(this IGraphics g, RectangleF r) + { + g.FillRect (r.Left, r.Top, r.Width, r.Height); + } + + public static void FillRect(this IGraphics g, Rectangle r) + { + g.FillRect(r.Left, r.Top, r.Width, r.Height); + } + + public static void DrawRect(this IGraphics g, RectangleF r, float w) + { + g.DrawRect (r.Left, r.Top, r.Width, r.Height, w); + } + + public static void DrawRect(this IGraphics g, Rectangle r, float w) + { + g.DrawRect(r.Left, r.Top, r.Width, r.Height, w); + } + + public static void FillOval(this IGraphics g, RectangleF r) + { + g.FillOval (r.Left, r.Top, r.Width, r.Height); + } + + public static void DrawOval(this IGraphics g, RectangleF r, float w) + { + g.DrawOval (r.Left, r.Top, r.Width, r.Height, w); + } + } + + public interface IImage + { + } + + [Flags] + public enum FontOptions + { + None = 0, + Bold = 1 + } + + public class Font + { + public string FontFamily { get; private set; } + + public string FontFilename { get; private set; } + + public FontOptions Options { get; private set; } + + public int Size { get; private set; } + + public object Tag { get; set; } + + public bool IsBold { get { return (Options & FontOptions.Bold) != 0; } } + + public Font (string fontFileName, string fontFamily, FontOptions options, int size) + { + FontFilename = fontFileName; + FontFamily = fontFamily; + Options = options; + Size = size; + } + + static Font[] _boldSystemFonts = new Font[0]; + static Font[] _systemFonts = new Font[0]; + static Font[] _userFixedPitchFonts = new Font[0]; + static Font[] _boldUserFixedPitchFonts = new Font[0]; + + public static Font BoldSystemFontOfSize (int size) { + if (size >= _boldSystemFonts.Length) { + return new Font ("", "SystemFont", FontOptions.Bold, size); + } + else { + var f = _boldSystemFonts[size]; + if (f == null) { + f = new Font ("", "SystemFont", FontOptions.Bold, size); + _boldSystemFonts[size] = f; + } + return f; + } + } + public static Font SystemFontOfSize (int size) { + if (size >= _systemFonts.Length) { + return new Font ("", "SystemFont", FontOptions.None, size); + } + else { + var f = _systemFonts[size]; + if (f == null) { + f = new Font ("", "SystemFont", FontOptions.None, size); + _systemFonts[size] = f; + } + return f; + } + } + public static Font UserFixedPitchFontOfSize (int size) { + if (size >= _userFixedPitchFonts.Length) { + return new Font ("", "Monospace", FontOptions.None, size); + } + else { + var f = _userFixedPitchFonts[size]; + if (f == null) { + f = new Font ("", "Monospace", FontOptions.None, size); + _userFixedPitchFonts[size] = f; + } + return f; + } + } + public static Font BoldUserFixedPitchFontOfSize (int size) { + if (size >= _boldUserFixedPitchFonts.Length) { + return new Font ("", "Monospace", FontOptions.Bold, size); + } + else { + var f = _boldUserFixedPitchFonts[size]; + if (f == null) { + f = new Font ("", "Monospace", FontOptions.Bold, size); + _boldUserFixedPitchFonts[size] = f; + } + return f; + } + } + + + //Customs Fonts + //iOS: + //You have to modify your info.plist and add the entry 'Fonts provided by application' UIAppFonts for your custom fonts and copy the fonts to your Bundle as BundleResource + //Not all fonts seem to work and I couldn't find out why + // + //Android: + //Copy the fonts to your Assets folder as AndroidAsset; remember to use the full filename to load the font like Font.FromName("UniversLTStd-LightCn.otf", "Univers LT Std", 18); + // + //Windows Phone/Store: + //According to + //http://stackoverflow.com/questions/14085818/custom-font-usage-in-windows-phone-8 + //you have to set the real font name not only the filename for windows phone like Font.FromName("UniversLTStd-LightCn.otf", "Univers LT Std", 18); + //The fonts should be copied inside a 'Fonts' folder. The custom fonts should be as type 'Content' + + public static Font FromName(string fontFileName, string name, int size) + { + return new Font(fontFileName, name, FontOptions.None, size); + } + + public override string ToString() + { + return string.Format ("[Font: FontFamily={0}, Options={1}, Size={2}, Tag={3}]", FontFamily, Options, Size, Tag); + } + } + + public interface IFontMetrics + { + int StringWidth(string s, int startIndex, int length); + + int Height { get; } + + int Ascent { get; } + + int Descent { get; } + } + + public static class FontMetricsEx + { + public static int StringWidth (this IFontMetrics fm, string s) + { + return fm.StringWidth (s, 0, s.Length); + } + } + + public class Color + { + public readonly int Red, Green, Blue, Alpha; + public object Tag; + + public float RedValue { + get { return Red / 255.0f; } + } + + public float GreenValue { + get { return Green / 255.0f; } + } + + public float BlueValue { + get { return Blue / 255.0f; } + } + + public float AlphaValue { + get { return Alpha / 255.0f; } + } + + public Color (int red, int green, int blue) + { + Red = red; + Green = green; + Blue = blue; + Alpha = 255; + } + + public Color (int red, int green, int blue, int alpha) + { + Red = red; + Green = green; + Blue = blue; + Alpha = alpha; + } + + public Color(float red, float green, float blue) + { + Red = (int)(red * 255); + Green = (int)(green * 255); + Blue = (int)(blue * 255); + Alpha = 255; + } + + public Color(float red, float green, float blue, float alpha) + { + Red = (int)(red * 255); + Green = (int)(green * 255); + Blue = (int)(blue * 255); + Alpha = (int)(alpha * 255); + } + + public int Intensity { get { return (Red + Green + Blue) / 3; } } + + public Color GetInvertedColor() + { + return new Color (255 - Red, 255 - Green, 255 - Blue, Alpha); + } + + public static bool AreEqual(Color a, Color b) + { + if (a == null && b == null) + return true; + if (a == null && b != null) + return false; + if (a != null && b == null) + return false; + return (a.Red == b.Red && a.Green == b.Green && a.Blue == b.Blue && a.Alpha == b.Alpha); + } + + public bool IsWhite { + get { return (Red == 255) && (Green == 255) && (Blue == 255); } + } + + public bool IsBlack { + get { return (Red == 0) && (Green == 0) && (Blue == 0); } + } + + public Color WithAlpha(int aa) + { + return new Color (Red, Green, Blue, aa); + } + + public override bool Equals (object obj) + { + var o = obj as Color; + return (o != null) && (o.Red == Red) && (o.Green == Green) && (o.Blue == Blue) && (o.Alpha == Alpha); + } + + public override int GetHashCode () + { + return (Red + Green + Blue + Alpha).GetHashCode (); + } + + public override string ToString() + { + return string.Format ("[Color: RedValue={0}, GreenValue={1}, BlueValue={2}, AlphaValue={3}]", RedValue, GreenValue, BlueValue, AlphaValue); + } + } + + public static class Colors + { + public static readonly Color Yellow = new Color (255, 255, 0); + public static readonly Color Red = new Color (255, 0, 0); + public static readonly Color Green = new Color (0, 255, 0); + public static readonly Color Blue = new Color (0, 0, 255); + public static readonly Color White = new Color (255, 255, 255); + public static readonly Color Cyan = new Color (0, 255, 255); + public static readonly Color Black = new Color (0, 0, 0); + public static readonly Color LightGray = new Color (212, 212, 212); + public static readonly Color Gray = new Color (127, 127, 127); + public static readonly Color DarkGray = new Color (64, 64, 64); + } + + public class Polygon + { + public readonly List Points; + + public object Tag { get; set; } + + public int Version { get; set; } + + public Polygon () + { + Points = new List (); + } + + public Polygon (int[] xs, int[] ys, int c) + { + Points = new List (c); + for (var i = 0; i < c; i++) { + Points.Add (new PointF (xs [i], ys [i])); + } + } + + public int Count { + get { return Points.Count; } + } + + public void Clear() + { + Points.Clear (); + Version++; + } + + public void AddPoint(PointF p) + { + Points.Add (p); + Version++; + } + + public void AddPoint(float x, float y) + { + Points.Add (new PointF (x, y)); + Version++; + } + } + + public struct Transform2D + { + public float M11, M12, M13; + public float M21, M22, M23; + //public float M31, M32, M33; + + public void Apply (float x, float y, out float xp, out float yp) + { + xp = M11 * x + M12 * y + M13; + yp = M21 * x + M22 * y + M23; + } + + public static Transform2D operator * (Transform2D l, Transform2D r) + { + var t = new Transform2D (); + + t.M11 = l.M11 * r.M11 + l.M12 * r.M21;// +l.M13 * r.M31; + t.M12 = l.M11 * r.M12 + l.M12 * r.M22;// +l.M13 * r.M32; + t.M13 = l.M11 * r.M13 + l.M12 * r.M23 + l.M13;// *r.M33; + + t.M21 = l.M21 * r.M11 + l.M22 * r.M21;// +l.M23 * r.M31; + t.M22 = l.M21 * r.M12 + l.M22 * r.M22;// +l.M23 * r.M32; + t.M23 = l.M21 * r.M13 + l.M22 * r.M23 + l.M23;// *r.M33; + + //t.M31 = l.M31 * r.M11 + l.M32 * r.M21 + l.M33 * r.M31; + //t.M32 = l.M31 * r.M12 + l.M32 * r.M22 + l.M33 * r.M32; + //t.M33 = l.M31 * r.M13 + l.M32 * r.M23 + l.M33 * r.M33; + + return t; + } + + public static Transform2D Identity () + { + var t = new Transform2D (); + t.M11 = 1; + t.M22 = 1; + //t.M33 = 1; + return t; + } + + public static Transform2D Translate (float x, float y) + { + var t = new Transform2D (); + t.M11 = 1; + t.M22 = 1; + //t.M33 = 1; + t.M13 = x; + t.M23 = y; + return t; + } + public static Transform2D Scale (float x, float y) + { + var t = new Transform2D (); + t.M11 = x; + t.M22 = y; + //t.M33 = 1; + return t; + } + } + + public static class RectangleEx + { + public static RectangleF ToRectangleF (this System.Drawing.Rectangle r) + { + return new RectangleF (r.X, r.Y, r.Width, r.Height); + } + + public static System.Drawing.Point GetCenter (this System.Drawing.Rectangle r) + { + return new System.Drawing.Point (r.Left + r.Width / 2, + r.Top + r.Height / 2); + } + + public static System.Drawing.PointF GetCenter (this System.Drawing.RectangleF r) + { + return new System.Drawing.PointF (r.X + r.Width / 2.0f, + r.Y + r.Height / 2.0f); + } + + public static List GetIntersections (this List boxes, RectangleF box) + { + var r = new List (); + foreach (var b in boxes) { + if (b.IntersectsWith (box)) { + r.Add (b); + } + } + return r; + } + } +} + diff --git a/samples/Clock/ClockSvg/Backup/Properties/AssemblyInfo.cs b/samples/Clock/ClockSvg/Backup/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..3d6a2cd --- /dev/null +++ b/samples/Clock/ClockSvg/Backup/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle ("ClockSvg")] +[assembly: AssemblyDescription ("")] +[assembly: AssemblyConfiguration ("")] +[assembly: AssemblyCompany ("")] +[assembly: AssemblyProduct ("ClockSvg")] +[assembly: AssemblyCopyright ("Copyright © 2012")] +[assembly: AssemblyTrademark ("")] +[assembly: AssemblyCulture ("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible (false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid ("73db20ab-7f16-475f-8124-e446ac68c521")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion ("1.0.0.0")] +[assembly: AssemblyFileVersion ("1.0.0.0")] diff --git a/samples/Clock/ClockSvg/Backup/SvgGraphics.cs b/samples/Clock/ClockSvg/Backup/SvgGraphics.cs new file mode 100644 index 0000000..9e1ae06 --- /dev/null +++ b/samples/Clock/ClockSvg/Backup/SvgGraphics.cs @@ -0,0 +1,364 @@ +// +// Copyright (c) 2010-2013 Frank A. Krueger +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +using System; +using System.Collections.Generic; +using System.IO; +using System.Drawing; + +namespace CrossGraphics +{ + public class SvgGraphics : IGraphics + { + TextWriter _tw; + + SvgGraphicsFontMetrics _fontMetrics; + //Font _lastFont = null; + string _lastColor = null; + + class State { + public PointF Scale; + public PointF Translation; + public RectangleF ClippingRect; + } + readonly Stack _states = new Stack (); + State _state = new State (); + + RectangleF _viewBox; + + public SvgGraphics (TextWriter tw, RectangleF viewBox) + { + _viewBox = viewBox; + _tw = tw; + IncludeXmlAndDoctype = true; + _fontMetrics = new SvgGraphicsFontMetrics (); + SetColor (Colors.Black); + _states.Push (_state); + } + + public SvgGraphics (TextWriter tw, Rectangle viewBox) + : this(tw, new RectangleF(viewBox.Left, viewBox.Top, viewBox.Width, viewBox.Height)) + { + } + + public SvgGraphics (Stream s, RectangleF viewBox) + : this(new StreamWriter(s, System.Text.Encoding.UTF8), viewBox) + { + } + + public bool IncludeXmlAndDoctype { get; set; } + + void WriteLine (string s) + { + _tw.WriteLine (s); + } + void WriteLine (string format, params object[] args) + { + WriteLine (string.Format (System.Globalization.CultureInfo.InvariantCulture, format, args)); + } + void Write (string s) + { + _tw.Write (s); + } + void Write (string format, params object[] args) + { + Write (string.Format (System.Globalization.CultureInfo.InvariantCulture, format, args)); + } + + public void BeginDrawing () + { + if (IncludeXmlAndDoctype) { + WriteLine (@" +"); + } + WriteLine (@"", + _viewBox.Left, _viewBox.Top, _viewBox.Width, _viewBox.Height); + + inGroup = false; + } + + bool inGroup = false; + public void BeginEntity (object entity) + { + if (inGroup) { + WriteLine (""); + } + var klass = (entity != null) ? entity.ToString () : ""; + WriteLine ("", klass); + inGroup = true; + } + + public void Clear (Color clearColor) + { + WriteLine ("", + _viewBox.X, _viewBox.Y, _viewBox.Width, _viewBox.Height, FormatColor (clearColor)); + } + + public void EndDrawing () + { + if (inGroup) { + WriteLine (""); + inGroup = false; + } + WriteLine(""); + _tw.Flush(); + } + + public void SaveState () + { + var ns = new State() { + Translation = _state.Translation, + }; + _states.Push (ns); + _state = ns; + } + + public void Scale (float sx, float sy) + { + _state.Scale.X *= sx; + _state.Scale.Y *= sy; + } + + public void Translate (float dx, float dy) + { + _state.Translation.X += dx; + _state.Translation.Y += dy; + } + + public void SetClippingRect (float x, float y, float width, float height) + { + _state.ClippingRect = new RectangleF (x, y, width, height); + } + + public void RestoreState () + { + if (_states.Count > 1) { + _state = _states.Pop (); + } + } + + public void SetFont (Font f) + { + //_lastFont = f; + } + + static string FormatColor (Color c) + { + return string.Format("#{0:X2}{1:X2}{2:X2}", c.Red, c.Green, c.Blue); + } + + public void SetColor (Color c) + { + _lastColor = FormatColor (c); + } + + public void FillPolygon (Polygon poly) + { + Write(""); + } + + public void DrawPolygon (Polygon poly, float w) + { + Write(""); + } + + public void FillOval (float x, float y, float width, float height) + { + var rx = width / 2; + var ry = height / 2; + var cx = x + rx; + var cy = y + ry; + WriteLine("", + cx, cy, rx, ry, _lastColor); + } + + public void DrawOval (float x, float y, float width, float height, float w) + { + var rx = width / 2; + var ry = height / 2; + var cx = x + rx; + var cy = y + ry; + WriteLine("", + cx, cy, rx, ry, _lastColor, w); + } + + public void FillArc (float cx, float cy, float radius, float startAngle, float endAngle) + { + WriteArc (cx, cy, radius, startAngle, endAngle, 0, "none", _lastColor); + } + + public void DrawArc (float cx, float cy, float radius, float startAngle, float endAngle, float w) + { + WriteArc (cx, cy, radius, startAngle, endAngle, w, _lastColor, "none"); + } + + public void WriteArc (float cx, float cy, float radius, float startAngle, float endAngle, float w, string stroke, string fill) + { + var sa = startAngle + Math.PI; + var ea = endAngle + Math.PI; + + var sx = cx + radius * Math.Cos (sa); + var sy = cy + radius * Math.Sin (sa); + var ex = cx + radius * Math.Cos (ea); + var ey = cy + radius * Math.Sin (ea); + + WriteLine("", + sx, sy, + radius, radius, + ex, ey, + stroke, w, fill); + } + + public void FillRoundedRect (float x, float y, float width, float height, float radius) + { + WriteLine("", + x, y, width, height, _lastColor, radius); + } + + public void DrawRoundedRect (float x, float y, float width, float height, float radius, float w) + { + WriteLine("", + x, y, width, height, _lastColor, w, radius); + } + + public void FillRect (float x, float y, float width, float height) + { + WriteLine("", + x, y, width, height, _lastColor); + } + + public void DrawRect (float x, float y, float width, float height, float w) + { + WriteLine("", + x, y, width, height, _lastColor, w); + } + + bool _inPolyline = false; + bool _startedPolyline = false; + + public void BeginLines (bool rounded) + { + _inPolyline = true; + } + + public void DrawLine (float sx, float sy, float ex, float ey, float w) + { + if (_inPolyline) { + if (!_startedPolyline) { + Write ("", sx, sy, ex, ey, _lastColor, w); + } + } + + public void EndLines () + { + if (_inPolyline) { + WriteLine("\" />"); + _inPolyline = false; + _startedPolyline = false; + } + } + + public void DrawString(string s, float x, float y, float width, float height, LineBreakMode lineBreak, TextAlignment align) + { + WriteLine("{2}", + x, y + _fontMetrics.Height, + s.Replace("&", "&").Replace("<", "<").Replace(">", ">")); + } + + public void DrawString (string s, float x, float y) + { + WriteLine("{2}", + x, y + _fontMetrics.Height, + s.Replace("&", "&").Replace("<", "<").Replace(">", ">")); + } + + public IFontMetrics GetFontMetrics () + { + return _fontMetrics; + } + + public void DrawImage (IImage img, float x, float y, float width, float height) + { + } + + public IImage ImageFromFile (string filename) + { + return null; + } + } + + class SvgGraphicsFontMetrics : IFontMetrics + { + int _height; + + public SvgGraphicsFontMetrics () + { + _height = 10; + } + + public int StringWidth (string str, int startIndex, int length) + { + return length * 10; + } + + public int Height + { + get { + return _height; + } + } + + public int Ascent + { + get { + return Height; + } + } + + public int Descent + { + get { + return 0; + } + } + } +} \ No newline at end of file diff --git a/samples/Clock/ClockSvg/Backup/Web.config b/samples/Clock/ClockSvg/Backup/Web.config new file mode 100644 index 0000000..0598be1 --- /dev/null +++ b/samples/Clock/ClockSvg/Backup/Web.config @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/samples/Clock/ClockSvg/ClockSvg.csproj b/samples/Clock/ClockSvg/ClockSvg.csproj index ec1eb8c..ebc6523 100644 --- a/samples/Clock/ClockSvg/ClockSvg.csproj +++ b/samples/Clock/ClockSvg/ClockSvg.csproj @@ -1,5 +1,6 @@  + Debug AnyCPU @@ -14,6 +15,11 @@ ClockSvg v4.0 false + + + + + 4.0 true @@ -66,8 +72,13 @@ + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + - + + diff --git a/samples/Clock/ClockSvg/ClockSvg.sln b/samples/Clock/ClockSvg/ClockSvg.sln index 82cb361..4ec65d5 100644 --- a/samples/Clock/ClockSvg/ClockSvg.sln +++ b/samples/Clock/ClockSvg/ClockSvg.sln @@ -1,6 +1,8 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.30723.0 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClockSvg", "ClockSvg.csproj", "{69365CC0-8B33-450F-8344-F710DBCFCF5B}" EndProject Global diff --git a/samples/Clock/ClockSvg/UpgradeLog.htm b/samples/Clock/ClockSvg/UpgradeLog.htm new file mode 100644 index 0000000..26832d2 Binary files /dev/null and b/samples/Clock/ClockSvg/UpgradeLog.htm differ diff --git a/samples/Clock/ClockWP7/App.xaml b/samples/Clock/ClockWP8/App.xaml similarity index 100% rename from samples/Clock/ClockWP7/App.xaml rename to samples/Clock/ClockWP8/App.xaml diff --git a/samples/Clock/ClockWP7/App.xaml.cs b/samples/Clock/ClockWP8/App.xaml.cs similarity index 100% rename from samples/Clock/ClockWP7/App.xaml.cs rename to samples/Clock/ClockWP8/App.xaml.cs diff --git a/samples/Clock/ClockWP7/ApplicationIcon.png b/samples/Clock/ClockWP8/ApplicationIcon.png similarity index 100% rename from samples/Clock/ClockWP7/ApplicationIcon.png rename to samples/Clock/ClockWP8/ApplicationIcon.png diff --git a/samples/Clock/ClockWP8/Assets/BadgeLogo.png b/samples/Clock/ClockWP8/Assets/BadgeLogo.png new file mode 100644 index 0000000..eb5bb83 Binary files /dev/null and b/samples/Clock/ClockWP8/Assets/BadgeLogo.png differ diff --git a/samples/Clock/ClockWP8/Assets/Logo.png b/samples/Clock/ClockWP8/Assets/Logo.png new file mode 100644 index 0000000..f2e1f40 Binary files /dev/null and b/samples/Clock/ClockWP8/Assets/Logo.png differ diff --git a/samples/Clock/ClockWP8/Assets/SplashScreen.png b/samples/Clock/ClockWP8/Assets/SplashScreen.png new file mode 100644 index 0000000..4b90728 Binary files /dev/null and b/samples/Clock/ClockWP8/Assets/SplashScreen.png differ diff --git a/samples/Clock/ClockWP8/Assets/SquareTile150x150.png b/samples/Clock/ClockWP8/Assets/SquareTile150x150.png new file mode 100644 index 0000000..ec1d121 Binary files /dev/null and b/samples/Clock/ClockWP8/Assets/SquareTile150x150.png differ diff --git a/samples/Clock/ClockWP8/Assets/SquareTile71x71.png b/samples/Clock/ClockWP8/Assets/SquareTile71x71.png new file mode 100644 index 0000000..4754af3 Binary files /dev/null and b/samples/Clock/ClockWP8/Assets/SquareTile71x71.png differ diff --git a/samples/Clock/ClockWP8/Assets/StoreLogo.png b/samples/Clock/ClockWP8/Assets/StoreLogo.png new file mode 100644 index 0000000..12c5f4f Binary files /dev/null and b/samples/Clock/ClockWP8/Assets/StoreLogo.png differ diff --git a/samples/Clock/ClockWP8/Assets/WideLogo.png b/samples/Clock/ClockWP8/Assets/WideLogo.png new file mode 100644 index 0000000..082197b Binary files /dev/null and b/samples/Clock/ClockWP8/Assets/WideLogo.png differ diff --git a/samples/Clock/ClockWP7/Background.png b/samples/Clock/ClockWP8/Background.png similarity index 100% rename from samples/Clock/ClockWP7/Background.png rename to samples/Clock/ClockWP8/Background.png diff --git a/samples/Clock/ClockWP8/Backup/App.xaml b/samples/Clock/ClockWP8/Backup/App.xaml new file mode 100644 index 0000000..1c4f6dc --- /dev/null +++ b/samples/Clock/ClockWP8/Backup/App.xaml @@ -0,0 +1,19 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/Clock/ClockWP8/Backup/App.xaml.cs b/samples/Clock/ClockWP8/Backup/App.xaml.cs new file mode 100644 index 0000000..3d1ab8f --- /dev/null +++ b/samples/Clock/ClockWP8/Backup/App.xaml.cs @@ -0,0 +1,139 @@ +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.Navigation; +using System.Windows.Shapes; +using Microsoft.Phone.Controls; +using Microsoft.Phone.Shell; + +namespace ClockWP7 +{ + public partial class App : Application + { + /// + /// Provides easy access to the root frame of the Phone Application. + /// + /// The root frame of the Phone Application. + public PhoneApplicationFrame RootFrame { get; private set; } + + /// + /// Constructor for the Application object. + /// + public App () + { + // Global handler for uncaught exceptions. + UnhandledException += Application_UnhandledException; + + // Standard Silverlight initialization + InitializeComponent (); + + // Phone-specific initialization + InitializePhoneApplication (); + + // Show graphics profiling information while debugging. + if (System.Diagnostics.Debugger.IsAttached) { + // Display the current frame rate counters. + Application.Current.Host.Settings.EnableFrameRateCounter = true; + + // Show the areas of the app that are being redrawn in each frame. + //Application.Current.Host.Settings.EnableRedrawRegions = true; + + // Enable non-production analysis visualization mode, + // which shows areas of a page that are handed off to GPU with a colored overlay. + //Application.Current.Host.Settings.EnableCacheVisualization = true; + + // Disable the application idle detection by setting the UserIdleDetectionMode property of the + // application's PhoneApplicationService object to Disabled. + // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run + // and consume battery power when the user is not using the phone. + PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; + } + + } + + // Code to execute when the application is launching (eg, from Start) + // This code will not execute when the application is reactivated + private void Application_Launching (object sender, LaunchingEventArgs e) + { + } + + // Code to execute when the application is activated (brought to foreground) + // This code will not execute when the application is first launched + private void Application_Activated (object sender, ActivatedEventArgs e) + { + } + + // Code to execute when the application is deactivated (sent to background) + // This code will not execute when the application is closing + private void Application_Deactivated (object sender, DeactivatedEventArgs e) + { + } + + // Code to execute when the application is closing (eg, user hit Back) + // This code will not execute when the application is deactivated + private void Application_Closing (object sender, ClosingEventArgs e) + { + } + + // Code to execute if a navigation fails + private void RootFrame_NavigationFailed (object sender, NavigationFailedEventArgs e) + { + if (System.Diagnostics.Debugger.IsAttached) { + // A navigation has failed; break into the debugger + System.Diagnostics.Debugger.Break (); + } + } + + // Code to execute on Unhandled Exceptions + private void Application_UnhandledException (object sender, ApplicationUnhandledExceptionEventArgs e) + { + if (System.Diagnostics.Debugger.IsAttached) { + // An unhandled exception has occurred; break into the debugger + System.Diagnostics.Debugger.Break (); + } + } + + #region Phone application initialization + + // Avoid double-initialization + private bool phoneApplicationInitialized = false; + + // Do not add any additional code to this method + private void InitializePhoneApplication () + { + if (phoneApplicationInitialized) + return; + + // Create the frame but don't set it as RootVisual yet; this allows the splash + // screen to remain active until the application is ready to render. + RootFrame = new PhoneApplicationFrame (); + RootFrame.Navigated += CompleteInitializePhoneApplication; + + // Handle navigation failures + RootFrame.NavigationFailed += RootFrame_NavigationFailed; + + // Ensure we don't initialize again + phoneApplicationInitialized = true; + } + + // Do not add any additional code to this method + private void CompleteInitializePhoneApplication (object sender, NavigationEventArgs e) + { + // Set the root visual to allow the application to render + if (RootVisual != RootFrame) + RootVisual = RootFrame; + + // Remove this handler since it is no longer needed + RootFrame.Navigated -= CompleteInitializePhoneApplication; + } + + #endregion + } +} \ No newline at end of file diff --git a/samples/Clock/ClockWP8/Backup/ApplicationIcon.png b/samples/Clock/ClockWP8/Backup/ApplicationIcon.png new file mode 100644 index 0000000..5859393 Binary files /dev/null and b/samples/Clock/ClockWP8/Backup/ApplicationIcon.png differ diff --git a/samples/Clock/ClockWP8/Backup/Background.png b/samples/Clock/ClockWP8/Backup/Background.png new file mode 100644 index 0000000..e46f21d Binary files /dev/null and b/samples/Clock/ClockWP8/Backup/Background.png differ diff --git a/samples/Clock/ClockWP8/Backup/Clock.cs b/samples/Clock/ClockWP8/Backup/Clock.cs new file mode 100644 index 0000000..c8a5b5e --- /dev/null +++ b/samples/Clock/ClockWP8/Backup/Clock.cs @@ -0,0 +1,105 @@ +using System; +using CrossGraphics; + +namespace Clock +{ + /// + /// This class demonstrates drawing with the CrossGraphics library. + /// + public class Clock + { + public float Width { get; set; } + public float Height { get; set; } + + 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); + + public void Draw (IGraphics g) + { + g.BeginEntity (this); + + var now = DateTime.Now; + + var r = Math.Min (Width / 2, Height / 2); + var center = new System.Drawing.PointF (Width / 2, Height / 2); + + // + // Draw the face + // + g.SetColor (BackColor); + g.FillOval (center.X - r, center.Y - r, 2 * r, 2 * r); + g.SetColor (BorderColor); + g.DrawOval (center.X - r, center.Y - r, 2 * r, 2 * r, 8); + + g.SetColor (FaceColor); + for (var i = 0; i < 12; i++) { + var angle = (i / 12.0) * 2 * Math.PI; + g.DrawLine ( + center.X + 0.75f * r * (float)Math.Cos (angle), + center.Y + 0.75f * r * (float)Math.Sin (angle), + center.X + 0.9f * r * (float)Math.Cos (angle), + center.Y + 0.9f * r * (float)Math.Sin (angle), + 7); + } + g.SetFont (LabelFont); + var textWidth = g.GetFontMetrics ().StringWidth ("Cross Graphics"); + g.DrawString ("Cross Graphics", center.X - textWidth / 2, center.Y + 0.25f * r); + + //Custom Font Test + var customFont = Font.FromName("BILLY ARGEL TRIAL___.otf", "BILLY ARGEL FONT", 30); + g.SetFont(customFont); + g.SetColor(new Color(255, 0, 0)); + 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 + // + g.SetColor (Colors.DarkGray); + var h = now.Hour + now.Minute / 60.0; + var hAngle = h > 12 ? + ((h - 12) / 12.0 * 2 * Math.PI - Math.PI /2) : + (h / 12.0 * 2 * Math.PI - Math.PI / 2); + g.DrawLine ( + center.X + -0.1f * r * (float)Math.Cos (hAngle), + center.Y + -0.1f * r * (float)Math.Sin (hAngle), + center.X + 0.65f * r * (float)Math.Cos (hAngle), + center.Y + 0.65f * r * (float)Math.Sin (hAngle), + 7); + + // + // Draw the minute hand + // + g.SetColor (Colors.DarkGray); + var m = now.Minute + now.Second / 60.0; + var mAngle = (m / 60.0) * 2 * Math.PI - Math.PI / 2; + g.DrawLine ( + center.X + -0.15f * r * (float)Math.Cos (mAngle), + center.Y + -0.15f * r * (float)Math.Sin (mAngle), + center.X + 0.85f * r * (float)Math.Cos (mAngle), + center.Y + 0.85f * r * (float)Math.Sin (mAngle), + 5); + + // + // Draw the second hand + // + g.SetColor (Colors.Red); + var sAngle = (now.Second / 60.0) * 2 * Math.PI - Math.PI / 2; + g.DrawLine ( + center.X + -0.15f * r * (float)Math.Cos (sAngle), + center.Y + -0.15f * r * (float)Math.Sin (sAngle), + center.X + 0.85f * r * (float)Math.Cos (sAngle), + center.Y + 0.85f * r * (float)Math.Sin (sAngle), + 1); + + // + // Draw the pin + // + g.SetColor (Colors.Black); + g.FillOval (center.X - 5, center.Y - 5, 10, 10); + } + } +} diff --git a/samples/Clock/ClockWP7/ClockWP7.csproj b/samples/Clock/ClockWP8/Backup/ClockWP7.csproj similarity index 100% rename from samples/Clock/ClockWP7/ClockWP7.csproj rename to samples/Clock/ClockWP8/Backup/ClockWP7.csproj diff --git a/samples/Clock/ClockWP7/ClockWP7.sln b/samples/Clock/ClockWP8/Backup/ClockWP7.sln similarity index 100% rename from samples/Clock/ClockWP7/ClockWP7.sln rename to samples/Clock/ClockWP8/Backup/ClockWP7.sln diff --git a/samples/Clock/ClockWP8/Backup/Graphics.cs b/samples/Clock/ClockWP8/Backup/Graphics.cs new file mode 100644 index 0000000..57819d4 --- /dev/null +++ b/samples/Clock/ClockWP8/Backup/Graphics.cs @@ -0,0 +1,559 @@ +// +// Copyright (c) 2010-2012 Frank A. Krueger +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +using System; +using System.Collections.Generic; +using System.Drawing; + +namespace CrossGraphics +{ + public interface IGraphics + { + void BeginEntity(object entity); + + void SetFont(Font f); + + void SetColor(Color c); + + void Clear (Color c); + + void FillPolygon(Polygon poly); + + void DrawPolygon(Polygon poly,float w); + + void FillRect(float x,float y,float width, float height); + + void DrawRect(float x, float y, float width, float height, float w); + + void FillRoundedRect(float x, float y, float width, float height, float radius); + + void DrawRoundedRect(float x, float y, float width, float height, float radius, float w); + + void FillOval(float x, float y, float width, float height); + + void DrawOval(float x, float y, float width, float height, float w); + + void BeginLines(bool rounded); + + void DrawLine(float sx, float sy, float ex, float ey, float w); + + void EndLines(); + + void FillArc(float cx, float cy, float radius, float startAngle, float endAngle); + + void DrawArc(float cx, float cy, float radius, float startAngle, float endAngle, float w); + + void DrawImage(IImage img, float x, float y, float width, float height); + + void DrawString(string s, float x, float y, float width, float height, LineBreakMode lineBreak, TextAlignment align); + + void DrawString(string s, float x, float y); + + void SaveState(); + + void SetClippingRect (float x, float y, float width, float height); + + void Translate(float dx, float dy); + + void Scale(float sx, float sy); + + void RestoreState(); + + IFontMetrics GetFontMetrics(); + + IImage ImageFromFile(string path); + } + + public enum LineBreakMode { + None, + Clip, + WordWrap, + } + + public enum TextAlignment { + Left, + Center, + Right, + Justified + } + + public static class GraphicsEx + { + public static void DrawString (this IGraphics g, string s, PointF p) + { + g.DrawString(s, p.X, p.Y); + } + + public static void DrawString(this IGraphics g, string s, PointF p, Font f) + { + g.SetFont (f); + g.DrawString (s, p.X, p.Y); + } + + public static void DrawString(this IGraphics g, string s, RectangleF p, Font f, LineBreakMode lineBreak, TextAlignment align) + { + g.SetFont (f); + g.DrawString (s, p.Left, p.Top, p.Width, p.Height, lineBreak, align); + } + + public static void DrawLine(this IGraphics g, PointF s, PointF e, float w) + { + g.DrawLine (s.X, s.Y, e.X, e.Y, w); + } + + public static void DrawRoundedRect(this IGraphics g, RectangleF r, float radius, float w) + { + g.DrawRoundedRect (r.Left, r.Top, r.Width, r.Height, radius, w); + } + + public static void DrawRoundedRect(this IGraphics g, Rectangle r, float radius, float w) + { + g.DrawRoundedRect(r.Left, r.Top, r.Width, r.Height, radius, w); + } + + public static void FillRoundedRect(this IGraphics g, RectangleF r, float radius) + { + g.FillRoundedRect (r.Left, r.Top, r.Width, r.Height, radius); + } + + public static void FillRoundedRect(this IGraphics g, Rectangle r, float radius) + { + g.FillRoundedRect (r.Left, r.Top, r.Width, r.Height, radius); + } + + public static void FillRect(this IGraphics g, RectangleF r) + { + g.FillRect (r.Left, r.Top, r.Width, r.Height); + } + + public static void FillRect(this IGraphics g, Rectangle r) + { + g.FillRect(r.Left, r.Top, r.Width, r.Height); + } + + public static void DrawRect(this IGraphics g, RectangleF r, float w) + { + g.DrawRect (r.Left, r.Top, r.Width, r.Height, w); + } + + public static void DrawRect(this IGraphics g, Rectangle r, float w) + { + g.DrawRect(r.Left, r.Top, r.Width, r.Height, w); + } + + public static void FillOval(this IGraphics g, RectangleF r) + { + g.FillOval (r.Left, r.Top, r.Width, r.Height); + } + + public static void DrawOval(this IGraphics g, RectangleF r, float w) + { + g.DrawOval (r.Left, r.Top, r.Width, r.Height, w); + } + } + + public interface IImage + { + } + + [Flags] + public enum FontOptions + { + None = 0, + Bold = 1 + } + + public class Font + { + public string FontFamily { get; private set; } + + public string FontFilename { get; private set; } + + public FontOptions Options { get; private set; } + + public int Size { get; private set; } + + public object Tag { get; set; } + + public bool IsBold { get { return (Options & FontOptions.Bold) != 0; } } + + public Font (string fontFileName, string fontFamily, FontOptions options, int size) + { + FontFilename = fontFileName; + FontFamily = fontFamily; + Options = options; + Size = size; + } + + static Font[] _boldSystemFonts = new Font[0]; + static Font[] _systemFonts = new Font[0]; + static Font[] _userFixedPitchFonts = new Font[0]; + static Font[] _boldUserFixedPitchFonts = new Font[0]; + + public static Font BoldSystemFontOfSize (int size) { + if (size >= _boldSystemFonts.Length) { + return new Font ("", "SystemFont", FontOptions.Bold, size); + } + else { + var f = _boldSystemFonts[size]; + if (f == null) { + f = new Font ("", "SystemFont", FontOptions.Bold, size); + _boldSystemFonts[size] = f; + } + return f; + } + } + public static Font SystemFontOfSize (int size) { + if (size >= _systemFonts.Length) { + return new Font ("", "SystemFont", FontOptions.None, size); + } + else { + var f = _systemFonts[size]; + if (f == null) { + f = new Font ("", "SystemFont", FontOptions.None, size); + _systemFonts[size] = f; + } + return f; + } + } + public static Font UserFixedPitchFontOfSize (int size) { + if (size >= _userFixedPitchFonts.Length) { + return new Font ("", "Monospace", FontOptions.None, size); + } + else { + var f = _userFixedPitchFonts[size]; + if (f == null) { + f = new Font ("", "Monospace", FontOptions.None, size); + _userFixedPitchFonts[size] = f; + } + return f; + } + } + public static Font BoldUserFixedPitchFontOfSize (int size) { + if (size >= _boldUserFixedPitchFonts.Length) { + return new Font ("", "Monospace", FontOptions.Bold, size); + } + else { + var f = _boldUserFixedPitchFonts[size]; + if (f == null) { + f = new Font ("", "Monospace", FontOptions.Bold, size); + _boldUserFixedPitchFonts[size] = f; + } + return f; + } + } + + + //Customs Fonts + //iOS: + //You have to modify your info.plist and add the entry 'Fonts provided by application' UIAppFonts for your custom fonts and copy the fonts to your Bundle as BundleResource + //Not all fonts seem to work and I couldn't find out why + // + //Android: + //Copy the fonts to your Assets folder as AndroidAsset; remember to use the full filename to load the font like Font.FromName("UniversLTStd-LightCn.otf", "Univers LT Std", 18); + // + //Windows Phone/Store: + //According to + //http://stackoverflow.com/questions/14085818/custom-font-usage-in-windows-phone-8 + //you have to set the real font name not only the filename for windows phone like Font.FromName("UniversLTStd-LightCn.otf", "Univers LT Std", 18); + //The fonts should be copied inside a 'Fonts' folder. The custom fonts should be as type 'Content' + + public static Font FromName(string fontFileName, string name, int size) + { + return new Font(fontFileName, name, FontOptions.None, size); + } + + public override string ToString() + { + return string.Format ("[Font: FontFamily={0}, Options={1}, Size={2}, Tag={3}]", FontFamily, Options, Size, Tag); + } + } + + public interface IFontMetrics + { + int StringWidth(string s, int startIndex, int length); + + int Height { get; } + + int Ascent { get; } + + int Descent { get; } + } + + public static class FontMetricsEx + { + public static int StringWidth (this IFontMetrics fm, string s) + { + return fm.StringWidth (s, 0, s.Length); + } + } + + public class Color + { + public readonly int Red, Green, Blue, Alpha; + public object Tag; + + public float RedValue { + get { return Red / 255.0f; } + } + + public float GreenValue { + get { return Green / 255.0f; } + } + + public float BlueValue { + get { return Blue / 255.0f; } + } + + public float AlphaValue { + get { return Alpha / 255.0f; } + } + + public Color (int red, int green, int blue) + { + Red = red; + Green = green; + Blue = blue; + Alpha = 255; + } + + public Color (int red, int green, int blue, int alpha) + { + Red = red; + Green = green; + Blue = blue; + Alpha = alpha; + } + + public Color(float red, float green, float blue) + { + Red = (int)(red * 255); + Green = (int)(green * 255); + Blue = (int)(blue * 255); + Alpha = 255; + } + + public Color(float red, float green, float blue, float alpha) + { + Red = (int)(red * 255); + Green = (int)(green * 255); + Blue = (int)(blue * 255); + Alpha = (int)(alpha * 255); + } + + public int Intensity { get { return (Red + Green + Blue) / 3; } } + + public Color GetInvertedColor() + { + return new Color (255 - Red, 255 - Green, 255 - Blue, Alpha); + } + + public static bool AreEqual(Color a, Color b) + { + if (a == null && b == null) + return true; + if (a == null && b != null) + return false; + if (a != null && b == null) + return false; + return (a.Red == b.Red && a.Green == b.Green && a.Blue == b.Blue && a.Alpha == b.Alpha); + } + + public bool IsWhite { + get { return (Red == 255) && (Green == 255) && (Blue == 255); } + } + + public bool IsBlack { + get { return (Red == 0) && (Green == 0) && (Blue == 0); } + } + + public Color WithAlpha(int aa) + { + return new Color (Red, Green, Blue, aa); + } + + public override bool Equals (object obj) + { + var o = obj as Color; + return (o != null) && (o.Red == Red) && (o.Green == Green) && (o.Blue == Blue) && (o.Alpha == Alpha); + } + + public override int GetHashCode () + { + return (Red + Green + Blue + Alpha).GetHashCode (); + } + + public override string ToString() + { + return string.Format ("[Color: RedValue={0}, GreenValue={1}, BlueValue={2}, AlphaValue={3}]", RedValue, GreenValue, BlueValue, AlphaValue); + } + } + + public static class Colors + { + public static readonly Color Yellow = new Color (255, 255, 0); + public static readonly Color Red = new Color (255, 0, 0); + public static readonly Color Green = new Color (0, 255, 0); + public static readonly Color Blue = new Color (0, 0, 255); + public static readonly Color White = new Color (255, 255, 255); + public static readonly Color Cyan = new Color (0, 255, 255); + public static readonly Color Black = new Color (0, 0, 0); + public static readonly Color LightGray = new Color (212, 212, 212); + public static readonly Color Gray = new Color (127, 127, 127); + public static readonly Color DarkGray = new Color (64, 64, 64); + } + + public class Polygon + { + public readonly List Points; + + public object Tag { get; set; } + + public int Version { get; set; } + + public Polygon () + { + Points = new List (); + } + + public Polygon (int[] xs, int[] ys, int c) + { + Points = new List (c); + for (var i = 0; i < c; i++) { + Points.Add (new PointF (xs [i], ys [i])); + } + } + + public int Count { + get { return Points.Count; } + } + + public void Clear() + { + Points.Clear (); + Version++; + } + + public void AddPoint(PointF p) + { + Points.Add (p); + Version++; + } + + public void AddPoint(float x, float y) + { + Points.Add (new PointF (x, y)); + Version++; + } + } + + public struct Transform2D + { + public float M11, M12, M13; + public float M21, M22, M23; + //public float M31, M32, M33; + + public void Apply (float x, float y, out float xp, out float yp) + { + xp = M11 * x + M12 * y + M13; + yp = M21 * x + M22 * y + M23; + } + + public static Transform2D operator * (Transform2D l, Transform2D r) + { + var t = new Transform2D (); + + t.M11 = l.M11 * r.M11 + l.M12 * r.M21;// +l.M13 * r.M31; + t.M12 = l.M11 * r.M12 + l.M12 * r.M22;// +l.M13 * r.M32; + t.M13 = l.M11 * r.M13 + l.M12 * r.M23 + l.M13;// *r.M33; + + t.M21 = l.M21 * r.M11 + l.M22 * r.M21;// +l.M23 * r.M31; + t.M22 = l.M21 * r.M12 + l.M22 * r.M22;// +l.M23 * r.M32; + t.M23 = l.M21 * r.M13 + l.M22 * r.M23 + l.M23;// *r.M33; + + //t.M31 = l.M31 * r.M11 + l.M32 * r.M21 + l.M33 * r.M31; + //t.M32 = l.M31 * r.M12 + l.M32 * r.M22 + l.M33 * r.M32; + //t.M33 = l.M31 * r.M13 + l.M32 * r.M23 + l.M33 * r.M33; + + return t; + } + + public static Transform2D Identity () + { + var t = new Transform2D (); + t.M11 = 1; + t.M22 = 1; + //t.M33 = 1; + return t; + } + + public static Transform2D Translate (float x, float y) + { + var t = new Transform2D (); + t.M11 = 1; + t.M22 = 1; + //t.M33 = 1; + t.M13 = x; + t.M23 = y; + return t; + } + public static Transform2D Scale (float x, float y) + { + var t = new Transform2D (); + t.M11 = x; + t.M22 = y; + //t.M33 = 1; + return t; + } + } + + public static class RectangleEx + { + public static RectangleF ToRectangleF (this System.Drawing.Rectangle r) + { + return new RectangleF (r.X, r.Y, r.Width, r.Height); + } + + public static System.Drawing.Point GetCenter (this System.Drawing.Rectangle r) + { + return new System.Drawing.Point (r.Left + r.Width / 2, + r.Top + r.Height / 2); + } + + public static System.Drawing.PointF GetCenter (this System.Drawing.RectangleF r) + { + return new System.Drawing.PointF (r.X + r.Width / 2.0f, + r.Y + r.Height / 2.0f); + } + + public static List GetIntersections (this List boxes, RectangleF box) + { + var r = new List (); + foreach (var b in boxes) { + if (b.IntersectsWith (box)) { + r.Add (b); + } + } + return r; + } + } +} + diff --git a/samples/Clock/ClockWP7/MainPage.xaml b/samples/Clock/ClockWP8/Backup/MainPage.xaml similarity index 100% rename from samples/Clock/ClockWP7/MainPage.xaml rename to samples/Clock/ClockWP8/Backup/MainPage.xaml diff --git a/samples/Clock/ClockWP7/MainPage.xaml.cs b/samples/Clock/ClockWP8/Backup/MainPage.xaml.cs similarity index 100% rename from samples/Clock/ClockWP7/MainPage.xaml.cs rename to samples/Clock/ClockWP8/Backup/MainPage.xaml.cs diff --git a/samples/Clock/ClockWP8/Backup/Properties/AppManifest.xml b/samples/Clock/ClockWP8/Backup/Properties/AppManifest.xml new file mode 100644 index 0000000..a955232 --- /dev/null +++ b/samples/Clock/ClockWP8/Backup/Properties/AppManifest.xml @@ -0,0 +1,6 @@ + + + + diff --git a/samples/Clock/ClockWP7/Properties/AssemblyInfo.cs b/samples/Clock/ClockWP8/Backup/Properties/AssemblyInfo.cs similarity index 100% rename from samples/Clock/ClockWP7/Properties/AssemblyInfo.cs rename to samples/Clock/ClockWP8/Backup/Properties/AssemblyInfo.cs diff --git a/samples/Clock/ClockWP7/Properties/WMAppManifest.xml b/samples/Clock/ClockWP8/Backup/Properties/WMAppManifest.xml similarity index 100% rename from samples/Clock/ClockWP7/Properties/WMAppManifest.xml rename to samples/Clock/ClockWP8/Backup/Properties/WMAppManifest.xml diff --git a/samples/Clock/ClockWP7/SplashScreenImage.jpg b/samples/Clock/ClockWP8/Backup/SplashScreenImage.jpg similarity index 100% rename from samples/Clock/ClockWP7/SplashScreenImage.jpg rename to samples/Clock/ClockWP8/Backup/SplashScreenImage.jpg diff --git a/samples/Clock/ClockWP8/Backup/System.Drawing.cs b/samples/Clock/ClockWP8/Backup/System.Drawing.cs new file mode 100644 index 0000000..64e6e2a --- /dev/null +++ b/samples/Clock/ClockWP8/Backup/System.Drawing.cs @@ -0,0 +1,189 @@ +// +// Copyright (c) 2010 Frank A. Krueger +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +using System; + +namespace System.Drawing +{ + public struct RectangleF + { + public float X, Y, Width, Height; + + public float Left { get { return X; } } + public float Top { get { return Y; } } + + public float Right { get { return X + Width; } } + public float Bottom { get { return Y + Height; } } + + public RectangleF (float left, float top, float width, float height) + { + X = left; + Y = top; + Width = width; + Height = height; + } + + public void Inflate (float width, float height) + { + Inflate (new SizeF (width, height)); + } + + public void Inflate (SizeF size) + { + X -= size.Width; + Y -= size.Height; + Width += size.Width * 2; + Height += size.Height * 2; + } + + public bool IntersectsWith(RectangleF rect) + { + return !((Left >= rect.Right) || (Right <= rect.Left) || + (Top >= rect.Bottom) || (Bottom <= rect.Top)); + } + + public bool Contains(PointF loc) + { + return (X <= loc.X && loc.X < (X + Width) && Y <= loc.Y && loc.Y < (Y + Height)); + } + + public override string ToString() + { + return string.Format("[RectangleF: Left={0} Top={1} Width={2} Height={3}]", Left, Top, Width, Height); + } + } + + public struct Rectangle + { + public int X, Y, Width, Height; + + public int Left { get { return X; } } + + public int Top { get { return Y; } } + + public int Bottom { get { return Top + Height; } } + + public int Right { get { return Left + Width; } } + + public Rectangle (int left, int top, int width, int height) + { + X = left; + Y = top; + Width = width; + Height = height; + } + + public void Offset (int dx, int dy) + { + X += dx; + Y += dy; + } + + public bool Contains (int x, int y) + { + return (x >= X && x < X + Width) && (y >= Y && y < Y + Height); + } + + public static Rectangle Union (Rectangle a, Rectangle b) + { + var left = Math.Min (a.Left, b.Left); + var top = Math.Min (a.Top, b.Top); + return new Rectangle (left, + top, + Math.Max (a.Right, b.Right) - left, + Math.Max (a.Bottom, b.Bottom) - top); + } + + public bool IntersectsWith (Rectangle rect) + { + return !((Left >= rect.Right) || (Right <= rect.Left) || + (Top >= rect.Bottom) || (Bottom <= rect.Top)); + } + + public void Inflate (int width, int height) + { + Inflate (new Size (width, height)); + } + + public void Inflate (Size size) + { + X -= size.Width; + Y -= size.Height; + Width += size.Width * 2; + Height += size.Height * 2; + } + + public override string ToString () + { + return string.Format ("[Rectangle: Left={0} Top={1} Width={2} Height={3}]", Left, Top, Width, Height); + } + } + + public struct PointF + { + public float X, Y; + + public PointF (float x, float y) + { + X = x; + Y = y; + } + + public override string ToString() + { + return string.Format("({0}, {1})", X, Y); + } + } + + public struct Point + { + public int X, Y; + + public Point (int x, int y) + { + X = x; + Y = y; + } + } + + public struct Size + { + public int Width, Height; + + public Size (int width, int height) + { + Width = width; + Height = height; + } + } + + public struct SizeF + { + public float Width, Height; + + public SizeF (float width, float height) + { + Width = width; + Height = height; + } + } +} + diff --git a/samples/Clock/ClockWP8/ClockWP8.csproj b/samples/Clock/ClockWP8/ClockWP8.csproj new file mode 100644 index 0000000..bf54e07 --- /dev/null +++ b/samples/Clock/ClockWP8/ClockWP8.csproj @@ -0,0 +1,183 @@ + + + + Debug + AnyCPU + 10.0.20506 + 2.0 + {202641C4-7536-4935-8A25-C88C12E2B876} + {C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + Clock.WP8 + ClockWP8 + v8.1 + + + + + WindowsPhone + true + + + true + true + ClockWP7_$(Configuration)_$(Platform).xap + Properties\AppManifest.xml + ClockWP7.App + true + true + + + + + 4.0 + 12.0 + en-US + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + false + Bin\Debug + DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE + true + true + prompt + 4 + + + pdbonly + true + Bin\Release + TRACE;SILVERLIGHT;WINDOWS_PHONE + true + true + prompt + 4 + + + + Bin\x86\Debug + true + full + false + + + + Bin\x86\Release + pdbonly + true + + + + Bin\ARM\Debug + true + full + false + + + + Bin\ARM\Release + pdbonly + true + + + + Graphics.cs + + + System.Drawing.cs + + + XamlGraphics.cs + + + Clock.cs + + + App.xaml + + + MainPage.xaml + + + + + + Designer + MSBuild:Compile + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + MSBuild:Compile + Designer + + + + + Designer + + + + + Designer + + + + + PreserveNewest + + + + + + + + + + PreserveNewest + + + + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + false + + + + + + + \ No newline at end of file diff --git a/samples/Clock/ClockWP8/ClockWP8.sln b/samples/Clock/ClockWP8/ClockWP8.sln new file mode 100644 index 0000000..1c437ee --- /dev/null +++ b/samples/Clock/ClockWP8/ClockWP8.sln @@ -0,0 +1,40 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.30723.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClockWP8", "ClockWP8.csproj", "{202641C4-7536-4935-8A25-C88C12E2B876}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|ARM = Debug|ARM + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|ARM = Release|ARM + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {202641C4-7536-4935-8A25-C88C12E2B876}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {202641C4-7536-4935-8A25-C88C12E2B876}.Debug|Any CPU.Build.0 = Debug|Any CPU + {202641C4-7536-4935-8A25-C88C12E2B876}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {202641C4-7536-4935-8A25-C88C12E2B876}.Debug|ARM.ActiveCfg = Debug|ARM + {202641C4-7536-4935-8A25-C88C12E2B876}.Debug|ARM.Build.0 = Debug|ARM + {202641C4-7536-4935-8A25-C88C12E2B876}.Debug|ARM.Deploy.0 = Debug|ARM + {202641C4-7536-4935-8A25-C88C12E2B876}.Debug|x86.ActiveCfg = Debug|x86 + {202641C4-7536-4935-8A25-C88C12E2B876}.Debug|x86.Build.0 = Debug|x86 + {202641C4-7536-4935-8A25-C88C12E2B876}.Debug|x86.Deploy.0 = Debug|x86 + {202641C4-7536-4935-8A25-C88C12E2B876}.Release|Any CPU.ActiveCfg = Release|Any CPU + {202641C4-7536-4935-8A25-C88C12E2B876}.Release|Any CPU.Build.0 = Release|Any CPU + {202641C4-7536-4935-8A25-C88C12E2B876}.Release|Any CPU.Deploy.0 = Release|Any CPU + {202641C4-7536-4935-8A25-C88C12E2B876}.Release|ARM.ActiveCfg = Release|ARM + {202641C4-7536-4935-8A25-C88C12E2B876}.Release|ARM.Build.0 = Release|ARM + {202641C4-7536-4935-8A25-C88C12E2B876}.Release|ARM.Deploy.0 = Release|ARM + {202641C4-7536-4935-8A25-C88C12E2B876}.Release|x86.ActiveCfg = Release|x86 + {202641C4-7536-4935-8A25-C88C12E2B876}.Release|x86.Build.0 = Release|x86 + {202641C4-7536-4935-8A25-C88C12E2B876}.Release|x86.Deploy.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/samples/Clock/ClockWP8/Fonts/BILLY ARGEL TRIAL___.otf b/samples/Clock/ClockWP8/Fonts/BILLY ARGEL TRIAL___.otf new file mode 100644 index 0000000..e084a2a Binary files /dev/null and b/samples/Clock/ClockWP8/Fonts/BILLY ARGEL TRIAL___.otf differ diff --git a/samples/Clock/ClockWP8/MainPage.xaml b/samples/Clock/ClockWP8/MainPage.xaml new file mode 100644 index 0000000..04493bd --- /dev/null +++ b/samples/Clock/ClockWP8/MainPage.xaml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/samples/Clock/ClockWP8/MainPage.xaml.cs b/samples/Clock/ClockWP8/MainPage.xaml.cs new file mode 100644 index 0000000..40da8e7 --- /dev/null +++ b/samples/Clock/ClockWP8/MainPage.xaml.cs @@ -0,0 +1,52 @@ +using System; +using System.Windows; +using System.Windows.Threading; +using Microsoft.Phone.Controls; +using CrossGraphics; + +namespace Clock.WP8 +{ + public partial class MainPage : PhoneApplicationPage + { + Clock _clock; + XamlGraphics _graphics; + + public MainPage () + { + InitializeComponent (); + + _clock = new Clock (); + } + + private void PhoneApplicationPage_Loaded (object sender, RoutedEventArgs e) + { + // + // Initialize the graphics context + // + _graphics = new XamlGraphics(LayoutRoot); + + // + // Create a timer to refresh the clock + // + var timer = new DispatcherTimer { + Interval = TimeSpan.FromSeconds (1), + }; + timer.Tick += delegate { + Draw (); + }; + timer.Start (); + } + + void Draw () + { + _clock.Width = (float)LayoutRoot.ActualWidth; + _clock.Height = (float)LayoutRoot.ActualHeight; + + _graphics.BeginDrawing (); + + _clock.Draw (_graphics); + + _graphics.EndDrawing (); + } + } +} diff --git a/samples/Clock/ClockWP8/Package.appxmanifest b/samples/Clock/ClockWP8/Package.appxmanifest new file mode 100644 index 0000000..faae6bc --- /dev/null +++ b/samples/Clock/ClockWP8/Package.appxmanifest @@ -0,0 +1,58 @@ + + + + + + + + + ClockWP7 + Juergen + Assets\StoreLogo.png + + + + 6.3.1 + 6.3.1 + + + + + + + + + + + + + + + + + + + + + + + + + + + AgHostSvcs.dll + + + + + \ No newline at end of file diff --git a/samples/Clock/ClockWP8/Properties/AppManifest.xml b/samples/Clock/ClockWP8/Properties/AppManifest.xml new file mode 100644 index 0000000..a955232 --- /dev/null +++ b/samples/Clock/ClockWP8/Properties/AppManifest.xml @@ -0,0 +1,6 @@ + + + + diff --git a/samples/Clock/ClockWP8/Properties/AssemblyInfo.cs b/samples/Clock/ClockWP8/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..44395c0 --- /dev/null +++ b/samples/Clock/ClockWP8/Properties/AssemblyInfo.cs @@ -0,0 +1,37 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Resources; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ClockWP8")] +[assembly: AssemblyDescription ("")] +[assembly: AssemblyConfiguration ("")] +[assembly: AssemblyCompany ("")] +[assembly: AssemblyProduct("ClockWP8")] +[assembly: AssemblyCopyright ("Copyright © 2012")] +[assembly: AssemblyTrademark ("")] +[assembly: AssemblyCulture ("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible (false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid ("c72d72aa-aecf-4325-9048-5ca6d40ed591")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion ("1.0.0.0")] +[assembly: AssemblyFileVersion ("1.0.0.0")] +[assembly: NeutralResourcesLanguageAttribute ("en-US")] diff --git a/samples/Clock/ClockWP8/Properties/WMAppManifest.xml b/samples/Clock/ClockWP8/Properties/WMAppManifest.xml new file mode 100644 index 0000000..17149c6 --- /dev/null +++ b/samples/Clock/ClockWP8/Properties/WMAppManifest.xml @@ -0,0 +1,52 @@ + + + + + ApplicationIcon.png + + + + + + + + + + + + + + + + + + + + + + + + + Background.png + 0 + Background.png + ClockWP8 + + + + + + + + + false + + + + + + + + + + \ No newline at end of file diff --git a/samples/Clock/ClockWP8/SplashScreenImage.jpg b/samples/Clock/ClockWP8/SplashScreenImage.jpg new file mode 100644 index 0000000..353b192 Binary files /dev/null and b/samples/Clock/ClockWP8/SplashScreenImage.jpg differ diff --git a/samples/Clock/ClockWP8/UpgradeLog.htm b/samples/Clock/ClockWP8/UpgradeLog.htm new file mode 100644 index 0000000..5348bb8 Binary files /dev/null and b/samples/Clock/ClockWP8/UpgradeLog.htm differ diff --git a/samples/Clock/ClockWpf/ClockWpf.csproj b/samples/Clock/ClockWpf/ClockWpf.csproj index 300dc3c..4b1ed74 100644 --- a/samples/Clock/ClockWpf/ClockWpf.csproj +++ b/samples/Clock/ClockWpf/ClockWpf.csproj @@ -62,12 +62,12 @@ Graphics.cs - - SilverlightGraphics.cs - System.Drawing.cs + + XamlGraphics.cs + Clock.cs @@ -104,6 +104,9 @@ + + +