Skip to content
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
9 changes: 6 additions & 3 deletions main/Classes/Category.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,11 @@ public Image loadImageCache(ProgramShortcut shortcutObject)

if (System.IO.File.Exists(programPath) || Directory.Exists(programPath) || shortcutObject.isWindowsApp)
{
try
if (shortcutObject.specificLogo != null)
{
return new Bitmap(shortcutObject.specificLogo);
}
try
{
// Try to construct the path like if it existed
// If it does, directly load it into memory and return it
Expand All @@ -237,8 +241,7 @@ public Image loadImageCache(ProgramShortcut shortcutObject)
String path = MainPath.path + @"\config\" + this.Name + @"\Icons\" + Path.GetFileNameWithoutExtension(programPath) + (Directory.Exists(programPath) ? "_FolderObjTSKGRoup.png" : ".png");

Image finalImage;

if (Path.GetExtension(programPath).ToLower() == ".lnk")
if (Path.GetExtension(programPath).ToLower() == ".lnk")
{
finalImage = Forms.frmGroup.handleLnkExt(programPath);
}
Expand Down
6 changes: 4 additions & 2 deletions main/Classes/ProgramShortcut.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
namespace client.Classes
using System.Drawing;

namespace client.Classes
{
public class ProgramShortcut
{
public string FilePath { get; set; }
public bool isWindowsApp { get; set; }

public string specificLogo { get; set; }
public string name { get; set; } = "";
public string Arguments = "";
public string WorkingDirectory = MainPath.exeString;
Expand Down
1,349 changes: 691 additions & 658 deletions main/Forms/frmGroup.Designer.cs

Large diffs are not rendered by default.

68 changes: 59 additions & 9 deletions main/Forms/frmGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public void LoadShortcut(ProgramShortcut psc, int position)
MotherForm = this,
Shortcut = psc,
Position = position,
logo = psc.specificLogo != null ? new Bitmap(psc.specificLogo) : null,
};
pnlShortcuts.Controls.Add(ucPsc);
ucPsc.Show();
Expand Down Expand Up @@ -350,10 +351,22 @@ private void pnlDragDropImg(object sender, DragEventArgs e)
}
}

private void handleIcon(String file, String imageExtension)
private void handleIcon(String file, String imageExtension, bool specific = false)
{
// Checks if the files being added/dropped are an .exe or .lnk in which tye icons need to be extracted/processed
if (specialImageExt.Contains(imageExtension))
// Checks if the files being added/dropped are an .exe or .lnk in which tye icons need to be extracted/processed
if (specific)
{
if (_selected == null) return;
if (imageExtension == ".lnk")
{
_selected.changeLogo(file);
}
else
{
_selected.changeLogo(file);
}
}
else if (specialImageExt.Contains(imageExtension))
{
if (imageExtension == ".lnk")
{
Expand All @@ -365,8 +378,8 @@ private void handleIcon(String file, String imageExtension)
}
}
else
{
cmdAddGroupIcon.BackgroundImage = Image.FromFile(file);
{
cmdAddGroupIcon.BackgroundImage = Image.FromFile(file);
}
lblAddGroupIcon.Text = "Change group icon";
}
Expand Down Expand Up @@ -770,9 +783,9 @@ public void resetSelection()
selectedShortcut = null;
}
}

// Enable the argument textbox once a shortcut/program has been selected
public void enableSelection(ucProgramShortcut passedShortcut)
private ucProgramShortcut _selected;
// Enable the argument textbox once a shortcut/program has been selected
public void enableSelection(ucProgramShortcut passedShortcut)
{
selectedShortcut = passedShortcut;
passedShortcut.ucSelected();
Expand All @@ -785,6 +798,8 @@ public void enableSelection(ucProgramShortcut passedShortcut)
pnlWorkingDirectory.Enabled = true;
cmdSelectDirectory.Enabled = true;

_selected = passedShortcut;

pnlColor.Visible = false;
pnlArguments.Visible = true;
}
Expand Down Expand Up @@ -863,5 +878,40 @@ private void frmGroup_MouseClick(object sender, MouseEventArgs e)
{
resetSelection();
}
}

private void label8_Click(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
resetSelection();

lblErrorIcon.Visible = false; //resetting error msg

OpenFileDialog openFileDialog = new OpenFileDialog
{
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures),
Title = "Select Specific Icon",
CheckFileExists = true,
CheckPathExists = true,
DefaultExt = "img",
Filter = "Image files and exec (*.jpg, *.jpeg, *.jpe, *.jfif, *.png, *.exe, *.ico) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png; *.ico; *.exe",
FilterIndex = 2,
RestoreDirectory = true,
ReadOnlyChecked = true,
DereferenceLinks = false,
};

if (openFileDialog.ShowDialog() == DialogResult.OK)
{

String imageExtension = Path.GetExtension(openFileDialog.FileName).ToLower();

handleIcon(openFileDialog.FileName, imageExtension, true);
}
}
}

}
15 changes: 10 additions & 5 deletions main/User controls/ucProgramShortcut.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using client.Forms;
using System.IO;
using System.Windows.Input;
using System.Drawing.Imaging;

namespace client.User_controls
{
Expand All @@ -21,7 +22,6 @@ public ucProgramShortcut()
{
InitializeComponent();
}

private void ucProgramShortcut_Load(object sender, EventArgs e)
{
// Grab the file name without the extension to be used later as the naming scheme for the icon .jpg image
Expand Down Expand Up @@ -61,18 +61,18 @@ private void ucProgramShortcut_Load(object sender, EventArgs e)
// Depending on the extension, the icon can be directly extracted or it has to be gotten through other methods as to not get the shortcut arrow
if (imageExtension == ".lnk")
{
picShortcut.BackgroundImage = logo = frmGroup.handleLnkExt(Shortcut.FilePath);
picShortcut.BackgroundImage = logo != null ? logo : frmGroup.handleLnkExt(Shortcut.FilePath);
}
else
{
picShortcut.BackgroundImage = logo = Icon.ExtractAssociatedIcon(Shortcut.FilePath).ToBitmap();
picShortcut.BackgroundImage = logo != null ? logo : Icon.ExtractAssociatedIcon(Shortcut.FilePath).ToBitmap();
}

} else if (Directory.Exists(Shortcut.FilePath))
{
try
{
picShortcut.BackgroundImage = logo = handleFolder.GetFolderIcon(Shortcut.FilePath).ToBitmap();
picShortcut.BackgroundImage = logo != null ? logo : handleFolder.GetFolderIcon(Shortcut.FilePath).ToBitmap();
}
catch (Exception ex)
{
Expand All @@ -96,7 +96,12 @@ private void ucProgramShortcut_Load(object sender, EventArgs e)
}

}

public void changeLogo(string file)
{
logo = new Bitmap(file);
Shortcut.specificLogo = file;
this.picShortcut.BackgroundImage = logo;
}
private void ucProgramShortcut_MouseEnter(object sender, EventArgs e)
{
ucSelected();
Expand Down
14 changes: 8 additions & 6 deletions main/client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,18 @@
<ApplicationIcon>Icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="ChinhDo.Transactions.FileManager, Version=1.4.0.36, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\TxFileManager.1.4.0\lib\netstandard2.0\ChinhDo.Transactions.FileManager.dll</HintPath>
<Reference Include="ChinhDo.Transactions.FileManager, Version=1.5.0.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\TxFileManager.1.5.0.1\lib\netstandard2.0\ChinhDo.Transactions.FileManager.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAPICodePack, Version=1.1.4.0, Culture=neutral, PublicKeyToken=8985beaab7ea3f04, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft-WindowsAPICodePack-Core.1.1.4\lib\net472\Microsoft.WindowsAPICodePack.dll</HintPath>
<Reference Include="CustomMarshalers" />
<Reference Include="Microsoft.WindowsAPICodePack, Version=1.1.5.0, Culture=neutral, PublicKeyToken=8985beaab7ea3f04, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft-WindowsAPICodePack-Core.1.1.5\lib\net472\Microsoft.WindowsAPICodePack.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAPICodePack.Shell, Version=1.1.4.0, Culture=neutral, PublicKeyToken=8985beaab7ea3f04, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft-WindowsAPICodePack-Shell.1.1.4\lib\net472\Microsoft.WindowsAPICodePack.Shell.dll</HintPath>
<Reference Include="Microsoft.WindowsAPICodePack.Shell, Version=1.1.5.0, Culture=neutral, PublicKeyToken=8985beaab7ea3f04, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft-WindowsAPICodePack-Shell.1.1.5\lib\net472\Microsoft.WindowsAPICodePack.Shell.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
Expand Down
6 changes: 3 additions & 3 deletions main/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft-WindowsAPICodePack-Core" version="1.1.4" targetFramework="net472" />
<package id="Microsoft-WindowsAPICodePack-Shell" version="1.1.4" targetFramework="net472" />
<package id="TxFileManager" version="1.4.0" targetFramework="net472" />
<package id="Microsoft-WindowsAPICodePack-Core" version="1.1.5" targetFramework="net472" />
<package id="Microsoft-WindowsAPICodePack-Shell" version="1.1.5" targetFramework="net472" />
<package id="TxFileManager" version="1.5.0.1" targetFramework="net472" />
</packages>