private void BindGestures()
        {
            // Clear existing gestures in list
            lstAvailableGestures.Items.Clear();

            // Get all available gestures from gesture manager
            IEnumerable <string> results = Gestures.GestureManager.Instance.Gestures.OrderBy(g => g.Name).GroupBy(g => g.Name).Select(g => g.First().Name);

            foreach (string gestureName in results)
            {
                // Create new listviewitem to represent gestures, create a thumbnail of the latest version of each gesture
                // and add it to image list, then to the output list
                ListViewItem newItem = new ListViewItem(gestureName);
                imgGestures.Images.Add(GestureThumbnail.Create(Gestures.GestureManager.Instance.GetNewestGestureSample(gestureName).Points, imgGestures.ImageSize, true));
                newItem.ImageIndex = imgGestures.Images.Count - 1;
                lstAvailableGestures.Items.Add(newItem);
            }
        }
示例#2
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);
            }
        }
 protected void picGestureThumbnail_Paint(object sender, PaintEventArgs e)
 {
     // Draw rounded rectangle and gesture thumbnail
     ImageHelper.DrawRoundedRectangle(e.Graphics, new Rectangle(0, 0, picGestureThumbnail.ClientSize.Width - 1, picGestureThumbnail.ClientSize.Height - 1), 11, new Pen(SystemColors.ControlDark, 1), Color.White);
     e.Graphics.DrawImage(GestureThumbnail.Create(_CapturedPoints, 75, 75, true), 5, 5);
 }