コード例 #1
0
ファイル: ThumbnailView.cs プロジェクト: lulzzz/CQRSAzure
        protected override void OnInvoke()
        {
            IFeatureContext featureContext = this.ServiceProvider.GetService <IFeatureContext>();

            Debug.Assert(featureContext != null);
            if (featureContext != null)
            {
                PanZoomWindow toolWindow = featureContext.CreateFeature <PanZoomWindow>();
                Debug.Assert(toolWindow != null);
                if (toolWindow != null)
                {
                    toolWindow.Show();
                }
            }
        }
コード例 #2
0
ファイル: ThumbnailView.cs プロジェクト: lulzzz/CQRSAzure
        public override void Associate(MetaFeature metaFeature, ITypedServiceProvider serviceProvider)
        {
            if (metaFeature == null)
            {
                throw new ArgumentNullException("metaFeature");
            }
            if (serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }

            base.Associate(metaFeature, serviceProvider);

            Debug.Assert(m_scrollPanel == null);
            if (m_scrollPanel == null)
            {
                DiagramContext diagramContext = serviceProvider.GetService <IFeatureContext>() as DiagramContext;
                Debug.Assert(diagramContext != null && diagramContext.DiagramView != null);
                if (diagramContext != null && diagramContext.DiagramView != null)
                {
                    // Create and show a thumbnail form.
                    DiagramView diagramView = diagramContext.DiagramView;
                    m_scrollPanel = new Panel();
                    m_scrollPanel.BackgroundImage       = new Bitmap(typeof(ThumbnailViewForm), @"ThumbnailView.bmp");
                    m_scrollPanel.Anchor                = AnchorStyles.Bottom | AnchorStyles.Right;
                    m_scrollPanel.BackgroundImageLayout = ImageLayout.Center;
                    diagramView.Invoke(new EventHandler(delegate(object sender, EventArgs e)
                    {
                        diagramView.Controls.Add(m_scrollPanel);
                    }));
                    m_scrollPanel.Width  = diagramView.Controls[1].Width;
                    m_scrollPanel.Height = diagramView.Controls[2].Height;
                    m_scrollPanel.Left   = diagramView.Width - m_scrollPanel.Width;
                    m_scrollPanel.Top    = diagramView.Height - m_scrollPanel.Height;
                    m_scrollPanel.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
                    m_scrollPanel.BringToFront();
                    m_scrollPanel.MouseDown += delegate(object sender, MouseEventArgs args)
                    {
                        // Right-click on the thumbnail icon brings pan/zoom tool window.
                        Debug.Assert(args != null);
                        if (args != null && args.Button == MouseButtons.Right)
                        {
                            IFeatureContext featureContext = this.ServiceProvider.GetService <IFeatureContext>();
                            Debug.Assert(featureContext != null);
                            if (featureContext != null)
                            {
                                PanZoomWindow toolWindow = featureContext.CreateFeature <PanZoomWindow>();
                                Debug.Assert(toolWindow != null);
                                if (toolWindow != null)
                                {
                                    toolWindow.Show();
                                }
                            }
                        }
                        else
                        {
                            // Any other click on thumbnail icon displays the thumbnail form.
                            new ThumbnailViewForm(m_scrollPanel, diagramView.DiagramClientView).ShowDialog();
                        }
                    };
                }
            }
        }