Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I add some features for Adding multiple items at once. I Add My C:\po… #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Mint/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>
40 changes: 32 additions & 8 deletions Mint/AppsStructure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,19 @@ namespace Mint
[Serializable]
public class AppsStructure
{
public List<App> Apps { get; set; }
public List<string> Groups { get; set; }
public List<App> Apps
{
get; set;
}

public AppsStructure() { }
public List<string> Groups
{
get; set;
}

public AppsStructure()
{
}

public AppsStructure(List<App> apps)
{
Expand All @@ -20,9 +29,24 @@ public AppsStructure(List<App> apps)
[Serializable]
public class App
{
public string AppTitle { get; set; }
public string AppLink { get; set; }
public string AppGroup { get; set; }
public string AppParams { get; set; }
public string AppTitle
{
get; set;
}

public string AppLink
{
get; set;
}

public string AppGroup
{
get; set;
}

public string AppParams
{
get; set;
}
}
}
}
135 changes: 135 additions & 0 deletions Mint/Automint.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using IWshRuntimeLibrary;
using Newtonsoft.Json;

namespace Mint
{
internal static class Automint
{
public static List<App> LoadFolder(string path)
{
List<App> ff = FindExeFiles(path);

ff.AddRange(FindLinks(path));

/* var xtop = ff.GroupBy(x => x.AppGroup)
.OrderByDescending(group => group.Count())
.Take(20).Select(group => group.Key);
*/
foreach (var item in ff)
{
if(!Program._AppsStructure.Groups.Contains(item.AppGroup))
{
Program._AppsStructure.Groups.Add(item.AppGroup);
}
}




Program._AppsStructure.Apps.AddRange(ff);




return ff;
}

private static List<App> FindLinks(string directoryPath)
{
List<App> appList = new List<App>();


foreach (string filePath in Directory.GetFiles(directoryPath, "*.lnk", SearchOption.AllDirectories))
{
string targetPath = GetShortcutTarget(filePath);
if (!string.IsNullOrEmpty(targetPath) && System.IO.File.Exists(targetPath) && targetPath.ToLower().EndsWith(".exe"))
{
App app = new App
{
AppTitle = Path.GetFileNameWithoutExtension(targetPath),
AppLink = targetPath,
AppGroup = Path.GetDirectoryName(targetPath),
AppParams = ""
};

appList.Add(app);
}
}
return appList;
}

private static List<App> FindExeFiles(string directoryPath)
{
List<App> appList = new List<App>();

foreach (string filePath in Directory.GetFiles(directoryPath, "*.exe", SearchOption.AllDirectories))
{
App app = new App
{
AppTitle = Path.GetFileNameWithoutExtension(filePath),
AppLink = filePath,
//AppGroup = "Auto", // Değiştirebilirsiniz.
AppGroup = Path.GetFileName(Path.GetDirectoryName(filePath)) ,
AppParams = ""
};

appList.Add(app);
}
return appList;
}

private static string GetShortcutTarget(string shortcutPath)
{
string targetPath = "";
try
{
WshShell shell = new WshShell();
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutPath);
targetPath = shortcut.TargetPath;
}
catch (Exception ee)
{
if (Debugger.IsAttached)
Console.WriteLine(ee.Message); // Kısayolun hedefi alınamazsa işleme devam edin.
}
return targetPath;
}

private static bool SaveJson(List<App> appList, string outputPath = "Apps.json")
{
try
{
string jsonOutput = JsonConvert.SerializeObject(appList, Formatting.Indented);

System.IO.File.WriteAllText(outputPath, jsonOutput);
return true;
}
catch (System.Exception)
{
return false;
}
}
}

internal class FolderFindings
{
public string Path;
public string Errors;

public List<App> ExeFiles
{
get; set;
}

public List<App> Links
{
get; set;
}
}
}
14 changes: 10 additions & 4 deletions Mint/Controls/MoonBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@ public class MoonBox : ComboBox
{
private const int WM_PAINT = 0xF;
private int buttonWidth = SystemInformation.HorizontalScrollBarArrowWidth;
Color borderColor = Color.Blue;
private Color borderColor = Color.Blue;

public Color BorderColor
{
get { return borderColor; }
set { borderColor = value; Invalidate(); }
get
{
return borderColor;
}
set
{
borderColor = value; Invalidate();
}
}

protected override void WndProc(ref Message m)
Expand Down Expand Up @@ -54,4 +60,4 @@ protected override void WndProc(ref Message m)
}
}
}
}
}
26 changes: 24 additions & 2 deletions Mint/Forms/MainForm.Designer.cs

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

Loading