//Save edits when clicked private void DoneButton_Click(object sender, RoutedEventArgs e) { //Populate attributes and save only if the graphic was drawn correctly if (NewSearchArea != null) { //Fill out the attributes of the new search area with user's input object attribute; List <string> attributeNames = new List <string>(NewSearchArea.Attributes.Keys); foreach (string attributeName in attributeNames) { if (SearchAreaAttributes.TryGetValue(attributeName, out attribute)) { NewSearchArea.Attributes[attributeName] = attribute; } } //Save the new search area SearchAreaLayer.SaveEdits(); } // When the user is finished with the toolbar, revert to the configured toolbar. if (MapWidget != null) { MapWidget.SetToolbar(null); } }
/// <summary> /// When user clicks the button, check if there's any selected team and the message to send is empty /// If there is/are selected team(s) and the message is not empty, send the SMS /// </summary> private void btnAssign_Click(object sender, RoutedEventArgs e) { #region Error checking: no team selected or empty message if (CheckListItems.Any(i => i.IsChecked) == false || string.IsNullOrEmpty(txtMessage.Text)) { MessageBox.Show("Make sure one or more team is selected, and the message is not empty"); return; } #endregion try { #region Get the selected teams and check if they have already been assigned to the designated area //1. Get the captions of the checked list items var checkedItemCaptions = from item in CheckListItems where item.IsChecked == true select item.Caption; //2. Fom the caption, get the actual team items that are now checked seletcedTeams = teamFeatureLayer.Graphics.Where(team => checkedItemCaptions.Contains(team.Attributes[nameAttribute].ToString())).ToList(); //3. Check if the same teams have already been assigned. Do not allow assignment if all selected teams have been assiged to that area if (seletcedTeams.Any(team => team.Attributes[areaAttribute].ToString() != searchAreaName) == false) { MessageBox.Show("Teams have been assigned to the designated area already", "Teams Assigned "); return; } #endregion #region Update team assignment //Assign teams by updating their SearchAreaName attributes foreach (client.Graphic team in seletcedTeams) { team.Attributes[areaAttribute] = searchAreaName; } //Save the edits commitEditCount = 0; teamFeatureLayer.EndSaveEdits += teamFeatureLayer_EndSaveEdits; teamFeatureLayer.SaveEdits(); #endregion } catch (Exception) { MessageBox.Show("Error sending message"); this.Close(); } }
void Map_MouseClick(object sender, client.Map.MouseEventArgs e) { if (sizeComboBox.Text=="Select Size") MessageBox.Show("Please select a size of animal before adding to the map."); if (btnAddSighting.IsEnabled == false && sizeComboBox.Text!="Select Size") { ESRI.ArcGIS.Client.Graphic graphicFeature = new client.Graphic(); ESRI.ArcGIS.Client.FeatureLayer featureLayer = new client.FeatureLayer(); featureLayer = this.globalFeatureLayer; ESRI.ArcGIS.Client.Geometry.MapPoint point = new client.Geometry.MapPoint(); point = e.MapPoint; graphicFeature.Geometry=point; graphicFeature.Attributes.Add("size", sizeComboBox.Text.ToString()); featureLayer.Graphics.Add(graphicFeature); featureLayer.SaveEdits(); MessageBox.Show("Successfully added sighting!"); ///Thread.Sleep(10000); //MessageBox.Show("finished"); //featureLayer.Update(); //featureLayer.Refresh(); //globalMapWidget.Map.UpdateLayout(); } }