Exemple #1
0
        public static int ImportGestures(this GestureManager gestureManager, IEnumerable <IGesture> gestures, IEnumerable <IApplication> relatedApplications)
        {
            int count = 0;

            if (gestures == null)
            {
                return(count);
            }

            foreach (IGesture newGesture in gestures)
            {
                string matchName = gestureManager.GetMostSimilarGestureName(newGesture);
                if (!string.IsNullOrEmpty(matchName))
                {
                    if (relatedApplications != null && newGesture.Name != matchName)
                    {
                        relatedApplications.RenameGestures(newGesture.Name, matchName);
                    }
                }
                else
                {
                    if (gestureManager.GestureExists(newGesture.Name))
                    {
                        string newName = gestureManager.GetNewGestureName();
                        if (relatedApplications != null)
                        {
                            relatedApplications.RenameGestures(newGesture.Name, newName);
                        }
                        newGesture.Name = newName;
                    }
                    gestureManager.AddGesture(newGesture);
                    count++;
                }
            }

            if (count != 0)
            {
                gestureManager.SaveGestures();
            }
            return(count);
        }