Exemplo n.º 1
0
        protected override void OnChecked(RoutedEventArgs e)
        {
            base.OnChecked(e);
            ConfigMenuRootPanel root_pan = (this.Parent as ConfigMenuPanel)?.Parent as ConfigMenuRootPanel;

            if (root_pan == null)
            {
                return;
            }

            int idx = root_pan.Children.IndexOf(this.Parent as ConfigMenuPanel);

            int i;

            for (i = 0; i < idx; i++)
            {
                ConfigMenuPanel pan = root_pan.Children[i] as ConfigMenuPanel;
                if (pan != null)
                {
                    pan.VerticalAlignment = VerticalAlignment.Top;
                }
                pan.IsChecked = false;
            }
            {
                ConfigMenuPanel pan = root_pan.Children[i++] as ConfigMenuPanel;
                if (pan != null)
                {
                    pan.VerticalAlignment = VerticalAlignment.Stretch;
                }
            }
            for (; i < root_pan.Children.Count; i++)
            {
                ConfigMenuPanel pan = root_pan.Children[i] as ConfigMenuPanel;
                if (pan != null)
                {
                    pan.VerticalAlignment = VerticalAlignment.Bottom;
                }
                pan.IsChecked = false;
            }

            ConfigMenuTreeView detailView = (this.Parent as ConfigMenuPanel)?.DetailView;

            if (detailView != null)
            {
                //if(root_pan != null)
                //{
                //	detailView.Margin = new Thickness(0, HEIGHT * (idx + 1), 0, HEIGHT * (root_pan.Children.Count - (idx + 1)));
                //}
                detailView.Visibility = Visibility.Visible;
            }
        }
Exemplo n.º 2
0
        public ConfigMenuRootPanel()
        {
            this.Background = null;

            panFileConfig = new ConfigMenuPanel()
            {
                Header = "File Config"
            };
            this.Children.Add(panFileConfig);

            panSamConfig = new ConfigMenuPanel()
            {
                Header = "Sam Config"
            };
            this.Children.Add(panSamConfig);

            panTailConfig = new ConfigMenuPanel()
            {
                Header = "Tail Config"
            };
            this.Children.Add(panTailConfig);

            for (int i = 0; i < this.Children.Count; i++)
            {
                ConfigMenuPanel btn = this.Children[i] as ConfigMenuPanel;
                if (btn != null)
                {
                    btn.Margin = new Thickness(0, i * ConfigMenuPanel.HEIGHT, 0, (this.Children.Count - (i + 1)) * ConfigMenuPanel.HEIGHT);
                }
            }

            if (this?.Children != null && this.Children.Count > 0 &&
                (this.Children[0] as ConfigMenuPanel) != null)
            {
                (this.Children[0] as ConfigMenuPanel).IsChecked = true;
            }

            //this.IsVisibleChanged += (sender, e) =>
            //{
            //	if(this.IsVisible)
            //		Refresh();
            //};
        }