SpriteHand
Module Border
  Most recent blog entries
Module Border
ResizeBehavior for Atlas
Andy's Blog By Andy Beaulieu on 3/25/2006 10:15 AM

IMPORTANT NOTE: Since the writing of this blog entry, the latest Atlas CTP now includes its own Resize Behavior and Extender! Details and Demo here.

Try It!

If you have played with Microsoft Atlas behaviors,  you might have come across the cool floatingBehavior which allows you to drag and drop web page elements around the screen.

Well, it's also possible to create your own behaviors, and while the documentation on this is pretty much nonexistant, there are two great blog entries here  and here on the subject.

So I thought, floatingBehavior is cool, but what if you could resize elements as well (like a little virtual window)? Thus was born my first Atlas Behavior, resizingBehavior!

Using ResizeBehavior
To add resizing behavior to an element, assuming you have already installed Atlas and created a new Atlas template project... First add ResizeBehavior.js (source at the end of this article) to your Script Manager...

    <atlas:ScriptManager ID="sm" runat="server">

        <Scripts>

            <atlas:ScriptReference ScriptName="AtlasUIDragDrop" />

            <atlas:ScriptReference Path="ScriptLibrary/ResizeBehavior.js" />

        Scripts>

    atlas:ScriptManager>

... next you need to assign the resizeBehavior properties in the XML Config section of your Atlas page...
      resizeControlId should be assigned to the element you want resized
      resizeObjectId should be assigned to the element that controls the resize
      minWidth, minHeight control the minimum resize size
      arrowThreshold allows you to control the sensitivity of resizeObjectId

    <script type="text/xml-script">

       

           

               

                   

                        resizeControlID="resizeTest" resizeObjectID="resizeHandle" minWidth="200" minHeight="100" arrowThreshold="20" />

                       

                   

               

           

       

    script>

ResizeBehavior.js

Type.registerNamespace('SpriteHand.UI');

 

SpriteHand.UI.ResizeBehavior = function() {

    SpriteHand.UI.ResizeBehavior.initializeBase(this);

 

    // Private fields.

    var _resizeControlHandler;

    var _mousedownHandler;

    var _mouseupHandler;

    var _mousemoveHandler;

    var _resizeControlID;          // control that is being resized

    var _resizeControl;

    var _popupBehavior;

    var _mouseIsDown = false;

    var _thresholdArrows = 20;

    var _thresholdMinWidth = 60;

    var _thresholdMinHeight = 40;

    var _isResizing = false;

    var _resizeObjectID;            // control that is used as the resize handle

    var _resizeObject;

 

    var _dragEndHandler;

 

 

    // Properties.

    this.get_resizeControlID = function() {

        return _resizeControlID;

    }

    this.set_resizeControlID = function(value) {

        if(value != _resizeControlID) {

            _resizeControlID = value;

            this.raisePropertyChanged('resizeControlID');

        }

    }

 

    this.get_resizeObjectID = function() {

        return _resizeObjectID;

    }

    this.set_resizeObjectID = function(value) {

        if(value != _resizeObjectID) {

            _resizeObjectID = value;

            this.raisePropertyChanged('resizeObjectID');

        }

    }

 

    this.get_minWidth = function() {

        return _thresholdMinWidth;

    }

    this.set_minWidth = function(value) {

        if(value != _thresholdMinWidth) {

            _thresholdMinWidth = value;

            this.raisePropertyChanged('minWidth');

        }

    }

 

    this.get_minHeight = function() {

        return _thresholdMinHeight;

    }

    this.set_minHeight = function(value) {

        if(value != _thresholdMinHeight) {

            _thresholdMinHeight = value;

            this.raisePropertyChanged('minHeight');

        }

    }

 

    this.get_arrowThreshold = function() {

        return _thresholdArrows;

    }

    this.set_arrowThreshold = function(value) {

        if(value != _thresholdArrows) {

            _thresholdArrows = value;

            this.raisePropertyChanged('arrowThreshold');

        }

    }

 

    // Events.

    this.resizeControlShow = this.createEvent();

 

    // Initialize / Dispose

    this.initialize = function() {

        SpriteHand.UI.ResizeBehavior.callBaseMethod(this, 'initialize');

        _resizeControl = new Sys.UI.Control($(_resizeControlID));

        _resizeObject = new Sys.UI.Control($(_resizeObjectID));

 

        _resizeControl.initialize();

 

        var bounds = Sys.UI.Control.getBounds(_resizeControl.element);

 

        _mousemoveHandler = Function.createDelegate(this, mousemoveHandler);

        document.attachEvent('onmousemove', _mousemoveHandler);

 

        _mousedownHandler = Function.createDelegate(this, mousedownHandler);

        document.attachEvent('onmousedown', _mousedownHandler);

 

        _mouseupHandler = Function.createDelegate(this, mouseupHandler);

        document.attachEvent('onmouseup', _mouseupHandler);

 

        // wire up dragend event with drag handler

        _dragEndHandler = Function.createDelegate(this, dragEndHandler);

        _resizeControl.element.attachEvent("ondragend", _dragEndHandler);

 

        // disable text selection (ie only)

        document.onselectstart = function() {return false;}

 

 

    }

 

    this.dispose = function() {

        SpriteHand.UI.ResizeBehavior.callBaseMethod(this, 'dispose');

 

        document.detachEvent('onmousedown', _mousedownHandler);

        document.detachEvent('onmouseup', _mouseupHandler);

        document.detachEvent('onmousemove', _mousemoveHandler);

 

        _mousemoveHandler = null;

        _mousedownHandler = null;

        _mouseupHandler = null;

    }

 

    // Handlers.

    function dragEndHandler() {

        window.status="dragEndHandler";

        _mouseIsDown = false

        _isResizing = false;

    }

 

    function mousedownHandler() {

        _mouseIsDown = true;

    }

 

    function mouseupHandler() {

        _mouseIsDown = false

        _isResizing = true;

    }

 

    function mousemoveHandler() {

        window.status="";

 

        var boundsDragHandle = Sys.UI.Control.getBounds(_resizeObject.element);

        var bounds = Sys.UI.Control.getBounds(_resizeControl.element);

 

        var x = window.event.clientX;

        var y = window.event.clientY;

 

        if (!_mouseIsDown) {

            // check for resize east

            if( (x >= (boundsDragHandle.x - _thresholdArrows) && x <= (boundsDragHandle.x + boundsDragHandle.width + _thresholdArrows)) &&

                (y >= (boundsDragHandle.y - _thresholdArrows) && y <= (boundsDragHandle.y + boundsDragHandle.height + _thresholdArrows))) {

                _resizeControl.element.style.cursor="se-resize";

                _isResizing = true;

                window.status="click and drag to resize southeast";

 

            } else {

                _resizeControl.element.style.cursor="auto";

            }

        }       

        if (_mouseIsDown && _isResizing) {

 

            newWidth = (x + _resizeObject.element.style.width) - bounds.x;

            if (newWidth > _thresholdMinWidth) _resizeControl.element.style.width = newWidth + "px";

 

            newHeight = (y + _resizeObject.element.style.height) - bounds.y;

            if (newHeight > _thresholdMinHeight) _resizeControl.element.style.height = newHeight + "px";

        }

 

 

    }

 

    // Public methods.

 

    // getDescriptor.

    this.getDescriptor = function() {

        var td = SpriteHand.UI.ResizeBehavior.callBaseMethod(this, 'getDescriptor');

 

        td.addProperty('resizeControlID', String);

        td.addProperty('resizeObjectID', String);

        td.addProperty('minWidth', Number);

        td.addProperty('minHeight', Number);

        td.addProperty('arrowThreshold', Number);

 

        return td;

    }

}

SpriteHand.UI.ResizeBehavior.registerClass('SpriteHand.UI.ResizeBehavior', Sys.UI.Behavior);

Sys.TypeDescriptor.addType('script', 'resizeBehavior', SpriteHand.UI.ResizeBehavior);

Comments (9)

SQL 2000 SECDoClientHandshake
Andy's Blog By Andy Beaulieu on 3/16/2006 4:30 PM

I had installed a CTP version of SQL2005 on my notebook, followed by the RTM... alongside a SQL2000 installation. Somewhere along the line, I could not longer connect to my SQL2000 installation (was it the SQL2005 installs? Can't say for sure). The error I got was:

SSL Security error :ConnectionOpen (SECDoClientHandshake())

So after poking around, I found this article, which descries the bug and leads you through deleting your certificates. It worked great, except in my case the Certificate was under "Current User" so note that the steps in the fix lead you through "local computer"

Comments (0)

DNN4 and SOLPARTMENU
Andy's Blog By Andy Beaulieu on 3/13/2006 7:27 AM

I have been porting a couple of sites over to Dotnetnuke 4 and came across a problem in my older skins... the CSS class for the active tabs in the Menu were not being applied. Turns out you need to apply the "rootmenuitemactivecssclass" attribute as shown below (for an ascx skin implementation):

<dnn:SOLPARTMENU runat="server" id="dnnSOLPARTMENU" usearrows="false" userootbreadcrumbarrow="false" rootmenuitemactivecssclass="MainMenu_MenuItemSel" />

Comments (0)

Susan Wisowaty visits CNY Developers
Andy's Blog By Andy Beaulieu on 3/9/2006 6:38 PM
We were all happy to have Susan Wisowaty come and present at our CNY .NET Developer Group! Susan is our new DCC for this area, and did a great job presenting a nice ASP.NET 2.0 Overview. The room was quite packed (normally we can have 2X capacity but were in a smaller room), and Susan had just one "vpc-related" (*wink*) crash. Great swag too - Ajax T-shirts from Dart, JetBrains licenses, MS Press Books, and Event DVD's. Thanks Susan!!!
Comments (1)

GridView DataFormatString
Andy's Blog By Andy Beaulieu on 1/26/2006 10:46 AM
Here's some fun with the ASP.NET 2.0 GridView... I'm generally more of a templated column kinda guy, but I was feeling lazy and tried to format a BoundColumn as Currency using

DataFormatString="{0:c}"


 ... simple enough, right? Then why doesn't it work?! Turns out you have to set the HtmlEncode attribute to False in order for the DataFormatString to take...
 

<asp:BoundField DataField="Amount" HeaderText="Amount" ReadOnly="True" SortExpression="Amount" DataFormatString="{0:c}" HtmlEncode="False" />

Comments (2)

DAL Generation and ORM tools
Andy's Blog By Andy Beaulieu on 1/26/2006 10:23 AM
I am trying to compile a list of Data Access Layer code generators and ORM mapping tools...
 
 
 
 
 
... and I found an OR Tool comparison for several here -
Comments (1)

ReportViewer control - programmatically
Andy's Blog By Andy Beaulieu on 1/26/2006 9:08 AM
In VS2005, the report designer is great for quickly throwing together a report and binding it to an ObjectDataSource... but what if you want to do this through code for more control?
 
The steps are to create the report _without_ using a TableAdapter, and then manually create the data source through code (below). Note that the "rds.Name" property must be set to the "DataSetName" attribute in the report's RSDL file:
         <DataSetName>DSCustomers_OutCustomersDataSetName>

Dim dsCustomers As DSCustomers
Dim oCustomers As New CCustomers()

dsCustomers = oCustomers.GetCustomers()
Dim rds As ReportDataSource = New ReportDataSource
ReportViewer1.LocalReport.DataSources.Clear()
rds.Name =
"DSCustomers_OutCustomers"
rds.Value = dsCustomers.OutCustomers
ReportViewer1.LocalReport.DataSources.Add(rds)
ReportViewer1.DataBind()


As a second example, let's say you use a Typed DataSet and TableAdapter as a Data Source and you are creating a WindowsForms application. In the example below, a Typed DataSet has been created called "DataSet1" which queries the Customers table.

Some important things to remember:

  • you need to call  the Reset() method on the ReportViewer whenever you dynamically switch reports.
  • you need to prefix report (RDLC) filenames with the Namespace of the project the report is in (below the namespace is "ReportViewerTest.")

reportViewer1.Reset();

DataSet1TableAdapters.CustomersTableAdapter ta1 = new DataSet1TableAdapters.CustomersTableAdapter();

DataSet1.CustomersDataTable dt1 = new DataSet1.CustomersDataTable();

ta1.Fill(dt1);

 

ReportDataSource rds = new ReportDataSource();

reportViewer1.LocalReport.DataSources.Clear();

reportViewer1.LocalReport.ReportEmbeddedResource = "ReportViewerTest.Report1.rdlc";

rds.Name = "DataSet1_Customers";

rds.Value = dt1;

reportViewer1.LocalReport.DataSources.Add(rds);

reportViewer1.RefreshReport();

 

 

 

Comments (1)

COM+ and MSDTC hosed
Andy's Blog By Andy Beaulieu on 1/23/2006 11:18 AM
The last couple of weeks have presented some freaky problems on my end. I had a development workstation that had a hosed COM+ install (when you try to navigate to COM+/My Computer/COM+ Applications it would give an error like "An error occured while processing the last operation.  Error code 80080005 -
Server execution failed."
 
After many attempts at re-installing stuff, this seemed to work for me:
 
(1) follow steps in KB315296 Clean up damaged COM+ catalog
http://support.microsoft.com/?id=315296

(2) reinstall MSDTC
     cd %systemroot%\system32
     msdtc -uninstall
     msdtc -install
Comments (0)

Frustrating VS2005 bug
Andy's Blog By Andy Beaulieu on 1/16/2006 8:11 PM
I got caught with this bug back when I was playing with betas long ago... But it recently bit me again on a fresh machine with RTM VS2005 (no betas or RC's installed prior)...
 
When in the editor, the carriage return, delete, backspace and Edit/Cut/Copy/Paste stop functioning. Something about the toolbox windows getting focus hosed up I guess... Anyway, after trying a bunch of IDE Resets and User Settings Import/Export, this finally did it for me... Had to delete default.vsk from Docs and Settings, as this article details:
 
Comments (0)

Mimicking a Data Repeater Control in WinForms
Andy's Blog By Andy Beaulieu on 1/4/2006 8:03 PM
VB6 had the cool Data Repeater which allowed you to create an ActiveX control and databind it so that it would show an instance of the user control for each row in your record set.
 
This cool control is missing from .NET, but it's pretty easy to mimick this functionality. Just create a Panel, set its AutoScroll property to True, and use the Controls collection to dynamically add instances of the user control. You will need to also track the Y Offset of each control you add to push down each instance.
 

Dim m_YOffSet As Integer = 0

Public Sub AddAddress(ByVal AddressId As Integer)
    Dim ucAddress1 As New ucAddress
    ucAddress1.Address = "123 University Lane"
    Panel1.Controls.Add(ucAddress1)
    ucAddress1.Visible = True
    ucAddress1.Top = m_YOffSet
    m_YOffSet += ucAddress1.Height
End Sub

Comments (0)

Module Border Module Border
Module Border
  Blog_List
Module Border
Module Border Module Border
Module Border
  Subscribe
Module Border

RSS

Module Border Module Border
Module Border
  Diversions
Module Border

DESTROY ALL INVADERS
A scrolling shooter game where the objective is to destroy the invading UFO's flying over a neighborhood of your choosing. Imagery provided by Microsoft Virtual Earth. Created using Silverlight 2.
PLAY IT

INFO AND CODE



SORT THE FOOBARS
A game where you need to sort the good foobars from the bad ones. Created using Silverlight 2 and the Farseer Physics engine.
PLAY IT

MORE INFO



POLYGON PHYSICS DEMO
A demo showing polygon physics where the user draws physics objects with the mouse. Created using Silverlight 2 and the Farseer Physics engine.
PLAY IT

MORE INFO



SILVERLIGHT ROCKS!
Destroy the asteroids before they destroy your ship! Created using Silverlight 2.
PLAY IT

INFO AND CODE



FISH GAME
A simple game of harpoon-the-fish. Written using the AJAX Sprite Toolkit.
PLAY IT

INFO AND CODE

Module Border Module Border
Module Border
  Search_Blog
Module Border
Module Border Module Border
Module Border
  Blog_Archive
Module Border
Module Border Module Border
Copyright (c) 2008 andy.beaulieu.com - Login