public void OpenTabWithText(string tabName, string Text)
        {
            CodeFileDocumentControl edit = FindTab(tabName + ".pas");

            if (edit != null)
            {
                CurrentCodeFileDocument = edit;
                return;
            }
            edit = AddNewTab(MainDockPanel);
            edit.FromMetadata = true;
            OpenDocuments.Add(Tools.FileNameToLower(tabName + ".pas"), edit);
            CloseButtonsEnabled = OpenDocuments.Count > 1;
            edit.FileName       = tabName + ".pas";
            edit.Text           = tabName;
            edit.SetHighlightingStrategyForFile("prog.pas");
            edit.TextEditor.Document.Insert(0, Text);
            if (!WorkbenchServiceFactory.DebuggerManager.IsRunning)
            {
                AddEditorHandlers(edit);
            }
            WorkbenchServiceFactory.CodeCompletionParserController.RegisterFileForParsing(tabName + ".pas");
            //edit.FileName = FileName;
            //SetTabPageText(edit);
        }
        private CodeFileDocumentControl AddNewProgramToTab(DockPanel tabControl, string FileName)
        {
            CodeFileDocumentControl edit = AddNewTab(tabControl);

            edit.FileName = FileName;
            SetTabPageText(edit);
            edit.SetHighlightingStrategyForFile(FileName);
            OpenDocuments.Add(Tools.FileNameToLower(FileName), edit);
            //this.codeCompletionParserController.SetAsChanged(FileName);
            //ivan
            AddBreakPointHandler(edit, FileName);
            var RunService = WorkbenchServiceFactory.RunService;

            if (!RunService.HasRunArgument(FileName.ToLower()))
            {
                RunService.AddRunArgument(FileName.ToLower(), "");
            }
            if (!WorkbenchServiceFactory.DebuggerManager.IsRunning)
            {
                AddEditorHandlers(edit);
            }
            CodeCompletionKeyHandler.Attach(edit.TextEditor);
            edit.TextEditor.ActiveTextAreaControl.TextArea.KeyEventHandler += TextArea_KeyEventHandler;

            //HostCallbackImplementation.Register(this);

            //\ivan
            return(edit);
        }
Exemple #3
0
        public void OpenDocument(Document document)
        {
            var ext = Path.GetExtension(document.FilePath);

            if (OpenDocuments.FirstOrDefault(x => x.FilePath.Equals(document.FilePath, StringComparison.OrdinalIgnoreCase)) is KDocument doc)
            {
                doc.IsSelected = false;
                doc.IsSelected = true;
                return;
            }

            if (ext.Equals(".cs", StringComparison.OrdinalIgnoreCase))
            {
                OpenDocuments.Add(new CSDocument(document)
                {
                    IsSelected = true,
                    IsSaved    = true,
                    Name       = document.Name
                });
            }
            else if (ext.Equals(".xaml", StringComparison.OrdinalIgnoreCase))
            {
                OpenDocuments.Add(new XamlDocument(document)
                {
                    IsSelected = true,
                    IsSaved    = true,
                    Name       = document.Name
                });
            }
        }
        public void ProjectDoubleClick()
        {
            if (SelectedSolutionItem == null || !SelectedSolutionItem.HasPreview)
            {
                return;
            }

            var alreadyOpenDocument = OpenDocuments.FirstOrDefault(d => d.AssociatedModel == SelectedSolutionItem);

            if (alreadyOpenDocument?.IsTemporary == true)
            {
                OpenDocuments.Remove(alreadyOpenDocument);
                alreadyOpenDocument = null;
            }

            if (alreadyOpenDocument != null)
            {
                ActiveDocument = alreadyOpenDocument;
            }
            else
            {
                var document = OpenDocument(SelectedSolutionItem);

                OpenDocuments.Add(document);
                ActiveDocument = document;
            }
        }
Exemple #5
0
        public void CreateNewDocument()
        {
            var openDocument = new OpenDocumentViewModel(this, null);

            OpenDocuments.Add(openDocument);
            CurrentOpenDocument = openDocument;
        }
Exemple #6
0
        /// <summary>
        /// Opens a document in the viewer.
        ///
        /// If the document is already opened it is just activated.
        /// </summary>
        /// <param name="filePath">Path of the document, which should be opened in the viewer.</param>
        /// <returns>Opened document view model.</returns>
        public DocumentViewModel OpenDocument(string filePath)
        {
            if (Engine.FileStorageProviders.Exists(filePath))
            {
                try
                {
                    System.Windows.Input.Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;

                    foreach (var openDocument in OpenDocuments)
                    {
                        if (openDocument.FilePath.Equals(filePath, StringComparison.OrdinalIgnoreCase))
                        {
                            return(openDocument);
                        }
                    }
                    var newDocument = new DocumentViewModel(filePath, fileActionCloseAllButThis: mCloseAllButThisFileAction, fileActionCloseAll: mCloseAllFilesAction);
                    newDocument.FileViewerTemplate = mFileViewerTemplate;
                    OpenDocuments.Add(newDocument);
                    CurrentDocument = newDocument;
                    return(newDocument);
                }
                finally
                {
                    System.Windows.Input.Mouse.OverrideCursor = null;
                }
            }
            else
            {
                System.Windows.MessageBox.Show(string.Format("Cannot open file \"{0}\" because it does not exist!", filePath), "Open file...", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
            }
            return(null);
        }
Exemple #7
0
        public Document Add(Document doc)
        {
            if (doc == null)
            {
                return(null);
            }

            OpenDocuments.Add(doc);
            return(doc);
        }
        public void SearchResultDoubleClick()
        {
            var document = OpenFile(null, SelectedSearchResult.FilePath);

            document.SelectionStart  = SelectedSearchResult.SelectionStart;
            document.SelectionLength = SelectedSearchResult.SelectionLenght;

            OpenDocuments.Add(document);
            ActiveDocument = document;
        }
Exemple #9
0
        public void OpenDocument(DocumentViewModel document)
        {
            var openDocument = OpenDocuments.FirstOrDefault(x => x.Document == document);

            if (openDocument == null)
            {
                openDocument = new OpenDocumentViewModel(this, document);
                OpenDocuments.Add(openDocument);
            }
            CurrentOpenDocument = openDocument;
        }
Exemple #10
0
        public void NewDocument()
        {
            OpenDocuments.Add(DocumentViewModel.LoadFromPayload(this, @"{
  ""type"": ""AdaptiveCard"",
  ""version"": ""0.5"",
  ""body"": [
    {
      ""type"": ""TextBlock"",
      ""text"": ""Untitled card""
    }
  ]
}"));
            CurrentDocument = OpenDocuments.Last();
        }
        public void OpenDocument(DocumentViewModel document)
        {
            if (document.IsFolder)
            {
                return;
            }

            var openDocument = OpenDocuments.FirstOrDefault(x => x.Document == document);

            if (openDocument == null)
            {
                openDocument = GetOpenDocumentViewModel(document);
                OpenDocuments.Add(openDocument);
            }
            CurrentOpenDocument = openDocument;
        }
Exemple #12
0
        public Document CreateAndActivateDocument(string filename, Gdk.Size size)
        {
            Document doc = new Document(size);

            if (string.IsNullOrEmpty(filename))
            {
                doc.Filename = string.Format(Catalog.GetString("Unsaved Image {0}"), new_file_name++);
            }
            else
            {
                doc.PathAndFileName = filename;
            }

            OpenDocuments.Add(doc);
            OnDocumentCreated(new DocumentEventArgs(doc));

            SetActiveDocument(doc);

            return(doc);
        }
Exemple #13
0
        public async void OpenDocument()
        {
            try
            {
                FileOpenPicker openPicker = new FileOpenPicker();
                openPicker.ViewMode = PickerViewMode.List;
                openPicker.FileTypeFilter.Add(".json");

                StorageFile file = await openPicker.PickSingleFileAsync();

                if (file != null)
                {
                    string token = StorageApplicationPermissions.FutureAccessList.Add(file);
                    OpenDocuments.Add(await DocumentViewModel.LoadFromFileAsync(this, file, token));
                    CurrentDocument = OpenDocuments.LastOrDefault();
                    SaveFileTokensAsync();
                }
                else
                {
                }
            }
            catch { }
        }
        public void OnSelectedSolutionItemChanged()
        {
            if (!(SelectedSolutionItem?.HasPreview ?? false))
            {
                return;
            }

            var alreadyOpenDocument = OpenDocuments.FirstOrDefault(d => d.AssociatedModel == SelectedSolutionItem);

            if (alreadyOpenDocument != null)
            {
                ActiveDocument = alreadyOpenDocument;
                return;
            }

            var currentTemporary = OpenDocuments.FirstOrDefault(d => d.IsTemporary);

            var document = OpenDocument(SelectedSolutionItem);

            if (currentTemporary == null)
            {
                currentTemporary = new DocumentViewModel
                {
                    IsTemporary = true
                };

                OpenDocuments.Add(currentTemporary);
            }

            currentTemporary.AssociatedModel = document.AssociatedModel;
            currentTemporary.Content         = document.Content;
            currentTemporary.Syntax          = document.Syntax;
            currentTemporary.Title           = $"*{document.Title}";

            ActiveDocument = currentTemporary;
        }
Exemple #15
0
 public override System.Threading.Tasks.Task <ParsedDocument> Parse(ParseOptions parseOptions, System.Threading.CancellationToken cancellationToken)
 {
     Doc.Editor.FileName = parseOptions.FileName;
     OpenDocuments.Add(new OpenRazorDocument(Doc.Editor));
     return(base.Parse(parseOptions, cancellationToken));
 }
Exemple #16
0
 private void AddDocument(BaseDocumentViewModel doc)
 {
     OpenDocuments.Add(doc);
     doc.OnRequestClose          += Doc_OnRequestClose;
     doc.OnRequestSaveFileTokens += Doc_OnRequestSaveFileTokens;
 }
 public override ParsedDocument Parse(bool storeAst, string fileName, System.IO.TextReader content, Project project = null)
 {
     Doc.Editor.Document.FileName = fileName;
     OpenDocuments.Add(Doc.Editor.Document);
     return(base.Parse(storeAst, fileName, content, project));
 }