public static void AddRecord( string text, int source, int dest ) { RecentRecord rr = new RecentRecord (); rr.Text = text; rr.SourceIndex = source; rr.DestinationIndex = dest; AddRecord ( rr ); }
public static void LoadFromFile() { records = new List<RecentRecord> (); try { using ( IsolatedStorageFileStream fs = new IsolatedStorageFileStream ( "recentTranslated.recent", System.IO.FileMode.Open, IsolatedStorageFile.GetUserStoreForApplication () ) ) { BinaryReader br = new BinaryReader ( fs ); int len = br.ReadInt32 (); for ( int i = 0; i < len; i++ ) { RecentRecord rr = new RecentRecord (); rr.Text = br.ReadString (); rr.SourceIndex = br.ReadInt32 (); rr.DestinationIndex = br.ReadInt32 (); records.Add ( rr ); } } } catch { } }
public RecentItem(RecentRecord rr) { InitializeComponent (); Content = rr; }
private void btnSaveTranslated_Click( object sender, EventArgs e ) { RecentRecord rr = new RecentRecord (); rr.Text = txtText.Text; rr.SourceIndex = lstSource.SelectedIndex; rr.DestinationIndex = lstDest.SelectedIndex; RecentManager.AddRecord ( rr ); AddRecentItem ( rr ); RecentManager.SaveToFile (); }
private void AddRecentItem( RecentRecord rr ) { RecentItem ri = new RecentItem ( rr ); ri.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; ri.SetValue ( TiltEffect.IsTiltEnabledProperty, true ); ri.Tap += ( object ss, System.Windows.Input.GestureEventArgs ee ) => { txtText.Text = rr.Text; lstSource.SelectedIndex = rr.SourceIndex; lstDest.SelectedIndex = rr.DestinationIndex; pivotPage.SelectedIndex = 0; btnTranslate_Click ( btnTranslate, null ); }; ContextMenu cm = new ContextMenu (); cm.Tag = ri; cm.Items.Add ( new MenuItem () { Header = "삭제", Tag = ri } ); cm.Tap += ( object ss, System.Windows.Input.GestureEventArgs ee ) => { lstRecent.Items.Remove ( ( ss as ContextMenu ).Tag ); RecentManager.RemoveRecord ( ( ( ss as ContextMenu ).Tag as RecentItem ).Content as RecentRecord ); RecentManager.SaveToFile (); }; ContextMenuService.SetContextMenu ( ri, cm ); lstRecent.Items.Add ( ri ); }
public static void RemoveRecord( RecentRecord rr ) { records.Remove ( rr ); }
public static void AddRecord( RecentRecord rr ) { if ( records == null ) LoadFromFile (); records.Add ( rr ); }