Example #1
0
        private void AddActionsToGroup(ListViewGroup Group, IEnumerable <IAction> Actions)
        {
            Size sizThumbSize  = new Size(45, 45);
            Size sizOutputSize = new Size(62, 52);

            // Loop through each global action
            foreach (Applications.Action currentAction in Actions)
            {
                // Ensure this action has a plugin
                if (!Plugins.PluginManager.Instance.PluginExists(currentAction.PluginClass, currentAction.PluginFilename))
                {
                    continue;
                }

                // Get plugin for this action
                IPluginInfo pluginInfo = Plugins.PluginManager.Instance.FindPluginByClassAndFilename(currentAction.PluginClass, currentAction.PluginFilename);

                // Feed settings to plugin
                pluginInfo.Plugin.Deserialize(currentAction.ActionSettings);

                // Get handle of action gesture
                IGesture actionGesture = Gestures.GestureManager.Instance.GetNewestGestureSample(currentAction.GestureName);

                // Continue if we don't have a gesture
                if (actionGesture == null)
                {
                    continue;
                }

                imgGestureThumbnails.Images.Add(ImageHelper.AlignImage(GestureThumbnail.Create(actionGesture.Points, sizThumbSize, true), sizOutputSize, ContentAlignment.MiddleCenter));

                ListViewItem newItem = new ListViewItem(Group);
                newItem.Text       = !String.IsNullOrEmpty(currentAction.Name) ? currentAction.Name : pluginInfo.Plugin.Name;
                newItem.ImageIndex = imgGestureThumbnails.Images.Count - 1;

                ListViewItem.ListViewSubItem subItem = new ListViewItem.ListViewSubItem();
                subItem.Text = pluginInfo.Plugin.Description;
                newItem.SubItems.Add(subItem);

                newItem.Group = Group;
                lstAvailableActions.Items.Add(newItem);
            }
        }