Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <ListBox SelectedItem="{Binding SelectedObject}"
- PreviewMouseMove="ListBox_PreviewMouseMove"
- PreviewMouseDown="ListBox_PreviewMouseDown" Name="platno">
- <ListBox.Template>
- <ControlTemplate>
- <Border>
- <Border.Background>
- <LinearGradientBrush StartPoint="0,0" EndPoint="1,1" Opacity=".3">
- <GradientStop Color="White" Offset="0"/>
- <GradientStop Color="GhostWhite" Offset="1"/>
- </LinearGradientBrush>
- </Border.Background>
- <ScrollViewer VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Visible" x:Name="scroll">
- <Border>
- <!-- Pozadí s mřížkou -->
- <Border.Background>
- <VisualBrush TileMode="Tile"
- Viewport="0,0,50,50" ViewportUnits="Absolute"
- Viewbox="0,0,50,50" ViewboxUnits="Absolute">
- <VisualBrush.Visual>
- <Rectangle Stroke="Darkgray" StrokeThickness="1" Height="50" Width="50"
- StrokeDashArray="5 3"/>
- </VisualBrush.Visual>
- </VisualBrush>
- </Border.Background>
- <ItemsPresenter/>
- </Border>
- </ScrollViewer>
- </Border>
- </ControlTemplate>
- </ListBox.Template>
- <ListBox.ItemsSource>
- <StaticResource ResourceKey="Col"/>
- </ListBox.ItemsSource>
- <ListBox.ItemsPanel>
- <ItemsPanelTemplate>
- <Canvas IsItemsHost="True" Background="#01FFFFFF"
- Height="{Binding AreaHeight}" Width="{Binding AreaWidth}"
- VerticalAlignment="Top" HorizontalAlignment="Left" x:Name="hlavniPlatno"/>
- </ItemsPanelTemplate>
- </ListBox.ItemsPanel>
- <ListBox.ItemContainerStyle>
- <Style TargetType="ListBoxItem">
- <Setter Property="Canvas.Left" Value="{Binding X}"/>
- <Setter Property="Canvas.Top" Value="{Binding Y}"/>
- <Setter Property="FocusVisualStyle" Value="{StaticResource EmptyFocusVisualStyle}"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="ListBoxItem">
- <ContentPresenter x:Name="Content"/>
- <ControlTemplate.Triggers>
- <Trigger Property="IsSelected" Value="True">
- <Setter TargetName="Content" Property="Effect">
- <Setter.Value>
- <DropShadowEffect Color="Gray" ShadowDepth="4" BlurRadius="10"/>
- </Setter.Value>
- </Setter>
- </Trigger>
- <DataTrigger Binding="{Binding IsNew}" Value="True">
- <Setter Property="Opacity" Value=".5"/>
- </DataTrigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- </ListBox.ItemContainerStyle>
- </ListBox>
- private void CreateJPG(string path) {
- var vm = DataContext as MainViewModel;
- var print = platno;
- RenderTargetBitmap rb = new RenderTargetBitmap(Convert.ToInt32(vm.AreaWidth), Convert.ToInt32(vm.AreaHeight), 150d, 150d, PixelFormats.Pbgra32);
- rb.Render(print);
- JpegBitmapEncoder encoder = new JpegBitmapEncoder();
- encoder.Frames.Add(BitmapFrame.Create(rb));
- using (FileStream fs = new FileStream(path, FileMode.Create)) {
- encoder.Save(fs);
- fs.Flush();
- fs.Close();
- }
- }
Add Comment
Please, Sign In to add comment