示例#1
0
        public void AddTile(Grid newTile)
        {
            for (int i = 0; i < TileRackSize; i++)
            {
                if (_rackOccupency[i] == false)
                {
                    _rackOccupency[i] = true;

                    if (newTile.Parent != null)
                    {
                        var parent = newTile.Parent as Grid;

                        if (parent != null)
                        {
                            parent.Children.Remove(newTile);
                        }
                    }

                    newTile.SetValue(Grid.RowProperty, (int)Math.Floor(i / (double)ColumnCount));
                    newTile.SetValue(Grid.ColumnProperty, i % ColumnCount);

                    _theRack.Children.Add(newTile);

                    break;
                }
            }
        }
示例#2
0
        public void Draw(ref UIElement surface)
        {
            _surface = surface;

            Delete(ref surface);


            if (IsVisible && _rootElement == null)
            {
                var grd = new Grid();
                grd.SetValue(Canvas.LeftProperty, Layout.Left);
                grd.SetValue(Canvas.TopProperty, Layout.Top);
                grd.SetValue(Canvas.WidthProperty, Layout.Width);
                grd.SetValue(Canvas.HeightProperty, Layout.Height);
                grd.Opacity = 0;


                var rec = new Rectangle();
                rec.HorizontalAlignment = HorizontalAlignment.Stretch;
                rec.VerticalAlignment = VerticalAlignment.Stretch;
                rec.Fill = new SolidColorBrush(Color.FromArgb(255, 211, 211, 211));
                grd.Children.Add(rec);


                var imageUriToUse = TextureBackgroundUri;
                if (string.IsNullOrEmpty(imageUriToUse)) imageUriToUse = "ms-appx:///Assets/stilltobegenerated.png";

                if (!string.IsNullOrEmpty(imageUriToUse))
                {
                    var img = new Image();
                    img.HorizontalAlignment = HorizontalAlignment.Stretch;
                    img.VerticalAlignment = VerticalAlignment.Stretch;
                    img.Margin = new Thickness(10, 15, 10, 15);
                    img.Source = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(imageUriToUse));
                    grd.Children.Add(img);
                }
                
                _rootElement = grd;

                var _this = this;
                grd.PointerExited += (o, e) => {
                    _this.DelayedDelete(100, _this._surface, _this._rootElement);
                };

                DelayedShow(20, surface);


                ((Canvas)surface).Children.Add(_rootElement);
            }


        }
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            var id = (int)value;

            //DataTemplate dt = null;

            //switch (id) {
            //    case 1: dt = (DataTemplate)App.Current.Resources.MergedDictionaries[2]["dtGS"]; break;
            //    case 2: dt = (DataTemplate)App.Current.Resources.MergedDictionaries[2]["dtSat"]; break;
            //    default: dt = (DataTemplate)App.Current.Resources.MergedDictionaries[2]["dtGS"]; break;
            //}

            //return dt;


            var effect = new SaturationEffect();
            effect.Level = 150;
            effect.Source = (string)parameter;

            var grd = new Grid();
            grd.SetValue(Composition.EffectProperty, effect);

            return grd;


        }
示例#4
0
        private void InsertOrders(OrderType type)
        {
            orderGrid.Children.Clear();
            orderGrid.RowDefinitions.Clear();
            orderGrid.ColumnDefinitions.Clear();
            List<OrderInfo> orders = null;
            switch(type)
            {
                case OrderType.NOT_PAY:
                    orders = notPayOrders;
                    break;
                case OrderType.PAYED:
                    orders = payedOrders;
                    break;
                case OrderType.COMPLETED:
                    orders = completedOrders;
                    break;
                default:
                    break;
            }
            if(null == orders)
            {
                return;
            }
            int count = orders.Count;
            for(int i=0; i<count; i++)
            {
                RowDefinition row = new RowDefinition();
                //row.Height = new GridLength(orderGridSizeInfo.orderGridHeight);
                orderGrid.RowDefinitions.Add(row);
            }
            int nRow = 0;
            foreach(var item in orders)
            {
                Grid oneOrderGrid = new Grid();
                oneOrderGrid.Background = new SolidColorBrush(Color.FromArgb(255,235,235,235));                          
                            
                //Init four panels
                RelativePanel topPanel = new RelativePanel();
                topPanel.Background = new SolidColorBrush(Color.FromArgb(255,241,241,241));
                topPanel.Height = orderGridSizeInfo.infoPanelHeight + orderGridSizeInfo.margin;
                topPanel.Width = infoPanel.Width;
                Grid.SetColumn(topPanel, 0);
                Grid.SetRow(topPanel, 0);
                oneOrderGrid.Children.Add(topPanel);

                RelativePanel addressPanel = new RelativePanel();
                addressPanel.Height = orderGridSizeInfo.infoPanelHeight + orderGridSizeInfo.margin;
                addressPanel.Width = infoPanel.Width;
                addressPanel.Background = new SolidColorBrush(Color.FromArgb(255, 241, 241, 241));
                Grid.SetColumn(addressPanel, 0);
                Grid.SetRow(addressPanel, 2);
                oneOrderGrid.Children.Add(addressPanel);

                //goods panel
                RelativePanel goodsGridPanel = new RelativePanel();              
                goodsGridPanel.Background = new SolidColorBrush(Color.FromArgb(255, 235, 235, 235));
                //goodsGridPanel.Width = infoPanel.Width;
                goodsGridPanel.Height = orderGridSizeInfo.goodsPicHeight + 4 * orderGridSizeInfo.margin + orderGridSizeInfo.infoPanelHeight*2;

                //SlidePanel slidePanel = new SlidePanel(infoPanel.Width);
                //slidePanel.Add(goodsGridPanel,orderGridSizeInfo.goodsPicWidth);
                //Grid.SetColumn(slidePanel, 0);
                //Grid.SetRow(slidePanel, 1);
                //oneOrderGrid.Children.Add(slidePanel);

                //Grid.SetColumn(goodsGridPanel, 0);
                //Grid.SetRow(goodsGridPanel, 1);
                //oneOrderGrid.Children.Add(goodsGridPanel);

                RelativePanel buttonPanel = new RelativePanel();
                buttonPanel.Background = new SolidColorBrush(Color.FromArgb(255, 241, 241, 241));
                buttonPanel.Width = infoPanel.Width;
                buttonPanel.Height = orderGridSizeInfo.infoPanelHeight + orderGridSizeInfo.margin*2;
                Grid.SetColumn(buttonPanel, 0);
                Grid.SetRow(buttonPanel, 3);
                buttonPanel.VerticalAlignment = VerticalAlignment.Top;
                oneOrderGrid.Children.Add(buttonPanel);

                RowDefinition topRow = new RowDefinition();
                topRow.Height = new GridLength(topPanel.Height);
                oneOrderGrid.RowDefinitions.Add(topRow);
                RowDefinition goodsGridRow = new RowDefinition();
                goodsGridRow.Height = new GridLength(goodsGridPanel.Height);
                oneOrderGrid.RowDefinitions.Add(goodsGridRow);
                RowDefinition addressRow = new RowDefinition();
                addressRow.Height = new GridLength(addressPanel.Height);
                oneOrderGrid.RowDefinitions.Add(addressRow);
                RowDefinition buttonRow = new RowDefinition();
                buttonRow.Height = new GridLength(buttonPanel.Height + orderGridSizeInfo.margin);
                oneOrderGrid.RowDefinitions.Add(buttonRow);

                #region order info panel items
                TextBlock topLeft = new TextBlock();
                topLeft.Width = 80;
                topLeft.Height = orderGridSizeInfo.infoPanelHeight;
                topLeft.Text = "订单号";
                topLeft.Foreground = new SolidColorBrush(Color.FromArgb(255,51,51,51));
                topLeft.Margin = new Thickness(20, 0, 0, 0);
                topLeft.SetValue(RelativePanel.AlignLeftWithPanelProperty,true);
                topLeft.SetValue(RelativePanel.AlignBottomWithPanelProperty, true);
                topPanel.Children.Add(topLeft);

                TextBlock topRight = new TextBlock();
                topRight.Width = 150;
                topRight.Height = orderGridSizeInfo.infoPanelHeight;
                topRight.Text = item.id;
                topRight.Foreground = new SolidColorBrush(Color.FromArgb(255, 51, 51, 51));
                topRight.Margin = new Thickness(0, 0, 20, 0);
                topRight.SetValue(RelativePanel.AlignRightWithPanelProperty, true);
                topRight.SetValue(RelativePanel.AlignBottomWithPanelProperty, true);
                topRight.TextAlignment = TextAlignment.Right;
                topPanel.Children.Add(topRight);
                #endregion

                #region address panel item
                TextBlock addressLeft = new TextBlock();
                addressLeft.Width = topPanel.Width / 2;
                addressLeft.Height = orderGridSizeInfo.infoPanelHeight;
                addressLeft.Margin = new Thickness(20,0,0,0);
                addressLeft.Text = "配送地址";
                addressLeft.Foreground = new SolidColorBrush(Color.FromArgb(255, 51, 51, 51));
                addressLeft.SetValue(RelativePanel.AlignLeftWithPanelProperty, true);
                addressLeft.SetValue(RelativePanel.AlignBottomWithPanelProperty, true);
                addressPanel.Children.Add(addressLeft);
               
                TextBlock addressRight = new TextBlock();
                addressRight.Width = 150;
                addressRight.Height = orderGridSizeInfo.infoPanelHeight;
                addressRight.Text = item.address;
                addressRight.Foreground = new SolidColorBrush(Color.FromArgb(255, 51, 51, 51));
                addressRight.Margin = new Thickness(0,0,20,0);
                addressRight.TextAlignment = TextAlignment.Right;
                addressRight.SetValue(RelativePanel.AlignRightWithPanelProperty, true);
                addressRight.SetValue(RelativePanel.AlignBottomWithPanelProperty, true);
                addressPanel.Children.Add(addressRight);
                #endregion

                #region button panel item
                TextBlock priceText = new TextBlock();
                priceText.Width = 12;
                priceText.Height = 20;
                priceText.Text = "¥";
                priceText.Name = "priceText";
                priceText.Foreground = new SolidColorBrush(Color.FromArgb(255,253,40,3));
                priceText.TextAlignment = TextAlignment.Left;
                priceText.SetValue(RelativePanel.AlignLeftWithPanelProperty, true);
                priceText.SetValue(RelativePanel.AlignHorizontalCenterWithPanelProperty, true);
                priceText.Margin = new Thickness(17, 0, 0, -32);
                buttonPanel.Children.Add(priceText);

                TextBlock priceNumberText = new TextBlock();
                priceNumberText.Width = 70;
                priceNumberText.Height = orderGridSizeInfo.infoPanelHeight;
                priceNumberText.Text = item.price;
                priceNumberText.Foreground = new SolidColorBrush(Colors.Red);
                priceNumberText.FontSize = 20;
                priceNumberText.TextAlignment = TextAlignment.Left;
                priceNumberText.SetValue(RelativePanel.RightOfProperty, "priceText");
                priceNumberText.SetValue(RelativePanel.AlignHorizontalCenterWithPanelProperty, true);
                priceNumberText.Margin = new Thickness(3, 0, 0, 0);
                buttonPanel.Children.Add(priceNumberText);

                Button btnPay = new Button();
                if (item.payed.Equals("true"))
                {
                    btnPay.Visibility = Visibility.Collapsed;
                }
                btnPay.Width = 100;
                btnPay.Height = orderGridSizeInfo.infoPanelHeight;
                btnPay.VerticalContentAlignment = VerticalAlignment.Center;
                btnPay.HorizontalContentAlignment = HorizontalAlignment.Center;
                btnPay.BorderThickness = new Thickness(0);
                btnPay.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 255, 78, 0));
                btnPay.Name = "btnPay";
                TextBlock btnPayText = new TextBlock();
                btnPayText.Text = "进行付款";               
                btnPayText.Foreground = new SolidColorBrush(Colors.White);                
                btnPay.Content = btnPayText;
                //btnPay.Foreground = new SolidColorBrush(Colors.White);
                btnPay.Background = new SolidColorBrush(Color.FromArgb(255,255,78,0));
                btnPay.SetValue(RelativePanel.AlignRightWithPanelProperty,true);
                btnPay.SetValue(RelativePanel.AlignHorizontalCenterWithPanelProperty, true);
                btnPay.Margin  = new Thickness(0, 0, 20, 0);
                buttonPanel.Children.Add(btnPay);           

                Button btnCancel = new Button();
                btnCancel.Width = 100;
                btnCancel.Height = orderGridSizeInfo.infoPanelHeight;
                btnCancel.VerticalContentAlignment = VerticalAlignment.Center;
                btnCancel.HorizontalContentAlignment = HorizontalAlignment.Center;
                //btnCancel.Content = "取消订单";
                TextBlock btnCancelText = new TextBlock();
                btnCancelText.Text = "取消订单";
                btnCancelText.Foreground = new SolidColorBrush(Colors.White);                
                btnCancel.Content = btnCancelText;
                btnCancel.BorderThickness = new Thickness(0);
                btnCancel.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 148, 148, 148));
                //btnCancel.Foreground = new SolidColorBrush(Colors.White);
                btnCancel.Background = new SolidColorBrush(Color.FromArgb(255,148,148,148));
                btnCancel.Margin = new Thickness(0, 0, 5, 0);
                btnCancel.SetValue(RelativePanel.LeftOfProperty, "btnPay");
                btnCancel.SetValue(RelativePanel.AlignHorizontalCenterWithPanelProperty, true);
                buttonPanel.Children.Add(btnCancel);
                #endregion

                #region goods detail panel item                            
                int goodsCount = item.goodsList.Count;            
                double goodsGridPanelWidth = 0;
                for(int i=0; i< goodsCount; i++)
                {
                    RelativePanel goodsItemPanel = new RelativePanel();
                    goodsItemPanel.Background = new SolidColorBrush(Color.FromArgb(255,224,224,224));
                    goodsItemPanel.SetValue(RelativePanel.AlignLeftWithPanelProperty,true);
                    goodsItemPanel.Margin = new Thickness(goodsGridPanelWidth + orderGridSizeInfo.margin,0,0,0);
                    //goods name
                    TextBlock goodsNameText = new TextBlock();
                    goodsNameText.Width = 60;
                    goodsNameText.Height = orderGridSizeInfo.infoPanelHeight - 5;
                    goodsNameText.Text = item.goodsList[i].name;
                    goodsNameText.TextAlignment = TextAlignment.Left;
                    goodsNameText.Foreground = new SolidColorBrush(Color.FromArgb(255,51,51,51));
                    goodsNameText.SetValue(RelativePanel.AlignLeftWithPanelProperty,true);
                    goodsNameText.SetValue(RelativePanel.AlignBottomWithPanelProperty,true);
                    goodsNameText.Margin = new Thickness(orderGridSizeInfo.margin,0,0,orderGridSizeInfo.margin);
                    goodsItemPanel.Children.Add(goodsNameText);

                    //goods number
                    TextBlock numberText = new TextBlock();
                    numberText.Height = orderGridSizeInfo.infoPanelHeight - 5;
                    numberText.Width = 25;
                    numberText.Name = "number";
                    numberText.TextAlignment = TextAlignment.Right;
                    numberText.Foreground = new SolidColorBrush(Color.FromArgb(255,51,51,51));
                    numberText.Text = "x" + Convert.ToString(item.goodsList[i].count);
                    numberText.SetValue(RelativePanel.AlignRightWithPanelProperty,true);
                    numberText.SetValue(RelativePanel.AlignBottomWithPanelProperty,true);
                    numberText.Margin = new Thickness(0,0, orderGridSizeInfo.margin, orderGridSizeInfo.margin);
                    goodsItemPanel.Children.Add(numberText);

                    //goods price
                    TextBlock singlePriceText = new TextBlock();
                    singlePriceText.Height = orderGridSizeInfo.infoPanelHeight;
                    singlePriceText.Width = 30;
                    singlePriceText.Name = "singlePriceText";
                    singlePriceText.TextAlignment = TextAlignment.Left;
                    singlePriceText.FontSize = 20;
                    singlePriceText.Foreground = new SolidColorBrush(Color.FromArgb(255, 253, 40, 3));
                    singlePriceText.Text = item.goodsList[i].price;
                    singlePriceText.SetValue(RelativePanel.AlignBottomWithPanelProperty,true);
                    singlePriceText.SetValue(RelativePanel.LeftOfProperty, "number");
                    singlePriceText.Margin = new Thickness(0,0,0, orderGridSizeInfo.margin);
                    goodsItemPanel.Children.Add(singlePriceText);

                    TextBlock priceSymbol = new TextBlock();
                    priceSymbol.Height = orderGridSizeInfo.infoPanelHeight - 5;
                    priceSymbol.Width = 20;
                    priceSymbol.TextAlignment = TextAlignment.Right;
                    priceSymbol.FontSize = 16;
                    priceSymbol.Foreground = new SolidColorBrush(Color.FromArgb(255, 253, 40, 3));
                    priceSymbol.Text = "¥";
                    priceSymbol.SetValue(RelativePanel.AlignBottomWithPanelProperty,true);
                    priceSymbol.SetValue(RelativePanel.LeftOfProperty, "singlePriceText");
                    priceSymbol.Margin = new Thickness(0, 0, 0, orderGridSizeInfo.margin);
                    goodsItemPanel.Children.Add(priceSymbol);

                    //pictrue name
                    TextBlock picNameText = new TextBlock();
                    picNameText.Name = "picNameText";
                    picNameText.Height = orderGridSizeInfo.infoPanelHeight;
                    picNameText.Width = orderGridSizeInfo.goodsPicWidth;
                    picNameText.Text = item.goodsList[i].imageName;
                    picNameText.TextAlignment = TextAlignment.Left;
                    picNameText.Foreground = new SolidColorBrush(Color.FromArgb(255, 51, 51, 51));
                    picNameText.FontSize = 18;
                    picNameText.SetValue(RelativePanel.AlignLeftWithPanelProperty,true);
                    picNameText.SetValue(RelativePanel.AboveProperty, "singlePriceText");
                    picNameText.Margin = new Thickness(orderGridSizeInfo.margin, 0, 0, orderGridSizeInfo.margin);
                    goodsItemPanel.Children.Add(picNameText);

                    //goods picture
                    Grid picGrid = new Grid();
                    RowDefinition row = new RowDefinition();
                    row.Height = new GridLength(orderGridSizeInfo.goodsPicHeight);
                    ColumnDefinition col = new ColumnDefinition();
                    col.Width = new GridLength(orderGridSizeInfo.goodsPicWidth);
                    picGrid.RowDefinitions.Add(row);
                    picGrid.ColumnDefinitions.Add(col);
                    Border border = new Border();
                    border.BorderBrush = new SolidColorBrush(Colors.White);
                    border.BorderThickness = new Thickness(1);
                    border.CornerRadius = new CornerRadius(3, 3, 3, 3);
                    border.Background = item.goodsList[i].brush;
                    picGrid.Children.Add(border);
                    picGrid.SetValue(RelativePanel.AlignLeftWithPanelProperty, true);
                    picGrid.SetValue(RelativePanel.AlignRightWithPanelProperty,true);
                    picGrid.SetValue(RelativePanel.AlignTopWithPanelProperty,true);
                    picGrid.SetValue(RelativePanel.AboveProperty, "picNameText");
                    picGrid.Margin = new Thickness(orderGridSizeInfo.margin, orderGridSizeInfo.margin, orderGridSizeInfo.margin, orderGridSizeInfo.margin);
                    goodsItemPanel.Children.Add(picGrid);

                    goodsGridPanelWidth += (orderGridSizeInfo.goodsPicWidth + 3*orderGridSizeInfo.margin);
                    goodsGridPanel.Children.Add(goodsItemPanel);
                }              
                SlidePanel slidePanel = new SlidePanel(infoPanel.Width);
                goodsGridPanel.Width = goodsGridPanelWidth;
                slidePanel.Add(goodsGridPanel, orderGridSizeInfo.goodsPicWidth + orderGridSizeInfo.margin);
                Grid.SetColumn(slidePanel, 0);
                Grid.SetRow(slidePanel, 1);
                oneOrderGrid.Children.Add(slidePanel);
                #endregion



                Grid.SetColumn(oneOrderGrid, 0);
                Grid.SetRow(oneOrderGrid, nRow);
                orderGrid.Children.Add(oneOrderGrid);
                nRow++;
            }
        }
        /// <summary>
        /// 给一个课程格子设置颜色,并添加到视图中
        /// </summary>
        /// <param name="setcoloritem"></param>
        /// <param name="ClassColor"></param>
        private void SetClassAll(EmptyClassDayLesson setcoloritem, int ClassColor)
        {
            Color[] colors = new Color[]{
                   Color.FromArgb(255,88, 179, 255),//蓝
                   Color.FromArgb(255,255, 181, 68),//黄
                   Color.FromArgb(255,172, 222, 76),//绿
                   Color.FromArgb(255,249, 130, 130),//红
                };
            int day = setcoloritem.Hash_day;
            int lesson = setcoloritem.Hash_lesson;
            TextBlock ClassTextBlock = new TextBlock();
            if (setcoloritem is ClassListLight)
            {
                ClassListLight item = setcoloritem as ClassListLight;
                ResultName[day, lesson] = item.Name;
                foreach (var nameitem in ResultName[day, lesson])
                {
                    ClassTextBlock.Text = ClassTextBlock.Text + "\n" + nameitem;
                }
            }
            if (setcoloritem is EmptyTable)
            {
                EmptyTable item = setcoloritem as EmptyTable;
                ResultName[day, lesson] = item.nameweek.Keys.ToArray();
                foreach (var nameitem in ResultName[day, lesson])
                {
                    if (item.nameweek[nameitem].Length != 0)
                    {
                        ClassTextBlock.Text = ClassTextBlock.Text + "\n" + nameitem + "\r";
                        ClassTextBlock.Text = ClassTextBlock.Text + WeeknumConverter(item.nameweek[nameitem]);
                    }
                }
            }
            ClassTextBlock.Foreground = new SolidColorBrush(Colors.White);
            ClassTextBlock.FontSize = 13;
            ClassTextBlock.TextWrapping = TextWrapping.WrapWholeWords;
            ClassTextBlock.VerticalAlignment = VerticalAlignment.Center;
            ClassTextBlock.HorizontalAlignment = HorizontalAlignment.Center;
            if (Utils.getPhoneWidth() < 333)
                ClassTextBlock.Margin = new Thickness(1);
            else
                ClassTextBlock.Margin = new Thickness(3);
            ClassTextBlock.MaxLines = 6;

            Grid BackGrid = new Grid();
            BackGrid.Background = new SolidColorBrush(colors[ClassColor]);
            BackGrid.SetValue(Grid.RowProperty, System.Int32.Parse(lesson * 2 + ""));
            BackGrid.SetValue(Grid.ColumnProperty, System.Int32.Parse(day + ""));
            BackGrid.SetValue(Grid.RowSpanProperty, 2);
            BackGrid.Margin = new Thickness(0.5);

            if ((setcoloritem is ClassListLight) && ResultName[day, lesson].Length == muIdList.Count)
            {
                TextBlock AllPeopleTextBlock = new TextBlock();
                AllPeopleTextBlock.Foreground = new SolidColorBrush(Colors.White);
                AllPeopleTextBlock.FontSize = 11;
                AllPeopleTextBlock.Text = "全";
                AllPeopleTextBlock.VerticalAlignment = VerticalAlignment.Bottom;
                AllPeopleTextBlock.HorizontalAlignment = HorizontalAlignment.Right;
                AllPeopleTextBlock.Margin = new Thickness(1);
                BackGrid.Children.Add(AllPeopleTextBlock);
            }

            BackGrid.Children.Add(ClassTextBlock);
            BackGrid.Tapped += BackGrid_Tapped;
            kebiaoGrid.Children.Add(BackGrid);

        }
        private void SetKebiaoGridBorder(int week)
        {
            //边框
            //for (int i = 0; i < kebiaoGrid.RowDefinitions.Count; i++)
            //{
            //    for (int j = 0; j < kebiaoGrid.ColumnDefinitions.Count; j++)
            //    {
            //        var border = new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(0.5) };
            //        Grid.SetRow(border, i);
            //        Grid.SetColumn(border, j);
            //        kebiaoGrid.Children.Add(border);
            //    }
            //}

            //星期背景色
            if (week == 0)
            {
                Grid backgrid = new Grid();
                backgrid.Background = new SolidColorBrush(Color.FromArgb(255, 254, 245, 207));
                backgrid.SetValue(Grid.RowProperty, 0);
                backgrid.SetValue(Grid.ColumnProperty, (Int16.Parse(Utils.GetWeek()) + 6) % 7);
                backgrid.SetValue(Grid.RowSpanProperty, 12);
                kebiaoGrid.Children.Add(backgrid);

                backweekgrid.Background = new SolidColorBrush(Color.FromArgb(255, 254, 245, 207));
                backweekgrid.SetValue(Grid.ColumnProperty, (Int16.Parse(Utils.GetWeek()) == 0 ? 6 : Int16.Parse(Utils.GetWeek()) - 1));
                backweekgrid.SetValue(Grid.RowSpanProperty, 2);
                KebiaoWeekTitleGrid.Children.Remove(backweekgrid);
                KebiaoWeekTitleGrid.Children.Add(backweekgrid);

            }
            else
            {
                backweekgrid.Background = new SolidColorBrush(Color.FromArgb(255, 248, 248, 248));
                backweekgrid.SetValue(Grid.ColumnProperty, (Int16.Parse(Utils.GetWeek()) == 0 ? 6 : Int16.Parse(Utils.GetWeek()) - 1));
                backweekgrid.SetValue(Grid.RowSpanProperty, 2);
                KebiaoWeekTitleGrid.Children.Remove(backweekgrid);
                KebiaoWeekTitleGrid.Children.Add(backweekgrid);
            }
            TextBlock KebiaoWeek = new TextBlock();
            KebiaoWeek.Text = Utils.GetWeek(2);
            KebiaoWeek.FontSize = 20;
            KebiaoWeek.Foreground = new SolidColorBrush(Color.FromArgb(255, 33, 33, 33));
            KebiaoWeek.FontWeight = FontWeights.Light;
            KebiaoWeek.VerticalAlignment = VerticalAlignment.Center;
            KebiaoWeek.HorizontalAlignment = HorizontalAlignment.Center;
            KebiaoWeek.SetValue(Grid.ColumnProperty, (Int16.Parse(Utils.GetWeek()) == 0 ? 6 : Int16.Parse(Utils.GetWeek()) - 1));
            KebiaoWeek.SetValue(Grid.RowProperty, 1);
            KebiaoWeekTitleGrid.Children.Add(KebiaoWeek);
        }
        /// <summary>
        /// 课程格子的填充
        /// </summary>
        /// <param name="item">ClassList类型的item</param>
        /// <param name="ClassColor">颜色数组,0~9</param>
        private void SetClass(ClassList item, int ClassColor)
        {

            Color[] colors = new Color[]{
                   //Color.FromArgb(255,132, 191, 19),
                   //Color.FromArgb(255,67, 182, 229),
                   //Color.FromArgb(255,253, 137, 1),
                   //Color.FromArgb(255,128, 79, 242),
                   //Color.FromArgb(255,240, 68, 189),
                   //Color.FromArgb(255,229, 28, 35),
                   //Color.FromArgb(255,156, 39, 176),
                   //Color.FromArgb(255,3, 169, 244),
                   //Color.FromArgb(255,255, 193, 7),
                   //Color.FromArgb(255,255, 152, 0),
                   //Color.FromArgb(255,96, 125, 139),
                   Color.FromArgb(255,255, 161, 16),
                   Color.FromArgb(255,56, 188, 242),
                   Color.FromArgb(255,159, 213, 27),
                };

            TextBlock ClassTextBlock = new TextBlock();

            ClassTextBlock.Text = item.Course + "\n" + item.Classroom + "\n" + item.Teacher;
            ClassTextBlock.Foreground = this.Foreground;
            ClassTextBlock.FontSize = 12;
            ClassTextBlock.TextWrapping = TextWrapping.WrapWholeWords;
            ClassTextBlock.VerticalAlignment = VerticalAlignment.Center;
            ClassTextBlock.HorizontalAlignment = HorizontalAlignment.Center;
            ClassTextBlock.Margin = new Thickness(3);
            ClassTextBlock.MaxLines = 6;

            Grid BackGrid = new Grid();
            BackGrid.Background = new SolidColorBrush(colors[ClassColor]);
            BackGrid.SetValue(Grid.RowProperty, System.Int32.Parse(item.Hash_lesson * 2 + ""));
            BackGrid.SetValue(Grid.ColumnProperty, System.Int32.Parse(item.Hash_day + ""));
            BackGrid.SetValue(Grid.RowSpanProperty, System.Int32.Parse(item.Period + ""));

            BackGrid.Children.Add(ClassTextBlock);

            if (classtime[item.Hash_day, item.Hash_lesson] != null)
            {
                Image img = new Image();
                img.Source = new BitmapImage(new Uri("ms-appx:///Assets/shape.png", UriKind.Absolute));
                img.VerticalAlignment = VerticalAlignment.Bottom;
                img.HorizontalAlignment = HorizontalAlignment.Right;
                img.Width = 10;
                BackGrid.Children.Add(img);

                string[] temp = classtime[item.Hash_day, item.Hash_lesson];
                string[] tempnew = new string[temp.Length + 1];
                for (int i = 0; i < temp.Length; i++)
                    tempnew[i] = temp[i];
                tempnew[temp.Length] = item._Id;
                classtime[item.Hash_day, item.Hash_lesson] = tempnew;
            }
            else
            {
                string[] tempnew = new string[1];
                tempnew[0] = item._Id;
                classtime[item.Hash_day, item.Hash_lesson] = tempnew;
            }

            BackGrid.Tapped += BackGrid_Tapped;
            kebiaoGrid.Children.Add(BackGrid);
        }
        /// <summary>
        ///     This function creates and adds one print preview page to the internal cache of print preview
        ///     pages stored in printPreviewPages.
        /// </summary>
        /// <param name="lastRTBOAdded">Last RichTextBlockOverflow element added in the current content</param>
        /// <param name="printPageDescription">Printer's page description</param>
        private RichTextBlockOverflow AddOnePrintPreviewPage(RichTextBlockOverflow lastRTBOAdded,
            PrintPageDescription printPageDescription)
        {
            // Create a cavase which represents the page 
            var page = new Canvas();
            page.Width = printPageDescription.PageSize.Width;
            page.Height = printPageDescription.PageSize.Height;

            var pageState = new PageLoadState(page, printPreviewPages.Count);
            pageState.ReadyAction = async (pageNumber, currentPage) =>
            {
                // Ignore if this is not the current page
                if (Interlocked.CompareExchange(ref currentPreviewPage, currentPreviewPage, pageNumber) == pageNumber)
                {
                    await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        //await new Windows.UI.Popups.MessageDialog("Content loaded").ShowAsync();
                        printDocument.SetPreviewPage(pageNumber + 1, currentPage);
                    });
                }
            };

            // Create a grid which contains the actual content to be printed
            var content = new Grid();

            // Get the margins size
            // If the ImageableRect is smaller than the app provided margins use the ImageableRect
            double marginWidth = Math.Max(
                printPageDescription.PageSize.Width - printPageDescription.ImageableRect.Width,
                printPageDescription.PageSize.Width*ApplicationContentMarginLeft*2);

            double marginHeight =
                Math.Max(printPageDescription.PageSize.Height - printPageDescription.ImageableRect.Height,
                    printPageDescription.PageSize.Height*ApplicationContentMarginTop*2);

            // Set content size based on the given margins
            content.Width = printPageDescription.PageSize.Width - marginWidth;
            content.Height = printPageDescription.PageSize.Height - marginHeight;

            // Set content margins
            content.SetValue(Canvas.LeftProperty, marginWidth/2);
            content.SetValue(Canvas.TopProperty, marginHeight/2);

            //// Add the RowDefinitions to the Grid which is a content to be printed
            //RowDefinition rowDef = new RowDefinition();
            //rowDef.Height = new GridLength(0.7, GridUnitType.Star);
            //content.RowDefinitions.Add(rowDef);
            //rowDef = new RowDefinition();
            //rowDef.Height = new GridLength(0.8, GridUnitType.Star);
            //content.RowDefinitions.Add(rowDef);
            //rowDef = new RowDefinition();
            //rowDef.Height = new GridLength(2.5, GridUnitType.Star);
            //content.RowDefinitions.Add(rowDef);
            //rowDef = new RowDefinition();
            //rowDef.Height = new GridLength(3.5, GridUnitType.Star);
            //content.RowDefinitions.Add(rowDef);
            //rowDef = new RowDefinition();
            //rowDef.Height = new GridLength(1.5, GridUnitType.Star);
            //content.RowDefinitions.Add(rowDef);
            //rowDef = new RowDefinition();
            //rowDef.Height = new GridLength(0.5, GridUnitType.Star);
            //content.RowDefinitions.Add(rowDef);
            //rowDef = new RowDefinition();
            //rowDef.Height = new GridLength(0.5, GridUnitType.Star);
            //content.RowDefinitions.Add(rowDef);


            // Add the ColumnDefinitions to the Grid which is a content to be printed
            //ColumnDefinition colDef = new ColumnDefinition();
            //colDef.Width = new GridLength(40, GridUnitType.Star);
            //content.ColumnDefinitions.Add(colDef);
            //colDef = new ColumnDefinition();
            //colDef.Width = new GridLength(60, GridUnitType.Star);
            //content.ColumnDefinitions.Add(colDef);


            //// Create the "Windows 8 SDK Sample" header which consists of an image and text in a stack panel
            //// and add it to the content grid
            //Image windowsLogo = new Image();
            //windowsLogo.Source = new BitmapImage(new Uri("ms-appx:///Images/windows-sdk.png"));
            //pageState.ListenForCompletion((BitmapImage)windowsLogo.Source);

            //TextBlock headerText = new TextBlock();
            //headerText.TextWrapping = TextWrapping.Wrap;
            //headerText.Text = "Windows 8 SDK Sample";
            //headerText.FontSize = 20;
            //headerText.Foreground = new SolidColorBrush(Colors.Black);

            //StackPanel sp = new StackPanel();
            //sp.Orientation = Orientation.Horizontal;
            //sp.Children.Add(windowsLogo);
            //sp.Children.Add(headerText);


            //StackPanel outerPanel = new StackPanel();
            //outerPanel.Orientation = Orientation.Vertical;
            //outerPanel.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top;
            //outerPanel.Children.Add(sp);
            //outerPanel.SetValue(Grid.RowProperty, 1);
            //outerPanel.SetValue(Grid.ColumnSpanProperty, 2);


            //TextBlock sampleTitle = new TextBlock();
            //sampleTitle.TextWrapping = TextWrapping.Wrap;
            //sampleTitle.Text = "Print Sample";
            //sampleTitle.FontSize = 22;
            //sampleTitle.FontWeight = FontWeights.Bold;
            //sampleTitle.Foreground = new SolidColorBrush(Colors.Black);
            //outerPanel.Children.Add(sampleTitle);

            //content.Children.Add(outerPanel);


            //// Create Microsoft image used to end each page and add it to the content grid
            //Image microsoftLogo = new Image();
            //microsoftLogo.Source = new BitmapImage(new Uri("ms-appx:///Images/microsoft-sdk.png"));
            //pageState.ListenForCompletion((BitmapImage)microsoftLogo.Source);
            //microsoftLogo.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Left;
            //microsoftLogo.SetValue(Grid.RowProperty, 5);
            //content.Children.Add(microsoftLogo);


            //// Add the copywrite notice and add it to the content grid
            //TextBlock copyrightNotice = new TextBlock();
            //copyrightNotice.Text = "© 2011 Microsoft. All rights reserved.";
            //copyrightNotice.FontSize = 16;
            //copyrightNotice.TextWrapping = TextWrapping.Wrap;
            //copyrightNotice.Foreground = new SolidColorBrush(Colors.Black);
            //copyrightNotice.SetValue(Grid.RowProperty, 6);
            //copyrightNotice.SetValue(Grid.ColumnSpanProperty, 2);
            //content.Children.Add(copyrightNotice);


            // If lastRTBOAdded is null then we know we are creating the first page. 
            bool isFirstPage = lastRTBOAdded == null;

            FrameworkElement previousLTCOnPage = null;
            var rtbo = new RichTextBlockOverflow();
            // Create the linked containers and and add them to the content grid
            if (isFirstPage)
            {
                // The first linked container in a chain of linked containers is is always a RichTextBlock
                if (ShowText)
                {
                    var rtbl = new RichTextBlock();
                    rtbl = AddContentToRTBl(rtbl);
                    content.Children.Add(rtbl);
                    // Save the RichTextBlock as the last linked container added to this page
                    previousLTCOnPage = rtbl;
                }

                //if (ShowImage)
                //{
                //    // Add the image to the first page and add it to the content grid
                //    Image pic = new Image();
                //    BitmapImage bitmap = new BitmapImage(new Uri("ms-appx:///Images/print_1.png"));
                //    pageState.ListenForCompletion(bitmap);
                //    pic.Source = bitmap;
                //    pic.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Left;
                //    pic.Margin = new Thickness(10);
                //    if (ShowText)
                //    {
                //        pic.SetValue(Grid.RowProperty, 3);
                //        pic.SetValue(Grid.ColumnProperty, 2);
                //        content.Children.Add(pic);
                //        content.RowDefinitions[2].Height = new GridLength(2.5, GridUnitType.Star);
                //    }
                //    else
                //    {
                //        pic.Width = content.Width;
                //        pic.Height = content.Height;
                //        page.Children.Add(pic);
                //    }
                //}
            }
            else if (ShowText)
            {
                // This is not the first page so the first element on this page has to be a
                // RichTextBoxOverflow that links to the last RichTextBlockOverflow added to
                // the previous page.
                rtbo = new RichTextBlockOverflow();
                rtbo.SetValue(Grid.RowProperty, 2);
                rtbo.SetValue(Grid.ColumnSpanProperty, 2);
                content.Children.Add(rtbo);

                // Keep text flowing from the previous page to this page by setting the linked text container just
                // created (rtbo) as the OverflowContentTarget for the last linked text container from the previous page 
                lastRTBOAdded.OverflowContentTarget = rtbo;

                // Save the RichTextBlockOverflow as the last linked container added to this page
                previousLTCOnPage = rtbo;
            }


            //if (ShowText)
            //{
            //    // Create the next linked text container for on this page.
            //    rtbo = new RichTextBlockOverflow();
            //    rtbo.SetValue(Grid.RowProperty, 3);

            //    // If this linked container is not on the first page make it span 2 columns.
            //    if (!isFirstPage || !ShowImage)
            //        rtbo.SetValue(Grid.ColumnSpanProperty, 2);

            //    // Add the RichTextBlockOverflow to the content to be printed.
            //    content.Children.Add(rtbo);

            //    // Add the new RichTextBlockOverflow to the chain of linked text containers. To do this we much check
            //    // to see if the previous container is a RichTextBlock or RichTextBlockOverflow.
            //    if (previousLTCOnPage is RichTextBlock)
            //        ((RichTextBlock)previousLTCOnPage).OverflowContentTarget = rtbo;
            //    else
            //        ((RichTextBlockOverflow)previousLTCOnPage).OverflowContentTarget = rtbo;

            //    // Save the last linked text container added to the chain
            //    previousLTCOnPage = rtbo;

            //    // Create the next linked text container for on this page.
            //    rtbo = new RichTextBlockOverflow();
            //    rtbo.SetValue(Grid.RowProperty, 4);
            //    rtbo.SetValue(Grid.ColumnSpanProperty, 2);
            //    content.Children.Add(rtbo);

            //    // Add the new RichTextBlockOverflow to the chain of linked text containers. We don't have to check
            //    // the type of the previous linked container this time because we know it's a RichTextBlockOverflow element
            //    ((RichTextBlockOverflow)previousLTCOnPage).OverflowContentTarget = rtbo;
            //}
            // We are done creating the content for this page. Add it to the Canvas which represents the page
            page.Children.Add(content);

            // Add the newley created page to the printing root which is part of the visual tree and force it to go
            // through layout so that the linked containers correctly distribute the content inside them.
            PrintingRoot.Children.Add(page);
            PrintingRoot.InvalidateMeasure();
            PrintingRoot.UpdateLayout();

            // Add the newley created page to the list of pages
            printPreviewPages.Add(pageState);

            // Return the last linked container added to the page
            return rtbo;
        }
        /// <summary>
        /// This function creates and adds one print preview page to the internal cache of print preview
        /// pages stored in printPreviewPages.
        /// </summary>
        /// <param name="lastRTBOAdded">Last RichTextBlockOverflow element added in the current content</param>
        /// <param name="printPageDescription">Printer's page description</param>
        private RichTextBlockOverflow AddOnePrintPreviewPage(RichTextBlockOverflow lastRTBOAdded, PrintPageDescription printPageDescription)
        {
            // Create a cavase which represents the page 
            Canvas page = new Canvas();
            page.Width = printPageDescription.PageSize.Width;
            page.Height = printPageDescription.PageSize.Height;

            PageLoadState pageState = new PageLoadState(page, printPreviewPages.Count);
            pageState.ReadyAction = async (pageNumber, currentPage) =>
            {
                // Ignore if this is not the current page
                if (Interlocked.CompareExchange(ref currentPreviewPage, currentPreviewPage, pageNumber) == pageNumber)
                {
                    await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                    {
                        //await new Windows.UI.Popups.MessageDialog("Content loaded").ShowAsync();
                        printDocument.SetPreviewPage(pageNumber + 1, currentPage);
                    });
                }
            };

            // Create a grid which contains the actual content to be printed
            Grid content = new Grid();

            // Get the margins size
            // If the ImageableRect is smaller than the app provided margins use the ImageableRect
            double marginWidth = Math.Max(printPageDescription.PageSize.Width - printPageDescription.ImageableRect.Width,
                                        printPageDescription.PageSize.Width * ApplicationContentMarginLeft * 2);

            double marginHeight = Math.Max(printPageDescription.PageSize.Height - printPageDescription.ImageableRect.Height,
                                         printPageDescription.PageSize.Height * ApplicationContentMarginTop * 2);

            // Set content size based on the given margins
            content.Width = printPageDescription.PageSize.Width - marginWidth;
            content.Height = printPageDescription.PageSize.Height - marginHeight;

            // Set content margins
            content.SetValue(Canvas.LeftProperty, marginWidth / 2);
            content.SetValue(Canvas.TopProperty, marginHeight / 2);

            // If lastRTBOAdded is null then we know we are creating the first page. 
            bool isFirstPage = lastRTBOAdded == null;

            FrameworkElement previousLTCOnPage = null;
            RichTextBlockOverflow rtbo = new RichTextBlockOverflow();
            // Create the linked containers and and add them to the content grid
            if (isFirstPage)
            {
                // The first linked container in a chain of linked containers is is always a RichTextBlock
                if (ShowText)
                {
                    RichTextBlock rtbl = new RichTextBlock();
                    rtbl = AddContentToRTBl(rtbl);
                    content.Children.Add(rtbl);
                    // Save the RichTextBlock as the last linked container added to this page
                    previousLTCOnPage = rtbl;
                }
            }
            else if (ShowText)
            {
                // This is not the first page so the first element on this page has to be a
                // RichTextBoxOverflow that links to the last RichTextBlockOverflow added to
                // the previous page.
                rtbo = new RichTextBlockOverflow();
                rtbo.SetValue(Grid.RowProperty, 2);
                rtbo.SetValue(Grid.ColumnSpanProperty, 2);
                content.Children.Add(rtbo);

                // Keep text flowing from the previous page to this page by setting the linked text container just
                // created (rtbo) as the OverflowContentTarget for the last linked text container from the previous page 
                lastRTBOAdded.OverflowContentTarget = rtbo;

                // Save the RichTextBlockOverflow as the last linked container added to this page
                previousLTCOnPage = rtbo;
            }

            // We are done creating the content for this page. Add it to the Canvas which represents the page
            page.Children.Add(content);

            // Add the newley created page to the printing root which is part of the visual tree and force it to go
            // through layout so that the linked containers correctly distribute the content inside them.
            PrintingRoot.Children.Add(page);
            PrintingRoot.InvalidateMeasure();
            PrintingRoot.UpdateLayout();

            // Add the newley created page to the list of pages
            printPreviewPages.Add(pageState);

            // Return the last linked container added to the page
            return rtbo;
        }
        private Grid CreateAnimationTile()
        {
            var tile = new Grid()
            {
                Width = 50,
                Height = 50,
                Background = new SolidColorBrush(Colors.DodgerBlue)
            };

            tile.VerticalAlignment = VerticalAlignment.Top;
            tile.HorizontalAlignment = HorizontalAlignment.Left;
            tile.SetValue(Grid.ColumnProperty, 0);

            tile.RenderTransformOrigin = new Point(.5, .5);
            tile.RenderTransform = new CompositeTransform();

            return tile;
        }
        private Storyboard CreatePeelAnimationStoryboard(int playerViewModelIndex, TileAnimationDirection direction, out Grid tile)
        {
            //
            // Initialize the tile grid.
            //

            tile = new Grid()
            {
                Width = 50,
                Height = 50,
                Background = new SolidColorBrush(Colors.DodgerBlue)
            };

            tile.VerticalAlignment = VerticalAlignment.Top;
            tile.HorizontalAlignment = HorizontalAlignment.Left;
            tile.SetValue(Grid.ColumnProperty, 0);

            RootGrid.Children.Add(tile);

            tile.RenderTransformOrigin = new Point(.5, .5);
            tile.RenderTransform = new CompositeTransform();


            var storyboard = new Storyboard();

            storyboard.Children.Add(CreateScaleXKeyFrames());

            storyboard.Children.Add(CreateScaleYKeyFrames());

            storyboard.Children.Add(CreateTranslationKeyFrames(playerViewModelIndex, direction, tile));

            storyboard.Children.Add(CreateOpacityKeyFrames());

            return storyboard;
        }
        /// <summary>
        /// 周视图课程格子的填充
        /// </summary>
        /// <param name="item">ClassList类型的item</param>
        /// <param name="ClassColor">颜色数组,0~9</param>
        private void SetClassAll(ClassList item, int ClassColor)
        {
            //有事项的画个角- -
            //foreach (var transactionItem in transationList) {
            //    if (item.Week == transactionItem.week && item.Lesson == transactionItem.classToLesson)
            //    {

            //    }
            //}

            Color[] colors = new Color[]{
                   //Color.FromArgb(255,132, 191, 19),
                   //Color.FromArgb(255,67, 182, 229),
                   //Color.FromArgb(255,253, 137, 1),
                   //Color.FromArgb(255,128, 79, 242),
                   //Color.FromArgb(255,240, 68, 189),
                   //Color.FromArgb(255,229, 28, 35),
                   //Color.FromArgb(255,156, 39, 176),
                   //Color.FromArgb(255,3, 169, 244),
                   //Color.FromArgb(255,255, 193, 7),
                   //Color.FromArgb(255,255, 152, 0),
                   //Color.FromArgb(255,96, 125, 139),
                   Color.FromArgb(255,255, 161, 16),
                   Color.FromArgb(255,56, 188, 242),
                   Color.FromArgb(255,159, 213, 27),
                   Color.FromArgb(255,200, 200, 200), //灰色
                };

            //折叠角的颜色数组
            Color[] _color = new Color[] {
                Color.FromArgb(255,255,219,178),
                Color.FromArgb(255,162,229,255),
                Color.FromArgb(255,155,244,244),
            };

            TextBlock ClassTextBlock = new TextBlock();

            ClassTextBlock.Text = item.Course + "\n" + item.Classroom + "\n" + item.Teacher;
            ClassTextBlock.Foreground = new SolidColorBrush(Colors.White);
            ClassTextBlock.FontSize = 12;
            ClassTextBlock.TextWrapping = TextWrapping.WrapWholeWords;
            ClassTextBlock.VerticalAlignment = VerticalAlignment.Center;
            ClassTextBlock.HorizontalAlignment = HorizontalAlignment.Center;
            ClassTextBlock.Margin = new Thickness(3);
            ClassTextBlock.MaxLines = 6;

            Grid BackGrid = new Grid();
            BackGrid.Background = new SolidColorBrush(colors[ClassColor]);
            BackGrid.SetValue(Grid.RowProperty, System.Int32.Parse(item.Hash_lesson * 2 + ""));
            BackGrid.SetValue(Grid.ColumnProperty, System.Int32.Parse(item.Hash_day + ""));
            BackGrid.SetValue(Grid.RowSpanProperty, System.Int32.Parse(item.Period + ""));
            BackGrid.Margin = new Thickness(0.5);
            BackGrid.Children.Add(ClassTextBlock);

            //TODO:新增 折叠三角
            if (classtime[item.Hash_day, item.Hash_lesson] != null)
            {
                Image img = new Image();
                img.Source = new BitmapImage(new Uri("ms-appx:///Assets/shape.png", UriKind.Absolute));
                img.VerticalAlignment = VerticalAlignment.Bottom;
                img.HorizontalAlignment = HorizontalAlignment.Right;
                img.Width = 10;

                //他要折叠..我画一个三角好了..
                Grid _grid = new Grid();
                Polygon pl = new Polygon();
                PointCollection collection = new PointCollection();
                collection.Add(new Point(0, 0));
                collection.Add(new Point(10, 0));
                collection.Add(new Point(0, 10));
                pl.Points = collection;
                pl.Stroke = new SolidColorBrush(Colors.Black);
                pl.StrokeThickness = 0;
                _grid.Children.Add(pl);
                _grid.Background = new SolidColorBrush(_color[ClassColor]);
                _grid.Width = 10;
                _grid.Height = 10;
                _grid.VerticalAlignment = VerticalAlignment.Bottom;
                _grid.HorizontalAlignment = HorizontalAlignment.Right;
                BackGrid.Children.Add(_grid);

                BackGrid.Children.Add(img);

                string[] temp = classtime[item.Hash_day, item.Hash_lesson];
                string[] tempnew = new string[temp.Length + 1];
                for (int i = 0; i < temp.Length; i++)
                    tempnew[i] = temp[i];
                tempnew[temp.Length] = item._Id;
                Debug.WriteLine("if~id->" + item._Id);
                classtime[item.Hash_day, item.Hash_lesson] = tempnew;
            }
            else
            {
                string[] tempnew = new string[1];
                tempnew[0] = item._Id;
                Debug.WriteLine("else~id->" + item._Id);
                classtime[item.Hash_day, item.Hash_lesson] = tempnew;
            }

            BackGrid.Tapped += BackGrid_Tapped;
            kebiaoGrid.Children.Add(BackGrid);
        }
        /// <summary>
        /// 日视图课程格子的填充
        /// </summary>
        /// <param name="classitem"></param>
        private void SetClassDay(ClassList classitem)
        {
            Grid BackGrid = new Grid();
            BackGrid.Background = new SolidColorBrush(Color.FromArgb(255, 88, 179, 255));
            //BackGrid.Background = new SolidColorBrush(Colors.Wheat);
            BackGrid.SetValue(Grid.RowProperty, System.Int32.Parse(classitem.Hash_lesson * 2 + ""));
            BackGrid.SetValue(Grid.ColumnProperty, System.Int32.Parse(classitem.Hash_day + ""));
            BackGrid.SetValue(Grid.RowSpanProperty, System.Int32.Parse(classitem.Period + ""));

            StackPanel BackStackPanel = new StackPanel();
            BackStackPanel.Margin = new Thickness(15);
            BackStackPanel.VerticalAlignment = VerticalAlignment.Center;

            TextBlock classNameTextBlock = new TextBlock();
            classNameTextBlock.Text = classitem.Course;
            classNameTextBlock.FontSize = 20;
            classNameTextBlock.Margin = new Thickness(0, 3, 0, 3);
            classNameTextBlock.Foreground = new SolidColorBrush(Colors.White);


            StackPanel classTeaStackPanel = new StackPanel();
            Image classTeaImage = new Image();
            TextBlock classTeaTextBlock = new TextBlock();
            classTeaImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/dialog_course_peo_white.png", UriKind.Absolute));
            classTeaImage.Width = 15;
            classTeaImage.Height = 15;
            classTeaTextBlock.Text = classitem.Teacher;
            classTeaTextBlock.FontSize = 15;
            classTeaTextBlock.Margin = new Thickness(10, 0, 0, 0);
            classTeaTextBlock.Foreground = new SolidColorBrush(Colors.White);
            classTeaStackPanel.Orientation = Orientation.Horizontal;
            classTeaStackPanel.Children.Add(classTeaImage);
            classTeaStackPanel.Children.Add(classTeaTextBlock);
            classTeaStackPanel.Margin = new Thickness(0, 3, 0, 3);


            StackPanel classAddStackPanel = new StackPanel();
            Image classAddImage = new Image();
            TextBlock classAddTextBlock = new TextBlock();
            classAddImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/dialog_course_add_white.png", UriKind.Absolute));
            classAddImage.Width = 15;
            classAddImage.Height = 15;
            classAddTextBlock.Text = classitem.Classroom;
            classAddTextBlock.FontSize = 15;
            classAddTextBlock.Margin = new Thickness(10, 0, 0, 0);
            classAddTextBlock.Foreground = new SolidColorBrush(Colors.White);
            classAddStackPanel.Orientation = Orientation.Horizontal;
            classAddStackPanel.Children.Add(classAddImage);
            classAddStackPanel.Children.Add(classAddTextBlock);
            classAddStackPanel.Margin = new Thickness(0, 3, 0, 3);

            StackPanel classTypeStackPanel = new StackPanel();
            Image classTypeImage = new Image();
            TextBlock classTypeTextBlock = new TextBlock();
            classTypeImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/dialog_course_type_white.png", UriKind.Absolute));
            classTypeImage.Width = 15;
            classTypeImage.Height = 15;
            classTypeTextBlock.Text = classitem.Type;
            classTypeTextBlock.FontSize = 15;
            classTypeTextBlock.Margin = new Thickness(10, 0, 0, 0);
            classTypeTextBlock.Foreground = new SolidColorBrush(Colors.White);
            classTypeStackPanel.Orientation = Orientation.Horizontal;
            classTypeStackPanel.Children.Add(classTypeImage);
            classTypeStackPanel.Children.Add(classTypeTextBlock);
            classTypeStackPanel.Margin = new Thickness(0, 3, 0, 3);

            BackStackPanel.Children.Add(classNameTextBlock);
            BackStackPanel.Children.Add(classTeaStackPanel);
            BackStackPanel.Children.Add(classAddStackPanel);
            BackStackPanel.Children.Add(classTypeStackPanel);

            BackGrid.Children.Add(BackStackPanel);

            KebiaoDayGrid.Children.Add(BackGrid);
        }
        /// <summary>
        /// 学期事项填充
        /// </summary>
        /// 跟当日事件填充除了判断条件基本一致 但是不太好合/头有点晕 有空再做优化
        private void SetTransactionAll(List<Transaction> transationList, List<ClassList> classlist)
        {
            Color[] Tcolor = new Color[]{
                   Color.FromArgb(255,232,245,254),
                   Color.FromArgb(255,255,245,233),
                   Color.FromArgb(255,230,255,251)
                };
            int RightC = 0;
            bool IsInClass = false;
            foreach (var transactionitem in transationList)
            {
                for (int i = 0; i < transactionitem.date.Count; i++)
                {
                    foreach (var classitem in classlist)
                    {
                        if (transactionitem.date[i]._class == classitem.Hash_lesson)
                        { IsInClass = true; break; }
                    }
                    switch (transactionitem.date[i]._class)
                    {
                        case 0:
                        case 1:
                            RightC = 0;
                            break;
                        case 2:
                        case 3:
                            RightC = 1;
                            break;
                        case 4:
                        case 5:
                            RightC = 2;
                            break;
                    }
                    if (transactiontime[transactionitem.date[i].day, transactionitem.date[i]._class] == null)
                    {
                        long[] tempstr = new long[1];
                        tempstr[0] = transactionitem.id;
                        transactiontime[transactionitem.date[i].day, transactionitem.date[i]._class] = tempstr;
                    }
                    else if (Array.IndexOf(transactiontime[transactionitem.date[i].day, transactionitem.date[i]._class], transactionitem.id) == -1)
                    {
                        long[] temp = transactiontime[transactionitem.date[i].day, transactionitem.date[i]._class];
                        long[] templ = new long[temp.Length + 1];
                        for (int a = 0; a < temp.Length; a++)
                            templ[a] = temp[a];
                        //if (Array.IndexOf(templ, transactionitem.id) != -1)
                        templ[temp.Length] = transactionitem.id;
                        transactiontime[transactionitem.date[i].day, transactionitem.date[i]._class] = templ;
                    }
                    if (IsInClass)
                    {
                        Grid transactionGrid = new Grid();
                        transactionGrid.SetValue(Grid.RowProperty, System.Int32.Parse(transactionitem.date[i]._class * 2 + ""));
                        transactionGrid.SetValue(Grid.ColumnProperty, System.Int32.Parse(transactionitem.date[i].day + ""));
                        transactionGrid.SetValue(Grid.RowSpanProperty, System.Int32.Parse(2 + ""));

                        transactionGrid.Margin = new Thickness(2);

                        transactionGrid.HorizontalAlignment = HorizontalAlignment.Right;
                        transactionGrid.VerticalAlignment = VerticalAlignment.Top;
                        transactionGrid.Width = 8;
                        transactionGrid.Height = 8;
                        transactionGrid.BorderThickness = new Thickness(0);
                        transactionGrid.Background = new SolidColorBrush(Colors.Transparent);
                        Polygon pl = new Polygon();
                        PointCollection collection = new PointCollection();
                        collection.Add(new Point(0, 0));
                        collection.Add(new Point(10, 10));
                        collection.Add(new Point(10, 0));
                        pl.Points = collection;
                        pl.StrokeThickness = 0;
                        pl.Fill = new SolidColorBrush(Colors.White);
                        transactionGrid.Children.Add(pl);
                        IsInClass = false;
                        kebiaoGrid.Children.Add(transactionGrid);
                    }
                    else
                    {
                        Grid transactionGrid = new Grid();
                        transactionGrid.SetValue(Grid.RowProperty, System.Int32.Parse(transactionitem.date[i]._class * 2 + ""));
                        transactionGrid.SetValue(Grid.ColumnProperty, System.Int32.Parse(transactionitem.date[i].day + ""));
                        transactionGrid.SetValue(Grid.RowSpanProperty, System.Int32.Parse(2 + ""));

                        transactionGrid.Background = new SolidColorBrush(Tcolor[RightC]);

                        Grid polygonGrid = new Grid();
                        polygonGrid.HorizontalAlignment = HorizontalAlignment.Right;
                        polygonGrid.VerticalAlignment = VerticalAlignment.Top;
                        polygonGrid.Height = 8;
                        polygonGrid.Width = 8;
                        polygonGrid.Background = new SolidColorBrush(Colors.Transparent);
                        polygonGrid.Margin = new Thickness(2);
                        Polygon pl = new Polygon();
                        PointCollection collection = new PointCollection();
                        collection.Add(new Point(0, 0));
                        collection.Add(new Point(10, 10));
                        collection.Add(new Point(10, 0));
                        pl.Points = collection;
                        pl.Fill = new SolidColorBrush(Colors.White);
                        pl.StrokeThickness = 0;
                        polygonGrid.Children.Add(pl);
                        transactionGrid.Children.Add(polygonGrid);

                        IsInClass = false;
                        transactionGrid.Margin = new Thickness(0.5);

                        transactionGrid.Tapped += BackGrid_Tapped;
                        kebiaoGrid.Children.Add(transactionGrid);
                    }
                }
            }
        }
        /// <summary>
        /// 当日事项填充
        /// </summary>
        private void SetTransactionDay(List<Transaction> transationList, List<ClassList> classlist, int week = 0, int weekOrAll = 0)
        {
            int nowWEEK;
            if (week == 0)
                nowWEEK = Int32.Parse(appSetting.Values["nowWeek"].ToString());
            else
                nowWEEK = week;
            //事项的背景颜色 略淡
            Color[] Tcolor = new Color[]{
                   Color.FromArgb(255,232,245,254),
                   Color.FromArgb(255,255,245,233),
                   Color.FromArgb(255,230,255,251)
                };
            //通过在某某节确定背景颜色
            int RightC = 0;
            bool isInClassGrid = false;
            foreach (var transactionitem in transationList)
            {
                for (int i = 0; i < transactionitem.date.Count; i++)
                {
                    if (Array.IndexOf(transactionitem.date[i].week, nowWEEK) != -1)
                    {
                        foreach (var classitem in classlist)
                        {
                            if (Array.IndexOf(classitem.Week, nowWEEK) != -1)
                            {
                                //当前课与当前时段的事件在同一周
                                //如果本周任意一节课与事件事件冲突 
                                if (transactionitem.date[i].day == classitem.Hash_day && transactionitem.date[i]._class == classitem.Hash_lesson)
                                { isInClassGrid = true; break; }
                            }
                        }
                        switch (transactionitem.date[i]._class)
                        {
                            case 0:
                            case 1:
                                RightC = 0;
                                break;
                            case 2:
                            case 3:
                                RightC = 1;
                                break;
                            case 4:
                            case 5:
                                RightC = 2;
                                break;
                        }
                        if (transactiontime[transactionitem.date[i].day, transactionitem.date[i]._class] == null)
                        {
                            long[] tempstr = new long[1];
                            tempstr[0] = transactionitem.id;
                            transactiontime[transactionitem.date[i].day, transactionitem.date[i]._class] = tempstr;
                        }
                        else if (Array.IndexOf(transactiontime[transactionitem.date[i].day, transactionitem.date[i]._class], transactionitem.id) == -1)
                        {
                            long[] temp = transactiontime[transactionitem.date[i].day, transactionitem.date[i]._class];
                            long[] templ = new long[temp.Length + 1];
                            for (int a = 0; a < temp.Length; a++)
                                templ[a] = temp[a];
                            //if (Array.IndexOf(templ, transactionitem.id) != -1)
                            templ[temp.Length] = transactionitem.id;
                            transactiontime[transactionitem.date[i].day, transactionitem.date[i]._class] = templ;
                        }
                        if (isInClassGrid)
                        {
                            //事件与课程冲突 就不订阅tapped事件了
                            Grid transactionGrid = new Grid();
                            transactionGrid.SetValue(Grid.RowProperty, System.Int32.Parse(transactionitem.date[i]._class * 2 + ""));
                            transactionGrid.SetValue(Grid.ColumnProperty, System.Int32.Parse(transactionitem.date[i].day + ""));
                            transactionGrid.SetValue(Grid.RowSpanProperty, System.Int32.Parse(2 + ""));

                            transactionGrid.Margin = new Thickness(2);

                            transactionGrid.HorizontalAlignment = HorizontalAlignment.Right;
                            transactionGrid.VerticalAlignment = VerticalAlignment.Top;
                            transactionGrid.Width = 8;
                            transactionGrid.Height = 8;
                            transactionGrid.BorderThickness = new Thickness(0);
                            transactionGrid.Background = new SolidColorBrush(Colors.Transparent);
                            Polygon pl = new Polygon();
                            PointCollection collection = new PointCollection();
                            collection.Add(new Point(0, 0));
                            collection.Add(new Point(10, 10));
                            collection.Add(new Point(10, 0));
                            pl.Points = collection;
                            pl.StrokeThickness = 0;
                            pl.Fill = new SolidColorBrush(Colors.White);
                            transactionGrid.Children.Add(pl);
                            isInClassGrid = false;
                            kebiaoGrid.Children.Add(transactionGrid);
                        }
                        else
                        {
                            Grid transactionGrid = new Grid();
                            transactionGrid.SetValue(Grid.RowProperty, System.Int32.Parse(transactionitem.date[i]._class * 2 + ""));
                            transactionGrid.SetValue(Grid.ColumnProperty, System.Int32.Parse(transactionitem.date[i].day + ""));
                            transactionGrid.SetValue(Grid.RowSpanProperty, System.Int32.Parse(2 + ""));

                            transactionGrid.Background = new SolidColorBrush(Tcolor[RightC]);

                            Grid polygonGrid = new Grid();
                            polygonGrid.HorizontalAlignment = HorizontalAlignment.Right;
                            polygonGrid.VerticalAlignment = VerticalAlignment.Top;
                            polygonGrid.Height = 8;
                            polygonGrid.Width = 8;
                            polygonGrid.Background = new SolidColorBrush(Colors.Transparent);
                            polygonGrid.Margin = new Thickness(2);
                            Polygon pl = new Polygon();
                            PointCollection collection = new PointCollection();
                            collection.Add(new Point(0, 0));
                            collection.Add(new Point(10, 10));
                            collection.Add(new Point(10, 0));
                            pl.Points = collection;
                            pl.Fill = new SolidColorBrush(Colors.White);
                            pl.StrokeThickness = 0;
                            polygonGrid.Children.Add(pl);
                            transactionGrid.Children.Add(polygonGrid);

                            isInClassGrid = false;
                            transactionGrid.Margin = new Thickness(0.5);

                            transactionGrid.Tapped += BackGrid_Tapped;
                            kebiaoGrid.Children.Add(transactionGrid);
                        }
                    }
                }
            }
        }
        private Grid FindOrCreateGridForLayout(Grid parent, string loc)
        {
            Tuple<int, int> quad;

            int row = 0;
            int col = 0;
            var gridName = (parent == baseImpl.RootUI ? kGridName : parent.Name) + "_" + loc;
            var pctl = (Grid)parent.FindName(gridName);
            if (pctl == null)
            {
                quad = TranslateQLoc(loc);
                row = quad.Item1;
                col = quad.Item2;

                var grid = new Grid();
                grid.Name = gridName;
                grid.HorizontalAlignment = HorizontalAlignment.Stretch;
                grid.VerticalAlignment = VerticalAlignment.Stretch;
                EnsureGrid(grid);
                grid.SetValue(Grid.RowProperty, row);
                grid.SetValue(Grid.ColumnProperty, col);

                parent.Children.Add(grid);
                pctl = grid;
            }
            return pctl;
        }