Exemplo n.º 1
0
        public MainForm(CopyDataTransport dataTransport)
        {
            instance = this;
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();
            lang = Language.GetInstance();
            IniConfig.IniChanged += new FileSystemEventHandler(ReloadConfiguration);

            // Make sure all hotkeys pass this window!
            HotkeyControl.RegisterHotkeyHWND(this.Handle);
            RegisterHotkeys();

            tooltip = new ToolTip();

            UpdateUI();
            InitializeQuickSettingsMenu();

            captureForm = new CaptureForm();

            // Load all the plugins
            PluginHelper.instance.LoadPlugins(this, captureForm);
            SoundHelper.Initialize();

            // Enable the Greenshot icon to be visible, this prevents Problems with the context menu
            notifyIcon.Visible = true;

            // Create a new instance of the class: copyData = new CopyData();
            copyData = new CopyData();

            // Assign the handle:
            copyData.AssignHandle(this.Handle);
            // Create the channel to send on:
            copyData.Channels.Add("Greenshot");
            // Hook up received event:
            copyData.CopyDataReceived += new CopyDataReceivedEventHandler(CopyDataDataReceived);

            if (dataTransport != null)
            {
                HandleDataTransport(dataTransport);
            }
            ClipboardHelper.RegisterClipboardViewer(this.Handle);
        }
Exemplo n.º 2
0
        public MainForm(CopyDataTransport dataTransport)
        {
            instance = this;

            // Make sure we never capture the mainform
            WindowDetails.RegisterIgnoreHandle(this.Handle);
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();
            this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();

            IniConfig.IniChanged += new FileSystemEventHandler(ReloadConfiguration);

            tooltip = new ToolTip();

            UpdateUI();

            // Do loading on a different Thread to shorten the startup
            Thread pluginInitThread = new Thread(delegate()
            {
                // Load all the plugins
                PluginHelper.instance.LoadPlugins(this);

                // Check destinations, remove all that don't exist
                foreach (string destination in conf.OutputDestinations.ToArray())
                {
                    if (DestinationHelper.GetDestination(destination) == null)
                    {
                        conf.OutputDestinations.Remove(destination);
                    }
                }

                // we should have at least one!
                if (conf.OutputDestinations.Count == 0)
                {
                    conf.OutputDestinations.Add(Destinations.EditorDestination.DESIGNATION);
                }
                BeginInvoke((MethodInvoker) delegate
                {
                    // Do after all plugins & finding the destination, otherwise they are missing!
                    InitializeQuickSettingsMenu();
                });
            });

            pluginInitThread.Name         = "Initialize plug-ins";
            pluginInitThread.IsBackground = true;
            pluginInitThread.Start();

            SoundHelper.Initialize();

            // Create a new instance of the class: copyData = new CopyData();
            copyData = new CopyData();

            // Assign the handle:
            copyData.AssignHandle(this.Handle);
            // Create the channel to send on:
            copyData.Channels.Add("Greenshot");
            // Hook up received event:
            copyData.CopyDataReceived += new CopyDataReceivedEventHandler(CopyDataDataReceived);

            if (dataTransport != null)
            {
                HandleDataTransport(dataTransport);
            }
        }