public void RefreshNews(string strUrl) { txtStatus.Text = myVariables.LoadingWait; RefreshNewsDelegate del = new RefreshNewsDelegate(RefreshNewsAsych); AsyncCallback callback = new AsyncCallback(XMLHasFinished); del.BeginInvoke(strUrl, callback, null); }
public void RefreshNews(string strUrl) { RefreshNewsDelegate del = new RefreshNewsDelegate(RefreshNewsAsych); AsyncCallback callback = new AsyncCallback(XMLHasFinished); del.BeginInvoke(strUrl, callback, null); }
private void XMLHasFinished(IAsyncResult theResult) { RefreshNewsDelegate del = (RefreshNewsDelegate)((AsyncResult)theResult).AsyncDelegate; List <RssItem> lstItems = del.EndInvoke(theResult); if (lstItems.Count > 0) { theItem = lstItems.First(); } this.Dispatcher.BeginInvoke(new System.Windows.Forms.MethodInvoker(delegate() { if (theItem != null) { blogText.ClearValue(FlowDocumentReader.DocumentProperty); try { FlowDocument theDocument = XamlReader.Load(new XmlTextReader(new StringReader(theItem.Description))) as FlowDocument; theDocument.Background = App.Current.Resources["LightAreaFill"] as RadialGradientBrush; ParseLinks(theDocument); //insert the date and the title Paragraph pgDateAndTitle = new Paragraph(); pgDateAndTitle.FontFamily = App.Current.Resources["FontFamily"] as FontFamily; pgDateAndTitle.FontWeight = FontWeights.Bold; pgDateAndTitle.FontSize = 20; pgDateAndTitle.Inlines.Add(new Run(theItem.Title)); pgDateAndTitle.Inlines.Add(new LineBreak()); pgDateAndTitle.Inlines.Add(new Run(theItem.Published.ToString("yyyy-MM-dd HH:mm:ss"))); theDocument.Blocks.InsertBefore(theDocument.Blocks.FirstBlock, pgDateAndTitle); blogText.Document = theDocument; btnFullArticle.IsEnabled = true; } catch (Exception ex) { Paragraph myErrorParagraph = new Paragraph(); myErrorParagraph.FontSize = 18; myErrorParagraph.FontFamily = App.Current.Resources["FontFamily"] as FontFamily; myErrorParagraph.Inlines.Add(new Run(myVariables.UnableToDisplayRSS)); myErrorParagraph.Inlines.Add(new LineBreak()); myErrorParagraph.Inlines.Add(new Run(ex.Message)); FlowDocument myErrorDocument = new FlowDocument(); myErrorDocument.Background = App.Current.Resources["LightAreaFill"] as RadialGradientBrush; myErrorDocument.Blocks.Add(myErrorParagraph); blogText.Document = myErrorDocument; } } }), System.Windows.Threading.DispatcherPriority.Normal); }
private void XMLHasFinished(IAsyncResult theResult) { RefreshNewsDelegate del = (RefreshNewsDelegate)((AsyncResult)theResult).AsyncDelegate; List <RssItem> lstItems = del.EndInvoke(theResult); this.Dispatcher.BeginInvoke(new System.Windows.Forms.MethodInvoker(delegate() { txtStatus.Text = myVariables.Loaded + " " + lstItems.Count.ToString(CultureInfo.InvariantCulture) + " " + myVariables.Items; lstNewsItems.ItemsSource = lstItems; //select the first item in the list box if (lstItems.Count > 0) { lstNewsItems.SelectedIndex = 0; } }), System.Windows.Threading.DispatcherPriority.Normal); }
public ClientLauncher(UserPreferences myUserPreferences) { InitializeComponent(); _ServerInfo = myUserPreferences.DefaultServerInformation; theUserPreferences = myUserPreferences; //does this exe even exist yet? if (!File.Exists(SWGANHPAth + _ServerInfo.SafeFolderName + "\\swganh.exe")) { PatchProgress myPatchProgress = new PatchProgress(_ServerInfo, myUserPreferences); myPatchProgress.Loaded += new RoutedEventHandler(myPatchProgress_Loaded); myPatchProgress.OnError += new EventHandler<ErrorMessageEventArgs>(myPatchProgress_OnError); myPatchProgress.PatchComplete += new EventHandler<Patcher.PatchFunctionCompleteEventArgs>(myPatchProgress_PatchComplete); grdRightPanel.Children.Clear(); grdRightPanel.Children.Add(myPatchProgress); btnLaunchClient.IsEnabled = false; } else { //read the first article RefreshNewsDelegate del = new RefreshNewsDelegate(RefreshNewsAsych); AsyncCallback callback = new AsyncCallback(XMLHasFinished); del.BeginInvoke(_ServerInfo.RSSFeedUrl, callback, null); } lblServerName.Text = _ServerInfo.ServerName; lblServerBuild.Text = "999"; lblServerPopulation.Text = _ServerInfo.Population.ToString(); //do we have any credentials for this server? if (myUserPreferences.ServerCredentials.Any(sc => sc.ServerId == _ServerInfo.ServerId)) { cboUsername.ItemsSource = myUserPreferences.ServerCredentials.Where(sc => sc.ServerId == _ServerInfo.ServerId); cboUsername.SelectedIndex = 0; } }
public ClientLauncher(UserPreferences myUserPreferences) { InitializeComponent(); _ServerInfo = myUserPreferences.DefaultServerInformation; theUserPreferences = myUserPreferences; //does this exe even exist yet? if (!File.Exists(SWGANHPAth + _ServerInfo.SafeFolderName + "\\swganh.exe")) { PatchProgress myPatchProgress = new PatchProgress(_ServerInfo, myUserPreferences); myPatchProgress.Loaded += new RoutedEventHandler(myPatchProgress_Loaded); myPatchProgress.OnError += new EventHandler <ErrorMessageEventArgs>(myPatchProgress_OnError); myPatchProgress.PatchComplete += new EventHandler <Patcher.PatchFunctionCompleteEventArgs>(myPatchProgress_PatchComplete); grdRightPanel.Children.Clear(); grdRightPanel.Children.Add(myPatchProgress); btnLaunchClient.IsEnabled = false; } else { //read the first article RefreshNewsDelegate del = new RefreshNewsDelegate(RefreshNewsAsych); AsyncCallback callback = new AsyncCallback(XMLHasFinished); del.BeginInvoke(_ServerInfo.RSSFeedUrl, callback, null); } lblServerName.Text = _ServerInfo.ServerName; lblServerBuild.Text = "999"; lblServerPopulation.Text = _ServerInfo.Population.ToString(); //do we have any credentials for this server? if (myUserPreferences.ServerCredentials.Any(sc => sc.ServerId == _ServerInfo.ServerId)) { cboUsername.ItemsSource = myUserPreferences.ServerCredentials.Where(sc => sc.ServerId == _ServerInfo.ServerId); cboUsername.SelectedIndex = 0; } }