martes, 27 de enero de 2009

Ver archivos de flash con link en MOSS 2007

Introduction

I've seen that many people are using HTML content web part for displaying Flash animation. I don't recommend this approach for many reasons, one of them being you won't tell your client to edit HTML code for changing Flash properties; so it is better to have a dedicated web part for rendering Flash animation.

Software Requirements


Microsoft SharePoint 2007 installed (With Site Collection created on port:80)
SharePoint Services 3.0 Extensions for Visual Studio 2005 installed
Using the code
To apply the code, you will need to create a new SharePoint Webpart Project then overrides the web part class file:


using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.WebControls;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
using Microsoft.SharePoint.Utilities;
using System.Web.UI.HtmlControls;
namespace FlashWebPart
{
[Guid("f04fa49d-1342-4c7d-904a-c43ebc942f39")]
[XmlRoot(Namespace = "FlashWebPart")]
public class FlashWebPart : Microsoft.SharePoint.WebPartPages.WebPart
{
public FlashWebPart()
{
this.ExportMode = WebPartExportMode.All;
}
protected int flashWidth = 400;
protected int flashHeight = 300;
protected string flashUrl = "";

true),
Category("Flash Info"),
DefaultValue(400),
WebPartStorage(Storage.Shared),
FriendlyName("Width"),
Description("Width of the web part")>
public int FlashWidth
{
get
{
return this.flashWidth;
}
set
{
this.flashWidth = value;
}
}
true),
Category("Flash Info"),
DefaultValue(300),
WebPartStorage(Storage.Shared),
FriendlyName("Height"),
Description("Height of the web part")>
public int FlashHeight
{
get
{
return this.flashHeight;
}
set
{
this.flashHeight = value;
}
}
true),
Category("Flash Info"),
DefaultValue(""),
WebPartStorage(Storage.Shared),
FriendlyName("URL"),
Description("URL of the web part")>
public string FlashURL
{
get
{
return this.flashUrl;
}
set
{
this.flashUrl = value;
}
}
protected override void Render(HtmlTextWriter writer)
{
string outHTML =
"
" + " " +
"" +
" " +
" "
+ "
";
writer.Write(outHTML);
}
}
}

Google Maps WebPart

Directamente desde el sitio de CodeProject, hay un interesante WebPart con comunicacion directa al Google Maps, donde se puede publicar directamente las coordenadas, si bien ya hay bastante material para Virtual Earth, esta es otra alternativa, totalmente free.


Descargarlo directamente desde el Sitio de CodeProject
Introduction
This article presents a Google map WebPart.
Using the code

The rendering on the Google map control is performed in the WebPart Render event. The Google map control is initialized using the ClientScriptManager object.
Collapse
Copy Code
protected override void Render(HtmlTextWriter writer)
{
string rScript = "";
rScript += "\n";
rScript += "\n";
rScript += "
GHeight + "px\">
\n";
writer.Write(rScript);
if (!Page.ClientScript.IsStartupScriptRegistered("MapInit"))
Page.ClientScript.RegisterStartupScript(typeof(string), "MapInit",
"Init()", true);
}
In order to be able to modify the Google map properties, I created an EditorPart class, allowing the user to change the Google API key or the dimensions of the WebPart.
Collapse
Copy Code
public class GoogleMapEditor : System.Web.UI.WebControls.WebParts.EditorPart
{
TextBox googleKey = new TextBox();
TextBox tbWidth = new TextBox();
TextBox tbHeight = new TextBox();
TextBox tbLat = new TextBox();
TextBox tbLong = new TextBox();
TextBox tbZoom = new TextBox();
CheckBox chkDisplayZoom = new CheckBox();
CheckBox chkDragging = new CheckBox();
CheckBox chkIcon = new CheckBox();
Just like a standard WebPart, editor parts must override the CreateChildControls to build a user interface. The user interface is drawn by overriding the RenderContents method.
Collapse
Copy Code
protected override void RenderContents(HtmlTextWriter writer)
{
writer.Write("Google Key
");
googleKey.RenderControl(writer);

writer.Write("
Width
");
tbWidth.RenderControl(writer);

writer.Write("
Height
");
tbHeight.RenderControl(writer);