Thread: VSTA Anyone?
View Single Post
  #8  
Old 05-01-2011, 16:57
still
Guest
 
Posts: n/a
Default

Sorry, my english is bad, so I just show my solution:

1) Main.cs:

Code:
using System;
using Corel.Interop.CorelDRAW;

namespace MyAddin
{
    [System.AddIn.AddIn("My Addin", Version = "1.0", Publisher = "", Description = "")]
    public partial class Main
    {
        private void Main_Startup(object sender, EventArgs e)
        {

            ToolboxForm ToolBox = new ToolboxForm();
            ToolBox.app = this.app;
            ToolBox.Show();
        }

        private void Main_Shutdown(object sender, EventArgs e)
        {
        }


        #region VSTA generated code
        private Corel.Interop.CorelDRAW.Application app = null;
        private void InternalStartup()
        {
            this.Startup += new System.EventHandler(Main_Startup);
            this.Shutdown += new System.EventHandler(Main_Shutdown);
            app = (Corel.Interop.CorelDRAW.Application)this.Host;
        }
        #endregion

    }
}
2) Custom Form Code:

Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Corel.Interop.CorelDRAW;

namespace GritsayAddin
{
    public partial class ToolboxForm : Form
    {
        public Corel.Interop.CorelDRAW.Application app = null;

        public ToolboxForm()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (app != null) {
                app.ActiveLayer.CreateLineSegment(0, 0, 2, -2);
            }
        }
    }
}

Form showing up when Corel Draw run. When button pressed - in active layer it draw line.

All working, but I dont know how to bind ToolBox.Show(); on custom pannel button.
Reply With Quote