本文整理汇总了C#中IServerConnection.GetService方法的典型用法代码示例。如果您正苦于以下问题:C# IServerConnection.GetService方法的具体用法?C# IServerConnection.GetService怎么用?C# IServerConnection.GetService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IServerConnection
的用法示例。
在下文中一共展示了IServerConnection.GetService方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadMap
private void LoadMap(IServerConnection conn, string mapDefinitionId)
{
//To render a map, we need to create a runtime map instance. IMappingService gives us
//the required services. This is not a standard service, so you need to call GetService()
//with the correct ServiceType to get the IMappingService reference.
IMappingService mapSvc = (IMappingService)conn.GetService((int)ServiceType.Mapping);
//Get an IMapDefinition from the specified resource id. GetResource() returns an instance
//of IResource, which IMapDefinition extends. As long as you pass in a valid resource id
//of the right type, you can safely cast the returned object to the expected type.
IMapDefinition mapDef = (IMapDefinition)conn.ResourceService.GetResource(mapDefinitionId);
//Create a runtime map
var rtMap = mapSvc.CreateMap(mapDef);
//Load it into the viewer
mapViewer.LoadMap(rtMap);
}
示例2: CreateItem
public override IResource CreateItem(string startPoint, IServerConnection conn)
{
using (var picker = new ResourcePicker(conn.ResourceService, ResourceTypes.DrawingSource, ResourcePickerMode.OpenResource))
{
picker.SetStartingPoint(startPoint);
if (picker.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
var ldf = ObjectFactory.CreateDefaultLayer(conn, OSGeo.MapGuide.ObjectModels.LayerDefinition.LayerType.Drawing, new Version(1, 0, 0));
ldf.SubLayer.ResourceId = picker.ResourceID;
var dl = ((IDrawingLayerDefinition)ldf.SubLayer);
dl.LayerFilter = string.Empty;
dl.MinScale = 0;
IDrawingService dwSvc = (IDrawingService)conn.GetService((int)ServiceType.Drawing);
var sheets = dwSvc.EnumerateDrawingSections(picker.ResourceID);
dl.Sheet = sheets.Section[0].Name;
return ldf;
}
return null;
}
}
示例3: CreateFlexibleLayout
/// <summary>
/// Creates a fusion flexible layout
/// </summary>
/// <param name="owner"></param>
/// <param name="templateName">The name of the template. See <see cref="FusionTemplateNames"/> for the common pre-defined names</param>
/// <returns></returns>
public static IApplicationDefinition CreateFlexibleLayout(IServerConnection owner, string templateName)
{
Check.NotNull(owner, "owner"); //NOXLATE
/*
Check.Precondition(Array.IndexOf(owner.Capabilities.SupportedServices, (int)ServiceType.Fusion) >= 0, "Required Fusion service not supported on this connection");
var fusionSvc = (IFusionService)owner.GetService((int)ServiceType.Fusion);
var templates = fusionSvc.GetApplicationTemplates();
var appDef = DeserializeEmbeddedFlexLayout();
//Find matching template.
var tpl = templates.FindTemplate(templateName);
if (tpl != null)
{
appDef.TemplateUrl = tpl.LocationUrl;
appDef.Title = tpl.Name;
}
appDef.CurrentConnection = owner;
return appDef;
*/
Check.Precondition(Array.IndexOf(owner.Capabilities.SupportedServices, (int)ServiceType.Fusion) >= 0, "Required Fusion service not supported on this connection");
IApplicationDefinition appDef = new ApplicationDefinitionType()
{
CurrentConnection = owner,
MapSet = new System.ComponentModel.BindingList<MapGroupType>(),
WidgetSet = new System.ComponentModel.BindingList<WidgetSetType>()
};
var fusionSvc = (IFusionService)owner.GetService((int)ServiceType.Fusion);
var templates = fusionSvc.GetApplicationTemplates();
var widgets = fusionSvc.GetApplicationWidgets();
var containers = fusionSvc.GetApplicationContainers();
//Find matching template. If it's a known template we should be able to
//build it programatically, otherwise return a deserialized copy from our
//embedded resource
var tpl = templates.FindTemplate(templateName);
if (tpl != null)
{
appDef.TemplateUrl = tpl.LocationUrl;
appDef.Title = tpl.Name;
}
else
{
//NOTE: Depending on MapGuide Server version, this document may be
//invalid (eg. References to widgets not available in that version)
return DeserializeEmbeddedFlexLayout(owner);
}
//Toolbars, every template has them
var toolbar = appDef.CreateContainer("Toolbar", containers.FindContainer("Toolbar")); //NOXLATE
var secToolbar = appDef.CreateContainer("ToolbarSecondary", containers.FindContainer("Toolbar")); //NOXLATE
var vertToolbar = appDef.CreateContainer("ToolbarVertical", containers.FindContainer("Toolbar")); //NOXLATE
//Context menus, every template has them
var mapContextMenu = appDef.CreateContainer("MapContextMenu", containers.FindContainer("ContextMenu")); //NOXLATE
var taskPaneMenu = appDef.CreateContainer("TaskMenu", containers.FindContainer("ContextMenu")); //NOXLATE
//Menu
var menu = appDef.CreateContainer("FileMenu", containers.FindContainer("Toolbar")); //NOXLATE
//Status bar
var statusbar = appDef.CreateContainer("Statusbar", containers.FindContainer("Splitterbar")); //NOXLATE
string mapId = "MainMap"; //NOXLATE
//Set default map group
appDef.AddMapGroup(mapId, true, string.Empty);
//Create default widget set
var widgetSet = appDef.CreateWidgetSet(appDef.CreateMapWidget(mapId, mapContextMenu.Name));
appDef.AddWidgetSet(widgetSet);
//Add all known non-parameterized widgets to this widget set
foreach (var wgt in widgets.WidgetInfo)
{
if (Array.IndexOf(parameterizedWidgets, wgt.Type) < 0)
{
var widget = appDef.CreateWidget(wgt.Type, wgt);
widgetSet.AddWidget(widget);
}
}
//Add some parameterized ones
//Zoom In
var zoomIn = (IUIWidget)appDef.CreateWidget("ZoomIn", widgets.FindWidget(KnownWidgetNames.ZoomOnClick)); //NOXLATE
zoomIn.SetValue("Factor", "2"); //NOXLATE
zoomIn.StatusText = zoomIn.Tooltip = Strings.ADF_Widget_ZoomIn_Desc;
zoomIn.Label = Strings.ADF_Widget_ZoomIn_Label;
zoomIn.ImageUrl = "images/icons.png"; //NOXLATE
zoomIn.ImageClass = "zoom-in-fixed"; //NOXLATE
//.........这里部分代码省略.........
示例4: RuntimeMap
/// <summary>
/// Initializes this instance
/// </summary>
/// <param name="conn"></param>
protected internal RuntimeMap(IServerConnection conn)
{
this.StrictSelection = true;
this.IsDirty = false;
_disableChangeTracking = true;
this.WatermarkUsage = (int)WatermarkUsageType.Viewer;
this.SiteVersion = conn.SiteVersion;
this.SessionId = conn.SessionID;
this.ObjectId = Guid.NewGuid().ToString();
m_changeList = new Dictionary<string, ChangeList>();
_finiteDisplayScales = new double[0];
this.CurrentConnection = conn;
if (Array.IndexOf(conn.Capabilities.SupportedServices, (int)ServiceType.Mapping) >= 0)
{
_mapSvc = (IMappingService)conn.GetService((int)ServiceType.Mapping);
}
if (Array.IndexOf(conn.Capabilities.SupportedCommands, (int)CommandType.GetResourceContents) >= 0)
{
_getRes = (IGetResourceContents)conn.CreateCommand((int)CommandType.GetResourceContents);
}
this.Layers = new RuntimeMapLayerCollection(this);
this.Groups = new RuntimeMapGroupCollection(this);
}
示例5: GetSymbol
/// <summary>
/// Fetches the thumbnail of a symbol in a symbol library
/// </summary>
/// <param name="conn"></param>
/// <param name="symbolLibId"></param>
/// <param name="symbolName"></param>
/// <returns></returns>
internal static Image GetSymbol(IServerConnection conn, string symbolLibId, string symbolName)
{
//NOTE: This could be nasty performance-wise if invoked at lot of times in succession
//But these types of symbols are deprecated anyway, so we can live with it, because people
//shouldn't be using these anymore (and thus this method by extension)
var ds = ImageSymbolConverter.PrepareSymbolDrawingSource(conn, symbolLibId);
//Now we should be able to query it via Drawing Service APIs
var drawSvc = (IDrawingService)conn.GetService((int)ServiceType.Drawing);
//Each section in the symbols.dwf represents a symbol
var sectionList = drawSvc.EnumerateDrawingSections(ds.ResourceID);
foreach (var sect in sectionList.Section)
{
if (sect.Title == symbolName)
{
var sectResources = drawSvc.EnumerateDrawingSectionResources(ds.ResourceID, sect.Name);
foreach (var res in sectResources.SectionResource)
{
if (res.Role.ToUpper() == StringConstants.Thumbnail.ToUpper())
{
using (var rs = drawSvc.GetSectionResource(ds.ResourceID, res.Href))
{
return Image.FromStream(rs);
}
}
}
}
}
return null;
}
示例6: OnLoad
protected override void OnLoad(EventArgs e)
{
//This call is a one-time only call that will instantly register all known resource
//version types and validators. This way you never have to manually reference a
//ObjectModels assembly of the desired resource type you want to work with
ModelSetup.Initialize();
//Anytime we work with the Maestro API, we require an IServerConnection
//reference. The Maestro.Login.LoginDialog provides a UI to obtain such a
//reference.
//If you need to obtain an IServerConnection reference programmatically and
//without user intervention, use the ConnectionProviderRegistry class
var login = new Maestro.Login.LoginDialog();
if (login.ShowDialog() == DialogResult.OK)
{
_conn = login.Connection;
//Connections carry a capability property that tells you what is and isn't supported.
//Here we need to check if this connection supports the IDrawingService interface. If
//it doesn't we can't continue.
if (Array.IndexOf(_conn.Capabilities.SupportedServices, (int)ServiceType.Drawing) < 0)
{
MessageBox.Show("This particular connection does not support the Drawing Service API");
Application.Exit();
return;
}
//For any non-standard service interface, we call GetService() passing in the service type and casting
//it to the required service interface.
_dwSvc = (IDrawingService)_conn.GetService((int)ServiceType.Drawing);
}
else //This sample does not work without an IServerConnection
{
Application.Exit();
}
}