示例#1
0
        internal static IOBJ GetStackFlatFromXml(GasPage basepage, XmlElement xmlelement)
        {
            var stackflat = new StackFlat();

            //Name
            stackflat.Name = xmlelement.GetAttribute("Name");
            //Width
            {
                var value = xmlelement.GetAttribute("Width");
                if (!string.IsNullOrEmpty(value))
                {
                    stackflat.Width = Convert.ToDouble(value);
                }
            }
            //Height
            {
                var value = xmlelement.GetAttribute("Height");
                if (!string.IsNullOrEmpty(value))
                {
                    stackflat.Height = Convert.ToDouble(value);
                }
            }
            //Horizontal
            {
                var value = xmlelement.GetAttribute("Horizontal");
                if (!string.IsNullOrEmpty(value))
                {
                    if (value.ToString() == "center")
                    {
                        stackflat.HorizontalAlignment = HorizontalAlignment.Center;
                    }
                    else if (value.ToString() == "left")
                    {
                        stackflat.HorizontalAlignment = HorizontalAlignment.Left;
                    }
                    else if (value.ToString() == "right")
                    {
                        stackflat.HorizontalAlignment = HorizontalAlignment.Right;
                    }
                    else if (value.ToString() == "stretch")
                    {
                        stackflat.HorizontalAlignment = HorizontalAlignment.Stretch;
                    }
                }
            }
            //Vertical

            {
                var value = xmlelement.GetAttribute("Vertical");

                if (!string.IsNullOrEmpty(value))
                {
                    if (value.ToString() == "center")
                    {
                        stackflat.VerticalAlignment = VerticalAlignment.Center;
                    }
                    else if (value.ToString() == "bottom")
                    {
                        stackflat.VerticalAlignment = VerticalAlignment.Bottom;
                    }
                    else if (value.ToString() == "stretch")
                    {
                        stackflat.VerticalAlignment = VerticalAlignment.Stretch;
                    }
                    else if (value.ToString() == "top")
                    {
                        stackflat.VerticalAlignment = VerticalAlignment.Top;
                    }
                }
            }
            //Margin
            {
                var value = xmlelement.GetAttribute("Margin");
                if (!string.IsNullOrEmpty(value))
                {
                    var list = value.Split(',');
                    stackflat.Margin = new Thickness(
                        Convert.ToDouble(list[0]), Convert.ToDouble(list[1]), Convert.ToDouble(list[2]), Convert.ToDouble(list[3])
                        );
                }
            }
            //Visibility
            {
                var value = xmlelement.GetAttribute("Visibility");
                if (!string.IsNullOrEmpty(value))
                {
                    if (value.ToString() == "gone")
                    {
                        stackflat.Visibility = Visibility.Collapsed;
                    }
                    else if (value.ToString() == "hidden")
                    {
                        stackflat.Visibility = Visibility.Hidden;
                    }
                    else if (value.ToString() == "visible")
                    {
                        stackflat.Visibility = Visibility.Visible;
                    }
                }
            }
            //BackGround
            {
                var value = xmlelement.GetAttribute("Background");
                if (!string.IsNullOrEmpty(value))
                {
                    stackflat.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(value.ToString()));
                }
            }
            //Orientation
            {
                var value = xmlelement.GetAttribute("Orientation");
                if (!string.IsNullOrEmpty(value))
                {
                    stackflat.Orientation = value.ToString() == "horizontal" ? Orientation.Horizontal : Orientation.Vertical;
                }
            }
            //Row
            {
                var value = xmlelement.GetAttribute("Row");
                if (!string.IsNullOrEmpty(value))
                {
                    Grid.SetRow(stackflat, Convert.ToInt32(value));
                }
            }
            //Column
            {
                var value = xmlelement.GetAttribute("Column");
                if (!string.IsNullOrEmpty(value))
                {
                    Grid.SetColumn(stackflat, Convert.ToInt32(value));
                }
            }
            foreach (XmlNode i in xmlelement.ChildNodes)
            {
                if (i is XmlElement)
                {
                    stackflat.Children.Add(GTWPF.Control.GetControlFromXmlElement(basepage, i as XmlElement).IGetCSValue() as UIElement);
                }
            }
            return(stackflat);
        }
示例#2
0
        internal static IOBJ GetScrollFlatFromXml(GasPage basepage, XmlElement xmlelement)
        {
            var scrollflat = new ScrollFlat();

            //Name
            scrollflat.Name = xmlelement.GetAttribute("Name");
            //Width
            {
                var value = xmlelement.GetAttribute("Width");
                if (!string.IsNullOrEmpty(value))
                {
                    scrollflat.Width = Convert.ToDouble(value);
                }
            }
            //Height
            {
                var value = xmlelement.GetAttribute("Height");
                if (!string.IsNullOrEmpty(value))
                {
                    scrollflat.Height = Convert.ToDouble(value);
                }
            }
            //Horizontal
            {
                var value = xmlelement.GetAttribute("Horizontal");
                if (!string.IsNullOrEmpty(value))
                {
                    if (value.ToString() == "center")
                    {
                        scrollflat.HorizontalAlignment = HorizontalAlignment.Center;
                    }
                    else if (value.ToString() == "left")
                    {
                        scrollflat.HorizontalAlignment = HorizontalAlignment.Left;
                    }
                    else if (value.ToString() == "right")
                    {
                        scrollflat.HorizontalAlignment = HorizontalAlignment.Right;
                    }
                    else if (value.ToString() == "stretch")
                    {
                        scrollflat.HorizontalAlignment = HorizontalAlignment.Stretch;
                    }
                }
            }
            //Vertical

            {
                var value = xmlelement.GetAttribute("Vertical");

                if (!string.IsNullOrEmpty(value))
                {
                    if (value.ToString() == "center")
                    {
                        scrollflat.VerticalAlignment = VerticalAlignment.Center;
                    }
                    else if (value.ToString() == "bottom")
                    {
                        scrollflat.VerticalAlignment = VerticalAlignment.Bottom;
                    }
                    else if (value.ToString() == "stretch")
                    {
                        scrollflat.VerticalAlignment = VerticalAlignment.Stretch;
                    }
                    else if (value.ToString() == "top")
                    {
                        scrollflat.VerticalAlignment = VerticalAlignment.Top;
                    }
                }
            }
            //Margin
            {
                var value = xmlelement.GetAttribute("Margin");
                if (!string.IsNullOrEmpty(value))
                {
                    var list = value.Split(',');
                    scrollflat.Margin = new Thickness(
                        Convert.ToDouble(list[0]), Convert.ToDouble(list[1]), Convert.ToDouble(list[2]), Convert.ToDouble(list[3])
                        );
                }
            }
            //Visibility
            {
                var value = xmlelement.GetAttribute("Visibility");
                if (!string.IsNullOrEmpty(value))
                {
                    if (value.ToString() == "gone")
                    {
                        scrollflat.Visibility = Visibility.Collapsed;
                    }
                    else if (value.ToString() == "hidden")
                    {
                        scrollflat.Visibility = Visibility.Hidden;
                    }
                    else if (value.ToString() == "visible")
                    {
                        scrollflat.Visibility = Visibility.Visible;
                    }
                }
            }
            //Padding
            {
                var value = xmlelement.GetAttribute("Padding");
                if (!string.IsNullOrEmpty(value))
                {
                    var list = value.Split(',');
                    scrollflat.Padding = new Thickness(
                        Convert.ToDouble(list[0]), Convert.ToDouble(list[1]), Convert.ToDouble(list[2]), Convert.ToDouble(list[3])
                        );
                }
            }
            //BackGround
            {
                var value = xmlelement.GetAttribute("Background");
                if (!string.IsNullOrEmpty(value))
                {
                    scrollflat.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(value.ToString()));
                }
            }
            //Row
            {
                var value = xmlelement.GetAttribute("Row");
                if (!string.IsNullOrEmpty(value))
                {
                    Grid.SetRow(scrollflat, Convert.ToInt32(value));
                }
            }
            //Column
            {
                var value = xmlelement.GetAttribute("Column");
                if (!string.IsNullOrEmpty(value))
                {
                    Grid.SetColumn(scrollflat, Convert.ToInt32(value));
                }
            }
            if (xmlelement.HasChildNodes)
            {
                scrollflat.Content = GTWPF.Control.GetControlFromXmlElement(basepage, xmlelement.FirstChild as XmlElement);
            }
            return(scrollflat);
        }