//-1:无效ID; 0:首点ID; 正数:末点ID public static Tuple<int, int> GetPointIDPairFromFeature( IFeature feature, IPoint point, double radius, EnumSelectMode selectMode) { if (feature == null) return new Tuple<int, int>(-1, -1); IGeometry Geometry = feature.Shape; IPointCollection PointCollection = Geometry as IPointCollection; int pointCount = PointCollection.PointCount; //几何点集个数 IPoint pt0 = PointCollection.get_Point(0); //首点 IPoint ptn = PointCollection.get_Point(pointCount - 1); //末点 double s0 = GetDistance2P(point, pt0); //首点到目标点距离 double sn = GetDistance2P(point, ptn); //末点到目标点距离 bool bChanged0 = false; //首点是否符合移动条件 bool bChangedn = false; //末点是否符合移动条件 switch (selectMode) { //1 最近点 case EnumSelectMode.MostNearOne: bChanged0 = (s0 < sn) && (s0 < radius); bChangedn = (!(s0 < sn)) && (sn < radius); break; //2 第一点 case EnumSelectMode.OnlyFirst: bChanged0 = (s0 < radius); break; //3 最后点 case EnumSelectMode.OnlyLast: bChangedn = (sn < radius); break; //4 两端点 case EnumSelectMode.BothFirstAndLast: bChanged0 = (s0 < radius); bChangedn = (sn < radius); break; } int item1 = bChanged0 ? 0 : -1; int item2 = bChangedn ? pointCount - 1 : -1; return new Tuple<int, int>(item1, item2); }
public static async Task RepositionCardsAsync(this PlayerCollection <LifeCardGamePlayerItem> thisList, LifeCardGameMainGameClass mainGame, LifeCardGameGameContainer gameContainer, LifeCardGameVMData model) { bool rets; rets = model.CurrentPile !.PileEmpty(); LifeCardGameCardInformation?thisCard = null; EnumSelectMode thisMode = EnumSelectMode.ChoosePlayer; // must prove its card if (rets == false) { thisCard = model.CurrentPile.GetCardInfo(); if (thisCard.Action == EnumAction.Lawsuit && mainGame.OtherTurn > 0) { thisMode = EnumSelectMode.ChooseCard; } else if (thisCard.Action == EnumAction.DonateToCharity && mainGame.OtherTurn > 0) { thisMode = EnumSelectMode.ChooseCard; } else if (thisCard.Action == EnumAction.CareerSwap || thisCard.Action == EnumAction.MovingHouse || thisCard.Action == EnumAction.YourStory || thisCard.Action == EnumAction.SecondChance || thisCard.Action == EnumAction.AdoptBaby || thisCard.Action == EnumAction.LongLostRelative || thisCard.Action == EnumAction.MixUpAtVets) { thisMode = EnumSelectMode.ChooseCard; } } if (thisMode == EnumSelectMode.ChoosePlayer) { if (gameContainer.CloseOtherScreenAsync != null) { await gameContainer.CloseOtherScreenAsync(); } } else { if (thisCard !.Action == EnumAction.Lawsuit) { model.OtherText = "Give Card"; // lawsuit is larger than second chance }
public void UpdateSelectMode(EnumSelectMode selectMod) { m_SelectMod = selectMod; }
private void FeatureSelectWhenMouseUp(IPoint pointCenter, IPoint pointMouseUp, EnumSelectMode selectMode) { //选择个数过多,放弃选择 if (GlobeStatus.Map.SelectionCount > GlobeStatus.Setting.MaxFeaturesSelect) { //GlobeStatus.Map.ClearSelection(); MessageBox.Show("Too many features selected"); return; } double currentRadius = FunctionCommon.GetDistance2P(m_PointCentre, pointMouseUp); ISelection pSelection = GlobeStatus.Map.FeatureSelection; IEnumFeatureSetup pEnumFeatureSetup = pSelection as IEnumFeatureSetup; IEnumFeature pRnumFeature = pEnumFeatureSetup as IEnumFeature; pRnumFeature.Reset(); IFeature pFeature = pRnumFeature.Next(); GlobeStatus.WorkspaceEdit.StartEditOperation(); while (pFeature != null) { if (pFeature.Shape.GeometryType != esriGeometryType.esriGeometryPolyline) { pFeature = pRnumFeature.Next(); continue; } string FeatureLayerName = FunctionCommon.GetLayerNameFromFeature(pFeature); if (!(GlobeStatus.CheckedPolyLines.Contains(FeatureLayerName))) { pFeature = pRnumFeature.Next(); continue; } Tuple<int, int> PointIDPair = FunctionCommon.GetPointIDPairFromFeature(pFeature, pointCenter, currentRadius, selectMode); IPointCollection pPointCollection = pFeature.Shape as IPointCollection; //图形几何点集 if (PointIDPair.Item1 ==0 || PointIDPair.Item2 > 0) { if (PointIDPair.Item1 ==0) pPointCollection.UpdatePoint(0, pointCenter); if (PointIDPair.Item2 > 0) pPointCollection.UpdatePoint(PointIDPair.Item2, pointCenter); pFeature.Shape = (IGeometry)pPointCollection; pFeature.Store(); } pFeature = pRnumFeature.Next(); } GlobeStatus.WorkspaceEdit.StopEditOperation(); }
private void FeatureSelectWhenMouseMove(IPoint pointCentre, IPoint pointMouseMoveTo, EnumSelectMode SelectMode) { double currentRadius = FunctionCommon.GetDistance2P(m_PointCentre, pointMouseMoveTo); //1 选择半径太大,不响应 if (currentRadius > GlobeStatus.Setting.PixelMaxRadius * GlobeStatus.MapUnit) { return; } //2 变化距离太小,不响应 double distanceChange = currentRadius - m_LastRadius; if (Math.Abs(distanceChange) < GlobeStatus.Setting.PixelRadiusChangeLimit * GlobeStatus.MapUnit) { return; } //3 开始选择 IGeometry pGeometry = FunctionCommon.GetCircleGeometry(m_PointCentre, currentRadius); ISelectionEnvironment env = new SelectionEnvironmentClass(); env.CombinationMethod = esriSelectionResultEnum.esriSelectionResultNew; GlobeStatus.Map.SelectByShape(pGeometry, env, false); }