//Die für die jeweilige Option richtige XMLDatei herunterladen wenn sie veraltet ist private void getXMLFile(bool ForceReload) { DateTime localFileDate; int daysBetween = 0; string remoteUri = config.XmlFileUrl(); string localFileName = config.ArtFilePath(); bool downloadFile = false; if (!ForceReload) { if (File.Exists(localFileName)) { localFileDate = File.GetLastWriteTime(localFileName).Date; daysBetween = DateTime.Now.Date.Subtract(localFileDate).Days; if (daysBetween >= config.XmlRefreshInterval) { Console.WriteLine("Xml file too old ({0} day(s) since last download - downloading new one", daysBetween); downloadFile = true; } } else { downloadFile = true; } } else { downloadFile = true; } if (downloadFile) { CStatusWindow sw = new CStatusWindow(Catalog.GetString("Downloading new XML file"), 1, false, true, true); sw.ButtonSensitive = false; sw.ExtInfoLabel = Catalog.GetString("Downloading") + ": " + remoteUri; sw.Mainlabel = Catalog.GetString("<i>XML file is being downloaded</i>\n\nThis program needs a descriptive " + "file that contains information about \n\n1) where the theme is located," + "\n2) what kind of theme is it, \n3) How often someone downloaded it," + " and so on \n\nSo please be patient while the download progress is going on.."); sw.SetProgress(Catalog.GetString("downloading... (no progress available)")); sw.Invalidate(); try { (new CFileDownloader(config)).DownloadFile(remoteUri, localFileName, sw.DetailProgressBar); } catch (Exception ex) { sw.Close(); new CInfoWindow(Catalog.GetString("Warning: Could not download xml file!"), ex.Message, Gtk.Stock.DialogError, true); } sw.Close(); } }
//Theme installieren und Revert verfügbar machen public virtual void StartInstallation() { CStatusWindow sw = new CStatusWindow(Catalog.GetString(String.Format("Installing \"{0}\"", Name)), installationSteps, false, false, true); sw.Mainlabel = Catalog.GetString("<i>Installing</i>\n\nYour selection is being downloaded and installed...please be" + " patient while the installation procedure proceeds. After everything's done, this" + " window will get closed.\n\n Have fun with your new theme, Greetings Tom"); try{ PreInstallation(sw); Installation(sw); PostInstallation(sw); sw.SetProgress(installationSteps + "/" + installationSteps); sw.Mainlabel = CConfiguration.txtInstallDone; sw.DetailProgressBar.Fraction = 1.0; sw.DetailProgressBar.Text = Catalog.GetString("All changes have been applied"); //Hint:It's enough to change the caption to the stock item!! No need for image transformations! sw.ButtonCaption = "gtk-ok"; } catch (Exception ex) { sw.Close(); CInfoWindow iw = new CInfoWindow("<b>" + Catalog.GetString("Theme installation failed!") + "</b>", Catalog.GetString("This message was reported from the installation function:\n\n"), Gtk.Stock.DialogError, true); iw.Description = ex.Message; } }
public void GetAllThumbs() { ArrayList list = getThemeList(); ArrayList downloadList = new ArrayList(); CTheme theme; int themeCount = list.Count; CStatusWindow w = new CStatusWindow(Catalog.GetString("Reading thumbnails on harddisc"), themeCount, true, false, true); w.ButtonSensitive = false; //Thumbs von der Platte lesen for (int i = 0; i < (int)(themeCount); i++) { theme = ((CTheme)list[i]); w.SetProgress((i + 1).ToString() + "/" + themeCount.ToString()); w.ExtInfoLabel = theme.SmallThumbnailUrl; if (!theme.LocalThumbExists) { downloadList.Add(theme); } else { theme.GetThumbnailImage(w.DetailProgressBar); } } //Thumbs herunterladen int downloadCount = downloadList.Count; if (downloadCount > 0) { w.Headline = Catalog.GetString("Downloading missing thumbnails"); w.ButtonSensitive = true; w.SetProgressStep(downloadList.Count); Console.WriteLine("New files: " + downloadList.Count); //Thread[] ta = new Thread[downloadCount]; for (int i = 0; i < downloadList.Count; i++) { if (w.CloseRequested) { break; } theme = ((CTheme)downloadList[i]); w.SetProgress((i + 1).ToString() + "/" + downloadCount.ToString()); w.ExtInfoLabel = Path.GetFileName(theme.SmallThumbnailUrl); /*Threading * ta[i] = new Thread(new ThreadStart(theme.GetThumbnailImage)); * ta[i].Start(); // Threads werden gestartet */ try{ theme.GetThumbnailImage(w.DetailProgressBar); } catch (Exception ex) { Console.WriteLine("Error while downloading file: " + ex.Message); } } /* Threading * bool done=false; * while (!done){ * done=true; * for (int k=0;k<downloadCount;k++){ * if (ta[k].ThreadState != ThreadState.Stopped) * done=false; * } * * } */ } w.Close(); }
private void OnSaveButtonClicked(object sender, EventArgs e) { CStatusWindow sw=new CStatusWindow(Catalog.GetString("Downloading the theme"),1,false,true,true); sw.ExtInfoLabel = Catalog.GetString("Download location")+": "+config.ThemesDownloadPath; sw.ButtonSensitive=false; try{ man.Theme.GetThemeFile(sw,config.ThemesDownloadPath); sw.Close(); } catch (Exception ex) { sw.Close(); new CInfoWindow(Catalog.GetString("Error")+":"+Catalog.GetString("Download failed!"),ex.Message,Gtk.Stock.DialogError,true); } }
private void OnPreviewButtonClicked(object sender, EventArgs e) { CStatusWindow sw=new CStatusWindow(Catalog.GetString("Downloading the preview file"),1,false,true,true); sw.SetProgress("1/1 - " +Catalog.GetString("Connected to art.gnome.org")); sw.Mainlabel=Catalog.GetString("<i>Downloading the preview file</i>\n\nYour preview is being downloaded. After the download has been finished,"+ " the preview will be rescaled if it's not fitting the preview window. See the lower bar to follow the progress."); sw.ButtonSensitive=false; try{ man.Theme.GetPreviewImage(sw.DetailProgressBar); sw.Close(); new CPreviewWindow(man.Theme,true); } catch (Exception ex) { sw.Close(); new CInfoWindow(Catalog.GetString("Error: the preview image could not be loaded!"),ex.Message,Gtk.Stock.DialogError,true); } }
//Theme installieren und Revert verfügbar machen public virtual void StartInstallation() { CStatusWindow sw=new CStatusWindow(Catalog.GetString(String.Format("Installing \"{0}\"",Name)),installationSteps,false,false,true); sw.Mainlabel=Catalog.GetString("<i>Installing</i>\n\nYour selection is being downloaded and installed...please be"+ " patient while the installation procedure proceeds. After everything's done, this"+ " window will get closed.\n\n Have fun with your new theme, Greetings Tom"); try{ PreInstallation(sw); Installation(sw); PostInstallation(sw); sw.SetProgress(installationSteps+"/"+installationSteps); sw.Mainlabel=CConfiguration.txtInstallDone; sw.DetailProgressBar.Fraction=1.0; sw.DetailProgressBar.Text = Catalog.GetString("All changes have been applied"); //Hint:It's enough to change the caption to the stock item!! No need for image transformations! sw.ButtonCaption = "gtk-ok"; } catch (Exception ex) { sw.Close(); CInfoWindow iw = new CInfoWindow("<b>"+Catalog.GetString("Theme installation failed!")+"</b>",Catalog.GetString("This message was reported from the installation function:\n\n"),Gtk.Stock.DialogError,true); iw.Description = ex.Message; } }
//Die für die jeweilige Option richtige XMLDatei herunterladen wenn sie veraltet ist private void getXMLFile(bool ForceReload) { DateTime localFileDate; int daysBetween=0; string remoteUri = config.XmlFileUrl(); string localFileName = config.ArtFilePath(); bool downloadFile=false; if (!ForceReload){ if (File.Exists(localFileName)) { localFileDate = File.GetLastWriteTime(localFileName).Date; daysBetween = DateTime.Now.Date.Subtract(localFileDate).Days; if ( daysBetween >= config.XmlRefreshInterval) { Console.WriteLine("Xml file too old ({0} day(s) since last download - downloading new one",daysBetween); downloadFile = true; } } else { downloadFile=true; } } else downloadFile=true; if (downloadFile){ CStatusWindow sw= new CStatusWindow(Catalog.GetString("Downloading new XML file"),1,false,true,true); sw.ButtonSensitive=false; sw.ExtInfoLabel=Catalog.GetString("Downloading")+": " + remoteUri; sw.Mainlabel=Catalog.GetString("<i>XML file is being downloaded</i>\n\nThis program needs a descriptive "+ "file that contains information about \n\n1) where the theme is located,"+ "\n2) what kind of theme is it, \n3) How often someone downloaded it,"+ " and so on \n\nSo please be patient while the download progress is going on.."); sw.SetProgress(Catalog.GetString("downloading... (no progress available)")); sw.Invalidate(); try { (new CFileDownloader(config)).DownloadFile(remoteUri,localFileName,sw.DetailProgressBar); } catch (Exception ex) { sw.Close(); new CInfoWindow(Catalog.GetString("Warning: Could not download xml file!"),ex.Message,Gtk.Stock.DialogError,true); } sw.Close(); } }
public void GetAllThumbs() { ArrayList list = getThemeList(); ArrayList downloadList = new ArrayList(); CTheme theme; int themeCount=list.Count; CStatusWindow w= new CStatusWindow(Catalog.GetString("Reading thumbnails on harddisc"),themeCount,true,false,true); w.ButtonSensitive=false; //Thumbs von der Platte lesen for (int i=0;i<(int)(themeCount);i++){ theme = ((CTheme)list[i]); w.SetProgress((i+1).ToString()+"/"+themeCount.ToString()); w.ExtInfoLabel = theme.SmallThumbnailUrl; if (!theme.LocalThumbExists) downloadList.Add(theme); else theme.GetThumbnailImage(w.DetailProgressBar); } //Thumbs herunterladen int downloadCount=downloadList.Count; if (downloadCount>0){ w.Headline=Catalog.GetString("Downloading missing thumbnails"); w.ButtonSensitive=true; w.SetProgressStep(downloadList.Count); Console.WriteLine("New files: "+downloadList.Count); //Thread[] ta = new Thread[downloadCount]; for (int i=0;i<downloadList.Count;i++){ if (w.CloseRequested){ break; } theme = ((CTheme)downloadList[i]); w.SetProgress((i+1).ToString()+"/"+downloadCount.ToString()); w.ExtInfoLabel = Path.GetFileName(theme.SmallThumbnailUrl); /*Threading ta[i] = new Thread(new ThreadStart(theme.GetThumbnailImage)); ta[i].Start(); // Threads werden gestartet */ try{ theme.GetThumbnailImage(w.DetailProgressBar); } catch (Exception ex){ Console.WriteLine("Error while downloading file: "+ex.Message); } } /* Threading bool done=false; while (!done){ done=true; for (int k=0;k<downloadCount;k++){ if (ta[k].ThreadState != ThreadState.Stopped) done=false; } } */ } w.Close(); }