Пример #1
0
        /// <summary>
        /// Opens a new unsaved file.
        /// </summary>
        /// <param name="defaultName">The (unsaved) name of the to open</param>
        /// <param name="content">Content of the file to create</param>
        public static IViewContent NewFile(string defaultName, byte[] content)
        {
            if (defaultName == null)
            {
                throw new ArgumentNullException("defaultName");
            }
            if (content == null)
            {
                throw new ArgumentNullException("content");
            }

            IDisplayBinding binding = DisplayBindingService.GetBindingPerFileName(defaultName);

            if (binding == null)
            {
                binding = new ErrorFallbackBinding("Can't create display binding for file " + defaultName);
            }
            OpenedFile file = CreateUntitledOpenedFile(defaultName, content);

            IViewContent newContent = binding.CreateContentForFile(file);

            if (newContent == null)
            {
                LoggingService.Warn("Created view content was null - DefaultName:" + defaultName);
                file.CloseIfAllViewsClosed();
                return(null);
            }

            DisplayBindingService.AttachSubWindows(newContent, false);

            WorkbenchSingleton.Workbench.ShowView(newContent);
            return(newContent);
        }
Пример #2
0
            public void Invoke(string fileName)
            {
                OpenedFile   file       = FileService.GetOrCreateOpenedFile(FileName.Create(fileName));
                IViewContent newContent = binding.CreateContentForFile(file);

                if (newContent != null)
                {
                    DisplayBindingService.AttachSubWindows(newContent, false);
                    WorkbenchSingleton.Workbench.ShowView(newContent, switchToOpenedView);
                }
                file.CloseIfAllViewsClosed();
            }