Esempio n. 1
0
        public void AddDocument(IDocumentTabViewModel document)
        {
            DocumentTabs.Documents.Add(document);
            DocumentTabs.SelectedDocument = document;

            DocumentTabs.InvalidateSeperatorVisibility();
        }
Esempio n. 2
0
        public void CloseDocumentsForProject(IProject project)
        {
            var documentsToClose = DocumentTabs.Documents.ToList();

            foreach (var document in documentsToClose)
            {
                if (document is EditorViewModel evm && evm.SourceFile.Project == project)
                {
                    DocumentTabs.CloseDocument(evm);
                }
            }
        }
Esempio n. 3
0
        public void RemoveDocument(IDocumentTabViewModel document)
        {
            if (document == null)
            {
                return;
            }

            if (document is EditorViewModel doc)
            {
                doc.Editor?.Save();
            }

            DocumentTabs.CloseDocument(document);
        }
Esempio n. 4
0
        public void CloseSolution()
        {
            var documentsToClose = DocumentTabs.Documents.ToList();

            foreach (var document in documentsToClose)
            {
                if (document is EditorViewModel evm)
                {
                    DocumentTabs.CloseDocument(evm);
                }
            }

            CurrentSolution = null;
        }
        public async Task CloseSolutionAsync()
        {
            var documentsToClose = DocumentTabs.Documents.ToList();

            foreach (var document in documentsToClose)
            {
                if (document is EditorViewModel evm)
                {
                    DocumentTabs.CloseDocument(evm);
                }
            }

            await CurrentSolution.UnloadProjectsAsync();

            await CurrentSolution.UnloadSolutionAsync();

            CurrentSolution = null;
        }
Esempio n. 6
0
        public void RemoveDocument(IDocumentTabViewModel document)
        {
            if (document == null)
            {
                return;
            }

            IDocumentTabViewModel newSelectedTab = DocumentTabs.SelectedDocument;

            if (DocumentTabs.SelectedDocument == document)
            {
                var index   = DocumentTabs.Documents.IndexOf(document);
                var current = index;

                bool foundTab = false;

                while (!foundTab)
                {
                    index++;

                    if (index < DocumentTabs.Documents.Count)
                    {
                        if (DocumentTabs.Documents[index].IsVisible)
                        {
                            foundTab       = true;
                            newSelectedTab = DocumentTabs.Documents[index];
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                index = current;

                while (!foundTab)
                {
                    index--;

                    if (index >= 0)
                    {
                        if (DocumentTabs.Documents[index].IsVisible)
                        {
                            foundTab       = true;
                            newSelectedTab = DocumentTabs.Documents[index];
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }

            DocumentTabs.SelectedDocument = newSelectedTab;

            document.IsVisible = false;

            if (document is EditorViewModel doc)
            {
                doc.Save();
            }

            if (DocumentTabs.TemporaryDocument == document)
            {
                DocumentTabs.TemporaryDocument = null;
            }

            if (DocumentTabs.Documents.OfType <EditorViewModel>().Where(d => !d.IsVisible).Count() == 5)
            {
                var toRemove = DocumentTabs.Documents.OfType <EditorViewModel>().Where(d => !d.IsVisible).First();

                DocumentTabs.Documents.Remove(toRemove);
                toRemove.OnClose();

                Dispatcher.UIThread.InvokeAsync(async() =>
                {
                    await Task.Delay(25);
                    GC.Collect();
                });
            }

            DocumentTabs.InvalidateSeperatorVisibility();
        }
Esempio n. 7
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel()
        {
            if (Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Mobile")
            {
                isMobile = true;
            }
            openPicker = new FileOpenPicker();
            openPicker.FileTypeFilter.Add(".ass");

            savePicker = new FileSavePicker()
            {
                DefaultFileExtension = ".ass"
            };
            savePicker.FileTypeChoices.Add(LocalizedStrings.Resources.AssFileName, new[] { ".ass" });

            saveDialog = new MessageDialog(LocalizedStrings.Resources.SaveDialogContent, LocalizedStrings.Resources.SaveDialogTitle);
            saveDialog.Commands.Add(new UICommand(LocalizedStrings.Resources.SaveDialogYes, null, dialogResult.Yes));
            saveDialog.Commands.Add(new UICommand(LocalizedStrings.Resources.SaveDialogNo, null, dialogResult.No));
            saveDialog.DefaultCommandIndex = 0;
            if (!isMobile)
            {
                saveDialog.Commands.Add(new UICommand(LocalizedStrings.Resources.SaveDialogCancel, null, dialogResult.Cancel));
                saveDialog.CancelCommandIndex = 2;
            }

            newFile = new RelayCommand(async() =>
            {
                if (!await CleanUpBeforeNewOrOpen())
                {
                    return;
                }
                Document.NewSubtitle();
            });
            openFile = new RelayCommand(async() =>
            {
                if (!await CleanUpBeforeNewOrOpen())
                {
                    return;
                }
                var file = await openPicker.PickSingleFileAsync();
                if (file == null)
                {
                    return;
                }
                await Document.OpenFileAsync(file);
            });
            saveFile = new RelayCommand(async() => await Save(), () => Document.IsModified);

            SplitViewButtons.Add(new SplitViewButtonData()
            {
                Icon    = "\xE160",
                Content = LocalizedStrings.Resources.SplitViewButtonNew,
                Command = newFile
            });
            SplitViewButtons.Add(new SplitViewButtonData()
            {
                Icon    = "\xE8E5",
                Content = LocalizedStrings.Resources.SplitViewButtonOpen,
                Command = openFile
            });
            SplitViewButtons.Add(new SplitViewButtonData()
            {
                Icon    = "\xE105",
                Content = LocalizedStrings.Resources.SplitViewButtonSave,
                Command = saveFile
            });

            DocumentTabs.Add(new SplitViewTabData()
            {
                Icon      = "\xE1CB",
                Content   = LocalizedStrings.Resources.SplitViewTabScriptInfo,
                PageType  = typeof(View.ScriptInfoPage),
                IsChecked = true
            });
            DocumentTabs.Add(new SplitViewTabData()
            {
                Icon     = "\xE2B1",
                Content  = LocalizedStrings.Resources.SplitViewTabStyle,
                PageType = typeof(View.StylePage)
            });
            DocumentTabs.Add(new SplitViewTabData()
            {
                Icon     = "\xE292",
                Content  = LocalizedStrings.Resources.SplitViewTabEvent,
                PageType = typeof(View.SubEventPage)
            });
            Document.PropertyChanged += documentPropertyChanged;
        }
Esempio n. 8
0
 public void AddDocument(IDocumentTabViewModel document, bool temporary = false)
 {
     DocumentTabs.OpenDocument(document, temporary);
 }