Ejemplo n.º 1
0
        void MonitorWorkbookClosed(object sender, WorkbookClosedEventArgs e)
        {
            VstoContribLog.Debug(log => log("Excel raised WorkbookClosed({0}) event", e.Workbook.ToLogFormat()));
            var handler = ViewClosed;

            if (handler == null)
            {
                return;
            }

            if (workbooks.ContainsKey(e.Workbook))
            {
                var windows = workbooks[e.Workbook];

                foreach (var window in windows)
                {
                    handler(this, new ViewClosedEventArgs(window, e.Workbook));
                    if (!IsMdi())
                    {
                        window.ReleaseComObject();
                    }
                }
                workbooks.Remove(e.Workbook);
            }

            if (!excelApplication.Workbooks.OfType <Workbook>().Except(new[] { e.Workbook }).Any())
            {
                nullContextOpen = true;
                foreach (Window window in excelApplication.Windows)
                {
                    NewView(this, new NewViewEventArgs(window, NullContext.Instance, ExcelRibbonType.ExcelWorkbook.GetEnumDescription()));
                }
            }
        }
Ejemplo n.º 2
0
        void MonitorWorkbookClosed(object sender, WorkbookClosedEventArgs e)
        {
            VstoContribLog.Debug(log => log("Excel raised WorkbookClosed({0}) event", e.Workbook.ToLogFormat()));
            var handler = ViewClosed;
            if (handler == null) return;

            if (workbooks.ContainsKey(e.Workbook))
            {
                var windows = workbooks[e.Workbook];

                foreach (var window in windows)
                {
                    handler(this, new ViewClosedEventArgs(window, e.Workbook));
                    if (!IsMdi())
                        window.ReleaseComObject();
                }
                workbooks.Remove(e.Workbook);
            }

            if (!excelApplication.Workbooks.OfType<Workbook>().Except(new[]{e.Workbook}).Any())
            {
                nullContextOpen = true;
                foreach (Window window in excelApplication.Windows)
                {
                    NewView(this, new NewViewEventArgs(window, NullContext.Instance, ExcelRibbonType.ExcelWorkbook.GetEnumDescription()));
                }
            }
        }
Ejemplo n.º 3
0
        void MonitorWorkbookClosed(object sender, WorkbookClosedEventArgs e)
        {
            var handler = ViewClosed;

            if (handler == null)
            {
                return;
            }

            if (workbooks.ContainsKey(e.Workbook))
            {
                var windows = workbooks[e.Workbook];

                foreach (var window in windows)
                {
                    handler(this, new ViewClosedEventArgs(window, e.Workbook));
                    if (!IsMdi())
                    {
                        window.ReleaseComObject();
                    }
                }
                workbooks.Remove(e.Workbook);
            }
        }
        void MonitorWorkbookClosed(object sender, WorkbookClosedEventArgs e)
        {
            var handler = ViewClosed;
            if (handler == null) return;

            if (workbooks.ContainsKey(e.Workbook))
            {
                var windows = workbooks[e.Workbook];

                foreach (var window in windows)
                {
                    handler(this, new ViewClosedEventArgs(window, e.Workbook));
                    if (!IsMdi())
                        window.ReleaseComObject();
                }
                workbooks.Remove(e.Workbook);
            }
        }
Ejemplo n.º 5
0
 void Monitor_WorkbookClosed(object sender, WorkbookClosedEventArgs e)
 {
     Log.WriteLog(string.Format("Monitor detected workbook {0} was closed", e.Name));
 }