Skip to content

Commit d24f5e7

Browse files
authored
Merge pull request #25 from 0523ronli/main2
Main2
2 parents 501ea92 + 92aec48 commit d24f5e7

6 files changed

Lines changed: 48 additions & 15 deletions

File tree

Config_Forms/Form_Temps.Designer.cs

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Config_Forms/Form_Temps.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public partial class Form_Temps : Form
1818
public Form_Temps()
1919
{
2020
InitializeComponent();
21+
checkBox1.Checked = Desktop_Instance.config_JSON.double_buffer;
2122
}
2223

2324
private void button1_Click(object sender, EventArgs e)
@@ -56,5 +57,10 @@ private void button2_Click(object sender, EventArgs e)
5657
Console.WriteLine($"An error occurred: {ex.Message}");
5758
}
5859
}
60+
61+
private void checkBox1_CheckedChanged(object sender, EventArgs e)
62+
{
63+
Desktop_Instance.config_JSON.double_buffer = checkBox1.Checked;
64+
}
5965
}
6066
}

Config_Forms/SettingMainForm.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private void Mainform_Load(object sender, EventArgs e)
9090
});
9191
originalleftbtn.Add(new Leftbtn()
9292
{
93-
Text = "Temp Folder",
93+
Text = "Other",
9494
Linkform = new Form_Temps()
9595
});
9696
originalleftbtn.Add(new Leftbtn()

Config_JSON.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class Config_JSON
2222
public string DI_ForeColor { get; set; } = "#000000";
2323
public bool DI_Transparent { get; set; } = false;
2424
public Size DI_size { get; set; } = DI_size_opt.Medium;
25+
public bool double_buffer { get; set; } = true;
2526
public List<DI_Json> DI_List { get; set; } = new();
2627
}
2728
}

DesktopItem.cs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -195,30 +195,38 @@ private void InitPictureBox()
195195
{
196196
try
197197
{
198-
using (FileStream stream = new FileStream(FilePath, FileMode.Open, FileAccess.Read))
198+
try
199199
{
200-
try
200+
using (FileStream stream = new FileStream(FilePath, FileMode.Open, FileAccess.Read))
201201
{
202-
Image image = Image.FromStream(stream); ;
203-
if (ImageAnimator.CanAnimate(image))
202+
try
204203
{
205-
pictureBox1.Image = Program.GIFToImage(FilePath);
204+
Image image = Image.FromStream(stream); ;
205+
if (ImageAnimator.CanAnimate(image))
206+
{
207+
pictureBox1.Image = Program.GIFToImage(FilePath);
208+
}
209+
else
210+
{
211+
pictureBox1.Image = Image.FromStream(stream); ;
212+
}
206213
}
207-
else
214+
catch (Exception)
208215
{
209-
pictureBox1.Image = Image.FromStream(stream);;
216+
pictureBox1.Image = Icon.ExtractAssociatedIcon(FilePath)?.ToBitmap();
210217
}
211218
}
212-
catch (Exception)
213-
{
214-
pictureBox1.Image = Icon.ExtractAssociatedIcon(FilePath)?.ToBitmap();
215-
}
219+
}
220+
catch (Exception)
221+
{
222+
pictureBox1.Image = Icon.ExtractAssociatedIcon(FilePath)?.ToBitmap();
216223
}
217224
}
218225
catch (Exception)
219226
{
220-
pictureBox1.Image = Icon.ExtractAssociatedIcon(FilePath)?.ToBitmap();
227+
221228
}
229+
222230
}
223231
protected override void OnPaint(PaintEventArgs e=null!)
224232
{

MainDesktop.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ private void onDragDrop(object? s, DragEventArgs e)
438438
catch (Exception ex)
439439
{
440440
MessageBox.Show(ex.Message, "Messed up when dropping");
441+
throw ex;
441442
}
442443
}
443444

@@ -562,8 +563,8 @@ public void ReadJSON(bool _)
562563
current_effects = config_JSON.DragDropEffects;
563564
if (config_JSON.Background == "Rainbow") RainbowGenerator.Start();
564565
else RainbowGenerator.Stop();
565-
AutoArrange();
566566
Refresh();
567+
AutoArrange();
567568
}
568569

569570
public void WriteJSON()
@@ -592,7 +593,8 @@ public void MakeDrag()
592593
protected override void OnPaint(PaintEventArgs e)
593594
{
594595
base.OnPaint(e);
595-
596+
DoubleBuffered = config_JSON.double_buffer;
597+
596598
foreach (DesktopItem item in Controls)
597599
{
598600
item.OnRender();

0 commit comments

Comments
 (0)