Example #1
0
        /// <summary>
        /// Gets a parent chain
        /// Example: If out component is in a chain Stage-A-B-C-Component, this method returns the list of: Stage, A, B, C.
        /// </summary>
        /// <param name="component">Compo</param>
        /// <param name="reverse">Reverse the chain</param>
        /// <returns></returns>
        public static List<DisplayListMember> GetParentChain(DisplayListMember component, bool reverse)
        {
            if (null == component)
                throw new Exception("Component not defined");

            List<DisplayListMember> list = new List<DisplayListMember>();
            DisplayListMember current = component;

            //list.Add(current); // removed on 2011-09-18

            while (!(current is Stage) && null != current.Parent)
            {
                current = current.Parent;
                list.Add(current);
            }

            if (reverse)
                list.Reverse();

            return list;
        }
Example #2
0
        ///<summary>
        ///</summary>
        ///<param name="component"></param>
        ///<param name="delimiter"></param>
        ///<returns></returns>
        public static string PathToString(Component component, string delimiter)
        {
            if (string.IsNullOrEmpty(delimiter))
                delimiter = ".";

            /**
             * 1. Build path
             * */
            List<Component> list = new List<Component>();

            while (null != component)
            {
                list.Add(component);
                component = component.Parent as Component;
            }

            list.Reverse();

            string name = "";
            int count = list.Count;
            for (int i = 0; i < count; i++)
            {
                name += list[i].Name;
                if (i < count - 1)
                    name += delimiter;
            }

            return name;
        }
        /// <summary>
        /// Searches throughout ALL the stages BACK TO FRONT
        /// Starts with the stage at back and goes to the front
        /// Returns the list of filtered components under the mouse
        /// This method is used when testing for components under the mouse for mouse wheel
        /// For a mouse wheel, a single component isn't enough, since it could be already scrolled to its maximum
        /// In that case the mouse wheel gesture is passed to the component below, and so on
        /// </summary>
        /// <param name="coords"></param>
        /// <param name="filter"></param>
        /// <param name="stopOnDisabled"></param>
        /// <param name="stopOnInvisible"></param>
        /// <returns></returns>
        internal static List<DisplayListMember> GetComponentStackUnderCoordinatesOnAllStages(Point coords, Filter filter, bool stopOnDisabled, bool stopOnInvisible)
        {
            if (null == StageListDesc)
                return null; // could be null on recompile //throw new Exception("StageListDesc is null"); //return null;

            List<DisplayListMember> components = new List<DisplayListMember>();

            /* Note: Using ascending order (negative values in ZIndex have priority)
             * However, we are reversing the order at the end of this call, so we'll use the descending list here (back to front) 
             */
            int stageCount = StageListDesc.Count;
            int count = 0;

            // search from back to front
            while (count < stageCount)
            {
                Stage stage = StageListDesc[count];
                count++;

                if (null != ExcludedStages && ExcludedStages.Contains(stage)) // skip excluded stages
                    continue;

                // search the component on a stage
                GetComponentStackUnderCoordinates(stage, coords, filter, stopOnDisabled, stopOnInvisible, ref components);
            }

#if DEBUG
            if (DebugMode)
            {
                Debug.Log(string.Format("ClickManager: GetComponentUnderCoordinatesOnAllStages returns [{0}] components", components.Count));
            }
#endif

            components.Reverse();

            return components;
        }