public ProgressIndicatorControl() { overlayrectangle = new Rectangle(); overlayrectangle.Fill = UI_Utils.Instance.Black; overlayrectangle.Visibility = Visibility.Collapsed; overlayrectangle.Opacity = 0.85; spProgress = new StackPanel(); spProgress.Visibility = Visibility.Collapsed; txtProgressText = new TextBlock(); txtProgressText.Margin = new Thickness(24, 250, 24, 0); txtProgressText.TextWrapping = TextWrapping.Wrap; txtProgressText.HorizontalAlignment = HorizontalAlignment.Center; txtProgressText.TextAlignment = TextAlignment.Center; txtProgressText.Foreground = UI_Utils.Instance.White; spProgress.Children.Add(txtProgressText); pBar = new PerformanceProgressBar(); pBar.IsEnabled = false; pBar.IsIndeterminate = true; pBar.VerticalAlignment = VerticalAlignment.Bottom; pBar.VerticalContentAlignment = VerticalAlignment.Center; pBar.HorizontalAlignment = HorizontalAlignment.Stretch; pBar.Height = 10; pBar.FontSize = 24; pBar.HorizontalContentAlignment = HorizontalAlignment.Center; pBar.IsTabStop = true; pBar.Opacity = 1; spProgress.Children.Add(pBar); }
public static void ShowProgress(this PerformanceProgressBar progressBar, bool show, bool forAppBarAlso = true) { progressBar.IsIndeterminate = show; progressBar.Visibility = show ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed; var page = progressBar.GetParent <PhoneApplicationPage>().ApplicationBar; if (page != null && forAppBarAlso) { progressBar.GetParent <PhoneApplicationPage>().ApplicationBar.EnableApplicationBar(!show); } }
/// <summary> /// Creates a new overlay progress bar. /// </summary> /// <param name="statusText">A initial value.</param> public ProgressOverlayControl(string statusText = "") { InitializeComponent(); this.Visibility = System.Windows.Visibility.Collapsed; _statusText = statusText; _base = (Grid)this.FindName("LayoutRoot"); _bar = (PerformanceProgressBar)this.FindName("OverlayProgressBar"); _textBlock = (TextBlock)this.FindName("OverlayText"); _textBlock.Text = statusText; }
public override void OnApplyTemplate() { base.OnApplyTemplate(); this.recordGeoButton = this.GetTemplateChild("recordGeoButton") as Button; this.performanceProgressBar = this.GetTemplateChild("performanceProgressBar") as PerformanceProgressBar; this.geoTextBlock = this.GetTemplateChild("geoTextBlock") as TextBlock; this.recordGeoButton.Click += this.OnRecordButtonClick; this.wasAplpyTemplate = true; if (this.isRecordedLocationChanged) { //AddRecordedLocation(this); } }
public ProgressControl() { // creating background background = new Rectangle(); background.StrokeThickness = 0; background.Stretch = Stretch.Fill; background.HorizontalAlignment = HorizontalAlignment.Stretch; background.VerticalAlignment = VerticalAlignment.Stretch; // creating progress bar progress = new PerformanceProgressBar(); progress.IsIndeterminate = true; progress.HorizontalAlignment = HorizontalAlignment.Stretch; progress.VerticalAlignment = VerticalAlignment.Center; // enable shading by default IsShaded = true; // ready to go Children.Add(background); Children.Add(progress); }
/// <summary> /// Opens the ProgressBar Popup. /// </summary> private void OpenPopup() { // Grab the frame for measurements. PhoneApplicationFrame rootVisual = Application.Current.RootVisual as PhoneApplicationFrame; // Panel that contains overlay layers _overlay = new Canvas { Background = new SolidColorBrush(Colors.Transparent) }; double width = rootVisual.ActualWidth; double height = rootVisual.ActualHeight; // Create a layer for the background brush (Prevents edge seeping). UIElement backgroundLayer = new Rectangle { Width = width, Height = height, Fill = (Brush)Application.Current.Resources["PhoneBackgroundBrush"], CacheMode = new BitmapCache(), }; _overlay.Children.Insert(0, backgroundLayer); // Create a layer for the page content WriteableBitmap writeableBitmap = new WriteableBitmap((int)width, (int)height); writeableBitmap.Render(rootVisual, null); writeableBitmap.Invalidate(); ScaleTransform scaleTransform = new ScaleTransform { CenterX = width / 2, CenterY = height / 2 }; UIElement contentLayer = new Image { Source = writeableBitmap, RenderTransform = scaleTransform, CacheMode = new BitmapCache(), }; _overlay.Children.Insert(1, contentLayer); // Create a layer for the background brush UIElement backgroundFadeLayer = new Rectangle { Width = width, Height = height, Fill = (Brush)Application.Current.Resources["PhoneBackgroundBrush"], Opacity = 0, CacheMode = new BitmapCache(), }; _overlay.Children.Insert(2, backgroundFadeLayer); // Prepare for scale animation double from = 1; double to = 0.94; TimeSpan timespan = TimeSpan.FromSeconds(0.42); IEasingFunction easingFunction = new ExponentialEase { EasingMode = EasingMode.EaseInOut }; _backgroundResizeStoryboard = new Storyboard(); // Create an animation for the X scale DoubleAnimation animationX = new DoubleAnimation { From = from, To = to, Duration = timespan, EasingFunction = easingFunction }; Storyboard.SetTarget(animationX, scaleTransform); Storyboard.SetTargetProperty(animationX, new PropertyPath(ScaleTransform.ScaleXProperty)); _backgroundResizeStoryboard.Children.Add(animationX); // Create an animation for the Y scale DoubleAnimation animationY = new DoubleAnimation { From = from, To = to, Duration = timespan, EasingFunction = easingFunction }; Storyboard.SetTarget(animationY, scaleTransform); Storyboard.SetTargetProperty(animationY, new PropertyPath(ScaleTransform.ScaleYProperty)); _backgroundResizeStoryboard.Children.Add(animationY); DoubleAnimation animationFade = new DoubleAnimation { From = 0, To = .8, Duration = timespan, EasingFunction = easingFunction }; Storyboard.SetTarget(animationFade, backgroundFadeLayer); Storyboard.SetTargetProperty(animationFade, new PropertyPath(Rectangle.OpacityProperty)); _backgroundResizeStoryboard.Children.Add(animationFade); _indicators = new StackPanel(); _progressBar = new PerformanceProgressBar() { Width = width, }; _indicators.Children.Add(_progressBar); _loadingText = new TextBlock { Text = AppResources.InitialLoadingText, Style = (Style)Application.Current.Resources["PhoneTextTitle3Style"], TextAlignment = TextAlignment.Center, Width = width }; _indicators.Children.Add(_loadingText); _errorText = new TextBlock { Text = AppResources.InitialLoadingFailedText, Style = (Style)Application.Current.Resources["PhoneTextAccentStyle"], TextAlignment = TextAlignment.Center, Width = width, Visibility = Visibility.Collapsed }; _indicators.Children.Add(_errorText); _overlay.Children.Add(_indicators); Canvas.SetLeft(_indicators, 0); Canvas.SetTop(_indicators, ((height / 2) - (_indicators.ActualHeight / 2))); _popup = new Popup { Child = _overlay }; _popup.Opened += (s, e) => { _progressBar.IsIndeterminate = true; _backgroundResizeStoryboard.Begin(); }; _popup.Closed += (s, e) => { _progressBar.IsIndeterminate = false; _progressBar.Visibility = Visibility.Collapsed; _loadingText.Visibility = Visibility.Collapsed; }; _popup.IsOpen = true; }
private void initializeBasedOnState(ConvMessage cm, bool isGroupChat, string userName, string messageString) { bool hasAttachment = cm.HasAttachment; string contentType = cm.FileAttachment == null ? "" : cm.FileAttachment.ContentType; bool isContact = hasAttachment && contentType.Contains(HikeConstants.CT_CONTACT); if (isContact) { messageString = string.IsNullOrEmpty(cm.FileAttachment.FileName) ? "contact" : cm.FileAttachment.FileName; } bool showDownload = cm.FileAttachment != null && (cm.FileAttachment.FileState == Attachment.AttachmentState.CANCELED || cm.FileAttachment.FileState == Attachment.AttachmentState.FAILED_OR_NOT_STARTED); bool isNudge = cm.MetaDataString != null && cm.MetaDataString.Contains("poke"); Rectangle BubbleBg = new Rectangle(); if (!isNudge) { BubbleBg.Fill = UI_Utils.Instance.ReceivedChatBubbleColor; bubblePointer.Fill = UI_Utils.Instance.ReceivedChatBubbleColor; } else { BubbleBg.Fill = UI_Utils.Instance.PhoneThemeColor; bubblePointer.Fill = UI_Utils.Instance.PhoneThemeColor; } Grid.SetRowSpan(BubbleBg, 2 + (isGroupChat ? 1 : 0)); wrapperGrid.Children.Add(BubbleBg); int rowNumber = 0; if (isGroupChat) { TextBlock textBlck = new TextBlock(); textBlck.Text = userName + " -"; textBlck.FontSize = 22; textBlck.FontFamily = UI_Utils.Instance.SemiBoldFont; textBlck.Foreground = UI_Utils.Instance.GroupChatHeaderColor; textBlck.Margin = userNameMargin; Grid.SetRow(textBlck, 0); wrapperGrid.Children.Add(textBlck); rowNumber = 1; } if (hasAttachment || isNudge) { attachment = new Grid(); RowDefinition r1 = new RowDefinition(); r1.Height = GridLength.Auto; RowDefinition r2 = new RowDefinition(); r2.Height = GridLength.Auto; attachment.RowDefinitions.Add(r1); attachment.RowDefinitions.Add(r2); Grid.SetRow(attachment, rowNumber); Grid.SetColumn(attachment, 1); wrapperGrid.Children.Add(attachment); MessageImage = new Image(); MessageImage.MaxWidth = 180; MessageImage.MaxHeight = 180; MessageImage.HorizontalAlignment = HorizontalAlignment.Left; MessageImage.Margin = imgMargin; if (contentType.Contains(HikeConstants.AUDIO)) { this.MessageImage.Source = UI_Utils.Instance.AudioAttachmentReceive; } else if (isNudge) { this.MessageImage.Source = UI_Utils.Instance.NudgeReceived; this.MessageImage.Height = 35; this.MessageImage.Width = 46; this.MessageImage.Margin = nudgeMargin; } else if (isContact) { this.MessageImage.Source = UI_Utils.Instance.ContactIcon; this.MessageImage.Height = 20; this.MessageImage.Width = 30; TextBlock textBlck = new TextBlock(); textBlck.Text = messageString; textBlck.FontSize = 22; textBlck.Foreground = UI_Utils.Instance.ReceiveMessageForeground; textBlck.Margin = contactMessageTextMargin; textBlck.TextWrapping = TextWrapping.Wrap; textBlck.FontFamily = UI_Utils.Instance.SemiLightFont; textBlck.MinWidth = 150; textBlck.MaxWidth = 330; Grid.SetRow(textBlck, 0); Grid.SetColumn(textBlck, 1); attachment.Children.Add(textBlck); } Grid.SetRow(MessageImage, 0); attachment.Children.Add(MessageImage); if ((contentType.Contains(HikeConstants.VIDEO) || contentType.Contains(HikeConstants.AUDIO) || showDownload) && !contentType.Contains(HikeConstants.LOCATION) && !contentType.Contains(HikeConstants.CT_CONTACT)) { PlayIcon = new Image(); PlayIcon.MaxWidth = 43; PlayIcon.MaxHeight = 42; if (contentType.Contains(HikeConstants.IMAGE)) { PlayIcon.Source = UI_Utils.Instance.DownloadIcon; } else { PlayIcon.Source = UI_Utils.Instance.PlayIcon; } PlayIcon.HorizontalAlignment = HorizontalAlignment.Center; PlayIcon.VerticalAlignment = VerticalAlignment.Center; PlayIcon.Margin = imgMargin; Grid.SetRow(PlayIcon, 0); attachment.Children.Add(PlayIcon); } if (!isNudge) { downloadProgress = new ProgressBar(); downloadProgress.Height = 10; downloadProgress.Background = new SolidColorBrush(Color.FromArgb(255, 0x99, 0x99, 0x99)); downloadProgress.Foreground = UI_Utils.Instance.ReceivedChatBubbleProgress; downloadProgress.Minimum = 0; downloadProgress.MaxHeight = 100; downloadProgress.Opacity = 0; if (showDownload) { temporaryProgressBar = new PerformanceProgressBar(); temporaryProgressBar.Height = 10; // temporaryProgressBar.Background = UI_Utils.Instance.TextBoxBackground; temporaryProgressBar.Foreground = UI_Utils.Instance.ReceivedChatBubbleProgress; temporaryProgressBar.IsEnabled = false; temporaryProgressBar.Opacity = 1; downloadProgress.Visibility = Visibility.Collapsed; downloadProgress.Opacity = 1; Grid.SetRow(temporaryProgressBar, 1); attachment.Children.Add(temporaryProgressBar); } Grid.SetRow(downloadProgress, 1); attachment.Children.Add(downloadProgress); } } else { MessageText = new LinkifiedTextBox(UI_Utils.Instance.ReceiveMessageForeground, 22, messageString); MessageText.Width = 330; if (!isGroupChat) { MessageText.Margin = messageTextMargin; } MessageText.FontFamily = UI_Utils.Instance.SemiLightFont; Grid.SetRow(MessageText, rowNumber); wrapperGrid.Children.Add(MessageText); } if (!isNudge) { TimeStampBlock = new TextBlock(); TimeStampBlock.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; TimeStampBlock.FontSize = 18; TimeStampBlock.Foreground = UI_Utils.Instance.ReceivedChatBubbleTimestamp; TimeStampBlock.Text = TimeStamp; TimeStampBlock.Margin = timeStampBlockMargin; Grid.SetRow(TimeStampBlock, rowNumber + 1); wrapperGrid.Children.Add(TimeStampBlock); } }