private void calculateAOI() { Rect topVolume = new Rect(0, 0, Screen.width, 250f); Vector3 topStart = Vector3.zero; Vector3 topEnd = new Vector3(Screen.width, 0, 0); AOI_Top = new AOI(topVolume, topStart, topEnd); }
public void SendAOEMsg(IMessage protocol, bool include_self = true) { AOI scene_aoi = this.GetScene().GetSceneAOI(); //一个玩家多个角色的情况下只需发送一次 Dictionary <int, bool> is_send = new Dictionary <int, bool>(); List <int> target_id_list = scene_aoi.GetRangeEntityId(entity_id); if (include_self) { target_id_list.Add(entity_id); } foreach (int target_id in target_id_list) { Entity entity = Server.GetInstance().GetService <SceneService>().GetSceneMgr().GetEntityById(target_id); if (entity != null && entity.IsBelongPlayer()) { int player_id = entity.GetPlayerId(); Player player = Server.GetInstance().GetService <SceneService>().GetPlayerMgr().GetPlayer(player_id); if (player != null && !is_send.ContainsKey(player_id)) { player.SendMsg(protocol); is_send[player_id] = true; } } } }
public void onAOICreated(AOI aoi) { if (this.aoi != null) //suggest previous values { aoi.Interest = this.aoi.Interest; aoi.Effort = this.aoi.Effort; aoi.Attentiveness = this.aoi.Interest; //aoi.timeRangeStart = this.aoi.timeRangeStart; //aoi.timeRangeEnd = this.aoi.timeRangeEnd; aoi.timeRangeStart = DisplaySlider.LowerValue; aoi.timeRangeEnd = DisplaySlider.HigherValue; } else //set default values { aoi.Interest = 1; aoi.Effort = 1; aoi.Attentiveness = 1; //aoi.timeRangeStart = 0; //aoi.timeRangeEnd = DisplaySlider.Maximum; aoi.timeRangeStart = DisplaySlider.LowerValue; aoi.timeRangeEnd = DisplaySlider.HigherValue; } writeToJSON(aoi); }
public void onRecordingChanged(Recording recording) { if (recording != null) { this.recording = recording; timeline_group.IsEnabled = true; visualisation_group.IsEnabled = true; string[] video = Directory.GetFiles(recording.dataDir, "*.wmv"); if (video.Length == 1) { player.Source = new Uri(video[0]); playback_group.IsEnabled = true; } resolveTimes(); //if (test.currentRecording.fixations.Count > 0) //{ // DisplaySlider.Maximum = recording.fixations[test.currentRecording.fixations.Count - 1].endPos.timestamp; // startTime = DisplaySlider.Minimum = recording.fixations[0].startPos.timestamp; //} //else //{ // startTime = DisplaySlider.Maximum = 0; // DisplaySlider.Minimum = 0; //} DisplaySlider.HigherValue = DisplaySlider.Maximum; DisplaySlider.LowerValue = DisplaySlider.Minimum; } aoi = null; markup_group.IsEnabled = false; }
private void OnButtonClick(object sender, RoutedEventArgs e) { switch (((Button)sender).Name) { case "buttonCancel": MapWindowManager.MapLayersHandler.RemoveLayer(AOIManager._hAOI); Close(); break; case "buttonOk": if (textBoxAOIName.Text.Length > 0) { _aoi = AOIManager.SaveAOI(textBoxAOIName.Text); if (_aoi != null) { Close(); } } else if (_editingAOI) { _aoi = AOIManager.SaveAOI(_aoi.Name, true); buttonOk.IsEnabled = _aoi == null; } break; } }
public static FormatGridMapWindow GetInstance(AOI aoi = null) { if (_instance == null) { _instance = new FormatGridMapWindow(aoi); } return(_instance); }
public FormatGridMapWindow(AOI aoi) { InitializeComponent(); Loaded += OnFormLoaded; Closing += OnWindowClosing; AOI = aoi; Closed += OnWindowClosed; }
private void OnGridSelectedCellChanged(object sender, SelectedCellsChangedEventArgs e) { if (dataGridAOIs.SelectedCells.Count == 1) { DataGridCellInfo cell = dataGridAOIs.SelectedCells[0]; _gridRow = dataGridAOIs.Items.IndexOf(cell.Item); _aoi = (AOI)dataGridAOIs.Items[_gridRow]; } }
public void writeToJSON(AOI aoi) //adapted from https://stackoverflow.com/questions/20626849/how-to-append-a-json-file-without-disturbing-the-formatting { if (aoi != null) { Console.WriteLine("Writing to AOI"); aoi.convertPolygon(); string filePath = recording.dataDir + "\\annotations.json"; List <AOI> aoiList; String jsonData; // Read existing json data if (!File.Exists(filePath)) { File.WriteAllText(filePath, ""); aoiList = new List <AOI>(); } else { jsonData = File.ReadAllText(filePath); // De-serialize to object or create new list aoiList = JsonConvert.DeserializeObject <List <AOI> >(jsonData) ?? new List <AOI>(); } // Add new aoi bool alreadyAnnotated = false; int index = 0; foreach (AOI a in aoiList) { if (Equals(aoi.Name, a.Name) && Equals(aoi.test, a.test)) { index = aoiList.IndexOf(a); alreadyAnnotated = true; } } if (alreadyAnnotated) { aoiList[index] = aoi; } else { aoiList.Add(aoi); } // Update json data string jsonData = JsonConvert.SerializeObject(aoiList, Formatting.Indented); System.IO.File.WriteAllText(filePath, jsonData); } }
public void onTestChanged(Test test) { this.test = test; if (this.aoi != null) { this.aoi = null; } markup_group.IsEnabled = false; timeline_group.IsEnabled = false; visualisation_group.IsEnabled = false; }
private void RemoveAOI_Click(object sender, RoutedEventArgs e) { AOI aoitoremove = (AOI)aoiList.SelectedItem; aoiList.SelectedItem = null; aoiRemoved(); removeFromJSON(aoitoremove); SelectedRecording.Aois.Remove(aoitoremove); aoiList.Items.Refresh(); renderAOIS(); removeAOI.IsEnabled = false; }
/// <summary> /// Definiert zwei AOI Flächen; Links und Rechts für die Rotation, die Später übergeben werden soll /// </summary> private void calculateAOI() { Rect leftVolume = new Rect(0, 0, Screen.width * widthAOI, Screen.height); Vector3 leftStart = Vector3.zero; Vector3 leftEnd = new Vector3(Screen.width * widthAOI, 0, 0); AOI_Left = new AOI(leftVolume, leftStart, leftEnd); Rect rightVolume = new Rect(Screen.width - Screen.width * widthAOI, 0, Screen.width * widthAOI, Screen.height); Vector3 rightEnd = new Vector3(Screen.width, 0, 0); Vector3 rightStart = new Vector3(Screen.width - Screen.width * widthAOI, 0, 0); AOI_Right = new AOI(rightVolume, rightStart, rightEnd); offSetRightAOI = AOI_Right.startPoint.x - AOI_Left.endPoint.x; }
public void endSelection(Polygon p) { //create new aoi AOI aoi = new AOI(SelectedRecording.testName, SelectedRecording.userID); aoi.Name = paragraphBox.SelectedItem.ToString(); aoi.p = p; //check if aoi for this paragraph already exists bool nameExists = false; int existingIndex = 0; foreach (AOI a in SelectedRecording.Aois) { if (Equals(a.Name, aoi.Name)) { nameExists = true; existingIndex = SelectedRecording.Aois.IndexOf(a); break; } } if (!nameExists) { SelectedRecording.Aois.Add(aoi); } else { SelectedRecording.Aois[existingIndex] = aoi; } foreach (AOI a in SelectedRecording.Aois) { a.p.Fill = new SolidColorBrush(Color.FromArgb(100, 255, 250, 205)); a.p.Stroke = new SolidColorBrush(Color.FromRgb(255, 250, 205)); _mainWin.SelectionCanvas.Children.Add(a.p); } drawAoi.IsEnabled = true; removeAOI.IsEnabled = true; aoiCreated(aoi); aoiList.SelectedItem = aoi; aoiList.Items.Refresh(); }
public void onAOIChanged(AOI aoi) { if (aoi != null) { this.aoi = aoi; effort = aoi.Effort; attentiveness = aoi.Attentiveness; interest = aoi.Interest; DisplaySlider.LowerValue = aoi.timeRangeStart; //Console.WriteLine("TRE " + aoi.timeRangeEnd); DisplaySlider.HigherValue = aoi.timeRangeEnd; setCheckBoxes(); markup_group.IsEnabled = true; } else { markup_group.IsEnabled = false; this.aoi = null; } }
public void removeFromJSON(AOI aoi) //adapted from https://stackoverflow.com/questions/20626849/how-to-append-a-json-file-without-disturbing-the-formatting { if (aoi != null) { //set values string filePath = _selectedRecording.dataDir + "\\annotations.json"; List <AOI> aoiList; String jsonData; // Read existing json data if (!File.Exists(filePath)) { File.WriteAllText(filePath, ""); aoiList = new List <AOI>(); } else { jsonData = File.ReadAllText(filePath); // De-serialize to object or create new list aoiList = JsonConvert.DeserializeObject <List <AOI> >(jsonData) ?? new List <AOI>(); } // remove aoi AOI aoitoremove = null; foreach (AOI a in aoiList) //since deserialized object wont be the same object { if (Equals(a.Name, aoi.Name)) { aoitoremove = a; } } aoiList.Remove(aoitoremove); // Update json data string jsonData = JsonConvert.SerializeObject(aoiList, Formatting.Indented); System.IO.File.WriteAllText(filePath, jsonData); } }
public void onLoad(object sender, RoutedEventArgs e) { //if (test == null) //{ test = null; aoi = null; recording = null; effort = 0; attentiveness = 0; interest = 0; DisplaySlider.LowerValue = 0; DisplaySlider.HigherValue = 0; DisplaySlider.Maximum = 0; DisplaySlider.Minimum = 0; timeline_group.IsEnabled = false; visualisation_group.IsEnabled = false; playback_group.IsEnabled = false; foreach (UIElement element in ((Grid)markup_group.Content).Children) { if (Equals(element.GetType(), Attentiveness.GetType())) { foreach (UIElement innerelement in ((StackPanel)element).Children) { if (Equals(innerelement.GetType(), i1.GetType())) { ((RadioButton)innerelement).IsChecked = false; } } } } //} //if(aoi == null) //{ markup_group.IsEnabled = false; //} endMarkup += new endMarkupHandler(((EndCtrl)_mainWindow.ctrlwin.controller.Content).markupExitComplete); }
private bool AssignClassificationToGrid(AOI aoi) { int counter = 0; int idx = aoi.SubGrids.FieldIndexByName[cboGridColumnNames.SelectedItem.ToString()]; aoi.SubGrids.Categories = _categories; aoi.SubGrids.Categories.ClassificationField = idx; for (int x = 0; x < aoi.SubGrids.NumShapes; x++) { for (int c = 0; c < _categories.Count; c++) { if (_categories.Item[c].MinValue != null) { double min = (double)_categories.Item[c].MinValue; double max = (double)_categories.Item[c].MaxValue; double?valueToCategorize = aoi.SubGrids.CellValue[idx, x]; if (valueToCategorize != null) { if (valueToCategorize >= min && valueToCategorize < max) { aoi.SubGrids.ShapeCategory[x] = c; _sheetMapSummary[_categories.Item[c].Name]++; counter++; break; } } else { aoi.SubGrids.ShapeCategory[x] = _nullCategoryIndex; break; } } } } return(counter > 0); }
private void OnGridSelectedCellChanged(object sender, SelectedCellsChangedEventArgs e) { menuRemoveGrid.IsEnabled = false; menuShowGrid.IsEnabled = true; menuGridMapping.IsEnabled = false; menuEditGrid.IsEnabled = false; menuFormatMap.IsEnabled = false; if (dataGridAOIs.SelectedCells.Count == 1) { DataGridCellInfo cell = dataGridAOIs.SelectedCells[0]; _gridRow = dataGridAOIs.Items.IndexOf(cell.Item); _aoi = (AOI)dataGridAOIs.Items[_gridRow]; menuGridMapping.IsEnabled = _aoi.GridIsLoaded; menuRemoveGrid.IsEnabled = _aoi.GridIsLoaded; menuEditGrid.IsEnabled = _aoi.GridFileName != null && _aoi.GridFileName.Length > 0 && !_aoi.GridIsLoaded; menuShowGrid.IsEnabled = !_aoi.GridIsLoaded; menuFormatMap.IsEnabled = _aoi.GridMapping.IsBerriedMapped || _aoi.GridMapping.IsCPUEMapped || _aoi.GridMapping.IsFishingInternsityMapped || _aoi.GridMapping.IsUndersizedMapped; } }
private async void RenderSymbols(Dictionary <string, object> info, bool initialize = false) { FeatureCollectionTable dTable; FeatureCollectionTable uTable; DictionaryRenderer dRend; UniqueValueRenderer uRend; string[] codes = Newtonsoft.Json.JsonConvert.DeserializeObject <string[]>(info["codes"].ToString()); int page = int.Parse(info["page"].ToString()); if (initialize) { // Create the default symbol SimpleMarkerSymbol sms = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Colors.Red, 12) { Outline = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Colors.Black, 1) }; // Create the Dictionary and Unique Value renderers dRend = new DictionaryRenderer(DictionarySymbolStyle.OpenAsync("mil2525c_b2", StylePath).Result); uRend = new UniqueValueRenderer(new[] { FieldName }, null, "MilSymbol", sms); // Create the fields for the Feature Collection table Field[] fields = { new Field(FieldType.Text, FieldName, FieldName, 15) }; // Create the Feature Collection Tables dTable = new FeatureCollectionTable(fields, GeometryType.Point, SpatialReferences.WebMercator) { Renderer = dRend }; uTable = new FeatureCollectionTable(fields, GeometryType.Point, SpatialReferences.WebMercator) { Renderer = uRend }; // Add the tables to the feature collection FeatureCollection collection = new FeatureCollection(new[] { dTable, uTable }); // Add the collection to the map MyMapView.Map.OperationalLayers.Add(new FeatureCollectionLayer(collection)); } else { // Get the feature collection from the map FeatureCollection collection = (MyMapView.Map.OperationalLayers.First() as FeatureCollectionLayer).FeatureCollection; // Get the tables from the collection dTable = collection.Tables.First(); uTable = collection.Tables.Last(); // Clear the records from the table and overlay QueryParameters query = new QueryParameters { WhereClause = "1=1" }; await dTable.DeleteFeaturesAsync(dTable.QueryFeaturesAsync(query).Result); await uTable.DeleteFeaturesAsync(uTable.QueryFeaturesAsync(query).Result); MyMapView.GraphicsOverlays.First().Graphics.Clear(); // Clear the symbols from the unique value renderer (uTable.Renderer as UniqueValueRenderer)?.UniqueValues.Clear(); } // Show the Page # MapPoint titleLocation = new MapPoint(AOI.GetCenter().X, AOI.Extent.YMax + 25); TextSymbol titleBar = new TextSymbol { Text = string.Format("Page: {0}", page), Color = Colors.Black, BackgroundColor = Colors.DodgerBlue, FontWeight = Esri.ArcGISRuntime.Symbology.FontWeight.Bold, Size = 50, HorizontalAlignment = Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Center, VerticalAlignment = Esri.ArcGISRuntime.Symbology.VerticalAlignment.Bottom, OutlineColor = Colors.Black, OutlineWidth = 2 }; MyMapView.GraphicsOverlays.First().Graphics.Add(new Graphic(titleLocation, titleBar)); int rows = codes.Length / Columns; double rowMargin = (AOI.XMax - AOI.XMin) / (Columns - 1); double colMargin = (AOI.YMax - AOI.YMin) / rows; int count = 0; for (double x = AOI.XMin; x < AOI.XMax; x += rowMargin) { if (count >= codes.Length) { break; } for (double y = AOI.YMax; y > AOI.YMin; y -= colMargin) { if (count >= codes.Length) { break; } string code = codes[count]; if (code.Length != 15) { System.Diagnostics.Debug.WriteLine(string.Format("Possible invalid code: {0}", code)); } else { // Create features with the sidc code Feature dFeature = dTable.CreateFeature(new Dictionary <string, object> { { FieldName, code } }, new MapPoint(x, y, SpatialReferences.WebMercator)); Feature uFeature = uTable.CreateFeature(new Dictionary <string, object> { { FieldName, code } }, new MapPoint(x + (rowMargin * 0.5), y, SpatialReferences.WebMercator)); // Create a label to display the code TextSymbol label = new TextSymbol { Text = code, FontWeight = Esri.ArcGISRuntime.Symbology.FontWeight.Bold, Color = Colors.DarkGoldenrod, BackgroundColor = Colors.Black, FontFamily = "Consolas", Size = 16 }; MapPoint labelPoint = new MapPoint(x + (rowMargin * 0.25), y - (colMargin * 0.25), SpatialReferences.WebMercator); MyMapView.GraphicsOverlays.First().Graphics.Add(new Graphic(labelPoint, label)); // Add the feature to the table await dTable.AddFeatureAsync(dFeature); await uTable.AddFeatureAsync(uFeature); // Triple the size of the Unique Value symbol MultilayerPointSymbol symbol = (MultilayerPointSymbol)(dTable.Renderer as DictionaryRenderer).GetSymbol(dFeature); symbol.Size *= 3; // Add the military symbol to the unique value renderer UniqueValue uval = new UniqueValue(code, code, symbol, code); (uTable.Renderer as UniqueValueRenderer).UniqueValues.Add(uval); } count++; System.Diagnostics.Debug.WriteLine(string.Format(@"Processed feature {0} for {1}...", count, codes.Length)); } } }
public void onAOIRemoved() { this.aoi = null; }
private void OnButtonClick(object sender, RoutedEventArgs e) { Button btn = (Button)sender; switch (btn.Name) { case "buttonProcessGrid": case "buttonShowGrid": case "buttonFormatMaps": if (Entities.AOIViewModel.CountSelected() > 0) { switch (btn.Name) { case "buttonShowGrid": Entities.AOIViewModel.SetGridFilenamesOfCommonSize(); if (Entities.AOIViewModel.CommonGridSizes.Count > 1) { SelectGridFileWindow sgw = new SelectGridFileWindow(); sgw.CommonGridSizes = Entities.AOIViewModel.CommonGridSizes; if ((bool)sgw.ShowDialog()) { //Entities.AOIViewModel.CommonGridSizeSelectedSize = sgw.SelectedGridSize; foreach (var aoi in Entities.AOIViewModel.GetSelectedAOIs()) { var file = aoi.GetGridFileNameOfGridSize(((int)sgw.SelectedGridSize).ToString()); aoi.CreateGridFromFileName(file); } } } else if (Entities.AOIViewModel.CommonGridSizes.Count == 1) { foreach (var aoi in Entities.AOIViewModel.GetSelectedAOIs()) { var file = aoi.GetGridFileNameOfGridSize(Entities.AOIViewModel.CommonGridSizes[0]); aoi.CreateGridFromFileName(file); } } SetDataGridContext(); break; case "buttonProcessGrid": var griddedAOICount = Entities.AOIViewModel.GetSelectedAOIs().Count(t => t.SubGrids != null); if (griddedAOICount == Entities.AOIViewModel.CountSelected()) { ShowGridMappingWindow(mulitpleAOIs: true); } else { MessageBox.Show("All selected AOIs must have a grid", "GPX Manager", MessageBoxButton.OK, MessageBoxImage.Information); } break; case "buttonFormatMaps": FormatGridMapWindow fmw = FormatGridMapWindow.GetInstance(_aoi); if (fmw.Visibility == Visibility.Visible) { fmw.BringIntoView(); } else { fmw.Owner = this; fmw.Show(); } break; } } else { MessageBox.Show("At least one AOI must be selected", "GPX Manager", MessageBoxButton.OK, MessageBoxImage.Information); } break; case "buttonCancel": MapWindowManager.MapLayersHandler.RemoveLayer(AOIManager._hAOI); Close(); break; case "buttonOk": if (textBoxAOIName.Text.Length > 0) { _aoi = AOIManager.SaveAOI(textBoxAOIName.Text); if (_aoi != null) { Close(); } } else if (_editingAOI) { _aoi = AOIManager.SaveAOI(_aoi.Name, true); buttonOk.IsEnabled = _aoi == null; } break; } }
private void setAOIsTopAndDown() { Rect topVolume = new Rect(0, 0, Screen.width, Screen.height * heightAOI); Vector3 topStart = new Vector3(0, 0, 0); Vector3 topEnd = new Vector3(Screen.width, Screen.height * 0.5f, 0); AOI_Top = new AOI(topVolume, topStart, topEnd); Rect downVolume = new Rect(0, Screen.height * 0.5f, Screen.width, Screen.height - Screen.height * heightAOI); Vector3 downEnd = new Vector3(Screen.width, Screen.height, 0); Vector3 downStart = new Vector3(0, Screen.height - Screen.height * 0.5f, 0); AOI_Down = new AOI(downVolume, downStart, downEnd); offSetDownAOI = AOI_Down.startPoint.x - AOI_Top.endPoint.x; }
public GridMapping(AOI aoi) { AOI = aoi; }