Exemplo n.º 1
0
 public override void Unload()
 {
     base.Unload();
     imageTexture.Dispose();
     imagePanel.Dispose();
     imagePanel       = null;
     statusStrip      = null;
     visualizerCanvas = null;
     imageTexture     = null;
 }
Exemplo n.º 2
0
        public override void Load(IServiceProvider provider)
        {
            StatusStripEnabled = true;
            visualizerCanvas   = new VisualizerCanvas {
                Dock = DockStyle.Fill
            };
            statusStrip = new StatusStrip {
                Visible = false
            };
            statusLabel = new ToolStripStatusLabel();
            statusStrip.Items.Add(statusLabel);
            visualizerCanvas.RenderFrame       += (sender, e) => RenderFrame();
            visualizerCanvas.Load              += (sender, e) => imageTexture = new IplImageTexture();
            visualizerCanvas.Canvas.MouseClick += (sender, e) => statusStrip.Visible =
                StatusStripEnabled &&
                e.Button == MouseButtons.Right ? !statusStrip.Visible : statusStrip.Visible;

            visualizerCanvas.Canvas.MouseMove        += (sender, e) => UpdateStatus();
            visualizerCanvas.Canvas.MouseDoubleClick += (sender, e) =>
            {
                if (e.Button == MouseButtons.Left)
                {
                    if (visualizerImage != null)
                    {
                        imagePanel.Parent.ClientSize = new Size(visualizerImage.Width, visualizerImage.Height);
                    }
                }
            };

            imagePanel = new UserControl();
            imagePanel.SuspendLayout();
            imagePanel.Dock = DockStyle.Fill;
            imagePanel.Size = new Size(320, 240);
            imagePanel.AutoScaleDimensions = new SizeF(6F, 13F);
            imagePanel.AutoScaleMode       = AutoScaleMode.Font;
            imagePanel.Controls.Add(visualizerCanvas);
            imagePanel.Controls.Add(statusStrip);
            imagePanel.ResumeLayout(false);

            var visualizerService = (IDialogTypeVisualizerService)provider.GetService(typeof(IDialogTypeVisualizerService));

            if (visualizerService != null)
            {
                updateTimer          = new Timer();
                updateTimer.Interval = TargetInterval;
                updateTimer.Tick    += updateTimer_Tick;
                visualizerService.AddControl(imagePanel);
                updateTimer.Start();
            }

            base.Load(provider);
        }