Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
lzcapp committed Feb 22, 2024
1 parent 4c2e06f commit 3c065ef
Show file tree
Hide file tree
Showing 13 changed files with 135 additions and 132 deletions.
4 changes: 2 additions & 2 deletions MikuWeather_CS/DataQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static Dictionary<string, string> UpdateData_Caiyun(string coor) {
return resultDict;
}

var todayTemp = realtime.temperature + " °C";
var todayTemp = realtime.temperature + "";
var todayPic = realtime.skycon;
resultDict.Add("today temp", todayTemp);
resultDict.Add("today pic", todayPic);
Expand All @@ -40,7 +40,7 @@ public static Dictionary<string, string> UpdateData_Caiyun(string coor) {
return resultDict;
}

var tomorrowTemp = Math.Round(daily.temperature_20h_32h[0].min, 0) + " °C ~ " + Math.Round(daily.temperature_20h_32h[0].max, 0) + " °C";
var tomorrowTemp = Math.Round(daily.temperature_20h_32h[0].min, 0) + "~ " + Math.Round(daily.temperature_20h_32h[0].max, 0) + "";
var tomorrowPic = daily.skycon_20h_32h[0].value;
resultDict.Add("tomorrow temp", tomorrowTemp);
resultDict.Add("tomorrow pic", tomorrowPic);
Expand Down
39 changes: 10 additions & 29 deletions MikuWeather_CS/FormMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 12 additions & 9 deletions MikuWeather_CS/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public FormMain() {

private void FormMain_Load(object sender, EventArgs e) {
if (Screen.PrimaryScreen != null) {
var locationX = Screen.PrimaryScreen.WorkingArea.Width - 290;
var locationY = Screen.PrimaryScreen.WorkingArea.Bottom - Size.Height + 20;
var locationX = Screen.PrimaryScreen.WorkingArea.Width - 300;
var locationY = Screen.PrimaryScreen.WorkingArea.Bottom - Size.Height - 80;
SetBounds(locationX, locationY, Size.Width, Size.Height);
}

Expand All @@ -34,7 +34,7 @@ private void FormMain_Load(object sender, EventArgs e) {
}

private void FormMain_MouseHover(object sender, EventArgs e) {
_frmShow.SetBounds(Location.X - _frmShow.Width / 2 + Width / 2 - 50, Location.Y - _frmShow.Height - 20, _frmShow.Width, _frmShow.Height);
_frmShow.SetBounds(Location.X - _frmShow.Width / 2 + Width / 2 - 20, Location.Y - _frmShow.Height - 10, _frmShow.Width, _frmShow.Height);
_frmShow.Show();
}

Expand All @@ -43,7 +43,11 @@ private void FormMain_MouseLeave(object sender, EventArgs e) {
}

private void CmWebsite_Click(object sender, EventArgs e) {
Process.Start("https://github.com/lzcapp/MikuWeather_Windows");
const string repoUrl = "https://github.com/lzcapp/MikuWeather_Windows";
Process.Start(new ProcessStartInfo {
FileName = repoUrl,
UseShellExecute = true
});
}

private void CmExit_Click(object sender, EventArgs e) {
Expand Down Expand Up @@ -72,8 +76,7 @@ private void UpdateData() {
_frmShow.SetTemp(todayTemp, tomorrowTemp);
_frmShow.SetWeather(todayWeather, tomorrowWeather);
_frmShow.SetPic(todayPic, tomorrowPic);
picBox.Image = todayPic;
picBox.Size = new Size(210, 210);
BackgroundImage = todayPic;
TransparentForm();
}

Expand Down Expand Up @@ -144,16 +147,16 @@ private void CmRefresh_Click(object sender, EventArgs e) {
}

private void TransparentForm() {
var img = new Bitmap((Bitmap)picBox.Image, new Size(200, 176));
var img = new Bitmap(((Bitmap)BackgroundImage)!, new Size(200, 176));
GraphicsPath graph = BitmapUtil.GetNoneTransparentRegion(img, 0);
Region = new Region(graph);

BackgroundImage = img;
BackgroundImageLayout = ImageLayout.None;

FormBorderStyle = FormBorderStyle.None;
Width = picBox.Image.Width;
Height = picBox.Image.Height;
Width = BackgroundImage.Width;
Height = BackgroundImage.Height;
}
}
}
107 changes: 57 additions & 50 deletions MikuWeather_CS/FormShow.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions MikuWeather_CS/FormShow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ public partial class FormShow : Form {
private static readonly PrivateFontCollection PFCAwe = new();

private static void AddPrivateFont() {
GCHandle hObject = GCHandle.Alloc(Properties.Resources.MFYaYuan, GCHandleType.Pinned);
GCHandle hObject = GCHandle.Alloc(Properties.Resources.FZMingMT, GCHandleType.Pinned);
var intptr = hObject.AddrOfPinnedObject();
PFCAwe.AddMemoryFont(intptr, Properties.Resources.MFYaYuan.Length);
PFCAwe.AddMemoryFont(intptr, Properties.Resources.FZMingMT.Length);
}

public FormShow() {
Expand All @@ -23,10 +23,9 @@ public FormShow() {

private void FormShow_Load(object sender, EventArgs e) {
AddPrivateFont();

lnkTodayTemp.Font = new Font(PFCAwe.Families[0], 14, FontStyle.Bold);
lnkTodayTemp.UseCompatibleTextRendering = true;
lnkTomorrowTemp.Font = new Font(PFCAwe.Families[0], 14, FontStyle.Bold);
lnkTomorrowTemp.UseCompatibleTextRendering = true;
}

internal void SetTemp(string todayTemp, string tomorrowTemp) {
Expand Down
Loading

0 comments on commit 3c065ef

Please sign in to comment.