public override void Execute(SolutionModel solutionModel, SelectionContext context) { FileModel fileModel; CodeSpan selection; if (!solutionModel.IsEditorSelection(context, out fileModel, out selection)) { return; } IMemberDeclaration memberDeclaration = fileModel.InnerMost<IMemberDeclaration>(selection); if (memberDeclaration.ExistsTextuallyInFile && !memberDeclaration.Identifier.CodeSpan.Intersects(selection)) { memberDeclaration.Identifier.Select(); } else { ITypeDeclaration typeDeclaration = fileModel.InnerMost<ITypeDeclaration>(selection); if (typeDeclaration.ExistsTextuallyInFile) { NavigateToTypeDeclaration(typeDeclaration, selection); } } }
public override void Execute(SolutionModel solutionModel, SelectionContext context) { FileModel fileModel; CodeSpan selection; if (!solutionModel.IsEditorSelection(context, out fileModel, out selection)) { return; } propertiesSelectedByUser = false; IIdentifier identifier = fileModel.InnerMost<IIdentifier>(selection); IClassDeclaration classDeclaration = identifier.ParentConstruct.As<IClassDeclaration>(); if (classDeclaration.ExistsTextuallyInFile && classDeclaration.IsInUserCode() && !classDeclaration.IsPrivate()) { IConstructEnumerable<IMemberDeclaration> propertiesForWrapping = GetPropertiesForWrapping(classDeclaration); if (!propertiesForWrapping.Any()) { CreateViewModelWithoutUserSelectedProperties(classDeclaration).NavigateTo(); } else { ConfirmOccurencesDialog confirmOccurencesDialog = fileModel.UIProcess.Get<ConfirmOccurencesDialog>(); confirmOccurencesDialog.ShowIfOccurencesToConfirmIn("Select properties for wrapping", "Select which properties to be wrapped", () => ConfirmPropertyDeclarationsToBeWrappedAndContinueWrapping(classDeclaration, propertiesForWrapping)); } } }
public override bool CanExecute(SolutionModel solutionModel, SelectionContext context) { FileModel fileModel; CodeSpan selection; if (!solutionModel.IsEditorSelection(context, out fileModel, out selection)) { return false; } return fileModel.MemberIdentifierAt(selection).ExistsTextuallyInFile; }
public override bool CanExecute(SolutionModel solutionModel, SelectionContext context) { FileModel fileModel; CodeSpan selection; if (!solutionModel.IsEditorSelection(context, out fileModel, out selection)) { return false; } IMemberDeclaration member = fileModel.InnerMost<IMemberDeclaration>(selection); return member.ExistsTextuallyInFile && member.Identifier.CodeSpan.Intersects(selection); }
public override bool CanExecute(SolutionModel solutionModel, SelectionContext context) { FileModel fileModel; CodeSpan selection; if (!solutionModel.IsEditorSelection(context, out fileModel, out selection)) { return false; } IConstructEnumerable<IFieldDeclaration> fields = FindFields(fileModel, selection); return fields.Exist() && ImplementsINotifyPropertyChanged(fields.First().EnclosingClass); }
public override bool CanExecute(SolutionModel solutionModel, SelectionContext context) { FileModel fileModel; CodeSpan selection; if (!solutionModel.IsEditorSelection(context, out fileModel, out selection)) { return false; } IIdentifier identifier = fileModel.InnerMost<IIdentifier>(selection); IClassDeclaration classDeclaration = identifier.ParentConstruct.As<IClassDeclaration>(); return classDeclaration.ExistsTextuallyInFile && classDeclaration.IsInUserCode() && !classDeclaration.IsPrivate(); }
public override bool CanExecute(SolutionModel solutionModel, SelectionContext context) { FileModel fileModel; CodeSpan selection; if (!solutionModel.IsEditorSelection(context, out fileModel, out selection)) { return false; } IUsingDirectiveSection section = fileModel.InnerMost<IUsingDirectiveSection>(selection); return section.Exists && !section.Enclosing<INamespaceDeclaration>().Exists; }
public UnusedMemberFinderResult FindIn(PartitionedAssemblySet assemblies) { // cries for refactoring) this.Trace("root: types"); var types = assemblies.Roots.SelectMany(a => this.LoadTypes(a)).ToArray(); var context = new SelectionContext(types); this.Trace("root: all members"); var allMembers = this.LoadMembers(context.Types, context); this.Trace("root: used members"); var usedMembers = this.FindUsedMembers(allMembers, context).ToSet(); this.Trace("other: types"); var otherTypes = assemblies.Other.SelectMany(a => this.LoadTypes(a)).ToSet(); this.Trace("all: types += other types"); context.Types.UnionWith(otherTypes); this.Trace("other: all members"); var otherMembers = this.LoadMembers(otherTypes, context); this.Trace("all: members += other members"); allMembers.UnionWith(otherMembers); this.Trace("other: used members"); var otherUsedMembers = this.FindUsedMembers(usedMembers, otherMembers, context); this.Trace("all: ignored members"); var ignoredMembers = this.FindIgnored(allMembers, context).ToSet(); this.Trace("all: unused members"); // this obviously messes up allMembers variable, // but it is so much faster to do it this way var unusedMembers = allMembers; unusedMembers.ExceptWith(ignoredMembers); unusedMembers.ExceptWith(usedMembers); unusedMembers.ExceptWith(otherUsedMembers); return new UnusedMemberFinderResult( allMembers, unusedMembers, ignoredMembers ); }
public override bool CanExecute(SolutionModel solutionModel, SelectionContext context) { FileModel fileModel; CodeSpan selection; if (!solutionModel.IsEditorSelection(context, out fileModel, out selection)) { return false; } IPropertyDeclaration propertyDeclaration = fileModel.InnerMost<IPropertyDeclaration>(selection); if (IsFieldBackedPropertyWithSetterInsideClass(propertyDeclaration)) { return EnclosingClassImplementsINotifyPropertyChanged(propertyDeclaration); } return false; }
public override void Execute(SolutionModel solutionModel, SelectionContext context) { FileModel fileModel; CodeSpan selection; if (!solutionModel.IsEditorSelection(context, out fileModel, out selection)) { return; } IMemberDeclaration memberDeclaration = fileModel.MemberIdentifierAt(selection); if (memberDeclaration.ExistsTextuallyInFile) { IMemberDeclaration nextMember = memberDeclaration.NextMember(); if (nextMember.ExistsTextuallyInFile) { nextMember.Identifier.NavigateTo(); } } }
public override void Execute(SolutionModel solutionModel, SelectionContext context) { FileModel fileModel; CodeSpan selection; if (!solutionModel.IsEditorSelection(context, out fileModel, out selection)) { return; } IPropertyDeclaration propertyDeclaration = fileModel.InnerMost<IPropertyDeclaration>(selection); if (IsFieldBackedPropertyWithSetterInsideClass(propertyDeclaration) && EnclosingClassImplementsINotifyPropertyChanged(propertyDeclaration)) { IConstructLanguage language = propertyDeclaration.Language; string methodInvocationName = language.Name == LanguageNames.CSharp ? "OnPropertyChanged" : "RaisePropertyChangedEvent"; IMethodInvocation methodInvocation = language.MethodInvocation( language.None<IExpression>(), language.Identifier(methodInvocationName), language.None<ITypeArguments>(), language.Arguments( language.Argument(language.StringLiteral(propertyDeclaration.Identifier.Name)))); IAccessor setter = propertyDeclaration.Setter(); List<IStatement> ifBlockStatements = new List<IStatement>(setter.Block.ChildStatements); ifBlockStatements.Add(language.ExpressionStatement(methodInvocation)); IIfStatement ifStatement = language.IfStatement( language.BinaryExpression( language.MemberAccess(language.None<IExpression>(), propertyDeclaration.BackingField().Identifier), Operator.NotEqual, language.Expression("value")), language.Block(ifBlockStatements)); IBlock newBlock = language.Block(ifStatement); setter.Block = newBlock; } }
public override bool CanExecute(SolutionModel solutionModel, SelectionContext context) { FileModel fileModel; CodeSpan selection; if (!solutionModel.IsEditorSelection(context, out fileModel, out selection)) { return false; } IMemberDeclaration memberDeclaration = fileModel.InnerMost<IMemberDeclaration>(selection); if (memberDeclaration.ExistsTextuallyInFile && !memberDeclaration.Identifier.CodeSpan.Intersects(selection)) { return memberDeclaration.Is<IMethodDeclaration>() || memberDeclaration.Is<IPropertyDeclaration>() || memberDeclaration.Is<IConstructorDeclaration>() || memberDeclaration.Is<IStaticConstructorDeclaration>(); } else { return fileModel.InnerMost<ITypeDeclaration>(selection).ExistsTextuallyInFile; } }
public override void Execute(SolutionModel solutionModel, SelectionContext context) { FileModel fileModel; CodeSpan selection; if (!solutionModel.IsEditorSelection(context, out fileModel, out selection)) { return; } IConstructEnumerable<IFieldDeclaration> fields = FindFields(fileModel, selection); if (fields.Exist()) { IConstructLanguage language = fields.Language; foreach (IFieldDeclaration field in fields) { IPropertyDeclaration property = language.Property( language.None<IDocComment>(), language.None<IAttributes>(), language.Modifiers(Modifiers.Public), language.TypeName(field.TypeName.Type), language.None<IIdentifier>()); NamingPolicy propertyNamingPolicy = property.PrimaryNamingPolicy(fileModel.UserSettings); string propertyName = propertyNamingPolicy.MakeMemberNameUniqueInScope(field, field.Identifier.Name); property.Identifier = language.Identifier(propertyName); IAccessor getter = language.FieldGetter(field.Identifier); IAccessor setter = CreateSetter(language, propertyName, field); property.Accessors = language.Enumerable(new List<IAccessor>() { getter, setter }); field.EnclosingClass.Insert(property); } } }
public override void Execute(SolutionModel solutionModel, SelectionContext context) { FileModel fileModel; CodeSpan selection; if (!solutionModel.IsEditorSelection(context, out fileModel, out selection)) { return; } IUsingDirectiveSection mainSection = fileModel.InnerMost<IUsingDirectiveSection>(selection); if (mainSection.Exists) { HashSet<IUsingDirectiveSection> sections = new HashSet<IUsingDirectiveSection>(); foreach (IUsingDirectiveSection section in fileModel.All<IUsingDirectiveSection>()) { INamespaceDeclaration nameSpaceItems = section.Enclosing<INamespaceDeclaration>(); //we are interested only in top level namespaces if (nameSpaceItems.Exists && !nameSpaceItems.Enclosing<INamespaceDeclaration>().Exists) { sections.Add(section); } } foreach (IUsingDirectiveSection section in sections) { section.Insert(mainSection.Directives, fileModel); } } foreach (IUsingDirective directive in mainSection.Directives) { directive.Remove(); } }
private string LookupFormIDI(SelectionContext context, uint id) { if (context != null && context.Record != null) { var p = GetPluginFromNode(context.Record); if (p != null) { p.LookupFormID(id); } } return "No selection"; }
protected DataModelItemBase(SelectionContext <DataModelItemBase> context) : base(context) { }
public override bool ShouldShowVisualAidTag(SolutionModel solutionModel, SelectionContext context) { return(true); }
//-------------------------------------------------------------------------------------------------- public override bool Start() { _SelectionContext = WorkspaceController.Selection.OpenContext(SelectionContext.Options.NewSelectedList); var workspace = WorkspaceController.Workspace; var editorSettings = SketchEditorSettingsCache.GetOrCreate(Sketch); if (editorSettings.WorkingContext == null) { editorSettings.WorkingContext = workspace.WorkingContext.Clone(); } workspace.WorkingContext = editorSettings.WorkingContext; WorkspaceController.LockWorkingPlane = true; workspace.WorkingPlane = Sketch.Plane; var vc = WorkspaceController.ActiveViewControlller; _SavedViewParameters = vc.Viewport.GetViewParameters(); vc.LockedToPlane = true; if (editorSettings.ViewParameters != null) { vc.Viewport.RestoreViewParameters(editorSettings.ViewParameters); // Update direction var twist = vc.Viewport.Twist; vc.SetPredefinedView(ViewportController.PredefinedViews.WorkingPlane); vc.Viewport.Twist = twist; } else { _CenterView(); RotateView(0); } vc.Viewport.PropertyChanged += _Viewport_PropertyChanged; EnableClipPlane(editorSettings.ClipPlaneEnabled); if (Sketch.IsVisible) { var visualSketchShape = WorkspaceController.VisualShapes.GetVisualShape(Sketch.Body, true); if (visualSketchShape != null) { visualSketchShape.IsHidden = true; } } _LastGizmoScale = WorkspaceController.ActiveViewport.GizmoScale; _TempPoints = new Dictionary <int, Pnt2d>(Sketch.Points); Transform = Sketch.GetTransformation(); Elements.InitElements(_TempPoints); _UpdateSelections(); Sketch.ElementsChanged += _Sketch_ElementsChanged; _SelectAction = new SelectSketchElementAction(this); if (!WorkspaceController.StartToolAction(_SelectAction)) { return(false); } _SelectAction.Finished += _OnSelectionChanged; StatusText = UnselectedStatusText; return(true); }
/// <summary> /// build a XPT Node out of a selection /// </summary> /// <param name="ctx"></param> /// <returns></returns> public bool BuildXPTNode(SelectionContext ctx) { // extract the class name if (String.IsNullOrEmpty(ctx.ClassName)) ctx.ClassName = ctx.dataObjectClass().GetText(); // create the result with the data object class name eXPressionTree.ResultList Result = (ResultList) ctx.resultSelection().XPTreeNode; // create a selection expression with the result eXPressionTree.SelectionExpression aSelection = new eXPressionTree.SelectionExpression(result: Result, engine: this.Engine); // L_SQUARE_BRACKET R_SQUARE_BRACKET // all if (ctx.selectConditions() == null) { // simple true operator aSelection.Nodes.Add(LogicalExpression.TRUE()); } else { // add the subtree to the selection aSelection.Nodes.Add(ctx.selectConditions().XPTreeNode); } // add it to selection as XPTreeNode ctx.XPTreeNode = aSelection; return true; }
private void ResetEditorWindow() { this.activeTimeline = null; this.activeEditingTab = EditingTab.NodeEditing; this.selection = new SelectionContext(); this.selectedCharacter = HamTimeline.InvalidID; this.selectedScene = HamTimeline.InvalidID; this.overviewOffset = Vector2.zero; }
public override bool ShouldShowVisualAidTag(SolutionModel solutionModel, SelectionContext context) { return true; }
private void model_SessionInitialized() { SelectionContext = null; }
public override RequestCode OnSelect( StorableObject[] arrSelectedObjects, SelectionContext oContext) { // Execute standard operation. base.OnSelect(arrSelectedObjects, oContext); if (EProjectManager.GetInstance().GetEditInteraction() != this) { return(RequestCode.Stop); } Function oF = null; if (arrSelectedObjects[0] is Rectangle) { string oFName = (arrSelectedObjects[0] as Rectangle).Properties.get_PROPUSER_TEST(1); oF = Function.FromStringIdentifier(oFName) as Function; } if (arrSelectedObjects[0] is Function) { oF = arrSelectedObjects[0] as Function; } if (oF != null) { Editor.ITreeViewItem item = Editor.Editor.GetInstance().EForm.GetActiveItem(); if (item == null) { return(RequestCode.Nothing); } if (item.IsUseDevList) { string devName; string objectName; int objectNumber; string deviceType; int deviceNumbe; bool res = Device.DeviceManager.CheckDeviceName(oF.Name, out devName, out objectName, out objectNumber, out deviceType, out deviceNumbe); if (res) { string oldDevices = " " + item.EditText[1] + " "; string newDevices = ""; //Для корректного поиска отделяем пробелами. devName = " " + devName + " "; if (oldDevices.Contains(devName)) { newDevices = oldDevices.Replace(devName, " "); } else { newDevices = oldDevices + devName.Trim(); } Editor.Editor.GetInstance().EForm.SetNewVal(newDevices); //Обновление списка устройств при его наличии. if (DFrm.GetInstance().IsVisible() == true) { Device.DeviceType[] devTypes; Device.DeviceSubType[] devSubTypes; item.GetDevTypes(out devTypes, out devSubTypes); DFrm.GetInstance().ShowDevices( Device.DeviceManager.GetInstance(), devTypes, devSubTypes, false, true, item.EditText[1], null); } } } } return(RequestCode.Select | RequestCode.NoPreselect | RequestCode.NoMultiSelect); }