private void cmbClass_SelectionChanged(object sender, SelectionChangedEventArgs e) { clsChanged = true; var temp = (Class)cmbClass.SelectedItem; if (rpBasicInfo.Children.Contains(addClass)) { rpBasicInfo.Children.Remove(addClass); rpBasicInfo.Children.Remove(txtLevel); rpBasicInfo.Children.Remove(txbLevel); rpBasicInfo.Children.Remove(txtHitPoints); rpBasicInfo.Children.Remove(txbHitPoints); } rpBasicInfo.Children.Remove(cmbSubclass); cmbSubclass.SelectionChanged += CmbSubclass_SelectionChanged;; cmbSubclass.ItemsSource = temp.Archetypes; cmbSubclass.Margin = new Thickness(0, 10, 0, 0); cmbSubclass.Width = 350; cmbSubclass.Height = 50; cmbSubclass.FontSize = 30; RelativePanel.SetAlignRightWithPanel(cmbSubclass, true); RelativePanel.SetBelow(cmbSubclass, sender); rpBasicInfo.Children.Add(cmbSubclass); // Set Saving Throws rbStr.IsChecked = temp.SaveProf[0]; rbDex.IsChecked = temp.SaveProf[1]; rbCon.IsChecked = temp.SaveProf[2]; rbInt.IsChecked = temp.SaveProf[3]; rbWis.IsChecked = temp.SaveProf[4]; rbCha.IsChecked = temp.SaveProf[5]; clsChanged = false; }
/// <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); }
protected override void OnNavigatedTo(NavigationEventArgs e) { if (e.Parameter == null) { return; } contest = e.Parameter as Contest; title.Text = contest.name; Dateo.Text = "Start Date"; Date.Text = contest.startDate.ToString(); int hours = contest.durationSeconds / 3600; int min = (contest.durationSeconds - hours * 3600) / 60; Durationo.Text = "Duration Time"; Duration.Text = hours.ToString() + " hour " + min.ToString() + " min "; RemainDateo.Text = "Remain Date"; TimeSpan diff = (DateTime.Now - contest.startDate).Negate(); RemainDate.Text = string.Format("{0:%d} days {0:%h} hours {0:%m} minutes ", diff) + (diff < TimeSpan.Zero?"Passed":"Left"); AppBarButton buttonForRegist = new AppBarButton(); buttonForRegist.Icon = new SymbolIcon(Symbol.Flag); buttonForRegist.Click += Regist_click; buttonForRegist.Label = "Alarm Me!"; panel.Children.Add(buttonForRegist); RelativePanel.SetAlignBottomWithPanel(buttonForRegist, true); RelativePanel.SetAlignRightWithPanel(buttonForRegist, true); }
void LoadRoomList() { SettingsModel settingsModel = SettingsModel.GetInstance(); List <string> rooms = settingsModel.Rooms; if (rooms.Count > 0) { foreach (string room in rooms) { RelativePanel relativePanel = new RelativePanel(); relativePanel.Width = 100; TextBlock roomText = new TextBlock(); roomText.Name = "rt" + rooms.IndexOf(room); roomText.Text = room; Button deleteButton = new Button(); RelativePanel.SetAlignRightWithPanel(deleteButton, true); RelativePanel.SetAlignVerticalCenterWith(deleteButton, roomText.Name); TextBlock deleteText = new TextBlock(); deleteText.Text = "\u2573"; deleteText.FontFamily = new FontFamily("Segoe UI Symbol"); deleteText.FontSize = 12; deleteText.Height = 20; deleteButton.Name = "db" + rooms.IndexOf(room); deleteButton.Click += new RoutedEventHandler(DeleteButton_Click); deleteButton.Content = deleteText; relativePanel.Children.Add(roomText); relativePanel.Children.Add(deleteButton); roomList.Items.Add(relativePanel); } } }
private void cmbRace_SelectionChanged(object sender, SelectionChangedEventArgs e) { var temp = (Race)cmbRace.SelectedItem; if (temp.Subraces.Count != 0) { cmbSubrace.ItemsSource = ((Race)cmbRace.SelectedItem).Subraces; cmbSubrace.Margin = new Thickness(0, 10, 0, 0); cmbSubrace.Width = 350; cmbSubrace.Height = 50; cmbSubrace.FontSize = 30; cmbSubrace.SelectionChanged += CmbSubrace_SelectionChanged; RelativePanel.SetAlignRightWithPanel(cmbSubrace, true); RelativePanel.SetBelow(cmbSubrace, sender); rpBasicInfo.Children.Add(cmbSubrace); RelativePanel.SetBelow(cmbClass, cmbSubrace); RelativePanel.SetBelow(txtClass, cmbSubrace); SetLanguages(temp); } else { RelativePanel.SetBelow(cmbClass, cmbRace); RelativePanel.SetBelow(txtClass, txtRace); rpBasicInfo.Children.Remove(cmbSubrace); SetAbilityBonuses(temp); SetLanguages(temp); } }
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 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); }
/// <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); }
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 void CmbSubclass_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (!clsChanged) { var temp = (Class)cmbClass.SelectedItem; // Define hitPoints txtHitPoints.Text = "HP:"; txtHitPoints.Margin = new Thickness(10, 10, 0, 0); txtHitPoints.Width = 50; txtHitPoints.Height = 40; txtHitPoints.FontSize = 25; txbHitPoints.PlaceholderText = "1" + temp.HitDice; txbHitPoints.Margin = new Thickness(10, 10, 0, 0); txbHitPoints.Width = 150; txbHitPoints.Height = 40; txbHitPoints.FontSize = 25; RelativePanel.SetAlignRightWithPanel(txbHitPoints, true); RelativePanel.SetBelow(txbHitPoints, sender); RelativePanel.SetLeftOf(txtHitPoints, txbHitPoints); RelativePanel.SetBelow(txtHitPoints, sender); // Define level txtLevel.Text = "Lvl:"; txtLevel.Margin = new Thickness(10, 10, 0, 0); txtLevel.Width = 50; txtLevel.Height = 40; txtLevel.FontSize = 25; txbLevel.Text = "1"; txbLevel.Margin = new Thickness(10, 10, 0, 0); txbLevel.Width = 50; txbLevel.Height = 40; txbLevel.FontSize = 25; RelativePanel.SetLeftOf(txbLevel, txtHitPoints); RelativePanel.SetBelow(txbLevel, sender); RelativePanel.SetLeftOf(txtLevel, txbLevel); RelativePanel.SetBelow(txtLevel, sender); // Define AddClassButton addClass.Content = "Add Class"; addClass.Click += AddClass_Click; addClass.Width = 150; addClass.Height = 50; addClass.Margin = new Thickness(0, 10, 100, 0); addClass.FontSize = 20; RelativePanel.SetBelow(addClass, txbHitPoints); RelativePanel.SetAlignRightWithPanel(addClass, true); // Create entities if (!rpBasicInfo.Children.Contains(txbHitPoints)) { rpBasicInfo.Children.Add(txbHitPoints); rpBasicInfo.Children.Add(txtHitPoints); rpBasicInfo.Children.Add(txbLevel); rpBasicInfo.Children.Add(txtLevel); rpBasicInfo.Children.Add(addClass); } } }
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); } }
public async Task LeftOfRightAligned() { /* * <RelativePanel> * <Border x:Name="BlueRect" Background="Blue" Height="100" Width="150" RelativePanel.AlignRightWithPanel="True"/> * <Border x:Name="RedRect" Background="Red" Height="100" Width="150" RelativePanel.LeftOf="BlueRect" Tag="Red"/> * </RelativePanel> */ await UIHelpers.RunUITest(async (container, info) => { container.Width = 400; container.Height = 300; var panel = new RelativePanel(); panel.Background = new SolidColorBrush(Colors.Green); var blueRect = new Border() { Width = 150, Height = 100, Background = new SolidColorBrush(Colors.Blue) }; RelativePanel.SetAlignRightWithPanel(blueRect, true); panel.Children.Add(blueRect); var redRect = new Border() { Width = 150, Height = 100, Background = new SolidColorBrush(Colors.Red) }; RelativePanel.SetLeftOf(redRect, blueRect); panel.Children.Add(redRect); container.Content = panel; var bitmap = await UIHelpers.RenderAsync(container, info.ScaleFactor); var redblobs = ImageAnalysis.FindConnectedPixels(bitmap, info.ScaleFactor, System.Drawing.Color.Red); var blueblobs = ImageAnalysis.FindConnectedPixels(bitmap, info.ScaleFactor, System.Drawing.Color.Blue); Assert.AreEqual(1, redblobs.Count); Assert.AreEqual(150, redblobs[0].Width); Assert.AreEqual(100, redblobs[0].Height); Assert.AreEqual(1, blueblobs.Count); Assert.AreEqual(150, blueblobs[0].Width); Assert.AreEqual(100, blueblobs[0].Height); Assert.AreEqual(redblobs[0].MaxColumn + 1, blueblobs[0].MinColumn); Assert.AreEqual(0, blueblobs[0].MinRow); Assert.AreEqual(100, redblobs[0].MinColumn); Assert.AreEqual(0, redblobs[0].MinRow); Assert.AreEqual(399, blueblobs[0].MaxColumn); }); }
/// <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 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); }
private void GenerateListItem(int index, String label) { // Container RelativePanel container = new RelativePanel(); container.Tag = index; Thickness border = container.BorderThickness; border.Bottom = 1; container.BorderThickness = border; container.BorderBrush = new SolidColorBrush(Colors.White); // Slot info TextBlock slot = new TextBlock(); slot.Text = "Slot " + (index + 1) + ": "; slot.VerticalAlignment = VerticalAlignment.Center; slot.HorizontalAlignment = HorizontalAlignment.Left; Thickness slot_margin = slot.Margin; slot_margin.Left = 25; slot.Margin = slot_margin; // Switch ToggleSwitch tswitch = new ToggleSwitch(); tswitch.Header = label; tswitch.Tag = index; tswitch.OffContent = "not available"; tswitch.OnContent = "available"; tswitch.IsOn = true; tswitch.Toggled += tswitch_Toggled; tswitch.HorizontalAlignment = HorizontalAlignment.Left; tswitch.VerticalAlignment = VerticalAlignment.Center; Thickness switch_margin = tswitch.Margin; switch_margin.Left = 150; tswitch.Margin = switch_margin; // Secure ToggleSwitch secure = new ToggleSwitch(); secure.Tag = index; secure.Header = " "; secure.OffContent = "not secure"; secure.OnContent = "secure"; secure.Toggled += Secure_Toggled; secure.HorizontalAlignment = HorizontalAlignment.Left; tswitch.VerticalAlignment = VerticalAlignment.Center; Thickness secure_margin = secure.Margin; secure_margin.Left = 350; secure.Margin = secure_margin; // Destroy Image dest = new Image(); dest.Source = new BitmapImage(new Uri("ms-appx://CoolSchrank/Assets/Plus.png")); dest.VerticalAlignment = VerticalAlignment.Center; dest.Height = 50; dest.Tag = index; dest.PointerPressed += dest_PointerPressed; RelativePanel.SetAlignRightWithPanel(dest, true); RotateTransform rt = new RotateTransform(); rt.Angle = 45; dest.RenderTransform = rt; // Adding container.Children.Add(slot); container.Children.Add(tswitch); container.Children.Add(secure); container.Children.Add(dest); list.Children.Add(container); }
/// <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;; } }
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++; } } } }
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(); }