Ejemplo n.º 1
0
        private void LoadAddons(ConfigGramer configuration)
        {
            addonList = new List <AddonItem>();

            ConfigGramer.Item result = configuration.GetItem(
                new ASTQualifier(ItemType.CONFIGURATION),
                new ASTQualifier(ItemType.SETTING_LIST),
                new ASTQualifier(ItemType.SETTING, "addons"),
                new ASTQualifier(ItemType.VALUE),
                new ASTQualifier(ItemType.LIST),
                new ASTQualifier(ItemType.VALUE_LIST)
                );

            if (result.IsEmpty())
            {
                return;
            }

            ConfigGramer._ValueList    valueList = (ConfigGramer._ValueList)result.value;
            List <ConfigGramer._Value> list      = valueList.Value;

            ASTQualifier[] qualifiers =
            {
                new ASTQualifier(ItemType.SETTING),
                new ASTQualifier(ItemType.VALUE),
                new ASTQualifier(ItemType.SCALAR_VALUE),
                new ASTQualifier(ItemType.STRING)
            };

            for (int i = 0; i < list.Count; i++)
            {
                ConfigGramer.Item listItem = configuration.GetItem(
                    result,
                    new ASTQualifier(ItemType.VALUE, i.ToString()),
                    new ASTQualifier(ItemType.GROUP),
                    new ASTQualifier(ItemType.SETTING_LIST)
                    );

                AddonItem addon = new AddonItem();

                qualifiers[3].itemType      = ItemType.STRING;
                qualifiers[0].itemQualifier = "name";
                addon.Name = configuration.GetItem(listItem, qualifiers).GetString();

                qualifiers[0].itemQualifier = "description";
                addon.Description           = configuration.GetItem(listItem, qualifiers).GetString();

                qualifiers[0].itemQualifier = "version";
                addon.Version = configuration.GetItem(listItem, qualifiers).GetString();

                qualifiers[0].itemQualifier = "type";
                addon.Type = configuration.GetItem(listItem, qualifiers).GetString();

                qualifiers[0].itemQualifier = "path";
                addon.Path = configuration.GetItem(listItem, qualifiers).GetString();

                qualifiers[0].itemQualifier = "enabled";
                qualifiers[3].itemType      = ItemType.BOOLEAN;
                addon.Enabled = configuration.GetItem(listItem, qualifiers).GetBoolean();

                addonList.Add(addon);
            }

            if (addonList.Count > DEFAULT_NUM_OPTIONS)
            {
                ExpandAddonListButton.Visibility = Visibility.Visible;
                ExpandAddonListButton.Content    = "▲";
                VisibleAddonList = addonList.GetRange(0, 3);
            }
            else
            {
                ExpandAddonListButton.Visibility = Visibility.Collapsed;
                VisibleAddonList = addonList;
            }

            AddonOptionsListView.ItemsSource = VisibleAddonList;
        }
Ejemplo n.º 2
0
        private void LoadPlugins(ConfigGramer configuration)
        {
            pluginList = new List <PluginItem>();

            ConfigGramer.Item result = configuration.GetItem(
                new ASTQualifier(ItemType.CONFIGURATION),
                new ASTQualifier(ItemType.SETTING_LIST),
                new ASTQualifier(ItemType.SETTING, "plugins"),
                new ASTQualifier(ItemType.VALUE),
                new ASTQualifier(ItemType.LIST),
                new ASTQualifier(ItemType.VALUE_LIST)
                );

            if (result.IsEmpty())
            {
                return;
            }

            ConfigGramer._ValueList    valueList = (ConfigGramer._ValueList)result.value;
            List <ConfigGramer._Value> list      = valueList.Value;

            ASTQualifier[] qualifiers =
            {
                new ASTQualifier(ItemType.SETTING),
                new ASTQualifier(ItemType.VALUE),
                new ASTQualifier(ItemType.SCALAR_VALUE),
                new ASTQualifier(ItemType.STRING)
            };

            for (int i = 0; i < list.Count; i++)
            {
                ConfigGramer.Item listItem = configuration.GetItem(
                    result,
                    new ASTQualifier(ItemType.VALUE, i.ToString()),
                    new ASTQualifier(ItemType.GROUP),
                    new ASTQualifier(ItemType.SETTING_LIST)
                    );

                PluginItem plugin = new PluginItem();

                qualifiers[3].itemType      = ItemType.STRING;
                qualifiers[0].itemQualifier = "name";
                plugin.Name = configuration.GetItem(listItem, qualifiers).GetString();

                qualifiers[0].itemQualifier = "description";
                plugin.Description          = configuration.GetItem(listItem, qualifiers).GetString();

                qualifiers[0].itemQualifier = "version";
                plugin.Version = configuration.GetItem(listItem, qualifiers).GetString();

                qualifiers[0].itemQualifier = "type";
                plugin.Type = configuration.GetItem(listItem, qualifiers).GetString();

                qualifiers[0].itemQualifier = "handler";
                plugin.Handler = configuration.GetItem(listItem, qualifiers).GetString();

                qualifiers[0].itemQualifier = "path";
                plugin.Path = configuration.GetItem(listItem, qualifiers).GetString();

                qualifiers[0].itemQualifier = "enabled";
                qualifiers[3].itemType      = ItemType.BOOLEAN;
                plugin.Enabled = configuration.GetItem(listItem, qualifiers).GetBoolean();
                plugin.Updated = false;

                // TODO load necessary and congress groups membership from
                pluginList.Add(plugin);
            }

            if (pluginList.Count > DEFAULT_NUM_OPTIONS)
            {
                ExpandPluginListButton.Visibility = Visibility.Visible;
                ExpandPluginListButton.Content    = "▼"; // ▲
                VisiblePluginList = pluginList.GetRange(0, 3);
            }
            else
            {
                ExpandPluginListButton.Visibility = Visibility.Collapsed;
                VisiblePluginList = pluginList;
            }

            ConfigurationSettingsGridView.ItemsSource = VisiblePluginList;
        }