void StopProgress ()
		{
			if (progress != null) {
				progress.StopAnimating ();
				NavigationItem.TitleView = null;
				progress = null;
			}
		}
Esempio n. 2
0
        void HandleBrowsingCompleted(object sender, EventArgs e)
        {
            if (!webViewVisible)
            {
                return;
            }

            if (authenticatingView == null)
            {
                authenticatingView = new UIView(View.Bounds)
                {
                    AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight,
                    BackgroundColor  = UIColor.FromRGB(0x33, 0x33, 0x33),
                };
                progress = new ProgressLabel("Authenticating...");
                var f = progress.Frame;
                var b = authenticatingView.Bounds;
                f.X            = (b.Width - f.Width) / 2;
                f.Y            = (b.Height - f.Height) / 2;
                progress.Frame = f;
                authenticatingView.Add(progress);
            }
            else
            {
                authenticatingView.Frame = View.Bounds;
            }

            webViewVisible = false;

            progress.StartAnimating();

            UIView.Transition(
                fromView: webView,
                toView: authenticatingView,
                duration: TransitionTime,
                options: UIViewAnimationOptions.TransitionCrossDissolve,
                completion: null);
        }
		void HandleSubmit ()
		{
			if (progress == null) {
				progress = new ProgressLabel (NSBundle.MainBundle.LocalizedString ("Verifying", "Verifying status message when adding accounts"));
				NavigationItem.TitleView = progress;
				progress.StartAnimating ();
			}

			cancelSource = new CancellationTokenSource ();

			authenticator.SignInAsync (cancelSource.Token).ContinueWith (task => {

				StopProgress ();

				if (task.IsFaulted) {
					this.ShowError ("Error Signing In", task.Exception);
				}
				else {
					authenticator.OnSucceeded (task.Result);
				}

			}, TaskScheduler.FromCurrentSynchronizationContext ());
		}
 void HandleBrowsingCompleted(object sender, EventArgs e)
 {
     if (authenticatingView == null)
     {
         authenticatingView = new UIView(Bounds)
         {
             AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight,
             BackgroundColor  = UIColor.FromRGB(0x33, 0x33, 0x33),
         };
         progress = new ProgressLabel("Authenticating...");
         var f = progress.Frame;
         var b = authenticatingView.Bounds;
         f.X            = (b.Width - f.Width) / 2;
         f.Y            = (b.Height - f.Height) / 2;
         progress.Frame = f;
         authenticatingView.Add(progress);
     }
     else
     {
         authenticatingView.Frame = Bounds;
     }
     progress.StartAnimating();
 }
        void HandleSubmit()
        {
            if (progress == null)
            {
                progress = new ProgressLabel(NSBundle.MainBundle.LocalizedString("Verifying", "Verifying status message when adding accounts"));
                NavigationItem.TitleView = progress;
                progress.StartAnimating();
            }

            cancelSource = new CancellationTokenSource();

            authenticator.SignInAsync(cancelSource.Token).ContinueWith(task => {
                StopProgress();

                if (task.IsFaulted)
                {
                    this.ShowError("Error Signing In", task.Exception);
                }
                else
                {
                    authenticator.OnSucceeded(task.Result);
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
 private void CreateBindings()
 {
     // menu bar
     PlayButton.SetBinding(IsEnabledProperty, new Binding("PlayButtonEnabled")
     {
         Source = _menuBarModel,
         Mode   = BindingMode.OneWay
     });
     PlayButtonImage.SetBinding(Image.SourceProperty, new Binding("PlayButtonImage")
     {
         Source = _menuBarModel,
         Mode   = BindingMode.OneWay
     });
     ProgressLabel.SetBinding(ContentProperty, new Binding("Progress")
     {
         Source = _menuBarModel,
         Mode   = BindingMode.OneWay
     });
     NowPlayingLabel.SetBinding(ContentProperty, new Binding("NowPlaying")
     {
         Source = _menuBarModel,
         Mode   = BindingMode.OneWay
     });
 }
		void HandleBrowsingCompleted (object sender, EventArgs e)
		{
			if (!webViewVisible) return;

			if (authenticatingView == null) {
				authenticatingView = new UIView (View.Bounds) {
					AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight,
					BackgroundColor = UIColor.FromRGB (0x33, 0x33, 0x33),
				};
				progress = new ProgressLabel ("Authenticating...");
				var f = progress.Frame;
				var b = authenticatingView.Bounds;
				f.X = (b.Width - f.Width) / 2;
				f.Y = (b.Height - f.Height) / 2;
				progress.Frame = f;
				authenticatingView.Add (progress);
			}
			else {
				authenticatingView.Frame = View.Bounds;
			}

			webViewVisible = false;

			progress.StartAnimating ();

			UIView.Transition (
				fromView: webView,
				toView: authenticatingView,
				duration: TransitionTime,
				options: UIViewAnimationOptions.TransitionCrossDissolve,
				completion: null);
		}
		void StopSharing ()
		{
			sharing = false;
			NavigationItem.RightBarButtonItem.Enabled = true;

			if (progress != null) {
				progress.StopAnimating ();
				NavigationItem.TitleView = null;
				progress = null;
			}
		}
		void StartSharing ()
		{
			sharing = true;
			NavigationItem.RightBarButtonItem.Enabled = false;

			if (progress == null) {
				progress = new ProgressLabel (NSBundle.MainBundle.LocalizedString ("Sending...", "Sending... status message when sharing"));
				NavigationItem.TitleView = progress;
				progress.StartAnimating ();
			}
		}
 private void RaiseEvent(object sender, EventArgs e)
 {
     ProgressLabel.Text = $"Event Raised: {DateTime.Now}";
     ProgressLabel.Invalidate();
     ProgressLabel.Update();
 }
Esempio n. 11
0
 public SplashScreen()
 {
     Instance = this;
     InitializeComponent();
     this.Load += (s, a) =>
     {
         List <bool> bools = new List <bool>();
         bools.AddRange(new bool[] { false, false, false });
         ProgressWorker.WorkerReportsProgress = true;
         ProgressWorker.DoWork += (_, e) =>
         {
             for (int i = 0; i < 103; i++)
             {
                 Thread.Sleep(50);
                 ProgressWorker.ReportProgress(i);
                 if (i < 30)
                 {
                     ProgressLabel.Invoke((MethodInvoker) delegate {
                         ProgressLabel.Text = $"Loading Sales {i}%";
                     });
                 }
                 if (i > 30 && i < 60)
                 {
                     ProgressLabel.Invoke((MethodInvoker) delegate {
                         ProgressLabel.Text = $"Initializing Accounts {i}%";
                     });
                     if (!bools[0])
                     {
                         bools[0] = true;
                         Accounts.InitializeDatabase();
                     }
                 }
                 if (i > 60 && i < 90)
                 {
                     ProgressLabel.Invoke((MethodInvoker) delegate {
                         ProgressLabel.Text = $"Getting Accounts {i}%";
                     });
                     if (!bools[1])
                     {
                         bools[1] = true;
                         Accounts.GetAllAccounts();
                     }
                 }
                 if (i > 90 && i < 101)
                 {
                     Thread.Sleep(250);
                     ProgressLabel.Invoke((MethodInvoker) delegate
                     {
                         ProgressLabel.Text = $"Loading Main Form {i}%";
                     });
                     if (!bools[2])
                     {
                         bools[2] = true;
                         this.Invoke((MethodInvoker) delegate
                         {
                             MainForm.Instance.InitializeMainForm();
                         });
                     }
                 }
                 if (i >= 101)
                 {
                     ProgressLabel.Invoke((MethodInvoker) delegate {
                         ProgressLabel.Text = $"Welcome to Windows 11";
                     });
                     Thread.Sleep(1000);
                 }
             }
         };
         ProgressWorker.ProgressChanged += (_, e) =>
         {
             ProgressLoader.Value = e.ProgressPercentage;
             DummyProgress.Value  = e.ProgressPercentage;
         };
         ProgressWorker.RunWorkerCompleted += (_, e) =>
         {
             this.Hide();
             MainForm.Instance.Show();
         };
         ProgressWorker.RunWorkerAsync();
     };
 }
Esempio n. 12
0
 private void UpdateProgress(string LabelText)
 {
     ProgressLabel.Text = "Progress: " + LabelText;
     ProgressLabel.Refresh();
 }
Esempio n. 13
0
        private async void MaterialFlatButton1_Click(object sender, EventArgs e)
        {
            SaveThumbnailCheckBox.Hide();
            materialProgressBar1.Show();
            ProgressLabel.Show();
            materialProgressBar1.Value = 0;
            materialFlatButton1.Hide();
            materialFlatButton2.Hide();

            var client  = new YoutubeClient();
            var videoId = YoutubeClient.ParseVideoId(SearchBoxInput.Text);

            ProgressLabel.Text         = "Searching Video";
            materialProgressBar1.Value = materialProgressBar1.Value + 1;

            var video = await client.GetVideoAsync(videoId);

            ProgressLabel.Text         = "Found Video";
            materialProgressBar1.Value = materialProgressBar1.Value + 1;

            var streamInfoSet = await client.GetVideoMediaStreamInfosAsync(videoId);

            var streamInfo = streamInfoSet.Muxed.WithHighestVideoQuality();

            var fileExtension = streamInfo.Container.GetFileExtension();
            var fileName      = $"{video.Title} - {video.Author}.{fileExtension}";

            fileName = ReplaceInvalidChars(fileName);

            ProgressLabel.Text = "Downloading Video";
            bool SaveThumbnail = SaveThumbnailCheckBox.Checked;
            int  TempProgressBarValue;

            if (SaveThumbnail)
            {
                TempProgressBarValue = 1;
            }
            else
            {
                TempProgressBarValue = 2;
            }
            materialProgressBar1.Value = materialProgressBar1.Value + TempProgressBarValue;

            await client.DownloadMediaStreamAsync(streamInfo, fileName);

            ProgressLabel.Text         = "Converting to MP3";
            materialProgressBar1.Value = materialProgressBar1.Value + 4;

            var    Convert       = new NReco.VideoConverter.FFMpegConverter();
            var    MP3FolderPath = "C:/Users/" + Environment.UserName + "/Music/mPlayer/";
            String SaveMP3File   = MP3FolderPath + fileName.Replace(".mp4", ".mp3");

            Convert.ConvertMedia(fileName, SaveMP3File, "mp3");

            if (SaveThumbnail)
            {
                ProgressLabel.Text         = "Saving Thumbnail";
                materialProgressBar1.Value = materialProgressBar1.Value + 1;
                var thumbnail = video.Thumbnails.HighResUrl;
                using (WebClient webClient = new WebClient())
                {
                    webClient.DownloadFile(thumbnail, "C:/Users/" + Environment.UserName + "/Music/mPlayer/Data/Thumbnails/" + fileName.Replace(".mp4", string.Empty) + ".jpg");;
                }
            }

            ProgressLabel.Text         = "Cleaning Old Files";
            materialProgressBar1.Value = materialProgressBar1.Value + 1;

            File.Delete(fileName);

            ProgressLabel.Text         = "Done. Refresh your Music!";
            materialProgressBar1.Value = materialProgressBar1.Value + 1;

            materialFlatButton1.Show();
            materialFlatButton2.Show();
        }
Esempio n. 14
0
 void Start()
 {
     mainPanel.SetActive(true);
     ProgressLabel.SetActive(false);
 }
Esempio n. 15
0
		void BuildUI ()
		{
			var b = View.Bounds;

			var statusHeight = 22.0f;

			//
			// Account Field
			//
			var fieldHeight = 33;

			accountField = new ChoiceField (
				#if ! __UNIFIED__
				new RectangleF (0, b.Y, b.Width, 33),
				#else
				new RectangleF (0, (float)b.Y, (float)b.Width, 33),
				#endif
				this,
				NSBundle.MainBundle.LocalizedString ("From", "From title when sharing"));
			View.AddSubview (accountField);
			b.Y += fieldHeight;
			b.Height -= fieldHeight;

			//
			// Text Editor
			//
			var editorHeight = b.Height;
			if (service.HasMaxTextLength || item.Links.Count > 0) {
				editorHeight -= statusHeight;
			}
			textEditor = new UITextView (
				#if ! __UNIFIED__
				new RectangleF (0, b.Y, b.Width, editorHeight)) 
				#else
				new RectangleF (0, (float) b.Y, (float) b.Width, (float)editorHeight)) 
				#endif
				{
				Font = TextEditorFont,
				AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight,
				Text = item.Text,
			};
			textEditor.Delegate = new TextEditorDelegate (this);
			View.AddSubview (textEditor);

			//
			// Icons
			//
			if (item.Images.Count > 0) {

				var rem = 4.0f;
				RectangleF f;
				var x = b.Right - AttachmentIcon.Size - 8 - rem*(item.Images.Count - 1);
				var y = textEditor.Frame.Y + 8;
				#if ! __UNIFIED__
				f = textEditor.Frame;
				f.Width = x - 8 - f.X;
				#else
				f = (RectangleF)textEditor.Frame;
				f.Width = (float)x - 8 - f.X;
				#endif
				textEditor.Frame = f;

				foreach (var i in item.Images) {
					var icon = new ImageIcon (i.Image);
					#if ! __UNIFIED__
					f = icon.Frame;
					f.X = x;
					f.Y = y;
					#else
					f = (RectangleF) icon.Frame;
					f.X = (float)x;
					f.Y = (float)y;
					#endif
					icon.Frame = f;

					View.AddSubview (icon);

					x += rem;
					y += rem;
				}
			}

			//
			// Remaining Text Length
			//
			if (service.HasMaxTextLength) {
				textLengthLabel = new TextLengthLabel (
					#if ! __UNIFIED__
					new RectangleF (4, b.Bottom - statusHeight, textEditor.Frame.Width - 8, statusHeight),
					#else
					new RectangleF (4, (float)(b.Bottom - statusHeight), (float)(textEditor.Frame.Width - 8), statusHeight),
					#endif
					service.MaxTextLength) {
					TextLength = service.GetTextLength (item),
				};
				View.AddSubview (textLengthLabel);
			}
			
			//
			// Links Label
			//
			if (item.Links.Count > 0) {
				linksLabel = new UILabel (
					#if ! __UNIFIED__
					new RectangleF (4, b.Bottom - statusHeight, textEditor.Frame.Width - 66, statusHeight)) {
					#else
					new RectangleF (4, (float)(b.Bottom - statusHeight), (float)(textEditor.Frame.Width - 66), statusHeight)) {
					#endif
					TextColor = UIColor.FromRGB (124, 124, 124),
					AutoresizingMask =
						UIViewAutoresizing.FlexibleTopMargin |
						UIViewAutoresizing.FlexibleBottomMargin |
						UIViewAutoresizing.FlexibleWidth,

					UserInteractionEnabled = false,
					BackgroundColor = UIColor.Clear,
					Font = UIFont.SystemFontOfSize (16),
					LineBreakMode = UILineBreakMode.HeadTruncation,
				};
				if (item.Links.Count == 1) {
					linksLabel.Text = item.Links[0].AbsoluteUri;
				}
				else {
					linksLabel.Text = string.Format (
						NSBundle.MainBundle.LocalizedString ("{0} links", "# of links label"),
						item.Links.Count);
				}
				View.AddSubview (linksLabel);
			}

			//
			// Navigation Items
			//
			NavigationItem.LeftBarButtonItem = new UIBarButtonItem (
				UIBarButtonSystemItem.Cancel,
				delegate {
					completionHandler (ShareResult.Cancelled);
				});


			NavigationItem.RightBarButtonItem = new UIBarButtonItem (
				NSBundle.MainBundle.LocalizedString ("Send", "Send button text when sharing"),
				UIBarButtonItemStyle.Done,
				HandleSend);

			//
			// Watch for the keyboard
			//
			NSNotificationCenter.DefaultCenter.AddObserver (UIKeyboard.DidShowNotification, HandleKeyboardDidShow);
			NSNotificationCenter.DefaultCenter.AddObserver (UIKeyboard.WillHideNotification, HandleKeyboardDidHide);
		}

		void HandleSend (object sender, EventArgs e)
		{
			if (sharing) return;
				
			item.Text = textEditor.Text;
			
			StartSharing ();

			var account = accounts.FirstOrDefault ();
			if (accounts.Count > 1 && accountField != null) {
				account = accounts.FirstOrDefault (x => x.Username == accountField.SelectedItem);
			}
			
			try {
				service.ShareItemAsync (item, account).ContinueWith (shareTask => {
					
					StopSharing ();
					
					if (shareTask.IsFaulted) {
						this.ShowError ("Share Error", shareTask.Exception);
					}
					else {
						completionHandler (ShareResult.Done);
					}
					
				}, TaskScheduler.FromCurrentSynchronizationContext ());
			}
			catch (Exception ex) {
				StopSharing ();
				this.ShowError ("Share Error", ex);
			}
		}

		void StartSharing ()
		{
			sharing = true;
			NavigationItem.RightBarButtonItem.Enabled = false;

			if (progress == null) {
				progress = new ProgressLabel (NSBundle.MainBundle.LocalizedString ("Sending...", "Sending... status message when sharing"));
				NavigationItem.TitleView = progress;
				progress.StartAnimating ();
			}
		}

		void StopSharing ()
		{
			sharing = false;
			NavigationItem.RightBarButtonItem.Enabled = true;

			if (progress != null) {
				progress.StopAnimating ();
				NavigationItem.TitleView = null;
				progress = null;
			}
		}