Exemplo n.º 1
0
 void Init()
 {
     // Set up all default properties
     fillColor    = Colors.DarkGray;
     fillGradient = null;
     BorderColor  = Colors.Black;
     BaseOffset   = 0;
     Center       = true;
     IsStacked    = false;
     Filled       = false;
 }
Exemplo n.º 2
0
 void Init()
 {
     // Set up all default properties
     fillColor = Colors.DarkGray;
     fillGradient = null;
     BorderColor = Colors.Black;
     BaseOffset = 0;
     Center = true;
     IsStacked = false;
     Filled = false;
 }
Exemplo n.º 3
0
        public StepPlotSample()
            : base()
        {
            infoText = "";
            infoText += "Sound Wave Example. Demonstrates - \n";
            infoText += " * StepPlot (centered) and HorizontalLine IDrawables \n";
            infoText += " * Vertical ColorGradient plotBackground \n";
            //infoText += " * AxisDrag Interaction - try left clicking and dragging X or Y axes \n";
            //infoText += " * Vertical & Horizontal GuideLines - without fragmentation problems! \n";
            //infoText += " * Rubberband Selection - click and drag to zoom an area of the plot \n";
            //infoText += " * Key actions : +,- zoom, left/right/up/down pan, Home restores original scale and origin";

            Assembly asm = Assembly.GetExecutingAssembly ();

            Stream file = asm.GetManifestResourceStream ("Samples.Resources.sound.wav");

            byte[] a = new byte[10000];
            System.Int16[] v = new short[5000];
            System.Int16[] w = new short[1000];

            file.Read (a, 0, 10000);
            for (int i=100; i<5000; ++i) {
                v[i] = BitConverter.ToInt16 (a,i*2);
            }
            file.Close();
            // Select only every 5th sample, so data size = 1000 points
            for (int i=1; i<1000; ++i) {
                w[i] = v[i*5];
            }

            plotCanvas.Clear();

            plotCanvas.AddInteraction (new KeyActions ());
            //plotCanvas.AddInteraction (new AxisDrag ());
            //plotCanvas.AddInteraction (new PlotSelection (Color.Gray));
            //plotCanvas.AddInteraction (new VerticalGuideline (Color.Gray));
            //plotCanvas.AddInteraction (new HorizontalGuideline (Color.Gray));

            plotCanvas.Add (new HorizontalLine (2500.0, Colors.LightBlue));

            StepPlot sp = new StepPlot ();
            sp.DataSource = w;
            sp.Color = Colors.Black;
            sp.Center = true;
            plotCanvas.Add (sp);

            plotCanvas.YAxis1.FlipTickText = true;

            plotCanvas.Canvas.BackgroundColor = new Color (0.375, 0.375, 0.375);

            ColorGradient g = new ColorGradient ();
            g.StartColor = new Color (0.5, 0.5, 1);
            g.EndColor = new Color (0.5, 1, 0.5);
            plotCanvas.PlotBackGradient = g;

            plotCanvas.XAxis1.LineColor = Colors.White;
            plotCanvas.YAxis1.LineColor = Colors.White;

            PackStart (plotCanvas.Canvas, true);
            Label la = new Label (infoText);
            PackStart (la);
        }