예제 #1
0
 public override void OnWorkbookActivate(Excel.Workbook Wb)
 {
     try{
         if (Wb == null)
         {
             return;
         }
         _tabVisible = false;
         if (_commandList.ContainsKey(Wb))
         {
             _commands   = _commandList[Wb];
             _tabVisible = true;
         }
         else if (IsTemplateWb(Wb))
         {
             _commands             = new WorkbookInstance(_excelapp, Wb);
             _commands.OnLogInOut += OnLogInOut;
             Wb.BeforeClose       += _commands.OnWorkbookClose;
             Wb.BeforeClose       += OnWorkbookClose;
             _commandList.Add(Wb, _commands);
             _tabVisible = true;
         }
         if (_ribbon != null)
         {
             _ribbon.Invalidate();
         }
     } catch (Exception ex) { new BusinessObjectsUtils.FrmException(_excelapp.Hwnd, ex).ShowDialog(); }
 }
예제 #2
0
 public override void OnWorkbookActivate(Excel.Workbook Wb)
 {
     try {
         if (Wb == null)
         {
             return;
         }
         if (_btTab != null)
         {
             _btTab.Visible = false;
         }
         if (_commandList.ContainsKey(Wb))
         {
             _commands      = _commandList[Wb];
             _btTab.Visible = true;
         }
         else if (IsTemplateWb(Wb))
         {
             _commands             = new WorkbookInstance(_excelapp, Wb);
             _commands.OnLogInOut += OnLogInOut;
             Wb.BeforeClose       += _commands.OnWorkbookClose;
             Wb.BeforeClose       += OnWorkbookClose;
             _commandList.Add(Wb, _commands);
             if (_btTab == null)
             {
                 try {
                     _excelapp.ScreenUpdating = false;
                     var xmldoc = new XmlDocument();
                     xmldoc.LoadXml(Properties.Resources.Ribbon);
                     _buttons = AddCommandBarButtons(xmldoc.DocumentElement.FirstChild.FirstChild.ChildNodes);
                 } catch (Exception) { throw; } finally {
                     _excelapp.ScreenUpdating = true;
                 }
             }
             _btTab.Visible = true;
         }
     }catch (Exception ex) { new BusinessObjectsUtils.FrmException(_excelapp.Hwnd, ex).ShowDialog(); }
 }