public Window OpenWindowWithFile(FileBase file)
        {
            var windowMetadata = FileAssociationConfig.GetMetadataForFile(file);

            Window window;

            switch (windowMetadata.NewWindowMode)
            {
            case WindowMetadata.NewWindowBehavior.FocusOldWindow:
                window = findWindowWithMetadata(windowMetadata);
                break;

            case WindowMetadata.NewWindowBehavior.OpenOneWindowPerFile:
                window = findWindowWithFile(file);
                break;

            case WindowMetadata.NewWindowBehavior.AlwaysOpenNewWindow:
                window = null;
                break;

            default:
                throw new InvalidOperationException($"file association config {FileAssociationConfig.name} has unsupported window mode {windowMetadata.NewWindowMode} configured for file type {file.GetType().Name}");
            }

            if (window == null)
            {
                window = Instantiate(windowMetadata.WindowPrefab, WindowParent);
                window.SetFile(file);

                if (windowMetadata.AddButtonToTaskbar)
                {
                    var button = Instantiate(TaskBarButtonPrefab);

                    window.SetTaskBarButton(button);
                    button.SetWindow(window);

                    TaskBar.Instance.AddButton(button);
                }
            }

            window.Focus();
            return(window);
        }
Exemple #2
0
        public WindowMetadata GetMetadataForFile(FileBase file)
        {
            string fileTypeName = file.GetType().FullName;

            return(Config.FirstOrDefault(d => d.FullNameOfFileType == fileTypeName)?.Metadata);
        }