Exemplo n.º 1
0
        /// <summary>
        ///     Switches the group of a specified index
        /// </summary>
        /// <param name="key">The Input-Key to the key you want moved</param>
        /// <param name="targetGroup">The Index of the Group you want the key moved to</param>
        public void SwitchGroup(Key key, int targetGroup)
        {
            lock (ThreadLock)
            {
                if (key.Group >= Groups.Count || key.Member >= Groups[key.Group].Members.Count || targetGroup >= Groups.Count)
                {
                    return;
                }

                //Grab the Input we want moved
                OpenTextInput input = Groups[key.Group].Members[key.Member];


                //Update the Index of the Input
                input.Index = Groups[targetGroup].Members.Count;

                //Add it to the desired group
                Groups[targetGroup].Members.Add(input);

                {
                    //Check if this is in favorites
                    string str = $"{key.Group}-{key.Member}";
                    if (FavoriteMembers.Contains(str))
                    {
                        FavoriteMembers.Remove(str);
                        str = $"{targetGroup}-{input.Index}";
                        FavoriteMembers.Add(str);
                    }
                }
                //Remove it from its old location
                Groups[key.Group].Members.RemoveAt(key.Member);


                //Remove the Group if it is empty
                if (key.Group != 0 && Groups[key.Group].Members.Count < 1)
                {
                    {
                        //Check if this is in favorites
                        if (FavoriteGroups.Contains(key.Group))
                        {
                            FavoriteGroups.Remove(key.Group);
                        }
                    }
                    Groups.RemoveAt(key.Group);
                    UpdateGroupIndexes();
                }
                else //Otherwise update the Member Indexes
                {
                    UpdateMemberIndexes(key.Group);
                }
            }

            EventStream();
        }
Exemplo n.º 2
0
        public void ArchiveGroup(int group)
        {
            lock (ThreadLock)
            {
                if (group >= Groups.Count)
                {
                    return;
                }

                for (int i = Groups[group].Members.Count - 1; i >= 0; i--)
                {
                    Key key = new Key
                    {
                        Group  = group,
                        Member = i
                    };

                    ArchiveInput(key);
                }

                int prev = Groups[group].Column;
                {
                    //Check if this is in favorites
                    if (FavoriteGroups.Contains(group))
                    {
                        FavoriteGroups.Remove(group);
                    }
                }

                Groups.RemoveAt(group);
                if (Groups.All(check => check.Column != prev))
                {
                    RemoveColumn(group);
                }
                UpdateGroupIndexes();
            }

            EventStream();
        }
Exemplo n.º 3
0
        public void SwitchGroup(IEnumerable <Key> keys, int target)
        {
            if (target >= Groups.Count)
            {
                return;
            }

            foreach (Key key in keys)
            {
                if (key.Group == target || key.Group >= Groups.Count || key.Member >= Groups[key.Group].Members.Count)
                {
                    continue;
                }

                //Grab the Input we want moved
                OpenTextInput input = Groups[key.Group].Members[key.Member];

                //Update the Index of the Input
                input.Index = Groups[target].Members.Count;

                lock (ThreadLock)
                {
                    {
                        //Check if this is in favorites
                        string str = $"{key.Group}-{key.Member}";
                        if (FavoriteMembers.Contains(str))
                        {
                            FavoriteMembers.Remove(str);
                            str = $"{target}-{input.Index}";
                            FavoriteMembers.Add(str);
                        }
                    }
                    //Remove it from its old location
                    Groups[key.Group].Members.RemoveAt(key.Member);

                    //Add it to the desired group
                    Groups[target].Members.Add(input);
                }
            }

            for (int i = 1; i < Groups.Count; i++)
            {
                if (Groups[i].Members.Count < 1) //TODO: Keep Previously Empty Groups?
                {
                    int prev = Groups[i].Column;
                    {
                        //Check if this is in favorites
                        if (FavoriteGroups.Contains(i))
                        {
                            FavoriteGroups.Remove(i);
                        }
                    }
                    Groups.RemoveAt(i);
                    if (Groups.All(check => check.Column != prev))
                    {
                        RemoveColumn(prev);
                    }

                    i--;
                }
            }

            UpdateGroupIndexes();

            foreach (OpenTextGroup group in Groups)
            {
                lock (ThreadLock)
                {
                    UpdateMemberIndexes(group.Index);
                }
            }

            EventStream();
        }