Mark Heath avatar Mark Heath committed 5bb16b6

can choose Bezier or Linear, fill and outline colours, and whether or not to draw an outline

Comments (0)

Files changed (8)

WpfWaveform/MainWindow.xaml

         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:local="clr-namespace:WpfWaveform"
+        xmlns:toolkit="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"
+        xmlns:toolkitx="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit.Extended"
         Title="MainWindow" Height="350" Width="525">
     <Grid>
         <Grid.RowDefinitions>
         </Grid.RowDefinitions>
         <StackPanel Orientation="Horizontal" Margin="5">
             <Button Content="Load" Width="80" Click="Button_Click" />
+            <CheckBox VerticalAlignment="Center" Margin="5,0" Content="Outline" Height="16" Name="checkBoxOutline" />
+            <CheckBox VerticalAlignment="Center" Margin="5,0" Content="Bezier" Height="16" Name="checkBoxBezier" />
+            <Label VerticalAlignment="Center">Fill:</Label>
+            <toolkitx:ColorPicker Name="colorPickerFill" />
+            <Label VerticalAlignment="Center">Outline:</Label>
+            <toolkitx:ColorPicker Name="colorPickerOutline" />
         </StackPanel>
         <Border BorderBrush="LightBlue" BorderThickness="5" Grid.Row="1">
             <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">

WpfWaveform/MainWindow.xaml.cs

         {
             InitializeComponent();
             this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
+            this.checkBoxBezier.IsChecked = true;
+            this.colorPickerFill.SelectedColor = Colors.LightGray;
+            this.colorPickerOutline.SelectedColor = Colors.SlateGray;
         }
 
         void MainWindow_Loaded(object sender, RoutedEventArgs e)
         {
             var generator = new WaveFormPointsGenerator();
             var mipMap = generator.GetPeaks(fileName, 4100);
-            var strokeBrush = new SolidColorBrush(Color.FromRgb(0xC1, 0xC1, 0x93));
+            Brush strokeBrush = (checkBoxOutline.IsChecked.Value) ? new SolidColorBrush(colorPickerOutline.SelectedColor) : null;
+            Brush fillBrush = new SolidColorBrush(colorPickerFill.SelectedColor);
             canvas.Children.Clear();
-            canvas.Children.Add(generator.GetBezierPath(mipMap.Peaks.Select(p => p.Channels[0].Max / 32768.0), 0, 2, 110, -100, strokeBrush, Brushes.Beige));
-            canvas.Children.Add(generator.GetBezierPath(mipMap.Peaks.Select(p => p.Channels[0].Min / 32768.0), 0, 2, 110, -100, strokeBrush, Brushes.Beige));
+
+            var topPoints = mipMap.Peaks.Select(p => p.Channels[0].Max / 32768.0);
+            var bottomPoints = mipMap.Peaks.Select(p => p.Channels[0].Min / 32768.0);
+
+            var topPath = checkBoxBezier.IsChecked.Value ? generator.GetBezierPath(topPoints, 0, 2, 110, -100, strokeBrush, fillBrush) : generator.GetLinearPath(topPoints, 0, 2, 110, -100, strokeBrush, fillBrush);
+            var bottomPath = checkBoxBezier.IsChecked.Value ? generator.GetBezierPath(bottomPoints, 0, 2, 110, -100, strokeBrush, fillBrush) : generator.GetLinearPath(bottomPoints, 0, 2, 110, -100, strokeBrush, fillBrush);
+            canvas.Children.Add(topPath);
+            canvas.Children.Add(bottomPath);
         }
 
 

WpfWaveform/WpfWaveform.csproj

     <Reference Include="WindowsBase" />
     <Reference Include="PresentationCore" />
     <Reference Include="PresentationFramework" />
+    <Reference Include="WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <HintPath>..\packages\Extended.Wpf.Toolkit.1.5.0\lib\net35\WPFToolkit.dll</HintPath>
+    </Reference>
+    <Reference Include="WPFToolkit.Extended">
+      <HintPath>..\packages\Extended.Wpf.Toolkit.1.5.0\lib\net35\WPFToolkit.Extended.dll</HintPath>
+    </Reference>
   </ItemGroup>
   <ItemGroup>
     <ApplicationDefinition Include="App.xaml">

WpfWaveform/packages.config

 <?xml version="1.0" encoding="utf-8"?>
 <packages>
+  <package id="Extended.Wpf.Toolkit" version="1.5.0" />
   <package id="NAudio" version="1.5" />
 </packages>
Add a comment to this file

packages/Extended.Wpf.Toolkit.1.5.0/Extended.Wpf.Toolkit.1.5.0.nupkg

Binary file added.

Add a comment to this file

packages/Extended.Wpf.Toolkit.1.5.0/lib/net35/WPFToolkit.Extended.dll

Binary file added.

Add a comment to this file

packages/Extended.Wpf.Toolkit.1.5.0/lib/net35/WPFToolkit.dll

Binary file added.

Add a comment to this file

packages/Extended.Wpf.Toolkit.1.5.0/lib/net40/WPFToolkit.Extended.dll

Binary file added.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.