Commit inicial
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
ImageCrusher/bin
|
||||||
|
ImageCrusher/obj
|
||||||
|
*.suo
|
||||||
20
ImageCrusher.sln
Normal file
20
ImageCrusher.sln
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||||
|
# Visual Studio 2010
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageCrusher", "ImageCrusher\ImageCrusher.csproj", "{BFFF979E-15D9-43A5-917D-69A8825C0819}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
|
Release|x86 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{BFFF979E-15D9-43A5-917D-69A8825C0819}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
|
{BFFF979E-15D9-43A5-917D-69A8825C0819}.Debug|x86.Build.0 = Debug|x86
|
||||||
|
{BFFF979E-15D9-43A5-917D-69A8825C0819}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
{BFFF979E-15D9-43A5-917D-69A8825C0819}.Release|x86.Build.0 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
126
ImageCrusher/FrmImageCrusher.Designer.cs
generated
Normal file
126
ImageCrusher/FrmImageCrusher.Designer.cs
generated
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
namespace ImageCrusher
|
||||||
|
{
|
||||||
|
partial class FrmImageCrusher
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Variable del diseñador requerida.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Limpiar los recursos que se estén utilizando.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true si los recursos administrados se deben eliminar; false en caso contrario, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Código generado por el Diseñador de Windows Forms
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Método necesario para admitir el Diseñador. No se puede modificar
|
||||||
|
/// el contenido del método con el editor de código.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.btnCrush = new System.Windows.Forms.Button();
|
||||||
|
this.lstImagenes = new System.Windows.Forms.ListBox();
|
||||||
|
this.txtPath = new System.Windows.Forms.TextBox();
|
||||||
|
this.lblPath = new System.Windows.Forms.Label();
|
||||||
|
this.txtSize = new System.Windows.Forms.TextBox();
|
||||||
|
this.lblSize = new System.Windows.Forms.Label();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// btnCrush
|
||||||
|
//
|
||||||
|
this.btnCrush.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.btnCrush.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.btnCrush.Location = new System.Drawing.Point(284, 288);
|
||||||
|
this.btnCrush.Name = "btnCrush";
|
||||||
|
this.btnCrush.Size = new System.Drawing.Size(114, 30);
|
||||||
|
this.btnCrush.TabIndex = 0;
|
||||||
|
this.btnCrush.Text = "Crush";
|
||||||
|
this.btnCrush.UseVisualStyleBackColor = true;
|
||||||
|
this.btnCrush.Click += new System.EventHandler(this.btnCrush_Click);
|
||||||
|
//
|
||||||
|
// lstImagenes
|
||||||
|
//
|
||||||
|
this.lstImagenes.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.lstImagenes.FormattingEnabled = true;
|
||||||
|
this.lstImagenes.Location = new System.Drawing.Point(12, 40);
|
||||||
|
this.lstImagenes.Name = "lstImagenes";
|
||||||
|
this.lstImagenes.Size = new System.Drawing.Size(386, 238);
|
||||||
|
this.lstImagenes.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// txtPath
|
||||||
|
//
|
||||||
|
this.txtPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.txtPath.Location = new System.Drawing.Point(74, 12);
|
||||||
|
this.txtPath.Name = "txtPath";
|
||||||
|
this.txtPath.Size = new System.Drawing.Size(324, 20);
|
||||||
|
this.txtPath.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// lblPath
|
||||||
|
//
|
||||||
|
this.lblPath.AutoSize = true;
|
||||||
|
this.lblPath.Location = new System.Drawing.Point(12, 15);
|
||||||
|
this.lblPath.Name = "lblPath";
|
||||||
|
this.lblPath.Size = new System.Drawing.Size(30, 13);
|
||||||
|
this.lblPath.TabIndex = 3;
|
||||||
|
this.lblPath.Text = "Ruta";
|
||||||
|
//
|
||||||
|
// txtSize
|
||||||
|
//
|
||||||
|
this.txtSize.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.txtSize.Location = new System.Drawing.Point(74, 284);
|
||||||
|
this.txtSize.Name = "txtSize";
|
||||||
|
this.txtSize.Size = new System.Drawing.Size(100, 20);
|
||||||
|
this.txtSize.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// lblSize
|
||||||
|
//
|
||||||
|
this.lblSize.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.lblSize.AutoSize = true;
|
||||||
|
this.lblSize.Location = new System.Drawing.Point(12, 287);
|
||||||
|
this.lblSize.Name = "lblSize";
|
||||||
|
this.lblSize.Size = new System.Drawing.Size(46, 13);
|
||||||
|
this.lblSize.TabIndex = 5;
|
||||||
|
this.lblSize.Text = "Tamaño";
|
||||||
|
//
|
||||||
|
// FrmImageCrusher
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(410, 330);
|
||||||
|
this.Controls.Add(this.lblSize);
|
||||||
|
this.Controls.Add(this.txtSize);
|
||||||
|
this.Controls.Add(this.lblPath);
|
||||||
|
this.Controls.Add(this.txtPath);
|
||||||
|
this.Controls.Add(this.lstImagenes);
|
||||||
|
this.Controls.Add(this.btnCrush);
|
||||||
|
this.Name = "FrmImageCrusher";
|
||||||
|
this.Text = "ImageCrusher";
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.Button btnCrush;
|
||||||
|
private System.Windows.Forms.ListBox lstImagenes;
|
||||||
|
private System.Windows.Forms.TextBox txtPath;
|
||||||
|
private System.Windows.Forms.Label lblPath;
|
||||||
|
private System.Windows.Forms.TextBox txtSize;
|
||||||
|
private System.Windows.Forms.Label lblSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
122
ImageCrusher/FrmImageCrusher.cs
Normal file
122
ImageCrusher/FrmImageCrusher.cs
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.IO;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
|
||||||
|
namespace ImageCrusher
|
||||||
|
{
|
||||||
|
public partial class FrmImageCrusher : Form
|
||||||
|
{
|
||||||
|
string _initialPath = string.Empty;
|
||||||
|
|
||||||
|
private void Initialize()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
txtPath.Text = _initialPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string InitialPath
|
||||||
|
{
|
||||||
|
get { return txtPath.Text; }
|
||||||
|
set { txtPath.Text = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int InitialSize
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
int size;
|
||||||
|
if (!int.TryParse(txtSize.Text, out size))
|
||||||
|
{
|
||||||
|
size = 640;
|
||||||
|
}
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
set { txtSize.Text = value.ToString(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public FrmImageCrusher()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
txtPath.Text = Directory.GetCurrentDirectory();
|
||||||
|
txtSize.Text = InitialSize.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void lstImagenes_Clean()
|
||||||
|
{
|
||||||
|
lstImagenes.Items.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void lstImagenes_AddLine(string line)
|
||||||
|
{
|
||||||
|
lstImagenes.Items.Add(line);
|
||||||
|
|
||||||
|
Application.DoEvents();
|
||||||
|
|
||||||
|
int visibleItems = lstImagenes.ClientSize.Height / lstImagenes.ItemHeight;
|
||||||
|
lstImagenes.TopIndex = Math.Max(lstImagenes.Items.Count - visibleItems + 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnCrush_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string path=txtPath.Text;
|
||||||
|
if (!Directory.Exists(path))
|
||||||
|
{
|
||||||
|
MessageBox.Show("El directorio no existe");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String destPath = String.Format("{0}/small", path);
|
||||||
|
int size = InitialSize;
|
||||||
|
|
||||||
|
lstImagenes_Clean();
|
||||||
|
|
||||||
|
string[] fileNames = Directory.GetFiles(path);
|
||||||
|
foreach (string fileName in fileNames)
|
||||||
|
{
|
||||||
|
string ext = Path.GetExtension(fileName).ToLower();
|
||||||
|
if (ext == ".png" || ext == ".jpg" || ext == ".jpeg")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Image img = Image.FromFile(fileName);
|
||||||
|
int width = img.Width;
|
||||||
|
int height = img.Height;
|
||||||
|
if (width > height)
|
||||||
|
{
|
||||||
|
height = (int)(height / (width / (double)size));
|
||||||
|
width = size;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
width = (int)(width / (height / (double)size));
|
||||||
|
height = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Directory.Exists(destPath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(destPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
Image imgThumb = img.GetThumbnailImage(width, height, null, new System.IntPtr());
|
||||||
|
string newFileName = String.Format("{0}/{1}.small.jpg", destPath, Path.GetFileNameWithoutExtension(fileName));
|
||||||
|
imgThumb.Save(newFileName, ImageFormat.Jpeg);
|
||||||
|
|
||||||
|
lstImagenes_AddLine(string.Format("OK: {0}", newFileName));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
lstImagenes_AddLine(string.Format("Error: {0} {1}", fileName, ex.Message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lstImagenes_AddLine("End.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
120
ImageCrusher/FrmImageCrusher.resx
Normal file
120
ImageCrusher/FrmImageCrusher.resx
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
88
ImageCrusher/ImageCrusher.csproj
Normal file
88
ImageCrusher/ImageCrusher.csproj
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||||
|
<ProductVersion>8.0.30703</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{BFFF979E-15D9-43A5-917D-69A8825C0819}</ProjectGuid>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>ImageCrusher</RootNamespace>
|
||||||
|
<AssemblyName>ImageCrusher</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<TargetFrameworkProfile />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Deployment" />
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Windows.Forms" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="FrmImageCrusher.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="FrmImageCrusher.Designer.cs">
|
||||||
|
<DependentUpon>FrmImageCrusher.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<EmbeddedResource Include="FrmImageCrusher.resx">
|
||||||
|
<DependentUpon>FrmImageCrusher.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
</Compile>
|
||||||
|
<None Include="app.config" />
|
||||||
|
<None Include="Properties\Settings.settings">
|
||||||
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
|
</None>
|
||||||
|
<Compile Include="Properties\Settings.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
86
ImageCrusher/Program.cs
Normal file
86
ImageCrusher/Program.cs
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace ImageCrusher
|
||||||
|
{
|
||||||
|
static class Program
|
||||||
|
{
|
||||||
|
private static bool CreateShortcut(string shortcut, string exe, string dir)
|
||||||
|
{
|
||||||
|
bool created = false;
|
||||||
|
Type t = Type.GetTypeFromCLSID(new Guid("72C24DD5-D70A-438B-8A42-98424B88AFB8")); //Windows Script Host Shell Object
|
||||||
|
object shell = Activator.CreateInstance(t);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
object lnk = t.InvokeMember("CreateShortcut", BindingFlags.InvokeMethod, null, shell, new object[] { shortcut });
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string targetPath = (string)t.InvokeMember("TargetPath", BindingFlags.GetProperty, null, lnk, null);
|
||||||
|
if (targetPath != exe)
|
||||||
|
{
|
||||||
|
t.InvokeMember("TargetPath", BindingFlags.SetProperty, null, lnk, new object[] { exe });
|
||||||
|
t.InvokeMember("WorkingDirectory", BindingFlags.SetProperty, null, lnk, new object[] { dir });
|
||||||
|
t.InvokeMember("IconLocation", BindingFlags.SetProperty, null, lnk, new object[] { String.Format("{0}, 1", exe) });
|
||||||
|
t.InvokeMember("Save", BindingFlags.InvokeMethod, null, lnk, null);
|
||||||
|
created = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Marshal.FinalReleaseComObject(lnk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Marshal.FinalReleaseComObject(shell);
|
||||||
|
}
|
||||||
|
return created;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool InstallSendToShortcut()
|
||||||
|
{
|
||||||
|
String shortcutPath=String.Format("{0}\\ImageCrusher.lnk",Environment.GetFolderPath(Environment.SpecialFolder.SendTo));
|
||||||
|
string exeName = Path.GetFileNameWithoutExtension(Application.ExecutablePath);
|
||||||
|
string exePath = Path.GetDirectoryName(Application.ExecutablePath);
|
||||||
|
return CreateShortcut(shortcutPath, string.Format("{0}\\{1}.exe", exePath, exeName), exePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Punto de entrada principal para la aplicación.
|
||||||
|
/// </summary>
|
||||||
|
[STAThread]
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
if (InstallSendToShortcut())
|
||||||
|
{
|
||||||
|
MessageBox.Show("Acceso directo creado correctamente");
|
||||||
|
}
|
||||||
|
|
||||||
|
Application.EnableVisualStyles();
|
||||||
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
FrmImageCrusher frmImageCrusher = new FrmImageCrusher();
|
||||||
|
if (args.Count() > 0)
|
||||||
|
{
|
||||||
|
String path = args[0];
|
||||||
|
if (!Directory.Exists(path))
|
||||||
|
{
|
||||||
|
if (File.Exists(path))
|
||||||
|
{
|
||||||
|
path = Path.GetDirectoryName(path);
|
||||||
|
frmImageCrusher.InitialPath = path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
frmImageCrusher.InitialPath = path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Application.Run(frmImageCrusher);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
36
ImageCrusher/Properties/AssemblyInfo.cs
Normal file
36
ImageCrusher/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// La información general sobre un ensamblado se controla mediante el siguiente
|
||||||
|
// conjunto de atributos. Cambie estos atributos para modificar la información
|
||||||
|
// asociada con un ensamblado.
|
||||||
|
[assembly: AssemblyTitle("ImageCrusher")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("ImageCrusher")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Si establece ComVisible como false, los tipos de este ensamblado no estarán visibles
|
||||||
|
// para los componentes COM. Si necesita obtener acceso a un tipo de este ensamblado desde
|
||||||
|
// COM, establezca el atributo ComVisible como true en este tipo.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// El siguiente GUID sirve como identificador de typelib si este proyecto se expone a COM
|
||||||
|
[assembly: Guid("520da27f-aa14-46ea-a168-2543c594e163")]
|
||||||
|
|
||||||
|
// La información de versión de un ensamblado consta de los cuatro valores siguientes:
|
||||||
|
//
|
||||||
|
// Versión principal
|
||||||
|
// Versión secundaria
|
||||||
|
// Número de compilación
|
||||||
|
// Revisión
|
||||||
|
//
|
||||||
|
// Puede especificar todos los valores o establecer como predeterminados los números de versión de compilación y de revisión
|
||||||
|
// mediante el asterisco ('*'), como se muestra a continuación:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
63
ImageCrusher/Properties/Resources.Designer.cs
generated
Normal file
63
ImageCrusher/Properties/Resources.Designer.cs
generated
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// Este código fue generado por una herramienta.
|
||||||
|
// Versión de runtime:4.0.30319.34014
|
||||||
|
//
|
||||||
|
// Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si
|
||||||
|
// se vuelve a generar el código.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace ImageCrusher.Properties {
|
||||||
|
using System;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clase de recurso fuertemente tipado, para buscar cadenas traducidas, etc.
|
||||||
|
/// </summary>
|
||||||
|
// StronglyTypedResourceBuilder generó automáticamente esta clase
|
||||||
|
// a través de una herramienta como ResGen o Visual Studio.
|
||||||
|
// Para agregar o quitar un miembro, edite el archivo .ResX y, a continuación, vuelva a ejecutar ResGen
|
||||||
|
// con la opción /str o recompile su proyecto de VS.
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
internal class Resources {
|
||||||
|
|
||||||
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
|
internal Resources() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Devuelve la instancia de ResourceManager almacenada en caché utilizada por esta clase.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
|
get {
|
||||||
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ImageCrusher.Properties.Resources", typeof(Resources).Assembly);
|
||||||
|
resourceMan = temp;
|
||||||
|
}
|
||||||
|
return resourceMan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reemplaza la propiedad CurrentUICulture del subproceso actual para todas las
|
||||||
|
/// búsquedas de recursos mediante esta clase de recurso fuertemente tipado.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Globalization.CultureInfo Culture {
|
||||||
|
get {
|
||||||
|
return resourceCulture;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
resourceCulture = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
117
ImageCrusher/Properties/Resources.resx
Normal file
117
ImageCrusher/Properties/Resources.resx
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
26
ImageCrusher/Properties/Settings.Designer.cs
generated
Normal file
26
ImageCrusher/Properties/Settings.Designer.cs
generated
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// Este código fue generado por una herramienta.
|
||||||
|
// Versión de runtime:4.0.30319.34014
|
||||||
|
//
|
||||||
|
// Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si
|
||||||
|
// se vuelve a generar el código.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace ImageCrusher.Properties {
|
||||||
|
|
||||||
|
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
7
ImageCrusher/Properties/Settings.settings
Normal file
7
ImageCrusher/Properties/Settings.settings
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||||
|
<Profiles>
|
||||||
|
<Profile Name="(Default)" />
|
||||||
|
</Profiles>
|
||||||
|
<Settings />
|
||||||
|
</SettingsFile>
|
||||||
3
ImageCrusher/app.config
Normal file
3
ImageCrusher/app.config
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<configuration>
|
||||||
|
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
|
||||||
Reference in New Issue
Block a user