Beispiel #1
0
 /// <summary>
 /// 销毁方法
 /// </summary>
 public override void Dispose()
 {
     if (!IsDisposed)
     {
         if (m_grid != null)
         {
             m_grid.UnRegisterEvent(m_gridCellClickEvent, EVENTID.GRIDCELLCLICK);
             m_grid.UnRegisterEvent(m_gridKeyDownEvent, EVENTID.KEYDOWN);
         }
         if (m_searchTextBox != null)
         {
             if (m_textBoxInputChangedEvent != null)
             {
                 m_searchTextBox.UnRegisterEvent(m_textBoxInputChangedEvent, EVENTID.TEXTCHANGED);
                 m_textBoxInputChangedEvent = null;
             }
             if (m_textBoxKeyDownEvent != null)
             {
                 m_searchTextBox.UnRegisterEvent(m_textBoxKeyDownEvent, EVENTID.KEYDOWN);
                 m_textBoxKeyDownEvent = null;
             }
         }
     }
     base.Dispose();
 }
Beispiel #2
0
        //autofac uses this
        public EditingView(EditingModel model, PageListView pageListView,
			CutCommand cutCommand, CopyCommand copyCommand, PasteCommand pasteCommand, UndoCommand undoCommand,
			DuplicatePageCommand duplicatePageCommand,
			DeletePageCommand deletePageCommand, NavigationIsolator isolator, ControlKeyEvent controlKeyEvent)
        {
            _model = model;
            _pageListView = pageListView;
            _cutCommand = cutCommand;
            _copyCommand = copyCommand;
            _pasteCommand = pasteCommand;
            _undoCommand = undoCommand;
            _duplicatePageCommand = duplicatePageCommand;
            _deletePageCommand = deletePageCommand;
            InitializeComponent();
            _browser1.Isolator = isolator;
            _splitContainer1.Tag = _splitContainer1.SplitterDistance; //save it
            //don't let it grow automatically
            //            _splitContainer1.SplitterMoved+= ((object sender, SplitterEventArgs e) => _splitContainer1.SplitterDistance = (int)_splitContainer1.Tag);
            SetupThumnailLists();
            _model.SetView(this);
            _browser1.SetEditingCommands(cutCommand, copyCommand, pasteCommand, undoCommand);

            _browser1.GeckoReady += new EventHandler(OnGeckoReady);

            _browser1.ControlKeyEvent = controlKeyEvent;

            if(SIL.PlatformUtilities.Platform.IsMono)
            {
                RepositionButtonsForMono();
                BackgroundColorsForLinux();
            }

            controlKeyEvent.Subscribe(HandleControlKeyEvent);

            // Adding this renderer prevents a white line from showing up under the components.
            _menusToolStrip.Renderer = new FixedToolStripRenderer();

            //we're giving it to the parent control through the TopBarControls property
            Controls.Remove(_topBarPanel);
            SetupBrowserContextMenu();
            #if __MonoCS__
            // The inactive button images look garishly pink on Linux/Mono, but look okay on Windows.
            // Merely introducing an "identity color matrix" to the image attributes appears to fix
            // this problem.  (The active form looks okay with or without this fix.)
            // See http://issues.bloomlibrary.org/youtrack/issue/BL-3714.
            float[][] colorMatrixElements = {
                new float[] {1,  0,  0,  0,  0},		// red scaling factor of 1
                new float[] {0,  1,  0,  0,  0},		// green scaling factor of 1
                new float[] {0,  0,  1,  0,  0},		// blue scaling factor of 1
                new float[] {0,  0,  0,  1,  0},		// alpha scaling factor of 1
                new float[] {0,  0,  0,  0,  1}};		// three translations of 0.0
            var colorMatrix = new ColorMatrix(colorMatrixElements);
            _duplicatePageButton.ImageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
            _deletePageButton.ImageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
            _undoButton.ImageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
            _cutButton.ImageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
            _pasteButton.ImageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
            _copyButton.ImageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
            #endif
        }
        public PageListView(PageSelection pageSelection,  RelocatePageEvent relocatePageEvent, EditingModel model,
			HtmlThumbNailer thumbnailProvider, NavigationIsolator isolator, ControlKeyEvent controlKeyEvent)
        {
            _pageSelection = pageSelection;
            _model = model;
            this.Font= SystemFonts.MessageBoxFont;
            InitializeComponent();

            _thumbNailList.Thumbnailer = thumbnailProvider;
            _thumbNailList.CanSelect = true;
            _thumbNailList.PreferPageNumbers = true;
            _thumbNailList.KeepShowingSelection = true;
            _thumbNailList.RelocatePageEvent = relocatePageEvent;
            _thumbNailList.PageSelectedChanged+=new EventHandler(OnPageSelectedChanged);
            _thumbNailList.Isolator = isolator;
            _thumbNailList.ControlKeyEvent = controlKeyEvent;
            // First action determines whether the menu item is enabled, second performs it.
            var menuItems = new List<WebThumbNailList.MenuItemSpec>();
            menuItems.Add(
                new WebThumbNailList.MenuItemSpec() {
                    Label = LocalizationManager.GetString("EditTab.DuplicatePageButton", "Duplicate Page"), // same ID as button in toolbar));
                    EnableFunction = (page) => page != null && !page.Required && !_model.CurrentBook.LockedDown,
                    ExecuteCommand = (page) => _model.DuplicatePage(page)});
            menuItems.Add(
                new WebThumbNailList.MenuItemSpec() {
                    Label = LocalizationManager.GetString("EditTab.DeletePageButton", "Remove Page"),  // same ID as button in toolbar));
                    EnableFunction = (page) => page != null && !page.Required && !_model.CurrentBook.LockedDown,
                    ExecuteCommand = (page) =>
                    {
                        if (ConfirmRemovePageDialog.Confirm())
                            _model.DeletePage(page);
                    }});
            menuItems.Add(
                new WebThumbNailList.MenuItemSpec() {
                    Label = LocalizationManager.GetString("EditTab.ChooseLayoutButton", "Choose Different Layout"),
                    EnableFunction = (page) => page != null && !page.Required && !_model.CurrentBook.LockedDown,
                    ExecuteCommand = (page) => _model.ChangePageLayout(page)});
            // This adds the desired menu items to the Gecko context menu that happens when we right-click
            _thumbNailList.ContextMenuProvider = args =>
            {
                var page = _thumbNailList.GetPageContaining(args.TargetNode);
                if (page == null)
                    return true; // no page-related commands if we didn't click on one.
                if(page != _pageSelection.CurrentSelection)
                {
                    return true; //it's too dangerous to let users do thing to a page they aren't seeing
                }
                foreach (var item in menuItems)
                {
                    var menuItem = new MenuItem(item.Label, (sender, eventArgs) => item.ExecuteCommand(page));
                    args.ContextMenu.MenuItems.Add(menuItem);
                    menuItem.Enabled = item.EnableFunction(page);
                }
                return true;
            };
            // This sets up the context menu items that will be shown when the user clicks the
            // arrow in the thumbnail list.
            _thumbNailList.ContextMenuItems = menuItems;
        }
Beispiel #4
0
 /// <summary>
 /// 创建键盘精灵
 /// </summary>
 public SearchDiv()
 {
     m_gridCellClickEvent       = new GridCellMouseEvent(GridCellClick);
     m_gridKeyDownEvent         = new ControlKeyEvent(GridKeyDown);
     m_textBoxInputChangedEvent = new ControlEvent(TextBoxInputChanged);
     m_textBoxKeyDownEvent      = new ControlKeyEvent(TextBoxKeyDown);
     BackColor = COLOR.EMPTY;
     IsWindow  = true;
 }
Beispiel #5
0
        public Shell(Func<WorkspaceView> projectViewFactory,
												CollectionSettings collectionSettings,
												BookDownloadStartingEvent bookDownloadStartingEvent,
												LibraryClosing libraryClosingEvent,
												QueueRenameOfCollection queueRenameOfCollection,
												ControlKeyEvent controlKeyEvent)
        {
            queueRenameOfCollection.Subscribe(newName => _nameToChangeCollectionUponClosing = newName.Trim().SanitizeFilename('-'));
            _collectionSettings = collectionSettings;
            _libraryClosingEvent = libraryClosingEvent;
            _controlKeyEvent = controlKeyEvent;
            InitializeComponent();

            //bring the application to the front (will normally be behind the user's web browser)
            bookDownloadStartingEvent.Subscribe((x) =>
            {
                try
                {
                    this.Invoke((Action)this.Activate);
                }
                catch (Exception e)
                {
                    Debug.Fail("(Debug Only) Can't bring to front in the current state: " + e.Message);
                    //swallow... so we were in some state that we couldn't come to the front... that's ok.
                }
            });

            #if DEBUG
            WindowState = FormWindowState.Normal;
            //this.FormBorderStyle = FormBorderStyle.None;  //fullscreen

            Size = new Size(1024,720);
            #else
            // We only want this screen size context menu in Debug mode
            ContextMenuStrip = null;
            #endif
            _workspaceView = projectViewFactory();
            _workspaceView.CloseCurrentProject += ((x, y) =>
                                                    {
                                                        UserWantsToOpenADifferentProject = true;
                                                        Close();
                                                    });

            _workspaceView.ReopenCurrentProject += ((x, y) =>
            {
                UserWantsToOpeReopenProject = true;
                Close();
            });

            _workspaceView.BackColor =
                System.Drawing.Color.FromArgb(64,64,64);
                                        _workspaceView.Dock = System.Windows.Forms.DockStyle.Fill;

            this.Controls.Add(this._workspaceView);

            SetWindowText(null);
        }
Beispiel #6
0
        public PageListView(PageSelection pageSelection, RelocatePageEvent relocatePageEvent, EditingModel model,
                            HtmlThumbNailer thumbnailProvider, NavigationIsolator isolator, ControlKeyEvent controlKeyEvent, PageListApi pageListApi, BloomWebSocketServer webSocketServer)
        {
            _pageSelection = pageSelection;
            _model         = model;
            this.Font      = SystemFonts.MessageBoxFont;
            InitializeComponent();
            _thumbNailList.PageListApi     = pageListApi;
            _thumbNailList.WebSocketServer = webSocketServer;
            this.BackColor = Palette.SidePanelBackgroundColor;

            _thumbNailList.Thumbnailer          = thumbnailProvider;
            _thumbNailList.RelocatePageEvent    = relocatePageEvent;
            _thumbNailList.PageSelectedChanged += new EventHandler(OnPageSelectedChanged);
            _thumbNailList.ControlKeyEvent      = controlKeyEvent;
            _thumbNailList.Model = model;
            _thumbNailList.BringToFront();             // needed to get DockStyle.Fill to work right.
            // First action determines whether the menu item is enabled, second performs it.
            var menuItems = new List <WebThumbNailList.MenuItemSpec>();

            menuItems.Add(
                new WebThumbNailList.MenuItemSpec()
            {
                Label          = LocalizationManager.GetString("EditTab.DuplicatePageButton", "Duplicate Page"),
                EnableFunction = (page) => page != null && _model.CanDuplicatePage,
                ExecuteCommand = (page) => _model.DuplicatePage(page)
            });
            menuItems.Add(
                new WebThumbNailList.MenuItemSpec()
            {
                Label          = LocalizationManager.GetString("EditTab.CopyPage", "Copy Page"),
                EnableFunction = (page) => page != null && _model.CanCopyPage,
                ExecuteCommand = (page) => _model.CopyPage(page)
            });
            menuItems.Add(
                new WebThumbNailList.MenuItemSpec()
            {
                Label          = LocalizationManager.GetString("EditTab.PastePage", "Paste Page"),
                EnableFunction = (page) => page != null && _model.CanAddPages && _model.GetClipboardHasPage(),
                ExecuteCommand = (page) => _model.PastePage(page)
            });
            menuItems.Add(
                new WebThumbNailList.MenuItemSpec()
            {
                Label          = LocalizationManager.GetString("EditTab.DeletePageButton", "Remove Page"),
                EnableFunction = (page) => page != null && _model.CanDeletePage,
                ExecuteCommand = (page) =>
                {
                    if (ConfirmRemovePageDialog.Confirm())
                    {
                        _model.DeletePage(page);
                    }
                }
            });
            menuItems.Add(
                new WebThumbNailList.MenuItemSpec()
            {
                Label          = LocalizationManager.GetString("EditTab.ChooseLayoutButton", "Choose Different Layout"),
                EnableFunction = (page) => page != null && !page.Required && !_model.CurrentBook.LockedDown,
                ExecuteCommand = (page) => _model.ChangePageLayout(page)
            });
            // This adds the desired menu items to the Gecko context menu that happens when we right-click
            _thumbNailList.ContextMenuProvider = args =>
            {
                var page = _thumbNailList.GetPageContaining(args.TargetNode);
                if (page == null)
                {
                    return(true);                    // no page-related commands if we didn't click on one.
                }
                if (page != _pageSelection.CurrentSelection)
                {
                    return(true);                    //it's too dangerous to let users do thing to a page they aren't seeing
                }
                foreach (var item in menuItems)
                {
                    var menuItem = new MenuItem(item.Label, (sender, eventArgs) => item.ExecuteCommand(page));
                    args.ContextMenu.MenuItems.Add(menuItem);
                    menuItem.Enabled = item.EnableFunction(page);
                }
                return(true);
            };
            // This sets up the context menu items that will be shown when the user clicks the
            // arrow in the thumbnail list.
            _thumbNailList.ContextMenuItems = menuItems;
        }