Beispiel #1
0
 public ShapeTool(DocumentWorkspace documentWorkspace,
                  ImageResource toolBarImage,
                  string name,
                  string helpText,
                  char hotKey,
                  ToolBarConfigItems toolBarConfigItemsInclude,
                  ToolBarConfigItems toolBarConfigItemsExclude)
     : base(documentWorkspace,
            toolBarImage,
            name,
            helpText,
            hotKey,
            false,
            (toolBarConfigItemsInclude |
             (ToolBarConfigItems.Brush |
              ToolBarConfigItems.Pen |
              ToolBarConfigItems.ShapeType |
              ToolBarConfigItems.Antialiasing |
              ToolBarConfigItems.AlphaBlending)) &
            ~(toolBarConfigItemsExclude))
 {
     this.mouseDown       = false;
     this.points          = null;
     this.cursorMouseUp   = new Cursor(PdnResources.GetResourceStream("Cursors.ShapeToolCursor.cur"));
     this.cursorMouseDown = new Cursor(PdnResources.GetResourceStream("Cursors.ShapeToolCursorMouseDown.cur"));
 }
Beispiel #2
0
        public BaseTool(DocumentWorkspace documentWorkspace,
                        ImageResource toolBarImage,
                        string name,
                        string helpText,
                        char hotKey,
                        bool skipIfActiveOnHotKey,
                        ToolBarConfigItems toolBarConfigItems)
        {
            this._documentWorkspace = documentWorkspace;
            this._toolBarImage      = toolBarImage;
            this._toolInfo          = new ToolInfo(name, helpText, toolBarImage, hotKey, skipIfActiveOnHotKey, toolBarConfigItems,
                                                   this.GetType());

            if (documentWorkspace == null)
            {
                return;
            }

            documentWorkspace.DocumentKeyDown  += PerformKeyDown;
            documentWorkspace.DocumentKeyUp    += PerformKeyUp;
            documentWorkspace.DocumentKeyPress += PerformKeyPress;

            documentWorkspace.DocumentMouseEnter += PerformMouseEnter;
            documentWorkspace.DocumentMouseLeave += PerformMouseLeave;

            documentWorkspace.DocumentMouseDown += PerformMouseDown;
            documentWorkspace.DocumentMouseUp   += PerformMouseUp;
            documentWorkspace.DocumentClick     += PerformClick;
            documentWorkspace.DocumentMouseMove += PerformMouseMove;
        }
Beispiel #3
0
 public ShapeTool(DocumentWorkspace documentWorkspace,
                  ImageResource toolBarImage,
                  string name,
                  string helpText,
                  ToolBarConfigItems toolBarConfigItemsInclude,
                  ToolBarConfigItems toolBarConfigItemsExclude)
     : this(documentWorkspace,
            toolBarImage,
            name,
            helpText,
            defaultShortcut,
            toolBarConfigItemsInclude,
            toolBarConfigItemsExclude)
 {
 }
Beispiel #4
0
 public ShapeTool(DocumentWorkspace documentWorkspace,
                  ImageResource toolBarImage,
                  string name,
                  string helpText,
                  ToolBarConfigItems toolBarConfigItemsInclude,
                  ToolBarConfigItems toolBarConfigItemsExclude)
     : this(documentWorkspace,
            toolBarImage,
            name,
            helpText,
            defaultShortcut,
            toolBarConfigItemsInclude,
            toolBarConfigItemsExclude)
 {
 }
Beispiel #5
0
 public SelectionTool(
     DocumentWorkspace documentWorkspace,
     ImageResource toolBarImage,
     string name,
     string helpText,
     char hotKey,
     ToolBarConfigItems toolBarConfigItems)
     : base(documentWorkspace,
            toolBarImage,
            name,
            helpText,
            hotKey,
            false,
            toolBarConfigItems | ToolBarConfigItems.SelectionCombineMode)
 {
     this.tracking = false;
 }
Beispiel #6
0
        // NOTE: Your constructor must be able to run successfully with a documentWorkspace
        //       of null. This is sent in while the DocumentControl static constructor
        //       class is building a list of ToolInfo instances, so that it may construct
        //       the list without having to also construct a DocumentControl.
        public Tool(DocumentWorkspace documentWorkspace,
                    ImageResource toolBarImage,
                    string name,
                    string helpText,
                    char hotKey,
                    bool skipIfActiveOnHotKey,
                    ToolBarConfigItems toolBarConfigItems)
        {
            this.documentWorkspace = documentWorkspace;
            this.toolBarImage      = toolBarImage;
            this.toolInfo          = new ToolInfo(name, helpText, toolBarImage, hotKey, skipIfActiveOnHotKey, toolBarConfigItems, this.GetType());

            if (this.documentWorkspace != null)
            {
                this.documentWorkspace.UpdateStatusBarToToolHelpText(this);
            }
        }
Beispiel #7
0
 public ToolInfo(
     string name, 
     string helpText, 
     ImageResource image, 
     char hotKey, 
     bool skipIfActiveOnHotKey, 
     ToolBarConfigItems toolBarConfigItems, 
     Type toolType)
 {
     this.name = name;
     this.helpText = helpText;
     this.image = image;
     this.hotKey = hotKey;
     this.skipIfActiveOnHotKey = skipIfActiveOnHotKey;
     this.toolBarConfigItems = toolBarConfigItems;
     this.toolType = toolType;
 }
            public ToolConfigRow(ToolBarConfigItems toolBarConfigItems)
            {
                this.toolBarConfigItems = toolBarConfigItems;

                this.headerLabel = new HeaderLabel();
                this.headerLabel.Name = "headerLabel:" + toolBarConfigItems.ToString();
                this.headerLabel.Text = PdnResources.GetString(GetHeaderResourceName());
                this.headerLabel.RightMargin = 0;

                this.toolConfigStrip = new ToolConfigStrip();
                this.toolConfigStrip.Name = "toolConfigStrip:" + toolBarConfigItems.ToString();
                this.toolConfigStrip.AutoSize = true;
                this.toolConfigStrip.Dock = DockStyle.None;
                this.toolConfigStrip.GripStyle = ToolStripGripStyle.Hidden;
                this.toolConfigStrip.LayoutStyle = ToolStripLayoutStyle.HorizontalStackWithOverflow;
                this.toolConfigStrip.ToolBarConfigItems = this.toolBarConfigItems;
            }
Beispiel #9
0
            public ToolConfigRow(ToolBarConfigItems toolBarConfigItems)
            {
                this.toolBarConfigItems = toolBarConfigItems;

                this.headerLabel             = new HeaderLabel();
                this.headerLabel.Name        = "headerLabel:" + toolBarConfigItems.ToString();
                this.headerLabel.Text        = PdnResources.GetString(GetHeaderResourceName());
                this.headerLabel.RightMargin = 0;

                this.toolConfigStrip                    = new ToolConfigStrip();
                this.toolConfigStrip.Name               = "toolConfigStrip:" + toolBarConfigItems.ToString();
                this.toolConfigStrip.AutoSize           = true;
                this.toolConfigStrip.Dock               = DockStyle.None;
                this.toolConfigStrip.GripStyle          = ToolStripGripStyle.Hidden;
                this.toolConfigStrip.LayoutStyle        = ToolStripLayoutStyle.HorizontalStackWithOverflow;
                this.toolConfigStrip.ToolBarConfigItems = this.toolBarConfigItems;
            }
Beispiel #10
0
 public ToolInfo(
     string name,
     string helpText,
     ImageResource image,
     char hotKey,
     bool skipIfActiveOnHotKey,
     ToolBarConfigItems toolBarConfigItems,
     Type toolType)
 {
     this.Name                 = name;
     this.HelpText             = helpText;
     this.Image                = image;
     this.HotKey               = hotKey;
     this.SkipIfActiveOnHotKey = skipIfActiveOnHotKey;
     this.ToolBarConfigItems   = toolBarConfigItems;
     this.ToolType             = toolType;
 }
Beispiel #11
0
 public SelectionTool(
     DocumentWorkspace documentWorkspace,
     ImageResource toolBarImage,
     string name,
     string helpText,
     char hotKey,
     ToolBarConfigItems toolBarConfigItems)
     : base(documentWorkspace,
            toolBarImage,
            name,
            helpText,
            hotKey,
            false,
            toolBarConfigItems)
 {
     this.tracking = false;
 }
Beispiel #12
0
            public ToolConfigRow(ToolBarConfigItems toolBarConfigItems)
            {
                this.ToolBarConfigItems = toolBarConfigItems;

                this.HeaderLabel             = new HeaderLabel();
                this.HeaderLabel.Name        = "headerLabel:" + toolBarConfigItems.ToString();
                this.HeaderLabel.Text        = PdnResources.GetString(GetHeaderResourceName());
                this.HeaderLabel.RightMargin = 0;

                this.ToolConfigStrip             = new ToolConfigStrip();
                this.ToolConfigStrip.Name        = "toolConfigStrip:" + toolBarConfigItems.ToString();
                this.ToolConfigStrip.AutoSize    = false;
                this.ToolConfigStrip.Dock        = DockStyle.None;
                this.ToolConfigStrip.GripStyle   = ToolStripGripStyle.Hidden;
                this.ToolConfigStrip.LayoutStyle = ToolStripLayoutStyle.Flow;
                ((FlowLayoutSettings)this.ToolConfigStrip.LayoutSettings).WrapContents = true;
                this.ToolConfigStrip.ToolBarConfigItems = this.ToolBarConfigItems;
            }
Beispiel #13
0
        // NOTE: Your constructor must be able to run successfully with a documentWorkspace
        //       of null. This is sent in while the DocumentControl static constructor
        //       class is building a list of ToolInfo instances, so that it may construct
        //       the list without having to also construct a DocumentControl.
        public Tool(DocumentWorkspace documentWorkspace,
                    ImageResource toolBarImage,
                    string name,
                    string helpText,
                    char hotKey,
                    bool skipIfActiveOnHotKey,
                    ToolBarConfigItems toolBarConfigItems)
        {
            this.documentWorkspace = documentWorkspace;
            this.toolBarImage = toolBarImage;
            this.toolInfo = new ToolInfo(name, helpText, toolBarImage, hotKey, skipIfActiveOnHotKey, toolBarConfigItems, this.GetType());

            if (this.documentWorkspace != null)
            {
                this.documentWorkspace.UpdateStatusBarToToolHelpText(this);
            }
        }
Beispiel #14
0
 public MoveToolBase(DocumentWorkspace documentWorkspace, ImageResource toolBarImage, string name,
                     string helpText, char hotKey, bool skipIfActiveOnHotKey, ToolBarConfigItems toolBarConfigItems)
     : base(documentWorkspace, toolBarImage, name, helpText, hotKey, skipIfActiveOnHotKey, toolBarConfigItems)
 {
 }
Beispiel #15
0
 public FloodToolBase(DocumentWorkspace documentWorkspace, ImageResource toolBarImage, string name, 
     string helpText, char hotKey, bool skipIfActiveOnHotKey, ToolBarConfigItems toolBarConfigItems)
     : base(documentWorkspace, toolBarImage, name, helpText, hotKey, skipIfActiveOnHotKey, 
       ToolBarConfigItems.Tolerance | toolBarConfigItems)
 {
 }
 protected AsyncSelectionToolBase(DocumentWorkspace docWorkspace, ImageResource toolBarImage, string name, string helpText, char hotKey, bool skipIfActiveOnHotKey, ToolBarConfigItems toolBarConfigItems) : base(docWorkspace, toolBarImage, name, helpText, hotKey, skipIfActiveOnHotKey, toolBarConfigItems, true)
 {
     this.beginCreateSelection = new Action(this.BeginCreateSelection);
     this.createSelectionOnBackgroundThread = new Action(this.CreateSelectionOnBackgroundThread);
 }
Beispiel #17
0
 protected BrushToolBase(DocumentWorkspace documentWorkspace, ImageResource toolBarImage, string name, string helpText, char hotKey, bool skipIfActiveOnHotKey, ToolBarConfigItems toolBarConfigItems) : base(documentWorkspace, toolBarImage, name, helpText, hotKey, skipIfActiveOnHotKey, (((toolBarConfigItems | (ToolBarConfigItems.None | ToolBarConfigItems.PenWidth)) | (ToolBarConfigItems.None | ToolBarConfigItems.PenHardness)) | ToolBarConfigItems.Antialiasing) | (ToolBarConfigItems.None | ToolBarConfigItems.SelectionRenderingQuality), false)
 {
     this.txHandler = new BitmapLayerTransactionHandler <TDerived, TChanges>((TDerived)this);
 }
Beispiel #18
0
 protected TransactedTool(DocumentWorkspace documentWorkspace, ImageResource toolBarImage, string name, string helpText, char hotKey, bool skipIfActiveOnHotKey, ToolBarConfigItems toolBarConfigItems, bool isCommitSupported) : base(documentWorkspace, toolBarImage, name, helpText, hotKey, skipIfActiveOnHotKey, toolBarConfigItems)
 {
     this.commitChangesRegion  = new ProtectedRegion("CommitChanges", ProtectedRegionOptions.ErrorOnPerThreadReentrancy);
     this.updateStatusCallback = new Action(this.UpdateStatus);
     this.state             = TransactedToolState.Inactive;
     base.IsCommitSupported = isCommitSupported;
 }
Beispiel #19
0
 public FloodToolBase(DocumentWorkspace documentWorkspace, ImageResource toolBarImage, string name,
                      string helpText, char hotKey, bool skipIfActiveOnHotKey, ToolBarConfigItems toolBarConfigItems)
     : base(documentWorkspace, toolBarImage, name, helpText, hotKey, skipIfActiveOnHotKey,
            ToolBarConfigItems.FloodMode | ToolBarConfigItems.Tolerance | toolBarConfigItems)
 {
 }
Beispiel #20
0
 public ShapeTool(DocumentWorkspace documentWorkspace,
                  ImageResource toolBarImage,
                  string name,
                  string helpText,
                  char hotKey,
                  ToolBarConfigItems toolBarConfigItemsInclude,
                  ToolBarConfigItems toolBarConfigItemsExclude)
     : base(documentWorkspace,
            toolBarImage,
            name,
            helpText,
            hotKey,
            false,
            (toolBarConfigItemsInclude |
                (ToolBarConfigItems.Brush | 
                 ToolBarConfigItems.Pen | 
                 ToolBarConfigItems.ShapeType | 
                 ToolBarConfigItems.Antialiasing | 
                 ToolBarConfigItems.AlphaBlending)) &
                ~(toolBarConfigItemsExclude))
 {
     this.mouseDown = false;
     this.points = null;
     this.cursorMouseUp = new Cursor(PdnResources.GetResourceStream("Cursors.ShapeToolCursor.cur"));
     this.cursorMouseDown = new Cursor(PdnResources.GetResourceStream("Cursors.ShapeToolCursorMouseDown.cur"));
 }
Beispiel #21
0
        protected override void OnLayout(LayoutEventArgs e)
        {
            bool plentyWidthBefore =
                (this.MainMenu.Width >= this.MainMenu.PreferredSize.Width) &&
                (this.CommonActionsStrip.Width >= this.CommonActionsStrip.PreferredSize.Width) &&
                (this.ViewConfigStrip.Width >= this.ViewConfigStrip.PreferredSize.Width) &&
                (this.ToolChooserStrip.Width >= this.ToolChooserStrip.PreferredSize.Width) &&
                (this.ToolConfigStrip.Width >= this.ToolConfigStrip.PreferredSize.Width);

            if (!plentyWidthBefore)
            {
                UI.SuspendControlPainting(this);
            }
            else
            {
                // if we don't do this then we get some terrible flickering of the right scroll arrow
                UI.SuspendControlPainting(this.documentStrip);
            }

            this.MainMenu.Location           = new Point(0, 0);
            this.MainMenu.Height             = this.MainMenu.PreferredSize.Height;
            this.ToolStripContainer.Location = new Point(0, this.MainMenu.Bottom);

            this.ToolStripContainer.RowMargin = new Padding(0);
            this.MainMenu.Padding             = new Padding(0, this.MainMenu.Padding.Top, 0, this.MainMenu.Padding.Bottom);

            this.CommonActionsStrip.Width = this.CommonActionsStrip.PreferredSize.Width;
            this.ViewConfigStrip.Width    = this.ViewConfigStrip.PreferredSize.Width;
            this.ToolChooserStrip.Width   = this.ToolChooserStrip.PreferredSize.Width;
            this.ToolConfigStrip.Width    = this.ToolConfigStrip.PreferredSize.Width;

            if (!this.computedMaxRowHeight)
            {
                ToolBarConfigItems oldTbci = this.ToolConfigStrip.ToolBarConfigItems;
                this.ToolConfigStrip.ToolBarConfigItems = ToolBarConfigItems.All;
                this.ToolConfigStrip.PerformLayout();

                this.maxRowHeight =
                    Math.Max(this.CommonActionsStrip.PreferredSize.Height,
                             Math.Max(this.ViewConfigStrip.PreferredSize.Height,
                                      Math.Max(this.ToolChooserStrip.PreferredSize.Height, this.ToolConfigStrip.PreferredSize.Height)));

                this.ToolConfigStrip.ToolBarConfigItems = oldTbci;
                this.ToolConfigStrip.PerformLayout();

                this.computedMaxRowHeight = true;
            }

            this.CommonActionsStrip.Height = this.maxRowHeight;
            this.ViewConfigStrip.Height    = this.maxRowHeight;
            this.ToolChooserStrip.Height   = this.maxRowHeight;
            this.ToolConfigStrip.Height    = this.maxRowHeight;

            this.CommonActionsStrip.Location = new Point(0, 0);
            this.ViewConfigStrip.Location    = new Point(this.CommonActionsStrip.Right, this.CommonActionsStrip.Top);
            this.ToolChooserStrip.Location   = new Point(0, this.ViewConfigStrip.Bottom);
            this.ToolConfigStrip.Location    = new Point(this.ToolChooserStrip.Right, this.ToolChooserStrip.Top);

            this.ToolStripContainer.Height =
                Math.Max(this.CommonActionsStrip.Bottom,
                         Math.Max(this.ViewConfigStrip.Bottom,
                                  Math.Max(this.ToolChooserStrip.Bottom,
                                           this.ToolConfigStrip.Visible ? this.ToolConfigStrip.Bottom : this.ToolChooserStrip.Bottom)));

            // Compute how wide the toolStripContainer would like to be
            int widthRow1 =
                this.CommonActionsStrip.Left + this.CommonActionsStrip.PreferredSize.Width + this.CommonActionsStrip.Margin.Horizontal +
                this.ViewConfigStrip.PreferredSize.Width + this.ViewConfigStrip.Margin.Horizontal;

            int widthRow2 =
                this.ToolChooserStrip.Left + this.ToolChooserStrip.PreferredSize.Width + this.ToolChooserStrip.Margin.Horizontal +
                this.ToolConfigStrip.PreferredSize.Width + this.ToolConfigStrip.Margin.Horizontal;

            int preferredMinTscWidth = Math.Max(widthRow1, widthRow2);

            // Throw in the documentListButton if necessary
            bool showDlb = this.documentStrip.DocumentCount > 0;

            this.documentListButton.Visible = showDlb;
            this.documentListButton.Enabled = showDlb;

            if (showDlb)
            {
                int documentListButtonWidth = UI.ScaleWidth(15);
                this.documentListButton.Width = documentListButtonWidth;
            }
            else
            {
                this.documentListButton.Width = 0;
            }

            // Figure out the DocumentStrip's size -- we actually make two passes at setting its Width
            // so that we can toss in the documentListButton if necessary
            if (this.documentStrip.DocumentCount == 0)
            {
                this.documentStrip.Width = 0;
            }
            else
            {
                this.documentStrip.Width = Math.Max(
                    this.documentStrip.PreferredMinClientWidth,
                    Math.Min(this.documentStrip.PreferredSize.Width,
                             ClientSize.Width - preferredMinTscWidth - this.documentListButton.Width));
            }

            this.documentStrip.Location      = new Point(ClientSize.Width - this.documentStrip.Width, 0);
            this.documentListButton.Location = new Point(this.documentStrip.Left - this.documentListButton.Width, 0);

            this.imageListMenu.Location = new Point(this.documentListButton.Left, this.documentListButton.Bottom - 1);
            this.imageListMenu.Width    = this.documentListButton.Width;
            this.imageListMenu.Height   = 0;

            this.documentListButton.Visible = showDlb;
            this.documentListButton.Enabled = showDlb;

            // Finish setting up widths and heights
            int oldDsHeight = this.documentStrip.Height;

            this.documentStrip.Height      = this.ToolStripContainer.Bottom;
            this.documentListButton.Height = this.documentStrip.Height;

            int tsWidth = ClientSize.Width - (this.documentStrip.Width + this.documentListButton.Width);

            this.MainMenu.Width           = tsWidth;
            this.ToolStripContainer.Width = tsWidth;

            this.Height = this.ToolStripContainer.Bottom;

            // Now get stuff to paint right
            this.documentStrip.PerformLayout();

            if (!plentyWidthBefore)
            {
                UI.ResumeControlPainting(this);
                Invalidate(true);
            }
            else
            {
                UI.ResumeControlPainting(this.documentStrip);
                this.documentStrip.Invalidate(true);
            }

            if (this.documentStrip.Width == 0)
            {
                this.MainMenu.Invalidate();
            }

            if (oldDsHeight != this.documentStrip.Height)
            {
                this.documentStrip.RefreshAllThumbnails();
            }

            base.OnLayout(e);
        }