本文整理匯總了C#中Windows.UI.Xaml.Controls.Grid.SetValue方法的典型用法代碼示例。如果您正苦於以下問題:C# Grid.SetValue方法的具體用法?C# Grid.SetValue怎麽用?C# Grid.SetValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Windows.UI.Xaml.Controls.Grid
的用法示例。
在下文中一共展示了Grid.SetValue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: AddTile
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: Draw
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);
}
}
示例3: Convert
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: InsertOrders
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);
//.........這裏部分代碼省略.........
示例5: SetClassAll
/// <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);
}
示例6: SetKebiaoGridBorder
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);
}
示例7: SetClass
/// <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);
}
示例8: AddOnePrintPreviewPage
/// <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);
//.........這裏部分代碼省略.........
示例9: AddOnePrintPreviewPage
/// <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;
}
示例10: CreateAnimationTile
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;
}
示例11: CreatePeelAnimationStoryboard
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;
}
示例12: SetClassAll
/// <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;
//.........這裏部分代碼省略.........
示例13: SetClassDay
/// <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);
}
示例14: SetTransactionAll
/// <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));
//.........這裏部分代碼省略.........
示例15: SetTransactionDay
/// <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 + ""));
//.........這裏部分代碼省略.........