Beispiel #1
0
        public async void CreateWindows()
        {
            const int margin     = 5;
            const int leftOffset = 150;
            const int topOffset  = 150;

            var isInEditMode = _dataProvider.CommonSettings.AppMode == AppMode.Editor;

            var mainViewModel = new MainViewModel(_dataProvider);

            _mainWindow = new MainWindow(mainViewModel);

            var objectBrowserViewModel = new ObjectBrowserViewModel(_dataProvider);

            _objectBrowser = new ObjectBrowser(objectBrowserViewModel)
            {
                Height = _mainWindow.Height
            };

            var toolsPanelViewModel = new ToolsPanelViewModel(_dataProvider);

            _toolsPanel = new ToolsPanel(toolsPanelViewModel);

            var variablesViewerViewModel = new VariablesViewerViewModel(_dataProvider);

            _variablesViewer = new VariablesViewer(variablesViewerViewModel);

            if (_dataProvider.CommonSettings.ObjectBrowserSettings.IsSet)
            {
                _objectBrowser.Left = _dataProvider.CommonSettings.ObjectBrowserSettings.Left;
                _objectBrowser.Top  = _dataProvider.CommonSettings.ObjectBrowserSettings.Top;
            }
            else
            {
                _objectBrowser.Left = leftOffset;
                _objectBrowser.Top  = topOffset + _toolsPanel.Height + margin;
            }

            _toolsPanel.Width = _objectBrowser.Width + _mainWindow.Width + margin;
            if (_dataProvider.CommonSettings.ToolsPanelSettings.IsSet)
            {
                _toolsPanel.Left = _dataProvider.CommonSettings.ToolsPanelSettings.Left;
                _toolsPanel.Top  = _dataProvider.CommonSettings.ToolsPanelSettings.Top;
            }
            else
            {
                _toolsPanel.Left = leftOffset;
                _toolsPanel.Top  = topOffset;
            }

            _variablesViewer.Height = _toolsPanel.Height + _mainWindow.Height + margin;
            if (_dataProvider.CommonSettings.VariablesViewerSettings.IsSet)
            {
                _variablesViewer.Left = _dataProvider.CommonSettings.VariablesViewerSettings.Left;
                _variablesViewer.Top  = _dataProvider.CommonSettings.VariablesViewerSettings.Top;
            }
            else
            {
                _variablesViewer.Left = _mainWindow.Left + _mainWindow.Width + margin;
                _variablesViewer.Top  = _toolsPanel.Top;
            }

            if (_dataProvider.CommonSettings.MainWindowSettings.IsSet)
            {
                _mainWindow.Left = _dataProvider.CommonSettings.MainWindowSettings.Left;
                _mainWindow.Top  = _dataProvider.CommonSettings.MainWindowSettings.Top;
            }
            else
            {
                _mainWindow.Left = leftOffset + _objectBrowser.Width + margin;
                _mainWindow.Top  = topOffset + _toolsPanel.Height + margin;
            }

            Application.Current.MainWindow = _mainWindow;
            _mainWindow.Activated         += GotFocus;
            _mainWindow.Closing           += OnClose;
            _mainWindow.StateChanged      += OnStateChanged;


            _toolsPanel.Closing += (sender, e) =>
            {
                e.Cancel = true;
                HideToolsPanel();
            };
            _objectBrowser.Closing += (sender, e) =>
            {
                e.Cancel = true;
                HideObjectBrowser();
            };
            _variablesViewer.Closing += (sender, e) =>
            {
                e.Cancel = true;
                HideVariablesViewer();
            };

            _toolsPanel.Hide();
            _variablesViewer.Hide();
            _objectBrowser.Hide();
            CenterMainWindow();

            _mainWindow.Show();
            SetVisibility();

            if (!_dataProvider.CommonSettings.IsSet)
            {
                await _dataProvider.DialogsManager.OpenConfiguration(_dataProvider);
            }
            else if (!isInEditMode)
            {
                await _dataProvider.DialogsManager.ShowMenu();
            }
        }