Skip to content

Commit

Permalink
Section Icons
Browse files Browse the repository at this point in the history
  • Loading branch information
PythEch committed May 7, 2014
1 parent 83bf2b7 commit ea4013c
Show file tree
Hide file tree
Showing 49 changed files with 675 additions and 36 deletions.
44 changes: 41 additions & 3 deletions Cygnus/Cygnus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
<Compile Include="AlertView.Designer.cs">
<DependentUpon>AlertView.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="7za.exe" />
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
Expand Down Expand Up @@ -144,9 +145,6 @@
<ItemGroup>
<None Include="Resources\spinner.gif" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="7za.exe" />
</ItemGroup>
<ItemGroup>
<COMReference Include="SHDocVw">
<Guid>{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}</Guid>
Expand All @@ -160,7 +158,47 @@
</ItemGroup>
<ItemGroup>
<Content Include="Cygnus.ico" />
<EmbeddedResource Include="Sections\Addons.png" />
<EmbeddedResource Include="Sections\Administration.png" />
<EmbeddedResource Include="Sections\Archiving.png" />
<EmbeddedResource Include="Sections\Books.png" />
<EmbeddedResource Include="Sections\Carrier_Bundles.png" />
<EmbeddedResource Include="Sections\Data_Storage.png" />
<EmbeddedResource Include="Sections\Development.png" />
<EmbeddedResource Include="Sections\Dictionaries.png" />
<EmbeddedResource Include="Sections\Education.png" />
<EmbeddedResource Include="Sections\Entertainment.png" />
<EmbeddedResource Include="Sections\Fonts.png" />
<EmbeddedResource Include="Sections\Games.png" />
<EmbeddedResource Include="Sections\Health_and_Fitness.png" />
<EmbeddedResource Include="Sections\Java.png" />
<EmbeddedResource Include="Sections\Keyboards.png" />
<EmbeddedResource Include="Sections\Localization.png" />
<EmbeddedResource Include="Sections\Messaging.png" />
<EmbeddedResource Include="Sections\Multimedia.png" />
<EmbeddedResource Include="Sections\Navigation.png" />
<EmbeddedResource Include="Sections\Networking.png" />
<EmbeddedResource Include="Sections\Packaging.png" />
<EmbeddedResource Include="Sections\Productivity.png" />
<EmbeddedResource Include="Sections\Repositories.png" />
<EmbeddedResource Include="Sections\Ringtones.png" />
<EmbeddedResource Include="Sections\Scripting.png" />
<EmbeddedResource Include="Sections\Security.png" />
<EmbeddedResource Include="Sections\Site-Specific_Apps.png" />
<EmbeddedResource Include="Sections\Social.png" />
<EmbeddedResource Include="Sections\Soundboards.png" />
<EmbeddedResource Include="Sections\System.png" />
<EmbeddedResource Include="Sections\Terminal_Support.png" />
<EmbeddedResource Include="Sections\Text_Editors.png" />
<EmbeddedResource Include="Sections\Themes.png" />
<EmbeddedResource Include="Sections\Toys.png" />
<EmbeddedResource Include="Sections\Tweaks.png" />
<EmbeddedResource Include="Sections\Utilities.png" />
<EmbeddedResource Include="Sections\Wallpaper.png" />
<EmbeddedResource Include="Sections\Widgets.png" />
<EmbeddedResource Include="Sections\X_Window.png" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
Expand Down
38 changes: 37 additions & 1 deletion Cygnus/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
namespace Cygnus.Extensions
// <copyright file="Extensions.cs">
// Copyright (C) 2014 PythEch
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either Version 3 of the License, or
// (at your option) any later Version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// </copyright>
// <summary>Cygnus - Cydia-like APT Client for Windows</summary>

namespace Cygnus.Extensions
{
using System;
using System.Collections.Generic;
using XPTable.Models;

/// <summary>
Expand Down Expand Up @@ -45,6 +64,23 @@ public static bool IsNullOrWhitespace(this String str)
return String.IsNullOrWhiteSpace(str);
}

/// <summary>
/// int.TryParse() shortcut.
/// </summary>
/// <param name="str">The string to cast.</param>
/// <param name="defaultValue">Default value to return in case conversion fails.</param>
/// <returns>Int32 equivalent of the string. defaultValue if something goes wrong.</returns>
public static int ToInt32(this String str, int defaultValue=0)
{
int result;
if (Int32.TryParse(str, out result))
{
return result;
}
// else
return defaultValue;
}

/// <summary>
/// String.Format() shortcut that I can't live without.
/// </summary>
Expand Down
9 changes: 5 additions & 4 deletions Cygnus/MainForm.APT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private void ExtractZip(string zipName)
//Extract archive to repos\temp directory first.
//Because sometimes it is necessary to rename extracted files.

ProcessStartInfo startInfo = new ProcessStartInfo("repos\\7za.exe", "x -orepos\\temp -y repos\\" + zipName);
ProcessStartInfo startInfo = new ProcessStartInfo("repos\\7za.exe", "x -orepos\\tmp -y repos\\" + zipName);
startInfo.RedirectStandardOutput = true;
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
Expand All @@ -201,7 +201,7 @@ private void ExtractZip(string zipName)

//Rename/Move the extracted file.

string sourceFilePath = Directory.GetFiles("repos\\temp")[0];
string sourceFilePath = Directory.GetFiles("repos\\tmp")[0];
string targetFilePath = "repos\\" + Path.GetFileNameWithoutExtension(zipName);

if (File.Exists(targetFilePath))
Expand All @@ -212,7 +212,7 @@ private void ExtractZip(string zipName)

File.Move(sourceFilePath, targetFilePath);

Directory.Delete("repos\\temp", true); //Clean up the mess
Directory.Delete("repos\\tmp", true); //Clean up the mess
}

/// <summary>
Expand Down Expand Up @@ -247,7 +247,8 @@ private string GetUDID()
return this.txtUDID.Text;
}
// else ...
return "0000000000000000000000000000000000000000";
//return "0000000000000000000000000000000000000000";
return "10ADED B4D455 C1A551C4L 1CE C01D DEB5"; // DEC1A551F1ED

This comment has been minimized.

Copy link
@PythEch

PythEch May 7, 2014

Author Owner

Damn I forgot to fix this...

}

/// <summary>
Expand Down
1 change: 1 addition & 0 deletions Cygnus/MainForm.Designer.cs

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

74 changes: 63 additions & 11 deletions Cygnus/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace Cygnus
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;
using System.Collections.Generic;

using Cygnus.Extensions;
using XPTable.Models;
Expand Down Expand Up @@ -59,6 +60,49 @@ public partial class MainForm : Form

private static HtmlElement cssBtnDownload, cssBtnDownloadFully, cssBtnBack, cssFrameDepiction;

private static readonly Dictionary<string, Bitmap> SectionIcons = new Dictionary<string, Bitmap>
{
{"Addons", Properties.Resources.Addons},
{"Administration", Properties.Resources.Administration},
{"Archiving", Properties.Resources.Archiving},
{"Books", Properties.Resources.Books},
{"Carrier_Bundles", Properties.Resources.Carrier_Bundles},
{"Data_Storage", Properties.Resources.Data_Storage},
{"Development", Properties.Resources.Development},
{"Dictionaries", Properties.Resources.Dictionaries},
{"Education", Properties.Resources.Education},
{"Entertainment", Properties.Resources.Entertainment},
{"Fonts", Properties.Resources.Fonts},
{"Games", Properties.Resources.Games},
{"Health_and_Fitness", Properties.Resources.Health_and_Fitness},
{"Java", Properties.Resources.Java},
{"Keyboards", Properties.Resources.Keyboards},
{"Localization", Properties.Resources.Localization},
{"Messaging", Properties.Resources.Messaging},
{"Multimedia", Properties.Resources.Multimedia},
{"Navigation", Properties.Resources.Navigation},
{"Networking", Properties.Resources.Networking},
{"Packaging", Properties.Resources.Packaging},
{"Productivity", Properties.Resources.Productivity},
{"Repositories", Properties.Resources.Repositories},
{"Ringtones", Properties.Resources.Ringtones},
{"Scripting", Properties.Resources.Scripting},
{"Security", Properties.Resources.Security},
{"Site-Specific_Apps", Properties.Resources.Site_Specific_Apps},
{"Social", Properties.Resources.Social},
{"Soundboards", Properties.Resources.Soundboards},
{"System", Properties.Resources.System},
{"Terminal_Support", Properties.Resources.Terminal_Support},
{"Text_Editors", Properties.Resources.Text_Editors},
{"Themes", Properties.Resources.Themes},
{"Toys", Properties.Resources.Toys},
{"Tweaks", Properties.Resources.Tweaks},
{"Utilities", Properties.Resources.Utilities},
{"Wallpaper", Properties.Resources.Wallpaper},
{"Widgets", Properties.Resources.Widgets},
{"X_Window", Properties.Resources.X_Window},
};

#endregion Fields

#region Constructors
Expand Down Expand Up @@ -86,7 +130,7 @@ private void InitializeXPTable()
this.tablePackages.GridLines = GridLines.None;
this.tablePackages.EnableWordWrap = true;

ImageColumn col1 = new ImageColumn(String.Empty, 20) { Editable = false, Resizable = false };
ImageColumn col1 = new ImageColumn(String.Empty, 32) { Editable = false, Resizable = false };
TextColumn col2 = new TextColumn() { Editable = false, Resizable = false };

this.tablePackages.ColumnModel = new ColumnModel(new Column[] { col1, col2 });
Expand All @@ -97,7 +141,7 @@ private void InitializeXPTable()
this.tableChanges.GridLines = GridLines.None;
this.tableChanges.EnableWordWrap = true;

ImageColumn col3 = new ImageColumn(String.Empty, 20) { Editable = false, Resizable = false };
ImageColumn col3 = new ImageColumn(String.Empty, 32) { Editable = false, Resizable = false };
TextColumn col4 = new TextColumn() { Editable = false, Resizable = false };

this.tableChanges.ColumnModel = new ColumnModel(new Column[] { col3, col4 });
Expand Down Expand Up @@ -208,8 +252,8 @@ private void LoadXMLSettings()
var settings = XDocument.Load("Cygnus.xml").Element("Settings");

txtUDID.Text = settings.Element("UDID").Value;
boxiDevice.SelectedIndex = Convert.ToInt32(settings.Element("iDevice").Value);
boxVersion.SelectedIndex = Convert.ToInt32(settings.Element("Version").Value);
boxiDevice.SelectedIndex = settings.Element("iDevice").Value.ToInt32(-1);
boxVersion.SelectedIndex = settings.Element("Version").Value.ToInt32(-1);

foreach (var source in settings.Elements("Source"))
{
Expand Down Expand Up @@ -289,7 +333,7 @@ private void AddIcons()
}

/// <summary>
/// Auto-resizes Column widths of listSources and listPackages
/// Auto-resizes Column widths of ListViews and XPTables.
/// </summary>
/// <remarks>
/// I had to increase Column.MaximumWidth property from 1024 to 8192 using XPTable source code...
Expand All @@ -299,9 +343,9 @@ private void ResizeColumns()
this.listSources.Columns[0].Width = this.listSources.Width - 116; // Perfect constant
this.listSources.Columns[1].AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);

this.tablePackages.ColumnModel.Columns[1].Width = this.tablePackages.Width - 41;
this.tablePackages.ColumnModel.Columns[1].Width = this.tablePackages.Width - 53;

this.tableChanges.ColumnModel.Columns[1].Width = this.tableChanges.Width - 41;
this.tableChanges.ColumnModel.Columns[0].Width = this.tableChanges.Width - 41;

this.tableQueue.Refresh(); // this is necessary for some reason
this.tableQueue.AutoResizeColumnWidths();
Expand Down Expand Up @@ -364,19 +408,23 @@ private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
SaveXMLSettings();
}


/// <summary>
/// Adds a "Package" to the tablePackages (XPTable).
/// </summary>
/// <param name="pack">Package to add.</param>
private void UpdatePackagesTable(Package pack)
{
Row row = new Row() { Height = 18 };
row.Cells.Add(new Cell()); // using empty cell for now, I'm going to replace this with Cydia-like Section Icons
row.Cells.Add(new Cell());
row.Cells.Add(new Cell(pack.Name, TitleStyle) { ForeColor = pack.Paid ? Color.Blue : Color.Black });
this.tablePackages.TableModel.Rows.Add(row);

Bitmap sectionImage = SectionIcons.FirstOrDefault(x => pack.Section.Contains(x.Key)).Value;

Row subrow = new Row();
subrow.Cells.Add(new Cell());
subrow.Cells.Add(new Cell(String.Empty, sectionImage) { Padding = new CellPadding(0, -16, 0, 0), ImageSizeMode = ImageSizeMode.NoClip });
// Overflow the bounds of the image to make it fit two rows instead of one.
subrow.Cells.Add(new Cell("from {0} ({1})".FormatWith(pack.Repo.Label, pack.Section), SectionStyle));
row.SubRows.Add(subrow);

Expand Down Expand Up @@ -708,7 +756,7 @@ private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
private void openFolderToolStripMenuItem_Click(object sender, EventArgs e)
{
string packName = selectedQueue.TableRow.Cells[0].Text;
System.Diagnostics.Process.Start("explorer.exe", Path.Combine("debs", packName));
System.Diagnostics.Process.Start("explorer.exe", Path.Combine("debs", ValidFilename(packName)));
}

/// <summary>
Expand Down Expand Up @@ -738,8 +786,12 @@ private void label5_Click(object sender, EventArgs e)
System.Diagnostics.Process.Start("https://github.com/PythEch/Cygnus");
}

private void splitContainer1_SplitterMoved(object sender, SplitterEventArgs e)
{
ResizeColumns();
}

#endregion Methods


}
}
4 changes: 2 additions & 2 deletions Cygnus/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.5.2.0")]
[assembly: AssemblyFileVersion("0.5.2.0")]
[assembly: AssemblyVersion("0.5.3.0")]
[assembly: AssemblyFileVersion("0.5.3.0")]
Loading

0 comments on commit ea4013c

Please sign in to comment.