Building ClickOnce with CruiseControl.Net

14. May 2009

I was configuring automated builds with CruiseControl.Net which went relatively good until publishing ClickOnce applications. Since I didn’t have Visual Studio installed on the development machine, I was getting the error:

error MSB3147: Could not find required file 'setup.bin' in 'ProjectFolder\Engine'

After searching for the answer for hours online, this article showed me the solution. It was in with some other office building stuff, so I am going to highlight the actual ClickOnce steps.

  1. Copy the bootstrapper files from Visual Studio to the same directory on the build server ‘Program Files\Microsoft SDKs\Windows\v6.0a\Bootstrapper’
  2. Create a registry setting to point to the location:
    Key: HKEY_LOCAL_MACHINE\Software\Microsoft\GenericBootstrapper\3.5\
    Value: Path
    Type: REG_SZ
    Data: C:\Program Files\Microsoft SDKs\Windows\v6.0a\Bootstrapper\

 

Hope this helps. Thank you Rinat Abdullin for the solution.



Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

CruiseControl.Net ,

Silverlight Zooming and Panning a Canvas

12. May 2009

Zooming and Panning seems to be in great demand for Silverlight projects. I myself searched around through numerous articles trying to figure out good ways to do it. I came up with a solution that hopefully can satisfy some of the demand here on the internets.

First thing I did was make a control that is the zooming and panning canvas. I called it DesignRender as it applied to the particular project I was developing.

<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    x:Class="SilverlightApplication2.DesignRender">
    
    <ScrollViewer x:Name="scrollRoot" VerticalScrollBarVisibility="Disabled" 
                  HorizontalScrollBarVisibility="Disabled">
        <Canvas x:Name="canvasRoot">
            <Canvas Background="#FF00FBF2" x:Name="canvasContainer"
                    Width="1000" Height="800">
                <!-- This is dummy stuff for zooming/panning -->
                <Rectangle Width="90" Height="90" Fill="#FFCA1F1F"
                           Canvas.Left="0" Canvas.Top="0" 
                           RadiusX="2" RadiusY="2" />
                <Canvas.RenderTransform>
                    <ScaleTransform x:Name="scaler" 
                                    CenterX="0" CenterY="0" 
                                    ScaleX="1" ScaleY="1" />
                </Canvas.RenderTransform>
            </Canvas>
        </Canvas>
    </ScrollViewer>
</UserControl>

I am using a scrollviewer so I can place the UserControl effectively in a parent control. You can change this as desired. The canvasRoot acts as your background and the canvasContainer is the actual content residing in your background. If this was photoshop, the canvasRoot would be the greyed out background and the canvasContainer would be your actual document. Hence the static sizing of the canvasContainer. Now for the code behind.

public partial class DesignRender : UserControl
{
    private bool isDragging = false;
    private Point offset;
    
    public DesignRender()
    {
        InitializeComponent();

        // Handle the mouse click events within the control
        // for panning.
        this.canvasContainer.MouseLeftButtonUp += 
            new MouseButtonEventHandler(canvasContainer_MouseLeftButtonUp);
        this.canvasContainer.MouseLeftButtonDown +=
            new MouseButtonEventHandler(canvasContainer_MouseLeftButtonDown);
        this.canvasContainer.MouseMove += 
            new MouseEventHandler(canvasContainer_MouseMove);
        
        // Handle the scroll wheel events. They are different
        // per browser so we have to attach to a couple of events.     
        HtmlPage.Window.AttachEvent("DOMMouseScroll", OnMouseWheel);
        HtmlPage.Window.AttachEvent("onmousewheel", OnMouseWheel);
        HtmlPage.Document.AttachEvent("onmousewheel", OnMouseWheel);
    }

    /// <summary>
    /// Called when the mouse wheel is used. Zooms
    /// in our out depending.
    /// </summary>
    private void OnMouseWheel(object sender, HtmlEventArgs e)
    {
        double mouseDelta = 0;
        ScriptObject obj = e.EventObject;
        
        // Get what the mouseDelta was in
        // the particular browser being used
        if (obj.GetProperty("detail") != null)
            mouseDelta = ((double)obj.GetProperty("detail"));
        else if (obj.GetProperty("wheelDelta") != null)
            mouseDelta = ((double)obj.GetProperty("wheelDelta"));
        
        // Quick mouse translation
        mouseDelta = Math.Sign(mouseDelta);

        // calculate the new scale for the canvas
        double newScale = this.scaler.ScaleX + (mouseDelta * .25);

        // Don't allow scrolling too big or small
        if (newScale < 0.25)
            return;
        if (newScale > 10)
            return;

        // Set the zoom!
        this.scaler.ScaleX = newScale;
        this.scaler.ScaleY = newScale;
    }
    
    /// <summary>
    /// Called when user presses mouse down. Start
    /// panning.
    /// </summary>
    private void canvasContainer_MouseLeftButtonDown(
        object sender, MouseButtonEventArgs e)
    {
        // Say we are dragging
        this.isDragging = true;
        this.canvasContainer.CaptureMouse();
        // Calculate the place where they clicked
        offset = e.GetPosition(this.canvasContainer);
        offset.X *= this.scaler.ScaleX;offset.Y *= this.scaler.ScaleY;
    }
    
    /// <summary>
    /// Called when user releases mouse. End panning
    /// </summary>
    private void canvasContainer_MouseLeftButtonUp(
        object sender, MouseButtonEventArgs e)
    {
        if (this.isDragging)
        {
            // Say we are done dragging
            this.isDragging = false;
            this.canvasContainer.ReleaseMouseCapture();
        }
    }
    
    /// <summary>
    /// Called when the user moves there mouse. If
    /// they have the mouse button pressed then we
    /// pan.
    /// </summary>
    private void canvasContainer_MouseMove(
        object sender, MouseEventArgs e)
    {
        if (this.isDragging)
        {
            // Calculate the new drag distance
            Point newPosition = e.GetPosition(this.canvasRoot);
            Point newPoint = 
                new Point(newPosition.X - offset.X,newPosition.Y - offset.Y);
            
            // Set the values
            this.canvasContainer.SetValue(Canvas.LeftProperty,newPoint.X);
            this.canvasContainer.SetValue(Canvas.TopProperty,newPoint.Y);
        }
    }
}

The code itself should be pretty self explanatory. I use scaling to do the zooming and mouse down events for panning. Now just host this control in your Page.xaml whatever way you would like. This should get everyone started in the right direction. Hope this helps.



Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

C#, Silverlight , , ,

Error performing inpage operation

2. May 2009

I have an external harddrive to which I thought I lost all of the information on. Whenever I plugged it in, the light would come on like it was going to read and then turn back off again. Whenever I tried to access the volume, I would get an error message saying “Error performing inpage operation.” After looking extensively online, I ran

chkdsk l: /f 
substitute l: for your volume label

It repaired the drive and works great. Off to buy another terabyte hdd for backups. Hope this can be useful for someone.



Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5