public void Init(string providerSpecified, bool noneProvider) { syncEngine = new SyncEngine(this, Owner is EssentialWindow); this.noneProvider = noneProvider; if (noneProvider) { this.lastSyncMessage.Content = "Choose your current provider."; this.lastSyncMessage.Visibility = Visibility.Visible; } try { if (!IsNET35Installed()) throw new System.Exception("Windows Live is unavailable. Install .NET 3.5 Framework."); Assembly a = LoadLocalAssembly( System.IO.Path.GetDirectoryName( Assembly.GetExecutingAssembly().Location) + "\\Synrc.WindowsLive.dll"); Type t = a.GetType("Synrc.LiveContactsProvider"); live = Activator.CreateInstance(t, new object[] { this, syncEngine }) as ISyncSource; //live = new LiveContactsProvider(this, syncEngine); } catch (Exception excp) { syncButton.DropDown.Items.Remove(GetSyncMenuItemByName("WindowsLive")); this.lastSyncMessage.Content = excp.Message; this.lastSyncMessage.Visibility = Visibility.Visible; } try { if (!IsOutlookInstalled()) throw new System.Exception("Outlook not installed."); //Assembly a = LoadLocalAssembly("Synrc.Outlook.dll"); //Type t = a.GetType("Synrc.OutlookContactsProvider"); //outlook = Activator.CreateInstance(t, new object[] { this, syncEngine}) as ISyncSource; outlook = new OutlookContactsProvider(this, syncEngine); } catch (System.IO.FileNotFoundException e) { Process reg = new Process(); reg.StartInfo.FileName = "regsvr32.exe"; reg.StartInfo.Arguments = "/s Redemption.dll"; reg.StartInfo.UseShellExecute = false; reg.StartInfo.CreateNoWindow = true; reg.StartInfo.RedirectStandardOutput = true; reg.Start(); reg.WaitForExit(); reg.Close(); outlook = new OutlookContactsProvider(this, syncEngine); } catch (Exception e) { syncButton.DropDown.Items.Remove(GetSyncMenuItemByName("Outlook")); } vista = new WindowsContactsProvider(this, syncEngine); gmail = new GmailContactsProvider(this, syncEngine); if (IsNokiaInstalled()) { nokia = new NokiaContactsProvider(this, syncEngine); nokiaDiscoverer = new NokiaDiscoverer(this, nokia as NokiaContactsProvider); this.syncButton.DropDown.Opened += new RoutedEventHandler(DropDown_Opened); nokiaDiscoverer.DiscoveryTask(); } if (!noneProvider) { switch (providerSpecified) { case "gmail": currentProvider = gmail; break; case "windows": currentProvider = vista; break; case "live": currentProvider = live; break; case "outlook": currentProvider = outlook; break; default: currentProvider = vista; break; } syncButton.DropDown.Items.Remove(GetSyncMenuItemByName(currentProvider.Name)); searchContext = syncEngine.Sync(currentProvider, currentProvider); } DataContext = searchContext; }
private void Window_Loaded(object sender, RoutedEventArgs e) { syncEngine = new SyncEngine(this, false); this.lastSyncMessage.Content = "Choose your current provider."; this.lastSyncMessage.Visibility = Visibility.Visible; try { if (!IsNET35Installed()) throw new System.Exception("Windows Live is unavailable. Install .NET 3.5 Framework."); Assembly a = LoadLocalAssembly( System.IO.Path.GetDirectoryName( Assembly.GetExecutingAssembly().Location) + "\\Synrc.WindowsLive.dll"); Type t = a.GetType("Synrc.LiveContactsProvider"); live = Activator.CreateInstance(t, new object[] { this, syncEngine }) as ISyncSource; //live = new LiveContactsProvider(this, syncEngine); } catch (Exception excp) { syncButton.DropDown.Items.Remove(GetSyncMenuItemByName("WindowsLive")); this.lastSyncMessage.Content = excp.Message; this.lastSyncMessage.Visibility = Visibility.Visible; } try { if (!IsOutlookInstalled()) throw new System.Exception("Outlook not installed."); //Assembly a = LoadLocalAssembly("Synrc.Outlook.dll"); //Type t = a.GetType("Synrc.OutlookContactsProvider"); //outlook = Activator.CreateInstance(t, new object[] { this, syncEngine}) as ISyncSource; outlook = new OutlookContactsProvider(this, syncEngine); } catch { syncButton.DropDown.Items.Remove(GetSyncMenuItemByName("Outlook")); } vista = new WindowsContactsProvider(this, syncEngine); gmail = new GmailContactsProvider(this, syncEngine); if (IsNokiaInstalled()) { nokia = new NokiaContactsProvider(this, syncEngine); nokiaDiscoverer = new NokiaDiscoverer(this, nokia as NokiaContactsProvider); this.syncButton.DropDown.Opened += new RoutedEventHandler(DropDown_Opened); nokiaDiscoverer.DiscoveryTask(); } currentProvider = null; //searchContext = syncEngine.Sync(currentProvider, currentProvider); DataContext = searchContext; }