drupal hit counter
Jerry Huang | All posts by jerry

Jerry Huang apps and developing apps

Translation between WP and Win8 Metro series: loading byte array into BitmapImage

1. November 2012 14:07 by Jerry in C#, Win8 Development, Windows Phone Development

WP

[code language=C#]
byte[] frameBuffer;
BitmapImage.SetSource(new MemoryStream(frameBuffer, 0, frameBuffer.Length));
[/code]

Win8

[code language=C#]
 var ms = new Windows.Storage.Streams.InMemoryRandomAccessStream();
                        ms.AsStreamForWrite().Write(frameBuffer, 0, frameBuffer.Length);
                        ms.Seek(0);
                        BitmapImage.SetSource(ms);
[/code]

it looks to me that Win8 just making thing complicated:(

Translation between WP and Win8 Metro series: async anonymous method in Win8

1. November 2012 13:48 by Jerry in C#, Win8 Development, Windows Phone Development

As I mentioned previously, I'm trying to develop a Win8 Metro version of IP CAM Coontroller, so I'm basically translating the WP coding into Win8. I'm going to post a series of blog post to record (and so benefit those googler with same problem) some of the interesting issue and topic.

WP coding:

[code language=C#]
Deployment.Current.Dispatcher.BeginInvoke(() =>
                        {
                            //do something here
                        }
                        );
[/code]

WIN8

[code language=C#]
 Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
                Windows.UI.Core.CoreDispatcherPriority.Normal,
                new Windows.UI.Core.DispatchedHandler(() =>
                {
                    //do something here
                }));
[/code]

This is not end of the story, by using the RunAsync like above, you will get a compiler warning from VS2012, and it's interesting that if you assign the returning result (of RunAsync) to a variable, the warning goes away. So the final version is like:

[code language=C#]
 var dummy = Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
                Windows.UI.Core.CoreDispatcherPriority.Normal,
                new Windows.UI.Core.DispatchedHandler(() =>
                {
                    //do something here
                }));
[/code]

Critical stopshower in Win8 store app development

1. November 2012 10:57 by Jerry in

Every upgrade from Microsoft is a nightmare! more or less...

I'm currently investgating the possibility of making a Windows 8 Metro version of my IP CAM Controller app. And what it turns out is not so pretty. Some developer already found out the issue a while back this year:

https://connect.microsoft.com/VisualStudio/feedback/details/737000/the-server-committed-a-protocol-violation-is-unoverridable-in-metro-style-apps

I'm encounterring the same and it's much much worse in my case, because what I'm dealing with is a bunch of HTTP servers implemented by various manufacturers that don't give a shit about Windows 8's world and they have their reasons - this has been working all the time, why just win8 can't?

Without enabling the useUnsafeHeaderParsing somehow, I don't think we can make any IP camera app unless we write our own HTTP component with raw socket, but Microsoft really expect us to do that? seriously?

IP CAM Controller v2.5 for Windows Phonoe released

11. October 2012 08:14 by Jerry in IP CAM, Windows Phone

Multi-View has been enhanced from this version, and free to use for trial users (while the new grouping functionis for paid version only).

How to use:

1) tap "Multi View" icon

2) select cameras you would like to put into your view

3) tap save button (at bottom) and enter a name to save current grouping

4) done

Note:

  • Multi View is mainly for people who own many (at least more than 1, obviouslywink) camera, with which you are able to view multiple cameras in one screen at the same time. You can even control each of them by tapping on image from this view!
  • Grouping is even more powerful if you want to have different views for different group of cameras, e.g. a view for cameras in building #1 another for building #2, etc.

IP CAM Controller is now on Android market!

27. September 2012 00:36 by Jerry in IP CAM, Android

After several months development, I'm so happy to announace the official release of IP CAM Controller in Google Play for Android phonesyes

Comparing with WP version, it has less functionalities in Android, but it's a wonderful start and all functionalities will be coming soon!

Here is the link for details: https://play.google.com/store/apps/details?id=com.zexu.ipcamera

A monthly view calendar in Windows Phone

17. June 2012 15:45 by Jerry in Windows Phone, Windows Phone Development

For some reason, I need a calendar control in a WP7 app, a special one, or a simple one. However, within the most exciting Metro world, it doesn't easy to get high sometimes - officially you don't have calendar control, you need to google it and, you don't have too many opotions after google. This is one of the biggest problem of WP7 development in my opinion. There is too few controls for developers to use.

Anyway, the control I need is a months view calendar that shows 12 months of the year and probably highlighted the current month. The year could be changed somehow. Eventually I found the regular calendar here:

http://adayofrequiem.blogspot.hk/2012/03/month-view-calendar-for-wp7.html

It said it's a "month-view-calendar" but it''s not really the month-view in this articlefrown, so based on the author's source code, I made my own MothView control. Take a look:

It doesn't look very excited, you may need to decorate a little to make it looks pretty. Here is the full source code:

monthview.rar (174.37 kb)

Force a data binding to update

16. June 2012 18:41 by Jerry in Windows Phone Development

The beauty of data binding in Silverlight or WP7 is that it completely separate the UI and data access logics. The ugliness of data binding however is that it doesn't work or work as expect sometimes. The problem is always in Two-Way binding for data input. Consider a very common and straightforward scenario:

A regular page that contains a few textboxes and listpickers for user to input something, and there are 2 buttons inside the application bar - done and cancel. Once user tap the "done" button, data save( or do some validation before that); tap the cancel button simply reset all data input controls. As a result, the best way to implement this is to use a two-way data binding that binding the textbox's Text property to your ViewModal class. Very easy, just a few lines of coding. Is that it? In most cases, yes. However.......

If a user is tapping the "done" button without leaving the textbox (i.e. without losing focus on the textbox), what will happen? The expected behavior is the text binding to viewmodal class and data get saved. You are just too innocent if you think sowink. The text will never get update to your viewmodal class before losing focus. The reason is that the default UpdateSourceTrigger (check MSDN for details) for a textbox (or maybe other controls) is the LostFocus event. With WPF, you may easily change this property like:

[code language=XML]<textbox text="{Binding TextViewModelProperty}" updatesourcetrigger="PropertyChanged"> </textbox>[/code]

In Siliverlight for WP7 however, the XAML doesn't support UpdateSourceTrigger, so you will have to do it manually in your save function:

[code language=C#]object focusObj = FocusManager.GetFocusedElement();
if (focusObj != null && focusObj is TextBox)
{
    var binding = (focusObj as TextBox).GetBindingExpression(TextBox.TextProperty);
    binding.UpdateSource();
}[/code]

 

Once the UpdateSource methid is called, text will be flush to your view-model class. This is the way I used to force a data binding to be inforced. Above coding is based on the post here (no 9 answer):

http://stackoverflow.com/questions/5569768/textbox-binding-twoway-doesnt-update-until-focus-lost-wp7

*credit goes to "StefanWick" and "rrhartjr" (for the WPF part)

 

Is this the end of the story? Is your input page perfect now?  Hoho you wish. The following issue is not really related to data binding but it's very common in every data-input-page with use of application bar button to save. The problem is that data will be save twice if you tap the "done" button quick enough. This bug is actully exists in the latest Facebook app. When you post a piece of comment on somebody's photo in (WP7 facebook app), once tap the "send" button, progress bar (the dot dot dot stuff) shows up at top of the screen, if you tap the "send" button again (believe me, you can), your comment will be posted twice.

I don't know how others resolve this issue, but here is what I did:

1) Write a private function in the xaml.cs
[code language=C#]
         private void EnableControls(bool enabled)
         {
             foreach (Microsoft.Phone.Shell.ApplicationBarIconButton btn in ApplicationBar.Buttons)
             {
                 btn.IsEnabled = enabled;
             }
             pvMain.IsEnabled = enabled;//the Pivot control
         }
 [/code]

2) call EnableControls(false); before the save data function

3) I assume you will bind a property like "InProgress" to the progress bar's IsIndeterminate property, like:

[code language=XML]<toolkit:PerformanceProgressBar x:Name="progressBar" VerticalAlignment="Top" IsIndeterminate="{Binding InProgress}" />[/code]

so the trick here is to call EnableControls(true) when the InProgress becomes false which means the data is saved.
 

[code language=C#]
        void vmNewTrans_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            switch (e.PropertyName)
            {
                case "InProgress":
                    if (!vmNewTrans.InProgress)
                    {
                        EnableControls(true);
                    }
                    break;
            }
        }
[/code]

That's it! No matter how quick you try to save twice, you will never get duplicated data:)

A major update of IP CAM Controller

8. February 2012 15:39 by Jerry in IP CAM, Windows Phone

I'm glad to annance that the v2.0 has been released to marketplace:)

V2.0 Relase Note
* App upgrades to Mango
* digital zooming
* pin camera to start and live tile update
* support new cameras: TP-Link, COMPRO, Level One, WansView,LogiLink
* new language: Swedish
* gesture support for pan and tilt scan
* Alarm and IR toggle for foscam, light toggle for axis

the new version is now based on the Mango WP7, that's why you will have those cool features like pin to start and live tile.

Are you ready to Mango? Let me know please...

11. January 2012 12:34 by Jerry in IP CAM

Recently I received a couple of great ideas from users (thanks, really!):

  • Live Tile support
    haven't made up the details, but one thing for sure is that the snapshot could be pin as icon or background
  • Pin the camera you created on IP CAM Controller to start screen
    this is really cool! Extremely fast to access to your camera, it's really one tap does the job. Moreover, you could use the camera snapshot as the back tile backgroup. (In Mango, each Tile has front one and back one, they are dynamically switched by the phone automatically)

However, as some of you may or maynot know, the current app is developed on earlier SDK (what we called 7.0 version) so that it's compatible with Mango and non-Mango (such as NoDo) devices. The above two features cannot be supported until the project is upgraded to SDK 7.1 (Mango SDK).

Once the project has been upgraded, the app is still available for non-Mango users, but they will not receive any update nofitication from marketplace, in other word, their IP CAM Controller will stick with existing version (v1.13) and not able to upgrade to any newer version until their phones are being upgraded.

I don't know how many people are still using earier version of Windows Phone, so I made a poll here, to collect your opinions and what phone you are using.

Please click here for the vote

 

The number one IP CAM app in "Music & Video" category on WP7 Marketplace

6. January 2012 18:21 by Jerry in

Finally, IP CAM Conotroller becomes the no. 1 IP Camera software in the Music & Video category, or ranking at top 18 in the category (US market) today. In the meanwhile, v1.13 has just been released.

I want to say thank you to all users (most likely they are parents like mecheeky). I'm so much appreciated for all your support in the past few months. As a result, I removed the time limitation on free trial from v1.13 version. Instead of having 3 minute limit on viewing for free trial users, there will be an ad bar showing up. The ad will be completely removed plus capacity of accessing multi view afte purchase. I hope this is acceptable for you.

The v1.13 starts to support multiple languages: Simplified and Traditional Chinese, German and Spanish (beta). Swedish will be coming in the next release, and maybe French:) If your language hasn't been listed, and you are happy to become an volunteer, please do contact me!