private void Scenario2_SizeChanged(object sender, SizeChangedEventArgs e) { bool isCurrentlySmall = e.NewSize.Width < 600; if (isSmall != isCurrentlySmall) { if (isCurrentlySmall) { RelativePanel.SetBelow(tbOverview, imgPoster); RelativePanel.SetAlignLeftWithPanel(tbOverview, true); RelativePanel.SetAlignLeftWithPanel(gridInfo, true); RelativePanel.SetBelow(grCast, gridInfo); lvCredits.ItemTemplate = (DataTemplate)Application.Current.Resources["CastNarrowTemplate"]; } else { RelativePanel.SetAlignLeftWithPanel(tbOverview, false); RelativePanel.SetAlignLeftWithPanel(gridInfo, false); RelativePanel.SetBelow(tbOverview, tbTitle); RelativePanel.SetRightOf(tbOverview, imgPoster); RelativePanel.SetBelow(grCast, imgPoster); lvCredits.ItemTemplate = (DataTemplate)Application.Current.Resources["CastWideTemplate"]; } isSmall = isCurrentlySmall; } }
/// <summary> /// Builds a relative panel containing the details of a voice memo /// </summary> /// <param name="voiceMemo">The voice memo to build the panel for</param> /// <param name="audioRecorder">The object that will play the voice memo's audio</param> /// <param name="DeleteCallBack">the callback function for when the voice memo's delete button is clicked</param> /// <returns></returns> public static RelativePanel BuildVoiceMemoPanel(VoiceMemo voiceMemo, AudioRecorder audioRecorder, Action DeleteCallBack = null) { var panel = new RelativePanel(); panel.Margin = new Thickness(0, 10, 0, 10); var ellipse = BuildMemoEllipse(); var titleBlock = BuildTitleBlock(voiceMemo); var durationBlock = BuildDurationBlock(voiceMemo); var dateRecordedBlock = BuildDateRecordedBlock(voiceMemo); var deleteButton = BuildDeleteButton(voiceMemo, audioRecorder, DeleteCallBack); var playbackButton = BuildPlayBackButton(voiceMemo, audioRecorder); panel.Children.Add(ellipse); panel.Children.Add(titleBlock); panel.Children.Add(durationBlock); panel.Children.Add(dateRecordedBlock); panel.Children.Add(deleteButton); panel.Children.Add(playbackButton); // position the elements within the panel RelativePanel.SetRightOf(titleBlock, ellipse); RelativePanel.SetAlignVerticalCenterWith(titleBlock, ellipse); RelativePanel.SetBelow(durationBlock, titleBlock); RelativePanel.SetAlignLeftWith(durationBlock, titleBlock); RelativePanel.SetBelow(dateRecordedBlock, durationBlock); RelativePanel.SetAlignLeftWith(dateRecordedBlock, durationBlock); RelativePanel.SetBelow(deleteButton, dateRecordedBlock); RelativePanel.SetAlignBottomWithPanel(deleteButton, true); RelativePanel.SetAlignLeftWithPanel(deleteButton, true); RelativePanel.SetBelow(playbackButton, dateRecordedBlock); RelativePanel.SetAlignBottomWithPanel(playbackButton, true); RelativePanel.SetAlignRightWithPanel(playbackButton, true); return(panel); }
public void RelativePanel_Can_Center() { using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface); var rect1 = new Rectangle { Height = 20, Width = 20 }; var rect2 = new Rectangle { Height = 20, Width = 20 }; var target = new RelativePanel { VerticalAlignment = Layout.VerticalAlignment.Center, HorizontalAlignment = Layout.HorizontalAlignment.Center, Children = { rect1, rect2 } }; RelativePanel.SetAlignLeftWithPanel(rect1, true); RelativePanel.SetBelow(rect2, rect1); target.Measure(new Size(400, 400)); target.Arrange(new Rect(target.DesiredSize)); Assert.Equal(new Size(20, 40), target.Bounds.Size); Assert.Equal(new Rect(0, 0, 20, 20), target.Children[0].Bounds); Assert.Equal(new Rect(0, 20, 20, 20), target.Children[1].Bounds); }
public void RelativePanel_Can_Center() { var rect1 = new Rectangle { Height = 20, Width = 20 }; var rect2 = new Rectangle { Height = 20, Width = 20 }; var target = new RelativePanel { VerticalAlignment = Layout.VerticalAlignment.Center, HorizontalAlignment = Layout.HorizontalAlignment.Center, Children = { rect1, rect2 } }; RelativePanel.SetAlignLeftWithPanel(rect1, true); RelativePanel.SetBelow(rect2, rect1); target.Measure(new Size(400, 400)); target.Arrange(new Rect(target.DesiredSize)); Assert.Equal(new Size(20, 40), target.Bounds.Size); Assert.Equal(new Rect(0, 0, 20, 20), target.Children[0].Bounds); Assert.Equal(new Rect(0, 20, 20, 20), target.Children[1].Bounds); }
public void Lays_Out_1_Child_Next_the_other() { var rect1 = new Rectangle { Height = 20, Width = 20 }; var rect2 = new Rectangle { Height = 20, Width = 20 }; var target = new RelativePanel { VerticalAlignment = Layout.VerticalAlignment.Top, HorizontalAlignment = Layout.HorizontalAlignment.Left, Children = { rect1, rect2 } }; RelativePanel.SetAlignLeftWithPanel(rect1, true); RelativePanel.SetRightOf(rect2, rect1); target.Measure(new Size(400, 400)); target.Arrange(new Rect(target.DesiredSize)); Assert.Equal(new Size(40, 20), target.Bounds.Size); Assert.Equal(new Rect(0, 0, 20, 20), target.Children[0].Bounds); Assert.Equal(new Rect(20, 0, 20, 20), target.Children[1].Bounds); }
private void AddAlarmToScreen(Alarm AlarmToAdd) { // each alarm is wrapped in a relative panel RelativePanel alarmPanel = new RelativePanel(); alarmPanel.Margin = new Thickness(5, 0, 5, 5); var borderBrush = new SolidColorBrush(Windows.UI.Colors.Gray); alarmPanel.BorderBrush = borderBrush; alarmPanel.BorderThickness = new Thickness(1); // create the text blocks for the title and date var alarmTitleBlock = this.CreateAlarmTitleBlock(AlarmToAdd); var alarmDateBlock = this.CreateAlarmDateBlock(AlarmToAdd); var deleteButton = this.CreateDeleteButton(AlarmToAdd); var editButton = this.CreateEditButton(AlarmToAdd); // add the blocks and buttons alarmPanel.Children.Add(alarmTitleBlock); alarmPanel.Children.Add(alarmDateBlock); alarmPanel.Children.Add(deleteButton); alarmPanel.Children.Add(editButton); // relatively place the edit text block RelativePanel.SetBelow(alarmDateBlock, alarmTitleBlock); // relatively place the delete button RelativePanel.SetAlignBottomWithPanel(deleteButton, true); RelativePanel.SetAlignLeftWithPanel(deleteButton, true); RelativePanel.SetBelow(deleteButton, alarmDateBlock); RelativePanel.SetLeftOf(deleteButton, editButton); // relatively place the edit button RelativePanel.SetAlignBottomWithPanel(editButton, true); RelativePanel.SetAlignRightWithPanel(editButton, true); RelativePanel.SetBelow(editButton, alarmDateBlock); this.VariableGrid.Children.Add(alarmPanel); }
/// <summary> /// Add minor update notification row /// </summary> /// <param name="moduleMenu">Module menu panel</param> private void AddMinorUpdateRow(Panel moduleMenu) { RelativePanel MinorUpdatePanel = new RelativePanel(); Grid.SetRow(MinorUpdatePanel, 1); DropShadowPanel MinorUpdateShadow = new DropShadowPanel { Style = ApplicationBase.Current.Resources["ShadowContent"] as Style, HorizontalContentAlignment = HorizontalAlignment.Stretch, VerticalContentAlignment = VerticalAlignment.Stretch }; RelativePanel.SetAlignTopWithPanel(MinorUpdateShadow, true); RelativePanel.SetAlignBottomWithPanel(MinorUpdateShadow, true); RelativePanel.SetAlignRightWithPanel(MinorUpdateShadow, true); RelativePanel.SetAlignLeftWithPanel(MinorUpdateShadow, true); Grid MinorUpdateContent = new Grid { Style = ApplicationBase.Current.Resources["ContentGrid"] as Style, HorizontalAlignment = HorizontalAlignment.Stretch }; Button MinorUpdateClose = new Button { Background = new SolidColorBrush(Windows.UI.Colors.Transparent), Content = "", Height = 40, Width = 40, FontFamily = new FontFamily("Segoe MDL2 Assets"), VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Right, HorizontalContentAlignment = HorizontalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center, Margin = new Thickness(0, 0, 10, 0) }; Binding minorUpdateCloseBinding = new Binding { Source = (DataContext as MainPageVMBase).CloseMinor }; BindingOperations.SetBinding(MinorUpdateClose, Button.CommandProperty, minorUpdateCloseBinding); TextBlock MinorUpdateText = new TextBlock { Text = "Your app has been udpated to version " + (DataContext as MainPageVMBase).CurrentVersion, Margin = new Thickness(10, 10, 50, 10), VerticalAlignment = VerticalAlignment.Center }; MinorUpdateContent.Children.Add(MinorUpdateClose); MinorUpdateContent.Children.Add(MinorUpdateText); MinorUpdateShadow.Content = MinorUpdateContent; MinorUpdatePanel.Children.Add(MinorUpdateShadow); moduleMenu.Children.Add(MinorUpdatePanel); }
/// <summary> /// Add module menu into page /// </summary> /// <param name="container">COntainer</param> public virtual void AddModuleMenu(Panel container) { if (container == null) { throw new ArgumentNullException("Parameter container is null."); } var pageHeader = container.Children.FirstOrDefault(x => (x as FrameworkElement).Name == "PageHeader"); DropShadowPanel ShadowPanel = new DropShadowPanel { Style = ApplicationBase.Current.Resources["ShadowContent"] as Style, HorizontalContentAlignment = HorizontalAlignment.Stretch, VerticalContentAlignment = VerticalAlignment.Stretch }; RelativePanel.SetBelow(ShadowPanel, pageHeader); RelativePanel.SetAlignBottomWithPanel(ShadowPanel, true); RelativePanel.SetAlignRightWithPanel(ShadowPanel, true); RelativePanel.SetAlignLeftWithPanel(ShadowPanel, true); Grid ContentGrid = new Grid { Style = ApplicationBase.Current.Resources["ContentGrid"] as Style }; RowDefinition RowMain = new RowDefinition(); RowDefinition MinorUpdateRow = new RowDefinition(); ValueWhenConverter boolToGridLength = new ValueWhenConverter { When = true, Value = new GridLength(50), Otherwise = new GridLength(0) }; Binding minorUpdateRowBinding = new Binding { Source = (DataContext as MainPageVMBase).ShowMinorUpdate, Mode = BindingMode.OneWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Converter = boolToGridLength }; BindingOperations.SetBinding(MinorUpdateRow, RowDefinition.HeightProperty, minorUpdateRowBinding); var MPVMB = DataContext as MainPageVMBase; ApplicationBase.Current.PropertyChangedNotifier.RegisterProperty(MinorUpdateRow, RowDefinition.HeightProperty, nameof(MPVMB.ShowMinorUpdate), viewModelType, converter: boolToGridLength); ContentGrid.RowDefinitions.Add(RowMain); ContentGrid.RowDefinitions.Add(MinorUpdateRow); AddMenuList(ContentGrid); AddMinorUpdateRow(ContentGrid); ShadowPanel.Content = ContentGrid; container.Children.Add(ShadowPanel); }
private async void ButtonAdd_Click(object sender, RoutedEventArgs e) { try { StackPanel stackPanel = new StackPanel(); TextBlock NameOfStyle = new TextBlock { Text = "Название стиля", Margin = new Thickness(10) }; TextBox NameOfStyleTextBlock = new TextBox { MaxLength = 255 }; RelativePanel relativePanel = new RelativePanel { FlowDirection = FlowDirection.LeftToRight, HorizontalAlignment = HorizontalAlignment.Stretch }; relativePanel.Children.Add(NameOfStyle); relativePanel.Children.Add(NameOfStyleTextBlock); RelativePanel.SetAlignLeftWithPanel(NameOfStyle, true); RelativePanel.SetAlignRightWithPanel(NameOfStyleTextBlock, true); RelativePanel.SetRightOf(NameOfStyleTextBlock, NameOfStyle); stackPanel.Children.Add(relativePanel); ContentDialog deleteFileDialog = new ContentDialog() { Title = "Подтверждение действия", Content = stackPanel, PrimaryButtonText = "ОК", MaxWidth = 500, SecondaryButtonText = "Отмена" }; ContentDialogResult result = await deleteFileDialog.ShowAsync(); if (result == ContentDialogResult.Primary) { await _styleService.CreateStyle(NameOfStyleTextBlock.Text); (DataContext as ApplicationViewModel).Styles = await _styleService.GetAllStyles(); } else if (result == ContentDialogResult.Secondary) { //header.Text = "Отмена действия"; } } catch (Exception ex) { Debug.WriteLine($"Message: {ex.Message}\r\nSource: { ex.Source}\r\nTarget Site Name: { ex.TargetSite.Name}\r\n{ ex.StackTrace}"); } }
private static void IsHome_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e) { var uc = (IncidentUserControl)d; if ((bool)e.NewValue) { //Grid.SetColumn(uc.StackPanel, 0); RelativePanel.SetAlignLeftWithPanel(uc.StackPanel, true); RelativePanel.SetAlignRightWithPanel(uc.StackPanel, false); } else { //Grid.SetColumn(uc.StackPanel, 1); RelativePanel.SetAlignLeftWithPanel(uc.StackPanel, false); RelativePanel.SetAlignRightWithPanel(uc.StackPanel, true); } }
/// <summary> /// Adds to columns. /// </summary> /// <param name="data">The data.</param> private void AddToColumns(MythicRootobject data) { var mainGrid = MenuGrid; _childGrid = mainGrid; RelativePanel.SetAlignLeftWithPanel(MainMythicPanel, true); RelativePanel.SetAlignRightWithPanel(MainMythicPanel, true); for (var i = 0; i < 100; i++) { for (var a = 0; a < 9; a++) { var tb = new TextBlock(); DefineText(tb); switch (a) { case 0: tb.Text = data.leading_groups[i].Ranking.ToString(); break; case 1: tb.Text = data.leading_groups[i].keystone_level.ToString(); break; case 2: tb.Text = data.leading_groups[i].Duration.ToString(); break; case 3: AddGroupMember(data, mainGrid, a, i); a = 7; break; case 8: tb.Text = data.leading_groups[i].completed_timestamp.ToString(); break; } if (a == 7) { continue; } var g = new Grid(); AddtoGrid(g, mainGrid, tb, a, i); } } }
private void AddFeedButton_Click(object sender, RoutedEventArgs e) { var rssInputBox = new TextBox(); rssInputBox = new TextBox { Header = "RSS链接", Width = 400 }; if (sender is FeedViewModel) { rssInputBox.Text = ((FeedViewModel)sender).Url; if (rssInputBox.Text == "") { return; } } rssInputPanel.Children.Add(rssInputBox); RelativePanel.SetAlignLeftWithPanel((UIElement)rssInputBox, true); RelativePanel.SetBelow(rssInputBox, rssInputPanel.Children[rssInputPanel.Children.Count - 2]); }
private RelativePanel CreateReminderCard(Reminder ReminderToAdd) { // each reminder is wrapped in a relative panel RelativePanel reminderPanel = new RelativePanel(); reminderPanel.Margin = new Thickness(5, 0, 5, 5); var borderBrush = new SolidColorBrush(Windows.UI.Colors.Gray); reminderPanel.BorderBrush = borderBrush; reminderPanel.BorderThickness = new Thickness(1); // create the text blocks for the title and date var ReminderTitleBlock = this.CreateReminderTitleBlock(ReminderToAdd); var ReminderDateBlock = this.CreateReminderDateBlock(ReminderToAdd); var ReminderDescriptionBlock = this.CreateDescriptionBlock(ReminderToAdd); var deleteButton = this.CreateDeleteButton(); var editButton = this.CreateEditButton(); // add the blocks and buttons reminderPanel.Children.Add(ReminderTitleBlock); reminderPanel.Children.Add(ReminderDateBlock); reminderPanel.Children.Add(ReminderDescriptionBlock); reminderPanel.Children.Add(deleteButton); reminderPanel.Children.Add(editButton); // relatively place the edit text block RelativePanel.SetRightOf(ReminderDateBlock, ReminderTitleBlock); RelativePanel.SetAlignRightWithPanel(ReminderDateBlock, true); // relatively place the description block RelativePanel.SetBelow(ReminderDescriptionBlock, ReminderTitleBlock); // relatively place the delete button RelativePanel.SetAlignBottomWithPanel(deleteButton, true); RelativePanel.SetAlignLeftWithPanel(deleteButton, true); RelativePanel.SetLeftOf(deleteButton, editButton); // relatively place the edit button RelativePanel.SetAlignBottomWithPanel(editButton, true); RelativePanel.SetAlignRightWithPanel(editButton, true); return(reminderPanel); }
/// <summary> /// Add content into page /// </summary> /// <param name="container">Container</param> protected virtual void AddContent(Panel container) { if (container == null) { throw new ArgumentNullException("Parameter container is null."); } var pageHeader = container.Children.FirstOrDefault(x => (x as FrameworkElement).Name == "PageHeader"); DropShadowPanel ShadowPanel = new DropShadowPanel() { Style = ApplicationBase.Current.Resources["ShadowContent"] as Style, HorizontalContentAlignment = HorizontalAlignment.Stretch, VerticalContentAlignment = VerticalAlignment.Stretch, }; RelativePanel.SetBelow(ShadowPanel, pageHeader); RelativePanel.SetAlignBottomWithPanel(ShadowPanel, true); RelativePanel.SetAlignRightWithPanel(ShadowPanel, true); RelativePanel.SetAlignLeftWithPanel(ShadowPanel, true); Grid ContentGrid = new Grid { Style = ApplicationBase.Current.Resources["ContentGrid"] as Style }; ColumnDefinition MasterFrame = new ColumnDefinition(); Binding masterFrameWidthBinding = new Binding() { Source = (GridLength)(DataContext as ViewModelBase).GetPropertyValue("MasterFrame"), Mode = BindingMode.OneWay }; BindingOperations.SetBinding(MasterFrame, ColumnDefinition.WidthProperty, masterFrameWidthBinding); ApplicationBase.Current.PropertyChangedNotifier.RegisterProperty(MasterFrame, ColumnDefinition.WidthProperty, "MasterFrame", viewModelType); slaveFrameCD = new ColumnDefinition(); slaveFrameCD.SetValue(FrameworkElement.NameProperty, "slaveFrameCD"); Binding slaveFrameCDWidthBinding = new Binding() { Source = (DataContext as ViewModelBase).GetPropertyValue("PaneVisibility"), Mode = BindingMode.OneWay, Converter = new BoolToGridVisibilityConverter() }; BindingOperations.SetBinding(slaveFrameCD, ColumnDefinition.WidthProperty, slaveFrameCDWidthBinding); ApplicationBase.Current.PropertyChangedNotifier.RegisterProperty(slaveFrameCD, ColumnDefinition.WidthProperty, "PaneVisibility", viewModelType, converter: new BoolToGridVisibilityConverter()); ContentGrid.ColumnDefinitions.Add(MasterFrame); ContentGrid.ColumnDefinitions.Add(slaveFrameCD); AddDataViewPart(ContentGrid); AddInAppNotify(ContentGrid); AddLoading(ContentGrid); AddSlavePane(ContentGrid); ShadowPanel.Content = ContentGrid; container.Children.Add(ShadowPanel); }
/// <summary> /// Create editable controls /// </summary> /// <param name="controlAnalyze">Analyze of property</param> /// <param name="previousControl">Previous control</param> /// <param name="uiModule">UI module</param> /// <returns>New control</returns> public static UIElement CreateEditableControl(KeyValuePair <string, PropertyAnalyze> controlAnalyze, ref UIElement previousControl, UIModule uiModule) { string controlName = controlAnalyze.Key; PropertyAnalyze controlData = controlAnalyze.Value; PropertyType controlTypeName = controlData.PropertyType; UIElement control; UIParamsAttribute customization = controlData.PropertyAttributes.FirstOrDefault(x => x.GetType() == typeof(UIParamsAttribute)) as UIParamsAttribute; var linkedTableAttribute = controlData.PropertyAttributes.FirstOrDefault(x => x.GetType() == typeof(LinkedTableAttribute)) as LinkedTableAttribute; if (linkedTableAttribute != null) { switch (linkedTableAttribute.LinkedTableRelation) { case LinkedTableRelation.One: control = LinkedTableSingleSelectorControl.CreateLinkedTableControl(controlName, controlData, controlTypeName, linkedTableAttribute); break; case LinkedTableRelation.Many: control = LinkedTableMultiSelectorControl.CreateLinkedTableControl(controlName, controlData, controlTypeName, linkedTableAttribute); break; default: throw new NotSupportedPropertyTypeException("Not supported LinkedTableRelation."); } } else { switch (controlTypeName) { case PropertyType.String: case PropertyType.Int: case PropertyType.Int32: case PropertyType.Double: case PropertyType.Char: case PropertyType.Decimal: case PropertyType.Float: control = new TextBox() { Name = controlName + Constants.DATA_CONTROL_IDENTIFIER, Margin = new Thickness(10), TextWrapping = TextWrapping.Wrap, PlaceholderText = "Insert " + controlName }; if (controlTypeName == PropertyType.Char) { (control as TextBox).MaxLength = 1; } if (customization != null && customization.UseLongTextInput) { (control as TextBox).Height = 150; } break; case PropertyType.Boolean: control = new CheckBox() { Content = controlName, Margin = new Thickness(10), Name = controlName + Constants.DATA_CONTROL_IDENTIFIER }; break; case PropertyType.DateTime: if (customization == null) { throw new MissingRequiredAdditionalDataException("Property DateTime require UIParams attribute for specificating design."); } control = new Grid() { Margin = new Thickness(10) }; RowDefinition labelRow = new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }; RowDefinition dateTimeRow = new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }; (control as Grid).RowDefinitions.Add(labelRow); (control as Grid).RowDefinitions.Add(dateTimeRow); TextBlock label = new TextBlock() { Name = controlName + Constants.LABEL_CONTROL_IDENTIFIER, Text = customization == null?controlTypeName.ToString() : customization.LabelDescription, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(0, 0, 0, 5) }; Grid.SetRow(label, 0); (control as Grid).Children.Add(label); //if (customization.ReadOnlyMode) //{ // TextBox data = new TextBox() // { // Text = "", // VerticalAlignment = VerticalAlignment.Center, // Margin = new Thickness(0, 0, 0, 5), // Name = controlName + DATA_CONTROL_IDENTIFIER // }; //} //else //{ // TextBlock data = new TextBlock() // { // Text = "", // VerticalAlignment = VerticalAlignment.Center, // Margin = new Thickness(0, 0, 0, 5), // Name = controlName + DATA_CONTROL_IDENTIFIER // }; //} UIElement dateTimeControl; switch (customization.DateTimeMode) { case DatePickerMode.Date: dateTimeControl = new CalendarDatePicker() { Date = DateTime.Today, HorizontalAlignment = HorizontalAlignment.Stretch, Margin = new Thickness(0, 5, 0, 0), PlaceholderText = "Select a date", Name = controlName + Constants.DATA_CONTROL_IDENTIFIER }; break; case DatePickerMode.Time: dateTimeControl = new TimePicker() { Time = DateTime.Now.TimeOfDay, HorizontalAlignment = HorizontalAlignment.Stretch, Margin = new Thickness(0, 5, 0, 0), Name = controlName + Constants.DATA_CONTROL_IDENTIFIER }; break; case DatePickerMode.DateAndTime: throw new Base.Exceptions.NotSupportedException("DateTime combination is not supported."); default: throw new Base.Exceptions.NotSupportedException("Not supported DatePickerMode."); } Grid.SetRow(dateTimeControl as FrameworkElement, 1); (control as Grid).Children.Add(dateTimeControl); break; case PropertyType.notImplementedYet: control = new Grid() { Background = new SolidColorBrush(Colors.Red), Margin = new Thickness(10), Height = 25 }; break; default: throw new NotSupportedPropertyTypeException("Not supported PropertyType."); } } RelativePanel.SetAlignLeftWithPanel(control, true); RelativePanel.SetAlignRightWithPanel(control, true); AddControlUnder(control, ref previousControl); return(control); }
/// <summary> /// Create readonly controls /// </summary> /// <param name="controlAnalyze">Analyze of property</param> /// <param name="previousControl">Previous control</param> /// <returns>New control</returns> internal static UIElement CreateDetailControl(KeyValuePair <string, PropertyAnalyze> controlAnalyze, ref UIElement previousControl) { string controlName = controlAnalyze.Key; PropertyAnalyze controlData = controlAnalyze.Value; PropertyType controlTypeName = controlData.PropertyType; UIElement control; UIParamsAttribute customization = controlData.PropertyAttributes.FirstOrDefault(x => x.GetType() == typeof(UIParamsAttribute)) as UIParamsAttribute; var linkedTableAttribute = controlData.PropertyAttributes.FirstOrDefault(x => x.GetType() == typeof(LinkedTableAttribute)) as LinkedTableAttribute; switch (controlTypeName) { case PropertyType.String: case PropertyType.Int: case PropertyType.Int32: case PropertyType.Double: case PropertyType.Char: case PropertyType.DateTime: case PropertyType.Boolean: if (customization == null && controlTypeName == PropertyType.DateTime) { throw new MissingRequiredAdditionalDataException("Property DateTime require UIParams attribute for specificating design."); } control = new Grid() { Margin = new Thickness(10), VerticalAlignment = VerticalAlignment.Stretch }; RowDefinition labelRow = new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }; RowDefinition dateTimeRow = new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }; (control as Grid).RowDefinitions.Add(labelRow); (control as Grid).RowDefinitions.Add(dateTimeRow); ColumnDefinition labelColumn = new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) }; ColumnDefinition dataColumn = new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) }; (control as Grid).ColumnDefinitions.Add(labelColumn); (control as Grid).ColumnDefinitions.Add(dataColumn); TextBlock label = new TextBlock() { VerticalAlignment = VerticalAlignment.Bottom, FontWeight = FontWeights.Bold, Margin = new Thickness(0, 0, 5, 0) }; if (customization.UseLabelDescription) { label.Text = customization.LabelDescription ?? ""; } else { label.Text = controlData.PropertyName; } Grid.SetRow(label, 0); (control as Grid).Children.Add(label); if (linkedTableAttribute != null && linkedTableAttribute.LinkedTableRelation == LinkedTableRelation.Many) { ListView linkedTableSelectedIds = new ListView() { Name = controlName + Constants.DATA_CONTROL_IDENTIFIER, VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Stretch, Margin = new Thickness(0, 5, 0, 5), Height = 250, SelectionMode = ListViewSelectionMode.None }; Grid.SetRow(linkedTableSelectedIds, 1); Grid.SetColumnSpan(linkedTableSelectedIds, 2); (control as Grid).Children.Add(linkedTableSelectedIds); } else { TextBlock data = new TextBlock() { Text = "", VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(0, 5, 0, 0), Name = controlName + Constants.DATA_CONTROL_IDENTIFIER }; (control as Grid).Children.Add(data); if (customization.ShowDetailOnOneLine) { data.Margin = new Thickness(5, 5, 0, 0); Grid.SetColumn(data, 1); } else { Grid.SetRow(data, 1); } } break; case PropertyType.notImplementedYet: control = new Grid() { Background = new SolidColorBrush(Colors.Red), Margin = new Thickness(10), Height = 25 }; break; default: throw new NotSupportedPropertyTypeException("Not supported PropertyType."); } RelativePanel.SetAlignLeftWithPanel(control, true); RelativePanel.SetAlignRightWithPanel(control, true); AddControlUnder(control, ref previousControl); return(control); }
public static void DisplayTasks(RelativePanel panel) { List <ToDoList> listComplete = new List <ToDoList> { }; List <ToDoList> listIncomplete = new List <ToDoList> { }; int count = 0; foreach (var t in tasks) { if (t.projectName == currentProject) { if (t.projCompleted == false) { listIncomplete.Add(t); } else { listComplete.Add(t); } } } listIncomplete = listIncomplete.OrderBy(x => x.projTask).ToList(); listComplete = listComplete.OrderBy(x => x.projTask).ToList(); foreach (var t in listIncomplete) { CheckBox check = new CheckBox { Tag = t.projTask, IsChecked = t.projCompleted, Width = 75, HorizontalContentAlignment = Windows.UI.Xaml.HorizontalAlignment.Center, Margin = new Windows.UI.Xaml.Thickness(50, 5, 0, 0), HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center }; HyperlinkButton block = new HyperlinkButton { Content = t.projTask, Margin = new Windows.UI.Xaml.Thickness(130, 5, 0, 0), Width = 820, HorizontalContentAlignment = Windows.UI.Xaml.HorizontalAlignment.Left, }; if (t.projCompleted == true) { block.Foreground = new SolidColorBrush(Windows.UI.Colors.DimGray); } if (count == 0) { RelativePanel.SetAlignTopWithPanel(check, true); RelativePanel.SetAlignLeftWithPanel(check, true); RelativePanel.SetAlignTopWithPanel(block, true); RelativePanel.SetAlignRightWithPanel(block, true); } else { RelativePanel.SetBelow(check, panel.Children[count - 1]); RelativePanel.SetAlignLeftWithPanel(check, true); RelativePanel.SetBelow(block, panel.Children[count - 1]); RelativePanel.SetAlignRightWithPanel(block, true); } panel.Children.Add(check); panel.Children.Add(block); count = count + 2;; } foreach (var t in listComplete) { //t.projTask = t.projTask + " -- " + t.dateCompleted.Date.ToString(); CheckBox check = new CheckBox { Tag = t.projTask, IsChecked = t.projCompleted, Width = 75, HorizontalContentAlignment = Windows.UI.Xaml.HorizontalAlignment.Center, Margin = new Windows.UI.Xaml.Thickness(50, 5, 0, 0), HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center }; HyperlinkButton block = new HyperlinkButton { Content = t.projTask, Margin = new Windows.UI.Xaml.Thickness(130, 5, 0, 0), Width = 820, HorizontalContentAlignment = Windows.UI.Xaml.HorizontalAlignment.Left, }; if (t.projCompleted == true) { block.Foreground = new SolidColorBrush(Windows.UI.Colors.DimGray); } if (count == 0) { RelativePanel.SetAlignTopWithPanel(check, true); RelativePanel.SetAlignLeftWithPanel(check, true); RelativePanel.SetAlignTopWithPanel(block, true); RelativePanel.SetAlignRightWithPanel(block, true); } else { RelativePanel.SetBelow(check, panel.Children[count - 1]); RelativePanel.SetAlignLeftWithPanel(check, true); RelativePanel.SetBelow(block, panel.Children[count - 1]); RelativePanel.SetAlignRightWithPanel(block, true); } panel.Children.Add(check); panel.Children.Add(block); count = count + 2;; } }
public async void ShowFileInfoDialog() { Windows.Storage.FileProperties.BasicProperties basicProperties = await File.GetBasicPropertiesAsync(); ContentDialog FileInfoDialog = new ContentDialog() { PrimaryButtonText = "OK" }; FileInfoDialog.Title = "File Information"; StackPanel ContentStackPanel = new StackPanel(); ContentStackPanel.Children.Add(new TextBlock() { Text = FileName, FontSize = 17 }); RelativePanel FileStackPanel = new RelativePanel(); TextBlock filePathTextBlock = new TextBlock() { Text = FilePath, FontSize = 12, IsTextSelectionEnabled = true, TextWrapping = TextWrapping.NoWrap, Padding = new Thickness(4) }; ScrollViewer filePathScrollViewer = new ScrollViewer() { Content = filePathTextBlock, HorizontalScrollBarVisibility = ScrollBarVisibility.Auto, MaxWidth = 320, Margin = new Thickness(0, 0, 90, 0) }; Button openFolderButton = new Button() { Content = "Open folder", FontSize = 12 }; FileStackPanel.Children.Add(filePathScrollViewer); FileStackPanel.Children.Add(openFolderButton); ContentStackPanel.Children.Add(FileStackPanel); openFolderButton.Click += OpenFolderButton_Click; ContentStackPanel.Children.Add(new TextBlock() { Text = "File type: " + FileType }); ContentStackPanel.Children.Add(new TextBlock() { Text = "File size: " + basicProperties.Size + " bytes" }); ContentStackPanel.Children.Add(new TextBlock() { Text = "Date created: " + File.DateCreated.DateTime }); ContentStackPanel.Children.Add(new TextBlock() { Text = "Date modified: " + basicProperties.DateModified.DateTime }); FileInfoDialog.Content = ContentStackPanel; RelativePanel.SetAlignLeftWithPanel(filePathScrollViewer, true); RelativePanel.SetAlignRightWithPanel(openFolderButton, true); await FileInfoDialog.ShowAsync(); }
private async void AddButtons() { int tabIndex = 1; count++; var style = new Style(); style = (Style)Application.Current.Resources["ProjButton"]; DataContext = this; //Remove Program Buttons foreach (Button b in ButtonPanel.Children) { if (b.Name != addNewButton.Name) { ButtonPanel.Children.Remove(b); } } addNewButton.TabIndex = 99; //Add Buttons if (Globals.projects != null) { foreach (var project in Globals.projects) { int numTasks = 0; if (project != null) { foreach (var t in Globals.tasks) { if ((t.projectName == project.projectName) && (t.projCompleted == false)) { numTasks++; } } RelativePanel panel = new RelativePanel { Margin = new Thickness(0, 105, 0, 0), Width = 130, Height = 25, }; TextBlock blockName = new TextBlock { Text = project.projectName, TextAlignment = TextAlignment.Center, TextWrapping = TextWrapping.Wrap, FontSize = 10, Margin = new Thickness(25, 0, 0, 0), Width = 80, }; RelativePanel.SetAlignLeftWithPanel(blockName, true); panel.Children.Add(blockName); if (numTasks != 0) { TextBlock blockTasks = new TextBlock { Text = numTasks.ToString(), TextAlignment = TextAlignment.Center, Margin = new Thickness(-1, 2, 0, 0), FontSize = 10, Width = 20, }; Brush shapeColor = Application.Current.Resources["SystemControlHighlightAccentBrush"] as SolidColorBrush; Ellipse shape = new Ellipse { Width = 20, Height = 20, Fill = shapeColor, }; RelativePanel.SetAlignRightWithPanel(shape, true); RelativePanel.SetAlignRightWithPanel(blockTasks, true); panel.Children.Add(shape); panel.Children.Add(blockTasks); } Button newButton = new Button { Name = project.projectName.Replace(" ", "") + "Button", Content = panel, Foreground = new SolidColorBrush(Windows.UI.Colors.White), Width = 150, Height = 150, Margin = new Thickness(5), TabIndex = tabIndex, Style = style, }; newButton.Click += ProjectButton_Click; if (tabIndex <= 5) { if (tabIndex == 1) { RelativePanel.SetAlignTopWithPanel(newButton, true); RelativePanel.SetAlignLeftWithPanel(newButton, true); } else { RelativePanel.SetAlignTopWithPanel(newButton, true); RelativePanel.SetRightOf(newButton, ButtonPanel.Children[tabIndex - 1]); } } if ((tabIndex > 5) && (tabIndex <= 10)) { if (tabIndex == 6) { RelativePanel.SetBelow(newButton, ButtonPanel.Children[1]); RelativePanel.SetAlignLeftWithPanel(newButton, true); } else { RelativePanel.SetBelow(newButton, ButtonPanel.Children[1]); RelativePanel.SetRightOf(newButton, ButtonPanel.Children[tabIndex - 1]); } } if ((tabIndex > 10) && (tabIndex <= 14)) { if (tabIndex == 11) { RelativePanel.SetAlignBottomWithPanel(newButton, true); RelativePanel.SetAlignLeftWithPanel(newButton, true); } else { RelativePanel.SetBelow(newButton, ButtonPanel.Children[6]); RelativePanel.SetRightOf(newButton, ButtonPanel.Children[tabIndex - 1]); } } // if (tabIndex > 14) // { // MessageDialog dialog = new MessageDialog("Max Projects Reached", "Max Projects Reached");///// // // await dialog.ShowAsync(); // } var backImg = new ImageBrush(); if ((project.imgSource != "") && (project.imgSource != null)) { StorageFile imageFile = await StorageFile.GetFileFromPathAsync(project.imgSource); var img = new BitmapImage(); using (var stream = await imageFile.OpenAsync(FileAccessMode.Read)) { img.SetSource(stream); } backImg.ImageSource = img; backImg.Stretch = Stretch.None; backImg.AlignmentY = AlignmentY.Top; backImg.AlignmentX = AlignmentX.Center; backImg.Opacity = .75; newButton.Background = backImg; } ButtonPanel.Children.Add(newButton); tabIndex++; } } } }