The Battle of Wolf 359… err, Project 365!
by DW on Jan.31, 2012, under Random, Technology
In late 2010 I jumped in as an early adopter to Windows Phone 7 and purchased a HTC 7 Mozart. While Windows Phone 7 still proves to be like Marmite, and the handsets available trail behind those offered by Android, it was an improvement over my previous phone. Finally I had a smartphone which easily supported the different social networks and had apps I wanted to use, unlike my previous Windows Mobile 6.5 handset, which had programs rather than apps.
The camera wasn’t bad either. An 8 megapixel sensor with a Xenon flash, quite a unique feature for a phone. Finally I was carrying a camera with me every day capable of some reasonable shots. Of course my compact Canon Ixus 85IS was, and still is, far better, but I don’t take that everywhere. So, on January 1st 2011, I began ‘Project 365′ (#project365).
The idea is simple – take at least 1 picture a day, and share it somewhere. I chose to do this primarily through Windows Live SkyDrive, because the phone could auto-upload the pictures. The album can be found here: http://bit.ly/z5m5H3
But looking back on it now, if I had known how difficult it would be, I’d not have committed!
At the end of the year, I had only 359 photos! Even when trying, I fell 6 short of a picture for every day. Some days I just felt there was nothing worth taking a picture of. Most of the time I’m travelling to the same depressing office, to do the same mindless job. I don’t want to be taking photos of that. I’m sure over half, possibly three quarters of the pictures are of my pet rats, and more recently, pet cats.
This really has shown me that most of the time, my life is boring. I do the same thing day in day out in such a routine, photo opportunities don’t really present themselves. Certainly not ones worth sharing. I at one point created a set on my Flickr to share these photos, but have since deleted them. These are not pictures worth having on Flickr. Instead, I will leave them on Windows Live, where they can be seen if anyone wants too.
This year, I knew right away I did not want to try this again. It highlights the boredom of my life far too much. Of course I’m going to keep taking, and sharing, pictures of my cats. That is, after all, what the internet is there for! But I’m not going to force myself to take pictures when pictures don’t need taking.
The Year That Stuff Happened.
by DW on Dec.31, 2011, under Electronics, Random, Work
Ok, so it’s the end of the year, and I still haven’t finished building my (rather simple) robot. The current hurdle I’ve not been able to clear involves configuring the XBee Wi-Fi Module. I have tried both the XBee Explorer Dongle and XBee Explorer USB from Sparkfun, without success. I have tested both on multiple machines, and get the same problems.
The X-CTU software used to configure the XBee modules has trouble seeing that the XBee module is connected. I am sometimes able to read the current settings from the XBee, or even write changes to it, but not reliably. It may be something to do with the USB to Serial (RS232) converter that is built in to both boards. Therefore I still haven’t been able to configure in a way that will work how I need it too. If I can’t get it working, I may get the official XBee USB Interface Board from Digi, and try again.
Work, is of course, still work. I go there every day, do what I need to do, and leave as soon as possible. My plan for 2012 is to move on to better things, be that another,more fulfilling job, postgraduate education, or something else. The thought of being stuck in the same hole this time next year is far too depressing. I’m sure all of you will agree, writing ‘software’ using VBA in Microsoft Word and Excel is something no one should have to suffer!
To that end, I’ve been getting involved in more things outside of work, so there is actually something interesting in my life to stop work from finishing me off. I have signed up as a mentor for Young Rewired State, after attending the 2011 Final. I may also look at the other things Rewired State has to offer. I have already met some cool people through there, and we’ve come up with an idea for a project to hack together. I’m not sure I’ll be able to contribute much, as work has killed off most of the useful stuff I once knew, from Uni and before, but it’ll be fun to try.
So it’s onwards into 2012. If 2011 was ‘The Year Stuff Happened’, hopefully 2012 for me will have an equally good tag line. Perhaps ‘The Year I Resurrected my Career’ or ‘The Year I Rose Out of the Gutter’. Either way, if I’m still stuck in the same place this time next year, in the same depressing dead end job, you’ll know I’ve failed. But for now, time to polish my C.V. (if that’s possible), update my website and profiles, and order some Moo cards!
The Forgotten Child(Window): How to Implement Pop-ups on Windows Phone 7.5 Mango – Part 2
by DW on Nov.30, 2011, under App Development, Programming
In my last post, I explain how to get the correct Silverlight assembly referenced in developing a Windows Phone 7.5 application, so you can implement the ChildWindow object. This allows you to add Pop-up dialogue boxes to your application that by default are not possible!
Now, I’m going to show you how to implement the ChildWindow, design your pop-up, and use it in your Windows Phone 7 app. I have tried to keep it simple, and focus on implementing the ChildWindow only. I have not included the other functionality I use in my app. There are many developer resources available that can help you can learn Windows Phone development, such as here at the Windows Phone App Hub, but these resources do not include the ChildWindow class I am explaining here.
First, add a new Windows Phone User Control to your project, and name it, for example ‘Popup.xaml‘. (Right click your project, Click Add -> New Item. Choose Windows Phone User Control from Silverlight for Windows Phone). This will create your control and display the visual and code XAML editors side by side.
You can design your control whichever way you prefer. You may drag controls from the toolbox onto the visual side, or you may type this in the code editor. As it is a pop-up, you should probably keep it simple. I have used just 2 TextBlocks, 1 TextBox and 2 Buttons.
The next step is very important. You must change the XAML to reference ‘System.Windows.Controls‘ and change it from a UserControl to a ChildWindow. It is also important to set the size and position relevant to the screen size. Remember, Windows Phone 7 handsets currently have a 480 x 800 (in portrait) resolution. I have created the pop-up to be 440 wide, not quite the full width of the screen, and only 200 high. (If you were designing your app to work in landscape, you would need to adjust the width and height to be appropriate.) I have positioned it towards the top of the screen, so that the software touch screen keyboard does not cover it. If you have the pop-up too low, it would be behind the keyboard and difficult to use.
Your Popup.xaml code outline should look like this:
<tk:ChildWindow x:Class="ExampleProject.Popup"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:tk="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
VerticalAlignment="Top"
HorizontalAlignment="Center"
Margin="0,40,0,0"
HasCloseButton="false" Height="200" Width="440">
<Grid x:Name="LayoutRoot">
<!--LayoutRoot is the root grid where all page content is placed-->
</Grid>
</tk:ChildWindow>
Next, for any Buttons you have used, make sure the Button Click events have been generated. Now go into ‘Popup.xaml.cs‘, and begin by adding reference to ‘System.Windows.Controls‘ at the top with the line ‘using System.Windows.Controls;‘. Change the base class for your pop-up from ‘UserControl‘ to ‘ChildWindow‘.
The outline of Popup.xaml.cs will now look like this:
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace ExampleProject
{
public partial class Popup : ChildWindow
{
public string HostName { get; set; }
public Popup()
{
InitializeComponent();
}
}
}
I am using my pop-up to input a network device Host name, which is then used to set the destination server of a UDP socket when broadcasting data. I have defined that as a public variable in Popup.xaml.cs, so it can be set, and then read back in my main app. I store this as a setting in my app, so it can be saved to memory, and loaded in future. I also have two buttons, ‘OK’ to set the Host name, and ‘Cancel’ to close the Pop-up without doing anything.
I use a Connect button in MainPage.xaml.cs to create an instance of the pop-up and display it. The existing value of Host name is loaded from ‘settings’ and passed to the pop-up window. Important: If you are developing a ‘Silverlight and XNA Application‘, as I am here, you may need to turn off the XNA rendering to display the Pop-up. When I first tried this, my pop-up would not display over the XNA graphics I was rendering at the time.
Opening the Pop-up from MainPage.xaml.cs:
private void btnConnect_Click(object sender, RoutedEventArgs e)
{
// Set the sharing mode of the graphics device to turn off XNA rendering
SharedGraphicsDeviceManager.Current.GraphicsDevice.SetSharingMode(false);
Popup popup = new Popup();
popup.HostName = settings.HostName;
popup.Closed += new EventHandler(OnPopupShow);
popup.Show();
}
In Popup.xaml.cs, it then takes the current Host name, and puts it into the text box:
protected override void OnOpened()
{
base.OnOpened();
this.txtHostName.Text = this.HostName;
this.txtHostName.SelectAll();
}
Finally the two buttons in Popup.xaml.cs control how it functions in MainPage.xaml.cs:
private void btnOK_Click(object sender, RoutedEventArgs e)
{
// Value is good so close this childwindow
this.HostName = this.txtHostName.Text.Trim();
this.DialogResult = true;
}
private void btnCancel_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = false;
}
Back in MainPage.xaml.cs I use the OnPopupShow event that occurs when the pop-up is closed, to decide what to do with the Host name. If the ‘OK’ button was pressed, the pop-up will return ‘true’, and so the Host name entered in the TextBox will be used and saved into the app settings. If ‘Cancel’ was pressed, the pop-up returns ‘false’, and so my application ignores any text that was entered, and will continue to use the existing saved Host name. Important: As we turned off XNA rendering to allow us to display the Pop-up correctly, you can now turn it back on as the Pop-up has closed.
Handling the result of the Pop-up with the OnPopupShow event:
private void OnPopupShow(object sender, EventArgs e)
{
Popup popup = sender as Popup;
if (popup.DialogResult == true)
{
settings.HostName = popup.HostName;
settings.Save();
// Set the sharing mode of the graphics device to turn on XNA rendering
SharedGraphicsDeviceManager.Current.GraphicsDevice.SetSharingMode(true);
}
}
This is a simple implementation of a ChildWindow in a Windows Phone 7 application, used to get the destination Host name for a UDP socket. As I said at the start, I have focussed just on the ChildWindow to display and use a pop-up, and left out the other functionality of my application.
This should now allow you to create your own Pop-up, with whatever controls you need, and use it in your own application. Another application of it could be entering a username and password.
Have fun developing Windows Phone 7 apps – hopefully you will find this useful. If you have any questions, or get stuck, post a comment and I’ll try to help!










Recent Comments