/// <summary> /// Sets the initial state of this editor and sets up any databinding /// within such that user interface changes will propagate back to the /// model. /// </summary> /// <param name="service"></param> public override void Bind(IEditorService service) { _edSvc = service; _map = _edSvc.GetEditedResource() as IMapDefinition; _map.SetExtentsFromFirstAddedLayer = true; mapSettingsCtrl.Bind(service); mapLayersCtrl.Bind(service); var mp2 = _map as IMapDefinition2; if (mp2 != null) { this.Controls.Remove(mapSettingsCtrl); this.Controls.Remove(mapLayersCtrl); var wm = new WatermarkCollectionEditorCtrl(service, mp2); wm.Dock = DockStyle.Fill; this.Controls.Add(wm); this.Controls.Add(mapLayersCtrl); this.Controls.Add(mapSettingsCtrl); } mapLayersCtrl.RequestLayerOpen += new OpenLayerEventHandler(OnRequestLayerOpen); }
public GroupPropertiesCtrl(IMapDefinition map, IMapLayerGroup group) : this() { _init = true; try { _mdf = map; _el = group; group.PropertyChanged += new PropertyChangedEventHandler(OnGroupChanged); string currentName = group.Name; txtName.Text = currentName; //TextBoxBinder.BindText(txtName, group, "Name"); /* IMapDefinition mdf = group.Parent; string currentName = group.Name; txtName.Text = currentName; txtName.TextChanged += (s, e) => { string newName = txtName.Text; group.Name = newName; mdf.UpdateDynamicGroupName(currentName, newName); System.Diagnostics.Debug.WriteLine(string.Format("Updated group name {0} -> {1}", currentName, newName)); currentName = newName; };*/ TextBoxBinder.BindText(txtLegendLabel, group, "LegendLabel"); } finally { _init = false; } }
//--------------------------------------------------------------------- /// <summary> /// Initializes a new instance. /// </summary> /// <param name="timestep"></param> /// <param name="mapDefns"></param> /// <param name="mapFileNames"></param> public Parameters(int timestep, IMapDefinition[] mapDefns, string mapFileNames) { this.timestep = timestep; this.mapDefns = mapDefns; this.mapFileNames = mapFileNames; }
//--------------------------------------------------------------------- /// <summary> /// Initializes a new instance. /// </summary> /// <param name="timestep"></param> /// <param name="coefficients"></param> /// <param name="mapDefns"></param> /// <param name="mapFileNames"></param> public Parameters(int timestep, double[] coefficients, IMapDefinition[] mapDefns, string mapFileNames) { this.timestep = timestep; this.coefficients = coefficients; this.mapDefns = mapDefns; this.mapFileNames = mapFileNames; }
public MapViewModel() { _viewConfiguration = DependencyFactory.Container.Resolve<IViewConfiguration>(); _mapDefinition = DependencyFactory.Container.Resolve<IMapDefinition>(); Markers = _mapDefinition.Markers; RegisterOnKinectEvents(); Configuration.postureNavigation = true; }
/// <summary> /// Initializes a new instance of the <see cref="ExtentCalculationDialog"/> class. /// </summary> /// <param name="mdf">The MDF.</param> public ExtentCalculationDialog(IMapDefinition mdf) { InitializeComponent(); _mdf = mdf; grdCalculations.DataSource = _results; prgCalculations.Maximum = mdf.GetLayerCount(); if (mdf.BaseMap != null) prgCalculations.Maximum += GetLayerCount(mdf.BaseMap); txtCoordinateSystem.Text = mdf.CoordinateSystem; }
public MapSettingsDialog(IServerConnection conn, IMapDefinition mdf, IMapViewer viewer) { InitializeComponent(); _conn = conn; _viewer = viewer; txtCoordinateSystem.Text = mdf.CoordinateSystem; var ext = mdf.Extents; txtLowerX.Text = ext.MinX.ToString(CultureInfo.InvariantCulture); txtLowerY.Text = ext.MinY.ToString(CultureInfo.InvariantCulture); txtUpperX.Text = ext.MaxX.ToString(CultureInfo.InvariantCulture); txtUpperY.Text = ext.MaxY.ToString(CultureInfo.InvariantCulture); cmbBackgroundColor.ResetColors(); cmbBackgroundColor.CurrentColor = mdf.BackgroundColor; _mdf = mdf; btnUseCurrentView.Visible = (_viewer != null); }
public ToolboxViewModel() { _mapDefinition = DependencyFactory.Container.Resolve<IMapDefinition>(); Cities = new List<string>() {"Record", "Replay"}; //var kinectSensor = DependencyFactory.Container.Resolve<KinectSensor>(); var testKinect = DependencyFactory.Container.Resolve<TKinect.TKinect>(); _framesCollector = new FramesCollector(testKinect); //_postureAnalyzer = new PostureAnalyzer(_framesCollector); //_postureAnalyzer.PostureDetected += PostureAnalyzerOnPostureDetected; //_handSwipeAnalyzer = new SwipeAnalyzer(_framesCollector, JointType.HandRight); //_handSwipeAnalyzer.SwipeDetected += HandSwipeAnalyzerOnSwipeDetected; }
public FiniteScaleListCtrl(IMapDefinition map, IEditorService editorSvc) : this() { _map = map; _edSvc = editorSvc; //Init scale list if (_map.BaseMap != null) { foreach (var scale in _map.BaseMap.FiniteDisplayScale) { _scales.Add(scale); } } //Now wire change events _scales.ListChanged += new ListChangedEventHandler(OnScaleListChanged); }
public GroupPropertiesCtrl(IMapDefinition map, IBaseMapGroup group) : this() { _init = true; try { _mdf = map; _el = group; group.PropertyChanged += new PropertyChangedEventHandler(OnGroupChanged); txtName.Text = group.Name; TextBoxBinder.BindText(txtLegendLabel, group, "LegendLabel"); } finally { _init = false; } }
/// <summary> /// Gets the number of groups (non-tiled) on this map /// </summary> /// <param name="map"></param> /// <returns></returns> public static int GetGroupCount(this IMapDefinition map) { Check.ArgumentNotNull(map, nameof(map)); return(new List <IMapLayerGroup>(map.MapLayerGroup).Count); }
public GroupedLayerModel(IMapDefinition map) { _map = map; }
public override void Bind(IEditorService service) { cmbBackgroundColor.ResetColors(); _service = service; _service.RegisterCustomNotifier(this); _map = (IMapDefinition)service.GetEditedResource(); var bmeta = new Binding("Text", _map, "Metadata"); bmeta.Parse += (sender, e) => { e.Value = META_START + e.Value + META_END; }; bmeta.Format += (sender, e) => { if (e.Value != null) { var str = e.Value.ToString(); if (str.StartsWith(META_START) && str.EndsWith(META_END)) { e.Value = str.Substring(META_START.Length, str.Length - (META_START.Length + META_END.Length)); } } }; TextBoxBinder.BindText(txtDescription, bmeta); TextBoxBinder.BindText(txtCoordinateSystem, _map, "CoordinateSystem"); //ColorComboBox requires custom databinding cmbBackgroundColor.CurrentColor = _map.BackgroundColor; cmbBackgroundColor.SelectedIndexChanged += (sender, e) => { _map.BackgroundColor = cmbBackgroundColor.CurrentColor; }; _map.PropertyChanged += (sender, e) => { if (e.PropertyName == "BackgroundColor") { cmbBackgroundColor.CurrentColor = _map.BackgroundColor; } else if (e.PropertyName == "Extents") { UpdateExtentsFromMap(); } }; txtLowerX.Text = _map.Extents.MinX.ToString(CultureInfo.InvariantCulture); txtLowerY.Text = _map.Extents.MinY.ToString(CultureInfo.InvariantCulture); txtUpperX.Text = _map.Extents.MaxX.ToString(CultureInfo.InvariantCulture); txtUpperY.Text = _map.Extents.MaxY.ToString(CultureInfo.InvariantCulture); txtLowerX.TextChanged += (s, e) => { if (_updatingExtents) return; if (txtLowerX.Text.EndsWith(".")) //Maybe typing in decimals atm return; double d; if (double.TryParse(txtLowerX.Text, out d)) _map.Extents.MinX = d; }; txtLowerY.TextChanged += (s, e) => { if (_updatingExtents) return; if (txtLowerY.Text.EndsWith(".")) //Maybe typing in decimals atm return; double d; if (double.TryParse(txtLowerY.Text, out d)) _map.Extents.MinY = d; }; txtUpperX.TextChanged += (s, e) => { if (_updatingExtents) return; if (txtUpperX.Text.EndsWith(".")) //Maybe typing in decimals atm return; double d; if (double.TryParse(txtUpperX.Text, out d)) _map.Extents.MaxX = d; }; txtUpperY.TextChanged += (s, e) => { if (_updatingExtents) return; if (txtUpperY.Text.EndsWith(".")) //Maybe typing in decimals atm return; double d; if (double.TryParse(txtUpperY.Text, out d)) _map.Extents.MaxY = d; }; _map.Extents.PropertyChanged += (sender, e) => { UpdateExtentsFromMap(); OnResourceChanged(); }; }
//--------------------------------------------------------------------- protected override IInputParameters Parse() { ReadLandisDataVar(); InputParameters parameters = new InputParameters(SpeciesDataset.Count); InputVar <int> timestep = new InputVar <int>("Timestep"); ReadVar(timestep); parameters.Timestep = timestep.Value; InputVar <string> speciesName = new InputVar <string>("Species"); Dictionary <string, int> lineNumbers = new Dictionary <string, int>(); const string ReclassMaps = "ReclassMaps"; // Read definitions of reclass maps ReadName(ReclassMaps); InputVar <string> mapName = new InputVar <string>("Map Name"); InputVar <string> forestType = new InputVar <string>("Forest Type"); lineNumbers.Clear(); Dictionary <string, int> forestTypeLineNumbers = new Dictionary <string, int>(); const string MapFileNames = "MapFileNames"; const string nameDelimiter = "->"; // delimiter that separates map name and forest type IMapDefinition mapDefn = null; while (!AtEndOfInput && CurrentName != MapFileNames) { StringReader currentLine = new StringReader(CurrentLine); // If the current line has the delimiter, then read the map // name. if (CurrentLine.Contains(nameDelimiter)) { ReadValue(mapName, currentLine); CheckForRepeatedName(mapName.Value, "map name", lineNumbers); mapDefn = new MapDefinition(); mapDefn.Name = mapName.Value; parameters.ReclassMaps.Add(mapDefn); TextReader.SkipWhitespace(currentLine); string word = TextReader.ReadWord(currentLine); if (word != nameDelimiter) { throw NewParseException("Expected \"{0}\" after the map name {1}.", nameDelimiter, mapName.Value.String); } forestTypeLineNumbers.Clear(); } else { // If there is no name delimiter and we don't have the // name for the first map yet, then it's an error. if (mapDefn == null) { throw NewParseException("Expected a line with map name followed by \"{0}\"", nameDelimiter); } } ReadValue(forestType, currentLine); CheckForRepeatedName(forestType.Value, "forest type", forestTypeLineNumbers); IForestType currentForestType = new ForestType(SpeciesDataset.Count); currentForestType.Name = forestType.Value; mapDefn.ForestTypes.Add(currentForestType); // Read species for forest types List <string> speciesNames = new List <string>(); TextReader.SkipWhitespace(currentLine); while (currentLine.Peek() != -1) { ReadValue(speciesName, currentLine); string name = speciesName.Value.Actual; bool negativeMultiplier = name.StartsWith("-"); if (negativeMultiplier) { name = name.Substring(1); if (name.Length == 0) { throw new InputValueException(speciesName.Value.String, "No species name after \"-\""); } } ISpecies species = GetSpecies(new InputValue <string>(name, speciesName.Value.String)); if (speciesNames.Contains(species.Name)) { throw NewParseException("The species {0} appears more than once.", species.Name); } speciesNames.Add(species.Name); currentForestType[species.Index] = negativeMultiplier ? -1 : 1; TextReader.SkipWhitespace(currentLine); } if (speciesNames.Count == 0) { throw NewParseException("At least one species is required."); } GetNextLine(); } // Template for filenames of reclass maps InputVar <string> mapFileNames = new InputVar <string>(MapFileNames); ReadVar(mapFileNames); parameters.MapFileNames = mapFileNames.Value; CheckNoDataAfter(string.Format("the {0} parameter", MapFileNames)); return(parameters); //.GetComplete(); }
/// <summary> /// Initializes a new instance of the <see cref="RuntimeMap"/> class. /// </summary> /// <param name="mdf">The map definition to create this map from.</param> /// <param name="metersPerUnit">The meters per unit value</param> /// <param name="suppressErrors"></param> internal RuntimeMap(IMapDefinition mdf, double metersPerUnit, bool suppressErrors) : this(mdf.CurrentConnection) { this.MetersPerUnit = metersPerUnit; this.MapDefinition = mdf.ResourceID; this.MapExtent = mdf.Extents.Clone(); this.DataExtent = mdf.Extents.Clone(); this.BackgroundColor = mdf.BackgroundColor; this.CoordinateSystem = mdf.CoordinateSystem; //TODO: infer real mpu from coordinate system //If a setup helper exists, use it to get required layers in a single //batch. Eliminating lots of chatter for really large maps. if (_getRes != null) { Debug.WriteLine("[RuntimeMap.ctor]: Batching layer requests"); //NOXLATE var res = _getRes.Execute(GetLayerIds(mdf)); //Pre-populate layer def cache so GetLayerDefinition() returns these //instead of making a new request foreach (var key in res.Keys) { var layer = res[key] as ILayerDefinition; if (layer != null) layerDefinitionCache.Add(key, layer); } Debug.WriteLine("[RuntimeMap.ctor]: {0} layers pre-cached", layerDefinitionCache.Count); //NOXLATE } //Load map layers foreach (var layer in mdf.MapLayer) { var rtl = _mapSvc.CreateMapLayer(this, layer, suppressErrors); this.Layers.Add(rtl); } //Load map groups foreach (var group in mdf.MapLayerGroup) { var grp = _mapSvc.CreateMapGroup(this, group); this.Groups.Add(grp); } //If base map specified load layers and groups there if (mdf.BaseMap != null) { var bm = mdf.BaseMap; foreach (var group in bm.BaseMapLayerGroup) { if (group.HasLayers()) { foreach (var layer in group.BaseMapLayer) { var rtl = _mapSvc.CreateMapLayer(this, layer); rtl.Type = RuntimeMapLayer.kDynamic; //HACK: Setting Visible = true not allowed for kBaseMap rtl.Visible = true; rtl.Type = RuntimeMapLayer.kBaseMap; rtl.Group = group.Name; this.Layers.Add(rtl); } } var rtg = _mapSvc.CreateMapGroup(this, group); this.Groups.Add(rtg); } //Init finite display scales if (bm.ScaleCount > 0) { _finiteDisplayScales = new double[bm.ScaleCount]; for (int i = 0; i < bm.ScaleCount; i++) { _finiteDisplayScales[i] = bm.GetScaleAt(i); } } } this.LayerRefreshMode = 1; this.ViewScale = 1.0; //TODO: Calc from extents and other parameters this.DisplayDpi = 96; this.DisplayWidth = 0; this.DisplayHeight = 0; var pt = this.DataExtent.Center(); this.SetViewCenter(pt.X, pt.Y); _disableChangeTracking = false; }
/// <summary> /// Updates and replaces the layer/group structure of the specified Map Definition with the /// layer/group structure of this Runtime Map /// </summary> /// <param name="newMdf"></param> public void UpdateMapDefinition(IMapDefinition newMdf) { newMdf.RemoveAllLayers(); newMdf.RemoveAllGroups(); newMdf.RemoveBaseMap(); var baseGroups = new List<RuntimeMapGroup>(); newMdf.CoordinateSystem = this.CoordinateSystem; newMdf.Extents = this.MapExtent; //Add dynamic groups for (int i = this.Groups.Count - 1; i >= 0; i--) { //Deal with base groups later if (this.Groups[i].Type == RuntimeMapGroup.kBaseMap) { baseGroups.Add(this.Groups[i]); continue; } var rtGroup = this.Groups[i]; var newGroup = newMdf.AddGroup(rtGroup.Name); newGroup.Group = rtGroup.Group; newGroup.ExpandInLegend = rtGroup.ExpandInLegend; newGroup.LegendLabel = rtGroup.LegendLabel; newGroup.ShowInLegend = rtGroup.ShowInLegend; newGroup.Visible = rtGroup.Visible; } var baseLayers = new List<RuntimeMapLayer>(); //Populate dynamic layers. Loop in reverse order so that they are added in correct draw order for (int i = this.Layers.Count - 1; i >= 0; i--) { //Deal with base layers later if (this.Layers[i].Type == RuntimeMapLayer.kBaseMap) { baseLayers.Add(this.Layers[i]); continue; } var rtLayer = this.Layers[i]; var newLayer = newMdf.AddLayer(rtLayer.Group, rtLayer.Name, rtLayer.LayerDefinitionID); newLayer.ExpandInLegend = rtLayer.ExpandInLegend; newLayer.LegendLabel = rtLayer.LegendLabel; newLayer.Selectable = rtLayer.Selectable; newLayer.ShowInLegend = rtLayer.ShowInLegend; newLayer.Visible = rtLayer.Visible; } if (baseLayers.Count > 0 && baseGroups.Count > 0) { newMdf.InitBaseMap(); //Add finite scales first for (int i = _finiteDisplayScales.Length - 1; i >= 0; i--) { newMdf.BaseMap.AddFiniteDisplayScale(_finiteDisplayScales[i]); } var baseGroupsByName = new Dictionary<string, IBaseMapGroup>(); //Now groups for (int i = baseGroups.Count - 1; i >= 0; i--) { var rtGroup = baseGroups[i]; var newGroup = newMdf.BaseMap.AddBaseLayerGroup(rtGroup.Name); newGroup.ExpandInLegend = rtGroup.ExpandInLegend; newGroup.LegendLabel = rtGroup.LegendLabel; newGroup.ShowInLegend = rtGroup.ShowInLegend; newGroup.Visible = rtGroup.Visible; baseGroupsByName.Add(newGroup.Name, newGroup); } //Then layers. Loop in reverse order so that they are added in correct draw order for (int i = baseLayers.Count - 1; i >= 0; i--) { var rtLayer = baseLayers[i]; //Should always happen if (baseGroupsByName.ContainsKey(rtLayer.Group)) { var newLayer = baseGroupsByName[rtLayer.Group].AddLayer(rtLayer.Name, rtLayer.LayerDefinitionID); newLayer.ExpandInLegend = rtLayer.ExpandInLegend; newLayer.LegendLabel = rtLayer.LegendLabel; newLayer.Selectable = rtLayer.Selectable; newLayer.ShowInLegend = rtLayer.ShowInLegend; } } } }
public unsafe bool Update(IMapDefinition mapDefinition) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) EventSystem current = EventSystem.get_current(); if (null != current && current.IsPointerOverGameObject()) { if (InputUtility.GetPointerUp()) { int clickedMouseButton; if (m_mouseButtonIsDown) { Vector2Int?mouseButtonPressLocation = this.mouseButtonPressLocation; Vector2Int?targetCell = this.targetCell; clickedMouseButton = ((mouseButtonPressLocation.HasValue == targetCell.HasValue && (!mouseButtonPressLocation.HasValue || mouseButtonPressLocation.GetValueOrDefault() == targetCell.GetValueOrDefault())) ? 1 : 0); } else { clickedMouseButton = 0; } this.clickedMouseButton = ((byte)clickedMouseButton != 0); pressedMouseButton = false; releasedMouseButton = true; this.mouseButtonPressLocation = null; mouseButtonReleaseLocation = this.targetCell; m_mouseButtonIsDown = false; } else { this.clickedMouseButton = false; pressedMouseButton = false; releasedMouseButton = false; } if (this.targetCell.HasValue) { this.targetCell = null; return(true); } return(false); } bool result = false; Vector3 pointerPosition = InputUtility.pointerPosition; bool flag = pointerPosition != m_previousMousePosition; if (null != m_cameraHandler && m_cameraHandler.userHasControl) { Rect pixelRect = m_camera.get_pixelRect(); if (pixelRect.Contains(pointerPosition)) { if (InputUtility.GetTertiaryDown()) { FightStatus local = FightStatus.local; if (local != null) { m_cameraHandler.StartFocusOnMapRegion(mapDefinition, local.fightId); } else { m_cameraHandler.StartFocusOnMapRegion(mapDefinition, 0); } } else if (InputUtility.IsSecondaryDown()) { if (flag) { m_cameraHandler.Pan(Vector2.op_Implicit(pointerPosition), Vector2.op_Implicit(m_previousMousePosition)); } } else { float y = ((IntPtr)(void *)Input.get_mouseScrollDelta()).y; if (Math.Abs(y) > float.Epsilon) { m_cameraHandler.TweenZoom(y); } } } } if (flag || m_forceUpdate) { if (null != m_camera) { Ray val = m_camera.ScreenPointToRay(pointerPosition); RaycastHit val2 = default(RaycastHit); if (m_collider.Raycast(val, ref val2, m_camera.get_farClipPlane())) { Vector3 val3 = val2.get_point() - m_collider.get_transform().get_position(); int num = Mathf.RoundToInt(((IntPtr)(void *)val3).x); int num2 = Mathf.RoundToInt(((IntPtr)(void *)val3).z); Vector2Int val4 = default(Vector2Int); val4._002Ector(num, num2); if (!this.targetCell.HasValue || this.targetCell.Value != val4) { this.targetCell = val4; result = true; } } else if (this.targetCell.HasValue) { this.targetCell = null; result = true; } } m_forceUpdate = false; m_previousMousePosition = pointerPosition; } if (InputUtility.GetPointerDown()) { pressedMouseButton = true; releasedMouseButton = false; this.clickedMouseButton = false; this.mouseButtonPressLocation = this.targetCell; mouseButtonReleaseLocation = null; m_mouseButtonIsDown = true; } else if (InputUtility.GetPointerUp()) { int clickedMouseButton2; if (m_mouseButtonIsDown) { Vector2Int?targetCell = this.mouseButtonPressLocation; Vector2Int?mouseButtonPressLocation = this.targetCell; clickedMouseButton2 = ((targetCell.HasValue == mouseButtonPressLocation.HasValue && (!targetCell.HasValue || targetCell.GetValueOrDefault() == mouseButtonPressLocation.GetValueOrDefault())) ? 1 : 0); } else { clickedMouseButton2 = 0; } this.clickedMouseButton = ((byte)clickedMouseButton2 != 0); pressedMouseButton = false; releasedMouseButton = true; this.mouseButtonPressLocation = null; mouseButtonReleaseLocation = this.targetCell; m_mouseButtonIsDown = false; } else { this.clickedMouseButton = false; pressedMouseButton = false; releasedMouseButton = false; } return(result); }
/// <summary> /// Validats the specified resources for common issues associated with this /// resource type /// </summary> /// <param name="context"></param> /// <param name="resource"></param> /// <param name="recurse"></param> /// <returns></returns> public ValidationIssue[] Validate(ResourceValidationContext context, IResource resource, bool recurse) { if (resource.ResourceType != ResourceTypes.ApplicationDefinition.ToString()) { return(null); } //TODO: Other items to check for // // - References to non-existent widgets // - MapWidget checks // - Ensure map id checks out // - Ensure context menu id checks out // - Verify containers of template are all referenced within this flexible layout // - Check required parameters of widgets are satisfied List <ValidationIssue> issues = new List <ValidationIssue>(); IApplicationDefinition fusionApp = resource as IApplicationDefinition; if (fusionApp.MapSet == null || fusionApp.MapSet.MapGroupCount == 0) { issues.Add(new ValidationIssue(fusionApp, ValidationStatus.Error, ValidationStatusCode.Error_Fusion_MissingMap, string.Format(Strings.ADF_MapMissingError))); } else { foreach (IMapGroup mapGroup in fusionApp.MapSet.MapGroups) { bool checkCmsProjection = false; List <IMapDefinition> mapDefsInGroup = new List <IMapDefinition>(); foreach (IMap map in mapGroup.Map) { if (IsCommercialOverlay(map)) { checkCmsProjection = true; } if (map.Type.ToLower() == "virtualearth") { //As of July 1, 2017 we need an API key on Bing Maps var bingMapsKey = fusionApp.GetValue("BingMapKey"); if (string.IsNullOrEmpty(bingMapsKey)) { issues.Add(new ValidationIssue(fusionApp, ValidationStatus.Error, ValidationStatusCode.Error_Fusion_BingMapsMissingApiKey, Strings.ADF_BingMapsMissingApiKey)); } //If this is still referencing the "Hybrid" base layer type, that no longer exists in the v8 API if (map.CmsMapOptions.Type == "Hybrid") { issues.Add(new ValidationIssue(fusionApp, ValidationStatus.Error, ValidationStatusCode.Error_Fusion_BingMapsHybridBaseLayerNoLongerAvailable, Strings.ADF_BingMapsHybridLayerNoLongerAvailable)); } } try { if (map.Type.ToLower() == "mapguide") //NOXLATE { var mdfId = map.GetMapDefinition(); if (string.IsNullOrEmpty(mdfId) || !this.Connection.ResourceService.ResourceExists(mdfId)) { issues.Add(new ValidationIssue(fusionApp, ValidationStatus.Error, ValidationStatusCode.Error_Fusion_InvalidMap, string.Format(Strings.ADF_MapInvalidError, mapGroup.id))); } else { IMapDefinition mdef = (IMapDefinition)context.GetResource(mdfId); mapDefsInGroup.Add(mdef); IEnvelope mapEnv = ObjectFactory.CreateEnvelope(mdef.Extents.MinX, mdef.Extents.MinY, mdef.Extents.MaxX, mdef.Extents.MaxY); if (mapGroup.InitialView != null) { if (!mapEnv.Contains(mapGroup.InitialView.CenterX, mapGroup.InitialView.CenterY)) { issues.Add(new ValidationIssue(mdef, ValidationStatus.Warning, ValidationStatusCode.Warning_Fusion_InitialViewOutsideMapExtents, string.Format(Strings.ADF_ViewOutsideMapExtents))); } } if (recurse) { issues.AddRange(ResourceValidatorSet.Validate(context, mdef, recurse)); } } } } catch (Exception ex) { string msg = NestedExceptionMessageProcessor.GetFullMessage(ex); issues.Add(new ValidationIssue(fusionApp, ValidationStatus.Error, ValidationStatusCode.Error_Fusion_MapValidationError, string.Format(Strings.ADF_MapValidationError, mapGroup.id, msg))); } } if (checkCmsProjection) { foreach (var mdf in mapDefsInGroup) { var wkt = mdf.CoordinateSystem; var csCode = this.Connection.CoordinateSystemCatalog.ConvertWktToCoordinateSystemCode(wkt); if (csCode.ToUpper() != "WGS84.PSEUDOMERCATOR") //NOXLATE { issues.Add(new ValidationIssue(resource, ValidationStatus.Warning, ValidationStatusCode.Warning_Fusion_MapCoordSysIncompatibleWithCommericalLayers, string.Format(Strings.ADF_MapWithIncompatibleCommericalCs, mdf.ResourceID))); } } } } } //Check labels of referenced widgets foreach (var wset in fusionApp.WidgetSets) { foreach (var cnt in wset.Containers) { var menu = cnt as IMenu; if (menu != null) { ValidateWidgetReferencesForMenu(fusionApp, menu, issues, context, resource); } } } context.MarkValidated(resource.ResourceID); return(issues.ToArray()); }
private static void SetupMapDefinitionForTest(IMapDefinition mdf) { mdf.AddGroup("Group1"); mdf.AddLayer("Group1", "Parcels", "Library://UnitTests/Layers/Parcels.LayerDefinition"); mdf.AddLayer("Group1", "Rail", "Library://UnitTests/Layers/Rail.LayerDefinition"); mdf.AddGroup("Group2"); }
public unsafe IEnumerator FocusOnMapRegion([NotNull] IMapDefinition mapDefinition, int regionIndex, [CanBeNull] CameraControlParameters parameters = null) { if (m_regionFocusCoroutine != null) { this.StopCoroutine(m_regionFocusCoroutine); m_regionFocusCoroutine = null; } Camera camera = this.camera; Transform cameraContainer = m_cameraContainer; if (null == camera || null == cameraContainer) { yield break; } float panTweenDuration; Ease val; float num; Ease val2; if (null == parameters) { CameraControlParameters defaultControlParameters = m_defaultControlParameters; if (null == defaultControlParameters) { panTweenDuration = m_panTweenDuration; val = 9; num = m_zoomTweenDuration; val2 = 9; } else { panTweenDuration = defaultControlParameters.panTweenDuration; val = defaultControlParameters.panTweenEase; num = defaultControlParameters.zoomTweenMaxDuration; val2 = defaultControlParameters.zoomTweenEase; } } else { panTweenDuration = parameters.panTweenDuration; val = parameters.panTweenEase; num = parameters.zoomTweenMaxDuration; val2 = parameters.zoomTweenEase; } FightMapRegionDefinition region = mapDefinition.GetRegion(regionIndex); Vector3 val3 = Vector3Int.op_Implicit(mapDefinition.origin); Vector2 val4 = Vector2Int.op_Implicit(region.sizeMin); Vector2 val5 = Vector2Int.op_Implicit(region.sizeMax); Vector3 val6 = cameraContainer.get_rotation() * m_cameraPositionOffset; Vector2 val7 = val4 + 0.5f * (val5 - Vector2.get_one() - val4); Vector3 targetCameraPosition = new Vector3(((IntPtr)(void *)val7).x, 0f, ((IntPtr)(void *)val7).y) + val3 + val6; Vector3 val8 = default(Vector3); val8._002Ector(((IntPtr)(void *)val4).x, 0f, ((IntPtr)(void *)val4).y); Vector3 val9 = default(Vector3); val9._002Ector(((IntPtr)(void *)val5).x, 0f, ((IntPtr)(void *)val5).y); Vector3 val10 = default(Vector3); val10._002Ector(((IntPtr)(void *)val8).x, 0f, ((IntPtr)(void *)val9).z); Vector3 val11 = default(Vector3); val11._002Ector(((IntPtr)(void *)val9).x, 0f, ((IntPtr)(void *)val8).z); Vector3 val12 = cameraContainer.get_rotation() * new Vector3(1f, 0f, 1f); Vector3 normalized = val12.get_normalized(); Vector3 normalized2 = val6.get_normalized(); val12 = val9 - val8; float num2 = Mathf.Abs(Vector3.Dot(val12.get_normalized(), normalized)); val12 = val11 - val10; float num3 = Mathf.Abs(Vector3.Dot(val12.get_normalized(), normalized)); float num4 = Mathf.Abs(Vector3.Dot(normalized2, normalized)); float num5 = Vector3.Distance(val8, val9); float num6 = Vector3.Distance(val10, val11); float num7 = 2f * val6.get_magnitude(); Vector2 val13 = 2.828427f * m_regionFocusMargin; float num8 = num2 * num5 + num3 * num6 + num4 * num7 + ((IntPtr)(void *)val13).y; float num9 = (1f - num2) * num5 + (1f - num3) * num6 + (1f - num4) * num7 + ((IntPtr)(void *)val13).x; float num10 = num8 / 4f; float num11 = num9 / 2f / camera.get_aspect(); float num12 = Mathf.Max(num10, num11); float targetZoomLevel2 = Mathf.InverseLerp(6f, m_maxOrthoSize, num12); targetZoomLevel2 = Mathf.Floor(targetZoomLevel2 / m_zoomIncrement) * m_zoomIncrement; m_targetCameraPosition = targetCameraPosition; m_targetZoomLevel = targetZoomLevel2; m_userHasControl = false; if (m_panTween != null && TweenExtensions.IsPlaying(m_panTween)) { TweenSettingsExtensions.SetEase <Tweener>(m_panTween.ChangeEndValue((object)targetCameraPosition, panTweenDuration, true), val); } else { m_panTween = TweenSettingsExtensions.SetEase <TweenerCore <Vector3, Vector3, VectorOptions> >(DOTween.To(new DOGetter <Vector3>((object)this, (IntPtr)(void *) /*OpCode not supported: LdFtn*/), new DOSetter <Vector3>((object)this, (IntPtr)(void *) /*OpCode not supported: LdFtn*/), targetCameraPosition, panTweenDuration), val); } float num13 = Mathf.Lerp(0f, num, Mathf.Abs(targetZoomLevel2 - m_zoomLevel) / m_zoomIncrement); if (m_zoomTween != null && TweenExtensions.IsPlaying(m_zoomTween)) { TweenSettingsExtensions.SetEase <Tweener>(m_zoomTween.ChangeEndValue((object)targetZoomLevel2, num13, true), val2); } else { m_zoomTween = TweenSettingsExtensions.SetEase <TweenerCore <float, float, FloatOptions> >(DOTween.To(new DOGetter <float>((object)this, (IntPtr)(void *) /*OpCode not supported: LdFtn*/), new DOSetter <float>((object)this, (IntPtr)(void *) /*OpCode not supported: LdFtn*/), targetZoomLevel2, num13), val2); } while (TweenExtensions.IsPlaying(m_panTween) || TweenExtensions.IsPlaying(m_zoomTween)) { yield return(null); if (m_targetCameraPosition != targetCameraPosition || m_targetZoomLevel != targetZoomLevel2) { break; } } m_regionFocusCoroutine = null; m_userHasControl = true; }
public void StartFocusOnMapRegion([NotNull] IMapDefinition mapDefinition, int regionIndex, [CanBeNull] CameraControlParameters parameters = null) { m_regionFocusCoroutine = this.StartCoroutine(FocusOnMapRegion(mapDefinition, regionIndex, parameters)); }
public unsafe CameraWorldRect(IMapDefinition mapDefinition, Vector2 margin) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) float num = 0f; float num2 = 0f; float num3 = 0f; float num4 = 0f; int regionCount = mapDefinition.regionCount; Vector2Int val3 = default(Vector2Int); for (int i = 0; i < regionCount; i++) { FightMapRegionDefinition region = mapDefinition.GetRegion(i); Vector2Int sizeMin = region.sizeMin; Vector2Int val = region.sizeMax - Vector2Int.get_one(); Vector2Int val2 = new Vector2Int(sizeMin.get_x(), val.get_y()); val3._002Ector(val.get_x(), sizeMin.get_y()); Vector2 val4 = Translate(Vector2Int.op_Implicit(sizeMin)); Vector2 val5 = Translate(Vector2Int.op_Implicit(val)); Vector2 val6 = Translate(Vector2Int.op_Implicit(val2)); Vector2 val7 = Translate(Vector2Int.op_Implicit(val3)); num = Mathf.Max(new float[5] { num, ((IntPtr)(void *)val4).y, ((IntPtr)(void *)val5).y, ((IntPtr)(void *)val6).y, ((IntPtr)(void *)val7).y }); num3 = Mathf.Min(new float[5] { num3, ((IntPtr)(void *)val4).y, ((IntPtr)(void *)val5).y, ((IntPtr)(void *)val6).y, ((IntPtr)(void *)val7).y }); num2 = Mathf.Min(new float[5] { num2, ((IntPtr)(void *)val4).x, ((IntPtr)(void *)val5).x, ((IntPtr)(void *)val6).x, ((IntPtr)(void *)val7).x }); num4 = Mathf.Max(new float[5] { num4, ((IntPtr)(void *)val4).x, ((IntPtr)(void *)val5).x, ((IntPtr)(void *)val6).x, ((IntPtr)(void *)val7).x }); } Vector3 val8 = Vector2.op_Implicit(Translate(Vector3Int.op_Implicit(mapDefinition.origin))); float num5 = (((IntPtr)(void *)margin).x + 1f) * 0.707106769f; float num6 = (((IntPtr)(void *)margin).y + 1f) * 0.707106769f; left = ((IntPtr)(void *)val8).x + num2 - num5; right = ((IntPtr)(void *)val8).x + num4 + num5; top = ((IntPtr)(void *)val8).z + num + num6; bottom = ((IntPtr)(void *)val8).z + num3 - num6; if (bottom > top) { top = (bottom = ((IntPtr)(void *)val8).z); } if (left > right) { left = (right = ((IntPtr)(void *)val8).x); } }
private void UpdateFeedbacks() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) FightMapFeedbackResources feedbackResources = m_feedbackResources; if (null == feedbackResources) { return; } FightMapMovementContext[] movementContexts = m_movementContexts; int num = movementContexts.Length; for (int i = 0; i < num; i++) { FightMapMovementContext fightMapMovementContext = movementContexts[i]; if (!fightMapMovementContext.hasEnded) { continue; } IMapDefinition mapDefinition = m_mapDefinition; IMapStateProvider stateProvider = fightMapMovementContext.stateProvider; Vector2Int sizeMin = stateProvider.sizeMin; Vector2Int sizeMax = stateProvider.sizeMax; for (int j = sizeMin.get_y(); j < sizeMax.get_y(); j++) { for (int k = sizeMin.get_x(); k < sizeMax.get_x(); k++) { int cellIndex = mapDefinition.GetCellIndex(k, j); CellObject cellObject = m_cellObjectsByIndex[cellIndex]; if (!(null == cellObject)) { cellObject.highlight.ClearSprite(); } } } } FightMapTargetContext targetContext = m_targetContext; if (targetContext != null) { if (targetContext.isActive) { IMapDefinition mapDefinition2 = m_mapDefinition; IMapStateProvider stateProvider2 = targetContext.stateProvider; Vector2Int sizeMin2 = stateProvider2.sizeMin; Vector2Int sizeMax2 = stateProvider2.sizeMax; Color targetableAreaColor = feedbackResources.feedbackColors.targetableAreaColor; for (int l = sizeMin2.get_y(); l < sizeMax2.get_y(); l++) { for (int m = sizeMin2.get_x(); m < sizeMax2.get_x(); m++) { int cellIndex2 = mapDefinition2.GetCellIndex(m, l); CellObject cellObject2 = m_cellObjectsByIndex[cellIndex2]; if (!(null == cellObject2)) { FightMapFeedbackHelper.SetupSpellTargetHighlight(feedbackResources, targetContext, cellObject2.coords, cellObject2.highlight, targetableAreaColor); } } } m_pathFinderFeedbackManager.Clear(); return; } if (targetContext.hasEnded) { IMapDefinition mapDefinition3 = m_mapDefinition; IMapStateProvider stateProvider3 = targetContext.stateProvider; Vector2Int sizeMin3 = stateProvider3.sizeMin; Vector2Int sizeMax3 = stateProvider3.sizeMax; for (int n = sizeMin3.get_y(); n < sizeMax3.get_y(); n++) { for (int num2 = sizeMin3.get_x(); num2 < sizeMax3.get_x(); num2++) { int cellIndex3 = mapDefinition3.GetCellIndex(num2, n); CellObject cellObject3 = m_cellObjectsByIndex[cellIndex3]; if (!(null == cellObject3)) { cellObject3.highlight.ClearSprite(); } } } } } FightMapMovementContext activeMovementContext = m_activeMovementContext; if (activeMovementContext == null) { m_pathFinderFeedbackManager.Clear(); return; } ICharacterEntity trackedCharacter = activeMovementContext.trackedCharacter; if (trackedCharacter != null) { Color highlightColor = GetHighlightColor(feedbackResources.feedbackColors, activeMovementContext.entityProvider, trackedCharacter); IMapDefinition mapDefinition4 = m_mapDefinition; IMapStateProvider stateProvider4 = activeMovementContext.stateProvider; Vector2Int sizeMin4 = stateProvider4.sizeMin; Vector2Int sizeMax4 = stateProvider4.sizeMax; for (int num3 = sizeMin4.get_y(); num3 < sizeMax4.get_y(); num3++) { for (int num4 = sizeMin4.get_x(); num4 < sizeMax4.get_x(); num4++) { int cellIndex4 = mapDefinition4.GetCellIndex(num4, num3); CellObject cellObject4 = m_cellObjectsByIndex[cellIndex4]; if (!(null == cellObject4)) { FightMapFeedbackHelper.SetupMovementAreaHighlight(feedbackResources, activeMovementContext, cellObject4.coords, cellObject4.highlight, highlightColor); } } } } if (m_pathFinder.tracking) { Vector2Int?target = activeMovementContext.targetedEntity?.area.refCoord; m_pathFinderFeedbackManager.Setup(feedbackResources.movementFeedbackResources, m_pathFinder.currentPath, target); } else { m_pathFinderFeedbackManager.Clear(); } }
private static void SetTempLayer(IMapDefinition mdf, string resourceId) { var layers = new List<IMapLayer>(mdf.MapLayer); for (int i = 0; i < layers.Count; i++) { mdf.RemoveLayer(layers[i]); } var layer = mdf.AddLayer(null, "x", resourceId); //NOXLATE layer.Visible = true; layer.Selectable = true; layer.Name = "x"; //NOXLATE layer.LegendLabel = string.Empty; }
public override void Bind(IEditorService service) { cmbBackgroundColor.ResetColors(); _service = service; _service.RegisterCustomNotifier(this); _map = (IMapDefinition)service.GetEditedResource(); var mdf3 = _map as IMapDefinition3; if (mdf3 == null) { pnlTileSource.Visible = false; } else { switch (mdf3.TileSourceType) { case TileSourceType.External: rdExternal.Checked = true; break; case TileSourceType.Inline: rdInline.Checked = true; break; default: //Default to none rdNone.Checked = true; break; } } var bmeta = new Binding("Text", _map, "Metadata"); bmeta.Parse += (sender, e) => { e.Value = META_START + e.Value + META_END; }; bmeta.Format += (sender, e) => { if (e.Value != null) { var str = e.Value.ToString(); if (str.StartsWith(META_START) && str.EndsWith(META_END)) { e.Value = str.Substring(META_START.Length, str.Length - (META_START.Length + META_END.Length)); } } }; TextBoxBinder.BindText(txtDescription, bmeta); TextBoxBinder.BindText(txtCoordinateSystem, _map, "CoordinateSystem"); //ColorComboBox requires custom databinding cmbBackgroundColor.CurrentColor = _map.BackgroundColor; cmbBackgroundColor.SelectedIndexChanged += (sender, e) => { _map.BackgroundColor = cmbBackgroundColor.CurrentColor; }; PropertyChangedEventHandler mapChanged = (sender, e) => { if (e.PropertyName == "BackgroundColor") { cmbBackgroundColor.CurrentColor = _map.BackgroundColor; } else if (e.PropertyName == "Extents") { UpdateExtentsFromMap(); } }; _map.PropertyChanged += WeakEventHandler.Wrap <PropertyChangedEventHandler>(mapChanged, (eh) => _map.PropertyChanged -= eh); txtLowerX.Text = _map.Extents.MinX.ToString(CultureInfo.InvariantCulture); txtLowerY.Text = _map.Extents.MinY.ToString(CultureInfo.InvariantCulture); txtUpperX.Text = _map.Extents.MaxX.ToString(CultureInfo.InvariantCulture); txtUpperY.Text = _map.Extents.MaxY.ToString(CultureInfo.InvariantCulture); txtLowerX.TextChanged += (s, e) => { if (_updatingExtents) { return; } if (txtLowerX.Text.EndsWith(".")) //Maybe typing in decimals atm { return; } double d; if (double.TryParse(txtLowerX.Text, out d)) { _map.Extents.MinX = d; } }; txtLowerY.TextChanged += (s, e) => { if (_updatingExtents) { return; } if (txtLowerY.Text.EndsWith(".")) //Maybe typing in decimals atm { return; } double d; if (double.TryParse(txtLowerY.Text, out d)) { _map.Extents.MinY = d; } }; txtUpperX.TextChanged += (s, e) => { if (_updatingExtents) { return; } if (txtUpperX.Text.EndsWith(".")) //Maybe typing in decimals atm { return; } double d; if (double.TryParse(txtUpperX.Text, out d)) { _map.Extents.MaxX = d; } }; txtUpperY.TextChanged += (s, e) => { if (_updatingExtents) { return; } if (txtUpperY.Text.EndsWith(".")) //Maybe typing in decimals atm { return; } double d; if (double.TryParse(txtUpperY.Text, out d)) { _map.Extents.MaxY = d; } }; PropertyChangedEventHandler extChange = (sender, e) => { UpdateExtentsFromMap(); OnResourceChanged(); }; var ext = _map.Extents; ext.PropertyChanged += WeakEventHandler.Wrap <PropertyChangedEventHandler>(extChange, (eh) => ext.PropertyChanged -= eh); }
public void RegisterMap(IMapDefinition mapDefinition) { maps.Add(mapDefinition); mapDefinition.SetResolver(this); }
private void ProfileMapDefinition(IMapDefinition mapDef) { //TODO: This was a line-by-line port from 2.x to match the 3.x APIs //we should find time to clean this up and ensure the profiling numbers are //truly reflective of actual performance metrics var mdef = (IMapDefinition)mapDef.Clone(); if (backgroundWorker.CancellationPending) return; string resourceId = mdef == m_item ? m_resourceId : mdef.ResourceID; backgroundWorker.ReportProgress(0, (string.Format(Strings.Prof_LogMessageMapDefinition, resourceId))); using (new Timer(Strings.Prof_LogMessageRuntimeMap, backgroundWorker)) { foreach (var ml in mdef.MapLayer) { try { if (backgroundWorker.CancellationPending) return; ILayerDefinition ldef = (ILayerDefinition)mdef.CurrentConnection.ResourceService.GetResource(ml.ResourceId); ProfileLayerDefinition(ldef); } catch (Exception ex) { //string msg = NestedExceptionMessageProcessor.GetFullMessage(ex); backgroundWorker.ReportProgress(0, (string.Format(Strings.Prof_LayerDefinitionProfilingError, ml.ResourceId, ex.ToString(), Environment.NewLine))); } } if (mdef.BaseMap != null) { foreach (var g in mdef.BaseMap.BaseMapLayerGroup) { if (g.BaseMapLayer != null) { foreach (var ml in g.BaseMapLayer) { try { if (backgroundWorker.CancellationPending) return; ILayerDefinition ldef = (ILayerDefinition)mdef.CurrentConnection.ResourceService.GetResource(ml.ResourceId); ProfileLayerDefinition(ldef); } catch (Exception ex) { //string msg = NestedExceptionMessageProcessor.GetFullMessage(ex); backgroundWorker.ReportProgress(0, (string.Format(Strings.Prof_LayerDefinitionProfilingError, ml.ResourceId, ex.ToString(), Environment.NewLine))); } } } } } } if (backgroundWorker.CancellationPending) return; var mpsvc = (IMappingService)m_connection.GetService((int)ServiceType.Mapping); try { if (backgroundWorker.CancellationPending) return; //m_connection.ResetFeatureSourceSchemaCache(); using (new Timer(Strings.Prof_LogMessageRuntimeMapTotal, backgroundWorker)) mpsvc.CreateMap(mdef); } catch (Exception ex) { //string msg = NestedExceptionMessageProcessor.GetFullMessage(ex); backgroundWorker.ReportProgress(0, (string.Format(Strings.Prof_RuntimeMapProfilingError, resourceId, ex.ToString(), Environment.NewLine))); } try { if (backgroundWorker.CancellationPending) return; //We cannot flub this anymore. AIMS 2012 demands the Map Definition id specified checks out mdef.ResourceID = "Session:" + m_connection.SessionID + "//ProfilingTest.MapDefinition"; //NOXLATE m_connection.ResourceService.SaveResource(mdef); var rtmap = mpsvc.CreateMap(mdef); if (m_connection.ResourceService.ResourceExists(rtmap.ResourceID)) m_connection.ResourceService.DeleteResource(rtmap.ResourceID); rtmap.Save(); using (new Timer(Strings.Prof_LogMessageRenderingMap, backgroundWorker)) { //TODO: Use extents rather than scale //using (System.IO.Stream s = m_connection.RenderRuntimeMap(tmp2, mdef.Extents, 1024, 800, 96)) using (System.IO.Stream s = mpsvc.RenderRuntimeMap(rtmap, ((mdef.Extents.MaxX - mdef.Extents.MinX) / 2) + mdef.Extents.MinX, ((mdef.Extents.MaxY - mdef.Extents.MinY) / 2) + mdef.Extents.MinY, 50000, 1024, 800, 96)) { //Just dispose it after being read backgroundWorker.ReportProgress(0, (string.Format(Strings.Prof_MapRenderingImageSize, s.Length))); } } } catch (Exception ex) { //string msg = NestedExceptionMessageProcessor.GetFullMessage(ex); backgroundWorker.ReportProgress(0, (string.Format(Strings.Prof_MapRenderingError, resourceId, ex.ToString(), Environment.NewLine))); } }
/// <summary> /// Constructs a new map to be processed /// </summary> /// <param name="parent">The parent entry</param> /// <param name="map">The resource id for the mapdefinition</param> public MapTilingConfiguration(TilingRunCollection parent, string map) { m_parent = parent; m_mapdefinition = (IMapDefinition)parent.Connection.ResourceService.GetResource(map); var baseMap = m_mapdefinition.BaseMap; if (baseMap != null && baseMap.ScaleCount > 0) { m_groups = new string[baseMap.GroupCount]; for (int i = 0; i < baseMap.GroupCount; i++) m_groups[i] = baseMap.GetGroupAt(i).Name; m_maxscale = baseMap.GetMaxScale(); CalculateDimensions(); } }
static IEnumerable<string> GetLayerIds(IMapDefinition mdf) { foreach (var layer in mdf.MapLayer) { yield return layer.ResourceId; } if (mdf.BaseMap != null) { foreach (var group in mdf.BaseMap.BaseMapLayerGroup) { foreach (var layer in group.BaseMapLayer) { yield return layer.ResourceId; } } } }
protected bool Matches(RuntimeMap map, IMapDefinition mdf) { if (map.MapDefinition != mdf.ResourceID) return false; if (map.Groups.Count != mdf.GetGroupCount()) return false; if (map.Layers.Count != mdf.GetLayerCount()) return false; foreach (var layer in map.Layers) { var ldfr = mdf.GetLayerByName(layer.Name); if (ldfr == null) return false; if (layer.LayerDefinitionID != ldfr.ResourceId) return false; if (layer.LegendLabel != ldfr.LegendLabel) return false; if (layer.Visible != ldfr.Visible) return false; if (layer.Selectable != ldfr.Selectable) return false; if (layer.ShowInLegend != ldfr.ShowInLegend) return false; if (layer.ExpandInLegend != ldfr.ExpandInLegend) return false; } foreach (var group in map.Groups) { var grp = mdf.GetGroupByName(group.Name); if (grp == null) return false; if (group.ExpandInLegend != grp.ExpandInLegend) return false; if (group.Group != grp.Group) return false; if (group.LegendLabel != grp.LegendLabel) return false; if (group.Name != grp.Name) return false; if (group.ShowInLegend != grp.ShowInLegend) return false; if (group.Visible != grp.Visible) return false; } return true; }
static int GetGroupCount(IMapDefinition map, string name) { int count = 0; foreach (var grp in map.MapLayerGroup) { if (grp.Name == name) count++; } if (map.BaseMap != null) { foreach (var grp in map.BaseMap.BaseMapLayerGroup) { if (grp.Name == name) count++; } } System.Diagnostics.Debug.WriteLine("{0} groups with the name: {1}", count, name); return count; }
/// <summary> /// Registers the mapping. /// </summary> /// <param name="inType">Source type.</param> /// <param name="outType">Destination type.</param> /// <param name="mapDefinition">Property mappings.</param> public virtual void Register(Type inType, Type outType, IMapDefinition mapDefinition) { _maps[new Tuple <Type, Type>(inType, outType)] = mapDefinition; }
private void LoadMapDefinitionForEditing(IMapDefinition mdf) { CleanupExistingMap(); if (mdf.BaseMap != null) { if (mdf.BaseMap.GroupCount > 0) { MessageBox.Show(Strings.TiledMapNote, Strings.TitleTiledMap); } } _mapEditor = new LiveMapDefinitionEditorCtrl(); _mapEditor.Bind(new ResourceEditorService(mdf.ResourceID, _conn)); _bComputeLayerCsAndExtentOnFirstLayerAdded = _mapEditor.EditorService.IsNew; _mapEditor.Map.LayerAdded += OnMapLayerAdded; _mapEditor.Dock = DockStyle.Fill; rootPanel.Controls.Add(_mapEditor); }
//--------------------------------------------------------------------- protected override ISuitabilityParameters Parse() { InputVar <string> landisData = new InputVar <string>("LandisData"); ReadVar(landisData); if (landisData.Value.Actual != "HabitatSuitabilityFile") { throw new InputValueException(landisData.Value.String, "The value is not \"{0}\"", "HabitatSuitabilityFile"); } SuitabilityParameters suitabilityParameters = new SuitabilityParameters(PlugIn.ModelCore.Species.Count); InputVar <string> wildlifeName = new InputVar <string>("WildlifeName"); ReadVar(wildlifeName); suitabilityParameters.WildlifeName = wildlifeName.Value; InputVar <string> suitabilityType = new InputVar <string>("SuitabilityType"); ReadVar(suitabilityType); if ((suitabilityType.Value.Actual != "AgeClass_ForestType") & (suitabilityType.Value.Actual != "AgeClass_TimeSinceDisturbance") & (suitabilityType.Value.Actual != "ForestType_TimeSinceDisturbance")) { throw new InputValueException(suitabilityType.Value.String, "The value is not \"{0}\"", "AgeClass_ForestType or AgeClass_TimeSinceDisturbance or ForestType_TimeSinceDisturbance"); } suitabilityParameters.SuitabilityType = suitabilityType.Value; List <string> keywordList = new List <string>(); if (suitabilityType.Value == "AgeClass_ForestType") { keywordList.Add("ReclassCoefficients"); keywordList.Add("ForestTypeTable"); keywordList.Add("SuitabilityTable"); } else if (suitabilityType.Value == "AgeClass_TimeSinceDisturbance") { keywordList.Add("DisturbanceTable"); keywordList.Add("SuitabilityTable"); } else if (suitabilityType.Value == "ForestType_TimeSinceDisturbance") { keywordList.Add("ReclassCoefficients"); keywordList.Add("ForestTypeTable"); keywordList.Add("DisturbanceTable"); keywordList.Add("SuitabilityTable"); } InputVar <string> speciesName = new InputVar <string>("Species"); int keywordIndex = 0; foreach (string keyword in keywordList) { if (keyword == "ReclassCoefficients") { // Table of reclass coefficients ReadName("ReclassCoefficients"); InputVar <double> reclassCoeff = new InputVar <double>("Reclass Coefficient"); Dictionary <string, int> lineNumbers = new Dictionary <string, int>(); bool continueLoop = true; while (continueLoop) { StringReader currentLine = new StringReader(CurrentLine); ReadValue(speciesName, currentLine); ISpecies species = GetSpecies(speciesName.Value); CheckForRepeatedName(speciesName.Value, "species", lineNumbers); ReadValue(reclassCoeff, currentLine); suitabilityParameters.ReclassCoefficients[species.Index] = reclassCoeff.Value; CheckNoDataAfter(string.Format("the {0} column", reclassCoeff.Name), currentLine); GetNextLine(); if (keywordIndex + 1 == keywordList.Count) { continueLoop = !AtEndOfInput; } else { continueLoop = (CurrentName != keywordList[keywordIndex + 1]); } } } if (keyword == "ForestTypeTable") { // Table of forest types ReadName("ForestTypeTable"); InputVar <string> forestType = new InputVar <string>("Forest Type"); Dictionary <string, int> forestTypeLineNumbers = new Dictionary <string, int>(); IMapDefinition mapDefn = null; mapDefn = new MapDefinition(); mapDefn.Name = "ForestTypes"; suitabilityParameters.ForestTypes.Add(mapDefn); bool continueLoop = true; while (continueLoop) { StringReader currentLine = new StringReader(CurrentLine); ReadValue(forestType, currentLine); CheckForRepeatedName(forestType.Value, "forest type", forestTypeLineNumbers); IForestType currentForestType = new ForestType(PlugIn.ModelCore.Species.Count); currentForestType.Name = forestType.Value; mapDefn.ForestTypes.Add(currentForestType); // Read species for forest types List <string> speciesNames = new List <string>(); TextReader.SkipWhitespace(currentLine); while (currentLine.Peek() != -1) { ReadValue(speciesName, currentLine); string name = speciesName.Value.Actual; bool negativeMultiplier = name.StartsWith("-"); if (negativeMultiplier) { name = name.Substring(1); if (name.Length == 0) { throw new InputValueException(speciesName.Value.String, "No species name after \"-\""); } } ISpecies species = GetSpecies(new InputValue <string>(name, speciesName.Value.String)); if (speciesNames.Contains(species.Name)) { throw NewParseException("The species {0} appears more than once.", species.Name); } speciesNames.Add(species.Name); currentForestType[species.Index] = negativeMultiplier ? -1 : 1; TextReader.SkipWhitespace(currentLine); } if (speciesNames.Count == 0) { throw NewParseException("At least one species is required."); } GetNextLine(); if (keywordIndex + 1 == keywordList.Count) { continueLoop = !AtEndOfInput; } else { continueLoop = (CurrentName != keywordList[keywordIndex + 1]); } } } if (keyword == "DisturbanceTable") { // Table of Disturbance classes InputVar <string> disturbanceType = new InputVar <string>("DisturbanceTable"); ReadVar(disturbanceType); Dictionary <int, double> fireSeverityTable = new Dictionary <int, double>(); Dictionary <string, double> prescriptionTable = new Dictionary <string, double>(); if (disturbanceType.Value == "Fire") { InputVar <int> severityClass = new InputVar <int>("Fire Severity Class"); InputVar <double> fireSuitability = new InputVar <double>("Fire Class Suitability"); suitabilityParameters.DisturbanceType = "Fire"; bool continueLoop = true; while (continueLoop) { StringReader currentLine = new StringReader(CurrentLine); TextReader.SkipWhitespace(currentLine); ReadValue(severityClass, currentLine); ReadValue(fireSuitability, currentLine); fireSeverityTable.Add(severityClass.Value, fireSuitability.Value); GetNextLine(); if (keywordIndex + 1 == keywordList.Count) { continueLoop = !AtEndOfInput; } else { continueLoop = (CurrentName != keywordList[keywordIndex + 1]); } } } else if (disturbanceType.Value == "Harvest") { InputVar <string> prescriptionName = new InputVar <string>("Prescription Name"); InputVar <double> prescriptionSuitability = new InputVar <double>("Prescription Suitability"); suitabilityParameters.DisturbanceType = "Harvest"; bool continueLoop = true; while (continueLoop) { StringReader currentLine = new StringReader(CurrentLine); TextReader.SkipWhitespace(currentLine); ReadValue(prescriptionName, currentLine); ReadValue(prescriptionSuitability, currentLine); prescriptionTable.Add(prescriptionName.Value, prescriptionSuitability.Value); GetNextLine(); if (keywordIndex + 1 == keywordList.Count) { continueLoop = !AtEndOfInput; } else { continueLoop = (CurrentName != keywordList[keywordIndex + 1]); } } } else { throw new InputValueException(disturbanceType.Value.String, "The value is not \"{0}\"", "Fire or Harvest"); } suitabilityParameters.FireSeverities = fireSeverityTable; suitabilityParameters.HarvestPrescriptions = prescriptionTable; } if (keyword == "SuitabilityTable") { // Table of suitabilities ReadName("SuitabilityTable"); Dictionary <string, Dictionary <int, double> > suitabilityTable = new Dictionary <string, Dictionary <int, double> >(); InputVar <int> ageCutoff = new InputVar <int>("Age Cutoff"); InputVar <string> suitabilityClass = new InputVar <string>("Suitability Class"); InputVar <double> suitabilityValue = new InputVar <double>("Suitability Value"); List <int> ageList = new List <int>(); StringReader currentLine = new StringReader(CurrentLine); while (currentLine.Peek() != -1) { ReadValue(ageCutoff, currentLine); ageList.Add(ageCutoff.Value); } GetNextLine(); bool continueLoop = true; while (continueLoop) { currentLine = new StringReader(CurrentLine); //TextReader.SkipWhitespace(currentLine); ReadValue(suitabilityClass, currentLine); Dictionary <int, double> suitabilityRow = new Dictionary <int, double>(); foreach (int age in ageList) { ReadValue(suitabilityValue, currentLine); suitabilityRow.Add(age, suitabilityValue.Value); } suitabilityTable.Add(suitabilityClass.Value, suitabilityRow); GetNextLine(); if (keywordIndex + 1 == keywordList.Count) { continueLoop = !AtEndOfInput; } else { continueLoop = (CurrentName != keywordList[keywordIndex + 1]); } } suitabilityParameters.Suitabilities = suitabilityTable; } keywordIndex++; } return(suitabilityParameters); }
//--------------------------------------------------------------------- protected override IInputParameters Parse() { ReadLandisDataVar(); InputParameters parameters = new InputParameters(SpeciesDataset.Count); InputVar <int> timestep = new InputVar <int>("Timestep"); ReadVar(timestep); parameters.Timestep = timestep.Value; const string LocalVariables = "LocalVariables"; const string DerivedLocalVariables = "DerivedLocalVariables"; const string NeighborhoodVariables = "NeighborhoodVariables"; const string ClimateVariables = "ClimateVariables"; const string SpeciesModels = "SpeciesModels"; const string LocalVarMapFileNames = "LocalVarMapFileNames"; const string NeighborVarMapFileNames = "NeighborVarMapFileNames"; const string ClimateVarMapFileNames = "ClimateVarMapFileNames"; const string SpeciesMapFileName = "SpeciesMapFileNames"; const string LogFile = "LogFile"; if (ReadOptionalName(LocalVariables)) { InputVar <string> speciesName = new InputVar <string>("Species"); Dictionary <string, int> lineNumbers = new Dictionary <string, int>(); InputVar <string> mapName = new InputVar <string>("Map Name"); InputVar <string> forestType = new InputVar <string>("Forest Type"); InputVar <string> ageKeyword = new InputVar <string>("Age Keyword"); InputVar <int> minAge = new InputVar <int>("Min Age"); InputVar <int> maxAge = new InputVar <int>("Max Age"); lineNumbers.Clear(); Dictionary <string, int> forestTypeLineNumbers = new Dictionary <string, int>(); const string nameDelimiter = "->"; // delimiter that separates map name and forest type IMapDefinition mapDefn = null; while (!AtEndOfInput && (CurrentName != DerivedLocalVariables) && (CurrentName != NeighborhoodVariables) && (CurrentName != ClimateVariables) && (CurrentName != SpeciesModels)) { StringReader currentLine = new StringReader(CurrentLine); // If the current line has the delimiter, then read the map // name. if (CurrentLine.Contains(nameDelimiter)) { ReadValue(mapName, currentLine); CheckForRepeatedName(mapName.Value, "map name", lineNumbers); mapDefn = new MapDefinition(); mapDefn.Name = mapName.Value; parameters.ReclassMaps.Add(mapDefn); TextReader.SkipWhitespace(currentLine); string word = TextReader.ReadWord(currentLine); if (word != nameDelimiter) { throw NewParseException("Expected \"{0}\" after the map name {1}.", nameDelimiter, mapName.Value.String); } forestTypeLineNumbers.Clear(); } else { // If there is no name delimiter and we don't have the // name for the first map yet, then it's an error. if (mapDefn == null) { throw NewParseException("Expected a line with map name followed by \"{0}\"", nameDelimiter); } } ReadValue(forestType, currentLine); CheckForRepeatedName(forestType.Value, "forest type", forestTypeLineNumbers); IForestType currentForestType = new ForestType(SpeciesDataset.Count); currentForestType.Name = forestType.Value; mapDefn.ForestTypes.Add(currentForestType); // Read the age ranges for the species: ReadValue(ageKeyword, currentLine); if (ageKeyword.Value == "All") { currentForestType.MinAge = 0; int maxAgeAllSpecies = 0; foreach (ISpecies species in PlugIn.ModelCore.Species) { if (species.Longevity > maxAgeAllSpecies) { maxAgeAllSpecies = species.Longevity; } } currentForestType.MaxAge = maxAgeAllSpecies; } else { //ReadValue(minAge, currentLine); currentForestType.MinAge = Convert.ToInt32(ageKeyword.Value); TextReader.SkipWhitespace(currentLine); string currentWord = TextReader.ReadWord(currentLine); if (currentWord != "to") { StringBuilder message = new StringBuilder(); message.AppendFormat("Expected \"to\" after the minimum age ({0})", minAge.Value.String); if (currentWord.Length > 0) { message.AppendFormat(", but found \"{0}\" instead", currentWord); } throw NewParseException(message.ToString()); } ReadValue(maxAge, currentLine); currentForestType.MaxAge = maxAge.Value; } // Read species for forest types List <string> speciesNames = new List <string>(); TextReader.SkipWhitespace(currentLine); while (currentLine.Peek() != -1) { ReadValue(speciesName, currentLine); string name = speciesName.Value.Actual; bool negativeMultiplier = name.StartsWith("-"); if (negativeMultiplier) { name = name.Substring(1); if (name.Length == 0) { throw new InputValueException(speciesName.Value.String, "No species name after \"-\""); } } if (name == "All") { foreach (ISpecies species in PlugIn.ModelCore.Species) { speciesNames.Add(species.Name); currentForestType[species.Index] = 1; } } else if (name == "None") { foreach (ISpecies species in PlugIn.ModelCore.Species) { speciesNames.Add(species.Name); currentForestType[species.Index] = 0; } } else { ISpecies species = GetSpecies(new InputValue <string>(name, speciesName.Value.String)); if (speciesNames.Contains(species.Name)) { throw NewParseException("The species {0} appears more than once.", species.Name); } speciesNames.Add(species.Name); currentForestType[species.Index] = negativeMultiplier ? -1 : 1; } TextReader.SkipWhitespace(currentLine); } if (speciesNames.Count == 0) { throw NewParseException("At least one species is required."); } GetNextLine(); } } if (ReadOptionalName(DerivedLocalVariables)) { Dictionary <string, int> lineNumbers = new Dictionary <string, int>(); lineNumbers.Clear(); InputVar <string> derVarName = new InputVar <string>("Derived Variable Name"); InputVar <string> derVarFormula = new InputVar <string>("Derived Variable Formula"); const string nameDelimiter = "->"; // delimiter that separates map name and forest type List <string> formulaSymbol = new List <string>(new string[] { "+", "-", "*" }); IVariableDefinition varDefn = null; while (!AtEndOfInput && (CurrentName != NeighborhoodVariables) && (CurrentName != ClimateVariables) && (CurrentName != SpeciesModels)) { StringReader currentLine = new StringReader(CurrentLine); ReadValue(derVarName, currentLine); CheckForRepeatedName(derVarName.Value, "var name", lineNumbers); varDefn = new VariableDefinition(); varDefn.Name = derVarName.Value; TextReader.SkipWhitespace(currentLine); string word = TextReader.ReadWord(currentLine); if (word != nameDelimiter) { throw NewParseException("Expected \"{0}\" after the map name {1}.", nameDelimiter, derVarName.Value.String); } TextReader.SkipWhitespace(currentLine); string variable = TextReader.ReadWord(currentLine); varDefn.Variables.Add(variable); while (currentLine.Peek() != null) { TextReader.SkipWhitespace(currentLine); string op = TextReader.ReadWord(currentLine); if (op == "") { break; } varDefn.Operators.Add(op); TextReader.SkipWhitespace(currentLine); variable = TextReader.ReadWord(currentLine); varDefn.Variables.Add(variable); } parameters.DerivedVars.Add(varDefn); GetNextLine(); } } if (ReadOptionalName(NeighborhoodVariables)) { // Read Neighborhood Variables Dictionary <string, int> lineNumbers = new Dictionary <string, int>(); lineNumbers.Clear(); InputVar <string> neighborVarName = new InputVar <string>("Neighbor Variable Name"); InputVar <string> localVarName = new InputVar <string>("Local Variable Name"); InputVar <int> neighborRadius = new InputVar <int>("Neighbor Radius"); InputVar <string> transform = new InputVar <string>("Transform"); INeighborVariableDefinition neighborVarDefn = null; while (!AtEndOfInput && (CurrentName != ClimateVariables) && (CurrentName != SpeciesModels)) { StringReader currentLine = new StringReader(CurrentLine); ReadValue(neighborVarName, currentLine); CheckForRepeatedName(neighborVarName.Value, "var name", lineNumbers); neighborVarDefn = new NeighborVariableDefinition(); neighborVarDefn.Name = neighborVarName.Value; ReadValue(localVarName, currentLine); neighborVarDefn.LocalVariable = localVarName.Value; ReadValue(neighborRadius, currentLine); neighborVarDefn.NeighborRadius = neighborRadius.Value; ReadValue(transform, currentLine); neighborVarDefn.Transform = transform.Value; parameters.NeighborVars.Add(neighborVarDefn); GetNextLine(); } } if (ReadOptionalName(ClimateVariables)) { // Read Climate Variables Dictionary <string, int> lineNumbers = new Dictionary <string, int>(); lineNumbers.Clear(); InputVar <string> climateVarName = new InputVar <string>("Climate Variable Name"); InputVar <string> climateLibraryVarName = new InputVar <string>("Climate Library Variable Name"); InputVar <string> sourceName = new InputVar <string>("Source Name"); InputVar <string> varYear = new InputVar <string>("Variable Year"); InputVar <int> minMonth = new InputVar <int>("Min Month"); InputVar <int> maxMonth = new InputVar <int>("Max Month"); InputVar <string> transform = new InputVar <string>("Tranformation"); IClimateVariableDefinition climateVarDefn = null; while (!AtEndOfInput && (CurrentName != SpeciesModels)) { StringReader currentLine = new StringReader(CurrentLine); ReadValue(climateVarName, currentLine); CheckForRepeatedName(climateVarName.Value, "var name", lineNumbers); climateVarDefn = new ClimateVariableDefinition(); climateVarDefn.Name = climateVarName.Value; ReadValue(varYear, currentLine); climateVarDefn.Year = varYear.Value; ReadValue(minMonth, currentLine); climateVarDefn.MinMonth = minMonth.Value; TextReader.SkipWhitespace(currentLine); string currentWord = TextReader.ReadWord(currentLine); if (currentWord != "to") { StringBuilder message = new StringBuilder(); message.AppendFormat("Expected \"to\" after the minimum month ({0})", minMonth.Value.String); if (currentWord.Length > 0) { message.AppendFormat(", but found \"{0}\" instead", currentWord); } throw NewParseException(message.ToString()); } ReadValue(maxMonth, currentLine); climateVarDefn.MaxMonth = maxMonth.Value; ReadValue(sourceName, currentLine); climateVarDefn.SourceName = sourceName.Value; ReadValue(climateLibraryVarName, currentLine); climateVarDefn.ClimateLibVariable = climateLibraryVarName.Value; ReadValue(transform, currentLine); climateVarDefn.Transform = transform.Value; parameters.ClimateVars.Add(climateVarDefn); GetNextLine(); } } // Read species models ReadName(SpeciesModels); InputVar <string> birdName = new InputVar <string>("Bird Name"); InputVar <string> parameter = new InputVar <string>("Parameter"); InputVar <string> paramType = new InputVar <string>("Parameter Type"); InputVar <double> paramValue = new InputVar <double>("Parameter Value"); Dictionary <string, int> speciesLineNumbers = new Dictionary <string, int>(); speciesLineNumbers.Clear(); const string speciesNameDelimiter = "->"; // delimiter that separates map name and forest type IModelDefinition modelDefn = null; while (!AtEndOfInput && (CurrentName != LocalVarMapFileNames) && (CurrentName != SpeciesMapFileName)) { StringReader currentLine = new StringReader(CurrentLine); // If the current line has the delimiter, then read the map // name. if (CurrentLine.Contains(speciesNameDelimiter)) { ReadValue(birdName, currentLine); CheckForRepeatedName(birdName.Value, "bird name", speciesLineNumbers); modelDefn = new ModelDefinition(); modelDefn.Name = birdName.Value; parameters.Models.Add(modelDefn); TextReader.SkipWhitespace(currentLine); string word = TextReader.ReadWord(currentLine); if (word != speciesNameDelimiter) { throw NewParseException("Expected \"{0}\" after the map name {1}.", speciesNameDelimiter, birdName.Value.String); } speciesLineNumbers.Clear(); } else { // If there is no name delimiter and we don't have the // name for the first map yet, then it's an error. if (modelDefn == null) { throw NewParseException("Expected a line with map name followed by \"{0}\"", speciesNameDelimiter); } } // Read the parameter name: ReadValue(parameter, currentLine); modelDefn.Parameters.Add(parameter.Value); // Read the parameter types: ReadValue(paramType, currentLine); modelDefn.ParamTypes.Add(paramType.Value); // Read the parameter value: ReadValue(paramValue, currentLine); modelDefn.Values.Add(paramValue.Value); GetNextLine(); } // Template for filenames of maps InputVar <string> localVarMapFileNames = new InputVar <string>(LocalVarMapFileNames); bool readLocalMaps = false; if (ReadOptionalVar(localVarMapFileNames)) { parameters.LocalVarMapFileNames = localVarMapFileNames.Value; readLocalMaps = true; } InputVar <string> neighborMapFileNames = new InputVar <string>(NeighborVarMapFileNames); bool readNeighborMaps = false; if (ReadOptionalVar(neighborMapFileNames)) { parameters.NeighborMapFileNames = neighborMapFileNames.Value; readNeighborMaps = true; } InputVar <string> climateMapFileNames = new InputVar <string>(ClimateVarMapFileNames); bool readClimateMaps = false; if (ReadOptionalVar(climateMapFileNames)) { parameters.ClimateMapFileNames = climateMapFileNames.Value; readClimateMaps = true; } InputVar <string> speciesMapFileNames = new InputVar <string>(SpeciesMapFileName); bool readSpeciesMaps = false; if (ReadOptionalVar(speciesMapFileNames)) { parameters.SpeciesMapFileNames = speciesMapFileNames.Value; readSpeciesMaps = true; } InputVar <string> logFile = new InputVar <string>(LogFile); bool readLogFile = false; if (ReadOptionalVar(logFile)) { parameters.LogFileName = logFile.Value; readLogFile = true; } if (readLogFile) { CheckNoDataAfter(string.Format("the {0} parameter", LogFile)); } else if (readSpeciesMaps) { CheckNoDataAfter(string.Format("the {0} parameter", SpeciesMapFileName)); } else if (readClimateMaps) { CheckNoDataAfter(string.Format("the {0} parameter", ClimateVarMapFileNames)); } else if (readNeighborMaps) { CheckNoDataAfter(string.Format("the {0} parameter", NeighborVarMapFileNames)); } else if (readLocalMaps) { CheckNoDataAfter(string.Format("the {0} parameter", LocalVarMapFileNames)); } else { CheckNoDataAfter(string.Format("the {0} parameter", SpeciesModels)); } return(parameters); //.GetComplete(); }
public DrawOrderLayerModel(IMapDefinition map) { _map = map; }
/// <summary> /// Binds the specified editor service to this editor /// </summary> /// <param name="service"></param> public override void Bind(IEditorService service) { this.EditorService = service; service.RegisterCustomNotifier(this); _shadowCopy = (IMapDefinition)service.GetEditedResource(); _mapSvc = (IMappingService)_shadowCopy.CurrentConnection.GetService((int)ServiceType.Mapping); _rtMap = _mapSvc.CreateMap(_shadowCopy); repoView.Init(service.ResourceService, new ResourceTypes[] { ResourceTypes.LayerDefinition, ResourceTypes.FeatureSource }, new ResourceTypes[] { ResourceTypes.LayerDefinition, ResourceTypes.FeatureSource }); ReloadViewer(); }
internal object Map(object inObj, MapContext mapContext, IMapDefinition mapDefinition) { var mapper = mapContext.PreserveReferences ? mapDefinition.MapperWithCache : mapDefinition.Mapper; return(mapper.DynamicInvoke(inObj, mapContext)); }
private IMapDefinition <TIn, TOut> RegisterMapImpl <TIn, TOut>(IMapDefinition <TIn, TOut> mapDefinition) { _mapDefinitions[Helper.GenerateHashCode(typeof(TIn), typeof(TOut))] = mapDefinition; return(mapDefinition); }
/// <summary> /// Previews the given resource /// </summary> /// <param name="res"></param> /// <param name="edSvc"></param> /// <param name="locale"></param> public void Preview(IResource res, IEditorService edSvc, string locale) { IServerConnection conn = edSvc.CurrentConnection; if (this.UseLocal && IsLocalPreviewableType(res) && SupportsMappingService(conn)) { BusyWaitDelegate worker = () => { IMappingService mapSvc = (IMappingService)conn.GetService((int)ServiceType.Mapping); IMapDefinition previewMdf = null; switch (res.ResourceType) { case "LayerDefinition": { ILayerDefinition ldf = (ILayerDefinition)res; string layerName = string.Empty; if (edSvc.IsNew) { layerName = ResourceIdentifier.GetName(ldf.SubLayer.ResourceId); } else { layerName = ResourceIdentifier.GetName(edSvc.ResourceID); } previewMdf = ResourcePreviewEngine.CreateLayerPreviewMapDefinition(ldf, edSvc.SessionID, layerName, conn); } break; case "WatermarkDefinition": { previewMdf = Utility.CreateWatermarkPreviewMapDefinition((IWatermarkDefinition)res); } break; case "MapDefinition": { previewMdf = (IMapDefinition)res; } break; } if (string.IsNullOrEmpty(previewMdf.ResourceID)) { var sessionId = edSvc.SessionID; var mdfId = "Session:" + sessionId + "//" + Guid.NewGuid() + ".MapDefinition"; //NOXLATE conn.ResourceService.SaveResourceAs(previewMdf, mdfId); previewMdf.ResourceID = mdfId; } if (previewMdf != null) { return(mapSvc.CreateMap(previewMdf, false)); } else { return(null); } }; Action <object, Exception> onComplete = (obj, ex) => { if (ex != null) { throw ex; } if (obj != null) { var rtMap = (RuntimeMap)obj; if (_viewManager != null) { _viewManager.OpenContent(ViewRegion.Document, () => new MapPreviewViewContent(rtMap, _launcher, (edSvc.IsNew) ? null : edSvc.ResourceID)); } else { var diag = new MapPreviewDialog(rtMap, _launcher, (edSvc.IsNew) ? null : edSvc.ResourceID); diag.Show(null); } } else //Fallback, shouldn't happen { _inner.Preview(res, edSvc, locale); } }; BusyWaitDialog.Run(Strings.PrgPreparingResourcePreview, worker, onComplete); } else { _inner.Preview(res, edSvc, locale); } }