Exemplo n.º 1
0
        public void AddMask(GCDCore.Project.Masks.AttributeFieldMask mask)
        {
            IGroupLayer pProjLyr      = AddProjectGroupLayer();
            IGroupLayer pGrpLayer     = ArcMapUtilities.GetGroupLayer(MasksGroupLayer, pProjLyr);
            short       dTransparency = GCDCore.Properties.Settings.Default.TransparencyAssociatedLayers ? GCDCore.Properties.Settings.Default.AutoTransparencyValue : (short)-1;

            IFeatureRenderer pRenderer   = null;
            string           queryFilter = string.Empty;
            string           labelField  = string.Empty;

            if (mask is GCDCore.Project.Masks.RegularMask)
            {
                GCDCore.Project.Masks.RegularMask rMask = mask as GCDCore.Project.Masks.RegularMask;

                pRenderer = VectorSymbolization.GetRegularMaskRenderer(rMask) as IFeatureRenderer;

                // Create a definition query if some features are not included

                if (rMask._Items.Any(x => !x.Include))
                {
                    queryFilter = string.Format("\"{0}\" IN ('{1}')", mask._Field, string.Join("','", rMask._Items.Where(x => x.Include).Select(y => y.FieldValue)));
                }
            }
            else if (mask is GCDCore.Project.Masks.DirectionalMask)
            {
                GCDCore.Project.Masks.DirectionalMask dirMask = mask as GCDCore.Project.Masks.DirectionalMask;
                // Directional mask. Black outline with labels
                pRenderer = VectorSymbolization.GetDirectionalMaskRenderer(dirMask) as IFeatureRenderer;

                labelField = string.IsNullOrEmpty(dirMask.LabelField) ? dirMask._Field : dirMask.LabelField;
            }

            VectorSymbolization.AddToMapVector(mask.Vector.GISFileInfo, mask.Name, pGrpLayer, mask._Field, pRenderer, queryFilter, labelField, dTransparency);
        }
Exemplo n.º 2
0
 private void cboMask_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (ErrorSurface == null)
     {
         GCDCore.Project.Masks.RegularMask mask = cboMask.SelectedItem as GCDCore.Project.Masks.RegularMask;
         ErrProps.Clear();
         mask.ActiveFieldValues.ForEach(x => ErrProps.Add(new ErrorSurfaceProperty(x.Label)));
     }
     else
     {
         ErrProps = new naru.ui.SortableBindingList <ErrorSurfaceProperty>(ErrorSurface.ErrorProperties.Values.ToList());
     }
 }
Exemplo n.º 3
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            if (!ValidateForm())
            {
                DialogResult = DialogResult.None;
                return;
            }

            try
            {
                Cursor = Cursors.WaitCursor;

                if (Mask == null)
                {
                    FileInfo fiMask = ProjectManager.Project.GetAbsolutePath(txtPath.Text);
                    fiMask.Directory.Create();

                    ucPolygon.SelectedItem.Copy(fiMask);

                    Mask = new GCDCore.Project.Masks.RegularMask(txtName.Text, fiMask, cboField.Text, MaskItems.ToList <GCDCore.Project.Masks.MaskItem>());
                    ProjectManager.Project.Masks.Add(Mask);
                    ProjectManager.AddNewProjectItemToMap(Mask);
                }
                else
                {
                    Mask.Name = txtName.Text;
                }

                ProjectManager.Project.Save();

                Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                GCDException.HandleException(ex, "Error creating regular mask.");
            }
        }
Exemplo n.º 4
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            if (!ucName.ValidateForm())
            {
                DialogResult = DialogResult.None;
                return;
            }

            try
            {
                Cursor = Cursors.WaitCursor;

                if (chkDefault.Checked && DEM.ErrorSurfaces.Count > 0)
                {
                    // Need to set all other error surfaces to not be the default
                    DEM.ErrorSurfaces.ToList().ForEach(x => x.IsDefault = false);
                }

                if (ErrorSurface == null)
                {
                    // Create the raster then add it to the DEM survey
                    ucName.AbsolutePath.Directory.Create();

                    // Get the mask values dictionary
                    GCDCore.Project.Masks.RegularMask     mask       = cboMask.SelectedItem as GCDCore.Project.Masks.RegularMask;
                    List <GCDCore.Project.Masks.MaskItem> maskValues = mask.ActiveFieldValues;

                    // Build dictionary of GCDConsole error properties
                    Dictionary <string, ErrorRasterProperties> gcdErrProps = new Dictionary <string, ErrorRasterProperties>();
                    foreach (GCDCore.Project.Masks.MaskItem item in maskValues)
                    {
                        foreach (ErrorSurfaceProperty prop in ErrProps)
                        {
                            if (string.Compare(prop.Name, item.FieldValue, true) == 0 || string.Compare(prop.Name, item.Label, true) == 0)
                            {
                                // For GCDConsole always add using mask value (not label)
                                gcdErrProps.Add(item.FieldValue, prop.GCDErrSurfPropery);
                                break;
                            }
                        }
                    }

                    // Build dictionary of GCD project error properties
                    Dictionary <string, ErrorSurfaceProperty> errProps = new Dictionary <string, ErrorSurfaceProperty>();
                    ErrProps.ToList().ForEach(x => errProps.Add(x.Name, x));

                    RasterOperators.CreateErrorRaster(DEM.Raster, mask.Vector, mask._Field, gcdErrProps, ucName.AbsolutePath, ProjectManager.OnProgressChange);
                    ErrorSurface = new ErrorSurface(ucName.ItemName, ucName.AbsolutePath, DEM, chkDefault.Checked, errProps, mask);
                    DEM.ErrorSurfaces.Add(ErrorSurface);
                    ProjectManager.AddNewProjectItemToMap(ErrorSurface);

                    // If this is a FIS error surface then copy the FIS file to the project and point the error surface property to
                    // this local file before saving the project. This will ensure that path to the FIS file is local to the project.
                    // MUST BE DONE BEFORE SAVING ERROR PROPERTIES TO THE PROJECT
                    ErrProps.ToList().ForEach(x => x.CloneToProject(string.Format("{0}_{1}", ucName.ItemName, x.Name), ucName.AbsolutePath.Directory));
                }
                else
                {
                    ErrorSurface.Name = ucName.ItemName;
                }

                // Handles unsetting default on other error surface and setting it for this one
                DEM.DefaultErrorSurface = ErrorSurface;

                ProjectManager.Project.Save();
                Cursor = Cursors.Default;
                MessageBox.Show("Error Surface Created Successfully.", Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                DialogResult = DialogResult.None;
                GCDException.HandleException(ex, "Error editing single region error surface");
            }
        }
Exemplo n.º 5
0
 public frmMaskProperties(GCDCore.Project.Masks.RegularMask mask = null)
 {
     InitializeComponent();
     MaskItems = new naru.ui.SortableBindingList <GCDCore.Project.Masks.MaskItem>();
     Mask      = mask;
 }
Exemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="mask"></param>
        /// <returns></returns>
        /// <remarks>https://gis.stackexchange.com/questions/58728/set-unique-values-to-different-groups-programmatically
        /// http://edndoc.esri.com/arcobjects/9.0/ComponentHelp/esriCarto/IUniqueValueRenderer_Example.htm
        /// </remarks>
        public static IUniqueValueRenderer GetRegularMaskRenderer(GCDCore.Project.Masks.RegularMask mask)
        {
            ISimpleFillSymbol symbol = new SimpleFillSymbol();

            symbol.Style         = esriSimpleFillStyle.esriSFSSolid;
            symbol.Outline.Width = 0.4;

            // Make the color ramp we will use for the symbols in the renderer
            IRandomColorRamp rx = new RandomColorRamp();

            rx.MinSaturation = 20;
            rx.MaxSaturation = 40;
            rx.MinValue      = 85;
            rx.MaxValue      = 100;
            rx.StartHue      = 76;
            rx.EndHue        = 188;
            rx.UseSeed       = true;
            rx.Seed          = 43;

            // These properties should be set prior to adding values
            IUniqueValueRenderer pRender = new UniqueValueRenderer();

            pRender.FieldCount       = 1;
            pRender.Field[0]         = mask._Field;
            pRender.DefaultSymbol    = (ISymbol)symbol;
            pRender.UseDefaultSymbol = false; // prevents "All other values" legend entry

            foreach (GCDCore.Project.Masks.MaskItem item in mask._Items.Where(x => x.Include))
            {
                ISimpleFillSymbol symx = new SimpleFillSymbol();
                symx.Style         = esriSimpleFillStyle.esriSFSSolid;
                symx.Outline.Width = 0.4;

                pRender.AddValue(item.FieldValue, string.Empty, (ISymbol)symx);
                pRender.Label[item.FieldValue]  = item.Label;
                pRender.Symbol[item.FieldValue] = (ISymbol)symx;
            }

            // now that we know how many unique values there are we can size the color ramp and assign the colors
            rx.Size = pRender.ValueCount;
            bool bOK;

            rx.CreateRamp(out bOK);
            IEnumColors RColors = rx.Colors;

            RColors.Reset();

            for (int i = 0; i < pRender.ValueCount; i++)
            {
                string            xv  = pRender.Value[i];
                ISimpleFillSymbol jsv = (ISimpleFillSymbol)pRender.Symbol[xv];
                jsv.Color          = RColors.Next();
                pRender.Symbol[xv] = (ISymbol)jsv;
            }

            // If you didn't use a color ramp that was predefined in a style, you need to use "Custom" here, otherwise
            // use the name of the color ramp you chose.
            pRender.ColorScheme = "Custom";
            pRender.set_FieldType(0, true);

            return(pRender);
        }