silverlight control size - silverlight

The control that I have built is of size 30x30. however, when the control is rendered, it takes up most of the space on the browser? Why is that so?
Any way to reduce the size to what is desired?
Thanks!

Look at your object tag's width and height attributes.
<object width="300" height="300"
data="data:application/x-silverlight-2,"
type="application/x-silverlight-2" >
<param name="source" value="..."/>
</object>

Related

prevent reloading of object tag on changing its display (style's display property)

I have embedded silverlight control in my html page using object tag. I have to show and hide the parent of object tag by changing the display property of the parent tag. I need to do this because the layout of the page is tabbed, i.e. user can switch between tabs. Showing a tab requires to hide the content of previous tab and show the new content.
Below is the object tag code:
<div id="slControlDiv" style="width:0px; height:0px;">
<object id="slobj" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100" height="25" style="display: block;">
<param name="source" value="ILCFileUploader.xap"/>
<param name="onError" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="4.0.50826.0" />
<param name="autoUpgrade" value="true" />
</object>
When I hide the parent of object tag, i.e change the display to none and then show it back by changing display to block or empty, silverlight control reloads.
Is there anyway to prevent its reloading? I have tried changing visibility to collapse and then to visible, but this works only in IE8 and Firefox. In other browsers the element still keeps occupying the space, although it is hidden. I want the control to release the space as well when it is hidden.
Thanks & regards,
Nadeem Ullah
I found that setting "visibility=hidden|show" of a containing element (eg a div) allowed hiding|showing the contained object element without it reloading when re-shown. Using the "offsets" method also works (absolutely positioning it out of the visible area of the document).

implement imapbuilder in cakephp

I have created a web page using cakephp. Now I feel like my boring map on the main page is killing it. I bought imapbuilder which lets you do flash effects on images, however I don't seem to be able to get the code working.
Here is the code I pasted in my home page, but it won't load. All I see is a blank square.
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0"
width="800" height="747" align="middle">
<param name="allowScriptAccess" value="always" />
<param name="movie" value="imapbuilder/loader.swf" />
<param name="base" value="imapbuilder/" />
<param name="flashvars" value="datasource=urlife_map.xml" />
<param name="loop" value="false" />
<param name="menu" value="true" />
<param name="quality" value="best" />
<param name="wmode" value="transparent" />
<param name="bgcolor" value="#ffffff" />
<embed src="imapbuilder/loader.swf" base="imapbuilder/" flashvars="datasource=urlife_map.xml" loop="false" menu="true" quality="best" wmode="transparent" bgcolor="#ffffff" width="800" height="747" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
</object>
This same code I pasted into a separate file and it worked. I kept the folder imapbuilder on the same directory as the home page file.
Does anyone have an idea why this won't load and work on my website?
Files can only be accessed if they are located inside the webroot directory of your app using a standard CakePHP setup.
I suggest you move the imapbuilder folder to the webroot folder and also append all references to it with a / (e.g. /imapbuilder/loader.swf instead of just imapbuilder/loader.swf).
I think an easier solution for you is to use iMapBuilder.net -- which is the online version of iMapbuilder. The map will then be remotely hosted on their server, and all you need to do is copy and paste their code so that no file copying / directory issues.
I have used imapbuilder.net on few CMS based sites, e.g. dotnetnuke and wordpress. And the online based map solution is a lot easier than their Windows version, at least for CMS based sites.

Embedding Flash on Master Page

My client request a flash header for his website. I'm using asp.net and a master page (where the code for the flash header is). My problem is that whenever I go to a page that's not in the website's root, the flash doesn't appear. I've had the same issue with pure css menus on this site...
Here's the code:
<div id="header">
<!--[if !IE]> -->
<object type="application/x-shockwave-flash"
data="App_Themes/Default/banner1.swf" width="1000" height="400">
<!-- <![endif]-->
<!--[if IE]>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
width="1000" height="400">
<param name="movie" value="App_Themes/Default/banner1.swf" />
<embed src="App_Themes/Default/banner1.swf" width="1000" height="400"></embed>
<!--><!--dgx-->
<param name="loop" value="true" />
<param name="menu" value="false" />
<p></p>
</object>
<!-- <![endif]-->
</div>
As you can see, I'm not calling the path to the flash object relative to the website root (in case this isn't clear... if it were an asp.net control, I'd use ~/App_Themes/Default/banner1.swf")
The flash object is being loaded relative to the location of the current page that's being viewed on the website. Assuming an indeterminate folder depth from root, how can I change the code to load the flash relative to the root, rather than the current page?
I have considered changing the path that's being used by perpending / or ~/ to it, but this only results in the flash not loading on any page at all.
Looking at the source code, the server modifies /App_Themes/Default/banner1.swf to ~/App_Themes/Default/banner1.swf
Sticking a ~/ in a plain URL won't work. Try using this:
<object type="application/x-shockwave-flash"
data="<%=ResolveUrl('~/App_Themes/Default/banner1.swf')%>"
width="1000" height="400">

Make silverlight object in the center of page

When I create a Silverlight project in the Visual Studio, then build it, the VS would popup a page with the silverlight that I just made.But that silverlight object always on the left-up corner, is there any way to make it in the horizontal center of the page?
Best Regards,
Ordinarily the positioning of the plugin content within the rest of the HTML page is a problem for the HTML/CSS to solve not the Silverlight. (If you want that look for CSS solutions that center any HTML element in the Viewport and then apply it to the object tag in the .aspx or .htm hosting your control).
However I'm going to guess you don't have any other content in the page, the page exists only to host the silverlight content. In this case it may be better to let the Silverlight content occupy the entire page. The default .aspx and .htm test pages are designed to allow the plugin to do that, you just need to move the Width and Height properties from the UserControl to the inner "LayoutRoot" element and set the "LayoutRoot" to have "Center" HorizontalAlignment and VerticalAlignment.
In other words from this:-
<UserControl xmlns=".... blah...."
Width="600" Height="400">
<Grid x:Name="LayoutRoot">
<!-- Content here --?
</Grid>
</UserControl>
to this:-
<UserControl xmlns=".... blah....">
<Grid x:Name="LayoutRoot" Width="600" Height="400"
HorizontalAlignment="Center" VerticalAlignment="Center">
<!-- Content here --?
</Grid>
</UserControl>

WPF- How Can I Show a Cropped Region of an ImageSource in an <Image> Control?

WPF- How can I show a cropped region of an ImageSource in an control?
I have an ImageSource of a vairable size in pixels. I have a caculated crop rectangle, indicating how much of the image we are actually going to use. I don't want to edit the image data directly, but I want my <Image> control to display only the cropped region of the ImageSource.
Does Microsoft provide a way to automate this?
Any advice is appreciated!
Use a CroppedBitmap.
Here is an example of its usage:
<Page.Resources>
<!-- Define some image resources, for use as the image element source. -->
<BitmapImage x:Key="masterImage" UriSource="/sampleImages/gecko.jpg" />
<CroppedBitmap x:Key="croppedImage"
Source="{StaticResource masterImage}" SourceRect="30 20 105 50"/>
</Page.Resources>

Resources