Пример #1
0
        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);
        }
Пример #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
        /// <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);
        }
Пример #4
0
        /// <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);
        }
Пример #5
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);
        }
Пример #6
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);
        }
Пример #7
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++;
                    }
                }
            }
        }
Пример #8
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);
        }