![]() |
|
Spaces home Simon Ransom's spacePhotosProfileFriends | ![]() |
|
|
March 07 Silverlight 2.0 Beta 1 releasedWhoohoo http://www.microsoft.com/silverlight/resources/installationfiles.aspx?v=2.0 Unfortunately it doesn't come with a commercial go-live license (although you can try and apply for one). March 05 CSS: Overflow:hidden and position:relativeWhile writing an Ajax app that was supposed to collapse rows I came across this age old IE bug where the text on the cells I was laying out had relative positioning but were not cropped by the overflow hidden on their containing div. I found this page useful http://www.brunildo.org/test/OverflowR.html But what actually fixed it was simply adding position:relative onto the div that had the overflow:hidden. February 26 EnableRedrawRegionsI haven't seen many performance problems but if I do, this looks like a useful tip: "For Perf debugging, a way to tell when you are causing a redraw is to turn on the control's EnableRedrawRegions property. agControl.settings.EnableRedrawRegions = true; With this feature on, when a section of the plugin causes a draw, that section will draw in a different color. This setting is not for those susceptible to seizures =P" February 08 Visio to Xaml converterWow - just spotted this:
"I was excited to see VisioExportToXaml on Codeplex from Saveen Reddy (with credits to Thierry Bouquain and SharpVectors). " January 29 Silverlight 1.1 Alpha Refresh cannot use the inplaceInstallPromptI hope someone finds this useful (at least until 2.0 Beta which I reckon will be out by Mix '08 in March), the Silverlight 1.1 Alpha Refresh does not appear to be able to use the "inplaceInstallPrompt" property. Silverlight.createObjectEx({
source: "Page.xaml",
parentElement: document.getElementById("SilverlightControlHost"),
id: controlID,
properties: {
width: "500",
height: "500",
version: "1.1",
enableHtmlAccess: "true",
inplaceInstallPrompt:true // <-- does not work
},
events: {onLoad: OnLoaded}
});
Looking at the Silverlight.js, it overrides the setting by doing the following: if(g.shortVer=="1.1")g.inplaceInstallPrompt=false I was surprised not to find any articles on the web about this but there are a lot of misleading posts like this one (which not only suggests that it works but wraps the true as a string which doesn't work in 1.0). Also to get around my issue that createHostedObjectEx points to the wrong version of Silverlight (rumours are this will be fixed by MIX '08), I simply used javascript to redirect to another html page that was a cut-down version of my main page. It still loaded the same application but in the Silverlight onLoad it executed some more javascript to go back to the main page. January 14 Could not load file or assembly 'System.Data.DataSetExtensions, Version=2.0.0.0, ...After upgrading from Visual Studio 2008 beta 2 to the RTM I got the following error: Could not load file or assembly 'System.Data.DataSetExtensions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified. Daniel Moth already figured this out last year. January 09 Silverlight expiry August/November 2007According to the current Terms and Conditions for the September 1.1 Alpha refresh, they will expire on 1st August (Mac) and 1st November (PC) 2007. This is not true, I posted this question (via my psuedonym LittleClive :-)) to http://silverlight.net/forums/p/8248/25757.aspx#25757
December 20 Uploading photos to PhotoboxI'm not trying to make money from my photos but wanted to give friends and family the opportunity to order photos if they wanted to so I've used the photobox FTP interface, a bespoke windows service, .NET remoting to retrieve the current upload status and a webservice to expose all this to the Silverlight app. Here are some screenshots of the current ordering process: Silverlight 1.1 is now Silverlight 2.0!It's official, Silverlight 1.1 is being rebranded 2.0 with a beta being released in Q1 of 2008. According to Scott Guthrie this will come with a Go-Live license that "enables developers to begin building and deploying Silverlight 2.0 applications". December 06 Album art rendered in 3dNovember 27 HttpWebRequest.GetRequestStream() appeared to hangAfter about two successful uploads to the Silverlight Streaming Servers, req.GetRequestStream() appeared to hang. Actually it was waiting for a free connection for 15 minutes (since that is what I had now set the timeout to) and couldn't get one. I already made sure I was closing the streams I was explicitly using, i.e. using (Stream requestStream = req.GetRequestStream()) {...} But I found I also needed to close the response even though I hadn't referred to it (unfortunately HttpWebRequest isn't disposable and doesn't have an overall close method): req.GetResponse().Close(); I should really be checking the response though... November 25 Silverlight raised events not reaching javascript/HTML pageOne of the events in my Silverlight app did not appear to reach my HTML page. Turned out that I had lazily put an event handler in my Silverlight app as follows: void buttonClose_Click(object sender, EventArgs e) { if (Close != null) { Close(this, e); } } The problem being the event args that came through from the buttonClose event could not be passed to javascript. No errors were thrown to help me, but all was fine again by changing the code to: void buttonClose_Click(object sender, EventArgs e) { if (Close != null) { Close(this, new EventArgs()); } } Note that even Close(this, null) seemed to stop the event getting through.November 21 15 minute upload timeoutI finally managed to get around the issue of .NET closing my socket before I'd finished with it. It was closing after 15 minutes as mentioned in my previous post. Unfortunately it was all futile because the Silverlight Streaming Server closes the connection a few seconds later that results in the exception: Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host. Quite a bit of digging around on the silverlight.net forums showed this post which refers to the following info on MSDN:
Now I seem to be a bit stuck since:
So basically I seem to be limited to a 30mb zip file for any video I want to cache for my application. The only alternative I can see is to launch separate Silverlight applications for cached content. November 19 Uploading large files to the Silverlight Streaming ServersI am trying to synchronize my most recent video content with the Silverlight Streaming Servers to give better performance for the newest content. Using the EXIF information in the photos and the Canon .THM files I have calculated the date ranges that each of the photo/movie collections spans. Using the Silverlight Streaming Services REST API to interrogate the list of applications, remove stale entries and upload new video content. The first issue whilst trying to upload a 140MB zip file was the following exception: System.Net.WebException: The request was aborted: The request was canceled. This occurred around 90 seconds into the upload (about 4.5MB had uploaded). To work around this I set the HttpWebRequest Timeout and ReadWriteTimeout properties to -1. I am now getting the following error after about 30MB has uploaded: Unable to write data to the transport connection: An established connection was aborted by the software in your host machine. November 09 ScreenshotsSome screenshots of how it's progressing so far... 1) Intro movie that I created using povray. This movie I've hosted on the Silverlight Streaming servers. Piles of photos on the left depict the categories, bigger piles represent larger categories. 2) As you drill down the menus on the left, the icon and label animate to the breadcrumb at the top. I might use the now blank space to show more thumbnails. The tabs at the bottom show Photos, Movies and Order. This order category has been a bit tacked on but it does work and allows a selection of photos to be uploaded to photobox. Full size images use a bit of [Scriptable] magic to use html to launch a popup containing the full size image. Toggle quality switches between bit-rates for movies (I used WMV9 Advanced Profile to create the VC-1 movies) so this button is currently a bit misplaced on the photo page. 3) A large spinning progress cog is used to indicate any progress like buffering and loading the menus (I'll probably regret this at some point but it's an iterative process). I wrote a Windows Service to poll for new orders and since this is a lightweight site I've used a remoting singleton to report on the current state of the upload so that feedback can be given to the user. This singleton is then exposed by a web-service, which is in turn polled by the Silverlight app. Wrong version of Silverlight installedWhen users don't have Silverlight 1.1, they get prompted to install 1.0 which results in a loop of going back to the page only to get told they need Silverlight. It appears the version of Silverlight.js in the SDK is incorrect and people have been tweaking it to fix it (see hacked Silverlight.js). I haven't tried this yet but I am currently hosting content on the Silverlight Streaming Servers and therefore have used the Silverlight Streaming specific Silverlight.js from http://agappdom.net/h/silverlight.js This script seems to be 1.0 specific so if the user doesn't have Silverlight, it tries to get them to install 1.0. Maybe I'll have to write my own detection.... October 10 Asynchronous web-service calls from SilverlightFollowing on from not being able to make webservice calls on non-UI thread, asynchronous calls can be made via the BeginXXX/EndXXX methods in the generated proxy as long as they are initiated on the UI thread. The check is done in the BrowserHttpWebRequest constructor so a bit of Lutz-ing on System.Silverlight.dll reveals that the constructor is called before the method is asynchronously invoked and hence works as long as the BeginXXX method is called on the UI thread. Based on all this and a bit of refactoring, my progress animation now plays whilst I make a number of paged web-service calls to gradually populate the navigation controls. October 04 This operation can only occur on the UI ThreadSo to avoid the JSON serialization length limit mentioned in a previous post, I have created a separate LoadMenuPage method that takes a menu file and a page number. The total number of pages is returned in the first LoadMenu call. At the moment, my client application loads all of the menus and merges them together into a single menu so the result is the same but this can take some time. The menus have to be limited to 10 menu items per web-service call and since there are 84 items in one of the menus, this requires 9 calls plus merge time. I wanted to give some feedback to the user about this long running application so I tried starting an animation before the long call and then hiding it afterwards. This didn't work because the long running call was executing on the UI thread so I moved the web-service invocation and merging logic to another thread. When it completes, it needs to populate a UI control which it can't do if it's not on the UI thread and there's no Dispatcher in Silverlight yet. So I created a custom dispatcher using the HtmlTimer (which is marked obsolete but from research seems to be the only choice at the moment): public class CustomDispatcher { private Queue<Delegate> uiWork = new Queue<Delegate>(); private HtmlTimer timer = new HtmlTimer(); public void Start() { timer.Start(); } public void InvokeOnUIThread(Delegate d) { uiWork.Enqueue(d); } private void OnTick(object sender, EventArgs args) { if (uiWork.Count > 0) { Delegate d = uiWork.Dequeue(); d.Method.Invoke(d.Target, null); } } public CustomDispatcher() { timer.Interval = 100; timer.Tick += new EventHandler(OnTick); } } So all is looking good-ish, but then I hit another wall when I ran it up because I got the error I had been trying to avoid "This operation can only occur on the UI Thread": It seems the web-service proxy code requires an internal call to System.Windows.Browser.HtmlPage.get_DocumentUri() which needs to be executed on the UI thread. I haven't tried the asynchronous BeginLoad in the proxy yet... Fixing the Silverlight 1.1 SDK Alpha controlsIt's great that the source code is provided for these controls. I've had to fix the ListBox so that it scrolls back to the top when UpdateItems is called, otherwise the canvas can appear empty when drilling down through menus:
//Updates the content children with the current items in the list public void UpdateItems() { //remove all the children and start from empty content.Children.Clear(); content.SetValue(Canvas.TopProperty, 0); I've also had to fix the list box so that after scrolling it doesn't select content if you release the mouse button inside the content area which has greatly reduced the number of mis-selections: /// <summary> /// Keep track of where mouse was originally pressed /// </summary> private bool mouseDownInsideContentArea; // CaptureMouse protected void OnMouseLeftButtonDown(object sender, MouseEventArgs args) { if (CheckMousePosition(args)) { ActualControl.CaptureMouse(); mouseDownInsideContentArea = true; } else { mouseDownInsideContentArea = false; } } // If the mouse is on the ListBox find on which item and select it. protected void OnMouseLeftButtonUp(object sender, MouseEventArgs args) { ActualControl.ReleaseMouseCapture(); //do thing only if we are outside the ScrollBar [Simon Ransom: and the mouse was originally pressed when not on scroll bar] if (CheckMousePosition(args) && mouseDownInsideContentArea) { Point pt = args.GetPosition(this); if ((items.Count > 0) && (pt.X < Width) && (pt.Y < Height)) { double contentY = pt.Y - (double)(content.GetValue(Canvas.TopProperty)); int itemNumber = (int)(contentY / itemHeight); FrameworkElement newSelection = itemNumber < items.Count ? items[itemNumber] : null; if (selectedItem != newSelection) { Select(newSelection); if (SelectionChanged != null) { SelectionChanged(this, null); } } } } } October 02 JSON serialization and "Error invoking service."To serve up my menu XML files which I already have .NET serialization classes for, I've created a webservice:
[ WebService(Namespace = "http://www.simonransom.com/menuservice/3.0")][ WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)][ ToolboxItem(false)][System.Web.Script.Services. ScriptService] public class MenuService : System.Web.Services.WebService{ [ WebMethod][ ScriptMethod(ResponseFormat = ResponseFormat.Json)] public SegmentedMenu Load(string menu){ string path = Server.MapPath("~/menufiles/" + menu); return new SegmentedMenu(MenuManager.GetInstance().Load(path));} } From this I learnt a few things:
{"menu":"publicphotos.xml"}
{"Message":"Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.","StackTrace":" at System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams)\r\n at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.InvalidOperationException"}
So now I need to work out how make the larger menus smaller or increase the maxJasonLength property. |
|
|