Updater (Builder builder, IntPtr handle)
Definition at line 13 of file Updater.cs .
◆ Updater()
BioGTK.Updater.Updater
(
Builder builder ,
IntPtr handle )
protected
Definition at line 66 of file Updater.cs .
66 : base(handle)
67 {
68 _builder = builder;
69 builder.Autoconnect(this );
70 this.DeleteEvent += Updater_DeleteEvent;
71 upBut.ButtonPressEvent += UpButton_ButtonPressEvent;
72 string st = BioLib.Settings.GetSettings("UpdateSites" );
73 if (st!="" )
74 {
75 string [] ups = st.Split(',' );
76 for (int i = 0; i < ups.Length; i++)
77 {
78 if (i < ups.Length - 1)
79 textBox.Buffer.Text += ups[i] + Environment.NewLine;
80 else
81 textBox.Buffer.Text += ups[i];
82 }
83 }
84 App.ApplyStyles(this );
85 }
◆ Create()
static Updater BioGTK.Updater.Create
(
)
static
It creates a new Updater object, which is a Gtk.Window, and returns it
Returns A new instance of the Updater class.
Definition at line 59 of file Updater.cs .
60 {
61 Builder builder = new Builder(new FileStream(System.IO.Path.GetDirectoryName(Environment.ProcessPath) + "/" + "Glade/Updater.glade" , FileMode.Open));
62 return new Updater(builder, builder.GetObject("updater" ).Handle);
63 }
◆ DownloadFileAsync()
static async Task BioGTK.Updater.DownloadFileAsync
(
string fileUrl ,
string savePath )
static
Definition at line 128 of file Updater.cs .
129 {
130 try
131 {
132
133 byte [] fileBytes = await fileUrl.WithHeader("User-Agent" , "BioGTK" ).GetBytesAsync().ConfigureAwait(false );
134
135
136 await File.WriteAllBytesAsync(savePath, fileBytes);
137 Console.WriteLine($"File downloaded successfully and saved to {savePath}" );
138 }
139 catch (FlurlHttpException e)
140 {
141
142 Console.WriteLine($"Failed to download the file. HTTP Error: {e.Message}" );
143 }
144 catch (Exception e)
145 {
146
147 Console.WriteLine($"An error occurred: {e.Message}" );
148 }
149 }
◆ GetHtmlContentAsync()
static async Task< string > BioGTK.Updater.GetHtmlContentAsync
(
string url )
static
Definition at line 151 of file Updater.cs .
152 {
153 try
154 {
155
156 string htmlContent = await url.WithHeader("User-Agent" , "BioGTK" ).GetStringAsync().ConfigureAwait(false );
157 return htmlContent;
158 }
159 catch (FlurlHttpException e)
160 {
161
162 Console.WriteLine($"HTTP Request Failed: {e.Message}" );
163 return null ;
164 }
165 }
The documentation for this class was generated from the following file: