Ejemplo n.º 1
0
        private void clickPhotoBox(object sender, EventArgs e)
        {
            Panel_Other controls     = getOtherControls();
            string      photo_column = "";

            if (controls.comboBoxObject.Text == "Sidewalk")
            {
                photo_column = "sidewalk_photos";
            }
            else if (controls.comboBoxObject.Text == "ADA Ramp")
            {
                photo_column = "ada_photos";
            }
            else if (controls.comboBoxObject.Text == "Severe Road Distress")
            {
                photo_column = "severe_distress_photos";
            }
            else if (controls.comboBoxObject.Text == "Accident")
            {
                photo_column = "accident_photos";
            }
            else if (controls.comboBoxObject.Text == "Drainage")
            {
                photo_column = "drainage_photos";
            }
            else if (controls.comboBoxObject.Text == "Other")
            {
                photo_column = "other_photos";
            }

            string subPath = Database.GetDataByQuery(Project.conn, "SELECT " + photo_column + " FROM photo_paths;").Rows[0][0].ToString();

            enlargePicture(controls.textBoxPhotoFile.Text, subPath);
        }
Ejemplo n.º 2
0
        private void moveLandmarkMouseUp(object sender, MouseEventArgs e)
        {
            Panel_Other otherControls = getOtherControls();

            if (e.Button == MouseButtons.Right && otherControls.toolStripMoveLandmark.BackColor == Color.LightSkyBlue)
            {
                otherControls.toolStripMoveLandmark.BackColor = originalColor;
                moveLandmark(sender, e);
                return;
            }
            if (!movingLandmark)
            {
                return;
            }
            FeatureLayer selectionLayer = (FeatureLayer)Layer;

            Properties.Settings.Default.Save();
            selectionLayer.ClearSelection();
            selectionLayer.DataSet.Save();
            setSymbolizer();
            Project.map.Invalidate();
            Project.map.Refresh();
            Project.map.ResetBuffer();
            Project.map.Update();
            if (otherControls.toolStripMoveLandmark.BackColor != originalColor)
            {
                return;
            }
            movingLandmark           = false;
            Project.map.FunctionMode = FunctionMode.Select;
            otherControls.toolStripMoveLandmark.BackColor = originalColor;
        }
Ejemplo n.º 3
0
        private void moveLandmark(object sender, EventArgs e)
        {
            Panel_Other otherControls = getOtherControls();

            if (otherControls.toolStripMoveLandmark.BackColor == Color.LightSkyBlue)
            {
                movingLandmark           = false;
                Project.map.FunctionMode = FunctionMode.Select;
                otherControls.toolStripMoveLandmark.BackColor = originalColor;
                return;
            }
            toggleAddFeature(sender, e);
            originalColor = otherControls.toolStripMoveLandmark.BackColor;
            otherControls.toolStripMoveLandmark.BackColor = Color.LightSkyBlue;
            IFeatureLayer      selectionLayer = (IFeatureLayer)Layer;
            MoveVertexFunction moveLandmark   = new MoveVertexFunction(Project.map);

            moveLandmark.Map        = Project.map;
            moveLandmark.YieldStyle = YieldStyles.LeftButton | YieldStyles.RightButton;
            if (Project.map.MapFunctions.Contains(moveLandmark) == false)
            {
                Project.map.MapFunctions.Add(moveLandmark);
            }
            Project.map.FunctionMode = FunctionMode.None;
            Project.map.Cursor       = Cursors.Cross;
            moveLandmark.DeselectFeature();
            moveLandmark.Layer = selectionLayer;
            SetSnapLayers(moveLandmark);
            moveLandmark.Activate();
            movingLandmark = true;
        }
Ejemplo n.º 4
0
        protected void resetRecordDate(object sender, EventArgs e)
        {
            surveyDate = DateTime.Now;
            Panel_Other controls = getOtherControls();

            controls.setTodayToolStripMenuItem.Checked     = true;
            controls.setOtherDateToolStripMenuItem.Checked = false;
        }
Ejemplo n.º 5
0
        protected void selectRecordDate(object sender, EventArgs e)
        {
            dateForm.Show();
            Panel_Other controls = getOtherControls();

            controls.setTodayToolStripMenuItem.Checked     = false;
            controls.setOtherDateToolStripMenuItem.Checked = true;
        }
Ejemplo n.º 6
0
        private void resetSaveCondition()
        {
            UnsavedChanges = false;
            Panel_Other controls = getOtherControls();

            controls.toolStripButtonSave.Enabled   = false;
            controls.toolStripButtonSave.BackColor = default(Color);
        }
Ejemplo n.º 7
0
        private void enableControls()
        {
            Panel_Other controls = getOtherControls();

            controls.groupBoxType.Enabled          = true;
            controls.toolStrip.Enabled             = true;
            controls.groupBoxProperties.Enabled    = true;
            controls.toolStripButtonRemove.Enabled = tamsids.Count == 1;
        }
Ejemplo n.º 8
0
        protected override void controlChanged(object sender, EventArgs e)
        {
            Panel_Other controls = getOtherControls();

            controls.toolStripButtonSave.Enabled   = true;
            controls.toolStripButtonSave.BackColor = Color.Red;
            UnsavedChanges = true;

            controls.toolStripButtonCancel.Enabled = true;
        }
Ejemplo n.º 9
0
        private void disableDisplay()
        {
            Panel_Other controls = getOtherControls();

            resetSaveCondition();
            controls.groupBoxProperties.Enabled    = false;
            controls.groupBoxType.Enabled          = false;
            controls.toolStripButtonSave.Enabled   = false;
            controls.toolStripButtonCancel.Enabled = false;
            controls.toolStripButtonRemove.Enabled = false;
        }
Ejemplo n.º 10
0
        public override bool openFile(string thePath = "", string type = "point")
        {
            if (type == "")
            {
                type = "point";
            }
            if (type != "point")
            {
                throw new Exception("Generic module requires a point-type shp file");
            }

            ModuleSettings.Add(new ProjectSetting(name: ModuleName + "_f_TAMSID", module: ModuleName, value: "",
                                                  display_text: "SHP field with a unique identifier (TAMSID).", display_type: "field",
                                                  description: "The unique identify for objects in this layer.", required: true));

            injectSettings();

            if (!base.openFile(thePath, type))
            {
                return(false);
            }

            ControlsPage.Controls.Remove(ControlsPage.Controls["MODULEADD"]);
            Panel_Other panel = new Panel_Other(Project);

            panel.Name = "OTHERCONTROLS";
            panel.Dock = DockStyle.Fill;
            ControlsPage.Controls.Add(panel);

            #region eventhandlers
            panel.toolStripMoveLandmark.Click += moveLandmark;
            panel.setChangedHandler(controlChanged);
            panel.toolStripButtonSave.Click               += saveHandler;
            panel.toolStripButtonCancel.Click             += cancelChanges;
            panel.toolStripDropDownAddObject.Click        += toggleAddFeature;
            panel.clickMapToolStripMenuItem.Click         += clickMap;
            panel.enterCoordinatesToolStripMenuItem.Click += enterCoordinates;
            panel.toolStripButtonRemove.Click             += deleteFeature;

            panel.setOtherDateToolStripMenuItem.Click += selectRecordDate;
            panel.setTodayToolStripMenuItem.Click     += resetRecordDate;
            panel.pictureBoxPhoto.Click += clickPhotoBox;
            Project.map.MouseUp         += moveLandmarkMouseUp;
            #endregion

            setMaxID();
            setSymbolizer();
            disableDisplay();
            resetDisplay();
            resetSaveCondition();

            return(true);
        }
Ejemplo n.º 11
0
        private void toggleAddFeature(object sender, EventArgs e)
        {
            Panel_Other otherControls = getOtherControls();

            if (otherControls.toolStripMoveLandmark.BackColor == Color.LightSkyBlue)
            {
                movingLandmark           = false;
                Project.map.FunctionMode = FunctionMode.Select;
                otherControls.toolStripMoveLandmark.BackColor = originalColor;
            }

            if (otherControls.toolStripDropDownAddObject.BackColor == Color.LightSkyBlue)
            {
                addLandmark = true;
                clickMap(sender, e);
            }
        }
Ejemplo n.º 12
0
        private void clickMap(object sender, EventArgs e)
        {
            Panel_Other otherControls = getOtherControls();

            bool hasStreetMap = false;
            bool hasSignMap   = false;

            addLandmark = !addLandmark;

            if (!addLandmark)
            {
                Project.map.MouseUp -= mapMouseUp;
                otherControls.toolStripDropDownAddObject.BackColor = originalColor;
                return;
            }
            otherControls.toolStripDropDownAddObject.BackColor = Color.LightSkyBlue;

            for (int i = 0; i < Project.map.Layers.Count; i++)
            {
                if (((FeatureLayer)Project.map.Layers[i]).Name.Contains("road"))
                {
                    hasStreetMap = true;
                }
                if (((FeatureLayer)Project.map.Layers[i]).Name.Contains("sign"))
                {
                    if (((FeatureLayer)Project.map.Layers[i]).FeatureSet.DataTable.Rows.Count > 0)
                    {
                        hasSignMap = true;
                    }
                }
            }

            if (Project.map.GetMaxExtent().IsEmpty() || (Layer.Extent.IsEmpty() && !hasStreetMap && !hasSignMap))
            {
                MessageBox.Show("Map has no view extent, please open a road SHP file or add feature support by coordinates.", "No view extent", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            Project.map.MouseClick += new MouseEventHandler(delegate(object _sender, MouseEventArgs _e) { determineLeftClick(_sender, _e); });
            Project.map.MouseUp    += mapMouseUp;
        }
Ejemplo n.º 13
0
        private void clickPhotoBox(object sender, EventArgs e)
        {
            Panel_Other controls = getOtherControls();

            enlargePicture(controls.textBoxPhotoFile.Text);
        }
Ejemplo n.º 14
0
        public void saveHandler(object sender, EventArgs e)
        {
            FeatureLayer selectionLayer = (FeatureLayer)Layer;
            ISelection   shpSelection   = selectionLayer.Selection;
            string       tamsidcolumn   = Project.settings.GetValue(ModuleName + "_f_TAMSID");

            Panel_Other controls = getOtherControls();
            Dictionary <string, string> values = new Dictionary <string, string>();

            values["type"]        = controls.comboBoxObject.Text;
            values["icon"]        = Util.DictionaryItemString(icons, controls.comboBoxObject.Text);
            values["address"]     = controls.textBoxAddress.Text;
            values["description"] = controls.textBoxDescription.Text;
            values["photo"]       = controls.textBoxPhotoFile.Text;
            values["property1"]   = controls.getProperty(values["type"], 0);
            values["property2"]   = controls.getProperty(values["type"], 1);
            values["property3"]   = controls.getProperty(values["type"], 2);
            values["notes"]       = controls.getProperty(values["type"], 3);

            if (!string.IsNullOrWhiteSpace(controls.textBoxPhotoFile.Text))
            {
                Properties.Settings.Default.lastPhoto = controls.textBoxPhotoFile.Text;
            }

            for (int i = 0; i < tamsids.Count; i++)
            {
                values["TAMSID"] = tamsids[i];
                Dictionary <string, string> v = new Dictionary <string, string>();

                foreach (string key in values.Keys)
                {
                    v[key] = values[key];
                    if ((string.IsNullOrWhiteSpace(values[key]) || values[key].Equals("multi") || values[key].Equals("-1") || key.Equals("category")) && selectionValues.Count > 1)
                    {
                        if (i < selectionValues.Count && selectionValues[i].ContainsKey(key))
                        {
                            v[key] = selectionValues[i][key];
                        }
                    }
                }

                if (!Database.ReplaceRow(Project.conn, v, ModuleName))
                {
                    MessageBox.Show("Could not save data!");
                }
            }

            string tamsidsCSV = string.Join(",", tamsids.ToArray());

            foreach (DataRow row in selectionLayer.DataSet.DataTable.Select(tamsidcolumn + " IN (" + tamsidsCSV + ")"))
            {
                row["TAMSICON"] = values["icon"];
            }

            resetSaveCondition();

            Properties.Settings.Default.Save();
            selectionLayer.ClearSelection();
            selectionLayer.DataSet.Save();
            setSymbolizer();
            Project.map.Invalidate();
            Project.map.Refresh();
            Project.map.ResetBuffer();
            Project.map.Update();
        }