Archive

Archive for November, 2015

Prerolled jqm themes #JQM #Themeroller

With the latest version of Jquery Mobile, the included themes have been made decidedly more bland, and the themes available for JQM are quite specialized, like the BlackBerry theme, NativeDroid, Flat UI etc., but if you just want something simple and attractive, here is a hack to show themes that other users have done on ThemeRoller,

Just go to the url – https://themeroller.jquerymobile.com/?ver=1.4.5&style_id=YYYYMMDD-NN

where YYYYMMDD is a date within the last 30 days, and N is a sequental number.

Most of them are un-styled, and a lot are quite ugly, but you might find a gem there,

https://themeroller.jquerymobile.com/?ver=1.4.5&style_id=20151124-15 – Cookie – colourful

https://themeroller.jquerymobile.com/?ver=1.4.5&style_id=20151124-11 – maroon

https://themeroller.jquerymobile.com/?ver=1.4.5&style_id=20151124-10 – blue green

https://themeroller.jquerymobile.com/?ver=1.4.5&style_id=20151123-10 – grey blue

https://themeroller.jquerymobile.com/?ver=1.4.5&style_id=20151123-14 – tourquize

https://themeroller.jquerymobile.com/?ver=1.4.5&style_id=20151123-15 – Grey green

https://themeroller.jquerymobile.com/?ver=1.4.5&style_id=20151123-17 – Grey cyan

https://themeroller.jquerymobile.com/?ver=1.4.5&style_id=20151123-19 – pink

https://themeroller.jquerymobile.com/?ver=1.4.5&style_id=20151123-2 – purple pink

https://themeroller.jquerymobile.com/?ver=1.4.5&style_id=20151122-10 – orange grey

https://themeroller.jquerymobile.com/?ver=1.4.5&style_id=20151122-12 – light green

 

 

themeroller

Categories: Uncategorized

Updating the font used throughout a #wp8 #app

Using a custom font is a nice design touch that helps a windows phone app stand out, by looking a little different. The Segoe font can be a bit boring…

So, the standard way this is done, is by adding the following into Application.Resources in App.xaml

<Style TargetType=”TextBlock”>
<Setter Property=”FontFamily” Value= “assets/fonts/whatever.ttf#whatever”/>
</Style>

<Style TargetType=”TextBox”>
<Setter Property=”FontFamily” Value= “assets/fonts/whatever.ttf#whatever”/>
</Style>

But, here’s another approach, using reflection, and page hooks, like used in a previous post:
https://blog.dotnetframework.org/2015/11/09/localise-datepicker-in-wp8-silverlighttoolkit-using-hooks/

So, from within CompleteInitializePhoneApplication, add the code

PhoneApplicationPage page = RootFrame.Content as PhoneApplicationPage;
FontChangeHook(page);

then, FontChangeHook method as follows;

public static void FontChangeHook(PhoneApplicationPage page)
{
LoopThroughControls(page, (ui => {
var type = ui.GetType();
var prop = type.GetProperty(“FontFamily”);
if (prop != null)
{
prop.SetValue(ui, new FontFamily(@”assets/fonts/whatever.ttf#whatever”));

}
}));
}

Categories: Uncategorized

Free OCR using C= #Webservice

Converting an image into text is a difficult job for a computer, hence the pervasive use of Captcha images, however, OCR (optical character recognition) is quite effective with printed text.

Here’s a free webservice provided by a9t9, it’s limited to 500 requests/day or 15000 requests/month per IP address. You can get more quota by emailing a9t9 – You provide it with a url with an image that contains text;

It returns it’s results in JSON, so the bulk of this code is really just to convert the response to a simple string.

[WebMethod]
public string Automatic(string imageUrl)
{
var wc = new WebClient();
wc.Headers[“Content-Type”] = “application/x-www-form-urlencoded”;
const string strUrl = “https://ocr.a9t9.com/api/Parse/Image&#8221;;
var strPostData = “apikey=helloworld”;
strPostData += “&url=” + HttpUtility.UrlEncode(imageUrl);
var strJson = wc.UploadString(strUrl, “POST”, strPostData);
var result = JavascriptDeserialize<A9T9>(strJson);
return result.ParsedResults.First().ParsedText;
}

And the json conversion;

/// <summary>
/// Converts a JSON string into an object of type T.
/// </summary>
/// <typeparam name=”T”></typeparam>
/// <param name=”json”>The JSON string.</param>
/// <returns></returns>
public static T JavascriptDeserialize<T>(string json)
{
var jsSerializer = new JavaScriptSerializer { MaxJsonLength = Int32.MaxValue };
return jsSerializer.Deserialize<T>(json);
}

public class ParsedResult
{
public int FileParseExitCode { get; set; }
public string ParsedText { get; set; }
public string ErrorDetails { get; set; }
}

public class A9T9
{
public List<ParsedResult> ParsedResults { get; set; }
public int OCRExitCode { get; set; }
public bool IsErroredOnProcessing { get; set; }
public object ErrorDetails { get; set; }
}

Categories: Uncategorized

Free SMS New Zealand, new website launched today

logo-nz

Just launched today http://www.freesms.co.nz – a website for sending free SMS messages to New Zealand, so you can keep in contact with your Kiwi relatives that haven’t yet moved over to the world of Whatsapp / Skype / Facebook Messenger yet.

It’s powered by the great guys over at Fortumo – a great free-to-try PSMS system, zero setup fees, zero monthly cost, and massive coverage. You just can’t beat them!

Categories: Uncategorized

Localise DatePicker in #WP8 #SilverlightToolkit using hooks

The Silverlight toolkit for Wndows phone is really handy to get up and running quickly with advanced functionality on a Windows Phone app, however, when you want to customize it, you find that you end up downloading the source, and tinkering with it directly, which is fine, since it’s an open source project. However, for a minor change, it would be nice to keep treating it as a black box.

This approach however, could therefore be used to access and modify the XAML of any control, even closed-source ones. Which could be useful for Syncfusion or Telerik controls too.

So, first, we modify app.xaml.cs to create our hook.

Comment out // RootFrame.Navigated -= CompleteInitializePhoneApplication; in CompleteInitializePhoneApplication, so that the method gets called on every page load, not just on first load.

Then check the current page like this

PhoneApplicationPage page = RootFrame.Content as PhoneApplicationPage;
var strPage = (sender as NavigationService).CurrentSource.ToString();
if (strPage.Contains(“DatePickerPage.xaml”)) UI.DatePickerHook(page);

Hopefully, you don’t have a page called DatePickerPage.xaml in your app!, but this will call UI.DatePickerHook when the datepicker is opened.

Now, for a helpful utility function, which I’ve called LoopThroughControls – which applies an action to every control on a page recursively as follows;

private static void LoopThroughControls(UIElement parent, Action<UIElement> modifier)
{
int count = VisualTreeHelper.GetChildrenCount(parent);
if (count > 0)
{
for (int i = 0; i < count; i++)
{
UIElement child = (UIElement)VisualTreeHelper.GetChild(parent, i);
modifier(child);
LoopThroughControls(child, modifier);
}
}
return;

Then the DatePickerHook function is defined as follows

public static void DatePickerHook(PhoneApplicationPage page)
{
// Somehow modify the text on the top of the page…
LoopThroughControls(page, (ui => {
var tb = ui as TextBlock;
if (tb != null && tb.Name == “HeaderTitle”)
{
tb.Text = “”;
}
}));
}

Categories: Uncategorized