Skip to content

Commit

Permalink
Merge pull request #1 from Clouz/TestGui
Browse files Browse the repository at this point in the history
Test gui
  • Loading branch information
Clouz authored May 24, 2017
2 parents 3449fb3 + 5ccb79b commit 9671102
Show file tree
Hide file tree
Showing 18 changed files with 852 additions and 4 deletions.
51 changes: 51 additions & 0 deletions ClassiDiScambio/Celle/CreaID.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Excel = Microsoft.Office.Interop.Excel;



namespace ClassiDiScambio.Celle
{
public class CellID
{
public int Row { get; set; }
public int Column { get; set; }


private Excel.Application application;
private Excel.Workbook workbook;

public CellID(Excel.Application application)
{
this.application = application;
this.workbook = application.ActiveWorkbook;
Excel.Worksheet worksheet = workbook.ActiveSheet;

Row = application.ActiveCell.Row;
Column = application.ActiveCell.Column;

Excel.Range range = worksheet.UsedRange.Columns[Column];

object[,] colonna = range.get_Value(Excel.XlRangeValueDataType.xlRangeValueDefault);

int conteggio = 0;

for (int i = 1; i <= colonna.Length; i++)
{
if (colonna[i,1] is double)
{
if (conteggio < (double)colonna[i, 1])
{
conteggio = int.Parse(colonna[i, 1].ToString());
}
}
}

worksheet.Cells[Row, Column] = conteggio+1;
}
}
}
64 changes: 64 additions & 0 deletions ClassiDiScambio/ClassiDiScambio.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.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>{430E6707-F233-4091-8B93-2C2A95BDF03E}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ClassiDiScambio</RootNamespace>
<AssemblyName>ClassiDiScambio</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</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="Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
<EmbedInteropTypes>True</EmbedInteropTypes>
<HintPath>..\packages\Microsoft.Office.Interop.Excel.15.0.4795.1000\lib\net20\Microsoft.Office.Interop.Excel.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Celle\CreaID.cs" />
<Compile Include="NumeraFogli\Sheet.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<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>
111 changes: 111 additions & 0 deletions ClassiDiScambio/NumeraFogli/Sheet.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Excel = Microsoft.Office.Interop.Excel;



namespace ClassiDiScambio.NumeraFogli
{
public class ContenutoFogli
{
public int Id { get; set; }
public string Description { get; set; }
public string Value { get; set; }
}

public class Sheet
{

public string Cell { get; set; }

private int _FromSheet;
public int FromSheet
{
get { return this._FromSheet; }
set
{
if (this._FromSheet != value && value <= ToSheet && value > 0)
this._FromSheet = value;
}
}

private int _ToSheet;
public int ToSheet
{
get { return _ToSheet; }
set {
if (_ToSheet != value && value <= TotalSheet && value >= FromSheet)
_ToSheet = value;
}
}

public int TotalSheet { get; set; }

private int _StartingNumber;
public int StartingNumber
{
get { return _StartingNumber; }
set { _StartingNumber = value; }
}

public int Row { get; set; }
public int Column { get; set; }

public List<ContenutoFogli> contenuto { get; set; } = new List<ContenutoFogli>();

private Excel.Application application;
private Excel.Workbook workbook;


public Sheet(Excel.Application application)
{
this.application = application;
this.workbook = application.ActiveWorkbook;
Excel.Worksheet worksheets = workbook.ActiveSheet;

Cell = application.ActiveCell.Address;
Row = application.ActiveCell.Row;
Column = application.ActiveCell.Column;
TotalSheet = workbook.Worksheets.Count;
ToSheet = TotalSheet;
FromSheet = worksheets.Index;
StartingNumber = FromSheet;

ReloadList();
}

public void ReloadList()
{
contenuto.Clear();

for (int i = 1; i <= ToSheet; i++)
{
Excel.Worksheet worksheets = workbook.Worksheets[i];
contenuto.Add(new ContenutoFogli()
{
Id = worksheets.Index,
Description = worksheets.Name,
Value = Convert.ToString((worksheets.Cells[Row, Column] as Excel.Range).Value)
});
}
}

public void Write()
{
Excel.Workbook workbook = application.ActiveWorkbook;
int num = StartingNumber;
for (int i = FromSheet; i <= ToSheet; i++)
{
Excel.Worksheet worksheets = workbook.Worksheets[i];
worksheets.Cells[Row, Column] = num++;
}
}

}
}
36 changes: 36 additions & 0 deletions ClassiDiScambio/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// Le informazioni generali relative a un assembly sono controllate dal seguente
// set di attributi. Modificare i valori di questi attributi per modificare le informazioni
// associate a un assembly.
[assembly: AssemblyTitle("ClassiDiScambio")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ClassiDiScambio")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Se si imposta ComVisible su false, i tipi in questo assembly non saranno visibili
// ai componenti COM. Se è necessario accedere a un tipo in questo assembly da
// COM, impostare su true l'attributo ComVisible per tale tipo.
[assembly: ComVisible(false)]

// Se il progetto viene esposto a COM, il GUID seguente verrà utilizzato come ID della libreria dei tipi
[assembly: Guid("430e6707-f233-4091-8b93-2c2a95bdf03e")]

// Le informazioni sulla versione di un assembly sono costituite dai seguenti quattro valori:
//
// Versione principale
// Versione secondaria
// Numero di build
// Revisione
//
// È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build
// usando l'asterisco '*' come illustrato di seguito:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
4 changes: 4 additions & 0 deletions ClassiDiScambio/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Office.Interop.Excel" version="15.0.4795.1000" targetFramework="net452" />
</packages>
16 changes: 14 additions & 2 deletions ExcelGenericUDF.sln
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26403.7
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExcelGenericUDF", "ExcelGenericUDF\ExcelGenericUDF.csproj", "{3B9277D4-E48C-42FF-9B44-FDF8817FD0E1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassiDiScambio", "ClassiDiScambio\ClassiDiScambio.csproj", "{430E6707-F233-4091-8B93-2C2A95BDF03E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExcelGui", "ExcelGui\ExcelGui.csproj", "{389192F4-B61B-4201-A9F9-C7A4EE725ED2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +19,14 @@ Global
{3B9277D4-E48C-42FF-9B44-FDF8817FD0E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3B9277D4-E48C-42FF-9B44-FDF8817FD0E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3B9277D4-E48C-42FF-9B44-FDF8817FD0E1}.Release|Any CPU.Build.0 = Release|Any CPU
{430E6707-F233-4091-8B93-2C2A95BDF03E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{430E6707-F233-4091-8B93-2C2A95BDF03E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{430E6707-F233-4091-8B93-2C2A95BDF03E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{430E6707-F233-4091-8B93-2C2A95BDF03E}.Release|Any CPU.Build.0 = Release|Any CPU
{389192F4-B61B-4201-A9F9-C7A4EE725ED2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{389192F4-B61B-4201-A9F9-C7A4EE725ED2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{389192F4-B61B-4201-A9F9-C7A4EE725ED2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{389192F4-B61B-4201-A9F9-C7A4EE725ED2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion ExcelGenericUDF/ExcelGenericUDF-AddIn.dna
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
Excel-DNA also allows the xml for ribbon UI extensions to be specified in the .dna file.
See the main Excel-DNA site at http://excel-dna.net for downloads of the full distribution.
-->

</DnaLibrary>
16 changes: 15 additions & 1 deletion ExcelGenericUDF/ExcelGenericUDF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@
<HintPath>..\packages\Microsoft.Office.Interop.Excel.15.0.4795.1000\lib\net20\Microsoft.Office.Interop.Excel.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand All @@ -60,9 +63,11 @@
<HintPath>..\packages\UIAComWrapper.1.1.0.14\lib\net40\UIAComWrapper.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Cavi\Calcola.cs" />
<Compile Include="Ribbon.cs" />
<Compile Include="Scheda\Nome.cs" />
<Compile Include="Scheda\Rinomina.cs" />
<Compile Include="Stringa\Spazia.cs" />
Expand All @@ -75,7 +80,16 @@
</Content>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<ProjectReference Include="..\ClassiDiScambio\ClassiDiScambio.csproj">
<Project>{430e6707-f233-4091-8b93-2c2a95bdf03e}</Project>
<Name>ClassiDiScambio</Name>
</ProjectReference>
<ProjectReference Include="..\ExcelGui\ExcelGui.csproj">
<Project>{389192f4-b61b-4201-a9f9-c7a4ee725ed2}</Project>
<Name>ExcelGui</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>xcopy "$(SolutionDir)\packages\ExcelDna.AddIn.0.33.9\tools\ExcelDna.xll" "$(TargetDir)ExcelGenericUDF-AddIn.xll*" /C /Y
Expand Down
Loading

0 comments on commit 9671102

Please sign in to comment.