/// <inheritdoc/>
        public IViewContent OpenFile(FileName fileName, bool switchToOpenedView)
        {
            if (fileName == null)
            {
                throw new ArgumentNullException("fileName");
            }
            LoggingService.Info("Open file " + fileName);

            IViewContent viewContent = GetOpenFile(fileName);

            if (viewContent != null)
            {
                if (switchToOpenedView)
                {
                    viewContent.WorkbenchWindow.SelectWindow();
                }
                return(viewContent);
            }

            IDisplayBinding binding = SD.DisplayBindingService.GetBindingPerFileName(fileName);

            if (binding == null)
            {
                binding = new ErrorFallbackBinding("Could not find any display binding for " + Path.GetFileName(fileName));
            }
            if (FileUtility.ObservedLoad(new NamedFileOperationDelegate(new LoadFileWrapper(binding, switchToOpenedView).Invoke), fileName) == FileOperationResult.OK)
            {
                RecentOpen.AddRecentFile(fileName);
            }
            return(GetOpenFile(fileName));
        }
Beispiel #2
0
        /// <inheritdoc/>
        public IFileViewContent OpenFile(FileName fileName, bool switchToOpenedView)
        {
            if (fileName == null)
            {
                throw new ArgumentNullException("fileName");
            }
            Current.Log.Info("Open file " + fileName);

            IFileViewContent viewContent = GetOpenFile(fileName);

            if (viewContent != null)
            {
                if (switchToOpenedView)
                {
                    viewContent.IsSelected = true;
                }
                return(viewContent);
            }

            IDisplayBinding binding = Altaxo.Current.GetRequiredService <IDisplayBindingService>().GetBindingPerFileName(fileName);

            if (binding == null)
            {
                binding = new ErrorFallbackBinding("Could not find any display binding for " + Path.GetFileName(fileName));
            }
            if (FileUtility.ObservedLoad(new NamedFileOperationDelegate(new LoadFileWrapper(binding, switchToOpenedView).Invoke), fileName) == FileOperationResult.OK)
            {
                RecentOpen.AddRecentFile(fileName);
            }
            return(GetOpenFile(fileName));
        }
 /// <inheritdoc/>
 public IViewContent OpenFileWith(FileName fileName, IDisplayBinding displayBinding, bool switchToOpenedView)
 {
     if (displayBinding == null)
     {
         throw new ArgumentNullException("displayBinding");
     }
     if (FileUtility.ObservedLoad(new NamedFileOperationDelegate(new LoadFileWrapper(displayBinding, switchToOpenedView).Invoke), fileName) == FileOperationResult.OK)
     {
         RecentOpen.AddRecentFile(fileName);
     }
     return(GetOpenFile(fileName));
 }