private void setControlsFromDefinition(LayerDefinition definition) { //Enabled stuff removeButton.Enabled = true; moveUpButton.Enabled = listBox.SelectedIndex > 0; moveDownButton.Enabled = listBox.SelectedIndex < listBox.Items.Count - 1; nameTextBox.Enabled = true; gridXTextBox.Enabled = true; gridYTextBox.Enabled = true; scrollXTextBox.Enabled = true; scrollYTextBox.Enabled = true; typeComboBox.Enabled = true; //Load properties nameTextBox.Text = definition.Name; gridXTextBox.Text = definition.Grid.Width.ToString(); gridYTextBox.Text = definition.Grid.Height.ToString(); scrollXTextBox.Text = definition.ScrollFactor.X.ToString(); scrollYTextBox.Text = definition.ScrollFactor.Y.ToString(); typeComboBox.SelectedIndex = LayerDefinition.LAYER_TYPES.FindIndex(e => e == definition.GetType()); //Remove the old layer editor if (layerEditor != null) { Controls.Remove(layerEditor); } //Add the new one layerEditor = definition.GetEditor(); if (layerEditor != null) { layerEditor.TabIndex = 6; Controls.Add(layerEditor); } }
public override void Run( ) { // 1. Opening the PDF file... string filePath = PromptFileChoice("Please select a PDF file"); using (File file = new File(filePath)) { Document document = file.Document; // 2. Get the layer definition! LayerDefinition layerDefinition = document.Layer; if (!layerDefinition.Exists()) { Console.WriteLine("\nNo layer definition available."); } else { Console.WriteLine("\nIterating through the layers...\n"); // 3. Parse the layer hierarchy! Parse(layerDefinition.Layers, 0); } } }
/* * Events */ private void addButton_Click(object sender, EventArgs e) { LayerDefinition def = getDefaultLayer(); layerDefinitions.Add(def); listBox.SelectedIndex = listBox.Items.Add(def.Name); }
/// <summary> /// This will return the appropriate layer when a group is selected. /// </summary> /// <returns>The correct layer inside the group</returns> private LayerDefinition GetLayerFromSelectedGroup() { int selectIndex = listBox.SelectedIndex; if (selectIndex < 0) { return(null); } if (layerGroupComboBox.SelectedIndex == 0) // If "All" selected { return(layerDefinitions[selectIndex]); } int num = 0; LayerDefinition result = null; foreach (LayerDefinition e in layerDefinitions) { if (e.GroupName == layerGroupComboBox.SelectedItem.ToString()) { if (num == selectIndex) { result = e; break; } num++; } } return(result); }
private void onLayerChanged(LayerDefinition layerDefinition, int index) { EditorVisible = layerDefinition is TileLayerDefinition; if (EditorVisible && Ogmo.LayersWindow.CurrentLayer != null) { tilesetsComboBox.SelectedIndex = Ogmo.Project.Tilesets.IndexOf((Ogmo.LayersWindow.CurrentLayer as TileLayer).Tileset); tileSelector.Tileset = (Ogmo.LayersWindow.CurrentLayer as TileLayer).Tileset; } }
// Create webmap layer out of a feature set from a query task private async Task <WebMapLayer> CreateFeatureCollectionLayer() { try { //Perform Query to get a featureSet and add to webmap as featurecollection QueryTask qt = new QueryTask( new Uri("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/EarthquakesFromLastSevenDays/MapServer/0")); Esri.ArcGISRuntime.Tasks.Query.Query query = new Esri.ArcGISRuntime.Tasks.Query.Query("magnitude > 3.5"); query.OutFields.Add("*"); query.ReturnGeometry = true; var queryResult = await qt.ExecuteAsync(query); var simpleRenderer = new SimpleRenderer { Symbol = new SimpleMarkerSymbol { Style = SimpleMarkerStyle.Circle, Color = Color.FromArgb(255, 0, 0, 255), Size = 8 } }; var drawingInfo = new DrawingInfo { Renderer = simpleRenderer }; var layerDefinition = new LayerDefinition { DrawingInfo = drawingInfo }; //Create FeatureCollection as webmap layer FeatureCollection featureCollection = null; if (queryResult.FeatureSet.Features.Count > 0) { var sublayer = new WebMapSubLayer(); sublayer.Id = 0; sublayer.FeatureSet = queryResult.FeatureSet; sublayer.LayerDefinition = layerDefinition; featureCollection = new FeatureCollection { SubLayers = new List <WebMapSubLayer> { sublayer } }; } return(new WebMapLayer { FeatureCollection = featureCollection, Title = "Earthquakes from last 7 days" }); } catch (Exception ex) { var _ = new MessageDialog(ex.Message, "Sample Error").ShowAsync(); return(null); } }
private async Task GenerateRenderer(GenerateRendererParameters rendererParam) { GenerateRendererResult result = await generateRendererTask.GenerateRendererAsync(rendererParam); LayerDrawingOptions layerDrawingOptions = null; LayerDrawingOptionCollection options = null; // If this is the first execution of this sample create a new LayerDrawingOptionsCollection if (((ArcGISDynamicMapServiceLayer)map.Layers["USA"]).LayerDrawingOptions == null) { options = new LayerDrawingOptionCollection(); // Add a new LayerDrawingOptions for layer ID 2 using the generated renderer options.Add(new LayerDrawingOptions() { LayerID = 2, Renderer = result.Renderer }); } else { // Otherwise the layer will have an existing LayerDrawingOptionsCollection from a previous button click options = ((ArcGISDynamicMapServiceLayer)map.Layers["USA"]).LayerDrawingOptions; // Iterate over the LayerDrawingOptionsCollection. // For layer ID 2 get the existing LayerDrawingOptions object and apply the newly generated renderer foreach (LayerDrawingOptions drawOption in options) { if (drawOption.LayerID == 2) { layerDrawingOptions = drawOption; drawOption.Renderer = result.Renderer; } } } // Retrieve the GenerateRendererParameters Where clause and create a new LayerDefinition for layer ID 2 if (!string.IsNullOrEmpty(rendererParam.Where)) { LayerDefinition layerDefinition = new LayerDefinition() { LayerID = 2, Definition = rendererParam.Where }; ((ArcGISDynamicMapServiceLayer)map.Layers["USA"]).LayerDefinitions = new ObservableCollection <LayerDefinition>() { layerDefinition }; } // Apply the updated LayerDrawingOptionsCollection to the LayerDrawingOptions property on the layer ((ArcGISDynamicMapServiceLayer)map.Layers["USA"]).LayerDrawingOptions = options; }
private void Editor_EditCompleted(object sender, Editor.EditEventArgs e) { var editor = sender as Editor; if (e.Action == Editor.EditAction.Select) { foreach (var edit in e.Edits) { if (edit.Graphic != null && edit.Graphic.Selected) { var layer = edit.Layer as FeatureLayer; if (layer != null && layer.IsGeometryUpdateAllowed(edit.Graphic)) { if (editor.EditVertices.CanExecute(edit.Graphic)) { editor.EditVertices.Execute(edit.Graphic); } FeatureInfoPage.Visibility = System.Windows.Visibility.Visible; symbolIDLB.SelectedIndex = (Int16)edit.Graphic.Attributes["symbolid"]; _featureDataFormOpen = true; LayerDefinition layerDefinition = new LayerDefinition() { LayerID = 2, Definition = string.Format("{0} <> {1}", layer.LayerInfo.ObjectIdField, edit.Graphic.Attributes[layer.LayerInfo.ObjectIdField].ToString()) }; (MyMap.Layers["WildFireDynamic"] as ArcGISDynamicMapServiceLayer).LayerDefinitions = new System.Collections.ObjectModel.ObservableCollection <LayerDefinition>() { layerDefinition }; (MyMap.Layers["WildFireDynamic"] as ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer).Refresh(); } FeatureInfoPage.DataContext = edit.Graphic; break; } } } else if (e.Action == Editor.EditAction.ClearSelection) { FeatureInfoPage.Visibility = System.Windows.Visibility.Collapsed; FeatureInfoPage.DataContext = null; (MyMap.Layers["WildFirePolygons"] as FeatureLayer).ClearSelection(); (MyMap.Layers["WildFireDynamic"] as ArcGISDynamicMapServiceLayer).LayerDefinitions = null; (MyMap.Layers["WildFireDynamic"] as ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer).Refresh(); } }
public void BuildIntGridValues() { RoundTilemapPos(); SortingOrder.Next(); GameObject tilemapGameObject = LayerGameObject.CreateChildGameObject(Layer.Type); /*if (Importer.DeparentInRuntime) * { * tilemapGameObject.AddComponent<LDtkDetachChildren>(); * }*/ Tilemap = tilemapGameObject.AddComponent <Tilemap>(); if (Importer.IntGridValueColorsVisible) { TilemapRenderer renderer = tilemapGameObject.AddComponent <TilemapRenderer>(); renderer.sortingOrder = SortingOrder.SortingOrderValue; } TilemapCollider2D collider = tilemapGameObject.AddComponent <TilemapCollider2D>(); int[] intGridValues = Layer.IntGridCsv.Select(p => (int)p).ToArray(); for (int i = 0; i < intGridValues.Length; i++) { int intGridValue = intGridValues[i]; //all empty intgrid values are 0 if (intGridValue == 0) { continue; } LayerDefinition intGridDef = Layer.Definition; IntGridValueDefinition intGridValueDef = intGridDef.IntGridValues[intGridValue - 1]; string intGridValueKey = LDtkKeyFormatUtil.IntGridValueFormat(intGridDef, intGridValueDef); LDtkIntGridTile intGridTile = Importer.GetIntGridValueTile(intGridValueKey); if (intGridTile == null) { intGridTile = LDtkResourcesLoader.LoadDefaultTile(); } BuildIntGridValue(intGridValueDef, i, intGridTile); } Tilemap.SetOpacity(Layer); }
public void BuildIntGridValues() { RoundTilemapPos(); SortingOrder.Next(); int[] intGridValues = Layer.IntGridCsv.Select(p => (int)p).ToArray(); for (int i = 0; i < intGridValues.Length; i++) { int intGridValue = intGridValues[i]; //all empty intgrid values are 0 if (intGridValue == 0) { continue; } LayerDefinition intGridDef = Layer.Definition; IntGridValueDefinition intGridValueDef = intGridDef.IntGridValues[intGridValue - 1]; string intGridValueKey = LDtkKeyFormatUtil.IntGridValueFormat(intGridDef, intGridValueDef); LDtkIntGridTile intGridTile = TryGetIntGridTile(intGridValueKey); if (intGridTile == null) { Debug.LogError("LDtk: Issue loading a IntGridTile. This is always expected to not be null"); continue; } TilemapKey key = new TilemapKey(intGridTile.TilemapTag, intGridTile.TilemapLayerMask, intGridTile.PhysicsMaterial); Tilemap tilemapToBuildOn = GetTilemapToBuildOn(key); BuildIntGridValue(tilemapToBuildOn, intGridValueDef, i, intGridTile); } foreach (KeyValuePair <TilemapKey, Tilemap> pair in _tilemaps) { TilemapKey key = pair.Key; Tilemap tilemap = pair.Value; tilemap.SetOpacity(Layer); AddLayerOffset(tilemap); GameObject obj = tilemap.gameObject; obj.tag = key.Tag; obj.layer = key.LayerMask; if (obj.TryGetComponent(out Rigidbody2D rb)) { rb.sharedMaterial = key.PhysicsMaterial; } } }
private void moveDownButton_Click(object sender, EventArgs e) { int index = listBox.SelectedIndex; LayerDefinition temp = layerDefinitions[index]; layerDefinitions[index] = layerDefinitions[index + 1]; layerDefinitions[index + 1] = temp; listBox.Items[index] = layerDefinitions[index].Name; listBox.Items[index + 1] = layerDefinitions[index + 1].Name; listBox.SelectedIndex = index + 1; }
/// <summary> /// Writes a binary file with this format: /// WORD width; /// WORD height; /// /// Followed by one word for each tile id /// /// </summary> /// <param name="name"></param> /// <param name="layer"></param> /// <param name="tileBpl"></param> /// <param name="tileWidth"></param> /// <param name="tileHeight"></param> public void Render(string name, LayerDefinition layer, int tileBpl, int tileWidth, int tileHeight) { _writer.StartObject(ObjectType.Layer, name); _writer.WriteCode(Code.Normal, $"LAYER_WIDTH_{name.ToUpperInvariant()}\t\tequ\t{layer.Width}"); _writer.WriteCode(Code.Normal, $"LAYER_HEIGHT_{name.ToUpperInvariant()}\t\tequ\t{layer.Height}"); foreach (var tileId in layer.TileIds) { // Pointer to tile instead of id would be // tileId * tileWinBytes * tileHeight * tileBpl _writer.WriteWord((ushort)((tileId) * tileWidth * tileHeight * tileBpl / 8)); } _writer.EndObject(); }
void generateRendererTask_ExecuteCompleted(object sender, GenerateRendererResultEventArgs e) { GenerateRendererResult rendererResult = e.GenerateRendererResult; LayerDrawingOptionsCollection options = (MyMap.Layers["USA"] as ArcGISDynamicMapServiceLayer).LayerDrawingOptions != null ? (MyMap.Layers["USA"] as ArcGISDynamicMapServiceLayer).LayerDrawingOptions : new LayerDrawingOptionsCollection(); LayerDrawingOptions layerDrawingOptionsParcels = null; foreach (LayerDrawingOptions drawOption in options) { if (drawOption.LayerID == 2) { layerDrawingOptionsParcels = drawOption; drawOption.Renderer = rendererResult.Renderer; } } if (e.UserState != null) { LayerDefinition layerDefinition = new LayerDefinition() { LayerID = 2, Definition = e.UserState as string }; (MyMap.Layers["USA"] as ArcGISDynamicMapServiceLayer).LayerDefinitions = new System.Collections.ObjectModel.ObservableCollection <LayerDefinition>() { layerDefinition }; } else { (MyMap.Layers["USA"] as ArcGISDynamicMapServiceLayer).LayerDefinitions = null; } if (layerDrawingOptionsParcels == null) { options.Add(new LayerDrawingOptions() { LayerID = 2, Renderer = rendererResult.Renderer }); } (MyMap.Layers["USA"] as ArcGISDynamicMapServiceLayer).LayerDrawingOptions = options; (MyMap.Layers["USA"] as ArcGISDynamicMapServiceLayer).Refresh(); }
public LayerButton(LayerDefinition definition, int y) { LayerDefinition = definition; InitializeComponent(); Location = new Point(0, y); pictureBox.Image = Image.FromFile(Path.Combine(Ogmo.ProgramDirectory, @"Content\layers", LayerDefinition.Image)); layerNameLabel.Text = definition.Name; //Init state selected = Ogmo.LayersWindow.CurrentLayerIndex != -1 && Ogmo.Project.LayerDefinitions[Ogmo.LayersWindow.CurrentLayerIndex] == LayerDefinition; layerNameLabel.BackColor = selected ? Selected : NotSelected; visibleCheckBox.Checked = LayerDefinition.Visible; //Add events Ogmo.LayersWindow.OnLayerChanged += onLayerChanged; }
private void Editor_EditCompleted(object sender, Editor.EditEventArgs e) { var editor = sender as Editor; if (e.Action == Editor.EditAction.Select) { foreach (var edit in e.Edits) { if (edit.Graphic != null && edit.Graphic.Selected) { var layer = edit.Layer as FeatureLayer; if (layer != null && layer.IsGeometryUpdateAllowed(edit.Graphic)) { if (editor.EditVertices.CanExecute(edit.Graphic)) editor.EditVertices.Execute(edit.Graphic); FeatureInfoPage.Visibility = System.Windows.Visibility.Visible; symbolIDLB.SelectedIndex = (Int16)edit.Graphic.Attributes["symbolid"]; _featureDataFormOpen = true; LayerDefinition layerDefinition = new LayerDefinition() { LayerID = 2, Definition = string.Format("{0} <> {1}", layer.LayerInfo.ObjectIdField, edit.Graphic.Attributes[layer.LayerInfo.ObjectIdField].ToString()) }; (MyMap.Layers["WildFireDynamic"] as ArcGISDynamicMapServiceLayer).LayerDefinitions = new System.Collections.ObjectModel.ObservableCollection<LayerDefinition>() { layerDefinition }; (MyMap.Layers["WildFireDynamic"] as ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer).Refresh(); } FeatureInfoPage.DataContext = edit.Graphic; break; } } } else if (e.Action == Editor.EditAction.ClearSelection) { FeatureInfoPage.Visibility = System.Windows.Visibility.Collapsed; FeatureInfoPage.DataContext = null; (MyMap.Layers["WildFirePolygons"] as FeatureLayer).ClearSelection(); (MyMap.Layers["WildFireDynamic"] as ArcGISDynamicMapServiceLayer).LayerDefinitions = null; (MyMap.Layers["WildFireDynamic"] as ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer).Refresh(); } }
private void typeComboBox_SelectionChangeCommitted(object sender, EventArgs e) { if (listBox.SelectedIndex == -1) { return; } LayerDefinition oldDef = layerDefinitions[GetLayerIDFromSelectedGroup()]; LayerDefinition newDef; newDef = (LayerDefinition)Activator.CreateInstance(LayerDefinition.LAYER_TYPES[typeComboBox.SelectedIndex]); newDef.Name = oldDef.Name; newDef.Grid = oldDef.Grid; layerDefinitions[GetLayerIDFromSelectedGroup()] = newDef; setControlsFromDefinition(newDef); }
public Layer( Document context, string title ) : base(context, PdfName.OCG) { Title = title; // Add this layer to the global collection! /* NOTE: Every layer MUST be included in the global collection [PDF:1.7:4.10.3]. */ LayerDefinition definition = context.Layer; if(definition == null) {context.Layer = definition = new LayerDefinition(context);} definition.AllLayersObject.Add(BaseObject); }
private void moveDownButton_Click(object sender, EventArgs e) { int index = listBox.SelectedIndex; if (index == -1) { return; } if (layerGroupComboBox.SelectedIndex > 0) { // A specific group is selected int cur, next; cur = next = 0; int num = 0; foreach (var ent in layerDefinitions) { if (ent.GroupName == layerGroupComboBox.SelectedItem.ToString()) { if (num == index) { cur = layerDefinitions.IndexOf(ent); } else if (num == index + 1) { next = layerDefinitions.IndexOf(ent); } num++; } } LayerDefinition tmp = layerDefinitions[next]; layerDefinitions[next] = layerDefinitions[cur]; layerDefinitions[cur] = tmp; } else { // The "All" group is selected LayerDefinition temp = layerDefinitions[index]; layerDefinitions[index] = layerDefinitions[index + 1]; layerDefinitions[index + 1] = temp; } RefreshListBoxItems(); listBox.SelectedIndex = index + 1; }
public static ILayerDefinition CreateDefault(LayerType type) { var lyr = new LayerDefinition(); switch (type) { case LayerType.Drawing: lyr.CreateDrawingLayer(); break; case LayerType.Raster: lyr.CreateRasterLayer(); break; case LayerType.Vector: lyr.CreateVectorLayer(); break; } return(lyr); }
private void setControlsFromDefinition(LayerDefinition definition) { //Enabled stuff removeButton.Enabled = true; moveUpButton.Enabled = listBox.SelectedIndex > 0; moveDownButton.Enabled = listBox.SelectedIndex < listBox.Items.Count - 1; nameTextBox.Enabled = true; gridXTextBox.Enabled = true; gridYTextBox.Enabled = true; scrollXTextBox.Enabled = true; scrollYTextBox.Enabled = true; typeComboBox.Enabled = true; itemGroupComboBox.Enabled = true; //Load properties nameTextBox.Text = definition.Name; gridXTextBox.Text = definition.Grid.Width.ToString(); gridYTextBox.Text = definition.Grid.Height.ToString(); scrollXTextBox.Text = definition.ScrollFactor.X.ToString(); scrollYTextBox.Text = definition.ScrollFactor.Y.ToString(); typeComboBox.SelectedIndex = LayerDefinition.LAYER_TYPES.FindIndex(e => e == definition.GetType()); //Remove the old layer editor if (layerEditor != null) { Controls.Remove(layerEditor); } //Add the new one layerEditor = definition.GetEditor(); if (layerEditor != null) { layerEditor.TabIndex = 6; Controls.Add(layerEditor); } // Get index of group from group name var gntemp = groups.groupNames.Where(ob => ob == definition.GroupName); itemGroupComboBox.SelectedIndex = (gntemp.Count() > 0 && gntemp.Single() != "") ? itemGroupComboBox.Items.IndexOf(gntemp.Single()) : 0; }
private void onLayerChanged(LayerDefinition def, int index) { Controls.Clear(); if (def != null) { tools = toolsForLayerTypes[def.GetType()]; for (int i = 0; i < tools.Length; i++) { Controls.Add(new ToolButton(tools[i], (i % 2) * 24, (i / 2) * 24, i)); } if (tools.Length > 0) { SetTool(tools[0]); } else { ClearTool(); } } }
void generateRendererTask_ExecuteCompleted(object sender, GenerateRendererResultEventArgs e) { GenerateRendererResult rendererResult = e.GenerateRendererResult; LayerDrawingOptionsCollection options = (MyMap.Layers["USA"] as ArcGISDynamicMapServiceLayer).LayerDrawingOptions != null ? (MyMap.Layers["USA"] as ArcGISDynamicMapServiceLayer).LayerDrawingOptions : new LayerDrawingOptionsCollection(); LayerDrawingOptions layerDrawingOptionsParcels = null; foreach (LayerDrawingOptions drawOption in options) if (drawOption.LayerID == 2) { layerDrawingOptionsParcels = drawOption; drawOption.Renderer = rendererResult.Renderer; } if (e.UserState != null) { LayerDefinition layerDefinition = new LayerDefinition() { LayerID = 2, Definition = e.UserState as string }; (MyMap.Layers["USA"] as ArcGISDynamicMapServiceLayer).LayerDefinitions = new System.Collections.ObjectModel.ObservableCollection<LayerDefinition>() { layerDefinition }; } else (MyMap.Layers["USA"] as ArcGISDynamicMapServiceLayer).LayerDefinitions = null; if (layerDrawingOptionsParcels == null) options.Add(new LayerDrawingOptions() { LayerID = 2, Renderer = rendererResult.Renderer }); (MyMap.Layers["USA"] as ArcGISDynamicMapServiceLayer).LayerDrawingOptions = options; (MyMap.Layers["USA"] as ArcGISDynamicMapServiceLayer).Refresh(); }
private void addButton_Click(object sender, EventArgs e) { LayerDefinition def = getDefaultLayer(); layerDefinitions.Add(def); listBox.SelectedIndex = -1; disableControls(); RefreshListBoxItems(); if (layerGroupComboBox.SelectedIndex == 0) // If the "All" group is selected { listBox.SelectedIndex = layerDefinitions.IndexOf(def); } else if (layerGroupComboBox.SelectedIndex > 0) { listBox.SelectedIndex = GetLayerListForCurrentSelection().Count() - 1; } if (layerDefinitions.Count == 0) { removeButton.Enabled = true; } }
public static ILayerDefinition CreateDefault(LayerType type) { var lyr = new LayerDefinition(); switch (type) { case LayerType.Drawing: lyr.CreateDrawingLayer(); break; case LayerType.Raster: lyr.CreateRasterLayer(); break; case LayerType.Vector: lyr.CreateVectorLayer(); break; } return lyr; }
private void onLayerChanged(LayerDefinition layer, int index) { selected = layer == LayerDefinition; layerNameLabel.BackColor = selected ? Selected : NotSelected; }
/** * <summary>Populates a PDF file with contents.</summary> */ private void Populate( Document document ) { // Initialize a new page! Page page = new Page(document); document.Pages.Add(page); // Initialize the primitive composer (within the new page context)! PrimitiveComposer composer = new PrimitiveComposer(page); composer.SetFont(new StandardType1Font(document, StandardType1Font.FamilyEnum.Helvetica, true, false), 12); // Initialize the block composer (wrapping the primitive one)! BlockComposer blockComposer = new BlockComposer(composer); // Initialize the document layer configuration! LayerDefinition layerDefinition = document.Layer; document.PageMode = Document.PageModeEnum.Layers; // Shows the layers tab on document opening. // Get the root layers collection! Layers rootLayers = layerDefinition.Layers; // 1. Nested layers. { Layer nestedLayer = new Layer(document, "Nested layers"); rootLayers.Add(nestedLayer); Layers nestedSubLayers = nestedLayer.Layers; Layer nestedLayer1 = new Layer(document, "Nested layer 1"); nestedSubLayers.Add(nestedLayer1); Layer nestedLayer2 = new Layer(document, "Nested layer 2"); nestedSubLayers.Add(nestedLayer2); nestedLayer2.Locked = true; /* * NOTE: Text in this section is shown using PrimitiveComposer. */ composer.BeginLayer(nestedLayer); composer.ShowText(nestedLayer.Title, new PointF(50, 50)); composer.End(); composer.BeginLayer(nestedLayer1); composer.ShowText(nestedLayer1.Title, new PointF(50, 75)); composer.End(); composer.BeginLayer(nestedLayer2); composer.ShowText(nestedLayer2.Title, new PointF(50, 100)); composer.End(); } // 2. Simple group (labeled group of non-nested, inclusive-state layers). { Layers simpleGroup = new Layers(document, "Simple group"); rootLayers.Add(simpleGroup); Layer layer1 = new Layer(document, "Grouped layer 1"); simpleGroup.Add(layer1); Layer layer2 = new Layer(document, "Grouped layer 2"); simpleGroup.Add(layer2); /* * NOTE: Text in this section is shown using BlockComposer along with PrimitiveComposer * to demonstrate their flexible cooperation. */ blockComposer.Begin(new RectangleF(50, 125, 200, 50), XAlignmentEnum.Left, YAlignmentEnum.Middle); composer.BeginLayer(layer1); blockComposer.ShowText(layer1.Title); composer.End(); blockComposer.ShowBreak(new SizeF(0, 15)); composer.BeginLayer(layer2); blockComposer.ShowText(layer2.Title); composer.End(); blockComposer.End(); } // 3. Radio group (labeled group of non-nested, exclusive-state layers). { Layers radioGroup = new Layers(document, "Radio group"); rootLayers.Add(radioGroup); Layer radio1 = new Layer(document, "Radiogrouped layer 1"); radioGroup.Add(radio1); radio1.Visible = true; Layer radio2 = new Layer(document, "Radiogrouped layer 2"); radioGroup.Add(radio2); radio2.Visible = false; Layer radio3 = new Layer(document, "Radiogrouped layer 3"); radioGroup.Add(radio3); radio3.Visible = false; // Register this option group in the layer configuration! LayerGroup options = new LayerGroup(document); options.Add(radio1); options.Add(radio2); options.Add(radio3); layerDefinition.OptionGroups.Add(options); /* * NOTE: Text in this section is shown using BlockComposer along with PrimitiveComposer * to demonstrate their flexible cooperation. */ blockComposer.Begin(new RectangleF(50, 185, 200, 75), XAlignmentEnum.Left, YAlignmentEnum.Middle); composer.BeginLayer(radio1); blockComposer.ShowText(radio1.Title); composer.End(); blockComposer.ShowBreak(new SizeF(0, 15)); composer.BeginLayer(radio2); blockComposer.ShowText(radio2.Title); composer.End(); blockComposer.ShowBreak(new SizeF(0, 15)); composer.BeginLayer(radio3); blockComposer.ShowText(radio3.Title); composer.End(); blockComposer.End(); } // 4. Print-only layer. { Layer printOnlyLayer = new Layer(document, "Print-only layer"); printOnlyLayer.Visible = false; printOnlyLayer.Printable = true; printOnlyLayer.Locked = true; rootLayers.Add(printOnlyLayer); composer.BeginLayer(printOnlyLayer); composer.ShowText(printOnlyLayer.Title, new PointF(50, 270)); composer.End(); } composer.Flush(); }
private async Task GenerateRenderer(GenerateRendererParameters rendererParam) { GenerateRendererResult result = await generateRendererTask.GenerateRendererAsync(rendererParam); LayerDrawingOptions layerDrawingOptions = null; LayerDrawingOptionCollection options = null; // If this is the first execution of this sample create a new LayerDrawingOptionsCollection if (((ArcGISDynamicMapServiceLayer)map.Layers["USA"]).LayerDrawingOptions == null) { options = new LayerDrawingOptionCollection(); // Add a new LayerDrawingOptions for layer ID 2 using the generated renderer options.Add(new LayerDrawingOptions() { LayerID = 2, Renderer = result.Renderer }); } else { // Otherwise the layer will have an existing LayerDrawingOptionsCollection from a previous button click options = ((ArcGISDynamicMapServiceLayer)map.Layers["USA"]).LayerDrawingOptions; // Iterate over the LayerDrawingOptionsCollection. // For layer ID 2 get the existing LayerDrawingOptions object and apply the newly generated renderer foreach (LayerDrawingOptions drawOption in options) { if (drawOption.LayerID == 2) { layerDrawingOptions = drawOption; drawOption.Renderer = result.Renderer; } } } // Retrieve the GenerateRendererParameters Where clause and create a new LayerDefinition for layer ID 2 if (!string.IsNullOrEmpty(rendererParam.Where)) { LayerDefinition layerDefinition = new LayerDefinition() { LayerID = 2, Definition = rendererParam.Where }; ((ArcGISDynamicMapServiceLayer)map.Layers["USA"]).LayerDefinitions = new ObservableCollection<LayerDefinition>() { layerDefinition }; } // Apply the updated LayerDrawingOptionsCollection to the LayerDrawingOptions property on the layer ((ArcGISDynamicMapServiceLayer)map.Layers["USA"]).LayerDrawingOptions = options; }
public Layer(Level level, LayerDefinition definition) { Level = level; Definition = definition; }
public MapGuideLayer(ServerConnectionI con, string layername) { m_con = con; m_layerDef = m_con.GetLayerDefinition(layername); if (!(m_layerDef.Item is VectorLayerDefinitionType)) throw new Exception("The resource " + layername + " is not a vector layer"); VectorLayerDefinitionType vldef = m_layerDef.Item as VectorLayerDefinitionType; m_columnnames = new Dictionary<string, string>(); m_columnnames[vldef.Geometry] = null; ExtractColumnNames(vldef.Url, m_columnnames); ExtractColumnNames(vldef.ToolTip, m_columnnames); try { FeatureSource fs = m_con.GetFeatureSource(vldef.ResourceId); FdoSpatialContextList lst = fs.GetSpatialInfo(); if (lst != null && lst.SpatialContext != null && lst.SpatialContext.Count > 0) { Topology.CoordinateSystems.CoordinateSystemFactory cf = new Topology.CoordinateSystems.CoordinateSystemFactory(); m_coordSys = cf.CreateFromWkt(lst.SpatialContext[0].CoordinateSystemWkt); } } catch { } foreach (VectorScaleRangeType vsr in vldef.VectorScaleRange) { ScaleRange sr = new ScaleRange(vsr.MinScaleSpecified ? vsr.MinScale : 0, vsr.MaxScaleSpecified ? vsr.MaxScale : double.MaxValue); foreach (object style in vsr.Items) if (style is PointTypeStyleType) { if (((PointTypeStyleType)style).PointRule != null) foreach (PointRuleType rule in ((PointTypeStyleType)style).PointRule) { if (rule.Item != null && rule.Item.Item != null) { OperationOrParameter op = ExtractColumnNames(rule.Filter, m_columnnames); if (rule.Label != null) ExtractColumnNames(rule.Label.Text, m_columnnames); LittleSharpRenderEngine.Style.Point p = new LittleSharpRenderEngine.Style.Point(); p.Center = new System.Drawing.Point( (int)(rule.Item.Item.InsertionPointXSpecified ? rule.Item.Item.InsertionPointX : 0.5), (int)(rule.Item.Item.InsertionPointYSpecified ? rule.Item.Item.InsertionPointY : 0.5)); p.Rotation = double.Parse(rule.Item.Item.Rotation, System.Globalization.CultureInfo.InvariantCulture); p.Size = new System.Drawing.Size( (int)double.Parse(rule.Item.Item.SizeX, System.Globalization.CultureInfo.InvariantCulture), (int)double.Parse(rule.Item.Item.SizeY, System.Globalization.CultureInfo.InvariantCulture)); if (rule.Item.Item is MarkSymbolType) { MarkSymbolType mark = rule.Item.Item as MarkSymbolType; switch (mark.Shape) { case ShapeType.Circle: p.Type = LittleSharpRenderEngine.Style.Point.PointType.Circle; break; case ShapeType.Square: p.Type = LittleSharpRenderEngine.Style.Point.PointType.Square; break; case ShapeType.Triangle: p.Type = LittleSharpRenderEngine.Style.Point.PointType.Triangle; break; default: p.Type = LittleSharpRenderEngine.Style.Point.PointType.Circle; break; } if (mark.Fill != null) { p.Fill = new LittleSharpRenderEngine.Style.Base.Fill(); p.Fill.BackgroundColor = mark.Fill.BackgroundColor; p.Fill.ForegroundColor = mark.Fill.ForegroundColor; //p.Fill.Pattern = mark.Fill.FillPattern; //TODO: Deal with unit/sizecontext } if (mark.Edge != null) { p.Outline = new LittleSharpRenderEngine.Style.Base.Outline(); p.Outline.ForegroundColor = mark.Edge.Color; //p.Outline.DashStyle = mark.Edge.LineStyle; //p.Outline.Pattern = mark.Edge.LineStyle; p.Outline.Width = (int)double.Parse(mark.Edge.Thickness, System.Globalization.CultureInfo.InvariantCulture); //TODO: Deal with unit/sizecontext } } else { p.Type = LittleSharpRenderEngine.Style.Point.PointType.Circle; p.Outline = new LittleSharpRenderEngine.Style.Base.Outline(); p.Fill = new LittleSharpRenderEngine.Style.Base.Fill(); p.Fill.BackgroundColor = System.Drawing.Color.Red; p.Fill.ForegroundColor = System.Drawing.Color.Black; p.Outline.ForegroundColor = System.Drawing.Color.Black; } sr.PointRules.Add(new KeyValuePair<OperationOrParameter, IPointStyle>(op, p)); } } } else if (style is LineTypeStyleType) { if (((LineTypeStyleType)style).LineRule != null) foreach (LineRuleType rule in ((LineTypeStyleType)style).LineRule) { if (rule.Items != null && rule.Items.Count > 0) { List<IOutline> lines = new List<IOutline>(); OperationOrParameter op = ExtractColumnNames(rule.Filter, m_columnnames); if (rule.Label != null) ExtractColumnNames(rule.Label.Text, m_columnnames); foreach (StrokeType st in rule.Items) { LittleSharpRenderEngine.Style.Base.Outline outline = new LittleSharpRenderEngine.Style.Base.Outline(); outline.ForegroundColor = st.Color; outline.Width = (int)double.Parse(st.Thickness, System.Globalization.CultureInfo.InvariantCulture); //outline.Pattern = st.LineStyle; //outline.DashStyle = st.LineStyle; //TODO: Deal with unit/sizecontext lines.Add(outline); } sr.LineRules.Add(new KeyValuePair<OperationOrParameter, ILineStyle>(op, new LittleSharpRenderEngine.Style.Line(lines))); } } } else if (style is AreaTypeStyleType) { if (((AreaTypeStyleType)style).AreaRule != null) foreach (AreaRuleType rule in ((AreaTypeStyleType)style).AreaRule) { OperationOrParameter op = ExtractColumnNames(rule.Filter, m_columnnames); if (rule.Label != null) ExtractColumnNames(rule.Label.Text, m_columnnames); LittleSharpRenderEngine.Style.Area a = new Area(); if (rule.Item != null) { if (rule.Item.Fill != null) { a.Fill = new LittleSharpRenderEngine.Style.Base.Fill(); a.Fill.BackgroundColor = rule.Item.Fill.BackgroundColor; a.Fill.ForegroundColor = rule.Item.Fill.ForegroundColor; //p.Fill.Pattern = rule.Item.Fill.FillPattern; //TODO: Deal with unit/sizecontext } if (rule.Item.Stroke != null) { a.Outline = new LittleSharpRenderEngine.Style.Base.Outline(); a.Outline.ForegroundColor = rule.Item.Stroke.Color; //p.Outline.DashStyle = rule.Item.Stroke.LineStyle; //p.Outline.Pattern = rule.Item.Stroke.LineStyle; a.Outline.Width = (int)double.Parse(rule.Item.Stroke.Thickness, System.Globalization.CultureInfo.InvariantCulture); //TODO: Deal with unit/sizecontext } sr.AreaRules.Add(new KeyValuePair<OperationOrParameter, IAreaStyle>(op, a)); } } } if (sr.PointRules.Count + sr.LineRules.Count + sr.AreaRules.Count > 0) m_scaleRanges.Add(sr); } }
/** * <summary>Populates a PDF file with contents.</summary> */ private void Populate(Document document) { // Initialize a new page! Page page = new Page(document); document.Pages.Add(page); // Initialize the primitive composer (within the new page context)! PrimitiveComposer composer = new PrimitiveComposer(page); composer.SetFont(PdfType1Font.Load(document, PdfType1Font.FamilyEnum.Helvetica, true, false), 12); // Initialize the block composer (wrapping the primitive one)! BlockComposer blockComposer = new BlockComposer(composer); // Initialize the document layer configuration! LayerDefinition layerDefinition = document.Layer; document.ViewerPreferences.PageMode = ViewerPreferences.PageModeEnum.Layers; // Shows the layers tab on document opening. // Get the root collection of the layers displayed to the user! UILayers uiLayers = layerDefinition.UILayers; // Nested layers. Layer parentLayer; { parentLayer = new Layer(document, "Parent layer"); uiLayers.Add(parentLayer); var childLayers = parentLayer.Children; var childLayer1 = new Layer(document, "Child layer 1"); childLayers.Add(childLayer1); var childLayer2 = new Layer(document, "Child layer 2"); childLayers.Add(childLayer2); childLayer2.Locked = true; /* * NOTE: Graphical content can be controlled through layers in two ways: * 1) marking content within content streams (that is content within the page body); * 2) associating annotations and external objects (XObject) to the layers. */ XObject imageXObject = entities::Image.Get(GetResourcePath("images" + Path.DirectorySeparatorChar + "gnu.jpg")).ToXObject(document); imageXObject.Layer = childLayer1; // Associates the image to the layer. composer.ShowXObject(imageXObject, new SKPoint(200, 75)); composer.BeginLayer(parentLayer); // Opens a marked block associating its contents with the specified layer. composer.ShowText(parentLayer.Title, new SKPoint(50, 50)); composer.End(); // Closes the marked block. composer.BeginLayer(childLayer1); composer.ShowText(childLayer1.Title, new SKPoint(50, 75)); composer.End(); composer.BeginLayer(childLayer2); composer.ShowText(childLayer2.Title, new SKPoint(50, 100)); composer.End(); } // Simple layer collection (labeled collection of inclusive-state layers). Layer simpleLayer1; { var simpleLayerCollection = new LayerCollection(document, "Simple layer collection"); uiLayers.Add(simpleLayerCollection); simpleLayer1 = new Layer(document, "Simple layer 1"); simpleLayerCollection.Add(simpleLayer1); var simpleLayer2 = new Layer(document, "Simple layer 2 (Design)"); /* * NOTE: Intent limits layer use in determining visibility to specific use contexts. In this * case, we want to mark content as intended to represent a document designer's structural * organization of artwork, hence it's outside the interactive use by document consumers. */ simpleLayer2.Intents = new HashSet <PdfName> { IntentEnum.Design.Name() }; simpleLayerCollection.Add(simpleLayer2); var simpleLayer3 = new Layer(document, "Simple layer 3"); simpleLayerCollection.Add(simpleLayer3); blockComposer.Begin(SKRect.Create(50, 125, 200, 75), XAlignmentEnum.Left, YAlignmentEnum.Middle); composer.BeginLayer(simpleLayer1); blockComposer.ShowText(simpleLayer1.Title); composer.End(); blockComposer.ShowBreak(new SKSize(0, 10)); composer.BeginLayer(simpleLayer2); blockComposer.ShowText(simpleLayer2.Title); composer.End(); blockComposer.ShowBreak(new SKSize(0, 10)); composer.BeginLayer(simpleLayer3); blockComposer.ShowText(simpleLayer3.Title); composer.End(); blockComposer.End(); } // Radio layer collection (labeled collection of exclusive-state layers). Layer radioLayer2; { var radioLayerCollection = new LayerCollection(document, "Radio layer collection"); uiLayers.Add(radioLayerCollection); var radioLayer1 = new Layer(document, "Radio layer 1") { Visible = true }; radioLayerCollection.Add(radioLayer1); radioLayer2 = new Layer(document, "Radio layer 2") { Visible = false }; radioLayerCollection.Add(radioLayer2); var radioLayer3 = new Layer(document, "Radio layer 3") { Visible = false }; radioLayerCollection.Add(radioLayer3); // Register this option group in the layer configuration! var optionGroup = new OptionGroup(document) { radioLayer1, radioLayer2, radioLayer3 }; layerDefinition.OptionGroups.Add(optionGroup); blockComposer.Begin(SKRect.Create(50, 200, 200, 75), XAlignmentEnum.Left, YAlignmentEnum.Middle); composer.BeginLayer(radioLayer1); blockComposer.ShowText(radioLayer1.Title); composer.End(); blockComposer.ShowBreak(new SKSize(0, 10)); composer.BeginLayer(radioLayer2); blockComposer.ShowText(radioLayer2.Title); composer.End(); blockComposer.ShowBreak(new SKSize(0, 10)); composer.BeginLayer(radioLayer3); blockComposer.ShowText(radioLayer3.Title); composer.End(); blockComposer.End(); } // Layer state action. { var actionLayer = new Layer(document, "Action layer") { Printable = false }; composer.BeginLayer(actionLayer); composer.BeginLocalState(); composer.SetFillColor(colors::DeviceRGBColor.Get(SKColors.Blue)); composer.ShowText( "Layer state action:\n * deselect \"" + simpleLayer1.Title + "\"\n and \"" + radioLayer2.Title + "\"\n * toggle \"" + parentLayer.Title + "\"", new SKPoint(400, 200), XAlignmentEnum.Left, YAlignmentEnum.Middle, 0, new SetLayerState( document, new SetLayerState.LayerState(SetLayerState.StateModeEnum.Off, simpleLayer1, radioLayer2), new SetLayerState.LayerState(SetLayerState.StateModeEnum.Toggle, parentLayer) ) ); composer.End(); composer.End(); } // Zoom-restricted layer. { var zoomRestrictedLayer = new Layer(document, "Zoom-restricted layer") { ZoomRange = new Interval <double>(.75, 1.251) }; // NOTE: Change this interval to test other magnification ranges. composer.BeginLayer(zoomRestrictedLayer); new TextMarkup( page, composer.ShowText(zoomRestrictedLayer.Title + ": this text is only visible if zoom between 75% and 125%", new SKPoint(50, 290)), "This is a highlight annotation visible only if zoom is between 75% and 125%", TextMarkupType.Highlight ) { Layer = zoomRestrictedLayer /* Associates the annotation to the layer. */ }; composer.End(); } // Print-only layer. { var printOnlyLayer = new Layer(document, "Print-only layer") { Visible = false, Printable = true }; composer.BeginLayer(printOnlyLayer); composer.BeginLocalState(); composer.SetFillColor(colors::DeviceRGBColor.Get(SKColors.Red)); composer.ShowText(printOnlyLayer.Title, new SKPoint(25, 300), XAlignmentEnum.Left, YAlignmentEnum.Top, 90); composer.End(); composer.End(); } // Language-specific layer. { var languageLayer = new Layer(document, "Language-specific layer") { Language = new LanguageIdentifier("en-GB"), // NOTE: Change this to test other languages and locales. LanguagePreferred = true, // Matches any system locale (e.g. en-US, en-AU...) if layer language (en-GB) doesn't match exactly the system language. Printable = false }; blockComposer.Begin(SKRect.Create(50, 320, 500, 75), XAlignmentEnum.Left, YAlignmentEnum.Top); composer.BeginLayer(languageLayer); blockComposer.ShowText(languageLayer.Title + ": this text is visible only if current system language is english (\"en\", any locale (\"en-US\", \"en-GB\", \"en-NZ\", etc.)) and is hidden on print."); composer.End(); blockComposer.End(); } // User-specific layer. { var userLayer = new Layer(document, "User-specific layer") { Users = new List <string> { "Lizbeth", "Alice", "Stefano", "Johann" }, // NOTE: Change these entries to test other user names. UserType = Layer.UserTypeEnum.Individual }; blockComposer.Begin(SKRect.Create(blockComposer.BoundBox.Left, blockComposer.BoundBox.Bottom + 15, blockComposer.BoundBox.Width, 75), XAlignmentEnum.Left, YAlignmentEnum.Top); composer.BeginLayer(userLayer); blockComposer.ShowText(userLayer.Title + ": this text is visible only to " + String.Join(", ", userLayer.Users) + " (exact match)."); composer.End(); blockComposer.End(); } // Layer membership (composite layer visibility). { var layerMembership = new LayerMembership(document) { /* * NOTE: VisibilityExpression is a more flexible alternative to the combination of * VisibilityPolicy and VisibilityMembers. However, for compatibility purposes is preferable * to provide both of them (the latter combination will work as a fallback in case of older * viewer application). */ VisibilityExpression = new VisibilityExpression( document, VisibilityExpression.OperatorEnum.And, new VisibilityExpression( document, VisibilityExpression.OperatorEnum.Not, new VisibilityExpression( document, VisibilityExpression.OperatorEnum.Or, simpleLayer1, radioLayer2 ) ), parentLayer ), VisibilityPolicy = LayerMembership.VisibilityPolicyEnum.AnyOff, VisibilityMembers = new List <Layer> { simpleLayer1, radioLayer2, parentLayer } }; blockComposer.Begin(SKRect.Create(blockComposer.BoundBox.Left, blockComposer.BoundBox.Bottom + 15, blockComposer.BoundBox.Width, 75), XAlignmentEnum.Left, YAlignmentEnum.Top); composer.BeginLayer(layerMembership); blockComposer.ShowText(String.Format("Layer membership: the visibility of this text is computed combining multiple layer states into an expression (\"{0}\" and \"{1}\" must be OFF while \"{2}\" must be ON).", simpleLayer1.Title, radioLayer2.Title, parentLayer.Title)); composer.End(); blockComposer.End(); } composer.Flush(); }
private void onLayerChanged(LayerDefinition def, int index) { EditorVisible = def is EntityLayerDefinition; }
public InputLayer(IInputReceiver receiver, LayerDefinition definition) { Receiver = receiver; Definition = definition; }
public override void Run( ) { // 1. Opening the PDF file... string filePath = PromptFileChoice("Please select a PDF file"); using (var file = new File(filePath)) { Document document = file.Document; // 2. Get the layer definition! LayerDefinition layerDefinition = document.Layer; if (!layerDefinition.Exists()) { Console.WriteLine("\nNo layer definition available."); } else { while (true) { var layers = new List <Layer>(); // 3.1. Show structured layers! Console.WriteLine("\nLayer structure:\n"); ShowUILayers(layerDefinition.UILayers, 0, layers); // 3.2. Show unstructured layers! bool hiddenShown = false; foreach (var layer in layerDefinition.Layers) // NOTE: LayerDefinition.Layers comprises all the layers (both structured and unstructured). { if (!layers.Contains(layer)) { if (!hiddenShown) { Console.WriteLine("Hidden layers (not displayed in the viewer panel)"); hiddenShown = true; } ShowLayer(layer, layers.Count, " "); layers.Add(layer); } } Console.WriteLine("[Q] Exit"); string choice; while (true) { choice = PromptChoice("Choose a layer to remove:").ToUpper(); if ("Q".Equals(choice)) { break; } else { int layerIndex; try { layerIndex = Int32.Parse(choice); } catch { continue; } if (layerIndex < 0 || layerIndex >= layers.Count) { continue; } Console.WriteLine("\nWhat to do with the contents associated to the removed layer?"); var contentRemovalOptions = new Dictionary <string, string>(StringComparer.Ordinal) { { "0", "Remove layered content" }, { "1", "Flatten layered content" } }; int contentRemovalChoice; try { contentRemovalChoice = Int32.Parse(PromptChoice(contentRemovalOptions)); } catch { contentRemovalChoice = 0; } // 4. Remove the chosen layer! layers[layerIndex].Delete(contentRemovalChoice == 1); break; } } if ("Q".Equals(choice)) { break; } } if (file.Updated) { Serialize(file, "Layer editing", "removing layers", "layers, optional content"); } } } }
// Create webmap layer out of a feature set from a query task private async Task<WebMapLayer> CreateFeatureCollectionLayer() { try { //Perform Query to get a featureSet and add to webmap as featurecollection QueryTask qt = new QueryTask( new Uri("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/EarthquakesFromLastSevenDays/MapServer/0")); Esri.ArcGISRuntime.Tasks.Query.Query query = new Esri.ArcGISRuntime.Tasks.Query.Query("magnitude > 3.5"); query.OutFields.Add("*"); query.ReturnGeometry = true; var queryResult = await qt.ExecuteAsync(query); var simpleRenderer = new SimpleRenderer { Symbol = new SimpleMarkerSymbol { Style = SimpleMarkerStyle.Circle, Color = Color.FromArgb(255, 0, 0, 255), Size = 8 } }; var drawingInfo = new DrawingInfo { Renderer = simpleRenderer }; var layerDefinition = new LayerDefinition {DrawingInfo = drawingInfo}; //Create FeatureCollection as webmap layer FeatureCollection featureCollection = null; if (queryResult.FeatureSet.Features.Count > 0) { var sublayer = new WebMapSubLayer(); sublayer.Id = 0; sublayer.FeatureSet = queryResult.FeatureSet; sublayer.LayerDefinition = layerDefinition; featureCollection = new FeatureCollection { SubLayers = new List<WebMapSubLayer> { sublayer } }; } return new WebMapLayer { FeatureCollection = featureCollection, Title = "Earthquakes from last 7 days" }; } catch (Exception ex) { MessageBox.Show(ex.Message, "Sample Error"); return null; } }
public static ILayerDefinition CreateDefault(LayerType type) { return(LayerDefinition.CreateDefault(type)); }
public static IResource Deserialize(string xml) { return(LayerDefinition.Deserialize(xml)); }
public MapGuideLayer(ServerConnectionI con, string layername) { m_con = con; m_layerDef = m_con.GetLayerDefinition(layername); if (!(m_layerDef.Item is VectorLayerDefinitionType)) { throw new Exception("The resource " + layername + " is not a vector layer"); } VectorLayerDefinitionType vldef = m_layerDef.Item as VectorLayerDefinitionType; m_columnnames = new Dictionary <string, string>(); m_columnnames[vldef.Geometry] = null; ExtractColumnNames(vldef.Url, m_columnnames); ExtractColumnNames(vldef.ToolTip, m_columnnames); try { FeatureSource fs = m_con.GetFeatureSource(vldef.ResourceId); FdoSpatialContextList lst = fs.GetSpatialInfo(); if (lst != null && lst.SpatialContext != null && lst.SpatialContext.Count > 0) { Topology.CoordinateSystems.CoordinateSystemFactory cf = new Topology.CoordinateSystems.CoordinateSystemFactory(); m_coordSys = cf.CreateFromWkt(lst.SpatialContext[0].CoordinateSystemWkt); } } catch { } foreach (VectorScaleRangeType vsr in vldef.VectorScaleRange) { ScaleRange sr = new ScaleRange(vsr.MinScaleSpecified ? vsr.MinScale : 0, vsr.MaxScaleSpecified ? vsr.MaxScale : double.MaxValue); foreach (object style in vsr.Items) { if (style is PointTypeStyleType) { if (((PointTypeStyleType)style).PointRule != null) { foreach (PointRuleType rule in ((PointTypeStyleType)style).PointRule) { if (rule.Item != null && rule.Item.Item != null) { OperationOrParameter op = ExtractColumnNames(rule.Filter, m_columnnames); if (rule.Label != null) { ExtractColumnNames(rule.Label.Text, m_columnnames); } LittleSharpRenderEngine.Style.Point p = new LittleSharpRenderEngine.Style.Point(); p.Center = new System.Drawing.Point( (int)(rule.Item.Item.InsertionPointXSpecified ? rule.Item.Item.InsertionPointX : 0.5), (int)(rule.Item.Item.InsertionPointYSpecified ? rule.Item.Item.InsertionPointY : 0.5)); p.Rotation = double.Parse(rule.Item.Item.Rotation, System.Globalization.CultureInfo.InvariantCulture); p.Size = new System.Drawing.Size( (int)double.Parse(rule.Item.Item.SizeX, System.Globalization.CultureInfo.InvariantCulture), (int)double.Parse(rule.Item.Item.SizeY, System.Globalization.CultureInfo.InvariantCulture)); if (rule.Item.Item is MarkSymbolType) { MarkSymbolType mark = rule.Item.Item as MarkSymbolType; switch (mark.Shape) { case ShapeType.Circle: p.Type = LittleSharpRenderEngine.Style.Point.PointType.Circle; break; case ShapeType.Square: p.Type = LittleSharpRenderEngine.Style.Point.PointType.Square; break; case ShapeType.Triangle: p.Type = LittleSharpRenderEngine.Style.Point.PointType.Triangle; break; default: p.Type = LittleSharpRenderEngine.Style.Point.PointType.Circle; break; } if (mark.Fill != null) { p.Fill = new LittleSharpRenderEngine.Style.Base.Fill(); p.Fill.BackgroundColor = mark.Fill.BackgroundColor; p.Fill.ForegroundColor = mark.Fill.ForegroundColor; //p.Fill.Pattern = mark.Fill.FillPattern; //TODO: Deal with unit/sizecontext } if (mark.Edge != null) { p.Outline = new LittleSharpRenderEngine.Style.Base.Outline(); p.Outline.ForegroundColor = mark.Edge.Color; //p.Outline.DashStyle = mark.Edge.LineStyle; //p.Outline.Pattern = mark.Edge.LineStyle; p.Outline.Width = (int)double.Parse(mark.Edge.Thickness, System.Globalization.CultureInfo.InvariantCulture); //TODO: Deal with unit/sizecontext } } else { p.Type = LittleSharpRenderEngine.Style.Point.PointType.Circle; p.Outline = new LittleSharpRenderEngine.Style.Base.Outline(); p.Fill = new LittleSharpRenderEngine.Style.Base.Fill(); p.Fill.BackgroundColor = System.Drawing.Color.Red; p.Fill.ForegroundColor = System.Drawing.Color.Black; p.Outline.ForegroundColor = System.Drawing.Color.Black; } sr.PointRules.Add(new KeyValuePair <OperationOrParameter, IPointStyle>(op, p)); } } } } else if (style is LineTypeStyleType) { if (((LineTypeStyleType)style).LineRule != null) { foreach (LineRuleType rule in ((LineTypeStyleType)style).LineRule) { if (rule.Items != null && rule.Items.Count > 0) { List <IOutline> lines = new List <IOutline>(); OperationOrParameter op = ExtractColumnNames(rule.Filter, m_columnnames); if (rule.Label != null) { ExtractColumnNames(rule.Label.Text, m_columnnames); } foreach (StrokeType st in rule.Items) { LittleSharpRenderEngine.Style.Base.Outline outline = new LittleSharpRenderEngine.Style.Base.Outline(); outline.ForegroundColor = st.Color; outline.Width = (int)double.Parse(st.Thickness, System.Globalization.CultureInfo.InvariantCulture); //outline.Pattern = st.LineStyle; //outline.DashStyle = st.LineStyle; //TODO: Deal with unit/sizecontext lines.Add(outline); } sr.LineRules.Add(new KeyValuePair <OperationOrParameter, ILineStyle>(op, new LittleSharpRenderEngine.Style.Line(lines))); } } } } else if (style is AreaTypeStyleType) { if (((AreaTypeStyleType)style).AreaRule != null) { foreach (AreaRuleType rule in ((AreaTypeStyleType)style).AreaRule) { OperationOrParameter op = ExtractColumnNames(rule.Filter, m_columnnames); if (rule.Label != null) { ExtractColumnNames(rule.Label.Text, m_columnnames); } LittleSharpRenderEngine.Style.Area a = new Area(); if (rule.Item != null) { if (rule.Item.Fill != null) { a.Fill = new LittleSharpRenderEngine.Style.Base.Fill(); a.Fill.BackgroundColor = rule.Item.Fill.BackgroundColor; a.Fill.ForegroundColor = rule.Item.Fill.ForegroundColor; //p.Fill.Pattern = rule.Item.Fill.FillPattern; //TODO: Deal with unit/sizecontext } if (rule.Item.Stroke != null) { a.Outline = new LittleSharpRenderEngine.Style.Base.Outline(); a.Outline.ForegroundColor = rule.Item.Stroke.Color; //p.Outline.DashStyle = rule.Item.Stroke.LineStyle; //p.Outline.Pattern = rule.Item.Stroke.LineStyle; a.Outline.Width = (int)double.Parse(rule.Item.Stroke.Thickness, System.Globalization.CultureInfo.InvariantCulture); //TODO: Deal with unit/sizecontext } sr.AreaRules.Add(new KeyValuePair <OperationOrParameter, IAreaStyle>(op, a)); } } } } } if (sr.PointRules.Count + sr.LineRules.Count + sr.AreaRules.Count > 0) { m_scaleRanges.Add(sr); } } }