SpriteHand
Module Border
  Andy's Blog
Module Border
Author: host Created: 3/6/2006 9:55 PM
Adventures in .NET

Deploying ReportViewer Control
By Andy Beaulieu on 5/19/2006 4:07 PM

So you've created a cool new WindowsForms Smart Client Application that uses the ReportViewer control, and it's time to deploy it. There is an article here that explains how to use the ReportViewer.exe redistributable.

But what if you don't want to distribute that funky ReportViewer.exe? Maybe you just want to throw the files on a PC and let a prototype tester have at it?   

Sure, you can do that - first snag these two files from C:\Program Files\Microsoft Visual Studio 8\ReportViewer

Microsoft.ReportViewer.Common.dll
Microsoft.ReportViewer.WinForms.dll

And now the tricky part, you need to snag Microsoft.ReportViewer.ProcessingObjectModel.dll from the GAC. It will be located in a directory something like C:\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.ProcessingObjectModel\8.0.0.
0__b03f5f7f11d50a3a

...but remember, you'll need to use the Command Line to get at this file, because of the cool Explorer add-in for the GAC.

Put the three ReportViewer assemblies in your app's BIN folder and you should be good to go!

Comments (8)

Groovy, Shadowy Tooltips
By Andy Beaulieu on 5/18/2006 12:30 AM

With all the neat-o AJAX and Atlas sites showing up, one of the recurring things I've noticed is groovy, shadowy tooltips. What am I talking about? If you haven't tried Netflix yet, at least visit their site and try hovering over a movie image. You'll see a nice popup flash up with title details. I really like the shadows that show up around this popup, it really adds a professional touch.

So how is this done? Well, it should be possible to use PNG images to define an alpha channel that supports transparency. Most browsers except Internet Explorer support this. But in order to support the most browsers, you have to use a klugey method that uses an AlphaImageLoader Filter in IE. I'll show some code that implements this kluge, but first let's look at how we can create a PNG file that has this nice alpha channel...

I'll be using Paint.NET because it's free and it does a fine job of managing layers and transparency for PNG's!

(1) Create a new image by selecting File/New. Be sure to input your desired height and width.

(2) Set the image background to transparent by selecting Layers/Layer Properties and setting the Opacity to 0.

(3) In this step we will create the shadow layer
Select Layers/Add New Layer. Select the “Draw filled shape with outline” option button on the toolbar.

(4) Set both the foreground and background colors to a dark gray

 

(5) Draw out a rectangle (or other shape) for the background shadow.

 

 (6) Next, blur the shadow by selecting Effects/Blurs/Gaussian. Note how the “shadow” gets blurred out!

(7) Next, we add the “real object” that is casting the shadow. Overlay another rectangle or other object that is casting the shadow.

That's it! We now have a nice PNG file that can implement alpha transparency. But in order to get this to work cross-browser, we need to do a couple of dirty, kludgey things.

First, we need to have a "bogus proxy image" that is at least 1x1 pixel and completely transparent. You can create a 1x1 GIF image that is completely transparent, that will work fine. Let's call that image bogusPixel.gif.

Next, we need some javascript that will figure out if we are in IE and need to apply an AlphaImageLoader filter. This is because IE doesn't really support alpha channel PNG's, but has a filter that does support them.

<script language="javascript">
   
var bInitialized;
    function showImg(id) {
        var img = document.getElementById(id);
        img.style.visibility=
'visible';
        if (navigator.appVersion.indexOf("MSIE")>-1) {
            if (!bInitialized) {
                bInitialized =
true;
                img.style.width = img.width;
                img.style.height = img.height;
                img.style.filter =
"progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod='scale', src='" + img.src + "')";
                img.src =
"images/bogusPixel.gif";
            }
        }
    }

    function hideImg(id) {
        document.getElementById(id).style.visibility=
'hidden';
    }

script>

And FINALLY we can implement our little tooltip!

<img id="imgBalloonTip" src="images/Balloon.png" style="visibility:hidden">

<div style="width:50px; border:solid 2px Black;" onmouseover="showImg('imgBalloonTip');" onmouseout="hideImg('imgBalloonTip');">
   
Try Me
div>



And that's about it. So to give this a try, hover over the "Try This" div below and you'll see a groovy shadowy popup:
Try Me
Comments (0)

CNY Developers "Chalk Talk" Session
By Andy Beaulieu on 4/5/2006 4:22 PM

Sam Gentile was quite distressed when he had an emergency come up and had to cancel his presentation at our local CNY .NET Developer Group. Luckily, everyone is OK and we held an open "Chalk Talk" type session in lieu of Sam's presentation.

Here are a few notes from the presentation -

System.Convert vs. Parse
A question came up about when to use the System.Convert methods over the "Parse" methods for type conversion. As it turns out, the System.Convert methods will internally call the "Parse" methods for the desired type. However, the Parse methods will throw a ArgumentNullException if a Null parameter is passed...

double value;
string text = null;
// internally, Convert.To* will just call Parse methods for given type..
value = System.Convert.ToDouble(text);
// but Parse will throw an ArgumentNullException for Nulls...
value = double.Parse(text);

So then, what about all of those nifty VB.NET CType, CDbl, CInt, etc. conversion methods? Well, there is a good article here that goes on to explain that the VB.NET compiler is cool enough to optimize the MSIL spit out for those. And in fact, it is recommended to use these conversion methods (this was surprising really, because these conversion methods are mostly considered legacy type functions).

Atlas and Ajax
I also spent some time going over Atlas and Ajax demos showing a simple web service call, AutoComplete Behaviors, and the Resize Behavior I created. I hope to have time to refine this into a full presentation to give later on in the year!

Here are some links for the Atlas/Ajax stuff:
    Fiddler tool - great for analyzing ajax traffic
    Ajax .NET - stable, widely used ajax library for ASP.NET
    Atlas home - download and start playing!

Some Links from Greg
Greg Smalter also provided some great relative links:

      Using Atlas without ASP.NET shows using PHP with Atlas
      How-to Video on ASP.NET Validation Controls

Comments (0)

ResizeBehavior for Atlas
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
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
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
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
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
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
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)

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



HOOK SHOT
This little basketball game was submitted as an entry to the TeamZoneSports Silverlight Contest. Created using Silverlight 2 and the Farseer Physics engine.
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