Beispiel #1
0
        /// <summary>
        /// Closes the top menu
        /// </summary>
        protected void CollapseUp()
        {
            Menu top = ParentMenu.GetTop();

            if (top != null)
            {
                top.CloseChild();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Opens a child menu item
        /// </summary>
        /// <param name="item">The item to open</param>
        /// <param name="openUnderneath">Indicates whether to display below or to the right</param>
        internal void OpenChild(MenuItem item, bool openUnderneath)
        {
            Menu  content = (Menu)item.Content;
            Point p;

            if (_current != null)
            {
                _current.Hide();
                _current = null;
            }

            if (content != null)
            {
                p = item.TransformToVisual(ElementChildren).Transform((openUnderneath ? new Point(0, item.RenderSize.Height - 1) : new Point(item.RenderSize.Width - 1, 0)));
                content.SetValue(Canvas.LeftProperty, p.X);
                content.SetValue(Canvas.TopProperty, p.Y);
                //250 ms delay loop
                int dwStartTime = System.Environment.TickCount;

                while (true)
                {
                    if (System.Environment.TickCount - dwStartTime > 250)
                    {
                        break;                                                   //1000 milliseconds
                    }
                }
                //delay loop end
                if (!ElementChildren.Children.Contains(content))
                {
                    ElementChildren.Children.Add(content);
                }
                content.ClearSelection();
                content.CloseChild();
                content.Show();
                _current = content;
            }
        }