Exemple #1
0
        public void OnCreate(DOCKLET_STATIC_DATA data, String ini, String iniGroup)
        {
            ODConsole.Initialize();

            docklet = new Docklet(data);

            docklet.Label     = "Dummy Docklet";
            docklet.ImageFile = "Dummy.png";

            #region Context Menu

            ContextMenu menu   = new ContextMenu();
            MenuItem    config = new MenuItem("Configure", onMenuConfigure);

            MenuItem testmenu = new MenuItem("Test Menu");
            testmenu.MenuItems.Add("Item 1", OnClickedItem1);
            testmenu.MenuItems.Add("Item 2", OnClickedItem2);

            MenuItem browse = new MenuItem("Browse", onBrowseForImage);

            menu.MenuItems.Add(config);
            menu.MenuItems.Add(browse);
            menu.MenuItems.Add(testmenu);

            docklet.ContextMenu = menu;

            #endregion
        }
Exemple #2
0
        public void OnCreate(DOCKLET_STATIC_DATA data, String ini, String iniGroup)
        {
            ODConsole.Initialize();

            docklet = new Docklet(data);

            docklet.Label     = "Featured Skins Docklet";
            docklet.ImageFile = "FeaturedSkins.png";

            #region Global Settings
            // Initialize docklet data
            dockletData = new DockletData();
            dockletData.Applications = new ArrayList();
            dockletData.index        = NO_VALUE;      // No application selected

            // Read global settings from ini file
            IniReader iniReader = new IniReader(docklet.RootFolder + docklet.RelativeFolder + "docklet.ini");

            ArrayList apps = iniReader.GetSectionNames();
            foreach (String app in apps)
            {
                if (app.CompareTo("docklet") == 0)
                {
                    continue;
                }

                Application application = new Application();
                // Name
                application.name = app;
                // Address
                application.address = new Uri(iniReader.ReadString(application.name, "address", ""));
                // Type
                string type = iniReader.ReadString(application.name, "type", "");
                switch (type)
                {
                default:
                    application.type = ApplicationType.INVALID;
                    break;

                case "ini":
                    application.type = ApplicationType.INI;
                    break;

                case "csv":
                    application.type = ApplicationType.CSV;
                    break;
                }
                application.data = new ApplicationData();

                dockletData.Applications.Add(application);
            }
            #endregion

            #region Saved Settings
            if (ini != String.Empty && iniGroup != String.Empty)
            {
                // Reuse the INIReader
                iniReader.Filename = ini;

                // Read saved app index
                dockletData.index    = iniReader.ReadInteger(iniGroup, "AppIndex", NO_VALUE);
                dockletData.cacheDir = iniReader.ReadString(iniGroup, "CacheDir", String.Empty);

                if (dockletData.index > dockletData.Applications.Count)
                {
                    dockletData.index = NO_VALUE;
                }
            }
            #endregion

            #region Context Menu

            ContextMenu menu        = new ContextMenu();
            MenuItem    appsMenu    = new MenuItem("Applications");
            MenuItem    refreshMenu = new MenuItem("Refresh");
            refreshMenu.Enabled = false;

            foreach (Application app in dockletData.Applications)
            {
                appsMenu.MenuItems.Add(new MenuItem(app.name, new EventHandler(onSelectApp)));
                if (app.type == ApplicationType.INVALID)
                {
                    appsMenu.MenuItems[appsMenu.MenuItems.Count - 1].Enabled = false;
                }
            }

            if (dockletData.index != NO_VALUE)
            {
                appsMenu.MenuItems[dockletData.index].Checked = true;
                refreshMenu.Enabled = true;
            }

            menu.MenuItems.Add(appsMenu);
            menu.MenuItems.Add(refreshMenu);

            // Show the menu
            docklet.ContextMenu = menu;

            #endregion

            // Get temporary directory for this session
            if (dockletData.cacheDir == String.Empty || dockletData.cacheDir == null)
            {
                Guid guid = Guid.NewGuid();
                dockletData.cacheDir = guid.ToString();
            }

            // Load Application Data
            if (dockletData.index != NO_VALUE)
            {
                updateThread = new Thread(new ThreadStart(UpdateData));
                updateThread.Start();
            }
        }