public static void SelectLayersFeaturesByOids( KeyValuePair <BasicFeatureLayer, List <long> > featuresOfLayer, SelectionCombinationMethod method) { if (!featuresOfLayer.Value.Any()) { return; } if (method == SelectionCombinationMethod.New) { //since SelectionCombinationMethod.New is only applied to //the current layer but selections of other layers remain, //we manually need to clear all selections first. SelectionUtils.ClearSelection(MapView.Active.Map); } { var qf = new QueryFilter { ObjectIDs = featuresOfLayer.Value }; featuresOfLayer.Key.Select(qf, method); } }
protected override bool IsInSelectionPhase() { if (KeyboardUtils.IsModifierPressed(Keys.Shift, true)) { return(true); } var task = QueuedTask.Run( () => { bool result; IList <Feature> selection = SelectionUtils.GetSelectedFeatures(ActiveMapView).ToList(); if (!CanUseSelection(selection)) { result = true; } else { result = !CanUseDerivedGeometries(); } return(result); }); return(task.Result); }
protected override Task OnToolActivateAsync(bool hasMapViewChanged) { _msg.VerboseDebug("OnToolActivateAsync"); MapView.Active.Map.PropertyChanged += Map_PropertyChanged; MapSelectionChangedEvent.Subscribe(OnMapSelectionChanged); try { return(QueuedTask.Run( () => { OnToolActivatingCore(); if (RequiresSelection) { ProcessSelection(SelectionUtils.GetSelectedFeatures(ActiveMapView)); } return OnToolActivatedCore(hasMapViewChanged); })); } catch (Exception e) { HandleError($"Error in tool activation ({Caption}): {e.Message}", e); } return(Task.CompletedTask); }
protected override bool HandleEscape() { if (IsInSketchMode) { // if sketch is empty, also remove selection and return to selection phase if (!RequiresSelection) { // remain in sketch mode, just reset the sketch ResetSketch(); } else { Geometry sketch = GetCurrentSketchAsync().Result; if (sketch != null && !sketch.IsEmpty) { ResetSketch(); } else { SelectionUtils.ClearSelection(ActiveMapView.Map); StartSelectionPhase(); } } } else { SelectionUtils.ClearSelection(ActiveMapView.Map); } return(true); }
public void OnChangePath(){ var assetPath = SelectionUtils.GetAssetFolder( Selection.objects[0] ); var path = EditorUtility.SaveFilePanel("Save Animation File", assetPath, Selection.activeObject.name , "anim"); XLogger.Log("path : " + path); XLogger.Log("path : " + path); }
public static void CreateSelection(){ if(Selection.objects == null || Selection.objects.Length == 0) { XLogger.Log("Selection objects must greater one!!"); return; } List<Sprite> sprites = new List<Sprite>(); List<Texture2D> textures = SelectionUtils.GetObjects<Texture2D>(); List<Sprite> tex2Sprite = XUtils.ToList<Texture2D, Sprite>(textures, (v)=>{ var objects = AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(v)); for (int i = 0; i < objects.Length; i++) { var o = objects[i]; if(o is Sprite){ return o as Sprite; } } return null; }); sprites = tex2Sprite; tex2Sprite.AddRange(SelectionUtils.GetObjects<Sprite>()); if(sprites.Count == 0) { XLogger.Log("Selection sprites must greater one!!"); return; } var creator = InitWindow<SpriteAnimationCreator>(); creator.totalSprite = sprites; creator.InitPath(); }
public static void SelectLayersFeaturesByOids( [CanBeNull] Dictionary <BasicFeatureLayer, List <long> > featuresPerLayer, SelectionCombinationMethod method) { if (featuresPerLayer == null) { return; } if (method == SelectionCombinationMethod.New) { //since SelectionCombinationMethod.New is only applied to //the current layer but selections of other layers remain, //we manually need to clear all selections first. SelectionUtils.ClearSelection(MapView.Active.Map); } foreach (KeyValuePair <BasicFeatureLayer, List <long> > kvp in featuresPerLayer) { var qf = new QueryFilter { ObjectIDs = kvp.Value }; kvp.Key.Select(qf, method); } }
protected override void AfterSelection(IList <Feature> selectedFeatures, CancelableProgressor progressor) { WorkListsModule.Current.OnWorkItemPicked(new WorkItemPickArgs { features = selectedFeatures.ToList() }); SelectionUtils.ClearSelection(ActiveMapView.Map); }
protected override bool HandleEscape() { SelectionUtils.ClearSelection(ActiveMapView.Map); ResetDerivedGeometries(); StartSelectionPhase(); return(true); }
//[MenuItem( "Tools/Copy GUISkin" )] public static void CopySkin() { var selectSkin = SelectionUtils.GetObject <GUISkin>(); skin.customStyles = selectSkin.customStyles; skin.window = selectSkin.window; skin.button = selectSkin.button; skin.label = selectSkin.label; EditorUtility.SetDirty(skin); }
protected override GH_GetterResult Prompt_Singular(ref Grasshopper.Kernel.Types.GH_Plane value) { Rhino.Geometry.Plane?plane = SelectionUtils.SelectPlane(); if (plane == null) { return(GH_GetterResult.cancel); } value = new Grasshopper.Kernel.Types.GH_Plane(plane.Value); return(GH_GetterResult.success); }
void OnGUI() { if (!grid.IsEditing() && !Managers.Store.store.button.IsStoreOpened() && isSelecting) { // Create a rect from both mouse positions var rect = SelectionUtils.GetScreenRect(OldMousePosition, Input.mousePosition); SelectionUtils.DrawScreenRect(rect, new Color(0.8f, 0.8f, 0.95f, 0.25f)); SelectionUtils.DrawScreenRectBorder(rect, 2, new Color(0.8f, 0.8f, 0.95f)); } }
protected override GH_GetterResult Prompt_Singular(ref X value) { var selected = SelectionUtils.SelectEntity(SubentType, SelFilter, false); if (selected == null) { return(GH_GetterResult.cancel); } var docName = Application.DocumentManager.MdiActiveDocument.Name; value = CreateParameter(selected[0], docName); return(GH_GetterResult.success); }
protected override GH_GetterResult Prompt_Plural(ref List <X> values) { var selected = SelectionUtils.SelectEntity(SubentType, SelFilter, true); if (selected == null) { return(GH_GetterResult.cancel); } var docName = Application.DocumentManager.MdiActiveDocument.Name; values = selected.Select(subent => CreateParameter(subent, docName)).ToList(); return(GH_GetterResult.success); }
public GcsBrowserViewModel(GcsFileBrowserWindow owner) { _owner = owner; _selectionUtils = new SelectionUtils(owner); _currentState = s_emptyState; NavigateToRootCommand = new ProtectedCommand(OnNavigateToRootCommand); NavigateToCommand = new ProtectedCommand <PathStep>(OnNavigateToCommand); RefreshCommand = new ProtectedCommand(OnRefreshCommand); NewFolderCommand = new ProtectedCommand(OnNewFolderCommand); DeleteSelectedCommand = new ProtectedCommand(OnDeleteCommand, canExecuteCommand: false); UploadFilesCommand = new ProtectedCommand(OnUploadFilesCommand); DoubleClickCommand = new ProtectedCommand <GcsRow>(OnDoubleClickCommand); }
public CloudExplorerViewModel(SelectionUtils selectionUtils) { _selectionUtils = selectionUtils; // Contains the list of sources to display to the user, in the order they will // be displayed. _sources = new List <ICloudExplorerSource> { // The Google App Engine source. new GaeSource(this), // The Google Compute Engine source. new GceSource(this), // The Google Cloud Storage source. new GcsSource(this), // The Google Cloud SQL source. new CloudSQLSource(this), // The Google Publish/Subscription source. new PubsubSource(this), // The source to navigate to the cloud console. new CloudConsoleSource(), }; var refreshButtonEnumerable = new[] { new ButtonDefinition { Icon = s_refreshIcon.Value, ToolTip = Resources.CloudExplorerRefreshButtonToolTip, Command = new ProtectedCommand(OnRefreshCommand), } }; Buttons = refreshButtonEnumerable.Concat(_sources.SelectMany(x => x.Buttons)); ManageAccountsCommand = new ProtectedCommand(OnManageAccountsCommand); DoubleClickCommand = new ProtectedCommand <IAcceptInput>(OnDoubleClickCommand); SelectProjectCommand = new ProtectedCommand(OnSelectProjectCommand); CredentialsStore.Default.CurrentAccountChanged += OnCredentialsChanged; CredentialsStore.Default.CurrentProjectIdChanged += OnCredentialsChanged; CredentialsStore.Default.Reset += OnCredentialsChanged; ErrorHandlerUtils.HandleAsyncExceptions(ResetCredentialsAsync); }
public bool IsWithinSelectionBounds(GameObject gameObject) { if (!isSelecting) { return(false); } var camera = Camera.main; var viewportBounds = SelectionUtils.GetViewportBounds(camera, OldMousePosition, Input.mousePosition); return(viewportBounds.Contains( camera.WorldToViewportPoint(gameObject.transform.position))); }
protected override bool OnToolActivatedCore(bool hasMapViewChanged) { var featureLayers = ActiveMapView.Map.Layers.OfType <FeatureLayer>(); foreach (FeatureLayer featureLayer in featureLayers) { if (WorkListsModule.Current.LayerByWorkList.ContainsValue(featureLayer)) { LayerUtils.SetLayerSelectability(featureLayer, true); } } SelectionUtils.ClearSelection(ActiveMapView.Map); return(true); }
static void CreateAnimationNodesFromSelection(object p_nodeType) { Transform[] selectedTransforms = SelectionUtils.GetTransformsFromSelection(); float zoom = DashEditorCore.EditorConfig.zoom; Vector2 viewOffset = DashEditorCore.EditorConfig.editingGraph.viewOffset; Vector2 position = new Vector2(_lastMousePosition.x * zoom - viewOffset.x, _lastMousePosition.y * zoom - viewOffset.y); Vector2 offset = Vector2.zero; foreach (Transform transform in selectedTransforms) { NodeBase node = NodeUtils.CreateNode(DashEditorCore.EditorConfig.editingGraph, (Type)p_nodeType, position + offset); if (node != null) { RetargetNodeModelBase model = node.GetModel() as RetargetNodeModelBase; model.retarget = true; //model.target.SetValue(transform.name); model.useReference = true; IExposedPropertyTable propertyTable = DashEditorCore.EditorConfig.editingController; bool isDefault = PropertyName.IsNullOrEmpty(model.targetReference.exposedName); if (isDefault) { PropertyName newExposedName = new PropertyName(GUID.Generate().ToString()); model.targetReference.exposedName = newExposedName; propertyTable.SetReferenceValue(newExposedName, transform); //p_fieldInfo.SetValue(p_object, exposedReference); } else { propertyTable.SetReferenceValue(model.targetReference.exposedName, transform); } // If its bindable bind all values to current transform if (node is IAnimationNodeBindable) { ((IAnimationNodeBindable)node).GetTargetFrom(transform); ((IAnimationNodeBindable)node).GetTargetTo(transform); } offset.y += node.Size.y + 24; } } }
/// <summary> /// Initializes a new instance of the <see cref="CloudExplorerToolWindow"/> class. /// </summary> public CloudExplorerToolWindow() : base(null) { SetCaption(); _selectionUtils = new SelectionUtils(this); var model = new CloudExplorerViewModel(_selectionUtils); Content = new CloudExplorerToolWindowControl(_selectionUtils) { DataContext = model, }; CredentialsStore.Default.CurrentAccountChanged += OnCurrentAccountChanged; EventsReporterWrapper.ReportEvent(CloudExplorerInteractionEvent.Create()); }
protected override bool OnHotkeyActivated(KeyInput e) { if (world.IsGameOver) { return(false); } var eligiblePlayers = SelectionUtils.GetPlayersToIncludeInSelection(world); // Select actors on the screen which belong to the current player(s) var newSelection = SelectionUtils.SelectActorsOnScreen(world, worldRenderer, null, eligiblePlayers).SubsetWithHighestSelectionPriority(e.Modifiers).ToList(); // Check if selecting actors on the screen has selected new units if (newSelection.Count > selection.Actors.Count()) { if (newSelection.Count > 1) { TextNotificationsManager.AddFeedbackLine($"Selected {newSelection.Count} units across screen."); } else { TextNotificationsManager.AddFeedbackLine($"Selected one unit across screen."); } } else { // Select actors in the world that have highest selection priority newSelection = SelectionUtils.SelectActorsInWorld(world, null, eligiblePlayers).SubsetWithHighestSelectionPriority(e.Modifiers).ToList(); if (newSelection.Count > 1) { TextNotificationsManager.AddFeedbackLine($"Selected {newSelection.Count} units across map."); } else { TextNotificationsManager.AddFeedbackLine($"Selected one unit across map."); } } selection.Combine(world, newSelection, false, false); Game.Sound.PlayNotification(world.Map.Rules, world.LocalPlayer, "Sounds", ClickSound, null); return(true); }
protected override bool OnMapSelectionChangedCore(MapSelectionChangedEventArgs args) { if (ActiveMapView == null) { return(false); } // TODO: only if selection was cleared? Generally allow changing the selection through attribute selection? IList <Feature> selection = SelectionUtils.GetSelectedFeatures(ActiveMapView).ToList(); if (!CanUseSelection(selection)) { //LogPromptForSelection(); StartSelectionPhase(); } return(true); }
/// <summary> /// Initializes a new instance of the <see cref="CloudExplorerToolWindow"/> class. /// </summary> public CloudExplorerToolWindow() : base(null) { SetCaption(); _selectionUtils = new SelectionUtils(this); var model = new CloudExplorerViewModel(_selectionUtils); Content = new CloudExplorerToolWindowControl(_selectionUtils) { DataContext = model, }; CredentialsStore.Default.CurrentAccountChanged += OnCurrentAccountChanged; CredentialsStore.Default.Reset += OnCurrentAccountChanged; ExtensionAnalytics.ReportScreenView(this); }
protected override bool SelectAndProcessDerivedGeometry( Dictionary <MapMember, List <long> > selection, Geometry sketch, CancelableProgressor progressor) { Assert.NotNull(_overlaps); Overlaps overlapsToRemove = SelectOverlaps(_overlaps, sketch); if (!overlapsToRemove.HasOverlaps()) { return(false); } IEnumerable <Feature> selectedFeatures = MapUtils.GetFeatures(selection); RemoveOverlapsResult result = MicroserviceClient.RemoveOverlaps( selectedFeatures, overlapsToRemove, _overlappingFeatures, progressor?.CancellationToken ?? new CancellationTokenSource().Token); var updates = new Dictionary <Feature, Geometry>(); var inserts = new Dictionary <Feature, IList <Geometry> >(); foreach (var resultPerFeature in result.ResultsByFeature) { updates.Add(resultPerFeature.OriginalFeature, resultPerFeature.UpdatedGeometry); if (resultPerFeature.InsertGeometries.Count > 0) { inserts.Add(resultPerFeature.OriginalFeature, resultPerFeature.InsertGeometries); } } bool saved = GdbPersistenceUtils.SaveInOperation("Remove overlaps", updates, inserts); var currentSelection = SelectionUtils.GetSelectedFeatures(MapView.Active).ToList(); CalculateDerivedGeometries(currentSelection, progressor); return(saved); }
// 开始具体的调试操作 private static void SuperSubScript(Application vsoApp, bool?superOrSubscript) { Document doc = vsoApp.ActiveDocument; if (doc != null) { int diagramServices = doc.DiagramServicesEnabled; doc.DiagramServicesEnabled = (int)VisDiagramServices.visServiceVersion140 + (int)VisDiagramServices.visServiceVersion150; // Window win = vsoApp.ActiveWindow; Selection sel = vsoApp.ActiveWindow.Selection; // 根据不同的编辑或选择情况而进行不同的处理 int[] selectedShapeIds; VisSelectionMode sm = SelectionUtils.GetSelectionMode(sel, out selectedShapeIds); switch (sm) { case VisSelectionMode.EditingCharactors: var chs = win.SelectedText; if (chs.CharCount > 0) { SuperOrSubScriptCharactors(chs, superOrSubscript); } break; case VisSelectionMode.SingleShape: SuperOrSubScriptShape(sel[1], superOrSubscript); break; case VisSelectionMode.MultiShapes: foreach (Shape shp in sel) { SuperOrSubScriptShape(shp, superOrSubscript); } break; } // 将 DiagramServicesEnabled 属性复原 doc.DiagramServicesEnabled = diagramServices; } }
public CloudExplorerViewModel(SelectionUtils selectionUtils) { _selectionUtils = selectionUtils; // Contains the list of sources to display to the user, in the order they will // be displayed. _sources = new List <ICloudExplorerSource> { // The Google Compute Engine source. new GceSource(this), // The Google Cloud Storage source. new GcsSource(this), // The Google Cloud SQL source. new CloudSQLSource(this), // The source to navigate to the cloud console. new CloudConsoleSource(), }; var refreshButtonEnumerable = new ButtonDefinition[] { new ButtonDefinition { Icon = s_refreshIcon.Value, ToolTip = Resources.CloudExplorerRefreshButtonToolTip, Command = new WeakCommand(this.OnRefresh), } }; Buttons = Enumerable.Concat(refreshButtonEnumerable, _sources.SelectMany(x => x.Buttons)); ManageAccountsCommand = new WeakCommand(OnManageAccountsCommand); CredentialsStore.Default.CurrentAccountChanged += OnCurrentAccountChanged; CredentialsStore.Default.CurrentProjectIdChanged += OnCurrentProjectIdChanged; CredentialsStore.Default.Reset += OnReset; ResetCredentials(); }
protected override void OnKeyUpCore(MapViewKeyEventArgs k) { _msg.VerboseDebug("OnKeyUpCore"); if (IsShiftKey(k.Key)) { _intermittentSelectionPhase = false; // TODO: Maintain selection by using SelectionChanged? Event? IList <Feature> selection = SelectionUtils.GetSelectedFeatures(ActiveMapView).ToList(); if (CanUseSelection(selection)) { StartSketchPhase(); if (_editSketchBackup != null) { ActiveMapView.SetCurrentSketchAsync(_editSketchBackup); // This puts back the edit operations in the undo stack, but when clicking on the top one, the sketch // is cleared and undoing any previous operation has no effect any more. ActiveMapView.Map.OperationManager.ClearUndoCategory("SketchOperations"); if (_sketchOperations != null) { foreach (Operation operation in _sketchOperations) { ActiveMapView.Map.OperationManager.AddUndoOperation(operation); } } } } _editSketchBackup = null; } if (k.Key == _keyRestorePrevious) { RestorePreviousSketch(); } }
protected override bool HandleEscape() { QueuedTaskUtils.Run( () => { if (IsInSubcurveSelectionPhase()) { ResetDerivedGeometries(); } else { SelectionUtils.ClearSelection(ActiveMapView.Map); StartSelectionPhase(); } return(true); }); return(true); }
private void RestorePreviousSketch() { if (!SupportRestoreLastSketch) { return; } if (_previousSketch == null || _previousSketch.IsEmpty) { _msg.Warn("There is no previous sketch to restore."); return; } if (!IsInSketchMode) { // If a non-rectangular sketch is set while SketchType is rectangle (or probably generally the wrong type) // sketching is not possible any more and the application appears hanging // Try start sketch mode: IList <Feature> selection = SelectionUtils.GetSelectedFeatures(ActiveMapView).ToList(); if (CanUseSelection(selection)) { AfterSelection(selection, null); } } if (IsInSketchMode) { SetCurrentSketchAsync(_previousSketch); } else { _msg.Warn("Sketch cannot be restored in selection phase. " + "Please try again in the sketch phase."); } }
protected override Task OnEditCompletedCore(EditCompletedEventArgs args) { bool requiresRecalculate = args.CompletedType == EditCompletedType.Discard || args.CompletedType == EditCompletedType.Reconcile || args.CompletedType == EditCompletedType.Redo || args.CompletedType == EditCompletedType.Undo; if (requiresRecalculate) { QueuedTask.Run( () => { var selectedFeatures = SelectionUtils.GetSelectedFeatures(ActiveMapView).ToList(); CalculateDerivedGeometries(selectedFeatures, GetCancelableProgressor()); return(true); }); } return(base.OnEditCompletedCore(args)); }