private void HideNowPlayingAnimation() { EventPanel.Visibility = Visibility.Visible; PlaybackControlPanelBorder.Visibility = Visibility.Visible; BottomArea.Height = BottomArea.ActualHeight; RelativePanel.SetAlignTopWithPanel(BottomArea, false); var sb = Resources["HideNowPlayingStoryboard"] as Storyboard; var animation = sb.Children[0] as DoubleAnimationUsingKeyFrames; var keyframe = animation.KeyFrames[0] as SplineDoubleKeyFrame; keyframe.Value = 60; var cpAnimation = sb.Children[1] as DoubleAnimation; cpAnimation.From = PlaybackControlPanel.Opacity; var npAnimation = sb.Children[2] as DoubleAnimation; npAnimation.From = NowPlayingPage.Opacity; DisableManipulation(); sb.Begin(); sb.Completed += OnHideNowPlayingStoryboardCompleted; }
/// <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); }
// page loaded private async void OnShowNowPlayingStoryboardCompleted(object sender, object e) { EnableManipulation(); var sb = sender as Storyboard; sb.Completed -= OnShowNowPlayingStoryboardCompleted; RelativePanel.SetAlignTopWithPanel(BottomArea, true); BottomArea.Height = double.NaN; _isInNowPlaying = true; EventPanel.Visibility = Visibility.Collapsed; if (await LrcAutoSearch()) { await Task.Delay(200); LrcPresenter.ForceRefresh(); } }
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++; } } } }
/// <summary> /// Search for the selected item in Spotify /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void SearchButton_Click(object sender, RoutedEventArgs e) { string feedbackMessage = ""; if (Feedback == null) { return; } Feedback.Text = ""; feedbackMessage = ""; PlaylistHeader.Visibility = Visibility.Collapsed; TracklistHeader.Visibility = Visibility.Collapsed; AlbumlistHeader.Visibility = Visibility.Collapsed; ResultsHeaderContainer.Visibility = Visibility.Collapsed; if (SearchBox.Text == "") { feedbackMessage = "Please enter text to search for (I can't read your mind...yet)"; } else { searchSave = SearchBox.Text; searchTypeSave = SearchType.SelectedIndex; MainPanel.SetValue(MarginProperty, new Thickness(0, 20, 0, 0)); RelativePanel.SetAlignTopWithPanel(SearchBox, true); ComboBoxItem selected = SearchType.SelectedValue as ComboBoxItem; String selectedString = selected.Content.ToString().ToLower(); UriBuilder searchUriBuilder = new UriBuilder(SEARCH_URL); List <KeyValuePair <string, string> > queryParams = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("type", selectedString), new KeyValuePair <string, string>("limit", "10"), new KeyValuePair <string, string>("q", SearchBox.Text.Replace(" ", "+")) }; string queryParamsString = RequestHandler.ConvertToQueryString(queryParams); searchUriBuilder.Query = queryParamsString; string searchResultString = await RequestHandler.SendCliGetRequest(searchUriBuilder.Uri.ToString()); JsonObject searchResultJson = new JsonObject(); try { searchResultJson = JsonObject.Parse(searchResultString); } catch (COMException) { return; } ClearResults(); Results.Visibility = Visibility.Visible; // playlists if (selectedString == "playlist") { if (searchResultJson.TryGetValue("playlists", out IJsonValue playlistsJson) && playlistsJson.ValueType == JsonValueType.Object) { JsonObject playlists = playlistsJson.GetObject(); if (playlists.TryGetValue("items", out IJsonValue itemsJson) && itemsJson.ValueType == JsonValueType.Array) { JsonArray playlistsArray = itemsJson.GetArray(); if (playlistsArray.Count == 0) { feedbackMessage = "No playlists found."; } else { ResultsHeaderContainer.Visibility = Visibility.Visible; PlaylistHeader.Visibility = Visibility.Visible; long loadingKey = DateTime.Now.Ticks; MainPage.AddLoadingLock(loadingKey); App.mainPage.SetLoadingProgress(PlaybackSource.Spotify, 0, playlistsArray.Count, loadingKey); foreach (JsonValue playlistJson in playlistsArray) { if (playlistJson.GetObject().TryGetValue("href", out IJsonValue fullHref) && fullHref.ValueType == JsonValueType.String) { string fullPlaylistString = await RequestHandler.SendCliGetRequest(fullHref.GetString()); Playlist playlist = new Playlist(); await playlist.SetInfo(fullPlaylistString); PlaylistList playlistList = new PlaylistList(playlist); try { if (!App.isInBackgroundMode) { Results.Items.Add(playlistList); if (Results.Items.IndexOf(playlistList) % 2 == 1) { playlistList.TurnOffOpaqueBackground(); } } } catch (COMException) { } App.mainPage.SetLoadingProgress(PlaybackSource.Spotify, Results.Items.Count, playlistsArray.Count, loadingKey); } } MainPage.RemoveLoadingLock(loadingKey); } } } } // track else if (selectedString == "track") { if (searchResultJson.TryGetValue("tracks", out IJsonValue tracksJson) && tracksJson.ValueType == JsonValueType.Object) { JsonObject tracks = tracksJson.GetObject(); if (tracks.TryGetValue("items", out IJsonValue itemsJson) && itemsJson.ValueType == JsonValueType.Array) { JsonArray tracksArray = itemsJson.GetArray(); if (tracksArray.Count == 0) { feedbackMessage = "No tracks found."; } else { ResultsHeaderContainer.Visibility = Visibility.Visible; TracklistHeader.Visibility = Visibility.Visible; long loadingKey = DateTime.Now.Ticks; MainPage.AddLoadingLock(loadingKey); App.mainPage.SetLoadingProgress(PlaybackSource.Spotify, 0, tracksArray.Count, loadingKey); foreach (JsonValue trackJson in tracksArray) { Track track = new Track(); await track.SetInfoDirect(trackJson.Stringify()); TrackList trackList = new TrackList(track); try { if (!App.isInBackgroundMode) { Results.Items.Add(trackList); if (Results.Items.IndexOf(trackList) % 2 == 1) { trackList.TurnOffOpaqueBackground(); } } } catch (COMException) { } App.mainPage.SetLoadingProgress(PlaybackSource.Spotify, Results.Items.Count, tracksArray.Count, loadingKey); } MainPage.RemoveLoadingLock(loadingKey); } } } } // album else if (selectedString == "album") { if (searchResultJson.TryGetValue("albums", out IJsonValue albumsJson) && albumsJson.ValueType == JsonValueType.Object) { JsonObject albums = albumsJson.GetObject(); if (albums.TryGetValue("items", out IJsonValue itemsJson) && itemsJson.ValueType == JsonValueType.Array) { JsonArray albumsArray = itemsJson.GetArray(); if (albumsArray.Count == 0) { feedbackMessage = "No albums found."; } else { ResultsHeaderContainer.Visibility = Visibility.Visible; AlbumlistHeader.Visibility = Visibility.Visible; long loadingKey = DateTime.Now.Ticks; MainPage.AddLoadingLock(loadingKey); App.mainPage.SetLoadingProgress(PlaybackSource.Spotify, 0, albumsArray.Count, loadingKey); foreach (JsonValue albumJson in albumsArray) { Album album = new Album(); await album.SetInfo(albumJson.Stringify()); AlbumList albumList = new AlbumList(album); try { if (!App.isInBackgroundMode) { Results.Items.Add(albumList); if (Results.Items.IndexOf(albumList) % 2 == 1) { albumList.TurnOffOpaqueBackground(); } } } catch (COMException) { } App.mainPage.SetLoadingProgress(PlaybackSource.Spotify, Results.Items.Count, albumsArray.Count, loadingKey); } MainPage.RemoveLoadingLock(loadingKey); } } } } } Feedback.Text = feedbackMessage; if (feedbackMessage == "") { Feedback.Visibility = Visibility.Collapsed; } else { Feedback.Visibility = Visibility.Visible; } }
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;; } }