Example #1
0
        internal void SetMappingDetailsInfo(
            MappingDetailsWindow mappingWindow,
            EditingContext context,
            EdmPackage.SelectionContainer <MappingDetailsSelection> selectionContainer)
        {
            _mappingWindow      = mappingWindow;
            _context            = context;
            _selectionContainer = selectionContainer;

            _context.Disposing += OnContextDisposing;
            _context.Items.SetValue(this);
        }
        internal void SetMappingDetailsInfo(
            MappingDetailsWindow mappingWindow,
            EditingContext context,
            EdmPackage.SelectionContainer<MappingDetailsSelection> selectionContainer)
        {
            _mappingWindow = mappingWindow;
            _context = context;
            _selectionContainer = selectionContainer;

            _context.Disposing += OnContextDisposing;
            _context.Items.SetValue(this);
        }
        public MappingDetailsWindowContainer(MappingDetailsWindow toolWindow, Control mainControl)
        {
            Debug.Assert(toolWindow != null, "toolWindow is null.");
            Debug.Assert(mainControl != null, "mainControl is null.");

            _toolWindow = toolWindow;

            InitializeComponent();

            // ensure the colors for the watermark LinkLabel are correct by VS UX
            SetWatermarkThemedColors();

            // hide the watermark
            watermarkLabel.Visible      = false;
            watermarkLabel.LinkClicked += watermarkLabel_LinkClicked;

            // add main control hosted in the tool window
            _mainControl         = mainControl;
            mainControl.TabIndex = 0;
            mainControl.Bounds   = new Rectangle(1, 1, 50, 50);
            mainControl.Anchor   = AnchorStyles.Left | AnchorStyles.Top;
            mainControl.Dock     = DockStyle.Fill;
            contentsPanel.Controls.Add(mainControl);

            // adjust control sizes
            var colorHintStripWidth = 3;

#if VS12ORNEWER
            toolbar.ImageScalingSize = toolbar.ImageScalingSize.LogicalToDeviceUnits();
            foreach (var button in toolbar.Items.OfType <ToolStripButton>())
            {
                button.Size = button.Size.LogicalToDeviceUnits();
            }
            colorHintStripWidth = DpiHelper.LogicalToDeviceUnitsX(colorHintStripWidth);
#endif

            contentsPanel.Padding = new Padding(colorHintStripWidth, 0, 0, 0);

            // By default set mainControl as a top control
            contentsPanel.Controls.SetChildIndex(mainControl, 0);

            // protect against unhandled exceptions in message loop.
            WindowTarget = new SafeWindowTarget(_toolWindow, WindowTarget);
            SafeWindowTarget.ReplaceWindowTargetRecursive(_toolWindow, Controls, false);

            // set color table for toolbar to use system colors
            toolbar.Renderer = GetToolbarRenderer();
            SetToolbarThemedColors();

            UpdateToolbar();
        }
        public MappingDetailsWindowContainer(MappingDetailsWindow toolWindow, Control mainControl)
        {
            Debug.Assert(toolWindow != null, "toolWindow is null.");
            Debug.Assert(mainControl != null, "mainControl is null.");

            _toolWindow = toolWindow;

            InitializeComponent();

            // ensure the colors for the watermark LinkLabel are correct by VS UX
            SetWatermarkThemedColors();

            // hide the watermark
            watermarkLabel.Visible = false;
            watermarkLabel.LinkClicked += watermarkLabel_LinkClicked;

            // add main control hosted in the tool window
            _mainControl = mainControl;
            mainControl.TabIndex = 0;
            mainControl.Bounds = new Rectangle(1, 1, 50, 50);
            mainControl.Anchor = AnchorStyles.Left | AnchorStyles.Top;
            mainControl.Dock = DockStyle.Fill;
            contentsPanel.Controls.Add(mainControl);

            // adjust control sizes
            var colorHintStripWidth = 3;
            #if VS12ORNEWER
            toolbar.ImageScalingSize = toolbar.ImageScalingSize.LogicalToDeviceUnits();
            foreach (var button in toolbar.Items.OfType<ToolStripButton>())
            {
                button.Size = button.Size.LogicalToDeviceUnits();
            }
            colorHintStripWidth = DpiHelper.LogicalToDeviceUnitsX(colorHintStripWidth);
            #endif

            contentsPanel.Padding = new Padding(colorHintStripWidth, 0, 0, 0);

            // By default set mainControl as a top control
            contentsPanel.Controls.SetChildIndex(mainControl, 0);

            // protect against unhandled exceptions in message loop.
            WindowTarget = new SafeWindowTarget(_toolWindow, WindowTarget);
            SafeWindowTarget.ReplaceWindowTargetRecursive(_toolWindow, Controls, false);

            // set color table for toolbar to use system colors
            toolbar.Renderer = GetToolbarRenderer();
            SetToolbarThemedColors();

            UpdateToolbar();
        }
        protected override void Dispose(bool disposing)
        {
            try
            {
                // HACK HACK -- change when the hack is removed above
                EFModelErrorTaskNavigator.DslDesignerOnNavigate = null;
                // --

                // always dispose and null out items that use VS resources
                _viewExplorerCmd = null;
                _viewMappingCmd = null;

                if (_explorerWindow != null)
                {
                    _explorerWindow.Dispose();
                    _explorerWindow = null;
                }

                if (_mappingDetailsWindow != null)
                {
                    // don't need to call this, the MDF takes care of this one
                    //_mappingDetailsWindow.Dispose();
                    _mappingDetailsWindow = null;
                }

                // remove all errors
                ErrorListHelper.RemoveAll();

                // Unregister for VS Events
                ErrorListHelper.UnregisterForNotifications();

                // dispose of our classes in reverse order than we created them
                if (_connectionManager != null)
                {
                    _connectionManager.Dispose();
                    _connectionManager = null;
                }

                if (_modelChangeEventListener != null)
                {
                    _modelChangeEventListener.Dispose();
                    _modelChangeEventListener = null;
                }

                if (_documentFrameMgr != null)
                {
                    _documentFrameMgr.Dispose();
                    _documentFrameMgr = null;
                }

                _modelManager.Dispose();

#if (VS11)
                // UnSubscribe from the SQL CE upgrade service
                var sqlCeUpgradeService = GetGlobalService(typeof(IVsSqlCeUpgradeService)) as IVsSqlCeUpgradeService;
                if (sqlCeUpgradeService != null)
                {
                    sqlCeUpgradeService.OnUpgradeProject -= EdmUtils.SqlCeUpgradeService_OnUpgradeProject;
                }
#endif
                // UnSubscribe from the SqlDatabaseFile upgrade service
                var sqlDatabaseFileUpgradeService =
                    GetGlobalService(typeof(IVsSqlDatabaseFileUpgradeService)) as IVsSqlDatabaseFileUpgradeService;
                if (sqlDatabaseFileUpgradeService != null)
                {
                    sqlDatabaseFileUpgradeService.OnUpgradeProject -= EdmUtils.SqlDatabaseFileUpgradeService_OnUpgradeProject;
                }

                // clear out any static references
                PackageManager.Package = null;
                Services.ServiceProvider = null;
                _dispatcher = null;
            }
            finally
            {
                base.Dispose(disposing);
            }
        }