예제 #1
0
 protected override void OnClick(EventArgs e)
 {
     if (mouse == enumMousePos.Close)
     {
         if (toolbox != null)
         {
             toolbox.HideToolBox(this, e);
         }
     }
     else if (mouse == enumMousePos.Add)
     {
         if (toolbox != null)
         {
             dlgToolboxTab dlg = new dlgToolboxTab();
             if (dlg.ShowDialog(this.FindForm()) == DialogResult.OK)
             {
                 string name = dlg.GetResult();
                 if (toolbox.TabNameExists(name))
                 {
                     MessageBox.Show(this.FindForm(), "<" + name + "> already exists", "Toolbox", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 else
                 {
                     ToolboxTab2 tab = toolbox.CreateTab(name, false, -1);
                     tab.AdjustSize();
                     toolbox.Changed = true;
                 }
             }
         }
     }
 }
 void itemList_MouseMove(object sender, MouseEventArgs e)
 {
     if (e.Button != MouseButtons.Left || itemList.SelectedIndex <= 0 || itemList.SelectedIndex != nSelectedIndex)
     {
         bPrepareDrag = false;
     }
     if (bPrepareDrag)
     {
         if (Math.Abs(e.X - x0) > 3 || Math.Abs(e.Y - y0) > 3)
         {
             ToolboxItem     tbi = itemList.Items[itemList.SelectedIndex] as ToolboxItem;
             xToolboxItem    xt  = tbi as xToolboxItem;
             InterfaceVOB    vob = ((IServiceContainer)toolbox.Host).GetService(typeof(InterfaceVOB)) as InterfaceVOB;
             IToolboxService tbs = ((IServiceContainer)toolbox.Host).GetService(typeof(IToolboxService)) as IToolboxService;
             if (tbs == null)
             {
                 if (vob == null)
                 {
                     bool          b   = true;
                     TraceLogClass log = new TraceLogClass();
                     log.Log("service InterfaceVOB not available", ref b);
                 }
                 else
                 {
                     PassData data = new PassData();
                     vob.SendNotice(enumVobNotice.GetToolbox, data);
                     tbs = data.Data as IToolboxService;
                 }
             }
             if (tbs != null)
             {
                 bool bCanDrop = true;
                 if (vob != null)
                 {
                     if (xt != null)
                     {
                         if (xt.Properties != null && xt.Properties.Contains("ClassId"))
                         {
                             ToolboxItemXType.SelectedToolboxClassId   = (UInt32)(xt.Properties["ClassId"]);
                             ToolboxItemXType.SelectedToolboxType      = null;
                             ToolboxItemXType.SelectedToolboxTypeKey   = null;
                             ToolboxItemXType.SelectedToolboxClassName = (string)(xt.Properties["DisplayName"]);
                         }
                         else
                         {
                             PassData pd = new PassData();
                             pd.Key        = xt.Type;
                             pd.Data       = true;
                             pd.Attributes = xt.Properties;
                             vob.SendNotice(enumVobNotice.ObjectCanCreate, pd);
                             bCanDrop = (bool)pd.Data;
                             if (bCanDrop && pd.Attributes != null)
                             {
                                 ToolboxItem tx0 = pd.Attributes as ToolboxItem;
                                 if (tx0 != null)
                                 {
                                     tbi = tx0;
                                 }
                             }
                         }
                     }
                 }
                 if (bCanDrop)
                 {
                     try
                     {
                         DataObject d = tbs.SerializeToolboxItem(tbi) as DataObject;
                         toolbox.HideToolBox(this, null);
                         itemList.DoDragDrop(d, DragDropEffects.Copy);
                     }
                     catch (Exception ex)
                     {
                         bool          b   = true;
                         TraceLogClass log = new TraceLogClass();
                         log.Log(this.FindForm(), ex, ref b);
                     }
                 }
             }
         }
     }
 }