示例#1
0
        /// <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);
        }
示例#2
0
        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);
        }
示例#3
0
        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;
        }
示例#4
0
        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;
            }
        }
示例#5
0
        public void StretchedPanel_Measures_Correctly(double availableWidth, double availableHeight, double desiredWidth, double desiredHeight)
        {
            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.Stretch,
                HorizontalAlignment = Layout.HorizontalAlignment.Stretch,
                Children            =
                {
                    rect1, rect2
                }
            };

            RelativePanel.SetBelow(rect2, rect1);
            target.Measure(new Size(availableWidth, availableHeight));
            target.Arrange(new Rect(target.DesiredSize));

            Assert.Equal(desiredWidth, target.DesiredSize.Width);
            Assert.Equal(desiredHeight, target.DesiredSize.Height);
        }
示例#6
0
        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);
            }
        }
示例#7
0
        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);
        }
示例#8
0
 private void SetUpUI()
 {
     this.StartRecordingButton  = VoiceMemoUIHelper.BuildStartRecordingButton(this.StartRecording);
     this.StopRecordingButton   = VoiceMemoUIHelper.BuildStopRecordingButton(this.StopRecording);
     this.SaveRecordingButton   = VoiceMemoUIHelper.BuildSaveRecordingButton(this.SaveRecording);
     this.DeleteRecordingButton = VoiceMemoUIHelper.BuildDeleteRecordingButton(this.DeleteRecording);
     this.RecordingNameBox      = VoiceMemoUIHelper.BuildDisplayNameTextBox();
     // relatively place all the components
     RelativePanel.SetAlignVerticalCenterWithPanel(StartRecordingButton, true);
     RelativePanel.SetAlignHorizontalCenterWithPanel(StartRecordingButton, true);
     RelativePanel.SetAlignVerticalCenterWithPanel(StopRecordingButton, true);
     RelativePanel.SetAlignHorizontalCenterWithPanel(StopRecordingButton, true);
     RelativePanel.SetAlignVerticalCenterWithPanel(SaveRecordingButton, true);
     RelativePanel.SetAlignHorizontalCenterWithPanel(SaveRecordingButton, true);
     RelativePanel.SetAlignVerticalCenterWithPanel(DeleteRecordingButton, true);
     RelativePanel.SetAlignHorizontalCenterWithPanel(DeleteRecordingButton, true);
     // place the save and delete buttons next to each other
     RelativePanel.SetLeftOf(DeleteRecordingButton, SaveRecordingButton);
     // place the text box below the save button
     RelativePanel.SetBelow(RecordingNameBox, SaveRecordingButton);
     RelativePanel.SetAlignLeftWith(RecordingNameBox, SaveRecordingButton);
     RelativePanel.SetAlignRightWith(RecordingNameBox, SaveRecordingButton);
     // hide all our buttons except the start recording one
     this.ResetUIComponents();
     // now add everything to the dynamic area
     this.DynamicArea.Children.Add(StartRecordingButton);
     this.DynamicArea.Children.Add(StopRecordingButton);
     this.DynamicArea.Children.Add(SaveRecordingButton);
     this.DynamicArea.Children.Add(DeleteRecordingButton);
     this.DynamicArea.Children.Add(RecordingNameBox);
 }
示例#9
0
        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);
        }
示例#10
0
        /// <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);
        }
示例#11
0
        /// <summary>
        /// Add control under selected control
        /// </summary>
        /// <param name="control">Control to add under control</param>
        /// <param name="upperControl">Upper control</param>
        private static void AddControlUnder(UIElement control, ref UIElement upperControl)
        {
            if (upperControl != null)
            {
                RelativePanel.SetBelow(control, upperControl);
            }

            upperControl = control;
        }
示例#12
0
 // often crash in xaml desigher when using visualstateManager to change the relativePanel properties
 // so put the resoponse logic to the sizeChanged
 private void PlayingView_SizeChanged(object sender, SizeChangedEventArgs e)
 {
     if (e.NewSize.Width >= (double)App.Current.Resources["MediumWindowSnapPoint"])
     {
         RelativePanel.SetRightOf(this.lyricsGrid, this.playerGrid);
         RelativePanel.SetBelow(this.lyricsGrid, null);
     }
     else
     {
         RelativePanel.SetRightOf(this.lyricsGrid, null);
         RelativePanel.SetBelow(this.lyricsGrid, this.playerGrid);
     }
 }
示例#13
0
        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);
                }
            }
        }
示例#14
0
        private void IncomeTypeChanged(object sender, SelectionChangedEventArgs e)
        {
            switch ((sender as ComboBox).SelectedItem)
            {
            // the use of  x:DeferLoadStrategy="Lazy" should be considered here
            case "Sale":
                if (datePicker.Visibility == Visibility.Visible)
                {
                    datePicker.Visibility = Visibility.Collapsed;
                }
                if (paymentPerionCB.Visibility == Visibility.Visible)
                {
                    paymentPerionCB.Visibility = Visibility.Collapsed;
                }
                RelativePanel.SetBelow(amountTxtBx, customerBox);
                break;

            case "Invoice":
                datePicker.Header = "Date of Transaction";
                RelativePanel.SetBelow(datePicker, customerBox);
                datePicker.Margin = new Thickness(0, 0, 0, 10);
                RelativePanel.SetBelow(amountTxtBx, datePicker);
                if (datePicker.Visibility == Visibility.Collapsed)
                {
                    datePicker.Visibility = Visibility.Visible;
                }
                if (paymentPerionCB.Visibility == Visibility.Visible)
                {
                    paymentPerionCB.Visibility = Visibility.Collapsed;
                }
                break;

            case "Subscription":
                datePicker.Header = "Start of Subscription";
                RelativePanel.SetBelow(datePicker, customerBox);
                datePicker.Margin = new Thickness(0, 0, 0, 10);
                RelativePanel.SetBelow(paymentPerionCB, datePicker);
                RelativePanel.SetBelow(amountTxtBx, paymentPerionCB);
                paymentPerionCB.Margin = new Thickness(0, 10, 0, 10);
                if (datePicker.Visibility == Visibility.Collapsed)
                {
                    datePicker.Visibility = Visibility.Visible;
                }
                if (paymentPerionCB.Visibility == Visibility.Collapsed)
                {
                    paymentPerionCB.Visibility = Visibility.Visible;
                }
                break;
            }
        }
示例#15
0
        private void MyUserControl1_VisibleBoundsChanged(Windows.UI.ViewManagement.ApplicationView sensor, object args)
        {
            var Width = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().VisibleBounds.Width;

            if (Width >= 500)
            {
                RelativePanel.SetRightOf(boxtest, texttest);
                RelativePanel.SetBelow(testButon, texttest);
            }
            else
            {
                RelativePanel.SetRightOf(boxtest, texttest);
                RelativePanel.SetBelow(testButon, texttest);
                RelativePanel.SetAlignBottomWith(boxtest, texttest);
            }
        }
示例#16
0
        public void SetMnemonics(Kanji item)
        {
            string input        = item.data.meaning_mnemonic;
            string inputReading = item.data.reading_mnemonic;

            var meaningText = CreateMnemonicTextBlock(input);

            mainRelative.Children.Add(meaningText);
            if (!String.IsNullOrEmpty(inputReading))
            {
                var readingText = CreateMnemonicTextBlock(inputReading);
                subRel.Children.Add(readingText);
                RelativePanel.SetBelow(readingText, ReadingSubd);
            }
            RelativePanel.SetBelow(meaningText, MeaningSub);
        }
示例#17
0
        private void UcRatingText_VisibleBoundsChanged(Windows.UI.ViewManagement.ApplicationView sender, object args)
        {
            var Width = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().VisibleBounds.Width;

            if (Width >= 360)
            {
                RelativePanel.SetBelow(tbTexto, null);
                RelativePanel.SetRightOf(tbTexto, rcStars);
                RelativePanel.SetAlignVerticalCenterWith(tbTexto, rcStars);
                RelativePanel.SetAlignVerticalCenterWithPanel(rcStars, true);
            }
            else
            {
                RelativePanel.SetRightOf(tbTexto, null);
                RelativePanel.SetBelow(tbTexto, rcStars);
                RelativePanel.SetAlignVerticalCenterWith(tbTexto, null);
                RelativePanel.SetAlignVerticalCenterWithPanel(rcStars, false);
            }
        }
        private void FavorityUC_VisibleBoundsChanged(ApplicationView sender, object args)
        {
            var width = ApplicationView.GetForCurrentView().VisibleBounds.Width;

            if (width >= 360)
            {
                //VisualStateManager.GoToState(this, "Width360", false);
                RelativePanel.SetBelow(FavText, null);
                RelativePanel.SetRightOf(FavText, Stars);
                RelativePanel.SetAlignVerticalCenterWith(FavText, Stars);
            }
            else
            {
                //VisualStateManager.GoToState(this, "Width0", false);
                RelativePanel.SetRightOf(FavText, null);
                RelativePanel.SetBelow(FavText, Stars);

                RelativePanel.SetAlignVerticalCenterWith(FavText, null);
                RelativePanel.SetAlignVerticalCenterWithPanel(Stars, false);
            }
        }
示例#19
0
        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 void MyUserControl1_VisibleBoundsChanged(Windows.UI.ViewManagement.ApplicationView sender, object args)
        {
            var width = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().VisibleBounds.Width;

            if (width >= 360)
            {
                RelativePanel.SetBelow(FavText, null);
                RelativePanel.SetRightOf(FavText, Stars);

                RelativePanel.SetAlignVerticalCenterWith(FavText, Stars);
                RelativePanel.SetAlignVerticalCenterWithPanel(Stars, true);
            }
            else
            {
                RelativePanel.SetBelow(FavText, null);
                RelativePanel.SetRightOf(FavText, Stars);

                RelativePanel.SetAlignVerticalCenterWith(FavText, null);
                RelativePanel.SetAlignVerticalCenterWithPanel(Stars, false);
            }
        }
示例#21
0
        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);
        }
示例#22
0
        /// <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);
        }
示例#23
0
        private void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
//                this.Background = new SolidColorBrush(Color.FromArgb(255,128, 128, 128));
                if (AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.IoT")
                {
                    // "Windows.Desktop"
                    // "Windows.Mobile" (phone)
                    // "Windows.IoT"
                    _fUseNetworkTime = true;
                }
                Action resetCameras = () =>
                {
                    lock (_timerLock)
                    {
                        _cameraDevices = null;// force reload
                    }
                };
                var deviceWatcher = DeviceInformation.CreateWatcher(DeviceClass.VideoCapture);
                deviceWatcher.Added += new TypedEventHandler <DeviceWatcher, DeviceInformation>(
                    (wat, info) => { resetCameras(); });
                deviceWatcher.Removed += new TypedEventHandler <DeviceWatcher, DeviceInformationUpdate>(
                    (wat, info) => { resetCameras(); });
                deviceWatcher.Updated += new TypedEventHandler <DeviceWatcher, DeviceInformationUpdate>(
                    (wat, info) => { resetCameras(); });
                deviceWatcher.Stopped += new TypedEventHandler <DeviceWatcher, object>(
                    (wat, obj) => { deviceWatcher.Start(); });
                deviceWatcher.Start();
                var relPanel = new RelativePanel();
                var spCtrls  = new StackPanel()
                {
                    Orientation = Orientation.Horizontal
                };
                _img.HorizontalAlignment = HorizontalAlignment.Center;
                _img.Stretch             = Stretch.UniformToFill;
                _btnSwitchCamera         = new Button()
                {
                    IsEnabled = _cameraDevices?.Count > 1,
                    Width     = 260
                };
                SetBtnSwitchLabel();
                ToolTipService.SetToolTip(_btnSwitchCamera, new ToolTip()
                {
                    Content = "Click to switch camera if available"
                });
                spCtrls.Children.Add(_btnSwitchCamera);
                _btnSwitchCamera.Click += (oc, ec) =>
                {
                    IncrementCameraInUse();
                    SetBtnSwitchLabel();
                };
                _chkCycleCameras = new CheckBox()
                {
                    Content   = "Cycle Cameras",
                    IsChecked = false
                };
                ToolTipService.SetToolTip(_chkCycleCameras, new ToolTip()
                {
                    Content = "Automatically switch through all attached cameras"
                });
                spCtrls.Children.Add(_chkCycleCameras);
                relPanel.Children.Add(spCtrls);
                var tbInterval = new TextBox()
                {
                    Text = "7"
                };
                spCtrls.Children.Add(tbInterval);
                var btnQuit = new Button()
                {
                    Content = "Quit"
                };
                spCtrls.Children.Add(btnQuit);
                btnQuit.Click += (oq, eq) =>
                {
                    lock (_timerLock)
                    {
                        // make sure we're done with cam before exit
                        Application.Current.Exit();
                    }
                };
                spCtrls.Children.Add(_tbStatus);
                relPanel.Children.Add(_img);
                RelativePanel.SetBelow(_img, spCtrls);
                var tmr = new DispatcherTimer();
                tmr.Interval          = TimeSpan.FromSeconds(4);
                tbInterval.LostFocus += (otb, etb) =>
                {
                    double n;
                    if (double.TryParse(tbInterval.Text, out n))
                    {
                        tmr.Interval = TimeSpan.FromSeconds(n);
                    }
                };
                bool fIsInTickRoutine = false;
                _tsSinceLastTimeCheck = TimeSpan.FromDays(1); // force time check
                tmr.Tick += async(ot, et) =>
                {
                    if (!fIsInTickRoutine)
                    {
                        fIsInTickRoutine = true;
                        if (Monitor.TryEnter(_timerLock))
                        {
                            try
                            {
                                if (_fUseNetworkTime)
                                {
                                    _tsSinceLastTimeCheck += tmr.Interval;
                                    if (_tsSinceLastTimeCheck.TotalMinutes >= 1)
                                    {
                                        // resync the clock
                                        try
                                        {
                                            _dtLastTimeCheck = await NtpClient.GetDateTimeAsync();

                                            _tsSinceLastTimeCheck = TimeSpan.Zero;
                                        }
                                        catch (Exception ex)
                                        {
                                            _tbStatus.Text = ex.ToString(); // task cancelled exception
                                        }
                                    }
                                }
                                await LookForCameraAndTakeAPicture();
                            }
                            finally
                            {
                                Monitor.Exit(_timerLock);
                            }
                        }
                        fIsInTickRoutine = false;
                    }
                };
                tmr.Start();
                this.Content = relPanel;
            }
            catch (Exception ex)
            {
                this.Content = new TextBlock()
                {
                    Text = ex.ToString()
                };
            }
        }
示例#24
0
        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;;
            }
        }
示例#25
0
        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++;
                    }
                }
            }
        }