private async void Initialize() { // Create a map with a light gray canvas basemap. Map sampleMap = new Map(Basemap.CreateLightGrayCanvas()); // Assign the map to the MapView. MyMapView.Map = sampleMap; // Define the Url string for the US highways feature layer. string highwaysUrlString = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/1"; // Create a service feature table from the url to the US highways feature service. ServiceFeatureTable highwaysServiceFeatureTable = new ServiceFeatureTable(new System.Uri(highwaysUrlString)); // Create a feature layer from the service feature table. FeatureLayer highwaysFeatureLayer = new FeatureLayer(highwaysServiceFeatureTable); // Add the US highways feature layer to the operations layers collection of the map. sampleMap.OperationalLayers.Add(highwaysFeatureLayer); // Load the US highways feature layer - this way we can obtain it's extent. await highwaysFeatureLayer.LoadAsync(); // Zoom the map view to the extent of the US highways feature layer. await MyMapView.SetViewpointGeometryAsync(highwaysFeatureLayer.FullExtent); // Help regarding the Json syntax for defining the LabelDefinition.FromJson syntax can be found here: // https://developers.arcgis.com/web-map-specification/objects/labelingInfo/ // This particular JSON string will have the following characteristics: // (1) The 'labelExpressionInfo' defines that the label text displayed comes from the field 'rte_num1' in the // feature service and will be prefaced with an "I -". Example: "I - 10", "I - 15", "I - 95", etc. // (2) The 'labelPlacement' will be placed above and along the highway polyline segment. // (3) The 'where' clause restricts the labels to be displayed that has valid (non-empty) data. Empty data // for this service has a single blank space in the 'rte_num1' field. // (4) The 'symbol' for the labeled text will be blue with a yellow halo. string theJSON_String = @"{ ""labelExpressionInfo"":{""expression"":""'I - ' + $feature.rte_num1""}, ""labelPlacement"":""esriServerLinePlacementAboveAlong"", ""where"":""$feature.rte_num1 <> ' '"", ""symbol"": { ""angle"":0, ""backgroundColor"":[0,0,0,0], ""borderLineColor"":[0,0,0,0], ""borderLineSize"":0, ""color"":[0,0,255,255], ""font"": { ""decoration"":""none"", ""size"":15, ""style"":""normal"", ""weight"":""normal"" }, ""haloColor"":[255,255,0,255], ""haloSize"":1.5, ""horizontalAlignment"":""center"", ""kerning"":false, ""type"":""esriTS"", ""verticalAlignment"":""middle"", ""xoffset"":0, ""yoffset"":0 } }"; // Create a label definition from the JSON string. LabelDefinition highwaysLabelDefinition = LabelDefinition.FromJson(theJSON_String); // Add the label definition to the feature layer's label definition collection. highwaysFeatureLayer.LabelDefinitions.Add(highwaysLabelDefinition); // Enable the visibility of labels to be seen. highwaysFeatureLayer.LabelsEnabled = true; }
public async void Initialize() { string licenseKey = "runtimelite,1000,rud3766972362,none,MJJC7XLS1HSB003AD015"; Esri.ArcGISRuntime.ArcGISRuntimeEnvironment.SetLicense(licenseKey); //Map myMap = new Map(Basemap.CreateTerrainWithLabels()); Map myMap = new Map(BasemapType.LightGrayCanvasVector, 35.728990, -78.856027, 18); // TEST GDB SERVICE VS MAP SERVICE // http://apexgis:6080/arcgis/rest/services/CemeteryHost/CEMTESTSERV/GeoDataServer/versions/dbo.DEFAULT // WFS serv http://apexgis:6080/arcgis/services/C+emeteryHost/CEMTESTSERV/GeoDataServer/WFSServer // LEGEND ILayerContent //var CemLot = new Uri("http://apexgis:6080/arcgis/rest/services/CemeteryHost/CEMTESTSERV/FeatureServer/0"); var CemLot = new Uri("http://apexgis:6080/arcgis/rest/services/CemeteryHost/CEMPRODSERV/FeatureServer/0"); FeatureLayer LotLayer = new FeatureLayer(CemLot); await LotLayer.LoadAsync(); SimpleLineSymbol LotLineSymb = new SimpleLineSymbol( SimpleLineSymbolStyle.Solid, System.Drawing.Color.Black, 1); SimpleFillSymbol lotSymbol = new SimpleFillSymbol() { Color = System.Drawing.Color.Transparent, Outline = LotLineSymb, }; SimpleRenderer LotRenderer = new SimpleRenderer(lotSymbol); // Lot label info StringBuilder LotStringLabelBuild = new StringBuilder(); LotStringLabelBuild.AppendLine("{"); LotStringLabelBuild.AppendLine("\"labelExpressionInfo\": {"); LotStringLabelBuild.AppendLine("\"expression\": \"return $feature.LOT_ID;\"},"); LotStringLabelBuild.AppendLine("\"maxScale\": 50,"); LotStringLabelBuild.AppendLine("\"minScale\": 1000,"); // Align labels above the center of each point LotStringLabelBuild.AppendLine("\"labelPlacement\": \"esriServerPolygonPlacementAlwaysHorizontal\","); // Use a white bold text symbol LotStringLabelBuild.AppendLine("\"symbol\": {"); // Color ARGB [R ALPHA B G] LotStringLabelBuild.AppendLine("\"color\": [13,38,68,255],"); LotStringLabelBuild.AppendLine("\"font\": {\"size\": 9, \"weight\": \"bold\"},"); LotStringLabelBuild.AppendLine("\"type\": \"esriTS\"}"); LotStringLabelBuild.AppendLine("}"); var LotLabelsJson = LotStringLabelBuild.ToString(); LabelDefinition LotLabelsDef = LabelDefinition.FromJson(LotLabelsJson); LotLayer.LabelDefinitions.Clear(); LotLayer.LabelDefinitions.Add(LotLabelsDef); LotLayer.LabelsEnabled = true; // CemPlot Properties //var CemPlot = new Uri("http://apexgis:6080/arcgis/rest/services/CemeteryHost/CEMTESTSERV/FeatureServer/1"); var CemPlot = new Uri("http://apexgis:6080/arcgis/rest/services/CemeteryHost/CEMPRODSERV/FeatureServer/1"); FeatureLayer PlotLayer = new FeatureLayer(CemPlot); await PlotLayer.LoadAsync(); var CemPlot2 = new Uri("http://apexgis:6080/arcgis/rest/services/CemeteryHost/CEMPRODSERV/FeatureServer/1"); FeatureLayer PlotLayer2 = new FeatureLayer(CemPlot); // Plot Label Properties StringBuilder PlotStringLabelBuild = new StringBuilder(); PlotStringLabelBuild.AppendLine("{"); PlotStringLabelBuild.AppendLine("\"labelExpressionInfo\": {"); PlotStringLabelBuild.AppendLine("\"expression\": \"return $feature.plot;\"},"); PlotStringLabelBuild.AppendLine("\"maxScale\": 10,"); PlotStringLabelBuild.AppendLine("\"minScale\": 250,"); // Align labels above the center of each point PlotStringLabelBuild.AppendLine("\"labelPlacement\": \"esriServerPolygonPlacementAlwaysHorizontal\","); // Use a white bold text symbol PlotStringLabelBuild.AppendLine("\"symbol\": {"); // Color ARGB [R ALPHA B G] PlotStringLabelBuild.AppendLine("\"color\": [13,38,68,255],"); PlotStringLabelBuild.AppendLine("\"font\": {\"size\": 8, \"weight\": \"italic\"},"); PlotStringLabelBuild.AppendLine("\"type\": \"esriTS\"}"); PlotStringLabelBuild.AppendLine("}"); var PlotLabelsJson = PlotStringLabelBuild.ToString(); LabelDefinition PlotLabelsDef = LabelDefinition.FromJson(PlotLabelsJson); PlotLayer.LabelDefinitions.Clear(); PlotLayer.LabelDefinitions.Add(PlotLabelsDef); PlotLayer.LabelsEnabled = true; // Plot Symbology var plotRenderer2 = new UniqueValueRenderer(); plotRenderer2.FieldNames.Add("name_LAST"); var plotOutline = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.White, 1); var town_plot = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, System.Drawing.ColorTranslator.FromHtml("#DB87F2"), plotOutline); plotRenderer2.UniqueValues.Add(new UniqueValue("Town Own", "Town Own", town_plot, "APEX")); plotRenderer2.UniqueValues.Add(new UniqueValue("Town Own", "Town Own", town_plot, "TOWN OF APEX")); var defaultFillSymbol2 = new SimpleFillSymbol(SimpleFillSymbolStyle.Null, System.Drawing.Color.Transparent, plotOutline); plotRenderer2.DefaultSymbol = defaultFillSymbol2; //plotRenderer.SceneProperties var plotRenderer = new UniqueValueRenderer(); plotRenderer.FieldNames.Add("Plot_status"); var validPlot = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, System.Drawing.ColorTranslator.FromHtml("#8DC055"), plotOutline); var unvalidPlot = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, System.Drawing.ColorTranslator.FromHtml("#F9F07F"), plotOutline); var notsaleable = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, System.Drawing.ColorTranslator.FromHtml("#F5503B"), plotOutline); plotRenderer.UniqueValues.Add(new UniqueValue("Valid Plot", "Valid Plot", validPlot, "Deeded")); plotRenderer.UniqueValues.Add(new UniqueValue("Unvalid", "Unvalid Plot", unvalidPlot, "Unknown")); plotRenderer.UniqueValues.Add(new UniqueValue("No Sale", "No Sell", notsaleable, "Not Saleable")); var defaultFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Null, System.Drawing.Color.Transparent, plotOutline); plotRenderer.DefaultSymbol = defaultFillSymbol; plotRenderer.DefaultLabel = "Other"; // CemBoundary Graphics //var CemBound = new Uri("http://apexgis:6080/arcgis/rest/services/CemeteryHost/CEMTESTSERV/FeatureServer/2"); var CemBound = new Uri("http://apexgis:6080/arcgis/rest/services/CemeteryHost/CEMPRODSERV/FeatureServer/2"); FeatureLayer BoundLayer = new FeatureLayer(CemBound); SimpleLineSymbol BoundLineSymb = new SimpleLineSymbol( SimpleLineSymbolStyle.Solid, System.Drawing.Color.IndianRed, 3); SimpleFillSymbol symbol = new SimpleFillSymbol() { Outline = BoundLineSymb, }; SimpleRenderer renderer = new SimpleRenderer(symbol); // Main GIS Operation Calls BoundLayer.Renderer = renderer; PlotLayer.Renderer = plotRenderer; LotLayer.Renderer = LotRenderer; PlotLayer2.Renderer = plotRenderer2; myMap.OperationalLayers.Add(BoundLayer); myMap.OperationalLayers.Add(PlotLayer); myMap.OperationalLayers.Add(PlotLayer2); myMap.OperationalLayers.Add(LotLayer); // Assign the map to the MapView myMap.MinScale = 2250; myMap.MaxScale = 30; MyMapView.Map = myMap; MyMapView.GeoViewTapped += MyMapView_GeoViewTapped; }
/// <summary> /// Construct with only a label. /// </summary> public TokenizedSourceLine([NotNull] LabelDefinition label) : this(label, null) { }
private async void Initialize() { // As of ArcGIS Enterprise 10.8.1, using utility network functionality requires a licensed user. The following login for the sample server is licensed to perform utility network operations. AuthenticationManager.Current.ChallengeHandler = new ChallengeHandler(async(info) => { try { // WARNING: Never hardcode login information in a production application. This is done solely for the sake of the sample. string sampleServer7User = "******"; string sampleServer7Pass = "******"; return(await AuthenticationManager.Current.GenerateCredentialAsync(info.ServiceUri, sampleServer7User, sampleServer7Pass)); } catch (Exception ex) { Debug.WriteLine(ex.Message); return(null); } }); try { // Starting viewpoint for the map view. Viewpoint _startingViewpoint = new Viewpoint(new Envelope(-9812691.11079696, 5128687.20710657, -9812377.9447607, 5128865.36767282, SpatialReferences.WebMercator)); // Create the map. MyMapView.Map = new Map(BasemapStyle.ArcGISStreetsNight) { InitialViewpoint = _startingViewpoint }; // NOTE: This layer supports any ArcGIS Feature Table that define subtypes. SubtypeFeatureLayer subtypeFeatureLayer = new SubtypeFeatureLayer(new ServiceFeatureTable(new Uri("https://sampleserver7.arcgisonline.com/server/rest/services/UtilityNetwork/NapervilleElectric/FeatureServer/0"))); MyMapView.Map.OperationalLayers.Add(subtypeFeatureLayer); // Select sublayer to control. await subtypeFeatureLayer.LoadAsync(); // Select the sublayer of street lights by name. _sublayer = subtypeFeatureLayer.GetSublayerBySubtypeName("Street Light"); // Create a text symbol for styling the sublayer label definition. TextSymbol textSymbol = new TextSymbol { Size = 12, OutlineColor = Color.White, Color = Color.Blue, HaloColor = Color.White, HaloWidth = 3, }; // Create a label definition with a simple label expression. LabelExpression simpleLabelExpression = new SimpleLabelExpression("[nominalvoltage]"); LabelDefinition labelDefinition = new LabelDefinition(simpleLabelExpression, textSymbol) { Placement = Esri.ArcGISRuntime.ArcGISServices.LabelingPlacement.PointAboveRight, UseCodedValues = true, }; // Add the label definition to the sublayer. _sublayer.LabelDefinitions.Add(labelDefinition); // Enable labels for the sub layer. _sublayer.LabelsEnabled = true; // Set the data context for data-binding in XAML. SublayerInfo.DataContext = _sublayer; // Get the default renderer for the sublayer. _defaultRenderer = _sublayer.Renderer.Clone(); // Create a custom renderer for the sublayer. _customRenderer = new SimpleRenderer() { Symbol = new SimpleMarkerSymbol() { Color = Color.Salmon, Style = SimpleMarkerSymbolStyle.Diamond, Size = 20, } }; // Set a default minimum scale. _sublayer.MinScale = 3000; } catch (Exception ex) { await new MessageDialog(ex.Message, ex.GetType().Name).ShowAsync(); } }
private async void Initialize() { // Create a map with a light gray canvas basemap. Map sampleMap = new Map(Basemap.CreateLightGrayCanvas()); // Assign the map to the MapView. MyMapView.Map = sampleMap; // Define the URL string for the feature layer. string layerUrl = "https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/USA_Congressional_Districts_analysis/FeatureServer/0"; // Create a service feature table from the URL. ServiceFeatureTable featureTable = new ServiceFeatureTable(new System.Uri(layerUrl)); // Create a feature layer from the service feature table. FeatureLayer districtFeatureLabel = new FeatureLayer(featureTable); // Add the feature layer to the operations layers collection of the map. sampleMap.OperationalLayers.Add(districtFeatureLabel); // Load the feature layer - this way we can obtain it's extent. await districtFeatureLabel.LoadAsync(); // Zoom the map view to the extent of the feature layer. await MyMapView.SetViewpointCenterAsync(new MapPoint(-10846309.950860, 4683272.219411, SpatialReferences.WebMercator), 20000000); // Help regarding the Json syntax for defining the LabelDefinition.FromJson syntax can be found here: // https://developers.arcgis.com/web-map-specification/objects/labelingInfo/ // This particular JSON string will have the following characteristics: string redLabelJson = @"{ ""labelExpressionInfo"":{""expression"":""$feature.NAME + ' (' + left($feature.PARTY,1) + ')\\nDistrict' + $feature.CDFIPS""}, ""labelPlacement"":""esriServerPolygonPlacementAlwaysHorizontal"", ""where"":""PARTY = 'Republican'"", ""symbol"": { ""angle"":0, ""backgroundColor"":[0,0,0,0], ""borderLineColor"":[0,0,0,0], ""borderLineSize"":0, ""color"":[255,0,0,255], ""font"": { ""decoration"":""none"", ""size"":10, ""style"":""normal"", ""weight"":""normal"" }, ""haloColor"":[255,255,255,255], ""haloSize"":2, ""horizontalAlignment"":""center"", ""kerning"":false, ""type"":""esriTS"", ""verticalAlignment"":""middle"", ""xoffset"":0, ""yoffset"":0 } }"; string blueLabelJson = @"{ ""labelExpressionInfo"":{""expression"":""$feature.NAME + ' (' + left($feature.PARTY,1) + ')\\nDistrict' + $feature.CDFIPS""}, ""labelPlacement"":""esriServerPolygonPlacementAlwaysHorizontal"", ""where"":""PARTY = 'Democrat'"", ""symbol"": { ""angle"":0, ""backgroundColor"":[0,0,0,0], ""borderLineColor"":[0,0,0,0], ""borderLineSize"":0, ""color"":[0,0,255,255], ""font"": { ""decoration"":""none"", ""size"":10, ""style"":""normal"", ""weight"":""normal"" }, ""haloColor"":[255,255,255,255], ""haloSize"":2, ""horizontalAlignment"":""center"", ""kerning"":false, ""type"":""esriTS"", ""verticalAlignment"":""middle"", ""xoffset"":0, ""yoffset"":0 } }"; // Create a label definition from the JSON string. LabelDefinition redLabelDefinition = LabelDefinition.FromJson(redLabelJson); LabelDefinition blueLabelDefinition = LabelDefinition.FromJson(blueLabelJson); // Add the label definition to the feature layer's label definition collection. districtFeatureLabel.LabelDefinitions.Add(redLabelDefinition); districtFeatureLabel.LabelDefinitions.Add(blueLabelDefinition); // Enable the visibility of labels to be seen. districtFeatureLabel.LabelsEnabled = true; }
// Constructors /////////////////////////////////////////////////////// /// <summary> /// Construct with optional label definition and instruction. /// </summary> public TokenizedSourceLine([CanBeNull] LabelDefinition label = null, [CanBeNull] SourceInstruction instruction = null) { Label = label; Instruction = instruction; }
private void get_feature_layer() { /*********************************************************************** * This function loads a feature layer from arcGIS online ************************************************************************/ // Create new Map with basemap myMap = new Map(Basemap.CreateTopographic()); // Create and set initial map area Envelope initialLocation = new Envelope( -160.6739, 13.3844, -179.5449, 80.2319, SpatialReferences.Wgs84); myMap.InitialViewpoint = new Viewpoint(initialLocation); /*********************************************************************** * Turtle Feature Layer ************************************************************************/ // Create uri to the used feature service var serviceUri = new Uri( "https://services6.arcgis.com/kInEIOmrLNzXMSuZ/arcgis/rest/services/Turtles/FeatureServer/0"); // Create feature table using a URL. _featureTable = new ServiceFeatureTable(serviceUri); MyMapView.Map = myMap; // Create feature layer using this feature table. Make it slightly transparent. _featureLayer = new FeatureLayer(_featureTable); string theJSON_String = @"{ ""labelExpressionInfo"":{""expression"":""$feature.Species""}, ""labelPlacement"":""esriServerLinePlacementAboveAlong"", ""where"":""Species <> ' '"", ""symbol"": { ""angle"":0, ""backgroundColor"":[0,0,0,0], ""borderLineColor"":[0,0,0,0], ""borderLineSize"":0, ""color"":[51, 51, 51, 255], ""font"": { ""decoration"":""none"", ""size"":10, ""style"":""normal"", ""weight"":""normal"" }, ""haloColor"":[0,0,0,0], ""haloSize"":1.5, ""horizontalAlignment"":""center"", ""kerning"":false, ""type"":""esriTS"", ""verticalAlignment"":""middle"", ""xoffset"":0, ""yoffset"":0 } }"; // Create a label definition from the JSON string. LabelDefinition turtleSpeciesLabelDefinition = LabelDefinition.FromJson(theJSON_String); /*********************************************************************** * Air Temp Feature Layer ************************************************************************/ var airServiceUri = new Uri( "https://services6.arcgis.com/kInEIOmrLNzXMSuZ/arcgis/rest/services/Air_Temp_/FeatureServer/0"); // Create feature table using a URL. _airFeatureTable = new ServiceFeatureTable(airServiceUri); // Create feature layer using this feature table. Make it slightly transparent. _airFeatureLayer = new FeatureLayer(_airFeatureTable) { Opacity = 0.6 }; /*********************************************************************** * Wind Feature Layer ************************************************************************/ var windServiceUri = new Uri( "https://services6.arcgis.com/kInEIOmrLNzXMSuZ/arcgis/rest/services/Wind/FeatureServer/0"); // Create feature table using a URL. _windFeatureTable = new ServiceFeatureTable(windServiceUri); // Create feature layer using this feature table. Make it slightly transparent. _windFeatureLayer = new FeatureLayer(_windFeatureTable) { Opacity = 0.6 }; /*********************************************************************** * Sea Surface Temperature Feature Layer ************************************************************************/ var seaTempServiceUri = new Uri( "https://services6.arcgis.com/kInEIOmrLNzXMSuZ/arcgis/rest/services/Sea_Temp/FeatureServer/0"); // Create feature table using a URL. _seaTempFeatureTable = new ServiceFeatureTable(seaTempServiceUri); // Create feature layer using this feature table. Make it slightly transparent. _seaTempFeatureLayer = new FeatureLayer(_seaTempFeatureTable) { Opacity = 0.6 }; // add feature layers to map /* myMap.OperationalLayers.Add(_featureLayer); * myMap.OperationalLayers.Add(_airFeatureLayer); * myMap.OperationalLayers.Add(_windFeatureLayer); * myMap.OperationalLayers.Add(_seaTempFeatureLayer);*/ // Add the label definition to the feature layer's label definition collection. _featureLayer.LabelDefinitions.Add(turtleSpeciesLabelDefinition); // Enable the visibility of labels to be seen. _featureLayer.LabelsEnabled = true; MyMapView.TimeExtent = new TimeExtent(start, end); // add the map to the map view MyMapView.Map = myMap; }
internal static void Check(LabelDefinition expected, LabelDefinition actual, String message) { LabelTest.Check(expected.Label, actual.Label, "Label: " + message); MemoryOffsetTest.Check(expected.RelOffset, actual.RelOffset, "RelOffset: " + message); MemoryAddressTest.Check(expected.AbsAddress, actual.AbsAddress, "AbsAddress: " + message); }
private bool AddLabel(LabelDefinition ld) { int index = labelDatas.BinarySearch(ld); if (index < 0) { labelDatas.Insert(~index, ld); return true; } return false; }
public TabDefinition GetTabDefinition() { var groups = new List <GroupDefinition>(); var maintenance = new List <ControlDefinition>(); ToolTipDefinition tooltip = new ToolTipDefinition(); tooltip.Description = String.Format("View all WebParts on page {0}.", SPContext.Current.ListItem.Title); tooltip.Title = "WebParts on Page."; var button = new ButtonDefinition() { Id = "WebpartMaintenance", Title = "WebParts on Page", ToolTip = tooltip, Image = ImageLibrary.GetStandardImage(3, 4), CommandJavaScript = "ShowMaintenancePage(commandId, properties, sequence)" }; maintenance.Add(button); button = new ButtonDefinition() { Id = "WebPartInsert", Title = "WebPart Adder", Image = ImageLibrary.GetStandardImage(13, 9), CommandEnableJavaScript = "document.forms[MSOWebPartPageFormName].MSOLayout_InDesignMode.value == 1", CommandJavaScript = "CoreInvoke('ShowWebPartAdder', 'insertWebPart');return false" }; //CommandJavaScript = "window.LoadWPAdderOnDemand(); ShowWebPartAdder('insertWebPart')" maintenance.Add(button); var maintenancegroup = new GroupDefinition() { Id = "Maintenance", Title = "Maintenance", Sequence = "10", Template = GroupTemplateLibrary.SimpleTemplate, Controls = maintenance.ToArray() }; groups.Add(maintenancegroup); if (WebPartManager.Zones.Count > 1) { var zones = new List <ControlDefinition>(); var label = new LabelDefinition() { Id = "ZoneLabel", Title = "Select your Zone", Image = ImageLibrary.GetStandardImage(2, 4), TemplateAlias = "c1", ForId = "ZoneDropDown" }; zones.Add(label); var choices = new List <ControlDefinition>(); string choice = string.Empty; foreach (WebPartZoneBase zone in WebPartManager.Zones) { if (zone != null && zone.ID != "wpz") { tooltip = new ToolTipDefinition(); tooltip.Description = String.Format("Add WebPart to {0} zone.", zone.DisplayTitle); tooltip.Title = zone.DisplayTitle; if (string.IsNullOrEmpty(choice)) { choice = zone.ID; } button = new ButtonDefinition() { Id = zone.ID, Title = zone.DisplayTitle, ToolTip = tooltip, Image = ImageLibrary.GetStandardImage(13, 2), TemplateAlias = "c1", CommandJavaScript = String.Format("SetWebpartZone('{0}')", zone.ID) }; choices.Add(button); } } var dropdown = new DropDownDefinition() { Id = "ZoneDropDown", ControlsSize = ControlSize.Size32x32, Title = "Zones", InitialValueJavaScript = "'" + choice + "'", Controls = choices.ToArray() }; zones.Add(dropdown); var Selectedlabel = new LabelDefinition() { Id = "SelectedZoneLabel", Title = "Selected Zone", TemplateAlias = "c1" }; zones.Add(Selectedlabel); var zonegroup = new GroupDefinition() { Id = "WebpartZone", Title = "WebpartZone", Sequence = "20", Template = GroupTemplateLibrary.ThreeRowTemplate, Controls = zones.ToArray() }; groups.Add(zonegroup); } int index = 0; int sequence = 30; foreach (string category in Categories) { List <WebPartGalleryItem> buttons = Sources.Where(n => n.Category == category).Select(n => n).ToList(); if (buttons.Count > 0) { var controls = new List <ControlDefinition>(); foreach (WebPartGalleryItem item in buttons) { ImageDefinition image = new ImageDefinition(); image.Url16 = item.IconUrl; image.Url32 = item.IconUrl; button = new ButtonDefinition() { Id = item.Title.Replace(" ", String.Empty).Trim(), Title = item.Title, Image = image, CommandEnableJavaScript = "webpartzone != null", CommandJavaScript = String.Format("AddWebPartToPage('{0}','{1}')", this.ClientID, item.Id), TemplateAlias = "c1" }; controls.Add(button); } var group = new GroupDefinition() { Id = ((category != null) ? category.Replace(" ", string.Empty).Trim() : "None"), Title = (category != null) ? category : "None", Sequence = sequence.ToString(), Template = GroupTemplateLibrary.SimpleTemplate, Controls = new ControlDefinition[] { new MRUSplitButtonDefinition() { Id = "MRU" + ((category != null) ? category.Replace(" ", string.Empty).Trim() : "None"), InitialItem = controls[0].Id, ControlsSize = ControlSize.Size32x32, Controls = controls.ToArray() } } }; groups.Add(group); sequence += 10; index += 1; } } if (groups.Count > 0) { return(new TabDefinition() { Id = "Hemrika.SharePresence.Content", Title = "Content", Sequence = "110", GroupTemplates = GroupTemplateLibrary.AllTemplates, Groups = groups.ToArray() }); } else { return(null); } }
internal string GetDefaultLabel( string lang ) { if ( this.labelDatas.Count == 1 ) { if ( labelDatas[0].Language.Equals( lang ) ) { return labelDatas[0].Label != null ? labelDatas[0].Label : string.Empty; } } LabelDefinition ll = new LabelDefinition( "label", lang, null ); int index = labelDatas.BinarySearch( ll ); if ( index >= 0 ) { return labelDatas[index].Label != null ? labelDatas[index].Label : string.Empty; } ll.LabelRole = "terseLabel"; index = labelDatas.BinarySearch( ll ); if ( index >= 0 ) { return labelDatas[index].Label != null ? labelDatas[index].Label : string.Empty; } foreach ( LabelDefinition ld in this.labelDatas ) { if ( ld.Language.Equals( lang ) ) { return ld.Label != null ? ld.Label : string.Empty; } } return string.Empty; }
/// <summary> /// Adds the <see cref="LabelDefinition"/> objects within a supplied collection to this /// <see cref="LabelLocator"/>'s collection of labels. /// </summary> /// <param name="labels">An <see cref="Array"/> of <see cref="LabelDefinition"/>.</param> public void Update( LabelDefinition[] labels ) { if (labels == null) return; foreach ( LabelDefinition label in labels ) { int index = labelDatas.BinarySearch( label ); if ( index < 0 ) { labelDatas.Insert( ~index, label ); } else { labelDatas[index] = label; } } }
/// <summary> /// Retrieves and returns a label from this <see cref="LabelLocator"/>'s collection /// of label definitions. /// </summary> /// <param name="lang">The language code of the label to be retrieved.</param> /// <param name="role">The role of the label to be retrieved.</param> /// <param name="info">An output parameter. The retrieved label.</param> /// <returns>True if <paramref name="info"/> could be retrieved and is not null.</returns> public bool TryGetInfo( string lang, string role, out string info ) { LabelDefinition ll = new LabelDefinition( role, lang, null ); int index = labelDatas.BinarySearch( ll ); if ( index >= 0 ) { ll = labelDatas[index]; } info = ll.Label; return info != null; }
private void CheckFindDefinitionFor(Label label, LabelDefinition expected, String message) { LabelDefinition actual = m_lblTable.FindDefinitionFor(label); Assert.AreSame(expected, actual, message); }
/// <summary> /// Adds the <see cref="LabelDefinition"/> objects within a supplied collection to this /// <see cref="Element"/>'s collection of labels. /// </summary> /// <param name="labels">An <see cref="Array"/> of <see cref="LabelDefinition"/>.</param> public void UpdateLabels(LabelDefinition[] labels) { if (labelInfo == null) { labelInfo = new LabelLocator(); } labelInfo.Update(labels); }