Saturday, April 26, 2014

How can I make my class not be NULL?

This is the constructor that we have been referring to:



public C1()
{
InitializeComponent();

// Clear out placeholder content
this.wrapPanel.Children.Clear();

// Add in display content
//for (var index = 0; index < 300; ++index)
//{
// var button = new KinectTileButton { Label = (index + 1).ToString(CultureInfo.CurrentCulture) };
// this.wrapPanel.Children.Add(button);
//}

try
{
var files = Directory.GetFiles(@".\GalleryImages");
string[] names = new string[13] { "Cosmin Contra l-a introdus din primul minut pe Ciprian Marica, în timp ce Diego Simeone l-a din nou la dispoziţie pe Diego Costa. Atacantul a ratat un penalty, apoi a dus scorul la 2-0, moment în care s-a şi accidentat, lovind cu genunchiul în bara porţii.", "Joanne", "Robert", "Andrei", "Mihai", "Radu", "Ionica", "Vasile","Cristi","Bogdan","Marian","Georgel","Dan" };

int i = 0;
foreach (var file in files)
{



FileInfo fileInfo = new FileInfo(file);

WineModel wineModel = new WineModel();
wineModel.Image = new Uri(file, UriKind.Relative);
wineModel.Description = names[i++];
wineModel.Price = new Random().NextDouble();

BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.UriSource = wineModel.Image;

bi.EndInit();

var button = new KinectTileButton
{
Label = System.IO.Path.GetFileNameWithoutExtension(file),

Background = new ImageBrush(bi),
Tag = wineModel
};

this.wrapPanel.Children.Add(button);

}
}

catch (Exception ex)
{
//TODO: Add logging
}

// Bind listner to scrollviwer scroll position change, and check scroll viewer position
this.UpdatePagingButtonState();
scrollViewer.ScrollChanged += (o, e) => this.UpdatePagingButtonState();
}



which is what is called when this line executes:



C1 C1 = new C1();





It would be greatly appreciated if you would mark any helpful entries as helpful and if the entry answers your question, please mark it with the Answer link.


No comments:

Post a Comment