private void UpdateGroupsDropdown(LayerGroup group) { // Clear Sites Dropdown groupDropdown.onValueChanged.RemoveListener(OnGroupDropdownChanged); groupDropdown.ClearOptions(); // Populate Sites Dropdown var groups = dataManager.groups; if (groups.Count > 0) { List <string> options = new List <string>(); foreach (var g in groups) { options.Add(g.name); } groupDropdown.AddOptions(options); if (group != null) { groupDropdown.value = groups.IndexOf(group); } groupDropdown.onValueChanged.AddListener(OnGroupDropdownChanged); } }
protected override void Edit(LayerGroup layerGroup) { // For now it will only draw on the bottommost layer in the group Layer currentLayer = layerGroup[0]; int tileX = this.tileX; int tileY = this.tileY; if (tileSheet != null) { if (tileX <= currentLayer.tiles.GetUpperBound(0) && tileY <= currentLayer.tiles.GetUpperBound(1)) { SpriteSheet.Gfx oldGfx = currentLayer.tiles[tileX, tileY].gfx; SpriteSheet.Gfx newGfx = (id == 0) ? SpriteSheet.Gfx.Empty : new SpriteSheet.Gfx(id - 1, tileSheet); if (oldGfx != newGfx) { AddCommand( delegate() { currentLayer.tiles[tileX, tileY].gfx = newGfx; }, delegate() { currentLayer.tiles[tileX, tileY].gfx = oldGfx; } ); } } } }
private void SetActiveGroup(LayerGroup group, Toggle toggle) { var newActiveSection = toggle.transform.parent.parent.GetChild(1).gameObject; if (activeSection != newActiveSection) { // Retrieve new section current position var groupSection = newActiveSection.transform.parent as RectTransform; var yPos = groupSection.localPosition.y + layersList.content.localPosition.y; var sectionTop = yPos + groupSection.rect.yMax; if (activeSection != null) { activeSection.SetActive(false); } activeSection = newActiveSection; activeSection.SetActive(true); GuiUtils.RebuildLayout(activeSection.transform); StartCoroutine(AdjustListScroll(sectionTop)); } activeGroup = group; activeGroupToggle = toggle; activeLayer = null; activeLayerToggle = null; ShowGroupProperties(group); UpdateListButtons(); }
private void DeleteActiveGroup() { if (activeSite != null) { return; } LayerGroup selectedGroup = null; int index = visibleGroups.IndexOf(activeGroup); if (index < visibleGroups.Count - 1) { selectedGroup = visibleGroups[index + 1]; } else if (index > 0) { selectedGroup = visibleGroups[index - 1]; } for (int i = activeGroup.layers.Count - 1; i >= 0; i--) { DeleteLayer(activeGroup.layers[i]); } dataManager.RemoveLayerGroup(activeGroup); UpdateLayerList(activeGroup); UpdateListButtons(); }
private void OnGroupToggleChanged(LayerGroup group, Toggle toggle) { if (toggle.isOn) { CheckForChanges(() => SetActiveGroup(group, toggle)); } }
public void Clone_ClonesTheProperties() { var group = new LayerGroup("group"); group.CoordinateTransformation = CreateTransformation(); group.Enabled = true; group.IsQueryEnabled = true; group.MinVisible = 10; group.MaxVisible = 100; group.SRID = 4326; group.Proj4Projection = "dummy"; group.TargetSRID = 4327; group.Style = new LabelStyle(); var clonedGroup = (LayerGroup)group.Clone(); Assert.That(clonedGroup.CoordinateTransformation, Is.EqualTo(group.CoordinateTransformation), "CoordinateTransformation mismatch"); Assert.That(clonedGroup.Enabled, Is.EqualTo(group.Enabled), "Enabled mismatch"); Assert.That(clonedGroup.IsQueryEnabled, Is.EqualTo(group.IsQueryEnabled), "IsQueryEnabled mismatch"); Assert.That(clonedGroup.MinVisible, Is.EqualTo(group.MinVisible), "MinVisible mismatch"); Assert.That(clonedGroup.MaxVisible, Is.EqualTo(group.MaxVisible), "MaxVisible mismatch"); Assert.That(clonedGroup.SRID, Is.EqualTo(group.SRID), "SRID mismatch"); Assert.That(clonedGroup.Proj4Projection, Is.EqualTo(group.Proj4Projection), "Proj4Projection mismatch"); Assert.That(clonedGroup.TargetSRID, Is.EqualTo(group.TargetSRID), "TargetSRID mismatch"); Assert.That(clonedGroup.Style, Is.EqualTo(group.Style), "Style mismatch"); }
public void Stop(int layer, float blendTime = 0.0f, InterpolationType easeType = InterpolationType.InOutSine, PlayMode playMode = PlayMode.StopSameLayer) { LayerGroup layerGroup = GetLayerGroup(layer); if (layerGroup != null) { if (blendTime > 0.0f) { layerGroup._state = LayerGroup.State.Stopping; layerGroup._lerpSpeed = 1.0f / blendTime; layerGroup._lerpT = 0.0f; layerGroup._lerpEase = easeType; layerGroup._playMode = playMode; if (IsLayerChannelPlaying(layerGroup._primaryLayer)) { layerGroup._primaryLayer._origWeight = layerGroup._primaryLayer._animation.weight; } for (int i = 0; i < layerGroup._backgroundLayers.Length; i++) { if (IsLayerChannelPlaying(layerGroup._backgroundLayers[i])) { layerGroup._backgroundLayers[i]._origWeight = layerGroup._backgroundLayers[i]._animation.weight; } } } else { StopLayer(layerGroup); } } }
public static Map InitializeMapGdal(Size size) { HttpContext.Current.Trace.Write("Initializing map..."); //Initialize a new map of size 'imagesize' Map map = new Map(size); //Set up the gdal layer LayerGroup g = new LayerGroup("OS"); g.SRID = 27700; //D:\Raster\Ordnance Survey\OS Street View SM\data\sm System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(HttpContext.Current.Server.MapPath(@"~\App_Data\Gdal")); foreach (System.IO.FileInfo fi in di.GetFiles("*.tif")) { try { SharpMap.Layers.GdalRasterLayer layer = new SharpMap.Layers.GdalRasterLayer( fi.Name, HttpContext.Current.Server.MapPath(@"~\App_Data\Gdal\" + fi.Name)); //layer.SRID = 27700; g.Layers.Add(layer); } catch (TypeInitializationException ex) { throw new Exception( "Please copy the umanaged dll's into your bin folder from javascript:window.location.href='http://www.codeplex.com/SharpMap/Wiki/View.aspx?title=Extensions';."); } } map.Layers.Add(g); map.ZoomToExtents(); HttpContext.Current.Trace.Write("Map initialized"); return(map); }
/// <summary> /// Checks if the CurrentUser is allowed to access the specified layergroup in the requested context. /// </summary> /// <param name="layerGroup">The layerGroup access is being requested for.</param> /// <param name="requestContext">The context of the access request (how the result will be displayed and where)</param> /// <returns>True, if the request is allowed, false otherwise.</returns> public bool IsAllowed( LayerGroup layerGroup, SecureRequestContext requestContext) { if (!IsUseSecurityRules) { return(true); } bool isAllowed = false; if (layerGroup == null) { Logger.LogError(5, "Access to a NULL layerGroup cannot be allowed!"); return(false); } List <GroupPermissions> contentAllowedGroups = null; isAllowed = IsContentAccessAllowed(layerGroup.LayerGroup_ID, SecureRequestContext.ContentType.STAT_LAYER_GROUP, out contentAllowedGroups); if (isAllowed) { isAllowed = IsRequestContextAllowed(contentAllowedGroups, requestContext); } return(isAllowed); }
public void Map_GetLayerByNameInGroupLayer() { Map m = new Map(); VectorLayer vlay1 = new VectorLayer("1"); VectorLayer vlay2 = new VectorLayer("2"); VectorLayer vlay3 = new VectorLayer("3"); m.Layers.Add(vlay1); LayerGroup lg = new LayerGroup("Group"); lg.Layers.Add(vlay2); lg.Layers.Add(vlay3); m.Layers.Add(lg); var lay = m.GetLayerByName("1"); Assert.IsNotNull(lay); Assert.AreEqual("1", lay.LayerName); lay = m.GetLayerByName("2"); Assert.IsNotNull(lay); Assert.AreEqual("2", lay.LayerName); lay = m.GetLayerByName("3"); Assert.IsNotNull(lay); Assert.AreEqual("3", lay.LayerName); lay = m.GetLayerByName("Group"); Assert.IsNotNull(lay); Assert.AreEqual("Group", lay.LayerName); }
public LayerGroup AddLayerGroup(string groupName) { var group = new LayerGroup(groupName); groups.Add(group); return(group); }
private void handleLayerChildrenVisibleChangeRequested(Object sender, LayerActionEventArgs e) { switch (e.LayerAction) { case LayerAction.Enabled: case LayerAction.Disabled: foreach (String layerName in e.Layers) { LayerGroup group = Map.Layers[layerName] as LayerGroup; if (group != null) { foreach (ILayer layer in group) { if (layer == group.MasterLayer) { continue; } if (e.LayerAction == LayerAction.Enabled) { Map.EnableLayer(layer); } else { Map.DisableLayer(layer); } } } } break; default: break; } }
public void LayerGroup_CloneProp() { var group = new LayerGroup("group"); // This is a transformation that cannot be "inverted" in ProjNet // Directly setting CoordinateTransformation will update SRID and TargetSRID group.CoordinateTransformation = CreateTransformation(); group.ReverseCoordinateTransformation = CreateReverseTransformation(); group.Enabled = true; group.IsQueryEnabled = true; group.MinVisible = 10; group.MaxVisible = 100; //group.SRID = 4326; // different to CoordinateTransformation above!!! //group.TargetSRID = 4318; // different to CoordinateTransformation above!!! group.Proj4Projection = "dummy"; group.Style = new LabelStyle(); var clonedGroup = (LayerGroup)group.Clone(); Assert.That(clonedGroup.CoordinateTransformation.SourceCS.WKT, Is.EqualTo(group.CoordinateTransformation.SourceCS.WKT), "CoordinateTransformation mismatch"); Assert.That(clonedGroup.CoordinateTransformation.TargetCS.WKT, Is.EqualTo(group.CoordinateTransformation.TargetCS.WKT), "CoordinateTransformation mismatch"); Assert.That(clonedGroup.ReverseCoordinateTransformation.SourceCS.WKT, Is.EqualTo(group.ReverseCoordinateTransformation.SourceCS.WKT), "CoordinateTransformation mismatch"); Assert.That(clonedGroup.ReverseCoordinateTransformation.TargetCS.WKT, Is.EqualTo(group.ReverseCoordinateTransformation.TargetCS.WKT), "CoordinateTransformation mismatch"); Assert.That(clonedGroup.Enabled, Is.EqualTo(group.Enabled), "Enabled mismatch"); Assert.That(clonedGroup.IsQueryEnabled, Is.EqualTo(group.IsQueryEnabled), "IsQueryEnabled mismatch"); Assert.That(clonedGroup.MinVisible, Is.EqualTo(group.MinVisible), "MinVisible mismatch"); Assert.That(clonedGroup.MaxVisible, Is.EqualTo(group.MaxVisible), "MaxVisible mismatch"); Assert.That(clonedGroup.SRID, Is.EqualTo(group.SRID), "SRID mismatch"); Assert.That(clonedGroup.Proj4Projection, Is.EqualTo(group.Proj4Projection), "Proj4Projection mismatch"); Assert.That(clonedGroup.TargetSRID, Is.EqualTo(group.TargetSRID), "TargetSRID mismatch"); Assert.That(clonedGroup.Style, Is.EqualTo(group.Style), "Style mismatch"); }
public override void OnMapCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { switch (e.Action) { case NotifyCollectionChangedAction.Remove: { if (sender is Map) { ILayer layer = (ILayer)e.Item; if (layer is LayerGroup) { LayerGroup layerGroup = (LayerGroup)layer; foreach (ILayer layerGroupLayer in layerGroup.Layers) { HandleLayerStatusChanged(layerGroupLayer); } } else { HandleLayerStatusChanged(layer); } } break; } case NotifyCollectionChangedAction.Replace: throw new NotImplementedException(); } }
/// <summary> /// Handles changes to the map (or bubbled up from ITheme, ILayer) properties. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public override void OnMapPropertyChanged(object sender, PropertyChangedEventArgs e) { if (sender is ILayer) { if (e.PropertyName == "Enabled") { // If a layer is enabled of disables and features of the layer are selected // the selection is cleared. Another solution is to remove only features of layer // from the selection, but this simple and effective. ILayer layer = (ILayer)sender; if (layer is LayerGroup) { LayerGroup layerGroup = (LayerGroup)layer; foreach (ILayer layerGroupLayer in layerGroup.Layers) { HandleLayerStatusChanged(layerGroupLayer); } } else { HandleLayerStatusChanged(layer); } } } }
static void GetAllMapLayers(LayerGroup layerGroup, List <AbstractMapLayer> layers) { layers.AddRange(layerGroup.MapLayers); foreach (var group in layerGroup.Group) { GetAllMapLayers(group, layers); } }
private void ReplaceExistingAsyncLayerFromGroup(LayerGroup group, Tuple <Mock <ILayer>, Mock <ITileAsyncLayer> > oldTileLayer, Tuple <Mock <ILayer>, Mock <ITileAsyncLayer> > newTileLayer) { var oldLayer = oldTileLayer.Item1.Object; var idx = group.Layers.IndexOf(oldLayer); group.Layers[idx] = newTileLayer.Item1.Object; }
public PaintContext() { Init(); OperationLayers = new LayerGroup(); LayerGroup = new LayerGroup(); HistoryLayerCnt = 0; }
private void DeleteActiveLayer(bool allSites) { var layerGroup = activeLayer.Group; DataLayer selectedLayer = null; LayerGroup selectedGroup = allSites ? null : layerGroup; int index = layerGroup.IndexOf(activeLayer); if (index < layerGroup.layers.Count - 1) { if (activeSite == null) { selectedLayer = layerGroup.layers[index + 1]; } else { int count = layerGroup.layers.Count; for (int i = index + 1; i < count; ++i) { if (layerGroup.layers[i].HasDataForSite(activeSite)) { selectedLayer = layerGroup.layers[i]; break; } } } } else if (index > 0) { if (activeSite == null) { selectedLayer = layerGroup.layers[index - 1]; } else { int count = layerGroup.layers.Count; for (int i = index - 1; i >= 0; --i) { if (layerGroup.layers[i].HasDataForSite(activeSite)) { selectedLayer = layerGroup.layers[i]; break; } } } } DeleteLayer(activeLayer); if (allSites) { layerGroup.RemoveLayer(activeLayer); } UpdateLayerList(selectedGroup, selectedLayer); UpdateListButtons(); }
private void InitVariableLayers() { LayerGroup lyrGrp = null; VectorLayer lyr = null; // group layer with single target + labels lyrGrp = new LayerGroup("Fast Boats Group"); lyr = CreateGeometryFeatureProviderLayer("Fast Boats", new[] { new System.Data.DataColumn("Name", typeof(string)), new System.Data.DataColumn("Heading", typeof(float)), new System.Data.DataColumn("Scale", typeof(float)), new System.Data.DataColumn("ARGB", typeof(int)) }); lyr.Style.PointColor = new SolidBrush(Color.Green); _fastBoats = new MovingObjects(50, 50, lyr, this.mb.Map, 0.8f, Color.Green); _fastBoats.AddObject("Fast 1", GetRectangleCenter(MapDecorationAnchor.LeftTop)); InitRasterPointSymbolizer(lyr, 0); lyrGrp.Layers.Add(lyr); lyrGrp.Layers.Add(CreateLabelLayer(lyr, "Name", false)); this.mb.Map.VariableLayers.Add(lyrGrp); // group layer with multiple targets + labels lyrGrp = new LayerGroup("Medium Boats Group"); lyr = CreateGeometryFeatureProviderLayer("Medium Boats", new[] { new System.Data.DataColumn("Name", typeof(string)), new System.Data.DataColumn("Heading", typeof(float)), new System.Data.DataColumn("Scale", typeof(float)), new System.Data.DataColumn("ARGB", typeof(int)) }); lyr.Style.PointColor = new SolidBrush(Color.Yellow); _mediumBoats = new MovingObjects(500, 100, lyr, this.mb.Map, 1, Color.Yellow); _mediumBoats.AddObject("Boat 1", GetRectangleCenter(MapDecorationAnchor.RightTop)); _mediumBoats.AddObject("Boat 2", GetRectangleCenter(MapDecorationAnchor.RightCenter)); InitRasterPointSymbolizer(lyr, 1); lyrGrp.Layers.Add(lyr); lyrGrp.Layers.Add(CreateLabelLayer(lyr, "Name", false)); this.mb.Map.VariableLayers.Add(lyrGrp); // group layer with multiple targets + labels lyrGrp = new LayerGroup("Slow Boats Group"); lyr = CreateGeometryFeatureProviderLayer("Slow Boats", new[] { new System.Data.DataColumn("Name", typeof(string)), new System.Data.DataColumn("Heading", typeof(float)), new System.Data.DataColumn("Scale", typeof(float)), new System.Data.DataColumn("ARGB", typeof(int)) }); // raster point symbolizer lyr.Style.PointColor = new SolidBrush(Color.Red); _slowBoats = new MovingObjects(2000, 100, lyr, this.mb.Map, 1.2f, Color.Red); _slowBoats.AddObject("Slow 1", GetRectangleCenter(MapDecorationAnchor.LeftBottom)); _slowBoats.AddObject("Slow 2", GetRectangleCenter(MapDecorationAnchor.CenterBottom)); _slowBoats.AddObject("Slow 3", GetRectangleCenter(MapDecorationAnchor.RightBottom)); InitRasterPointSymbolizer(lyr, 1); lyrGrp.Layers.Add(lyr); lyrGrp.Layers.Add(CreateLabelLayer(lyr, "Name", true)); this.mb.Map.VariableLayers.Add(lyrGrp); }
public void Envelope_WhenInnerLayerEnvelopeIsNull_ReturnsNull() { var group = new LayerGroup("group"); group.Layers.Add(new DummyLayer()); Assert.That(group.Envelope, Is.Null, "LayerGroup envelope should be null since we added a layer with a null envelope"); }
public void Envelope_SomeInnerLayerWithNullEnvelope_SkipNulls() { var group = new LayerGroup("group"); group.Layers.Add(new DummyLayer()); group.Layers.Add(new FooLayer()); Assert.That(group.Envelope, Is.EqualTo(new Envelope(5, 10, 5, 10))); }
public void ChangeGroup(LayerGroup newGroup) { if (newGroup == null || newGroup == Group) { return; } Group.MoveLayerToGroup(this, newGroup); Group = newGroup; }
void MoveLayerToGroup(Layer layer, LayerGroup group) { var name = layer.Name; var copy = new Layer(layer); group.Insert(copy, -1); ActiveImage.RemoveLayer(layer); copy.Name = name; }
public static void Run() { //ExStart:SupportOfSectionDividerLayer // The following code demonstrates SectionDividerLayer layers and how to get the related to it LayerGroup. // Layers hierarchy // [0]: '</Layer group>' SectionDividerLayer for Group 1 // [1]: 'Layer 1' Regular Layer // [2]: '</Layer group>' SectionDividerLayer for Group 2 // [3]: '</Layer group>' SectionDividerLayer for Group 3 // [4]: 'Group 3' GroupLayer // [5]: 'Group 2' GroupLayer // [6]: 'Group 1' GroupLayer void AssertAreEqual(object expected, object actual, string message = null) { if (!object.Equals(expected, actual)) { throw new Exception(message ?? "Objects are not equal."); } } using (var image = new PsdImage(100, 100)) { // Creating layers hierarchy // Add the LayerGroup 'Group 1' LayerGroup group1 = image.AddLayerGroup("Group 1", 0, true); // Add regular layer Layer layer1 = new Layer(); layer1.DisplayName = "Layer 1"; group1.AddLayer(layer1); // Add the LayerGroup 'Group 2' LayerGroup group2 = group1.AddLayerGroup("Group 2", 1); // Add the LayerGroup 'Group 3' LayerGroup group3 = group2.AddLayerGroup("Group 3", 0); // Gets the SectionDividerLayer's SectionDividerLayer divider1 = (SectionDividerLayer)image.Layers[0]; SectionDividerLayer divider2 = (SectionDividerLayer)image.Layers[2]; SectionDividerLayer divider3 = (SectionDividerLayer)image.Layers[3]; // using the SectionDividerLayer.GetRelatedLayerGroup() method, obtains the related LayerGroup instance. AssertAreEqual(group1.DisplayName, divider1.GetRelatedLayerGroup().DisplayName); // the same LayerGroup AssertAreEqual(group2.DisplayName, divider2.GetRelatedLayerGroup().DisplayName); // the same LayerGroup AssertAreEqual(group3.DisplayName, divider3.GetRelatedLayerGroup().DisplayName); // the same LayerGroup LayerGroup folder1 = divider1.GetRelatedLayerGroup(); AssertAreEqual(5, folder1.Layers.Length); // 'Group 1' contains 5 layers } //ExEnd:SupportOfSectionDividerLayer Console.WriteLine("SupportOfSectionDividerLayer executed successfully"); }
public override bool Execute() { var image = ActiveImage; var group = new LayerGroup(image); image.InsertLayer(group, -1); SelectedLayers.ForEach(layer => MoveLayerToGroup(layer, group)); return true; }
public bool IsPlaying(string animName, int layer = 0) { LayerGroup layerGroup = GetLayerGroup(layer); if (layerGroup != null) { return(IsLayerChannelPlaying(layerGroup._primaryLayer, animName)); } return(false); }
private void LoadItems(LayerGroup layerGroup) { lstItems.Items.Clear(); foreach (var item in layerGroup.Layers.Where(x => x.User == UI.CurrentUser && x.Versions.Any(l => l.Dataset.Cartography.Country == UI.CurrentCountry)).OrderBy(x => x.Caption)) { var ele = new ListViewItem(item.ToArray()); ele.Tag = item; lstItems.Items.Add(ele); } }
override public bool Execute() { var image = ActiveImage; var group = new LayerGroup(image); image.InsertLayer(group, -1); SelectedLayers.ForEach(layer => MoveLayerToGroup(layer, group)); return(true); }
public void SetAnimationWeight(string animName, float weight, int layer = 0) { LayerGroup layerGroup = GetLayerGroup(layer); if (layerGroup != null) { if (IsLayerChannelPlaying(layerGroup._primaryLayer, animName)) { layerGroup._primaryLayer._animation.weight = weight; } } }
/// <summary> /// 绑定command删除多个会出问题 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void RemoveLayer_Click(object sender, RoutedEventArgs e) { List <LayerBase> list = new List <LayerBase>(); foreach (var item in LayerGroup.SelectedItems) { list.Add(item as LayerBase); } LayerGroup.UnselectAll(); Service.RemoveLayer(list); }
private void StopLayer(LayerGroup layerGroup) { if (layerGroup != null) { StopLayerChannel(layerGroup._primaryLayer); for (int i = 0; i < layerGroup._backgroundLayers.Length; i++) { StopLayerChannel(layerGroup._backgroundLayers[i]); } } }
protected override void Edit(LayerGroup layerGroup) { if (!(layerGroup is SimpleLayerGroup)) throw new NotSupportedException(); Layer layer = layerGroup[0]; int tileX = this.tileX; int tileY = this.tileY; if (tileX >= layer.objects.GetLength(0)|| tileY >= layer.objects.GetLength(1)) { return; } if (layer.objects[tileX, tileY] == null) { AddCommand( delegate() { layer.objects[tileX, tileY] = new Map.Obj(); layer.objects[tileX, tileY].Sprite = sprite; }, delegate() { layer.objects[tileX, tileY] = null; }); } else { Sprite oldSprite = layer.objects[tileX, tileY].Sprite; AddCommand( delegate() { layer.objects[tileX, tileY].Sprite = sprite; }, delegate() { layer.objects[tileX, tileY].Sprite = oldSprite; }); } if (clearScriptInfo) { string oldAction = layer.objects[tileX, tileY].actionScript; string oldCollide = layer.objects[tileX,tileY].collideScript; string oldMovement = layer.objects[tileX, tileY].movementAIScript; AddCommand( delegate() { layer.objects[tileX, tileY].actionScript = ""; layer.objects[tileX, tileY].movementAIScript = ""; layer.objects[tileX, tileY].collideScript = ""; }, delegate() { layer.objects[tileX, tileY].actionScript = oldAction; layer.objects[tileX, tileY].movementAIScript = oldMovement; layer.objects[tileX, tileY].collideScript = oldCollide; }); } }
protected override void Edit(LayerGroup layerGroup) { if (!(layerGroup is SimpleLayerGroup)) throw new NotSupportedException(); Layer layer = layerGroup[0]; int tileX = this.tileX; int tileY = this.tileY; if (tileX >= layer.objects.GetLength(0) || tileY >= layer.objects.GetLength(1)) { return; } Map.Obj oldObj = layer.objects[tileX, tileY]; if (oldObj == null) return; AddCommand( delegate() { layer.objects[tileX, tileY] = null; }, delegate() { layer.objects[tileX, tileY] = oldObj; }); }
protected override void Edit(LayerGroup layerGroup) { if (!(layerGroup is SimpleLayerGroup)) throw new NotSupportedException(); Layer layer = layerGroup[0]; Map map = layerGroup[0].Map; int tileX = this.tileX; int tileY = this.tileY; if (tileX >= map.width || tileY >= map.height || tileY == 0) return; if (map.ladders[tileX, tileY] == null && map.ladders[tileX, tileY - 1] == null && (tileY == map.height - 1 || map.ladders[tileX, tileY + 1] == null)) { Layer baseLayer = layer, topLayer = layer; if (SelectTwoLayersDialog.SelectTwoDifferentLayers(map, ref baseLayer, ref topLayer)) { AddCommand( delegate() { map.ladders[tileX, tileY] = new Map.Ladder(baseLayer, topLayer); }, delegate() { map.ladders[tileX, tileY] = null; } ); EndEdit(); } } }
/** <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(); }
/// <summary> /// Starts performing the actions associated with the cursor. /// Some cursors can painted, thus the undo action will be finalized when the /// <see cref="EndEdit()"/> function is called. /// </summary> /// <param name="layer">The layer the cursor should act on.</param> public void DoEdit(LayerGroup layer) { this.Edit(layer); }
/// <summary> /// Adds the cursors actions to the current command list. /// </summary> /// <param name="layer">The layer the actions are performed on.</param> protected abstract void Edit(LayerGroup layer);
public static void ImportNestedFilters(LayerFilter srcFilter, LayerFilter destFilter, Database srcDb, Database destDb) { using (Transaction t = srcDb.TransactionManager.StartTransaction()) { LayerTable lt = t.GetObject(srcDb.LayerTableId, OpenMode.ForRead, false) as LayerTable; foreach (LayerFilter sf in srcFilter.NestedFilters) { // Получаем слои, которые следует клонировать в db // Только те, которые участвуют в фильтре ObjectIdCollection layerIds = new ObjectIdCollection(); foreach (ObjectId layerId in lt) { LayerTableRecord ltr = t.GetObject(layerId, OpenMode.ForRead, false) as LayerTableRecord; if (sf.Filter(ltr)) { layerIds.Add(layerId); } } // Клонируем слои во внешнюю db IdMapping idmap = new IdMapping(); if (layerIds.Count > 0) { srcDb.WblockCloneObjects(layerIds, destDb.LayerTableId, idmap, DuplicateRecordCloning.Replace, false); } // Опеределяем не было ли фильтра слоев // с таким же именем во внешней db LayerFilter df = null; foreach (LayerFilter f in destFilter.NestedFilters) { if (f.Name.Equals(sf.Name)) { df = f; break; } } if (df == null) { if (sf is LayerGroup) { // Создаем новую группу слоев если // ничего не найдено LayerGroup sfgroup = sf as LayerGroup; LayerGroup dfgroup = new LayerGroup(); dfgroup.Name = sf.Name; df = dfgroup; LayerCollection lyrs = sfgroup.LayerIds; foreach (ObjectId lid in lyrs) { if (idmap.Contains(lid)) { IdPair idp = idmap[lid]; dfgroup.LayerIds.Add(idp.Value); } } destFilter.NestedFilters.Add(df); } else { // Создаем фильтр слоев если // ничего не найдено df = new LayerFilter(); df.Name = sf.Name; df.FilterExpression = sf.FilterExpression; destFilter.NestedFilters.Add(df); } } // Импортируем другие фильтры ImportNestedFilters(sf, df, srcDb, destDb); } t.Commit(); } }