/// <summary> /// Oblicza i zapisuje histogramy do zmiennych typu SeriesCollection, wywoływana przy załadowaniu okna /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LoadHistograms(object sender, RoutedEventArgs e) { int[] rHistogramValues, gHistogramValues, bHistogramValues, brightnessHistogramValues; (rHistogramValues, gHistogramValues, bHistogramValues, brightnessHistogramValues) = BitmapSource.Histogram(); CollectionR.Add(new LineSeries { Values = new ChartValues <int>(rHistogramValues), LineSmoothness = 0 }); CollectionG.Add(new LineSeries { Values = new ChartValues <int>(gHistogramValues), LineSmoothness = 0 }); CollectionB.Add(new LineSeries { Values = new ChartValues <int>(bHistogramValues), LineSmoothness = 0 }); CollectionBrightness.Add(new LineSeries { Values = new ChartValues <int>(brightnessHistogramValues), LineSmoothness = 0 }); }
static void Main(string[] args) { const short collectionsLength = 4; var sampleObject = new SampleClass(new int[] { 0, 1, 2, 3 }); var collections = new ICollection[collectionsLength]; collections[0] = sampleObject.GetCollectionA(false); collections[1] = sampleObject.GetCollectionA(true); collections[2] = sampleObject.GetCollectionB(false); collections[3] = sampleObject.GetCollectionB(true); for (int i = 0; i < collectionsLength; i++) { Console.WriteLine($"Collection {i}: {sampleObject.GetListInfo<int>(collections[i])}"); } var cb = new CollectionBridge <SampleClass>(sampleObject); foreach (ICollection collection in collections) { try { Console.WriteLine(cb.GetItems(sampleObject, collection)); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("We shouldn't reach this code."); } catch (ArgumentException) { Console.WriteLine("We can't get the protected property using a new CollectionBridge."); } } ICollection _collection = new CollectionA <int>(); try { Console.WriteLine(sampleObject._collectionBridge.GetItems(sampleObject, _collection)); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("We shouldn't reach this code."); } catch (ArgumentException) { Console.WriteLine("We can't get the protected property using a new Collection."); } _collection = new CollectionB <int>(); try { Console.WriteLine(sampleObject._collectionBridge.GetItems(sampleObject, _collection)); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("We shouldn't reach this code."); } catch (ArgumentException) { Console.WriteLine("We can't get the protected property using a new Collection."); } }