示例#1
0
        private void AttachToCurrentWindow()
        {
            // If the current window does not yet have our task pane, add it to it
            IntPtr currentHandle = Bovender.Win32Window.MainWindowHandleProvider();

            if (!Panes.ContainsKey(currentHandle))
            {
                Logger.Info("Attaching new WorksheetManager panel to window 0x{0:X08}", currentHandle);
                WorkbookViewModel viewModel;
                if (Instance.Default.IsSingleDocumentInterface)
                {
                    // Create a new workbook view model only if this is an SDI application
                    viewModel = new WorkbookViewModel(Instance.Default.ActiveWorkbook);
                }
                else
                {
                    viewModel = _viewModel;
                }
                SheetManagerTaskPane tp = new SheetManagerTaskPane(viewModel, Width, Visible);
                tp.VisibilityChanged += (object sender, SheetManagerEventArgs args) =>
                {
                    OnVisibilityChanged(args.TaskPane);
                };
                Panes.Add(currentHandle, tp);
            }
            else
            {
                Logger.Info("Window 0x{0:X08} already has a WorksheetManager panel", currentHandle);
            }
        }