Esempio n. 1
0
        public ImageEditorForm(Surface surface, bool outputMade)
        {
            //
             // The InitializeComponent() call is required for Windows Forms designer support.
             //
             InitializeComponent();
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ImageEditorForm));
             Image backgroundForTransparency = (Image)resources.GetObject("checkerboard.Image");
             surface.TransparencyBackgroundBrush = new TextureBrush(backgroundForTransparency, WrapMode.Tile);
             // Make sure Double-buffer is enabled
             SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);

             // Intial "saved" flag for asking if the image needs to be save
             surface.Modified = !outputMade;

             // resizing the panel is futile, since it is docked. however, it seems
             // to fix the bug (?) with the vscrollbar not being able to shrink to
             // a smaller size than the initial panel size (as set by the forms designer)
             panel1.Height = 10;

             // init surface
             this.surface = surface;
             surface.TabStop = false;

             surface.MovingElementChanged += delegate { refreshEditorControls(); };
             surface.DrawingModeChanged += new SurfaceDrawingModeEventHandler(surface_DrawingModeChanged);
             surface.SurfaceSizeChanged += new SurfaceSizeChangeEventHandler(SurfaceSizeChanged);

             this.fontFamilyComboBox.PropertyChanged += new PropertyChangedEventHandler(FontPropertyChanged);

             surface.FieldAggregator.FieldChanged += new FieldChangedEventHandler(FieldAggregatorFieldChanged);
             obfuscateModeButton.DropDownItemClicked += FilterPresetDropDownItemClicked;
             highlightModeButton.DropDownItemClicked += FilterPresetDropDownItemClicked;

             panel1.Controls.Add(surface);

             lang = Language.GetInstance();

             // Make sure the editor is placed on the same location as the last editor was on close
             WindowDetails thisForm = new WindowDetails(this.Handle);
             thisForm.SetWindowPlacement(editorConfiguration.GetEditorPlacement());

             SurfaceSizeChanged(this.Surface);

             updateUI();
             IniConfig.IniChanged += new FileSystemEventHandler(ReloadConfiguration);

             bindFieldControls();
             refreshEditorControls();
             // Workaround: As the cursor is (mostly) selected on the surface a funny artifact is visible, this fixes it.
             hideToolstripItems();

             toolbarButtons = new ToolStripButton[] { btnCursor, btnRect, btnEllipse, btnText, btnLine, btnArrow, btnFreehand, btnHighlight, btnObfuscate, btnCrop };
             //toolbarDropDownButtons = new ToolStripDropDownButton[]{btnBlur, btnPixeliate, btnTextHighlighter, btnAreaHighlighter, btnMagnifier};

             PluginHelper.instance.CreateImageEditorOpenEvent(this);
             pluginToolStripMenuItem.Visible = pluginToolStripMenuItem.DropDownItems.Count > 0;

             emailToolStripMenuItem.Enabled = EmailConfigHelper.HasMAPI() || EmailConfigHelper.HasOutlook();

             // Workaround: for the MouseWheel event which doesn't get to the panel
             this.MouseWheel += new MouseEventHandler(PanelMouseWheel);
        }
        public ImageEditorForm(ISurface iSurface, bool outputMade)
        {
            // init surface
            this.surface = iSurface as Surface;
            editorList.Add(this);
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();
            this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();

            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ImageEditorForm));
            Image backgroundForTransparency = GreenshotPlugin.Core.GreenshotResources.getImage("Checkerboard.Image");
            surface.TransparencyBackgroundBrush = new TextureBrush(backgroundForTransparency, WrapMode.Tile);
            // Make sure Double-buffer is enabled
            SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);

            // Intial "saved" flag for asking if the image needs to be save
            surface.Modified = !outputMade;

            // resizing the panel is futile, since it is docked. however, it seems
            // to fix the bug (?) with the vscrollbar not being able to shrink to
            // a smaller size than the initial panel size (as set by the forms designer)
            panel1.Height = 10;

            surface.TabStop = false;

            surface.MovingElementChanged += delegate { refreshEditorControls(); };
            surface.DrawingModeChanged += new SurfaceDrawingModeEventHandler(surface_DrawingModeChanged);
            surface.SurfaceSizeChanged += new SurfaceSizeChangeEventHandler(SurfaceSizeChanged);
            surface.SurfaceMessage += new SurfaceMessageEventHandler(SurfaceMessageReceived);

            this.fontFamilyComboBox.PropertyChanged += new PropertyChangedEventHandler(FontPropertyChanged);

            surface.FieldAggregator.FieldChanged += new FieldChangedEventHandler(FieldAggregatorFieldChanged);
            obfuscateModeButton.DropDownItemClicked += FilterPresetDropDownItemClicked;
            highlightModeButton.DropDownItemClicked += FilterPresetDropDownItemClicked;

            panel1.Controls.Add(surface);

            // Make sure the editor is placed on the same location as the last editor was on close
            WindowDetails thisForm = new WindowDetails(this.Handle);
            thisForm.SetWindowPlacement(editorConfiguration.GetEditorPlacement());

            SurfaceSizeChanged(this.Surface);

            updateUI();
            IniConfig.IniChanged += new FileSystemEventHandler(ReloadConfiguration);

            bindFieldControls();
            refreshEditorControls();
            // Workaround: As the cursor is (mostly) selected on the surface a funny artifact is visible, this fixes it.
            hideToolstripItems();

            toolbarButtons = new ToolStripButton[] { btnCursor, btnRect, btnEllipse, btnText, btnLine, btnArrow, btnFreehand, btnHighlight, btnObfuscate, btnCrop };
            //toolbarDropDownButtons = new ToolStripDropDownButton[]{btnBlur, btnPixeliate, btnTextHighlighter, btnAreaHighlighter, btnMagnifier};

            pluginToolStripMenuItem.Visible = pluginToolStripMenuItem.DropDownItems.Count > 0;

            // Workaround: for the MouseWheel event which doesn't get to the panel
            this.MouseWheel += new MouseEventHandler(PanelMouseWheel);

            // Create export buttons
            foreach (IDestination destination in DestinationHelper.GetAllDestinations())
            {
                if (destination.Priority <= 2)
                {
                    continue;
                }
                if (!destination.isActive)
                {
                    continue;
                }
                if (destination.DisplayIcon == null)
                {
                    continue;
                }
                try
                {
                    AddDestinationButton(destination);
                }
                catch (Exception addingException)
                {
                    LOG.WarnFormat("Problem adding destination {0}", destination.Designation);
                    LOG.Warn("Exception: ", addingException);
                }
            }
        }