Import exisitng code

This commit is contained in:
Jan Groß
2021-05-14 22:54:30 +02:00
parent 1d5e0f69d3
commit 732abefd12
8 changed files with 26485 additions and 0 deletions

25
Wallpaperchan.sln Normal file
View File

@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31205.134
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wallpaperchan", "Wallpaperchan\Wallpaperchan.csproj", "{FA5C9ECF-E3E1-4A0A-BD3C-039D3F306892}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FA5C9ECF-E3E1-4A0A-BD3C-039D3F306892}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FA5C9ECF-E3E1-4A0A-BD3C-039D3F306892}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FA5C9ECF-E3E1-4A0A-BD3C-039D3F306892}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FA5C9ECF-E3E1-4A0A-BD3C-039D3F306892}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8FB10183-078B-4067-900B-C77B695D8CFD}
EndGlobalSection
EndGlobal

241
Wallpaperchan/Form1.Designer.cs generated Normal file
View File

@@ -0,0 +1,241 @@

namespace Wallpaperchan
{
partial class MainForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Windows.Forms.ListViewItem listViewItem1 = new System.Windows.Forms.ListViewItem("", 1);
System.Windows.Forms.ListViewItem listViewItem2 = new System.Windows.Forms.ListViewItem("", 2);
System.Windows.Forms.ListViewItem listViewItem3 = new System.Windows.Forms.ListViewItem("", 0);
System.Windows.Forms.ListViewItem listViewItem4 = new System.Windows.Forms.ListViewItem("", 3);
System.Windows.Forms.ListViewItem listViewItem5 = new System.Windows.Forms.ListViewItem("", 3);
System.Windows.Forms.ListViewItem listViewItem6 = new System.Windows.Forms.ListViewItem("", 4);
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
this.btnSelectFolder = new System.Windows.Forms.Button();
this.path = new System.Windows.Forms.TextBox();
this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
this.btnApplyWallpaper = new System.Windows.Forms.Button();
this.listView1 = new System.Windows.Forms.ListView();
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
this.status = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.delay = new System.Windows.Forms.NumericUpDown();
this.delayLabel = new System.Windows.Forms.Label();
this.btnPause = new System.Windows.Forms.Button();
this.btnToggleGrid = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.delay)).BeginInit();
this.SuspendLayout();
//
// btnSelectFolder
//
this.btnSelectFolder.Location = new System.Drawing.Point(1608, 39);
this.btnSelectFolder.Name = "btnSelectFolder";
this.btnSelectFolder.Size = new System.Drawing.Size(182, 40);
this.btnSelectFolder.TabIndex = 0;
this.btnSelectFolder.Text = "Select Folder";
this.btnSelectFolder.UseVisualStyleBackColor = true;
this.btnSelectFolder.Click += new System.EventHandler(this.button1_Click);
//
// path
//
this.path.Location = new System.Drawing.Point(813, 39);
this.path.Name = "path";
this.path.Size = new System.Drawing.Size(767, 35);
this.path.TabIndex = 1;
//
// btnApplyWallpaper
//
this.btnApplyWallpaper.Location = new System.Drawing.Point(1608, 117);
this.btnApplyWallpaper.Name = "btnApplyWallpaper";
this.btnApplyWallpaper.Size = new System.Drawing.Size(182, 40);
this.btnApplyWallpaper.TabIndex = 3;
this.btnApplyWallpaper.Text = "Apply wallpaper";
this.btnApplyWallpaper.UseVisualStyleBackColor = true;
this.btnApplyWallpaper.Click += new System.EventHandler(this.button2_Click);
//
// listView1
//
this.listView1.Alignment = System.Windows.Forms.ListViewAlignment.Default;
this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listView1.AutoArrange = false;
this.listView1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(44)))), ((int)(((byte)(47)))), ((int)(((byte)(51)))));
this.listView1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.listView1.CheckBoxes = true;
this.listView1.ForeColor = System.Drawing.SystemColors.Window;
this.listView1.HideSelection = false;
listViewItem1.StateImageIndex = 0;
listViewItem2.StateImageIndex = 0;
listViewItem3.StateImageIndex = 0;
listViewItem4.StateImageIndex = 0;
listViewItem5.StateImageIndex = 0;
listViewItem6.StateImageIndex = 0;
this.listView1.Items.AddRange(new System.Windows.Forms.ListViewItem[] {
listViewItem1,
listViewItem2,
listViewItem3,
listViewItem4,
listViewItem5,
listViewItem6});
this.listView1.LargeImageList = this.imageList1;
this.listView1.Location = new System.Drawing.Point(39, 242);
this.listView1.Margin = new System.Windows.Forms.Padding(0);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(1914, 744);
this.listView1.TabIndex = 4;
this.listView1.TileSize = new System.Drawing.Size(120, 100);
this.listView1.UseCompatibleStateImageBehavior = false;
//
// imageList1
//
this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth24Bit;
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
this.imageList1.Images.SetKeyName(0, "AgaKill0103.png");
this.imageList1.Images.SetKeyName(1, "ASV.png");
this.imageList1.Images.SetKeyName(2, "ASV2.png");
this.imageList1.Images.SetKeyName(3, "ASV3.png");
this.imageList1.Images.SetKeyName(4, "atot0310.png");
//
// status
//
this.status.AutoSize = true;
this.status.ForeColor = System.Drawing.SystemColors.ControlLightLight;
this.status.Location = new System.Drawing.Point(1456, 127);
this.status.Name = "status";
this.status.Size = new System.Drawing.Size(68, 30);
this.status.TabIndex = 5;
this.status.Text = "status";
//
// timer1
//
this.timer1.Enabled = true;
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// delay
//
this.delay.Location = new System.Drawing.Point(1191, 125);
this.delay.Name = "delay";
this.delay.Size = new System.Drawing.Size(87, 35);
this.delay.TabIndex = 6;
this.delay.Value = new decimal(new int[] {
3,
0,
0,
0});
this.delay.ValueChanged += new System.EventHandler(this.delay_ValueChanged);
//
// delayLabel
//
this.delayLabel.AutoSize = true;
this.delayLabel.ForeColor = System.Drawing.SystemColors.ControlLightLight;
this.delayLabel.Location = new System.Drawing.Point(1284, 127);
this.delayLabel.Name = "delayLabel";
this.delayLabel.Size = new System.Drawing.Size(118, 30);
this.delayLabel.TabIndex = 7;
this.delayLabel.Text = "Delay (min)";
//
// btnPause
//
this.btnPause.Location = new System.Drawing.Point(1822, 117);
this.btnPause.Name = "btnPause";
this.btnPause.Size = new System.Drawing.Size(131, 40);
this.btnPause.TabIndex = 8;
this.btnPause.Text = "Pause";
this.btnPause.UseVisualStyleBackColor = true;
this.btnPause.Click += new System.EventHandler(this.btnPause_Click);
//
// btnToggleGrid
//
this.btnToggleGrid.Location = new System.Drawing.Point(39, 193);
this.btnToggleGrid.Name = "btnToggleGrid";
this.btnToggleGrid.Size = new System.Drawing.Size(131, 40);
this.btnToggleGrid.TabIndex = 9;
this.btnToggleGrid.Text = "List/Grid";
this.btnToggleGrid.UseVisualStyleBackColor = true;
this.btnToggleGrid.Click += new System.EventHandler(this.button1_Click_1);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Segoe Script", 15.85714F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
this.label1.ForeColor = System.Drawing.SystemColors.ButtonShadow;
this.label1.Location = new System.Drawing.Point(54, 59);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(345, 61);
this.label1.TabIndex = 10;
this.label1.Text = "Wallpaper-chan";
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 30F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(35)))), ((int)(((byte)(39)))), ((int)(((byte)(42)))));
this.ClientSize = new System.Drawing.Size(1999, 1029);
this.Controls.Add(this.label1);
this.Controls.Add(this.btnToggleGrid);
this.Controls.Add(this.btnPause);
this.Controls.Add(this.delayLabel);
this.Controls.Add(this.delay);
this.Controls.Add(this.status);
this.Controls.Add(this.listView1);
this.Controls.Add(this.btnApplyWallpaper);
this.Controls.Add(this.path);
this.Controls.Add(this.btnSelectFolder);
this.Name = "MainForm";
this.Text = "Hello, this is app";
this.Load += new System.EventHandler(this.MainForm_Load);
this.Shown += new System.EventHandler(this.MainForm_Shown);
((System.ComponentModel.ISupportInitialize)(this.delay)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button btnSelectFolder;
private System.Windows.Forms.TextBox path;
private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1;
private System.Windows.Forms.Button btnApplyWallpaper;
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.ImageList imageList1;
private System.Windows.Forms.Label status;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.NumericUpDown delay;
private System.Windows.Forms.Label delayLabel;
private System.Windows.Forms.Button btnPause;
private System.Windows.Forms.Button btnToggleGrid;
private System.Windows.Forms.Label label1;
}
}

190
Wallpaperchan/Form1.cs Normal file
View File

@@ -0,0 +1,190 @@
using System;
using Microsoft.Win32;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;
namespace Wallpaperchan
{
public partial class MainForm : Form
{
int remainingSeconds = 0;
int currentImageIndex = 0;
string[] files;
[DllImport("user32.dll", EntryPoint = "SystemParametersInfo")]
public static extern int SystemParametersInfo(UAction uAction, int uParam, StringBuilder lpvParam, int fuWinIni);
public enum UAction
{
/// <summary>
/// set the desktop background image
/// </summary>
SPI_SETDESKWALLPAPER = 0x0014,
/// <summary>
/// set the desktop background image
/// </summary>
SPI_GETDESKWALLPAPER = 0x0073,
}
public static IEnumerable<FileInfo> GetFilesByExtensions(DirectoryInfo dir, params string[] extensions)
{
if (extensions == null)
throw new ArgumentNullException("extensions");
IEnumerable<FileInfo> files = dir.EnumerateFiles();
return files.Where(f => extensions.Contains(f.Extension));
}
public static int SetBackgroud(string fileName)
{
int result = 0;
if (File.Exists(fileName))
{
StringBuilder s = new StringBuilder(fileName);
result = SystemParametersInfo(UAction.SPI_SETDESKWALLPAPER, 0, s, 0x2);
}
return result;
}
public MainForm()
{
InitializeComponent();
}
private void LoadImagesFromFolder(string folder)
{
//this.files = System.IO.Directory.GetFiles(folder, "*.png");
DirectoryInfo dInfo = new DirectoryInfo(folder);
this.files = GetFilesByExtensions(dInfo, ".jpg", ".png", ".jpeg", ".jfif").Select(f => f.FullName).ToArray();
ImageList il = imageList1;
il.Images.Clear();
for (int i = 0; i < files.Count(); i++)
{
string image = files[i];
this.status.Text = String.Format("Loading image {0}/{1}", i, files.Count());
this.status.Refresh();
//Application.DoEvents();
try
{
Image fullImage = Image.FromFile(image);
Image thumb = fullImage.GetThumbnailImage(112, 63, () => false, IntPtr.Zero);
fullImage.Dispose();
il.Images.Add(thumb);
} catch
{
continue;
}
}
listView1.LargeImageList = il;
listView1.Items.Clear();
for (int i = 0; i < il.Images.Count; i++)
{
ListViewItem lvi = new ListViewItem();
lvi.ImageIndex = i;
lvi.Text = this.files[i];
listView1.Items.Add(lvi);
}
}
private void button1_Click(object sender, EventArgs e)
{
string folder = ChooseFolder();
Properties.Settings.Default.wallpaperFolder = folder;
Properties.Settings.Default.Save();
this.LoadImagesFromFolder(folder);
}
public string ChooseFolder()
{
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
return folderBrowserDialog1.SelectedPath;
}
return "";
}
private void button2_Click(object sender, EventArgs e)
{
if (this.listView1.FocusedItem == null) { return; }
int index = this.listView1.FocusedItem.Index;
SetBackgroud(files[index]);
this.currentImageIndex = index;
this.remainingSeconds = (int)this.delay.Value * 60;
}
private void timer1_Tick(object sender, EventArgs e)
{
if (this.files == null || files.Count() == 0)
{
return;
}
this.status.Text = String.Format("Current Image: {0} \nNext image in: {1}", currentImageIndex, remainingSeconds);
this.remainingSeconds--;
if (this.remainingSeconds <= 0)
{
this.remainingSeconds = (int)this.delay.Value * 60;
this.currentImageIndex++;
if (this.currentImageIndex > this.listView1.Items.Count -1)
{
this.currentImageIndex = 0;
}
}
SetBackgroud(files[this.currentImageIndex]);
}
private void delay_ValueChanged(object sender, EventArgs e)
{
Properties.Settings.Default.delay = (int)this.delay.Value;
Properties.Settings.Default.Save();
}
private void btnPause_Click(object sender, EventArgs e)
{
this.timer1.Enabled = !this.timer1.Enabled;
this.btnPause.Text = this.timer1.Enabled ? "Pause" : "Continue";
}
private void MainForm_Load(object sender, EventArgs e)
{
}
private void MainForm_Shown(object sender, EventArgs e)
{
this.Refresh();
this.delay.Value = Properties.Settings.Default.delay;
this.path.Text = Properties.Settings.Default.wallpaperFolder;
if (this.path.Text != "")
{
this.LoadImagesFromFolder(this.path.Text);
}
this.currentImageIndex = Properties.Settings.Default.lastIndex;
this.remainingSeconds = (int)this.delay.Value * 60;
}
private void button1_Click_1(object sender, EventArgs e)
{
if (listView1.View == View.LargeIcon)
{
listView1.View = View.List;
} else
{
listView1.View = View.LargeIcon;
}
}
}
}

25898
Wallpaperchan/Form1.resx Normal file

File diff suppressed because it is too large Load Diff

23
Wallpaperchan/Program.cs Normal file
View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Wallpaperchan
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
}
}

View File

@@ -0,0 +1,62 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Wallpaperchan.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("1")]
public int delay {
get {
return ((int)(this["delay"]));
}
set {
this["delay"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("0")]
public int lastIndex {
get {
return ((int)(this["lastIndex"]));
}
set {
this["lastIndex"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string wallpaperFolder {
get {
return ((string)(this["wallpaperFolder"]));
}
set {
this["wallpaperFolder"] = value;
}
}
}
}

View File

@@ -0,0 +1,15 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Wallpaperchan.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="delay" Type="System.Int32" Scope="User">
<Value Profile="(Default)">1</Value>
</Setting>
<Setting Name="lastIndex" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
<Setting Name="wallpaperFolder" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>

View File

@@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<TargetFramework>net5.0-windows</TargetFramework>
<XXXXSelfContained>true</XXXXSelfContained>
<PublishTrimmed>true</PublishTrimmed>
<PublishSingleFile>true</PublishSingleFile>
<XXXXPublishReadyToRun>true</XXXXPublishReadyToRun>
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<ItemGroup>
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
</Project>