public override UIElement generatePage()
        {
            string xamlColumns = string.Empty;

            for (int i = 0; i < NGridColumns; i++)
            {
                xamlColumns += "<ColumnDefinition Width='*'></ColumnDefinition>\r\n";
            }

            string xamlRows = string.Empty;

            for (int i = 0; i < NGridRows; i++)
            {
                xamlRows += "<RowDefinition Height='*'></RowDefinition>\r\n";
            }

            string xaml = string.Format(@"
<Grid 
xmlns='http://schemas.microsoft.com/client/2007'
    xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
Background='White'>
        <Grid.ColumnDefinitions>
            {0}
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            {1}
        </Grid.RowDefinitions>
    </Grid>
", xamlColumns, xamlRows);

            int  iCounter = 0;
            Grid grd      = (Grid)Ultis.LoadXamlFromString(xaml);

            //load item
            foreach (Tile item in ListSubMenu)
            {
                grd.Children.Add(item.generate());
                iCounter++;
            }

            if (iCounter > 0)
            {
                return(grd);
            }
            else
            {
                return(null);
            }
        }
示例#2
0
        public override UIElement generate()
        {
            string xaml = @"
<Button 
xmlns='http://schemas.microsoft.com/client/2007'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
Grid.Row='{0}' Grid.Column='{1}' Grid.ColumnSpan='{2}' Grid.RowSpan='{3}'
>
            <Image Source='{4}'></Image>
        </Button>
";

            xaml = string.Format(xaml, GridRow, GridColumn, GridColumnSpan, GridRowSpan, ImageSource);
            Button bt = (Button)Ultis.LoadXamlFromString(xaml);

            bt.Click += new RoutedEventHandler(bt_Click);
            //bt.Style = App.Current.Resources["customButtonNoStyle"] as Style;

            return(bt);
        }
        public override UIElement generate()
        {
            string xaml    = string.Format(@"
<Grid 
    xmlns='http://schemas.microsoft.com/client/2007'
    xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
ShowGridLines='True' VerticalAlignment='{0}' HorizontalAlignment='{1}'
>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width='*'></ColumnDefinition>\r
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height='*'></RowDefinition>
            </Grid.RowDefinitions>
    </Grid>
", VerticalAlignment, HorizontalAlignment);
            Grid   grdRoot = (Grid)Ultis.LoadXamlFromString(xaml);

            #region Title
            string xamlTitle = @"
<Button 
xmlns='http://schemas.microsoft.com/client/2007'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
Grid.Row='{0}' Grid.Column='{1}' Grid.ColumnSpan='{2}' Grid.RowSpan='{3}' VerticalAlignment='{5}' HorizontalAlignment='{6}'
>
            <Image Source='{4}' Stretch='None'></Image>
        </Button>
";
            xaml = string.Format(xaml, GridRow, GridColumn, GridColumnSpan, GridRowSpan, ImageSource, VerticalAlignment, HorizontalAlignment);
            Button bt = (Button)Ultis.LoadXamlFromString(xaml);
            bt.Click += new RoutedEventHandler(bt_Click);
            bt.Style  = App.Current.Resources["customButtonNoStyle"] as Style;

            #endregion


            return(grdRoot);
        }
示例#4
0
        public virtual UIElement generatePage()
        {
            string xamlColumns = string.Empty;

            for (int i = 0; i < NGridColumns; i++)
            {
                xamlColumns += "<ColumnDefinition Width='*'></ColumnDefinition>\r\n";
            }

            string xamlRows = string.Empty;

            for (int i = 0; i < NGridRows; i++)
            {
                xamlRows += "<RowDefinition Height='*'></RowDefinition>\r\n";
            }

            //<!--<ImageBrush AlignmentX='Left' AlignmentY='Top' Stretch='None' ImageSource='/PageFlip;component/Images/Demo1/lifestyle_01_01.jpg'></ImageBrush>-->
            //<SolidColorBrush Color='Orange'></SolidColorBrush>
            string strBackgroundColor;

            if (this.ImageBrush != string.Empty)
            {
                strBackgroundColor = "<ImageBrush AlignmentX='Left' AlignmentY='Top' Stretch='None' ImageSource='"
                                     + this.ImageBrush + "'></ImageBrush>";
            }
            else
            {
                if (this.currentIndex % 2 == 0)
                {
                    strBackgroundColor = "<SolidColorBrush Color='White'></SolidColorBrush>";
                }
                else
                {
                    strBackgroundColor = "<SolidColorBrush Color='White'></SolidColorBrush>";
                }
            }

            string xaml = string.Format(@"
<Grid
    xmlns='http://schemas.microsoft.com/client/2007'
    xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
>
            <Grid.Background>
                {3}
            </Grid.Background>

<Grid.ColumnDefinitions>
    <ColumnDefinition Width='*'></ColumnDefinition>
</Grid.ColumnDefinitions>

<Grid.RowDefinitions>
    <RowDefinition Height='*'></RowDefinition>
</Grid.RowDefinitions>

    <Grid ShowGridLines='False' Margin='{2}'>
            <Grid.ColumnDefinitions>
                {0}
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                {1}
            </Grid.RowDefinitions>
    </Grid>
</Grid>
", xamlColumns, xamlRows, this.Margin, strBackgroundColor);

            int  iCounter = 0;
            Grid grdRoot  = (Grid)Ultis.LoadXamlFromString(xaml);
            Grid grd      = (Grid)grdRoot.Children[0];

            //load item
            foreach (Tile item in ListSubMenu)
            {
                grd.Children.Add(item.generate());
                iCounter++;
            }

            //add stack-back button
            if (this.currentIndex % 2 == 0)
            {
                List <string> listBackImg = BookLoader.Instance().listMenuBackImageSource;
                //string strlistMenuBackImageSource = string.Empty;
                //foreach (string item in listBackImg)
                //{
                //    strlistMenuBackImageSource += item;
                //}
                //MessageBox.Show(strlistMenuBackImageSource + " " + listBackImg);

                //dang o dung cap cua no, nen chi can lay n-1 cap truoc no la dc
                if (listBackImg.Count >= 1)
                {
                    StackPanel StPnl = new StackPanel();
                    StPnl.Orientation         = Orientation.Horizontal;
                    StPnl.VerticalAlignment   = VerticalAlignment.Top;
                    StPnl.HorizontalAlignment = HorizontalAlignment.Left;

                    for (int i = 0; i < listBackImg.Count; i++)
                    {
                        string xamlBt = @"
<Button 
xmlns='http://schemas.microsoft.com/client/2007'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
>
            <Image Source='{0}' Stretch='None'></Image>
        </Button>
";
                        xamlBt = string.Format(xamlBt, listBackImg[i]);
                        Button bt = (Button)Ultis.LoadXamlFromString(xamlBt);
                        bt.Click += new RoutedEventHandler(bt_Click);
                        bt.Style  = App.Current.Resources["customButtonNoStyle"] as Style;
                        StPnl.Children.Add(bt);
                    }
                    grdRoot.Children.Add(StPnl);
                }
            }

            if (iCounter > 0)
            {
                return(grdRoot);
            }
            else
            {
                return(null);
            }
        }