]]>
]]>
#include <iostream>
#include "List-Class.h"
using namespace std;
using namespace aList;
int main()
{
try {
ArrayList<int> a;
//costruttore standard, si è creata un'istanza
//di tipo intero dell'oggetto ArrayList, ora può essere usata tramite i metodi definiti
//dalla classe stessa
//quando la lista è vuota si possono aggiungere solo elementi in testa
//se si prova a fare a.AddInQueue(elemento) si riceve un errore, stessa cosa per
// a.AddAfterPosition(posizione,elemento) e per a.AddAfterElement(elemento)
a.AddInHead(2); //aggiungo un elemento in testa
a.AddInHead(4); //aggiungo un altro elemento in testa
//stampa 4 2
cout<<"Lista a: "<<a<<endl;
/* In alternativa a cout<<a si poteva usare
for(int i=1;i<=obj.Count();i++)
cout<<"n["<<i<<"] Elemento: "<<obj[i]; //o obj(i) è la stessa cosa
*/
int array[3]={10,11,13};
a.LoadFromArray(array,3); //carico tre elementi nella lista
//stampo 4 2 10 11 13
cout<<"Lista a dopo l'inserimento dell'array: "<<a<<endl;
a.AddAfterElement(11,12); //aggiungo il 12 dopo l'11
//stampo 4 2 10 11 12 13
cout<<"Lista a dopo l'inserimento del 12: "<<a<<endl;
a.SetElem(1,8); //setto l'elemento di poszione 1 ad 8 e quello di posizione 2 a 9
a.SetElem(2,9);
//stampo 8 9 10 11 12 13
cout<<"Lista a dopo la modifica: "<<a<<endl;
a.Sort("DESC"); //ordino in modo decrescente
cout<<"Lista a dopo l'ordinamento: "<<a<<endl;
a.Clear();
ArrayList<int> b(5); //utilizza il costruttore di copia ad un parametro
//crea una lista di 5 interi e ci carica i numeri relativi alle posizioni
//stampa 1 2 3 4 5
cout<<"Lista b appena caricata: "<<b<<endl;
b.DeleteHead();
cout<<"Lista b dopo aver cancellato il 1^ elemento: "<<b<<endl;
b.DeleteQueu();
cout<<"Lista b dopo l'eliminazione dell'ultimo: "<<b<<endl;
b.DeletePosition(2);
cout<<"Lista b dopo la cancellazione dell'elemento in posizione 2: "<<b<<endl;
b.AddInHead(94);
b.DeleteElement(2);
cout<<"Lista b dopo l'inserimento in testa di 94 e la cancellazione di 2: "<<b<<endl;
a=b;
cout<<"Lista a dopo che gli si sono impostati i valori di b: "<<a<<endl;
a+=b;
cout<<"Lista a dopo che gli si sono aggiunti i valori di b: "<<a<<endl;
ArrayList<int> c(2,1),e(2,2),d; //quest'ultimo costruttore crea
//due elementi (in questo caso) e ad entrambi setta il valore passato come
//default (il secondo parametro)
cout<<"Lista c appena creata: "<<c<<endl;
cout<<"Lista e appena creata: "<<e<<endl;
d=c+e;
cout<<"Lista d dopo che gli si sono aggiunti i valori della lista c ed e: "<<d<<endl;
cout<<"Premi invio per continuare..."<<endl;
a.Clear();
b.Clear();
c.Clear();
d.Clear();
e.Clear();
cin.get();
ArrayList<int> A(4),B(2);
if(A==B) cout<<"A = B"<<endl;
if(A!=B) cout<<"A != B"<<endl;
if(A>=B) cout<<"A >= B"<<endl;
if(A>B) cout<<"A > B"<<endl;
if(A<B) cout<<"A < B"<<endl;
if(A<=B) cout<<"A <= B"<<endl;
cout<<"Premi invio per continuare..."<<endl;
cin.get();
ArrayList<double> f; //crea un'istanza della classe vuota di tipo double
//inserisci i dieci elementi che leggerà dallo stream di input
for(int i=1;i<=10;i++) {
cout<<"Inserisci un nuovo elemento: ";
cin>>f;
}
//la stampa
cout<<"Lista appena caricata: "<<f<<endl;
f.BubbleSort("ASC"); //la ordina in modo crescente
cout<<"Lista ordinata: "<<f<<endl;
//legge altri due elementi dallo stream di input
for(int i=1;i<=2;cout<<"Inserisci il nuovo elemento: ",cin>>f,i++);
cout<<"Lista aggiornata: "<<f;
double arr[f.Count()];
//passa la lista su un array
f.UnloadToArray(arr,f.Count());
cout<<endl;
for(int i=0;i<f.Count();i++) {
cout<<"["<<i+1<<"]: "<<arr[i]<<endl;
}
cout<<"Premi invio per continuare..."<<endl;
cin.get();
}catch(int error) {
//nel caso in cui si verifica un errore viene stampato il relativo nummero
cout<<"nNumero errore: "<<error;
}
fflush(stdin);
cin.get();
return 0;
}
]]>MoO moO MoO mOo [[ ciclo principale ]] MOO [[ stampa del primo numero ]] OOM [[ copia temporanea del primo numero ]] MMM moO moO MMM mOo mOo [[ salvataggio del secondo numero nella prima posizione ]] moO MMM mOo MMM [[ spostamento nel numero temporaneo ]] moO moO [[ uso del numero temporaneo e salvataggio del numero secondario nel ciclo ]] MOO MOo mOo MoO moO moo mOo mOo mooE questo è l'output
1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 1346269 2178309 3524578 5702887 9227465 14930352 ... L'interprete riesce a comprendere i commenti, ogni 'istruzione' deve essere seguita da un carattere di tabulazione (spazio, tab, end-line), i commenti sono accettati solo multilinea tra i due terminatori [[ e ]], i commenti del tipo [[commento]], non vengono interpretati, bisogna mettere un carattere di tabulazione tra la keyword e il commento vero e proprio (come nell'esempio). Buon divertimento![]()
/; ; __ \____// /{__/ `'____ ___ (o) (o } _____________________________/ :--' ,-,'`@@@@@@@@ @@@@@@ _ `__ ;:( @@@@@@@@@ @@@ ___(o'o) :: ) @@@@ @@@@@@ ,'@@( `====' Moo! :: : @@@@@: @@@@ `@@@: :: @@@@@: @@@@@@@) ( '@@@' ;; / /`, @@@@@@@@@ :@@@@@) ::/ ) {_----------------: :~`,~~; ;;'`; : ) : / `; ; ;;;; : : ; : ; ; : `'`' / : : : : : : )_ __; ";" :_ ; _ `,',' :__ * `,'* : * 8`;'* * ` ` ` `^' ` ` :/ ` ` ` ` ` `^' `-^-' ` v/ `: / ]]>
Nell'archivio è presente l'intero progetto sviluppato con Code::Blocks.
]]><Application x:Class="VipWpfUtente.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainForm.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/VipWpfUtente;component/Resources/DataSources.xaml" />
<ResourceDictionary Source="/VipWpfUtente;component/Resources/GlassButton.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application> ]]>
private void xdgVentole_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
FrameworkElement recordContentArea = Infragistics.Windows.Utilities.GetAncestorFromName(e.OriginalSource as DependencyObject, "PART_RecordContentSite");
DataRecord record = null;
//xdgVentole.SelectedItems.DataPresenter.ActiveRecord = record;
if (null != recordContentArea)
record = recordContentArea.DataContext as DataRecord;
if (record != null)
{
//this.xchProva.Series.Clear();
Ventola selectedItem = (Ventola)record.DataItem;
if (_shownItems.ContainsKey(selectedItem.VentolaID))
{
this.xchProva.Series.Remove(_shownItems[selectedItem.VentolaID]);
}
else
{
ObservableCollection<Prova> provas = (new ProvaBO()).GetProvaVentolaPubblicata(selectedItem);
if (selectedItem.Provas.Count != 0 && provas[0].Puntos != null && provas[0].Puntos.Count > 1)
{
//xchProva.Visibility = Visibility.Hidden;
//lblMancanoPunti.Visibility = Visibility.Visible;
xchProva.Visibility = Visibility.Visible;
Series serie = new Series();
serie.DataSource = provas[0].Puntos;
serie.DataMapping = "ValueX = Potenza; ValueY = PressioneTotale";
serie.Name = "Punti";
serie.ChartType = ChartType.ScatterLine;
serie.StrokeThickness = 4;
serie.Animation = new Animation();
serie.Animation.BeginTime = new TimeSpan(0, 0, 0, 0, 100);
serie.Animation.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 200));
this.xchProva.Series.Add(serie);
_shownItems.Add(selectedItem.VentolaID, serie);
}
}
}
}
]]>
//NEL CODICE XAML HO QUESTO
<igDP:XamDataGrid Name="xdgVentole"
DataSource="{Binding Source={StaticResource odpVentolePubblicate}}"
AutoFit="True"
Grid.Column="0" Grid.Row="2"
CellActivated="visualizzazioneAltraVentola"
Height="630"
MouseDoubleClick="xdgVentole_MouseDoubleClick"
>
//CODE BEHIND QUESTO
protected Dictionary<long, Series> _shownItems = new Dictionary<long, Series>();
private void xdgVentole_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
FrameworkElement recordContentArea = Infragistics.Windows.Utilities.GetAncestorFromName(e.OriginalSource as DependencyObject, "PART_RecordContentSite");
DataRecord record = null;
xdgVentole.SelectedItems.DataPresenter.ActiveRecord = record;
if (null != recordContentArea)
record = recordContentArea.DataContext as DataRecord;
if (record != null)
{
this.xchProva.Series.Clear();
Ventola selectedItem = (Ventola)record.DataItem;
ObservableCollection<Prova> provas = (new ProvaBO()).GetProvaVentolaPubblicata(selectedItem);
if (selectedItem.Provas.Count == 0)
{
xchProva.Visibility = Visibility.Hidden;
lblMancanoPunti.Visibility = Visibility.Visible;
}
else
{
xchProva.Visibility = Visibility.Visible;
Series serie = new Series();
serie.DataSource = provas[0].Puntos;
serie.DataMapping = "ValueX = Potenza; ValueY = PressioneTotale";
serie.Name = "Punti";
serie.ChartType = ChartType.ScatterLine;
serie.StrokeThickness = 4;
serie.Animation = new Animation();
serie.Animation.BeginTime = new TimeSpan(0, 0, 1);
serie.Animation.Duration = new Duration(new TimeSpan(0, 0, 2));
this.xchProva.Series.Add(serie);
}
}
}
#endregion
private void visualizzazioneAltraVentola(object sender, Infragistics.Windows.DataPresenter.Events.CellActivatedEventArgs e)
{
//MessageBox.Show(e.Cell.Record.Index.ToString());
//FrameworkElement recordContentArea = Infragistics.Windows.Utilities.GetAncestorFromName(e.OriginalSource as DependencyObject, "PART_RecordContentSite");
FrameworkElement recordContentArea = Infragistics.Windows.Utilities.GetAncestorFromName(e.OriginalSource as DependencyObject, "PART_RecordContentSite");
DataRecord record = null;
if (null != recordContentArea)
record = recordContentArea.DataContext as DataRecord;
if (record != null)
{
//this.xchProva.Series.Clear();
Ventola selectedItem = (Ventola)record.DataItem;
if (_shownItems.ContainsKey(selectedItem.VentolaID))
{
this.xchProva.Series.Remove(_shownItems[selectedItem.VentolaID]);
}
else
{
ObservableCollection<Prova> provas = (new ProvaBO()).GetProvaVentolaPubblicata(selectedItem);
if (selectedItem.Provas.Count != 0 && provas[0].Puntos != null && provas[0].Puntos.Count > 1)
{
xchProva.Visibility = Visibility.Visible;
Series serie = new Series();
serie.DataSource = provas[0].Puntos;
serie.DataMapping = "ValueX = Potenza; ValueY = PressioneTotale";
serie.Name = "Punti";
serie.ChartType = ChartType.ScatterLine;
serie.StrokeThickness = 4;
serie.Animation = new Animation();
serie.Animation.BeginTime = new TimeSpan(0, 0, 0, 0, 100);
serie.Animation.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 200));
this.xchProva.Series.Add(serie);
_shownItems.Add(selectedItem.VentolaID, serie);
}
}
}
}
]]>
private void visualizzazioneAltraVentola(object sender, Infragistics.Windows.DataPresenter.Events.CellActivatedEventArgs e)
{
//MessageBox.Show(e.Cell.Record.Index.ToString());
//FrameworkElement recordContentArea = Infragistics.Windows.Utilities.GetAncestorFromName(e.OriginalSource as DependencyObject, "PART_RecordContentSite");
FrameworkElement recordContentArea = Infragistics.Windows.Utilities.GetAncestorFromName(e.OriginalSource as DependencyObject, "PART_RecordContentSite");
DataRecord record = null;
if (null != recordContentArea)
record = recordContentArea.DataContext as DataRecord;
if (record != null)
{
this.xchProva.Series.Clear();
Ventola selectedItem = (Ventola)record.DataItem;
ObservableCollection<Prova> provas = (new ProvaBO()).GetProvaVentolaPubblicata(selectedItem);
if (selectedItem.Provas.Count == 0)
{
xchProva.Visibility = Visibility.Hidden;
lblMancanoPunti.Visibility = Visibility.Visible;
}
else
{
xchProva.Visibility = Visibility.Visible;
Series serie = new Series();
serie.DataSource = provas[0].Puntos;
serie.DataMapping = "ValueX = Potenza; ValueY = PressioneTotale";
serie.Name = "Punti";
serie.ChartType = ChartType.ScatterLine;
serie.StrokeThickness = 4;
serie.Animation = new Animation();
serie.Animation.BeginTime = new TimeSpan(0, 0, 1);
serie.Animation.Duration = new Duration(new TimeSpan(0, 0, 2));
this.xchProva.Series.Add(serie);
}
}
}
]]>
private void btnSalvaParametro_Click(object sender, RoutedEventArgs e)
{
bool isInsert = false;
if (this.Parametro == null)
{
this.Parametro = new Parametro();
isInsert = true;
}
this.Parametro.NomeValore = txtNomeValore.Text;
this.Parametro.Descrizione = txtDescrizione.Text;
this.Parametro.Tipo = txtTipo.Text;
ParametroBO parametroBO = new ParametroBO();
if (isInsert)
{
List<Parametro> insLstParametro = new List<Parametro>();
insLstParametro.Add(this.Parametro);
parametroBO.Insert(insLstParametro);
this.SourceCollection.Add(this.Parametro);
}
else
{
parametroBO.Update();
}
Close();
}
]]>