Archive
.NET WinForms splitter with normal/maximize/normal/shrink cycling action at double-click
The following code is from the application I authored for LeViS (see screenshot at that link). I had a vertical splitter (=splitting horizontally) and both left & right panes where split again with horizontal splitters (=splitting vertically) themselves and needed to double-click a splitter to make it cycle between normal/maximized/normal/shrunk state.
Java JFC/Swing’s JSplitter control can show two small button arrows (called accelerator buttons if I remember well) on the splitter that do the maximize/shrink/restore cycle actions, but didn’t find something similar for .NET WinForms, so I implemented the cycle via double-click (keeping at a local variable the current movement direction [a pendulum "cycle"])
So here’s the code I authored to make this work (the real worker is the "splitCycle" method near the end)
#Region "Splitter double-click"
Protected splitHorizontally_DoubleClickToUp As Boolean = False
Protected splitLeftVertically_DoubleClickToLeft As Boolean = False
Protected splitRightVertically_DoubleClickToLeft As Boolean = False
Private Sub splitHorizontal_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles splitHorizontally.MouseDoubleClick
splitCycle(splitHorizontally, splitHorizontally.ClientSize.Width, splitHorizontally_DoubleClickToUp)
End Sub
Private Sub splitLeftVertical_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles splitLeftVertically.MouseDoubleClick
splitCycle(splitLeftVertically, splitLeftVertically.ClientSize.Height, splitLeftVertically_DoubleClickToLeft)
End Sub
Private Sub splitRightVertically_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles splitRightVertically.MouseDoubleClick
splitCycle(splitRightVertically, splitRightVertically.ClientSize.Height, splitRightVertically_DoubleClickToLeft)
End Sub
Protected Const SPLITTER_MARGIN As Integer = 10 ‘need an accuracy margin >0 since the user can never move with the mouse the splitter exactly to its bounds
Private Sub splitCycle(ByVal splitter As SplitContainer, ByVal max As Integer, ByRef direction As Boolean)
With splitter
If .SplitterDistance <= .Panel1MinSize + SPLITTER_MARGIN Then
.SplitterDistance = CInt(max / 2)
direction = False
ElseIf .SplitterDistance >= max – .Panel2MinSize – .SplitterWidth – SPLITTER_MARGIN Then
.SplitterDistance = CInt(max / 2)
direction = True
ElseIf direction Then
.SplitterDistance = .Panel1MinSize
direction = False
Else
.SplitterDistance = max – .Panel2MinSize – .SplitterWidth
direction = True
End If
End With
End Sub
#End Region
Interprocess Communication (IPC) made easy
How about drag-dropping a control from a toolbox palette into your application or active document (say an Office PowerPoint presentation) and set it to hold some data (a string, a number, a date, an image, an array of data etc.) and give it a unique producer id (autogenerated UUID/GUIDs included which are statistically unique numbers), allowing it to propagate (produce/broadcast) or receive (consume/listen) changed data cross-application and cross-machine boundaries?
Checkout "Plugs" at:
Originated as Delphi VCL controls (StringPlug, IntegerPlug, ImagePlug etc.), some later on available as ActiveX controls too (e.g. StringPlugX – more datatypes easily supported upon request)
Insert MPEG-4 video, QuickTime movies and QTVR panoramas in PowerPoint presentations
To insert MPEG-4 video, QuickTime movies and QTVR panoramas in PowerPoint presentations, you can use QTVRControlX ActiveX control, see:
Unregistered version is free to use for as long as you like (but you’re not allowed to redistribute it) if you don’t mind the "Unregistered version" popup dialog when it starts up.
Dr ASCII
my Java-based interactive game (Greek page, but the game itself is pretty much language-agnostic) to learn about bitmap fonts and the ASCII code table:
Updated my MVP Profile
you can see my updated Microsoft MVP profile (Visual Developer – J# for 2004-2007) at:
Converting a VB6 form to an ASP.net WebForm
See my opensource VB6toWebForm tool at http://tranXform.onestop.net
It converts a VB6 form’s design to XML (eXtended Markup Language) via my VB6FormDesignToXML tool that you can also find on that site, and then via XSL (eXtended Stylesheet Transformations) it converts that XML into ASP.net 1.x WebForm pages (using classic vertical flow layout based on the tab-order from the VB6 form and making sure labels that have been assigned to edit controls stay on the same line as those controls)
If you use ASP.net 2.x, VS.net has a nice import wizard (which won’t convert the coding style of those 1.x pages [e.g. the usage of a single codebehind file without using a partial class - a concept that .NET1.x didn't support], but will tweak them to work fine with ASP.net 2.x)
If you add to the XSL transformations files logic to handle more VB6 controls, please consider contributing your enhancements to the tranXform project
BTW, more free XML related utilities are on that website
Mac OS X Leopard test period is over
Speaking of Apple, the new Mac OS X version is out. Checkout their developer center for more:
http://developer.apple.com/leopard/devcenter/
Did you know Microsoft Silverlight (a novel RIA [=Rich Internet Application] platform) is available for Mac OS X too? See for yourself at:
at last: iTunes Developer Center from Apple
for all iTunes wanna-be web application authors out there:
http://developer.apple.com/iphone/devcenter/
it’s good that Apple finally decided to promote third-party development for iPhone
hope some time in the future they’ll even allow Java and why not Silverlight apps for iPhone (Microsoft has made Silverlight available for MacOS-X too [with .NET programming support at Silverlight 1.1 version!] and the "project mono" guys from Novell and their opensource community are making "MoonLight" for Linux with support from MS)
Cross-platform JavaScript for webpages
very useful reading:
http://developer.mozilla.org/en/docs/Migrate_apps_from_Internet_Explorer_to_Mozilla