/// <summary> /// Initializes a new instance of the <see cref="GotoLineToolWindowViewModel"/> class. /// </summary> /// <param name="owner">The editor that owns the tool window.</param> public GotoLineToolWindowViewModel(CodeEditorViewModel owner) : base(owner) { Caption = "Go to Line"; LineNumber = new IntegerFieldViewModel("Line", 1, Int32.MaxValue); }
protected override async void OnDrop(DragEventArgs e) { base.OnDrop(e); if (e.DataView != null) { if (e.DataView.Properties.TryGetValue(TabKey, out object tab) && e.DataView.Properties.TryGetValue(TabViewKey, out object tabView) && tabView is TabViewViewModel originalTabView) { originalTabView.Tabs.Remove(tab); ViewModel.Tabs.Add(tab); } else if (e.DataView.Contains(StandardDataFormats.StorageItems)) { var items = await e.DataView.GetStorageItemsAsync(); foreach (IStorageFile file in items.OfType <IStorageFile>()) { StorageApplicationPermissions.FutureAccessList.Add(file, file.Path); CodeEditorViewModel codeEditor = new CodeEditorViewModel(file); ViewModel.Tabs.Add(codeEditor); } } } }
public RESTScreenViewModel(Infrastructure infrastructure, CodeEditorViewModel requestBodyViewModel, CodeEditorViewModel resultViewModel) { Ensure.ArgumentNotNull(infrastructure, "infrastructure"); ResultEditor = resultViewModel; RequestBodyEditor = requestBodyViewModel; _infrastructure = infrastructure; base.DisplayName = "REST"; _eventAggregator = infrastructure.EventAggregator; Methods = new List<ComboBoxItemViewModel> { ComboBoxItemViewModel.FromString("GET"), ComboBoxItemViewModel.FromString("POST"), ComboBoxItemViewModel.FromString("PUT"), ComboBoxItemViewModel.FromString("DELETE"), ComboBoxItemViewModel.FromString("HEAD"), ComboBoxItemViewModel.FromString("OPTIONS"), ComboBoxItemViewModel.FromString("TRACE"), ComboBoxItemViewModel.FromString("PATCH"), }; Method = "GET"; }
public CodeEditorViewTemplate(int tabId, GCode file = null) { InitializeComponent(); _viewModel = new CodeEditorViewModel(tabId, file); DataContext = _viewModel; }
public CodeEditorViewModelTests() { codeEditor = new CodeEditorViewModel( Mock.Of <IFoldingStrategy>(), highlightingDefinition.Object, Enumerable.Empty <MenuViewModel>(), clipboard.Object); }
/// <summary> /// Initializes a new instance of the <see cref="CodeReferencesToolWindowViewModel"/> class. /// </summary> /// <param name="caption">The tool window caption.</param> /// <param name="owner">The editor that owns the tool window.</param> public CodeReferencesToolWindowViewModel(string caption, CodeEditorViewModel owner) : base(owner) { Caption = caption; References = new ObservableCollection <CodeReferenceViewModel>(); GotoReferenceCommand = new DelegateCommand <CodeReferenceViewModel>(GotoReference); }
public void Setup() { var mockClipboard = new Mock <IClipboardService>(); var mockTimer = new Mock <ITimerService>(); var mockBackgroundWorkerService = new Mock <IBackgroundWorkerService>(); codeEditor = new CodeEditorViewModel(mockClipboard.Object, mockTimer.Object, mockBackgroundWorkerService.Object); viewModel = new LineViewModel(codeEditor, 1); }
/// <summary> /// Initializes a new instance of the <see cref="GotoLineToolWindowViewModel"/> class. /// </summary> /// <param name="owner">The editor that owns the tool window.</param> public ReplaceToolWindowViewModel(CodeEditorViewModel owner) : base(owner) { Caption = "Replace"; ReplaceText = new TextFieldViewModel("Replace", 255); ReplaceCommand = new DelegateCommand(Replace); ReplaceAllCommand = new DelegateCommand(ReplaceAll); }
private static int GetColumn(CodeEditorViewModel viewModel, Point mousePosition) { var characterWidth = viewModel.Resources.CharacterWidth; int column = (int)((mousePosition.X - 2 - viewModel.LineNumberColumnWidth + 1) / characterWidth) + 1; if (column < 1) { column = 1; } return(column); }
/// <summary> /// Initializes a new instance of the <see cref="GotoLineToolWindowViewModel"/> class. /// </summary> /// <param name="owner">The editor that owns the tool window.</param> public FindToolWindowViewModel(CodeEditorViewModel owner) : base(owner) { Caption = "Find"; SearchText = new TextFieldViewModel("Find", 255); SearchText.AddPropertyChangedHandler(TextFieldViewModel.TextProperty, OnTextChanged); FindNextCommand = new DelegateCommand(FindNext); FindPreviousCommand = new DelegateCommand(FindPrevious); _matches = new List <MatchLocation>(); }
private IEnumerator Start() { TerrainManager.CreateTerrain(Vector3.zero); yield return(null); //CameraManager.AddCamera("Default Camera 1", new Vector3(-40, 115, -138), Quaternion.Euler(30, 10, 0)); //CameraManager.AddCamera("Default Camera 2", new Vector3(33, 70.5f, -49), Quaternion.Euler(50, -32, 0)); //CameraManager.AddCamera("Default Camera 3", new Vector3(36.5f, 180f, 138), Quaternion.Euler(63, 230, -5f)); CameraManager.Remove("GUI Camera"); NPCInit.Initialize(); UIManager.Create <HUDViewModel>().IsActive = true; UIManager.Create <NPCDialogueViewModel>().IsActive = false; UIManager.Create <BlacksmithViewModel>().IsActive = false; UIManager.Create <InGameMenuViewModel>().IsActive = false; UIManager.Create <RecipeViewModel>().IsActive = false; //TODO: Parametrize prefab name with a UI selector CodeEditorViewModel codeEditorViewModel = UIManager.Create <CodeEditorViewModel>(); StartCoroutine(codeEditorViewModel.ToggleEditorCoroutine()); GameObject robot = RobotManager.CreateRobot("robotSphere", new Vector3(-10, 20, 0), Quaternion.identity); RobotManager.ActiveRobot = robot; RobotManager.CreateRobot("robotSphere", new Vector3(0, 20, 0), Quaternion.identity); RobotManager.CreateRobot("robotSphere", new Vector3(10, 20, 0), Quaternion.identity); RobotManager.CreateRobot("robotSphere", new Vector3(-10, 20, -10), Quaternion.identity); RobotManager.CreateRobot("robotSphere", new Vector3(0, 20, -10), Quaternion.identity); RobotManager.CreateRobot("robotSphere", new Vector3(10, 20, -10), Quaternion.identity); RobotManager.CreateRobot("robotSphere", new Vector3(-10, 20, -20), Quaternion.identity); RobotManager.CreateRobot("robotSphere", new Vector3(0, 20, -20), Quaternion.identity); RobotManager.CreateRobot("robotSphere", new Vector3(10, 20, -20), Quaternion.identity); GameObject enemyManagerPrefab = Resources.Load <GameObject>("InfrastructurePrefabs/EnemyManager"); Instantiate(enemyManagerPrefab); InventoryManager.Inventory = new Inventory(); InventoryViewModel inventoryViewModel = UIManager.Create <InventoryViewModel>(); ItemDialogViewModel itemDialogViewModel = UIManager.Create <ItemDialogViewModel>(); inventoryViewModel.IsActive = false; codeEditorViewModel.IsActive = false; itemDialogViewModel.IsActive = false; CameraManager.SetCameraWall(); }
private void TreeView_OnMouseDoubleClick(object sender, MouseButtonEventArgs e) { if (e.Source is ItemsPresenter) { return; } var item = (ExplorerItem)((FrameworkElement)e.OriginalSource).DataContext; Script script; if ((script = item.Instance as Script) != null) { CodeEditorViewModel.TryOpenScript(script); } }
protected override object GetInstance(Type service, string key) { if (service == typeof(IWindowManager)) { service = typeof(WindowManager); } if (service == typeof(ICommandBar)) { return(Editor.Current.Shell.CommandBar); } if (service == typeof(IStatusBar)) { return(Editor.Current.Shell.StatusBar); } if (service == typeof(ICodeEditor)) { var existing = Editor.Current.Shell?.Items.OfType <CodeEditorViewModel>() .FirstOrDefault(w => w.LuaSourceContainer.InstanceId.Equals(key)); if (existing != null) { return(existing); } WeakReference <Instance> obj; Game.Instances.TryGetValue(key, out obj); var editor = new CodeEditorViewModel((LuaSourceContainer)obj); Editor.Current.Shell?.OpenDocument(editor); return(editor); } var item = Editor.Current.Shell?.Widgets.FirstOrDefault(service.IsInstanceOfType); if (item != null) { return(item); } return(base.GetInstance(service, key)); }
public void UpdateItems() { Items = null; var doc = Editor.Current.Shell.ActiveDocument; IEnumerable <Type> types; if ((_materialEditor = doc as MaterialEditorViewModel) != null) { types = new Type[0]; _mode = Mode.Expressions; DisplayName = "Material Expressions"; } else if ((_scriptEditor = doc as CodeEditorViewModel) != null) { // TODO: code snippets. types = new Type[0]; _mode = Mode.Snippets; DisplayName = "Code Snippets"; } else if ((_viewportEditor = doc as ViewportViewModel) != null) { types = Inst.TypeDictionary.Values.Where(t => !t.IsAbstract && t.IsPublic && t.GetCustomAttribute <UncreatableAttribute>() == null && !typeof(Service).IsAssignableFrom(t.Type)).Select(t => t.Type); _mode = Mode.Objects; DisplayName = "Advanced Objects"; } else { types = new Type[0]; } var entries = types.Select(t => new ObjectEntry(t)); var items = CollectionViewSource.GetDefaultView(entries); items.Filter = FilterFunc; items.SortDescriptions.Add(new SortDescription(nameof(ObjectEntry.Name), ListSortDirection.Ascending)); Items = items; }
public QueryViewModel(CodeEditorViewModel queryEditorModel, CodeEditorViewModel resultEditorModel, Infrastructure infrastructure) { Ensure.ArgumentNotNull(infrastructure, "infrastructure"); Ensure.ArgumentNotNull(resultEditorModel, "resultEditorModel"); base.DisplayName = "Query"; _queryEditor = queryEditorModel; _resultEditor = resultEditorModel; _infrastructure = infrastructure; _resultEditor.IsReadOnly = true; Methods = new BindableCollection<ComboBoxItemViewModel> { ComboBoxItemViewModel.FromString("GET"), ComboBoxItemViewModel.FromString("POST"), ComboBoxItemViewModel.FromString("PUT"), ComboBoxItemViewModel.FromString("DELETE"), ComboBoxItemViewModel.FromString("HEAD"), }; Method = "GET"; Url = _infrastructure.Config.DefaultQueryUrl; }
private void GridControl_OpenCodeEditorOnCell(object sender, DataCellEventArgs e) { try { var getEditingContent = new Func <DataCell, object>((c) => { if (c is IEditingContent content) { return(content.EditingContent); } throw new ArgumentException(nameof(c)); }); var dataCell = getEditingContent(e.Cell); var saveAction = new Action <string>((text) => { if (e.Cell is IEditingContent content) { content.EditingContent = text; } }); var subTitle = this.Domain.Source?.ToString(); var dialog = new CodeEditorViewModel(this.configs, saveAction, subTitle) { Text = (dataCell ?? "").ToString() }; if (dialog.ShowDialog() == true) { saveAction?.Invoke(dialog.Text); } ; } catch (Exception ex) { AppMessageBox.ShowError(ex); } }
private IEnumerator CommonInitRoutine() { UIManager.Get <BackgroundViewModel>().IsActive = false; StartCoroutine(PrefabPool.Instance.LoadPrefabs(prefabList)); TerrainManager.CreateTerrain(Vector3.zero); CameraManager.Remove("GUI Camera"); UIManager.Create <HUDViewModel>().IsActive = true; UIManager.Create <NPCDialogueViewModel>().IsActive = false; UIManager.Create <BlacksmithViewModel>().IsActive = false; InGameMenuViewModel inGameMenuViewModel = UIManager.Create <InGameMenuViewModel>(); inGameMenuViewModel.IsActive = false; inGameMenuViewModel.ExitGameButton.onClick.AddListener(OnExit); NPCInit.Initialize(); CodeEditorViewModel codeEditorViewModel = UIManager.Create <CodeEditorViewModel>(); StartCoroutine(codeEditorViewModel.ToggleEditorCoroutine()); codeEditorViewModel.IsActive = false; while (!PrefabPool.Instance.Initialized) { yield return(null); } yield return(null); }
/// <summary> /// Initializes a new instance of the <see cref="ToolWindowViewModel"/> class. /// </summary> /// <param name="owner">The editor that owns the tool window.</param> protected ToolWindowViewModel(CodeEditorViewModel owner) { Owner = owner; CloseCommand = new DelegateCommand(Close); }
/// <summary> /// Initializes a new instance of the <see cref="LineViewModel"/> class. /// </summary> /// <param name="owner">The editor the line is to be displayed in.</param> /// <param name="line">The line number.</param> public LineViewModel(CodeEditorViewModel owner, int line) { _owner = owner; SetValueCore(LineProperty, line); }
public void OpenScript(LuaSourceContainer script, int lineNumber = 0) { ScriptService.AssertIdentity(ScriptIdentity.Plugin); CodeEditorViewModel.TryOpenScript(script, lineNumber); }
/* * protected override void OnDragEnter(DragEventArgs e) * { * e.Effects = ValidateDrag(e.OriginalSource, e) ? DragDropEffects.Copy : DragDropEffects.None; * e.Handled = true; * } * * protected override void OnDragOver(DragEventArgs e) * { * e.Effects = ValidateDrag(e.OriginalSource, e) ? DragDropEffects.Copy : DragDropEffects.None; * e.Handled = true; * } * * protected override void OnDrop(DragEventArgs e) * { * if (ValidateDrag(e.OriginalSource, e)) * OnDropAction(e.OriginalSource, e); * * e.Handled = true; * } * * private void OnPreviewMouseDown(object sender, MouseButtonEventArgs e) * { * UpdateSelection(e, false); * } * * private void OnPreviewMouseUp(object sender, MouseButtonEventArgs e) * { * _didDrag = false; * * if (_didSelect) * { * _didSelect = false; * return; * } * * if (e.OriginalSource != null) * UpdateSelection(e, true); * } * * private void OnPreviewMouseMove(object sender, MouseEventArgs e) * { * var mousePosition = e.GetPosition(null); * var diff = _mouseDownPosition - mousePosition; * * if (!_isDragging && e.LeftButton == MouseButtonState.Pressed && * (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance || * Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)) * { * var treeViewItem = VisualTreeUtility.FindParent<TreeViewItem>((DependencyObject)Mouse.DirectlyOver); * * if (treeViewItem == null) * return; * * if (_adornerEnabled) * { * var adornerBitmap = new RenderTargetBitmap((int)TreeView.ActualWidth, (int)TreeView.ActualHeight, 96, * 96, * PixelFormats.Pbgra32); * * var drawingVisual = new DrawingVisual(); * * using (var dc = drawingVisual.RenderOpen()) * { * VisualTreeUtility.Where(TreeView, visual => * { * var tvi = visual as TreeViewItem; * * if (tvi == null) return false; * if (!((CustomTreeItem)tvi.DataContext).IsSelected) return false; * * // get the border so children don't get drawn * var bd = (Border)VisualTreeUtility.First(tvi, x => (x as Border)?.Name == "Bd"); * var relativePos = bd.TranslatePoint(new Point(0, 0), TreeView); * * var rt = new RenderTargetBitmap((int)bd.ActualWidth * 2, (int)bd.ActualHeight, 96, 96, * PixelFormats.Pbgra32); * rt.Render(bd); * * dc.DrawImage(rt, new Rect(relativePos, new Size(bd.ActualWidth * 2, bd.ActualHeight))); * * return false; * }); * } * * adornerBitmap.Render(drawingVisual); * * _dragAdorner.Source = (DependencyObject)e.OriginalSource; * _dragAdorner.Image = adornerBitmap; * _dragAdorner.IsDragging = true; * _dragAdorner.Offset = e.GetPosition(TreeView); * * _adornerTimer.Start(); * } * * var dragData = GetDragDataFunc(); * DragDrop.DoDragDrop(treeViewItem, dragData, DragDropEffects.Copy | DragDropEffects.None); * * Debug.WriteLine("didDrag set to true"); * _didDrag = true; * } * } */ /// <summary> /// Updates the selection. /// </summary> /// <param name="e">Mouse button event argument.</param> /// <param name="allowSelectionClick"> /// If the clicked item is already selected, this argument determines if other items /// should be deselected. /// </param> private bool UpdateSelection(MouseButtonEventArgs e, bool allowSelectionClick) { var treeItemVisual = VisualTreeUtility.FindParent <TreeViewItem>((DependencyObject)e.OriginalSource); var treeItemViewModel = (CustomTreeItem)treeItemVisual?.DataContext; var clickPoint = e.GetPosition(TreeView); var controlDown = Keyboard.IsKeyDown(System.Windows.Input.Key.LeftCtrl); var shiftDown = Keyboard.IsKeyDown(System.Windows.Input.Key.LeftShift); /* * if (_didDrag) * { * Debug.WriteLine("DRAG CANCEL: _didDrag == true"); * _didDrag = false; * return; * }*/ if (!(treeItemVisual == null && shiftDown) && (treeItemVisual == null || shiftDown)) { Game.Selection.ClearSelection(); } if (treeItemVisual == null) { Debug.WriteLine("DRAG CANCEL: treeeItemVisual == null"); return(false); } if (e.ClickCount == 2 && e.ButtonState == MouseButtonState.Pressed) { var codeContainer = treeItemViewModel.Instance as LuaSourceContainer; if (codeContainer != null) { var doc = new CodeEditorViewModel(codeContainer); Editor.Current.Shell.OpenDocument(doc); codeContainer.Destroyed.Event += () => doc.TryClose(); } } if (treeItemViewModel.IsSelected && !allowSelectionClick) { Debug.WriteLine("DRAG CANCEL: (treeItemViewModel.IsSelected && !allowSelectionClick) == true"); return(false); } if (!controlDown && !shiftDown) { Game.Selection.ClearSelection(); } if (shiftDown && _lastSelected != null) { var needsReversed = clickPoint.Y < _lastPoint.Y; VisualTreeUtility.ForEach(TreeView, visual => { var tvi = visual as TreeViewItem; if (tvi == null) { return; } var relPoint = tvi.TranslatePoint(new Point(0, 0), TreeView); var check = needsReversed ? (relPoint.Y > clickPoint.Y && relPoint.Y < _lastPoint.Y) : (relPoint.Y <clickPoint.Y && relPoint.Y> _lastPoint.Y); if (check) { Game.Selection.Select(((CustomTreeItem)tvi.DataContext).Instance); } }); } if (shiftDown && _lastSelected != null) { Game.Selection.Select(_lastSelected.Instance); _didSelect = true; } if (controlDown) { if (treeItemViewModel.Instance.IsSelected) { Game.Selection.Deselect(treeItemViewModel.Instance); } else { Game.Selection.Select(treeItemViewModel.Instance); _didSelect = true; } } else { Game.Selection.Select(treeItemViewModel.Instance); _didSelect = true; } if (!shiftDown) { _lastSelected = treeItemViewModel; _lastPoint = clickPoint; } return(true); }
public ErrorsToolWindowViewModel(CodeEditorViewModel owner) : base("Error List", owner) { }
public InsertBreakpointCommand(CodeEditorViewModel codeEditor) { _codeEditor = codeEditor; }
public CodeEditor() { InitializeComponent(); DataContext = _viewModel = new CodeEditorViewModel(); }