Archive
Fix: Visual Studio opens class diagram in XML editor with double click
Recently, to save myself sometime after having renamed some interfaces/classes in the ClipFlair project sourcecode, I right-clicked one of the class diagrams (.cd files) in it at Visual Studio’s “Solution Navigator” (this is an enhanced Solution Explorer addon) and using “Open With…” I opened up the diagrams with the XML editor to do a rename-all operation for the respective class names.
However, after saving the project I found out that from then on, that specific .cd file was opening up as XML file when double-clicked instead of opening up as a Class Diagram in the respective designer pane. Using Open With dialog would open it as a Class Diagram when asked to specifically, but using the checkbox to always open up as Class Diagram wouldn’t help fix the double-click problem for that specific .cd file (others would open up fine as class diagrams, not as XML files, when double-clicked).
I just managed to fix that issue by right clicking the file node in solution navigator’s tree and and excluding that file from the project (not deleting!), then saving the project, closing the solution containg the project and adding the file (via “Add existing file”) again after having reopened the solution. I could also possibly have right clicked selected “Unload project” after saving it and then select to reload it again, think that would have worked too.
Using VisualHG addon for Visual Studio I commited the changes to the Mercurial repository used by ClipFlair on Codeplex, which showed me that the file difference that did the fix was the following in the .csproj project file:
<ItemGroup>
<None Include="Diagrams\Windows.cd" />
- <None Include="Diagrams\Windows.Views.Interfaces.cd">
- <SubType>Designer</SubType>
- </None>
+ <None Include="Diagrams\Windows.Views.Interfaces.cd" />
<None Include="Diagrams\Windows.Views.ViewModels.cd" />
</ItemGroup>
That is instead of that marked-as-bold entry above (marked by the diff tool with – prefix), the line marked with + prefix should be used instead. This is obviously some bug in Visual Studio 2010, it’s nice to know though that you can easily take the project offline and edit the .csproj to fix it (or remove the .cd file, save the project, reload it and add the file again).
HowTo: load CaptionElements into Silverlight Media Framework player
Trying to make CaptionsGridWindow of ClipFlair serve captions editing on-the-fly to SMF (Silverlight Media Framework [now called MMPPF]) player component, I had a real hard time, plagued by a bug at TimedTextElementStyle. It seems to be setting default FontSize for captions using a “Cell” unit instead of using a “Pixel” unit. Currently SMF only supports “Pixel” units at FontSize of TimedTextElements according to the codedoc notes.
Another issue I had was that CaptionRegion constructor sets it to be active all the time (specifying a Begin value of a min possible TimeExtent and an End value of the max possible TimeExtent), so it renders ShowBackground.WhenActive setting useless for it. That is if you want the captions background to show up only when there are captions showing (active), then you have to set the CaptionRegion’s background to Colors.Transparent and set each CaptionElement’s background to some non-transparent color (note that both CaptionRegion and CaptionElement are TimedTextElements, with the later added to the former’s Children property, forming a TimedTree that is).
public void UpdateMarkers(MediaMarkerCollection<TimedTextElement> newMarkers) { if (newMarkers == null) return; CaptionRegion region = new CaptionRegion(); region.Style.ShowBackground = ShowBackground.WhenActive;
//doesn't seem to work if other than transparent color is used region.Style.BackgroundColor = Colors.Transparent; foreach (CaptionElement marker in newMarkers) { region.Children.Add(marker); marker.CaptionElementType = TimedTextElementType.Text; marker.Style.ShowBackground = ShowBackground.WhenActive; marker.Style.BackgroundColor = Color.FromArgb(100, 0, 0, 0);
//use a semi-transparent background marker.Style.Color = Colors.White; //marker.Style.TextAlign = TextAlignment.Center; Length length = new Length { Unit = LengthUnit.Pixel, Value = 20 }; //must use this, since the default LengthUnit.Cell used
//at TimedTextStyle constructor is not supported marker.Style.FontSize = length; } Captions.Add(region); }
Γιατί παρατάθηκε η χρήση της εφαρμογής περιουσιολογίου στο Taxisnet
Πρόσφατα το Taxisnet έδωσε άτυπη παράταση χρήσης της εφαρμογής περιουσιολογίου για τον έλεγχο και διόρθωση (χωρίς πρόστιμο) των παλαιότερων δηλώσεων E9 (μεταβολών περιουσιακής κατάστασης) για τις ημερομηνίες 1-1-2009, 1-1-2010, 1-1-2011, που κανονικά έληγε τέλος Μαρτίου. Προφανώς όλοι μπήκαν τελευταία στιγμή στο σύστημα και “γονάτισε”. Τα μηνύματα σφάλματος πάντως που έδινε δεν ήταν καθόλου φιλικά στο χρήστη. Δύο παραδείγματα φαίνονται παρακάτω:
Internet Explorer 9 and Windows 7 taskbar previews, a broken story
Hello Microsoft, can you count? In the image above you can see the Windows 7 taskbar showing THREE (merged) icons/instances of Internet Explorer, although I only have ONE windows open (they seem to use multiple processes internally when you have many tabs, but why should the user care?). More importantly, in the popup shown when left-clicking the pinned Internet Explorer button, you can count 18 entries for open tabs, however in the Internet Explorer window there are many-many more open tabs.
This occurs both in Classic Windows theme and in Aero theme (using Windows 7 Ultimate – a courtesy of Microsoft to active testers of Windows 7 beta) and shows both when you see a list of titles (for many tabs) and when you’d see previews (shown when that bug makes it “THINK” you have few tabs – you might have lots more of course as shown above)
This brings to the surface the bad practice of some Microsoft teams on Microsoft Connect (former Product Feedback Center). They tend to close bug submissions very easily without checking who I the submitter (e.g. a current or former Microsoft MVP like me) and what is their past record of bug submission resolutions in all Microsoft products over the years.
I had submitted this issue in the past (sadly I currently can’t Connect to Microsoft Connect to locate it), only to see it soon closed as non reproducible without much effort to think why it might be happening (update: since I can’t find that feedback now that I made it to connect again – probably was together with some other tab-related feedback – I submitted it separately at https://connect.microsoft.com/IE/feedback/details/725397/ie9-bad-behaviour-with-multiple-tabs). For example, I believe IE chokes upon a frozen tab – e.g. one with some heavy JavaScript or Flash – and stops polling the other tabs for their title/preview etc., showing only some few as a result. Also it seems that counting IE processes as separate apps and merging them as three IE9 icons (when you only have one window with many tabs open) might play a role (might it be showing tab previews from only one of the IE9 processes?). Have they checked their source code if it is robust enough against such a scenario? Why do they feel they need to reproduce every bad software behavior reported first, instead of proactively act to be shielded against similar software behaviors?
Especially the many open tabs scenario that really makes IE9 crawl to its knees both in performance and usability, which is really sad given the effort Microsoft has spent on it. Not to speak of the many-many favorites (gathered over several years or from many synced machines – e.g via Windows Live Mesh) scenario and the very poorly designed, folder-based Favorites dialog which takes a long-long time to open up and has a miserable scrolling UI with no embedded Search filter.
Speaking of multiple tabs, in Mozilla Firefox you can set an option to remember tabs that were open at last application run so that you can shut down your PC and continue later. With IE9 only if it crashes it suggests to reopen previous tabs at next run, so unless you use the Add Current Tabs to Favorites (Folder) option of the very-very slow (if you have many favs like me) IE9 Favorites tab, you are forced to keep IE9 and your PC running if you want to checkout those multiple tabs you’ve opened, but don’t have the time to do it all in one go.
Can’t connect to Microsoft Connect
Ahem, Microsoft Connect says I can’t Connect (sign-in) to it for the moment. The Microsoft bug reporting site probably came upon some bug itself?
#LOL
TAXISnet – Internal Server Error
Πήγα και εγώ χθες στην εφορία μου κι έλαβα τον κλειδάριθμο για να πιστοποιήσω το λογαριασμό που είχα από παλιότερα (στο παλιό TAXISnet) – έδωσε και νέο password όπως μου ζήτησε και μπήκα να δώ τι καλούδια έχει.
Φαίνεται ενδιαφέρον (απ’ότι κατάλαβα πλέον τα βιβλία θα τα κρατάμε ΜΟΝΟ ηλεκτρονικά), αλλά έχει τα bug-άκια του ακόμη απ’ότι φαίνεται. Παραπάνω φαίνεται ένα “Error 500–Internal Server Error” στο νέο TAXISnet.
Mου χτύπησε όταν πήγα στο “Εφαρμογές φορολ. προφίλ” που σου δείχνει ποιές εφαρμογές υπάρχουν, σε ποιές έχεις πρόσβαση και σε αφήνει να πας σε αυτές από εκεί στα γρήγορα. Το πρόβλημα εμφανίστηκε όταν εκεί διάλεξα “Εφαρμογή Τελών και Ειδικών Φόρων” και πάτησα “Εύρεση” (γιατί άραγε να πρέπει να πατήσω καν το κουμπί και να μην αρκεί να διαλέξω στο dropdown list τι θέλω να δώ;)
Windows 7 Command Line Help mistake for IF command
If you type
help IF
at the Windows 7 command-line (can launch this by searching at Windows Start menu search box for “Command” or by typing cmd there and pressing ENTER), you get in one of the help pages printed out for the batch files’ IF command:
%ERRORLEVEL% will expand into a string representation of
the current value of ERRORLEVEL, provided that there is not already
an environment variable with the name ERRORLEVEL, in which case you
will get its value instead. After running a program, the following
illustrates ERRORLEVEL use:goto answer%ERRORLEVEL%
:answer0
echo Program had return code 0
:answer1
echo Program had return code 1
If a program you launched from the batch file returns error code 0 (meaning usually no error), then you jump to label (using “goto” command) answer%ERRORLEVEL% that is answer0 (labels are prefixed with : in DOS/Windows batch files) and it prints out (using echo command) on the console “Program had return code 0”.
Fine till here, but then it will proceed to next commands (the block labeled :answer1) and also print out “Program had return code 1”. Obviously the correct example should be:
goto answer%ERRORLEVEL%
:answer0
echo Program had return code 0
goto finish
:answer1
echo Program had return code 1
:finish
Could also have a goto finish after the last echo, but its needless since we don’t have :answer2 etc. labels after that and proceeds to finish by itself anyway.
Thinking of this example again, it’s a pretty silly one since one could do instead:
echo Program had return code %ERRORLEVEL%
BTW, to output an empty line to the console you can use echo:
And speaking of batch file tips, you can use :: for comment lines instead of REM command.
Η σελίδα σφάλματος του YouTube
500 Internal Server Error
Λυπούμαστε, κάτι δεν πήγε καλά.
Η διευθέτηση του ζητήματος έχει ανατεθεί σε μια άρτια εκπαιδευμένη ομάδα μαϊμούδων.
If you see them, show them this information:
IH6pYV6uW08aEw7RTmh2nctOCLKwYBoSQTT250UKk1Aq9OGTSu0MO16kB8kH IX8I1EZVDq2NHuva2SRpXGL6hG38xdffPCV3YBYJu8LVe1L9r7vz_fQrTavV aEsYIAILDGIATDB2OC78kZeqDUS9jeQzQqBiA6_Q7RDGkivkzT6XcaChvBAI TVWzwDPaNPJV8J7m2aqxgprbkCwzzcIfMD1toWoe4cbls7NqoBvCYAEsfZKD HlQ_3ylykRbFkJfi1HapcCFYJvnFB-6wyNYtgciyVuTEcieOHUq3-6zSAHk9 jzA1y2nndSZdSonvl5QTyCxWlrUzJR-ILxQuCmLI7iJgjl6r6rJCiR0G4ETR 4saaalM-MS2GGaikabqbENBLmtcerB5ZM37s-CgMgfbgxjTDb6__Te4_hveU H0mFIVTykRF3KkJKNTbKnXgzZ8l3OxU1KFiPL3Qsbnk5XADrMx1ThvgRWS-C wANkQ3C7EM0TDm0Xfwl4lVg2tE_eGmdktkmSzIpK3mnzZMUJ5TPhpchuoE_H kSIcV16f_p2phAfJsjbwKs11szwt_HLlEyeH1MUizpvNcrMh8qzDcd2H8siN mtkBjG0NrRjPyh2Cv8VIxfY__LpSJQ5J-V8t7ee9wFgmRrwL0MbzOopueiV_ SccnIpDai8vLFWAnAUr_AsNKKmHMd8BMEb2tiPinyoZUspbc1ad8cmn0_QUm EeXVbx0G3pSdnESz-5zD0gg2xCmtJg3xKIaYSF5rKAG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QaSFD8Me4uGM7tXbYt_RJUAhFb9O-xmHIrOHgWNhsh icxG8rAH-kkgycoDF5tYlv-4UTsQtkffgWGK8PltToYgDfSfL_b0ah42qg==
VB gotcha: when If function isn’t equivalent to an If-Then-Else block
Just got bitten by the following:
Dim takeN As Integer = If(Integer.TryParse(EdTake.Text, takeN), takeN, itemsCount)
I had used that instead of writing in 2 lines:
Dim takeN As Integer
If not Integer.TryParse(EdTake.Text, takeN) then takeN = itemsCount
However, there’s an important difference:
“If” is a function, so its arguments are evaluated at call-time. The “If” signature is:
I guess the default is to pass arguments ByVal (by value) and not ByRef (by reference), although I’d expect the signature to specify it explicitly to avoid confusion. When one passes a literal value (say 15) to TruePart or FalsePart it just gets “boxed” into an Object, whereas if one passes an expression (e.g. “takeN+1” or even just “takeN”) it gets evaluated first, then result is boxed and passed as an Object.
So, whereas one might think (esp. if coming from the ALGOL “Call-By-Name” era) the 1st line to be equivalent to:
Dim takeN As Integer
If Integer.TryParse(EdTake.Text, takeN) then takeN = [RESULT OF TRYPARSE] else takeN = itemsCount
in fact it’s equivalent to:
Dim takeN As Integer
If Integer.TryParse(EdTake.Text, takeN) then takeN = [ANY] else takeN = itemsCount
where ANY is whatever the takeN variable one had defined contains.
I thought the VB compiler was warning when using a variable before having assigned a value to it, but it seems in this case it misses to issue a warning. In fact I just tried:
Public ReadOnly Property Take As Integer
Get
Dim takeN As Integer
Return takeN
End Get
End Property
and it still doesn’t complain. Strange, probably it sets new local variables to 0 by default, but it shouldn’t encourage a programming style that relies on implicit default values – such syntax usually means there’s a mistake in the source code that can lead to a nasty bug.
The moral of the story? Avoid such shorthand expressions and stick to classic keyword-based syntactical structures – after all structured programming had been introduced as an alternative to the many times incomprehensible programs written in functional programming languages (e.g. due to overuse of nested function calls).