/// <summary> /// Initialisation /// </summary> /// <param name="manager"></param> public IPreviewControl Initialize(RemoteFileInfoManager manager ) { _Current = this; this.Manager = manager; this.Control = new PreviewDatabaseControl(); Thread thread = new Thread(new ThreadStart(() => { string filename = null; try { filename = manager.Load(); } catch (FileLoadException ex) { MessageBox.Show("This file is locked by the phone application. To access it, quit the phone application and retry to select the file. It's typical in the case of a database file (.sdf)"); //Affichage que le fichier est locké ! return; } SqlServerCeHelper.Filename = filename; this.RefreshTable(); } )); thread.Start(); return this.Control; }
/// <summary> /// Initialisation /// </summary> /// <param name="manager"></param> public IPreviewControl Initialize(RemoteFileInfoManager manager ) { this.Manager = manager; PreviewTextControl control = null; control = new PreviewTextControl(); control.Plugin = this; Thread thread = new Thread( new ThreadStart( () => { try { using (StreamReader reader = new StreamReader(manager.Load())) { string text = reader.ReadToEnd(); if (text.Length > 200) text = text.Substring(0, 200) + "\r\n..."; Application.Current.Dispatcher.BeginInvoke(new Action(() => { control.Text = text; } )); } } catch { } } )); thread.Start(); this.Control = control as IPreviewControl; return this.Control; }