public void PrintAsPDF(string filename, Project project)
        {
            // first, just start beginning of tile downloading...

            string      localdata      = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\ResTBDesktop";
            PdfDocument mapTemplate    = PdfReader.Open(localdata + "\\PrintTemplates\\A4_landscape.pdf", PdfDocumentOpenMode.Modify);
            PdfDocument outputDocument = new PdfDocument();

            outputDocument.PageLayout = mapTemplate.PageLayout;
            PdfPage page = mapTemplate.Pages[0];

            page             = outputDocument.AddPage();
            page.Orientation = mapTemplate.Pages[0].Orientation;
            page.Width       = mapTemplate.Pages[0].Width;
            page.Height      = mapTemplate.Pages[0].Height;
            int dx = (int)page.Width.Point, dy = (int)page.Height.Point;
            // calculate aspect
            var    diffX  = AxMap.Extents.xMax - AxMap.Extents.xMin;
            double aspect = ((double)dy / dx);
            int    diffY  = (int)(aspect * diffX);

            // start tile loading for cache
            Extents MapExtents = new Extents();

            MapExtents.SetBounds(AxMap.Extents.xMin, AxMap.Extents.yMin, AxMap.Extents.zMin, AxMap.Extents.xMax, AxMap.Extents.yMin + diffY, AxMap.Extents.zMax);

            AxMap.TilesLoaded += AxMap_TilesLoaded;
            int width = (int)(dx * (96.0 / 72.0) * 1.5);

            this.filename = filename;
            this.project  = project;
            bool shouldwait = AxMap.LoadTilesForSnapshot(MapExtents, (int)(dx * (96.0 / 72.0) * 2), "Snapshot");

            if (shouldwait)
            {
                AxMap.TilesLoaded -= AxMap_TilesLoaded;
                PrintAsPDFAfterTilesAreLoaded();
            }
        }
        /// <summary>
        /// opens an existing template shapefile by looking for the .lay extension
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public bool OpenLayoutFile(string fileName)
        {
            bool success = false;

            _sfLayout = new Shapefile();
            if (_sfLayout.Open(fileName.Replace("lay", "shp")))
            {
                _hsfLayout = _majorGrid.MaplayersHandler.AddLayer(_sfLayout, "Layout frame", true, true);
                if (_hsfLayout > 0)
                {
                    MaxPanelHeight = 0;
                    MaxPanelWidth  = 0;
                    for (int n = 0; n < _sfLayout.NumShapes; n++)
                    {
                        var ext = _sfLayout.Shape[n].Extents;
                        if (ext.Width > MaxPanelWidth)
                        {
                            MaxPanelWidth           = (int)ext.Width;
                            LayoutMaxDimensionIndex = n;
                        }

                        if (ext.Height > MaxPanelHeight)
                        {
                            MaxPanelHeight          = (int)ext.Height;
                            LayoutMaxDimensionIndex = n;
                        }
                    }
                    _sfLayout.DefaultDrawingOptions.FillVisible = false;
                    _sfLayout.DefaultDrawingOptions.LineWidth   = 2;
                    _sfLayout.DefaultDrawingOptions.LineColor   = new Utils().ColorByName(tkMapColor.DarkBlue);
                    _majorGrid.MaplayersHandler[_hsfLayout].IsFishingGridLayoutTemplate = true;
                    _axMap.Redraw();
                    success = true;
                    LayoutTemplateFromFile = true;
                    _layoutExtents         = _sfLayout.Extents;
                }
            }
            return(success);
        }
Beispiel #3
0
        public override void InternalToBinary(IBinaryRawWriter writer)
        {
            base.InternalToBinary(writer);

            VersionSerializationHelper.EmitVersionByte(writer, VERSION_NUMBER);

            writer.WriteGuid(ProjectID);
            writer.WriteBoolean(DesignDescriptor != null);
            DesignDescriptor?.ToBinary(writer);

            writer.WriteLong(AsAtDate.Ticks);

            writer.WriteBoolean(Extents != null);
            Extents?.ToBinary(writer);

            writer.WriteBoolean(ExistenceMap != null);

            if (ExistenceMap != null)
            {
                writer.WriteByteArray(ExistenceMap.ToBytes());
            }
        }
        /// <summary>
        /// Creates a new instance of the tile prefetcher
        /// </summary>
        public PrefetcherForm(Extents ext, int provider, string dbFilename)
        {
            InitializeComponent();

            this.btnChangeDiskLocation.Click += new System.EventHandler(this.btnChangeDiskLocation_Click);
            this.btnChoose.Click             += new System.EventHandler(this.btnChoose_Click);
            this.chkSelectAll.CheckedChanged += new System.EventHandler(this.chkSelectAll_CheckedChanged_1);
            this.Ok.Click              += new System.EventHandler(this.Ok_Click_1);
            this.FormClosing           += new System.Windows.Forms.FormClosingEventHandler(this.PrefetcherForm_FormClosing);
            this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);

            this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
            //this.btnTestConnection.Click += new System.EventHandler(this.btnTestConnection_Click);
            //this.chkVisible.CheckedChanged += new System.EventHandler(this.chkVisible_CheckedChanged);

            this.tiles = new MapWinGIS.Tiles();
            tiles.AutodetectProxy();
            this.SetExtents(ext);
            Thread.Sleep(300);

            TileSettings.Read(tiles);
            TileSettings.FillProviderTree(this.treeView1, provider);

            if (dbFilename != "")
            {
                this.tiles.DiskCacheFilename = dbFilename;
            }
            this.txtDatabase.Text = tiles.DiskCacheFilename;

            try
            {
                if (this.treeView1.SelectedNode == null)
                {
                    this.treeView1.SelectedNode = this.treeView1.Nodes[0].Nodes[0].Nodes[0];
                }
            }
            catch (Exception ex) { }
        }
Beispiel #5
0
        public void PropertyValueGetExtentsValue()
        {
            tlog.Debug(tag, $"PropertyValueGetExtentsValue START");

            var testingTarget = new PropertyValue(new Extents(1, 2, 3, 4));

            Assert.IsNotNull(testingTarget, "Should be not null!");
            Assert.IsInstanceOf <PropertyValue>(testingTarget, "Should be an Instance of PropertyValue class!");

            Extents extents = new Extents(0, 0, 0, 0);
            var     result  = testingTarget.Get(extents);

            Assert.IsTrue(result);

            Assert.AreEqual(1, extents.Start, "should be equal.");
            Assert.AreEqual(2, extents.End, "should be equal.");
            Assert.AreEqual(3, extents.Top, "should be equal.");
            Assert.AreEqual(4, extents.Bottom, "should be equal.");

            extents.Dispose();
            testingTarget.Dispose();
            tlog.Debug(tag, $"PropertyValueGetExtentsValue END (OK)");
        }
Beispiel #6
0
        private object _prepareDependencies(object state)
        {
            var setupState = new SetupState();

            // TODO: read these from static storage (will be set by map select screen)
            _heightMap     = DefaultHeightMap;
            _featureMap    = DefaultFeatureMap;
            _extents       = DefaultExtents;
            _decorationMap = DefaultDecorationMap;

            setupState.Terrain = new GameObject("Terrain");
            setupState.Terrain.transform.SetParent(transform);
            setupState.Terrain.layer = LayerMask.NameToLayer("Terrain");

            var meshFilter = setupState.Terrain.AddComponent <MeshFilter>();

            setupState.MeshRenderer = setupState.Terrain.AddComponent <MeshRenderer>();

            setupState.Mesh = meshFilter.mesh;
            setupState.Mesh.Clear();

            return(setupState);
        }
Beispiel #7
0
        public override void MouseUpHandler(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
            {
                if (_isStarted == false)
                {
                    if (_isMoving == true)
                    {
                        var pt1 = MapControl.Current.GetWorldCoord(_mouseDownOrigin);
                        var pt2 = MapControl.Current.GetWorldCoord(_mouseDownEnd);

                        var extents = Extents.FromPoints(pt1, pt2);
                        MapControl.Current.Zoom(extents);

                        _isMoving = false;
                    }

                    MapControl.Current.Children.Remove(Rect);
                    Rect.Visibility = Visibility.Collapsed;
                    _isDragging     = false;
                }
            }
        }
            public void Sim1000ms(float delta)
            {
                //List<PositionMonitor.PositionMonitorEntry> entitiesList = new List<PositionMonitor.PositionMonitorEntry>();

                Extents gridCheck = new Extents(Grid.PosToCell(this.gameObject), 5);

                PUtil.LogDebug(("Extent: x: {0}, y: {1}, width: {2}, height: {3}").F(gridCheck.x, gridCheck.y, gridCheck.width, gridCheck.height));
                PUtil.LogDebug(("PosToCell: {0}, cell x: {1}, cell y {2}").F(Grid.PosToCell(this.gameObject), Grid.CellToPos(Grid.PosToCell(this.gameObject)).x, Grid.CellToPos(Grid.PosToCell(this.gameObject)).y));

                //PositionMonitor.Instance.GatherEntries(gridCheck, PositionMonitor.Instance.Layer("DW_Hatches"), entitiesList);
                //GameScenePartitioner.Instance.GatherEntries(gridCheck, GameScenePartitioner.Instance.attackableEntitiesLayer, entitiesList);
                int count = PositionMonitor.Instance.CountEntries(gridCheck, PositionMonitor.Instance.Layer("DW_Hatches"));

                //PUtil.LogDebug(("Number of components found: {0}").F(entitiesList.Count));
                PUtil.LogDebug(("Number of Hatches found: {0}").F(count));

                /*for (int index = 0; index < entitiesList.Count; ++index)
                 * {
                 *  GameObject cmp = entitiesList[index].m_object as GameObject;
                 *  //FactionAlignment cmp = entitiesList[index].m_object as FactionAlignment;
                 *  PUtil.LogDebug(("Component {0}, name {1}").F(index, cmp.name));
                 * }*/
            }
Beispiel #9
0
        public void ExtentsConstructorWithExtents()
        {
            tlog.Debug(tag, $"ExtentsConstructorWithExtents START");

            var testingTarget = new Extents(1, 2, 3, 4);

            Assert.IsNotNull(testingTarget, "should be not null");
            Assert.IsInstanceOf <Extents>(testingTarget, "should be an instance of testing target class!");

            var result = new Extents(testingTarget);

            Assert.IsNotNull(result, "should be not null");
            Assert.IsInstanceOf <Extents>(result, "should be an instance of Extents class!");

            Assert.AreEqual(1, result.Start, "Retrieved extents.Start should be equal to 1");
            Assert.AreEqual(2, result.End, "Retrieved extents.End should be equal to 2");
            Assert.AreEqual(3, result.Top, "Retrieved extents.Top should be equal to 3");
            Assert.AreEqual(4, result.Bottom, "Retrieved extents.Bottom should be equal to 4");

            result.Dispose();
            testingTarget.Dispose();
            tlog.Debug(tag, $"ExtentsConstructorWithExtents END (OK)");
        }
Beispiel #10
0
        public void ExtentsCopyFromNullExtents()
        {
            tlog.Debug(tag, $"ExtentsCopyFromNullExtents START");

            var testingTarget = new Extents();

            Assert.IsNotNull(testingTarget, "should be not null");
            Assert.IsInstanceOf <Extents>(testingTarget, "should be an instance of testing target class!");

            Assert.AreEqual(0, testingTarget.Top, "Should be equal!");

            try
            {
                Extents extents = null;
                testingTarget.CopyFrom(extents);
            }
            catch (ArgumentNullException)
            {
                testingTarget.Dispose();
                tlog.Debug(tag, $"ExtentsCopyFromNullExtents END (OK)");
                Assert.Pass("Caught ArgumentNullException : Passed!");
            }
        }
Beispiel #11
0
        /// <summary>Moves to the selected shape(s)</summary>
        /// <param name = "selectedRows">A collection of th selected rows.</param>
        /// <param name = "shapefile">The current shapefile.</param>
        public void MoveToSelected(DataGridViewSelectedRowCollection selectedRows, Shapefile shapefile)
        {
            // TODO: Check if this is the most optimal method. Perhaps the SF objects has some better solutions
            try
            {
                var map       = Map;
                var currentEx = map.Extents as Extents;
                if (currentEx == null)
                {
                    throw new NullReferenceException("Can't access map extents.");
                }

                // Get the current center of the view
                double mpX = (currentEx.xMax - currentEx.xMin) / 2;
                double mpY = (currentEx.yMax - currentEx.yMin) / 2;

                // Determine the center point of the selected shapes
                double centroidX = shapefile.Shape[Convert.ToInt32(selectedRows[0].Cells[0].Value)].Center.x;
                double centroidY = shapefile.Shape[Convert.ToInt32(selectedRows[0].Cells[0].Value)].Center.y;

                // Check if the new centroid is calculated OK
                if (centroidX * centroidY != 0)
                {
                    // Create new extents
                    var newEx = new Extents();

                    // Set new extents
                    newEx.SetBounds((centroidX - mpX), (centroidY - mpY), 0, (centroidX + mpX), (centroidY + mpY), 0);

                    map.Extents = newEx;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Error in MoveToSelected: {0}", ex.Message));
            }
        }
Beispiel #12
0
 private void Insert(ScenePartitionerEntry entry)
 {
     if (entry.obj == null)
     {
         Debug.LogWarning("Trying to put null go into scene partitioner");
     }
     else
     {
         Extents nodeExtents = GetNodeExtents(entry);
         if (nodeExtents.x + nodeExtents.width > nodes.GetLength(2))
         {
             Debug.LogError(entry.obj.ToString() + " x/w " + nodeExtents.x + "/" + nodeExtents.width + " < " + nodes.GetLength(2));
         }
         if (nodeExtents.y + nodeExtents.height > nodes.GetLength(1))
         {
             Debug.LogError(entry.obj.ToString() + " y/h " + nodeExtents.y + "/" + nodeExtents.height + " < " + nodes.GetLength(1));
         }
         int layer = entry.layer;
         for (int i = nodeExtents.y; i < nodeExtents.y + nodeExtents.height; i++)
         {
             for (int j = nodeExtents.x; j < nodeExtents.x + nodeExtents.width; j++)
             {
                 if (!nodes[layer, i, j].dirty)
                 {
                     nodes[layer, i, j].dirty = true;
                     dirtyNodes.Add(new DirtyNode
                     {
                         layer = layer,
                         x     = j,
                         y     = i
                     });
                 }
                 nodes[layer, i, j].entries.Add(entry);
             }
         }
     }
 }
Beispiel #13
0
        private void axMap1_MouseDownEvent(object sender, AxMapWinGIS._DMapEvents_MouseDownEvent e)
        {
            int       layerHandler = axMap1.get_LayerHandle(7);
            Shapefile node         = axMap1.get_Shapefile(layerHandler);

            if (node != null)
            {
                double projX = 0.0;
                double projY = 0.0;
                axMap1.PixelToProj(e.x, e.y, ref projX, ref projY);
                object  result = null;
                Extents ext    = new Extents();
                ext.SetBounds(projX, projY, 0.0, projX, projY, 0.0);
                if (node.SelectShapes(ext, 10.0, SelectMode.INCLUSION, ref result))
                {
                    int[] shapes = result as int[];
                    if (shapes == null)
                    {
                        return;
                    }
                    if (shapes.Length > 1)
                    {
                        MessageBox.Show("Please select only one node for the device location.");
                    }
                    else
                    {
                        File.WriteAllText("..\\..\\devloc.txt", Convert.ToString(shapes[0]));
                        MessageBox.Show("Device location was selected. Node number " + shapes[0]);
                    }
                }
                else
                {
                    MessageBox.Show("Please select a node to set device location.");
                }
            }
        }
Beispiel #14
0
 public override void ApplyStyle(ViewStyle viewStyle)
 {
     base.ApplyStyle(viewStyle);
     if (viewStyle != null && viewStyle is DefaultTitleItemStyle defaultStyle)
     {
         if (itemLabel != null)
         {
             itemLabel.ApplyStyle(defaultStyle.Label);
         }
         if (itemIcon != null)
         {
             itemIcon.ApplyStyle(defaultStyle.Icon);
         }
         if (itemSeperator != null)
         {
             itemSeperator.ApplyStyle(defaultStyle.Seperator);
             //FIXME : currently margin is not applied by ApplyStyle automatically.
             itemSeperator.Margin = defaultStyle.Seperator.Margin;
         }
         //FIXME : currently padding is not applied by ApplyStyle automatically.
         Extents padding = defaultStyle.Padding;
         Padding = padding;
     }
 }
Beispiel #15
0
        public bool Equals(EntityInfo other)
        {
            if (ReferenceEquals(this, other))
            {
                return(true);
            }
            if (other is null)
            {
                return(false);
            }
            var res = Extents.Equals(other.Extents) &&
                      ClassId.Equals(other.ClassId) &&
                      Color.Equals(other.Color) &&
                      Layer.Equals(other.Layer) &&
                      Linetype.Equals(other.Linetype) &&
                      Lineweight.Equals(other.Lineweight);

#if DEBUG
            if (!res)
            {
            }
#endif
            return(res);
        }
    protected override void OnSpawn()
    {
        base.OnSpawn();
        base.OnToggle += OnSwitchToggled;
        UpdateLogicCircuit();
        UpdateVisualState(true);
        RefreshReachableCells();
        wasOn = switchedOn;
        Vector2I   vector2I = Grid.CellToXY(this.NaturalBuildingCell());
        int        cell     = Grid.XYToCell(vector2I.x, vector2I.y + pickupRange / 2);
        CellOffset offset   = new CellOffset(0, pickupRange / 2);

        if ((bool)rotatable)
        {
            offset = rotatable.GetRotatedCellOffset(offset);
            if (Grid.IsCellOffsetValid(this.NaturalBuildingCell(), offset))
            {
                cell = Grid.OffsetCell(this.NaturalBuildingCell(), offset);
            }
        }
        pickupableExtents       = new Extents(cell, pickupRange / 2);
        pickupablesChangedEntry = GameScenePartitioner.Instance.Add("DuplicantSensor.PickupablesChanged", base.gameObject, pickupableExtents, GameScenePartitioner.Instance.pickupablesChangedLayer, OnPickupablesChanged);
        pickupablesDirty        = true;
    }
Beispiel #17
0
        // <summary>
        // Handles mouse move event. Determines which shape is under cursor. Calls drawing routine.
        // </summary>
        void AxMap1MouseMoveEvent(object sender, _DMapEvents_MouseMoveEvent e)
        {
            Labels labels = axMap1.get_DrawingLabels(0);

            labels.Clear();

            // it's assumed here that the layer we want to edit is the first 1 (with 0 index)
            int layerHandle = axMap1.get_LayerHandle(0);
            var sf          = axMap1.get_Shapefile(layerHandle);

            if (sf != null)
            {
                double projX = 0.0;
                double projY = 0.0;
                axMap1.PixelToProj(e.x, e.y, ref projX, ref projY);

                object result = null;
                var    ext    = new Extents();
                ext.SetBounds(projX, projY, 0.0, projX, projY, 0.0);
                if (sf.SelectShapes(ext, 0.0, SelectMode.INTERSECTION, ref result))
                {
                    int[] shapes = result as int[];
                    if (shapes != null && shapes.Length == 1)
                    {
                        string s = "";
                        for (int i = 0; i < sf.NumFields; i++)
                        {
                            s += sf.Field[i].Name + ": " + sf.CellValue[i, shapes[0]] + "\n";
                        }
                        labels.AddLabel(s, e.x + 80, e.y);
                    }
                }
            }

            axMap1.Redraw2(tkRedrawType.RedrawSkipDataLayers);
        }
 private static IEnumerable <IFeature> WindowQuery(ILayer layer, Extents extents)
 {
     if (layer.GeoType == VectorLayer.GEOTYPE_POINT)
     {
         foreach (var f in layer.Features)
         {
             var p = f.GeoData[0];
             if (extents.IsPointIn(p))
             {
                 yield return(f);
             }
         }
     }
     else if (layer.GeoType == VectorLayer.GEOTYPE_LINEAR)
     {
         foreach (var f in layer.Features)
         {
             var poly = new PointString(f.GeoData);
             if (extents.IsExtentsIn(poly.GetExtents()))
             {
                 yield return(f);
             }
         }
     }
     else if (layer.GeoType == VectorLayer.GEOTYPE_REGION)
     {
         foreach (var f in layer.Features)
         {
             var poly = new PointString(f.GeoData);
             if (extents.IsExtentsIn(poly.GetExtents()))
             {
                 yield return(f);
             }
         }
     }
 }
Beispiel #19
0
        /// <summary>
        /// Updates the scene partitioner entry if the offsets change.
        /// </summary>
        public void UpdateOffsets()
        {
            var inst = FastGroupProber.Instance;

            if (inst != null && smi != null)
            {
                var offsets = smi.master.GetOffsets();
                var extents = new Extents(Grid.PosToCell(transform.position), offsets);
                // Only if the extents actually changed
                if (extents.x != lastExtents.x || extents.y != lastExtents.y || extents.
                    width != lastExtents.width || extents.height != lastExtents.height)
                {
                    var gsp = GameScenePartitioner.Instance;
                    if (partitionerEntry.IsValid())
                    {
                        gsp.UpdatePosition(partitionerEntry, extents);
                    }
                    else
                    {
                        partitionerEntry = gsp.Add("FastReachabilityMonitor.UpdateOffsets",
                                                   this, extents, inst.mask, OnReachableChanged);
                    }
                    // The offsets changed, fire a manual check if not the first time
                    // (the smi constructor already updated it once)
                    if (lastExtents.x >= 0)
                    {
                        smi.UpdateReachability();
                    }
                    lastExtents = extents;
                }
            }
            else
            {
                PUtil.LogWarning("FastReachabilityMonitor scene partitioner is unavailable");
            }
        }
Beispiel #20
0
        /// <summary>
        /// Adds this decor splat to its affecting cells. Line of sight checks are performed.
        /// </summary>
        /// <param name="cell">The originating cell.</param>
        /// <param name="decor">The decor value to add.</param>
        /// <param name="extents">The locations where it should be added.</param>
        private void AddDecor(int cell, float decor, Extents extents)
        {
            int maxX = extents.x + extents.width, maxY = extents.y + extents.height;
            // Bounds were already checked for us
            var inst = DecorCellManager.Instance;

            if (inst != null)
            {
                cells.Clear();
                for (int x = extents.x; x < maxX; x++)
                {
                    for (int y = extents.y; y < maxY; y++)
                    {
                        int target = Grid.XYToCell(x, y);
                        if (Grid.IsValidCell(target) && Grid.VisibilityTest(cell, target,
                                                                            false))
                        {
                            inst.AddDecorProvider(target, provider, decor);
                            cells.Add(target);
                        }
                    }
                }
            }
        }
Beispiel #21
0
        /// <summary>
        /// Applies style to AppBar.
        /// </summary>
        /// <param name="viewStyle">The style to apply.</param>
        /// <since_tizen> 9 </since_tizen>
        public override void ApplyStyle(ViewStyle viewStyle)
        {
            styleApplied = false;

            base.ApplyStyle(viewStyle);

            var appBarStyle = viewStyle as AppBarStyle;

            if (appBarStyle == null)
            {
                return;
            }

            if (appBarStyle.NavigationPadding != null)
            {
                navigationPadding = new Extents(appBarStyle.NavigationPadding);
            }

            if (appBarStyle.ActionPadding != null)
            {
                actionPadding = new Extents(appBarStyle.ActionPadding);
            }

            // Apply Back Button style.
            if ((appBarStyle.BackButton != null) && (DefaultNavigationContent is Button button))
            {
                button.ApplyStyle(appBarStyle.BackButton);
            }

            // Apply Title style.
            if ((appBarStyle.TitleTextLabel != null) && (DefaultTitleContent is TextLabel textLabel))
            {
                textLabel.ApplyStyle(appBarStyle.TitleTextLabel);
            }

            // Apply ActionCellPadding style.
            if (DefaultActionContent?.Layout is LinearLayout linearLayout && appBarStyle.ActionCellPadding != null)
            {
                linearLayout.CellPadding = new Size2D(appBarStyle.ActionCellPadding.Width, appBarStyle.ActionCellPadding.Height);
            }

            // Apply Action and ActionButton styles.
            if (DefaultActionContent?.Children != null)
            {
                foreach (var action in DefaultActionContent?.Children)
                {
                    if ((action is Button) && (appBarStyle.ActionButton != null))
                    {
                        action.ApplyStyle(appBarStyle.ActionButton);
                    }
                    else if (appBarStyle.ActionView != null)
                    {
                        action.ApplyStyle(appBarStyle.ActionView);
                    }
                }
            }

            if (actionButtonStyle == null)
            {
                actionButtonStyle = (ButtonStyle)appBarStyle.ActionButton?.Clone();
            }
            else
            {
                actionButtonStyle.MergeDirectly(appBarStyle.ActionButton);
            }

            if (actionViewStyle == null)
            {
                actionViewStyle = (ViewStyle)appBarStyle.ActionView?.Clone();
            }
            else
            {
                actionViewStyle.MergeDirectly(appBarStyle.ActionView);
            }


            styleApplied = true;

            // Calculate children's positions based on padding sizes.
            CalculatePosition();
        }
 public bool Equals(SimpleBounds other)
 {
     return(Center.Equals(other.Center) && Extents.Equals(other.Extents));
 }
 public override int GetHashCode()
 {
     return(Center.GetHashCode() ^ Extents.GetHashCode() << 2);
 }
Beispiel #24
0
 Boolean IIntersectable <IExtents> .Intersects(IExtents bounds)
 {
     return(Extents.Intersects(bounds));
 }
 /// AddLayersTools Methods
 public bool AddWMSLayer(string baseUrl, string layers, string name, Extents extents, int Epsg, string Format)
 {
     return(AddLayersTool.AddWMSLayer(baseUrl, layers, name, extents, Epsg, Format));
 }
Beispiel #26
0
 public LayerEventArg(Extents selectionExtent)
 {
     SelectionExtent = selectionExtent;
 }
        // <summary>
        // Performs a segmentation of shapes by regular grid
        // </summary>
        public void Segmentation(AxMap axMap1, string dataPath)
        {
            axMap1.Projection             = tkMapProjection.PROJECTION_NONE;
            axMap1.GrabProjectionFromData = true;

            string[] filenames = new string[2];
            filenames[0] = dataPath + "natural.shp";
            filenames[1] = dataPath + "landuse.shp";

            if (!File.Exists(filenames[0]) || !File.Exists(filenames[1]))
            {
                MessageBox.Show("Couldn't file the files (natural.shp, landuse.shp): " + dataPath);
                return;
            }

            List <Shapefile> layers = new List <Shapefile>();

            for (int i = 0; i < filenames.Length; i++)
            {
                Shapefile sf = new Shapefile();
                sf.Open(filenames[i], null);
                layers.Add(sf);
                axMap1.AddLayer(layers[i], true);
            }

            int     count = 4;
            Extents ext   = axMap1.MaxExtents as Extents;
            double  xStep = (ext.xMax - ext.xMin) / count;
            double  yStep = (ext.yMax - ext.yMin) / count;

            Shapefile sfGrid = new Shapefile();

            sfGrid.CreateNewWithShapeID("", ShpfileType.SHP_POLYGON);
            sfGrid.GeoProjection.CopyFrom(layers[0].GeoProjection);

            ColorScheme scheme = new ColorScheme();

            scheme.SetColors2(tkMapColor.Orange, tkMapColor.Yellow);

            for (int i = 0; i < layers.Count; i++)
            {
                string name       = Path.GetFileNameWithoutExtension(layers[i].Filename);
                int    fieldIndex = sfGrid.EditAddField(name, FieldType.DOUBLE_FIELD, 10, 12);
                uint   color      = scheme.GraduatedColor[(i + 1) / (double)layers.Count];
                sfGrid.Charts.AddField2(fieldIndex, color);
            }

            for (int i = 0; i < count; i++)
            {
                for (int j = 0; j < count; j++)
                {
                    Shape shp = new Shape();
                    shp.Create(ShpfileType.SHP_POLYGON);
                    shp.AddPoint(ext.xMin + i * xStep, ext.yMin + j * yStep);
                    shp.AddPoint(ext.xMin + i * xStep, ext.yMin + (j + 1) * yStep);
                    shp.AddPoint(ext.xMin + (i + 1) * xStep, ext.yMin + (j + 1) * yStep);
                    shp.AddPoint(ext.xMin + (i + 1) * xStep, ext.yMin + j * yStep);
                    shp.AddPoint(ext.xMin + i * xStep, ext.yMin + j * yStep);
                    int shapeIndex = sfGrid.EditAddShape(shp);

                    for (int layer = 0; layer < layers.Count; layer++)
                    {
                        Shapefile sf   = layers[layer];
                        double    area = 0.0;
                        for (int n = 0; n < sf.NumShapes; n++)
                        {
                            Shape shp2 = sf.Shape[n];
                            if (shp.Intersects(shp2))
                            {
                                Shape shpResult = shp2.Clip(shp, tkClipOperation.clIntersection);
                                if (shpResult != null)
                                {
                                    area += shpResult.Area;
                                }
                            }
                        }

                        // divide by 10000.0 to convert square meters to hectars
                        bool success = sfGrid.EditCellValue(layer + 1, shapeIndex, area / 10000.0);
                    }
                }
            }

            // generating charts
            Charts charts = sfGrid.Charts;

            charts.Generate(tkLabelPositioning.lpCenter);
            charts.ChartType     = tkChartType.chtPieChart;
            charts.PieRadius     = 18;
            charts.Thickness     = 10;
            charts.ValuesVisible = true;
            charts.Visible       = true;

            ShapeDrawingOptions options = sfGrid.DefaultDrawingOptions;

            options.FillVisible = false;
            options.LineWidth   = 2;
            options.LineStipple = tkDashStyle.dsDash;
            options.LineColor   = 255;

            axMap1.AddLayer(sfGrid, true);
            axMap1.ZoomToMaxExtents();
        }
Beispiel #28
0
 protected void OnCompleted(Extents extents)
 {
     this.Completed?.Invoke(Extents);
 }
        /// <summary>
        /// Receives the extent made by selection box or a click select to select shapes in a shapefile using intersection.
        /// Afterwards, a Selection event is raised
        /// </summary>
        /// <param name="selectExtents"></param>
        /// <param name="selectionFromSelectBox"></param>
        private void Select(Extents selectExtents, bool selectionFromSelectBox = false)
        {
            if (_currentMapLayer != null)
            {
                _selectedShapeIndexes   = null;
                _selectionFromSelectBox = selectionFromSelectBox;
                if (_currentMapLayer.LayerType == "ShapefileClass")
                {
                    var sf = _axMap.get_Shapefile(_currentMapLayer.Handle);
                    if (sf != null)
                    {
                        _currentMapLayer.SelectedIndexes = null;
                        sf.SelectNone();
                        sf.SelectionAppearance = tkSelectionAppearance.saDrawingOptions;

                        switch (sf.ShapefileType)
                        {
                        case ShpfileType.SHP_POINT:
                            if (sf.Categories.Count > 0)
                            {
                                sf.SelectionAppearance = tkSelectionAppearance.saSelectionColor;
                            }
                            else
                            {
                                sf.SelectionAppearance = tkSelectionAppearance.saDrawingOptions;
                                sf.SelectionDrawingOptions.PointSize     = sf.DefaultDrawingOptions.PointSize;
                                sf.SelectionDrawingOptions.PointRotation = sf.DefaultDrawingOptions.PointRotation;
                                sf.SelectionDrawingOptions.PointShape    = sf.DefaultDrawingOptions.PointShape;
                            }
                            break;

                        case ShpfileType.SHP_POLYGON:
                            break;

                        case ShpfileType.SHP_POLYLINE:

                            break;
                        }

                        var objSelection = new object();
                        if (sf.SelectShapes(selectExtents, 0, SelectMode.INTERSECTION, ref objSelection))
                        {
                            _selectedShapeIndexes            = (int[])objSelection;
                            _currentMapLayer.SelectedIndexes = _selectedShapeIndexes;
                            for (int n = 0; n < _selectedShapeIndexes.Length; n++)
                            {
                                sf.ShapeSelected[_selectedShapeIndexes[n]] = true;
                            }
                            if (ShapesSelected != null)
                            {
                                var lyArg = new LayerEventArg(_currentMapLayer.Handle, _selectedShapeIndexes);
                                ShapesSelected(this, lyArg);
                            }
                        }
                        else
                        {
                            SelectionCleared?.Invoke(this, EventArgs.Empty);
                        }
                        _axMap.Redraw();
                        Selection?.Invoke(this, EventArgs.Empty);
                    }
                }
                else if (_currentMapLayer.LayerType == "ImageClass")
                {
                }
            }
        }
Beispiel #30
0
 /// <summary>
 ///  Calculates statistics for portion of grid that is overlapped by specified polygon.
 /// </summary>
 /// <param name="Grid">Input grid</param>
 /// <param name="Header">Grid header. Can be retrieved with Grid.Header property.</param>
 /// <param name="gridExtents">Grid extents. Can be retrieved with Grid.Extents property.</param>
 /// <param name="Shape">Polygon shape within borders of which the statistics will be calculated.</param>
 /// <param name="NodataValue">No data value for grid. Can be retrieved from header.</param>
 /// <param name="MeanValue">Calculated mean value.</param>
 /// <param name="MinValue">Calculated min value.</param>
 /// <param name="MaxValue">Calculated max value</param>
 /// <returns>True on success.</returns>
 /// <remarks>Header, gridExtents, NodataValue parameters are added, so that these properties can be retrieved
 /// only ones in case the function is called multiple times for each polygon in shapefile.</remarks>
 /// \new490 Added in version 4.9.0
 public bool GridStatisticsForPolygon(Grid Grid, GridHeader Header, Extents gridExtents, Shape Shape, double NodataValue, ref double MeanValue, ref double MinValue, ref double MaxValue)
 {
     throw new NotImplementedException();
 }