Inheritance: UserControl
示例#1
0
        private void MergeDatabaseView()
        {
            var newList = _databases.Select(
                db => new DatabaseReference()
            {
                Name    = db,
                Caption = Connection.PowerBIFileName.Length > 0 ? Connection.PowerBIFileName : db
            }).OrderBy(db => db.Name);

            // remove deleted databases
            for (int i = _databasesView.Count - 1; i >= 0; i--)
            {
                var found = newList.Where(db => db.Name == _databasesView[i].Name).Any();
                if (!found)
                {
                    _databasesView.RemoveAt(i);
                }
            }

            // add new databases
            foreach (DatabaseReference dbRef in newList)
            {
                var found = _databasesView.Where(db => db.Name == dbRef.Name).DefaultIfEmpty();
                if (found != null)
                {
                    _databasesView.Add(dbRef);
                }
            }

            NotifyOfPropertyChange(() => DatabasesView);
            if (SelectedDatabase == null)
            {
                SelectedDatabase = DatabasesView.FirstOrDefault();
            }
        }
示例#2
0
 private void ActiveDocumentPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "IsQueryRunning")
     {
         NotifyOfPropertyChange(() => CanSelectDatabase);
         NotifyOfPropertyChange(() => CanSelectModel);
     }
     if (e.PropertyName == "SelectedDatabase")
     {
         var selectedDB = DatabasesView.FirstOrDefault(db => db.Name == ActiveDocument.SelectedDatabase);
         if (selectedDB != null)
         {
             SelectedDatabase = selectedDB;
         }
         // TODO - should we log a warning here?
     }
 }
示例#3
0
        /// <inheritdoc/>
        public override IDock CreateDefaultLayout()
        {
            // Dashboard

            var dashboardView = new DashboardView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Dashboard"
            };

            // Page

            var pageView = new PageView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Page"
            };

            // Left / Top

            var projectView = new ProjectView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Project"
            };

            var optionsView = new OptionsView
            {
                Dock   = "",
                Width  = 200,
                Height = 200,
                Title  = "Options"
            };

            var imagesView = new ImagesView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Images"
            };

            // Left / Bottom

            var groupsView = new GroupsView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Groups"
            };

            var databasesView = new DatabasesView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Databases"
            };

            // Right / Top

            var stylesView = new StylesView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Styles"
            };

            var templatesView = new TemplatesView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Templates"
            };

            var containerView = new ContainerView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Container"
            };

            var zoomView = new ZoomView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Zoom"
            };

            // Right / Bottom

            var toolsView = new ToolsView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Tools"
            };

            var shapeView = new ShapeView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Shape"
            };

            var dataView = new DataView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Data"
            };

            var styleView = new StyleView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Style"
            };

            var templateView = new TemplateView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Template"
            };

            // Left

            var leftPane = new DockLayout
            {
                Dock        = "Left",
                Width       = 200,
                Height      = double.NaN,
                Title       = "EditorLeft",
                CurrentView = null,
                Views       = new ObservableCollection <IDock>
                {
                    new DockStrip
                    {
                        Dock        = "Top",
                        Width       = double.NaN,
                        Height      = 340,
                        Title       = "EditorLeftTop",
                        CurrentView = projectView,
                        Views       = new ObservableCollection <IDock>
                        {
                            projectView,
                            optionsView,
                            imagesView
                        }
                    },
                    new DockSplitter()
                    {
                        Dock = "Top", Title = "LeftTopSplitter"
                    },
                    new DockStrip
                    {
                        Dock        = "Bottom",
                        Width       = double.NaN,
                        Height      = double.NaN,
                        Title       = "EditorLeftBottom",
                        CurrentView = groupsView,
                        Views       = new ObservableCollection <IDock>
                        {
                            groupsView,
                            databasesView
                        }
                    }
                }
            };

            // Right

            var rightPane = new DockLayout
            {
                Dock        = "Right",
                Width       = 240,
                Height      = double.NaN,
                Title       = "EditorRight",
                CurrentView = null,
                Views       = new ObservableCollection <IDock>
                {
                    new DockStrip
                    {
                        Dock        = "Top",
                        Width       = double.NaN,
                        Height      = 340,
                        Title       = "EditorRightTop",
                        CurrentView = stylesView,
                        Views       = new ObservableCollection <IDock>
                        {
                            stylesView,
                            templatesView,
                            containerView,
                            zoomView
                        }
                    },
                    new DockSplitter()
                    {
                        Dock = "Top", Title = "RightTopSplitter"
                    },
                    new DockStrip
                    {
                        Dock        = "Bottom",
                        Width       = double.NaN,
                        Height      = double.NaN,
                        Title       = "EditorRightBottom",
                        CurrentView = toolsView,
                        Views       = new ObservableCollection <IDock>
                        {
                            toolsView,
                            shapeView,
                            dataView,
                            styleView,
                            templateView
                        }
                    }
                }
            };

            // Editor

            var editorLayout = new DockLayout
            {
                Dock        = "",
                Width       = double.NaN,
                Height      = double.NaN,
                Title       = "EditorLayout",
                CurrentView = null,
                Views       = new ObservableCollection <IDock>
                {
                    leftPane,
                    new DockSplitter()
                    {
                        Dock = "Left", Title = "LeftSplitter"
                    },
                    rightPane,
                    new DockSplitter()
                    {
                        Dock = "Right", Title = "RightSplitter"
                    },
                    pageView
                }
            };

            var editorView = new EditorView
            {
                Dock        = "",
                Width       = double.NaN,
                Height      = double.NaN,
                Title       = "Editor",
                CurrentView = editorLayout,
                Views       = new ObservableCollection <IDock>
                {
                    editorLayout
                }
            };

            // About

            var aboutView = new AboutView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "About"
            };

            // Browser

            var browserView = new BrowserView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Browser"
            };

            // Document

            var documentView = new DocumentView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Document"
            };

            // Main

            var layout = new DockRoot
            {
                Dock        = "",
                Width       = double.NaN,
                Height      = double.NaN,
                CurrentView = dashboardView,
                Views       = new ObservableCollection <IDock>
                {
                    dashboardView,
                    editorView,
                    aboutView,
                    browserView,
                    documentView
                }
            };

            return(layout);
        }
 internal void ChangeDatabase(string databaseName)
 {
     SelectedDatabase = DatabasesView.Where(db => db.Name == databaseName).FirstOrDefault();
 }