ayy lmao
This commit is contained in:
parent
abbe94a72c
commit
3b1afdf2c0
92 changed files with 23248 additions and 0 deletions
66
CatalogLib/CatalogLib.csproj
Normal file
66
CatalogLib/CatalogLib.csproj
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{D27ACCF2-80FC-4DE8-AEB8-351FF076E6D5}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>CatalogLib</RootNamespace>
|
||||
<AssemblyName>CatalogLib</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
<SccAuxPath>SAK</SccAuxPath>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<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|AnyCPU' ">
|
||||
<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.Drawing" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Class1.cs" />
|
||||
<Compile Include="ImageCreator.cs" />
|
||||
<Compile Include="PicSettings.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CatalogVbLib\CatalogVbLib.vbproj">
|
||||
<Project>{44465926-240d-473f-90b8-786ba4384406}</Project>
|
||||
<Name>CatalogVbLib</Name>
|
||||
</ProjectReference>
|
||||
</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>
|
||||
12
CatalogLib/Class1.cs
Normal file
12
CatalogLib/Class1.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CatalogLib
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
}
|
||||
}
|
||||
569
CatalogLib/ImageCreator.cs
Normal file
569
CatalogLib/ImageCreator.cs
Normal file
|
|
@ -0,0 +1,569 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using CatalogVbLib;
|
||||
|
||||
namespace CatalogLib
|
||||
{
|
||||
public class ImageCreator
|
||||
{
|
||||
|
||||
#region "dichiarazioni"
|
||||
|
||||
|
||||
private bool FotoRuotaADestra = false;
|
||||
|
||||
private bool FotoRuotaASinistra = false;
|
||||
private string TempMinText = "";
|
||||
//Private crFont1 As Font
|
||||
|
||||
private string _NomeFileChild;
|
||||
private DirectoryInfo _SourceDir;
|
||||
private DirectoryInfo _DestDirStart;
|
||||
|
||||
private DirectoryInfo _DestDir;
|
||||
|
||||
private FileInfo _workFile;
|
||||
private string testoFirma;
|
||||
private string testoFirmaV;
|
||||
private int alphaScelta;
|
||||
private int _dimensioneStandard;
|
||||
private int _dimensioneStandardMiniatura;
|
||||
private DateTime dataFoto;
|
||||
private DateTime dataPartenzaI;
|
||||
private string testoOrario;
|
||||
private string testoFirmaPiccola;
|
||||
private Size thumbSizeSmall;
|
||||
private Size thumbSizeBig;
|
||||
private string nomeFileSmall;
|
||||
private string nomeFileBig;
|
||||
|
||||
private string nomeFileBig2;
|
||||
private float yPosFromBottom;
|
||||
private float yPosFromBottom1;
|
||||
private float yPosFromBottom2;
|
||||
private float yPosFromBottom3;
|
||||
private float yPosFromBottom4;
|
||||
|
||||
public string NomeFileChild
|
||||
{
|
||||
get { return _NomeFileChild; }
|
||||
set { _NomeFileChild = value; }
|
||||
}
|
||||
|
||||
public DirectoryInfo DestDirStart
|
||||
{
|
||||
get { return _DestDirStart; }
|
||||
set { _DestDirStart = value; }
|
||||
}
|
||||
|
||||
public DirectoryInfo SourceDir
|
||||
{
|
||||
get { return _SourceDir; }
|
||||
set { _SourceDir = value; }
|
||||
}
|
||||
|
||||
public DirectoryInfo DestDir
|
||||
{
|
||||
get { return _DestDir; }
|
||||
set { _DestDir = value; }
|
||||
}
|
||||
|
||||
public FileInfo WorkFile
|
||||
{
|
||||
get { return _workFile; }
|
||||
set { _workFile = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public ImageCreator(string nomeFileChild, DirectoryInfo sourceDir, DirectoryInfo destDir, DirectoryInfo destDirStart)
|
||||
{
|
||||
this.NomeFileChild = nomeFileChild;
|
||||
SourceDir = sourceDir;
|
||||
DestDir = destDir;
|
||||
DestDirStart = destDirStart;
|
||||
WorkFile = new FileInfo(nomeFileChild);
|
||||
}
|
||||
|
||||
public ImageCreator(string nomeFileChild, DirectoryInfo sourceDir, DirectoryInfo destDir)
|
||||
{
|
||||
NomeFileChild = nomeFileChild;
|
||||
DestDir = destDir;
|
||||
}
|
||||
|
||||
public ImageCreator(FileInfo file, DirectoryInfo destination)
|
||||
{
|
||||
WorkFile = file;
|
||||
DestDir = destination;
|
||||
}
|
||||
|
||||
public StringDigitSubstitute CreaImmagineThread(string info)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void CreaImmagineThread(string info)
|
||||
{
|
||||
|
||||
CatalogLib.PicSettings ps = new CatalogLib.PicSettings();
|
||||
|
||||
Image g = Image.FromFile(WorkFile.FullName);
|
||||
|
||||
|
||||
|
||||
if (ps.CreaMiniature)
|
||||
{
|
||||
CreaMiniature();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void Rotation(ref System.Drawing.Image g)
|
||||
{
|
||||
FotoRuotaADestra = false;
|
||||
FotoRuotaASinistra = false;
|
||||
|
||||
if (CatalogVbLib.PicSettings.UsaRotazioneAutomatica == true)
|
||||
{
|
||||
// ci sono dati exif
|
||||
if (g.PropertyIdList.Length > 0)
|
||||
{
|
||||
ExifReader DatiExif = new ExifReader((Bitmap)g);
|
||||
|
||||
switch (DatiExif.Orientation)
|
||||
{
|
||||
case ExifReader.Orientations.BottomLeft:
|
||||
|
||||
break;
|
||||
case ExifReader.Orientations.BottomRight:
|
||||
|
||||
break;
|
||||
case ExifReader.Orientations.LeftTop:
|
||||
|
||||
break;
|
||||
case ExifReader.Orientations.LftBottom:
|
||||
FotoRuotaASinistra = true;
|
||||
break;
|
||||
case ExifReader.Orientations.RightBottom:
|
||||
|
||||
break;
|
||||
case ExifReader.Orientations.RightTop:
|
||||
|
||||
break;
|
||||
case ExifReader.Orientations.TopLeft:
|
||||
|
||||
break;
|
||||
case ExifReader.Orientations.TopRight:
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (FotoRuotaASinistra == true)
|
||||
{
|
||||
g.RotateFlip(RotateFlipType.Rotate270FlipNone);
|
||||
}
|
||||
if (FotoRuotaADestra == true)
|
||||
{
|
||||
g.RotateFlip(RotateFlipType.Rotate90FlipNone);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ImpostaTestoExtra(Image g)
|
||||
{
|
||||
if (CatalogVbLib.PicSettings.UsaOrarioTestoApplicare ||
|
||||
CatalogVbLib.PicSettings.UsaTempoGaraTestoApplicare ||
|
||||
CatalogVbLib.PicSettings.UsaOrarioMiniatura ||
|
||||
CatalogVbLib.PicSettings.TestoMin ||
|
||||
CatalogVbLib.PicSettings.AggTempoGaraMin ||
|
||||
CatalogVbLib.PicSettings.AggNumTempMin)
|
||||
{
|
||||
if (g.PropertyIdList.Length > 0) //ci sono dati exif
|
||||
{
|
||||
var datiExix = new ExifReader((Bitmap)g);
|
||||
dataFoto = datiExix.DateTimeOriginal;
|
||||
testoFirma = CatalogVbLib.PicSettings.TestoFirmaStart;
|
||||
testoFirmaV = CatalogVbLib.PicSettings.TestoFirmaStartV;
|
||||
|
||||
if (dataFoto.Year != 1)
|
||||
{
|
||||
testoFirmaPiccola = dataFoto.ToShortDateString();
|
||||
if (CatalogVbLib.PicSettings.UsaOrarioTestoApplicare)
|
||||
{
|
||||
testoFirma = string.Concat(testoFirma, " ", dataFoto.ToShortDateString(), " ",
|
||||
dataFoto.ToLongDateString());
|
||||
testoFirmaV = string.Concat(testoFirmaV, " ", dataFoto.ToShortDateString(), " ",
|
||||
dataFoto.ToLongDateString());
|
||||
|
||||
}
|
||||
if (CatalogVbLib.PicSettings.UsaTempoGaraTestoApplicare)
|
||||
{
|
||||
TimeSpan orario = dataPartenzaI - dataFoto;
|
||||
testoFirma = string.Concat(testoFirma, " ", testoOrario, orario.ToString(@"hh\:mm\:ss"));
|
||||
testoFirmaV = string.Concat(testoFirmaV, " ", testoOrario, orario.ToString(@"hh\:mm\:ss"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
testoFirma = CatalogVbLib.PicSettings.TestoFirmaStart;
|
||||
testoFirmaV = CatalogVbLib.PicSettings.TestoFirmaStartV;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void PreparaVariabili()
|
||||
{
|
||||
alphaScelta = (int)(255 * (100 - CatalogVbLib.PicSettings.Trasparenza) / 100);
|
||||
testoFirma = string.Empty;
|
||||
testoFirmaV = string.Empty;
|
||||
dataPartenzaI = CatalogVbLib.PicSettings.DataPartenza;
|
||||
testoOrario = CatalogVbLib.PicSettings.TestoOrario;
|
||||
if (testoOrario.Length > 0)
|
||||
{
|
||||
testoOrario += " ";
|
||||
}
|
||||
testoFirmaPiccola = string.Empty;
|
||||
thumbSizeSmall = new Size();
|
||||
thumbSizeBig = new Size();
|
||||
nomeFileSmall = string.Empty;
|
||||
nomeFileBig2 = string.Empty;
|
||||
nomeFileBig = string.Empty;
|
||||
_dimensioneStandard = CatalogVbLib.PicSettings.DimStandard;
|
||||
_dimensioneStandardMiniatura = CatalogVbLib.PicSettings.DimStandardMiniatura;
|
||||
|
||||
nomeFileSmall = CatalogVbLib.PicSettings.Suffisso + WorkFile.Name;
|
||||
nomeFileBig = WorkFile.Name;
|
||||
}
|
||||
|
||||
private void PrepareThumbnailSize(Image g)
|
||||
{
|
||||
if (g.Width > g.Height)
|
||||
{
|
||||
thumbSizeSmall = NewthumbSize(g.Width, g.Height, CatalogVbLib.PicSettings.LarghezzaSmall, "Larghezza");
|
||||
Size sizeOrig = new Size(g.Width, g.Height);
|
||||
thumbSizeBig = sizeOrig;
|
||||
}
|
||||
else
|
||||
{
|
||||
thumbSizeSmall = NewthumbSize(g.Width, g.Height, CatalogVbLib.PicSettings.AltezzaSmall, "Altezza");
|
||||
Size sizeOrig = new Size(g.Width, g.Height);
|
||||
thumbSizeBig = sizeOrig;
|
||||
}
|
||||
}
|
||||
|
||||
private void CreaMiniature(Image g, Bitmap imgOutputBig, ImageFormat thisFormat)
|
||||
{
|
||||
CatalogLib.PicSettings ps = new PicSettings();
|
||||
|
||||
if (CatalogVbLib.PicSettings.TestoMin)
|
||||
{
|
||||
testoFirmaPiccola = nomeFileBig;
|
||||
|
||||
}
|
||||
else if (CatalogVbLib.PicSettings.AggNumTempMin)
|
||||
{
|
||||
testoFirmaPiccola = nomeFileBig + " ";
|
||||
}
|
||||
|
||||
Font crFont1;
|
||||
Font crFont2;
|
||||
SizeF crSize1 = new SizeF();
|
||||
SizeF crSize2 = new SizeF();
|
||||
|
||||
if (CatalogVbLib.PicSettings.CreaMiniature)
|
||||
{
|
||||
if (!CatalogVbLib.PicSettings.AggiungiScritteMiniature)
|
||||
{
|
||||
if (string.Equals(CatalogVbLib.PicSettings.DirectorySorgente, CatalogVbLib.PicSettings.DirectoryDestinazione, StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
nomeFileSmall = nomeFileSmall.Substring(0, nomeFileSmall.Length - 4) + CatalogVbLib.PicSettings.Codice +
|
||||
nomeFileSmall.Substring(nomeFileSmall.Length - 4);
|
||||
}
|
||||
|
||||
if (CatalogVbLib.PicSettings.UsaOrarioMiniatura ||
|
||||
CatalogVbLib.PicSettings.TestoMin ||
|
||||
CatalogVbLib.PicSettings.AggTempoGaraMin ||
|
||||
CatalogVbLib.PicSettings.AggNumTempMin)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(testoFirmaPiccola))
|
||||
{
|
||||
Bitmap imgOutputSmall = (Bitmap)imgOutputBig.Clone();
|
||||
|
||||
Graphics grPhoto1 = Graphics.FromImage(imgOutputSmall);
|
||||
grPhoto1.SmoothingMode = SmoothingMode.HighSpeed; //Todo: permettere di cambiare questo parametro
|
||||
|
||||
int larghezzaStandard1;
|
||||
|
||||
_dimensioneStandardMiniatura = 50;
|
||||
bool grassetto = CatalogVbLib.PicSettings.Grassetto;
|
||||
crFont1 = new Font(CatalogVbLib.PicSettings.IlFont, _dimensioneStandardMiniatura, grassetto ? FontStyle.Bold : FontStyle.Regular);
|
||||
crFont2 = new Font(CatalogVbLib.PicSettings.IlFont, _dimensioneStandard, grassetto ? FontStyle.Bold : FontStyle.Regular);
|
||||
|
||||
crSize1 = grPhoto1.MeasureString(testoFirmaPiccola, crFont1);
|
||||
crSize2 = grPhoto1.MeasureString(testoFirma, crFont1);
|
||||
|
||||
larghezzaStandard1 = (int)crSize1.Width;
|
||||
|
||||
if (crSize1.Width > g.Width)
|
||||
{
|
||||
int conta = _dimensioneStandardMiniatura;
|
||||
do
|
||||
{
|
||||
if (conta > 20)
|
||||
{
|
||||
conta -= 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
conta -= 1;
|
||||
}
|
||||
|
||||
crFont1 = new Font(CatalogVbLib.PicSettings.IlFont, conta, grassetto ? FontStyle.Bold : FontStyle.Regular);
|
||||
crSize1 = grPhoto1.MeasureString(testoFirmaPiccola, crFont1);
|
||||
|
||||
if (crSize1.Width < g.Width)
|
||||
{
|
||||
larghezzaStandard1 = (int)crSize1.Width;
|
||||
break;
|
||||
}
|
||||
|
||||
} while (conta > 5);
|
||||
_dimensioneStandardMiniatura = conta;
|
||||
|
||||
}
|
||||
|
||||
switch (CatalogVbLib.PicSettings.Posizione.ToUpper())
|
||||
{
|
||||
case "ALTO":
|
||||
yPosFromBottom1 = CatalogVbLib.PicSettings.Margine;
|
||||
yPosFromBottom4 = CatalogVbLib.PicSettings.MargVert;
|
||||
break;
|
||||
|
||||
case "BASSO":
|
||||
yPosFromBottom1 =
|
||||
(float)
|
||||
(g.Height - crSize1.Height - (g.Height * CatalogVbLib.PicSettings.Margine / 100));
|
||||
yPosFromBottom4 = (float)(g.Height - crSize1.Height - (g.Height * CatalogVbLib.PicSettings.MargVert / 100));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
float xCenterOfImg1 = Single.NaN;
|
||||
|
||||
StringFormat strFormat1 = new StringFormat();
|
||||
|
||||
switch (CatalogVbLib.PicSettings.Allineamento.ToUpper())
|
||||
{
|
||||
case "SINISTRA":
|
||||
xCenterOfImg1 = CatalogVbLib.PicSettings.Margine + (larghezzaStandard1 / 2);
|
||||
if ((larghezzaStandard1 / 2) > (g.Width / 2) - CatalogVbLib.PicSettings.Margine)
|
||||
{
|
||||
xCenterOfImg1 = g.Width / 2;
|
||||
}
|
||||
break;
|
||||
|
||||
case "CENTRO":
|
||||
xCenterOfImg1 = (g.Width / 2);
|
||||
break;
|
||||
|
||||
case "DESTRA":
|
||||
xCenterOfImg1 = (g.Width - CatalogVbLib.PicSettings.Margine - (larghezzaStandard1 / 2));
|
||||
if ((larghezzaStandard1 / 2) > (g.Width / 2) - CatalogVbLib.PicSettings.Margine)
|
||||
{
|
||||
xCenterOfImg1 = g.Width / 2;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
strFormat1.Alignment = StringAlignment.Center;
|
||||
|
||||
SolidBrush semiTransBrush21 = new SolidBrush(Color.FromArgb(alphaScelta, 0, 0, 0));
|
||||
SolidBrush semiTransBrush1 = new SolidBrush(Color.FromArgb(alphaScelta, CatalogVbLib.PicSettings.fontColoreRGB));
|
||||
|
||||
_dimensioneStandardMiniatura = CatalogVbLib.PicSettings.DimMin;
|
||||
|
||||
if (ps.Grassetto)
|
||||
{
|
||||
crFont1 = new Font(ps.IlFont, _dimensioneStandardMiniatura, FontStyle.Bold);
|
||||
}
|
||||
else
|
||||
{
|
||||
crFont1 = new Font(ps.IlFont, _dimensioneStandardMiniatura);
|
||||
}
|
||||
|
||||
if (ps.TestoMin)
|
||||
{
|
||||
grPhoto1.DrawString(nomeFileBig, crFont1, semiTransBrush21, new PointF(xCenterOfImg1 + 1, yPosFromBottom1 + 1), strFormat1);
|
||||
grPhoto1.DrawString(nomeFileBig, crFont1, semiTransBrush1, new PointF(xCenterOfImg1, yPosFromBottom1), strFormat1);
|
||||
}
|
||||
else if (ps.AggTempoGaraMin & ps.UsaTempoGaraTestoApplicare)
|
||||
{
|
||||
//TimeSpan orario = (dataPartenzaI - dataFoto) * 10000000; //todo
|
||||
TimeSpan orario = dataPartenzaI - dataFoto; //todo controllare se torna la roba giusta
|
||||
|
||||
string tempStr = "";
|
||||
|
||||
|
||||
|
||||
tempStr += Environment.NewLine + testoOrario + orario.Hours.ToString("00") + ":" +
|
||||
orario.Minutes.ToString("00") + ":" + orario.Seconds.ToString("00"); //todo: usare una stringa formato per sta boiata
|
||||
|
||||
grPhoto1.DrawString(tempStr, crFont1, semiTransBrush21, new PointF(xCenterOfImg1 + 1, yPosFromBottom1 + 1));
|
||||
grPhoto1.DrawString(tempStr, crFont1, semiTransBrush1, new PointF(xCenterOfImg1, yPosFromBottom1), strFormat1);
|
||||
}
|
||||
else if (ps.AggNumTempMin) //todo semplificare la logica di sti eif
|
||||
{
|
||||
TimeSpan orario = dataPartenzaI - dataFoto; //todo controllare se torna la roba giusta
|
||||
string tempStr = "";
|
||||
tempStr += nomeFileBig + Environment.NewLine + testoOrario + orario.Hours.ToString("00") + ":" +
|
||||
orario.Minutes.ToString("00") + ":" + orario.Seconds.ToString("00"); //todo: usare una stringa formato per sta boiata
|
||||
|
||||
grPhoto1.DrawString(tempStr, crFont1, semiTransBrush21, new PointF(xCenterOfImg1 + 1, yPosFromBottom1 + 1));
|
||||
grPhoto1.DrawString(tempStr, crFont1, semiTransBrush1, new PointF(xCenterOfImg1, yPosFromBottom1), strFormat1);
|
||||
}
|
||||
else
|
||||
{
|
||||
grPhoto1.DrawString(testoFirmaPiccola, crFont1, semiTransBrush21, new PointF(xCenterOfImg1 + 1, yPosFromBottom1 + 1), strFormat1);
|
||||
grPhoto1.DrawString(testoFirmaPiccola, crFont1, semiTransBrush1, new PointF(xCenterOfImg1, yPosFromBottom1), strFormat1);
|
||||
}
|
||||
|
||||
|
||||
//Salva miniatura
|
||||
|
||||
imgOutputSmall.Save(Path.Combine(DestDir.FullName, "Temp_" + nomeFileSmall), thisFormat);
|
||||
float width = 0;
|
||||
float height = 0;
|
||||
//float scale = Math.Min(width/imgOutputSmall.Width, height/imgOutputSmall.Height);
|
||||
using (var bmp = new Bitmap(thumbSizeSmall.Width, thumbSizeSmall.Height))
|
||||
{
|
||||
using (var graph = Graphics.FromImage(bmp))
|
||||
{
|
||||
// uncomment for higher quality output
|
||||
//graph.InterpolationMode = InterpolationMode.High;
|
||||
//graph.CompositingQuality = CompositingQuality.HighQuality;
|
||||
//graph.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
|
||||
graph.DrawImage(imgOutputSmall, new Rectangle(0, 0, (int)width, (int)height));
|
||||
|
||||
bmp.Save(Path.Combine(DestDir.FullName, nomeFileSmall), thisFormat);
|
||||
}
|
||||
}
|
||||
//var bmp = new Bitmap(thumbSizeSmall.Width, thumbSizeSmall.Height);
|
||||
//var graph = Graphics.FromImage(bmp);
|
||||
|
||||
|
||||
|
||||
// 10 down vote accepted
|
||||
|
||||
|
||||
//Target parameters:
|
||||
|
||||
//float width = 1024;
|
||||
//float height = 768;
|
||||
//var brush = new SolidBrush(Color.Black);
|
||||
|
||||
//Your original file:
|
||||
|
||||
//var image = new Bitmap(file);
|
||||
|
||||
//Target sizing (scale factor):
|
||||
|
||||
//float scale = Math.Min(width / image.Width, height / image.Height);
|
||||
|
||||
//The resize including brushing canvas first:
|
||||
|
||||
//var bmp = new Bitmap((int)width, (int)height);
|
||||
//var graph = Graphics.FromImage(bmp);
|
||||
|
||||
//// uncomment for higher quality output
|
||||
////graph.InterpolationMode = InterpolationMode.High;
|
||||
////graph.CompositingQuality = CompositingQuality.HighQuality;
|
||||
////graph.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
|
||||
//var scaleWidth = (int)(image.Width * scale);
|
||||
//var scaleHeight = (int)(image.Height * scale);
|
||||
|
||||
//graph.FillRectangle(brush, new RectangleF(0, 0, width, height));
|
||||
//graph.DrawImage(image, new Rectangle(((int)width - scaleWidth)/2, ((int)height - scaleHeight)/2, scaleWidth, scaleHeight));
|
||||
|
||||
|
||||
|
||||
//imgOutputSmall.Save(Path.Combine(DestDir.FullName, nomeFileSmall), thisFormat);
|
||||
|
||||
|
||||
//Image g2 = Image.FromFile(Path.Combine(DestDir.FullName, "Temp_" + nomeFileSmall));
|
||||
//Bitmap imgOutputSmall2 = new Bitmap(g2, thumbSizeSmall.Width, thumbSizeSmall.Height);
|
||||
//imgOutputSmall2.Save(Path.Combine(DestDir.FullName, nomeFileSmall), thisFormat);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Calculate the Size of the New image
|
||||
/// </summary>
|
||||
/// <param name="currentwidth">Larghezza</param>
|
||||
/// <param name="currentheight">Altezza</param>
|
||||
/// <param name="MaxPixel"></param>
|
||||
/// <param name="TipoSize"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks></remarks>
|
||||
private Size NewthumbSize(int currentwidth, int currentheight, int MaxPixel, string TipoSize)
|
||||
{
|
||||
// e
|
||||
//*** Larghezza, Altezza, Auto
|
||||
|
||||
double tempMultiplier = 0;
|
||||
|
||||
if (TipoSize.ToUpper() == "Larghezza".ToUpper())
|
||||
{
|
||||
tempMultiplier = MaxPixel / currentwidth;
|
||||
}
|
||||
else if (TipoSize.ToUpper() == "Altezza".ToUpper())
|
||||
{
|
||||
tempMultiplier = MaxPixel / currentheight;
|
||||
}
|
||||
else
|
||||
{
|
||||
// portrait
|
||||
if (currentheight > currentwidth)
|
||||
{
|
||||
tempMultiplier = MaxPixel / currentheight;
|
||||
}
|
||||
else
|
||||
{
|
||||
tempMultiplier = MaxPixel / currentwidth;
|
||||
}
|
||||
}
|
||||
|
||||
Size NewSize = new Size(Convert.ToInt32(currentwidth * tempMultiplier), Convert.ToInt32(currentheight * tempMultiplier));
|
||||
|
||||
return NewSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
157
CatalogLib/PicSettings.cs
Normal file
157
CatalogLib/PicSettings.cs
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CatalogLib
|
||||
{
|
||||
public class PicSettings
|
||||
{
|
||||
//TODO: Singleton
|
||||
|
||||
private Dictionary<string, object> _settingsDict = new Dictionary<string, object>();
|
||||
|
||||
|
||||
public PicSettings()
|
||||
{
|
||||
SetDefaults();
|
||||
}
|
||||
|
||||
public void Set(string key, object value)
|
||||
{
|
||||
if (_settingsDict.ContainsKey(key))
|
||||
{
|
||||
_settingsDict[key] = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
_settingsDict.Add(key,value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Exists(string key)
|
||||
{
|
||||
return _settingsDict.ContainsKey(key);
|
||||
}
|
||||
|
||||
public int GetInt(string key)
|
||||
{
|
||||
return _settingsDict.ContainsKey(key) ? (int) _settingsDict[key] : 0;
|
||||
}
|
||||
|
||||
public string GetString(string key)
|
||||
{
|
||||
return _settingsDict.ContainsKey(key) ? (string) _settingsDict[key] : string.Empty;
|
||||
}
|
||||
|
||||
public bool GetBool(string key)
|
||||
{
|
||||
return _settingsDict.ContainsKey(key) && (bool) _settingsDict[key];
|
||||
}
|
||||
|
||||
public void SetBool(string key, bool value)
|
||||
{
|
||||
if (_settingsDict.ContainsKey(key))
|
||||
{
|
||||
_settingsDict[key] = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
_settingsDict.Add(key, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public object GetObject(string key)
|
||||
{
|
||||
return _settingsDict.ContainsKey(key) ? _settingsDict[key] : null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void SetDefaults()
|
||||
{
|
||||
Set("dirSorgente",string.Empty);
|
||||
Set("dirDestinazione",string.Empty);
|
||||
Set("dirAggiornaSottodirectory", false);
|
||||
Set("dirCreaSottoCartelle",false);
|
||||
//Set();
|
||||
}
|
||||
|
||||
public bool Grassetto
|
||||
{
|
||||
get { return GetBool("Grassetto"); }
|
||||
set { SetBool("Grassetto", value);}
|
||||
}
|
||||
|
||||
public string IlFont //todo
|
||||
{
|
||||
get { return GetString(""); }
|
||||
set { }
|
||||
}
|
||||
|
||||
public bool TestoMin //todo
|
||||
{
|
||||
get { return false; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public bool AggTempoGaraMin //todo
|
||||
{
|
||||
get { return false; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public bool UsaTempoGaraTestoApplicare //todo
|
||||
{
|
||||
get { return false; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public bool AggNumTempMin //todo
|
||||
{
|
||||
get { return false; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public bool CreaMiniature //todo
|
||||
{
|
||||
get { return false; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public bool AggiungiScritteMiniature
|
||||
{
|
||||
get { return false; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public string Suffisso
|
||||
{
|
||||
get { return string.Empty; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public string Codice
|
||||
{
|
||||
get { return null; }
|
||||
set {}
|
||||
}
|
||||
|
||||
public int Trasparenza
|
||||
{
|
||||
get { return 0; }
|
||||
}
|
||||
|
||||
public bool Posizione
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
38
CatalogLib/Properties/AssemblyInfo.cs
Normal file
38
CatalogLib/Properties/AssemblyInfo.cs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("CatalogLib")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("CatalogLib")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2013")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("7bb8e6ce-72c8-4b36-a166-a62ed446d4e9")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// 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("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: CLSCompliant(true)]
|
||||
Loading…
Add table
Add a link
Reference in a new issue