Ejemplo n.º 1
0
        public LandingSiteForm(TargetArea targetArea, MainForm parent, Landingsite landingSite, bool isNew = false)
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();

            //
            // TODO: Add constructor code after the InitializeComponent() call.
            //
            _targetArea  = targetArea;
            _parentForm  = parent;
            _isNew       = isNew;
            _landingSite = landingSite;

            Text = "Landing site";

            if (_isNew)
            {
                Text = "New landing site";
                _landingSite.IsNew();
            }

            SetupProvinceComboBox();
        }
Ejemplo n.º 2
0
        private bool ValidateForm()
        {
            bool proceed = false;

            if (textLandingSiteName.Text.Length > 0 && comboMunicipality.Text.Length > 0 && comboProvince.Text.Length > 0)
            {
                if (TargetArea.LandingSiteFromName(textLandingSiteName.Text, _targetArea.TargetAreaGuid) == null)
                {
                    proceed = true;
                }
                else
                {
                    if (_isNew)
                    {
                        proceed = false;
                        MessageBox.Show("A landing site with the same name already exists", "Validation error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        proceed = true;
                    }
                }
            }
            return(proceed);
        }
Ejemplo n.º 3
0
 public static TargetAreaGearsForm GetInstance(TargetArea aoi)
 {
     if (_instance == null)
     {
         _instance = new TargetAreaGearsForm(aoi);
     }
     return(_instance);
 }
Ejemplo n.º 4
0
        private void FillList()
        {
            switch (_action)
            {
            case fad3GearEditAction.addGearVariation:
                _List = Gears.AllGearVariationNames();
                foreach (var item in _List)
                {
                    listBox.Items.Add(item);
                }
                break;

            case fad3GearEditAction.addGearCode:
                foreach (var item in Gears.GearCodesByClass(_GearClassGuid))
                {
                    listBox.Items.Add(item);
                }

                labelCode.Text = Gears.GearLetterFromGearClass(_GearClassGuid);
                break;

            case fad3GearEditAction.addAOI:
            case fad3GearEditAction.addLocalName:
                TargetArea targetArea = new TargetArea();

                ((ComboBox)comboBox).With(o =>
                {
                    if (_action == fad3GearEditAction.addAOI)
                    {
                        foreach (var item in targetArea.TargetAreas)
                        {
                            comboBox.Items.Add(item);
                        }
                    }
                    else
                    {
                        foreach (var item in Gears.GearLocalNames)
                        {
                            comboBox.Items.Add(item);
                        }
                    }

                    o.DisplayMember      = "Value";
                    o.ValueMember        = "Key";
                    o.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
                    o.AutoCompleteSource = AutoCompleteSource.ListItems;
                });

                for (int i = 0; i < comboBox.Items.Count; i++)
                {
                    comboList.Add(((KeyValuePair <string, string>)comboBox.Items[i]).Value);
                }

                break;
            }
        }
Ejemplo n.º 5
0
 public LandingSiteForm(TargetArea targetArea, LandingSiteFromKMLForm kmlParentForm, string name, double xCoord, double yCoord, bool isNew = false, bool definedFromKML = true)
 {
     InitializeComponent();
     _targetArea      = targetArea;
     _landingSiteName = name;
     _xCoordinate     = xCoord;
     _yCoordinate     = yCoord;
     _isNew           = isNew;
     _definedFromKML  = definedFromKML;
     SetupProvinceComboBox();
     _parentKMLForm = kmlParentForm;
 }
        public static string GetNextReferenceNumber(string GearCode)
        {
            var AOIcode  = TargetArea.TargetAreaCodeFromGuid(_AOIGuid);
            var Year     = _SamplingDate.Year.ToString().Substring(2, 2);
            var NextCode = "";

            _AOI_Year_GearCode = AOIcode + Year + "-" + GearCode;
            using (var con = new OleDbConnection(global.ConnectionString))
            {
                con.Open();
                var sql = $"Select Counter from tblRefCodeCounter where GearRefCode = '{_AOI_Year_GearCode}'";

                using (var dt = new DataTable())
                {
                    var adapter = new OleDbDataAdapter(sql, con);
                    try
                    {
                        adapter.Fill(dt);
                    }
                    catch (Exception ex)
                    {
                    }
                    if (dt.Rows.Count > 0)
                    {
                        _counter = int.Parse(dt.Rows[0]["Counter"].ToString());
                        _Has_AOI_Year_GearCode = true;
                    }
                    else
                    {
                        _counter = _RefNoRangeMin;
                        _Has_AOI_Year_GearCode = false;
                    }
                    NextCode = _AOI_Year_GearCode + "-" + (++_counter).ToString("000000");
                }

                return(NextCode);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// add the MBR of a target area as a new map layer
        /// </summary>
        /// <param name="moveMapToMBRCenter"></param>
        public void AddMBRLayer(TargetArea targetArea, bool moveMapToMBRCenter = false)
        {
            var sf = new Shapefile();

            if (sf.CreateNew("", ShpfileType.SHP_POLYGON))
            {
                GeoProjection gp = new GeoProjection();
                gp.SetWgs84();
                sf.GeoProjection = gp;

                int ifldTargetArea = sf.EditAddField("Target area", FieldType.STRING_FIELD, 1, 30);
                int ifldyMax       = sf.EditAddField("yMax", FieldType.DOUBLE_FIELD, 10, 12);
                int ifldxMin       = sf.EditAddField("xMin", FieldType.DOUBLE_FIELD, 10, 12);
                int ifldyMin       = sf.EditAddField("yMin", FieldType.DOUBLE_FIELD, 10, 12);
                int ifldxMax       = sf.EditAddField("xMax", FieldType.DOUBLE_FIELD, 10, 12);
                int ifldWidth      = sf.EditAddField("Width", FieldType.DOUBLE_FIELD, 10, 12);
                int ifldHeight     = sf.EditAddField("Height", FieldType.DOUBLE_FIELD, 10, 12);
                int ifldArea       = sf.EditAddField("Area", FieldType.DOUBLE_FIELD, 15, 17);
                var ext            = new Extents();
                //ext.SetBounds(FishingGrid.LowerRighttExtent.X,
                //    FishingGrid.LowerRighttExtent.Y,
                //    0,
                //    FishingGrid.UpperLeftExtent.X,
                //    FishingGrid.UpperLeftExtent.Y,
                //    0);
                ext.SetBounds(targetArea.UpperLeftPointLL.X, targetArea.LowerRightPointLL.Y, 0,
                              targetArea.LowerRightPointLL.X, targetArea.UpperLeftPointLL.Y, 0);
                var shp  = ext.ToShape();
                int iShp = sf.EditAddShape(shp);
                if (iShp >= 0)
                {
                    sf.EditCellValue(ifldTargetArea, iShp, targetArea.TargetAreaName);
                    if (sf.Labels.Generate("[Target area]", tkLabelPositioning.lpCenter, true) > 0)
                    {
                        sf.Labels.FontSize     = 13;
                        sf.Labels.FrameVisible = false;
                        sf.Labels.Visible      = true;
                        sf.Labels.FontBold     = true;
                    }

                    sf.EditCellValue(ifldyMax, iShp, ext.yMax);
                    sf.EditCellValue(ifldxMin, iShp, ext.xMin);
                    sf.EditCellValue(ifldyMin, iShp, ext.yMin);
                    sf.EditCellValue(ifldxMax, iShp, ext.xMax);

                    sf.EditCellValue(ifldWidth, iShp, targetArea.Width);

                    sf.EditCellValue(ifldHeight, iShp, targetArea.Height);

                    sf.EditCellValue(ifldArea, iShp, targetArea.Area);

                    sf.DefaultDrawingOptions.FillVisible = false;
                    sf.DefaultDrawingOptions.LineColor   = new Utils().ColorByName(tkMapColor.Blue);
                    sf.DefaultDrawingOptions.LineWidth   = 2;
                    AddLayer(sf, "MBR", true, true);
                    if (moveMapToMBRCenter)
                    {
                        ext = MapControl.Extents;
                        ext.MoveTo(sf.Extents.Center.x, sf.Extents.Center.y);
                        MapControl.Extents = ext;
                    }
                }
            }
        }
Ejemplo n.º 8
0
 public TargetAreaGearsForm(TargetArea targetArea)
 {
     InitializeComponent();
     _targetArea = targetArea;
 }