BioGTK  5.1.1
A .NET library & program for annotating, editing various microscopy imaging formats using Bioformats supported images.
Loading...
Searching...
No Matches
BioGTK.Updater Class Reference
Inheritance diagram for BioGTK.Updater:

Classes

class  GitHubFile
 

Static Public Member Functions

static Updater Create ()
 
static async Task DownloadFileAsync (string fileUrl, string savePath)
 
static async Task< string > GetHtmlContentAsync (string url)
 

Protected Member Functions

 Updater (Builder builder, IntPtr handle)
 

Constructor & Destructor Documentation

◆ Updater()

BioGTK.Updater.Updater ( Builder  builder,
IntPtr  handle 
)
inlineprotected
66 : base(handle)
67 {
68 _builder = builder;
69 builder.Autoconnect(this);
70 this.DeleteEvent += Updater_DeleteEvent;
71 upBut.ButtonPressEvent += UpButton_ButtonPressEvent;
72 string st = 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 }

Member Function Documentation

◆ Create()

static Updater BioGTK.Updater.Create ( )
inlinestatic

It creates a new Updater object, which is a Gtk.Window, and returns it

Returns
A new instance of the Updater class.
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 }
Updater(Builder builder, IntPtr handle)
Definition Updater.cs:66

◆ DownloadFileAsync()

static async Task BioGTK.Updater.DownloadFileAsync ( string  fileUrl,
string  savePath 
)
inlinestatic
129 {
130 try
131 {
132 // Download the file data as byte array
133 byte[] fileBytes = await fileUrl.WithHeader("User-Agent", "BioGTK").GetBytesAsync().ConfigureAwait(false);
134
135 // Write the byte array to a file
136 await File.WriteAllBytesAsync(savePath, fileBytes);
137 Console.WriteLine($"File downloaded successfully and saved to {savePath}");
138 }
139 catch (FlurlHttpException e)
140 {
141 // Handle HTTP errors here (e.g., 404 or 403 errors)
142 Console.WriteLine($"Failed to download the file. HTTP Error: {e.Message}");
143 }
144 catch (Exception e)
145 {
146 // Handle other errors here
147 Console.WriteLine($"An error occurred: {e.Message}");
148 }
149 }

◆ GetHtmlContentAsync()

static async Task< string > BioGTK.Updater.GetHtmlContentAsync ( string  url)
inlinestatic
152 {
153 try
154 {
155 // Fetch the HTML content of the page
156 string htmlContent = await url.WithHeader("User-Agent", "BioGTK").GetStringAsync().ConfigureAwait(false);
157 return htmlContent;
158 }
159 catch (FlurlHttpException e)
160 {
161 // Handle HTTP errors (e.g., 404, 500)
162 Console.WriteLine($"HTTP Request Failed: {e.Message}");
163 return null;
164 }
165 }

The documentation for this class was generated from the following file: