protected void GridViewFilterScelti_RowCommand(object sender, GridViewCommandEventArgs e) { GridViewRow gdr = (GridViewRow)((Control)e.CommandSource).NamingContainer; int rowIndex = gdr.RowIndex; if (e.CommandName == "Deseleziona") { GridViewRow row = GridViewFilterScelti.Rows[rowIndex]; row.Cells[1].Text = HttpUtility.HtmlDecode(row.Cells[1].Text); row.Cells[2].Text = HttpUtility.HtmlDecode(row.Cells[2].Text); if (row.Cells[1].Text == SelectedFilterDataTable_Types.Data) { dictionarySelectedRows.Remove(SelectedFilterDataTable_Types.Data); } else { Dictionary <string, string> CurrentDictionary; if (dictionarySelectedRows.TryGetValue(row.Cells[1].Text, out CurrentDictionary)) { CurrentDictionary.Remove(row.Cells[2].Text.Split((" - ").ToCharArray())[0]); dictionarySelectedRows[row.Cells[1].Text] = CurrentDictionary; } } dataTableSelectedItems.RemoveFiltro(row.Cells[1].Text, row.Cells[2].Text); GridViewFilterScelti.DataSource = dataTableSelectedItems.getDataTable(); GridViewFilterScelti.DataBind(); } }
public string TextToJSON(string Text) { try { Dictionary <string, object> Datos = new Dictionary <string, object>(); Dictionary <string, object> CurrentDictionary = null; foreach (string Line in Text.Split('\n')) { Console.WriteLine(Line); if (Line.Trim().StartsWith("[")) { string Header = Line.Replace("[", "").Replace("]", "").Trim(); CurrentDictionary = new Dictionary <string, object>(); if (!Datos.ContainsKey(Header)) { Datos.Add(Header, CurrentDictionary); } } else if (Line.Contains("|")) { string[] data = Line.Split('='); string[] values = data[1].Split('|'); var TempDictionary = new Dictionary <string, object>(); foreach (string value in values) { var subvalues = value.Split('&'); TempDictionary.Add(subvalues[0].Trim(), subvalues[1].Trim()); } CurrentDictionary.Add(data[0].Trim(), TempDictionary); } else if (Line.Contains("=")) { string[] data = Line.Split('='); if (CurrentDictionary.ContainsKey(data[0])) { int count = CurrentDictionary.Keys.Count <string>(x => x.Contains(data[0])); CurrentDictionary.Add(data[0].Trim() + count, data[1]?.Trim()); } else { CurrentDictionary.Add(data[0].Trim(), data[1]?.Trim()); } } } return(NASA.PROCNASA.BusinessLayer.CLS_Json.SerializeObject(Datos)); } catch (Exception ex) { throw new Exception(string.Format("TextToJSON: {0}", ex.Message)); } }
public void RemoveElement(string name) { try { CurrentDictionary.Remove(name); foreach (Selector dependency in Dependencies) { if (dependency.Items.Contains(name)) { dependency.Items.Remove(name); } //dependency.Items.Refresh(); } } catch { throw new Exception($"Element {name} doesn't exist"); } }
public void AddElement(AnyTransportClass element, string name) { try { CurrentDictionary.Add(name, element); foreach (Selector dependency in Dependencies) { if (!dependency.Items.Contains(name)) { dependency.Items.Add(name); // dependency.Items.Refresh(); } } } catch { throw new Exception($"Element {name} already exists"); } }
async void RenamePlaylist(object playlist) { var stop = System.Diagnostics.Stopwatch.StartNew(); var dictPl = playlist != null ? (playlist as Dictionary <Playlist, IEnumerable <Mediafile> >).First() : CurrentDictionary.First(); //get the dictionary containing playlist and songs. var selectedPlaylist = dictPl.Key; //get selected playlist var songs = dictPl.Value; //get songs of the playlist var dialog = new InputDialog() { Title = "Rename this playlist", Text = selectedPlaylist.Name, Description = selectedPlaylist.Description }; var Playlists = new Dictionary <Playlist, IEnumerable <Mediafile> >(); if (await dialog.ShowAsync() == ContentDialogResult.Primary) { var pl = new Playlist() { Name = dialog.Text, Description = dialog.Description }; if (songs.Count() > 0) { foreach (var file in songs) { file.Playlists.First(t => t.Name == selectedPlaylist.Name).Name = pl.Name; file.Playlists.First(t => t.Name == pl.Name).Description = pl.Description; LibVM.db.Update(file); //update database saving all songs and changes. } } ShellVM.PlaylistsItems.First(t => t.Label == selectedPlaylist.Name).Label = pl.Name; //change playlist name in the hamburgermenu LibVM.Options.First(t => t.Text == selectedPlaylist.Name).Text = pl.Name; //change playlist name in context menu of each song. LibVM.db.playlists.FindOne(t => t.Name == selectedPlaylist.Name); //change playlist name in the 'playlist' collection in the database. dictPl.Key.Name = pl.Name; Playlist = pl; //set this.Playlist to pl (local variable); } stop.Stop(); System.Diagnostics.Debug.WriteLine("It took: " + stop.ElapsedMilliseconds.ToString()); }
async void DeletePlaylist(object playlist) { var stop = System.Diagnostics.Stopwatch.StartNew(); var dictPl = playlist != null ? (playlist as Dictionary <Playlist, IEnumerable <Mediafile> >).First() : CurrentDictionary.First(); //get the dictionary containing playlist and songs. var selectedPlaylist = dictPl.Key; //get selected playlist var songs = dictPl.Value; //get songs of the playlist Windows.UI.Popups.MessageDialog dia = new Windows.UI.Popups.MessageDialog("Do you want to delete this playlist?", "Confirmation"); dia.Commands.Add(new Windows.UI.Popups.UICommand("Yes") { Id = 0 }); dia.Commands.Add(new Windows.UI.Popups.UICommand("No") { Id = 1 }); dia.DefaultCommandIndex = 0; dia.CancelCommandIndex = 1; var result = await dia.ShowAsync(); if (result.Label == "Yes") { if (songs.Count() > 0) //check to see if there are any songs. If not then the playlist is empty. { foreach (var file in songs) { file.Playlists.Remove(file.Playlists.First(t => t.Name == selectedPlaylist.Name)); //remove playlist from the song. LibVM.db.Update(file); //update database and save all changes. } } ShellVM.PlaylistsItems.Remove(ShellVM.PlaylistsItems.First(t => t.Label == selectedPlaylist.Name)); //delete from hamburger menu LibVM.Options.Remove(LibVM.Options.First(t => t.Text == selectedPlaylist.Name)); //delete from context menu LibVM.db.playlists.Delete(t => t.Name == selectedPlaylist.Name); //delete from database. } stop.Stop(); System.Diagnostics.Debug.WriteLine("It took: " + stop.ElapsedMilliseconds.ToString()); }