Added buttons

This commit is contained in:
Daniel Brunner
2017-02-04 19:20:34 +01:00
parent f39015ff6a
commit ee8697d97f
2 changed files with 90 additions and 7 deletions

View File

@@ -33,7 +33,12 @@
this.columnName = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn()));
this.columnDirectory = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn()));
this.columnLibrary = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn()));
this.panel1 = new System.Windows.Forms.Panel();
this.buttonRefresh = new System.Windows.Forms.Button();
this.buttonMove = new System.Windows.Forms.Button();
this.buttonDelete = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.objectListView1)).BeginInit();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// objectListView1
@@ -47,12 +52,14 @@
this.columnName,
this.columnDirectory});
this.objectListView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.objectListView1.Location = new System.Drawing.Point(0, 0);
this.objectListView1.Location = new System.Drawing.Point(0, 52);
this.objectListView1.Name = "objectListView1";
this.objectListView1.Size = new System.Drawing.Size(968, 590);
this.objectListView1.Size = new System.Drawing.Size(968, 538);
this.objectListView1.TabIndex = 0;
this.objectListView1.UseCompatibleStateImageBehavior = false;
this.objectListView1.UseOverlays = false;
this.objectListView1.View = System.Windows.Forms.View.Details;
this.objectListView1.SelectedIndexChanged += new System.EventHandler(this.objectListView1_SelectedIndexChanged);
//
// columnId
//
@@ -76,15 +83,60 @@
this.columnLibrary.IsVisible = false;
this.columnLibrary.Text = "Library";
//
// panel1
//
this.panel1.Controls.Add(this.buttonDelete);
this.panel1.Controls.Add(this.buttonMove);
this.panel1.Controls.Add(this.buttonRefresh);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(968, 52);
this.panel1.TabIndex = 1;
//
// buttonRefresh
//
this.buttonRefresh.Location = new System.Drawing.Point(12, 3);
this.buttonRefresh.Name = "buttonRefresh";
this.buttonRefresh.Size = new System.Drawing.Size(181, 43);
this.buttonRefresh.TabIndex = 0;
this.buttonRefresh.Text = "Refresh list";
this.buttonRefresh.UseVisualStyleBackColor = true;
this.buttonRefresh.Click += new System.EventHandler(this.buttonRefresh_Click);
//
// buttonMove
//
this.buttonMove.Enabled = false;
this.buttonMove.Location = new System.Drawing.Point(199, 3);
this.buttonMove.Name = "buttonMove";
this.buttonMove.Size = new System.Drawing.Size(181, 43);
this.buttonMove.TabIndex = 1;
this.buttonMove.Text = "Move game";
this.buttonMove.UseVisualStyleBackColor = true;
this.buttonMove.Click += new System.EventHandler(this.buttonMove_Click);
//
// buttonDelete
//
this.buttonDelete.Enabled = false;
this.buttonDelete.Location = new System.Drawing.Point(386, 3);
this.buttonDelete.Name = "buttonDelete";
this.buttonDelete.Size = new System.Drawing.Size(181, 43);
this.buttonDelete.TabIndex = 2;
this.buttonDelete.Text = "Delete game";
this.buttonDelete.UseVisualStyleBackColor = true;
this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(968, 590);
this.Controls.Add(this.objectListView1);
this.Controls.Add(this.panel1);
this.Name = "Form1";
this.Text = "Form1";
this.Text = "Steam Mover";
((System.ComponentModel.ISupportInitialize)(this.objectListView1)).EndInit();
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);
}
@@ -96,6 +148,10 @@
private BrightIdeasSoftware.OLVColumn columnName;
private BrightIdeasSoftware.OLVColumn columnDirectory;
private BrightIdeasSoftware.OLVColumn columnLibrary;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Button buttonDelete;
private System.Windows.Forms.Button buttonMove;
private System.Windows.Forms.Button buttonRefresh;
}
}

View File

@@ -25,14 +25,21 @@ namespace SteamMover
{
InitializeComponent();
objectListView1.AlwaysGroupByColumn = columnLibrary;
Refresh();
}
void Refresh()
{
var libraries = new List<string> { defaultDir };
var libraryConf = (Dictionary<string, object>)ReadConfigObject(File.OpenText(Path.Combine(defaultDir, "libraryfolders.vdf")))["LibraryFolders"];
for (var i = 1; libraryConf.ContainsKey(i.ToString()); i++)
libraries.Add(Path.Combine((string)libraryConf[i.ToString()], "steamapps"));
var games = new List<Game>();
foreach(var library in libraries)
foreach(var appmanifestPath in Directory.GetFiles(library, "appmanifest_*.acf", SearchOption.TopDirectoryOnly))
foreach (var library in libraries)
foreach (var appmanifestPath in Directory.GetFiles(library, "appmanifest_*.acf", SearchOption.TopDirectoryOnly))
{
var appmanifestConf = (Dictionary<string, object>)ReadConfigObject(File.OpenText(appmanifestPath))["AppState"];
@@ -45,8 +52,7 @@ namespace SteamMover
});
}
objectListView1.AlwaysGroupByColumn = columnLibrary;
objectListView1.SetObjects(games);
objectListView1.SetObjects(games.OrderBy(o => o.name));
}
private Dictionary<string, object> ReadConfigObject(StreamReader streamReader, bool nestedObject = false)
@@ -98,5 +104,26 @@ namespace SteamMover
return dictionary;
}
private void objectListView1_SelectedIndexChanged(object sender, EventArgs e)
{
buttonMove.Enabled = true;
buttonDelete.Enabled = true;
}
private void buttonRefresh_Click(object sender, EventArgs e)
{
Refresh();
}
private void buttonMove_Click(object sender, EventArgs e)
{
throw new NotImplementedException();
}
private void buttonDelete_Click(object sender, EventArgs e)
{
throw new NotImplementedException();
}
}
}