CropperExt.cs :  » GUI » Cropper » NAMESPACE » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » GUI » Cropper 
Cropper » NAMESPACE » CropperExt.cs
#region Using Directives

using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Windows.Forms;
using Fusion8Design.Cropper.Extensibility;

#endregion

namespace NAMESPACE{
    /// <summary>
    /// This is a sample class that you can use as a starting point for new Cropper plug-ins.
    /// </summary>
    public class [OUTPUTFORMAT] : IPersistableImageFormat
    {
        // A referance to the host application. Subscribe to its events to be notified
        // when a capture has been started or completed
        private IPersistableOutput output;

        // The event that you raise when a user clicks your format in the output menu.
        // The host then loads your format as the active plugin.
        public event ImageFormatClickEventHandler ImageFormatClick;

        // The extension is used when getting the next available file name and is
        // the extension that the file stream is created with.
        public string Extension
        {
            get { return "Exension"; }
        }

        // The description is displayed on the crop form when your format is chosen.
        // Space may be limited when the form is sized small, so keep it short.
        public string Description
        {
            get { return "My Format"; }
        }

        // Create your outputs menu item here. You may add submenus to your output item if needed.
        // See the source code for the jpg format for an example.
        public MenuItem Menu
        {
            get
            {
                MenuItem menuItem = new MenuItem();
                menuItem.RadioCheck = true;
                menuItem.Text = Description;
                menuItem.Click += MenuClick;
                return menuItem;
            }
        }

        // A sample event handler when your menu item is clicked. Create a new ImageFormatEventArgs
        // and then raise the ImageFormatClick event. The host will respond by loading your plugin.
        private void MenuClick(object sender, EventArgs e)
        {
            ImageFormatEventArgs formatEvents = new ImageFormatEventArgs();
            formatEvents.ClickedMenuItem = (MenuItem)sender;
            formatEvents.ImageOutputFormat = this;
            OnImageFormatClick(sender, formatEvents);
        }

        // Raises the ImageFormatClick event if there is a listener.
        private void OnImageFormatClick(object sender, ImageFormatEventArgs e)
        {
            if (ImageFormatClick != null)
                ImageFormatClick(sender, e);
        }

        // The method called by the host when your plugin is loaded. You should subscribe
        // to any events you need in this method.
        public void Connect(IPersistableOutput persistableOutput)
        {
            if(persistableOutput == null)
                throw new ArgumentNullException("persistableOutput");

            output = persistableOutput;
            output.ImageCaptured += ImageCaptured;
        }

        // The method that is called when your format is unloaded. You should unsubscribe
        // from any events you subscribed to in the Connect method.
        public void Disconnect()
        {
            output.ImageCaptured -= ImageCaptured;
        }

        // A sample event handler that retrieves a stream for the full and thumbnailed images using the
        // stream handler delegate. Using the delegate causes the host to manage the stream and its cleanup,
        // freeing the plugin from that responsibility.
        private void ImageCaptured(object sender, ImageCapturedEventArgs e)
        {
            output.FetchOutputStream(SaveImag), e.ImageNames.FullSize, e.FullSizeImage);

            if(e.IsThumbnailed)
            {
                output.FetchOutputStream(SaveImage, e.ImageNames.Thumbnail, e.ThumbnailImage);
            }

            // If you need to manage the image retrieval yourself, such as adding multiple images to a stream
            // or building an animated gif for instance, you can use the ImageHandler delegate and pass it
            // a callback that takes an image as its only parameter. See the avi plugin source in the
            // Cropper Plugin project.
        }

        // A sample call back method for saving the captured image. This is passed to the 
        // StreamHandler delegate in the ImageCaptured method above.
        private void SaveImage(Stream stream, Image image)
        {
            image.Save(stream, ImageFormat.Bmp);
        }
    }
}
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.