/// <summary> /// Creates a new VM, or if there was already created it returns the cached VM /// </summary> /// <param name="projectitem"></param> /// <returns></returns> public static CodeFileViewModel Create(ProjectItemCodeDocument projectitem) { var viewModelPoolService = ServiceLocator.Instance.Resolve<IViewModelPoolService>(); CodeFileViewModel vm; vm = viewModelPoolService.Resolve<CodeFileViewModel>(projectitem); if(vm == null) { vm = new CodeFileViewModel(projectitem); viewModelPoolService.Register(projectitem, vm); } return vm; }
public InvokeCompletionViewModel(CodeFileViewModel documentVM, CodeSegment methodSegment, int startParam) { _document = documentVM.CodeDocument; _documentVM = documentVM; _toolTip = new ToolTip(); _toolTip.Placement = PlacementMode.Custom; _toolTip.PlacementTarget = _documentVM.Editor.TextArea.TextView; _toolTip.Content = this; _toolTip.CustomPopupPlacementCallback = PopupPlacement; _documentVM.Editor.TextArea.KeyDown += (s, e) => { if(e.Key == Key.Escape) this.CloseCommand.Execute(null); }; //_documentVM.Editor.TextArea.TextEntered += OnTextEntered; _documentVM.Editor.TextArea.Caret.PositionChanged += OnCaretPositionChanged; AllParameters = new ObservableCollection<InvokeParameter>(); SetMethod(methodSegment); SetCurrentParam(startParam); }