private AppController()
        {
            snarlSentNotifications = new Dictionary<int, string>();
            snarl = new Snarl.SnarlInterface();
            snarl.CallbackEvent += new SnarlInterface.CallbackEventHandler(snarl_CallbackEvent);
            snarl.GlobalSnarlEvent +=new SnarlInterface.GlobalEventHandler(snarl_GlobalSnarlEvent);

            watcher = new System.IO.FileSystemWatcher();
            lastNotification = DateTime.Now;

            IconPath = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\FileSystemSnarl.ico";
            if (!System.IO.File.Exists(IconPath))
            {
                throw new Exception("Corrupt installation - missing icon for tray area and Snarl notifications which should be at " + IconPath);
            }
        }
        private AppController()
        {
            snarlSentNotifications = new Dictionary <int, string>();
            snarl = new Snarl.SnarlInterface();
            snarl.CallbackEvent    += new SnarlInterface.CallbackEventHandler(snarl_CallbackEvent);
            snarl.GlobalSnarlEvent += new SnarlInterface.GlobalEventHandler(snarl_GlobalSnarlEvent);

            watcher          = new System.IO.FileSystemWatcher();
            lastNotification = DateTime.Now;

            IconPath = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\FileSystemSnarl.ico";
            if (!System.IO.File.Exists(IconPath))
            {
                throw new Exception("Corrupt installation - missing icon for tray area and Snarl notifications which should be at " + IconPath);
            }
        }
Exemple #3
0
            internal SnarlCallbackNativeWindow(SnarlInterface parent, IntPtr windowHandle)
            {
                this.parent        = parent;
                snarlGlobalMessage = SnarlInterface.Broadcast();

                if (windowHandle == IntPtr.Zero)
                {
                    hasCreatedCallbackWindow = true;

                    CreateParams cp = new CreateParams();
                    cp.Caption = GetType().FullName;
                    CreateHandle(cp);
                }
                else
                {
                    hasCreatedCallbackWindow = false;
                    AssignHandle(windowHandle);
                }
            }
Exemple #4
0
            internal SnarlCallbackNativeWindow(SnarlInterface parent, IntPtr windowHandle)
            {
                this.parent = parent;
                snarlGlobalMessage = SnarlInterface.Broadcast();

                if (windowHandle == IntPtr.Zero)
                {
                    hasCreatedCallbackWindow = true;

                    CreateParams cp = new CreateParams();
                    cp.Caption = GetType().FullName;
                    CreateHandle(cp);
                }
                else
                {
                    hasCreatedCallbackWindow = false;
                    AssignHandle(windowHandle);
                }
            }
 void snarl_GlobalSnarlEvent(SnarlInterface sender, SnarlInterface.GlobalEventArgs args)
 {
     if (args.GlobalEvent == SnarlInterface.GlobalEvent.SnarlLaunched && isRunning)
     {
         RegisterWithSnarl();
     }
 }
        void snarl_CallbackEvent(SnarlInterface sender, SnarlInterface.CallbackEventArgs args)
        {
            switch (args.SnarlEvent)
            {
                case SnarlInterface.SnarlStatus.NotifyAction:
                    HandleActionCallback(args.Parameter, args.MessageToken);
                    break;

                case SnarlInterface.SnarlStatus.CallbackInvoked:
                case SnarlInterface.SnarlStatus.CallbackClosed:
                case SnarlInterface.SnarlStatus.CallbackMiddleClick:
                case SnarlInterface.SnarlStatus.CallbackTimedOut:
                    if (snarlSentNotifications.ContainsKey(args.MessageToken))
                    {
                        try
                        {
                            snarlSentNotifications.Remove(args.MessageToken);
                        }
                        catch { }
                    }
                    break;
            }
        }
        public void RegisterWithSnarl()
        {
            if (Properties.Settings.Default.snarlLocal)
            {
                if (snarl == null)
                {
                    snarl = new SnarlInterface();
                    snarl.CallbackEvent += new SnarlInterface.CallbackEventHandler(snarl_CallbackEvent);
                    snarl.GlobalSnarlEvent += new SnarlInterface.GlobalEventHandler(snarl_GlobalSnarlEvent);
                }
                snarl.RegisterWithEvents("FileSystemSnarl", "FileSystemSnarl", IconPath,"fgvh54546bg54", IntPtr.Zero, null);

                snarl.AddClass("File has been created", "File has been created");
                snarl.AddClass("File has been changed", "File has been changed");
                snarl.AddClass("File has been renamed", "File has been renamed");
                snarl.AddClass("File has been deleted", "File has been deleted");
            }
            else
            {
                snarlNetwork = new SnarlNetwork.SnarlNetwork(Properties.Settings.Default.snpIp, Properties.Settings.Default.snpPort);
                snarlNetwork.register(Properties.Settings.Default.snpIp, Properties.Settings.Default.snpPort, "FileSystemSnarl");
                snarlNetwork.addClass(Properties.Settings.Default.snpIp, Properties.Settings.Default.snpPort, "FileSystemSnarl", "File has been created", "File has been created");
                snarlNetwork.addClass(Properties.Settings.Default.snpIp, Properties.Settings.Default.snpPort, "FileSystemSnarl", "File has been changed", "File has been changed");
                snarlNetwork.addClass(Properties.Settings.Default.snpIp, Properties.Settings.Default.snpPort, "FileSystemSnarl", "File has been renamed", "File has been renamed");
                snarlNetwork.addClass(Properties.Settings.Default.snpIp, Properties.Settings.Default.snpPort, "FileSystemSnarl", "File has been deleted", "File has been deleted");
            }
        }