This commit is contained in:
Tanya Dimitrova 2020-05-18 21:13:04 +03:00
Родитель 732045da8c
Коммит de742e0d6b
44 изменённых файлов: 1820 добавлений и 52 удалений

@ -1 +1 @@
Subproject commit 8fc2293082e6e914d803027b8ff6d65c42306c6d
Subproject commit 467f9fd32f95f8c82b96dda50b37e6a7432f042e

Просмотреть файл

@ -48,13 +48,13 @@
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Background_Over" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource ItemOuterBorder_SelectedUnfocused}"/>
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource GridView_ItemOuterBorder_SelectedUnfocused}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundInner_Over" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource ItemBackground_SelectedUnfocused}"/>
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource GridView_ItemBackground_SelectedUnfocused}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundInner_Over" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource ItemInnerBorder_SelectedUnfocused}"/>
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource GridView_ItemInnerBorder_SelectedUnfocused}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
@ -209,40 +209,40 @@
Margin="1 1 1 2"
BorderThickness="1"
CornerRadius="1"
BorderBrush="{StaticResource ItemOuterBorder_Over}"
BorderBrush="{StaticResource GridView_ItemOuterBorder_Over}"
Grid.Column="2"
Grid.ColumnSpan="2"
Visibility="Collapsed"
grid:SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical"
HorizontalAlignment="{Binding RenderHorizontalAlignment, RelativeSource={RelativeSource TemplatedParent}}"
MinWidth="{Binding RenderWidth, RelativeSource={RelativeSource TemplatedParent}}">
<Border x:Name="BackgroundInner_Over" BorderThickness="1" BorderBrush="{StaticResource ItemInnerBorder_Over}" Background="{StaticResource ItemBackground_Over}"/>
<Border x:Name="BackgroundInner_Over" BorderThickness="1" BorderBrush="{StaticResource GridView_ItemInnerBorder_Over}" Background="{StaticResource GridView_ItemBackground_Over}"/>
</Border>
<Border x:Name="Background_Selected"
Margin="1 1 1 2"
BorderThickness="1"
CornerRadius="1"
BorderBrush="{StaticResource ItemOuterBorder_Selected}"
BorderBrush="{StaticResource GridView_ItemOuterBorder_Selected}"
Grid.Column="2"
Grid.ColumnSpan="2"
Visibility="Collapsed"
grid:SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical"
HorizontalAlignment="{Binding RenderHorizontalAlignment, RelativeSource={RelativeSource TemplatedParent}}"
MinWidth="{Binding RenderWidth, RelativeSource={RelativeSource TemplatedParent}}">
<Border BorderThickness="1" BorderBrush="{StaticResource ItemInnerBorder_Selected}" Background="{StaticResource ItemBackground_Selected}"/>
<Border BorderThickness="1" BorderBrush="{StaticResource GridView_ItemInnerBorder_Selected}" Background="{StaticResource GridView_ItemBackground_Selected}"/>
</Border>
<Border x:Name="Background_Invalid"
Margin="1 1 1 2"
BorderThickness="1"
CornerRadius="1"
BorderBrush="{StaticResource ItemOuterBorder_Invalid}"
BorderBrush="{StaticResource GridView_ItemOuterBorder_Invalid}"
Grid.Column="2"
Grid.ColumnSpan="2"
Visibility="Collapsed"
grid:SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical"
HorizontalAlignment="{Binding RenderHorizontalAlignment, RelativeSource={RelativeSource TemplatedParent}}"
MinWidth="{Binding RenderWidth, RelativeSource={RelativeSource TemplatedParent}}">
<Border BorderThickness="1" BorderBrush="{StaticResource ItemInnerBorder_Invalid}" Background="{StaticResource ItemBackground_Invalid}"/>
<Border BorderThickness="1" BorderBrush="{StaticResource GridView_ItemInnerBorder_Invalid}" Background="{StaticResource GridView_ItemBackground_Invalid}"/>
</Border>
<controls:GridViewToggleButton
Grid.Column="2"
@ -273,7 +273,7 @@
Grid.Row="2"
Grid.ColumnSpan="2"
Padding="6"
BorderBrush="{StaticResource ControlOuterBorder}"
BorderBrush="{StaticResource GridView_ControlOuterBorder}"
BorderThickness="0,1"
Visibility="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BooleanToVisibilityConverter}}"
HorizontalAlignment="{Binding RenderHorizontalAlignment, RelativeSource={RelativeSource TemplatedParent}}"
@ -300,11 +300,11 @@
Visibility="{TemplateBinding RowIndicatorVisibility}"
grid:SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical"
Grid.RowSpan="3"
BorderBrush="{StaticResource ControlOuterBorder}"
BorderBrush="{StaticResource GridView_ControlOuterBorder}"
BorderThickness="0 0 1 1">
<Border x:Name="NavigatorIndicatorBackground"
Background="{StaticResource GridView_RowIndicatorCellBackground}"
BorderBrush="{StaticResource ControlInnerBorder}"
BorderBrush="{StaticResource GridView_ControlInnerBorder}"
BorderThickness="1">
<Grid>
<Grid x:Name="NavigatorIndicator" HorizontalAlignment="Center" VerticalAlignment="Center" Width="11" Height="11" Visibility="Collapsed">
@ -372,7 +372,7 @@
<Style TargetType="grid:GridViewRow" BasedOn="{StaticResource GridViewRowStyle}">
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="Template" Value="{StaticResource GridViewRowTemplate}"/>
<Setter Property="Background" Value="{StaticResource ItemBackground}"/>
<Setter Property="Background" Value="{StaticResource GridView_ItemBackground}"/>
<Setter Property="BorderBrush" Value="{StaticResource GridView_GridLinesItemBorder}"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="AllowDrop" Value="True"/>

Просмотреть файл

@ -46,13 +46,13 @@
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Background_Over" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource ItemOuterBorder_SelectedUnfocused}"/>
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource GridView_ItemOuterBorder_SelectedUnfocused}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundInner_Over" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource ItemBackground_SelectedUnfocused}"/>
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource GridView_ItemBackground_SelectedUnfocused}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundInner_Over" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource ItemInnerBorder_SelectedUnfocused}"/>
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource GridView_ItemInnerBorder_SelectedUnfocused}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
@ -204,34 +204,34 @@
Margin="1 1 1 2"
BorderThickness="1"
CornerRadius="1"
BorderBrush="{StaticResource ItemOuterBorder_Over}"
BorderBrush="{StaticResource GridView_ItemOuterBorder_Over}"
Grid.Column="2"
Grid.ColumnSpan="2"
Visibility="Collapsed"
grid:SelectiveScrollingGrid.SelectiveScrollingClip="True">
<Border x:Name="BackgroundInner_Over" BorderThickness="1" BorderBrush="{StaticResource ItemInnerBorder_Over}" Background="{StaticResource ItemBackground_Over}"/>
<Border x:Name="BackgroundInner_Over" BorderThickness="1" BorderBrush="{StaticResource GridView_ItemInnerBorder_Over}" Background="{StaticResource GridView_ItemBackground_Over}"/>
</Border>
<Border x:Name="Background_Selected"
Margin="1 1 1 2"
BorderThickness="1"
CornerRadius="1"
BorderBrush="{StaticResource ItemOuterBorder_Selected}"
BorderBrush="{StaticResource GridView_ItemOuterBorder_Selected}"
Grid.Column="2"
Grid.ColumnSpan="2"
Visibility="Collapsed"
grid:SelectiveScrollingGrid.SelectiveScrollingClip="True">
<Border BorderThickness="1" BorderBrush="{StaticResource ItemInnerBorder_Selected}" Background="{StaticResource ItemBackground_Selected}"/>
<Border BorderThickness="1" BorderBrush="{StaticResource GridView_ItemInnerBorder_Selected}" Background="{StaticResource GridView_ItemBackground_Selected}"/>
</Border>
<Border x:Name="Background_Invalid"
Margin="1 1 1 2"
BorderThickness="1"
CornerRadius="1"
BorderBrush="{StaticResource ItemOuterBorder_Invalid}"
BorderBrush="{StaticResource GridView_ItemOuterBorder_Invalid}"
Grid.Column="2"
Grid.ColumnSpan="2"
Visibility="Collapsed"
grid:SelectiveScrollingGrid.SelectiveScrollingClip="True">
<Border BorderThickness="1" BorderBrush="{StaticResource ItemInnerBorder_Invalid}" Background="{StaticResource ItemBackground_Invalid}"/>
<Border BorderThickness="1" BorderBrush="{StaticResource GridView_ItemInnerBorder_Invalid}" Background="{StaticResource GridView_ItemBackground_Invalid}"/>
</Border>
<controls:GridViewToggleButton
Grid.Column="2"
@ -260,7 +260,7 @@
Grid.Row="2"
Grid.ColumnSpan="2"
Padding="6"
BorderBrush="{StaticResource ControlOuterBorder}"
BorderBrush="{StaticResource GridView_ControlOuterBorder}"
BorderThickness="0,1"
Visibility="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BooleanToVisibilityConverter}}">
<ContentPresenter x:Name="PART_HierarchyChildPresenter" grid:SelectiveScrollingGrid.SelectiveScrollingClip="True"/>
@ -283,11 +283,11 @@
Visibility="{TemplateBinding RowIndicatorVisibility}"
grid:SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical"
Grid.RowSpan="3"
BorderBrush="{StaticResource ControlOuterBorder}"
BorderBrush="{StaticResource GridView_ControlOuterBorder}"
BorderThickness="0 0 1 1">
<Border x:Name="NavigatorIndicatorBackground"
Background="{StaticResource GridView_RowIndicatorCellBackground}"
BorderBrush="{StaticResource ControlInnerBorder}"
BorderBrush="{StaticResource GridView_ControlInnerBorder}"
BorderThickness="1">
<Grid>
<Grid x:Name="NavigatorIndicator" HorizontalAlignment="Center" VerticalAlignment="Center" Width="11" Height="11" Visibility="Collapsed">
@ -355,7 +355,7 @@
<Style TargetType="grid:GridViewRow" BasedOn="{StaticResource GridViewRowStyle}">
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="Template" Value="{StaticResource GridViewRowTemplate}"/>
<Setter Property="Background" Value="{StaticResource ItemBackground}"/>
<Setter Property="Background" Value="{StaticResource GridView_ItemBackground}"/>
<Setter Property="BorderBrush" Value="{StaticResource GridView_GridLinesItemBorder}"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="AllowDrop" Value="True"/>

Просмотреть файл

@ -0,0 +1,9 @@
<Application x:Class="BingGeoDataAPI.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:BingGeoDataAPI"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary Source="/Telerik.Windows.Controls;component/Themes/FontResources.xaml"/>
</Application.Resources>
</Application>

Просмотреть файл

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
namespace BingGeoDataAPI
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

Просмотреть файл

@ -0,0 +1,116 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{2624A8F0-543A-4BB3-AE0C-A02BCE152789}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>BingGeoDataAPI</RootNamespace>
<AssemblyName>BingGeoDataAPI</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="Telerik.Windows.Controls, Version=2020.1.115.40, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(TELERIKWPFDIR)\Binaries\WPF40\Telerik.Windows.Controls.dll</HintPath>
</Reference>
<Reference Include="Telerik.Windows.Controls.DataVisualization, Version=2020.1.115.40, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(TELERIKWPFDIR)\Binaries\WPF40\Telerik.Windows.Controls.DataVisualization.dll</HintPath>
</Reference>
<Reference Include="Telerik.Windows.Controls.Input, Version=2020.1.115.40, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(TELERIKWPFDIR)\Binaries\WPF40\Telerik.Windows.Controls.Input.dll</HintPath>
</Reference>
<Reference Include="Telerik.Windows.Data, Version=2020.1.115.40, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(TELERIKWPFDIR)\Binaries\WPF40\Telerik.Windows.Data.dll</HintPath>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="SearchArea.cs" />
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="GeodataHelper.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Resource Include="Readme.md" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

Просмотреть файл

@ -0,0 +1,92 @@
using System;
using Telerik.Windows.Controls.Map;
namespace BingGeoDataAPI
{
// GeodataHelper implementation is based on the following article:
// https://docs.microsoft.com/en-us/bingmaps/spatial-data-services/geodata-api
public class GeodataHelper
{
internal static string BaseURL = "http://platform.bing.com/geo/spatial/v1/public/Geodata?SpatialFilter=GetBoundary({0},{1},{2},{3},{4},{5},{6})&key={7}";
private const string safeCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";
internal static bool TryParseEncodedValue(string value, out LocationCollection parsedValue)
{
parsedValue = null;
var list = new LocationCollection();
int index = 0;
int xsum = 0, ysum = 0;
while (index < value.Length) // While we have more data,
{
long n = 0; // initialize the accumulator
int k = 0; // initialize the count of bits
while (true)
{
if (index >= value.Length) // If we ran out of data mid-number
return false; // indicate failure.
int b = safeCharacters.IndexOf(value[index++]);
if (b == -1) // If the character wasn't on the valid list,
return false; // indicate failure.
n |= ((long)b & 31) << k; // mask off the top bit and append the rest to the accumulator
k += 5; // move to the next position
if (b < 32) break; // If the top bit was not set, we're done with this number.
}
// The resulting number encodes an x, y pair in the following way:
//
// ^ Y
// |
// 14
// 9 13
// 5 8 12
// 2 4 7 11
// 0 1 3 6 10 ---> X
// determine which diagonal it's on
int diagonal = (int)((Math.Sqrt(8 * n + 5) - 1) / 2);
// subtract the total number of points from lower diagonals
n -= diagonal * (diagonal + 1L) / 2;
// get the X and Y from what's left over
int ny = (int)n;
int nx = diagonal - ny;
// undo the sign encoding
nx = (nx >> 1) ^ -(nx & 1);
ny = (ny >> 1) ^ -(ny & 1);
// undo the delta encoding
xsum += nx;
ysum += ny;
// position the decimal point
list.Add(new Telerik.Windows.Controls.Map.Location(ysum * 0.00001, xsum * 0.00001));
}
parsedValue = list;
return true;
}
internal static LocationRect GetBestViewFromXMLString(string xmlBestView)
{
LocationRect rest = new LocationRect();
string temp = xmlBestView.Substring(xmlBestView.IndexOf("((") + 2);
string[] parts = temp.Split(new char[] { ',', ' ', ')', '(' }, StringSplitOptions.RemoveEmptyEntries);
if (parts.Length == 4)
{
rest = new LocationRect(new Location(double.Parse(parts[1]), double.Parse(parts[0])),
new Location(double.Parse(parts[3]), double.Parse(parts[2])));
}
return rest;
}
}
}

Просмотреть файл

@ -0,0 +1,45 @@
<Window x:Class="BingGeoDataAPI.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
mc:Ignorable="d"
Title="MainWindow">
<Grid Background="{telerik:FluentResource ResourceKey=BasicBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel Margin="10 10 0 10">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<telerik:RadWatermarkTextBox x:Name="appIdInput" WatermarkContent="Enter Bing Maps Application Id"/>
<telerik:RadButton HorizontalAlignment="Right" Margin="10 0" Grid.Column="1"
Width="150" Content="Set Id" Click="OnSetIdClick" />
</Grid>
<Grid x:Name="searchBarPanel" IsEnabled="False" Margin="0 10 0 0">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<telerik:RadWatermarkTextBox x:Name="textInput" WatermarkContent="Enter address"/>
<telerik:RadButton Grid.Column="1" Click="OnSearchClick" IsDefault="True"
Content="Search" Width="150" Margin="10 0" />
</Grid>
</StackPanel>
<telerik:RadMap x:Name="radMap" Margin="10" Center="43.7, -79.3834" ZoomLevel="10" Grid.Row="1">
<telerik:RadMap.Provider>
<telerik:BingRestMapProvider x:Name="bingProvider"/>
</telerik:RadMap.Provider>
<telerik:VisualizationLayer x:Name="vizLayer">
<telerik:VisualizationLayer.ShapeFill>
<telerik:MapShapeFill Fill="#220000FF" Stroke="Blue" StrokeThickness="2" />
</telerik:VisualizationLayer.ShapeFill>
</telerik:VisualizationLayer>
</telerik:RadMap>
</Grid>
</Window>

Просмотреть файл

@ -0,0 +1,147 @@
using System;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Media;
using System.Windows.Shapes;
using System.Xml;
using Telerik.Windows.Controls;
using Telerik.Windows.Controls.Map;
namespace BingGeoDataAPI
{
public partial class MainWindow : Window
{
private static Random rndNumberGenerator = new Random();
private Location lastSearchLoaction;
private Brush[] brushes = new Brush[] { Brushes.Red, Brushes.Green, Brushes.DeepSkyBlue, Brushes.DeepPink, Brushes.Yellow, Brushes.LimeGreen, Brushes.Blue, Brushes.Aqua, Brushes.Aquamarine };
public MainWindow()
{
StyleManager.ApplicationTheme = new MaterialTheme();
InitializeComponent();
this.bingProvider.SearchLocationCompleted += BingProvider_SearchLocationCompleted;
this.bingProvider.SearchLocationError += BingProvider_SearchLocationError;
}
private void BingProvider_SearchLocationError(object sender, BingRestSearchLocationErrorEventArgs e)
{
MessageBox.Show(e.Error.ToString());
}
private void BingProvider_SearchLocationCompleted(object sender, BingRestSearchLocationCompletedEventArgs e)
{
if (e.Locations.Count() == 0)
return;
Telerik.Windows.Controls.DataVisualization.Map.BingRest.Location foundLocation = e.Locations[0];
Location mapLocation = new Location(foundLocation.Point.Coordinates[0], foundLocation.Point.Coordinates[1]);
this.lastSearchLoaction = mapLocation;
SearchArea area = new SearchArea(foundLocation.Name, mapLocation, this.bingProvider.ApplicationId, "'" + foundLocation.EntityType + "'");
this.SearchByArea(area);
if (this.searchBarPanel.IsEnabled == false)
{
this.searchBarPanel.IsEnabled = true;
}
}
private void Client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error != null)
return;
this.vizLayer.Items.Clear();
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(e.Result);
XmlNodeList listOfShapes = xmlDoc.GetElementsByTagName("d:Shape");
foreach (XmlNode shapeNode in listOfShapes)
{
LocationCollection list;
GeodataHelper.TryParseEncodedValue(shapeNode.InnerText.Split(',').LastOrDefault(), out list);
if (list != null && list.Count > 0)
{
this.AddPolygon(list, listOfShapes.Count > 0);
}
}
XmlNodeList bestViews = xmlDoc.GetElementsByTagName("d:BestMapViewBox");
if (bestViews.Count > 0)
{
XmlNode bestView = bestViews[0];
LocationRect bestViewRect = GeodataHelper.GetBestViewFromXMLString(bestView.InnerText);
this.radMap.SetView(bestViewRect);
}
Ellipse ellipse = new Ellipse() { Width = 20, Height = 20, Fill = Brushes.Transparent, Stroke = Brushes.Orange, StrokeThickness = 6 };
MapLayer.SetLocation(ellipse, this.lastSearchLoaction);
this.vizLayer.Items.Add(ellipse);
}
private void OnSetIdClick(object sender, RoutedEventArgs e)
{
this.radMap.Provider = null;
this.bingProvider.ApplicationId = this.appIdInput.Text;
this.radMap.Provider = this.bingProvider;
if (string.IsNullOrEmpty(this.textInput.Text))
{
this.textInput.Text = "Sofia";
}
this.StartSearch();
}
private void OnSearchClick(object sender, RoutedEventArgs e)
{
this.StartSearch();
}
private void AddPolygon(LocationCollection list, bool useMultiColors)
{
PolygonData data = new PolygonData();
if (useMultiColors)
{
data.ShapeFill = new MapShapeFill()
{
Fill = new SolidColorBrush(Color.FromArgb(80, (byte)rndNumberGenerator.Next(0, 255), (byte)rndNumberGenerator.Next(0, 255), (byte)rndNumberGenerator.Next(0, 255))),
Stroke = brushes[rndNumberGenerator.Next(0, brushes.Length)],
StrokeThickness = 2,
};
}
data.Points = list;
this.vizLayer.Items.Add(data);
}
private void SearchByArea(SearchArea area)
{
int getAllPollygons = area.GetAllPolygons ? 1 : 0;
int getMetadata = area.GetEntityMetadata ? 1 : 0;
string searchURL = string.Format(GeodataHelper.BaseURL,
area.Location.ToString(),
area.LevelOfDetail,
area.EntityType,
getAllPollygons,
getMetadata,
area.Culture,
area.UserRegion,
area.BingKey);
WebClient client = new WebClient();
client.DownloadStringCompleted += Client_DownloadStringCompleted;
client.DownloadStringAsync(new Uri(searchURL));
}
private void StartSearch()
{
BingRestSearchLocationRequest request = new BingRestSearchLocationRequest();
request.Query = this.textInput.Text;
this.bingProvider.SearchLocationAsync(request);
}
}
}

Просмотреть файл

@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("BingGeoDataAPI")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BingGeoDataAPI")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

71
Map/WPF/BingGeoDataAPI/Properties/Resources.Designer.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace BingGeoDataAPI.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("BingGeoDataAPI.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

Просмотреть файл

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

30
Map/WPF/BingGeoDataAPI/Properties/Settings.Designer.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace BingGeoDataAPI.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

Просмотреть файл

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

Просмотреть файл

@ -0,0 +1,5 @@
## BingGeoData API ##
This example shows how to use the RadMap's BingRestMapProvider along with the GeoData API of Bing Maps in order to find and show boundaries of specific areas.
<keywords:geodata,api,bingrestmapprovider,bingrestsearchlocationrequest>

Просмотреть файл

@ -0,0 +1,48 @@
namespace BingGeoDataAPI
{
internal class SearchArea
{
public SearchArea(string name, Telerik.Windows.Controls.Map.Location loc, string key, string type = null)
{
this.Location = loc;
this.EntityType = type != null ? type : "'PopulatedPlace'";
this.LevelOfDetail = 2;
this.GetAllPolygons = true;
this.GetEntityMetadata = true;
this.Culture = "'en-us'";
this.UserRegion = "'US'";
this.BingKey = key;
this.Name = name;
}
// {0}
public Telerik.Windows.Controls.Map.Location Location { get; set; }
// {0}
public string Address { get; set; }
// {1}
public int LevelOfDetail { get; set; }
// {2}
public string EntityType { get; set; }
// {3} bool -> 0 or 1
public bool GetAllPolygons { get; set; }
// {4} bool -> 0 or 1
public bool GetEntityMetadata { get; set; }
// {5}
public string Culture { get; set; }
// {6}
public string UserRegion { get; set; }
// {7}
public string BingKey { get; set; }
public string Name { get; set; }
}
}

Просмотреть файл

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2018
# Visual Studio Version 16
VisualStudioVersion = 16.0.29613.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProvidersBingMapProvider", "ProvidersBingMapProvider\ProvidersBingMapProvider.csproj", "{69BF076F-CEE0-4A7D-96BA-7D2AA43FD82E}"
EndProject
@ -163,6 +163,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AsyncSqlGeospatialDataReade
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FileSystemMapProvider", "ProvidersFileSystemMapProvider\FileSystemMapProvider.csproj", "{A306A36B-9E6F-45F8-A181-BEF7EEF09B90}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BingGeoDataAPI", "BingGeoDataAPI\BingGeoDataAPI.csproj", "{2624A8F0-543A-4BB3-AE0C-A02BCE152789}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -489,6 +491,10 @@ Global
{A306A36B-9E6F-45F8-A181-BEF7EEF09B90}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A306A36B-9E6F-45F8-A181-BEF7EEF09B90}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A306A36B-9E6F-45F8-A181-BEF7EEF09B90}.Release|Any CPU.Build.0 = Release|Any CPU
{2624A8F0-543A-4BB3-AE0C-A02BCE152789}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2624A8F0-543A-4BB3-AE0C-A02BCE152789}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2624A8F0-543A-4BB3-AE0C-A02BCE152789}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2624A8F0-543A-4BB3-AE0C-A02BCE152789}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

Просмотреть файл

@ -0,0 +1,136 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{77F53CE3-6B74-412A-BE7D-241A0F2E4F49}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>AddDocumentContent</RootNamespace>
<AssemblyName>AddDocumentContent</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="Telerik.Windows.Controls">
<HintPath>$(TELERIKWPFDIR)\Binaries\WPF40\Telerik.Windows.Controls.dll</HintPath>
</Reference>
<Reference Include="Telerik.Windows.Controls.FixedDocumentViewers">
<HintPath>$(TELERIKWPFDIR)\Binaries\WPF40\Telerik.Windows.Controls.FixedDocumentViewers.dll</HintPath>
</Reference>
<Reference Include="Telerik.Windows.Controls.FixedDocumentViewersUI">
<HintPath>$(TELERIKWPFDIR)\Binaries\WPF40\Telerik.Windows.Controls.FixedDocumentViewersUI.dll</HintPath>
</Reference>
<Reference Include="Telerik.Windows.Controls.Input">
<HintPath>$(TELERIKWPFDIR)\Binaries\WPF40\Telerik.Windows.Controls.Input.dll</HintPath>
</Reference>
<Reference Include="Telerik.Windows.Controls.Navigation">
<HintPath>$(TELERIKWPFDIR)\Binaries\WPF40\Telerik.Windows.Controls.Navigation.dll</HintPath>
</Reference>
<Reference Include="Telerik.Windows.Documents.Core">
<HintPath>$(TELERIKWPFDIR)\Binaries\WPF40\Telerik.Windows.Documents.Core.dll</HintPath>
</Reference>
<Reference Include="Telerik.Windows.Documents.Fixed">
<HintPath>$(TELERIKWPFDIR)\Binaries\WPF40\Telerik.Windows.Documents.Fixed.dll</HintPath>
</Reference>
<Reference Include="Telerik.Windows.Zip">
<HintPath>$(TELERIKWPFDIR)\Binaries\WPF40\Telerik.Windows.Zip.dll</HintPath>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="AddTextUILayer.cs" />
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="CustomUILayersBuilder.cs" />
<Compile Include="MainPageViewModel.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="InvertedNullToBooleanConverter.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Resource Include="SampleData\Sample.pdf" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Resource Include="edit.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

Просмотреть файл

@ -0,0 +1,149 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
using Telerik.Windows.Controls;
using Telerik.Windows.Documents.Fixed.Model;
using Telerik.Windows.Documents.Fixed.Model.Editing;
using Telerik.Windows.Documents.Fixed.UI.Layers;
using Telerik.Windows.Documents.Fixed.Utilities.Rendering;
namespace AddDocumentContent
{
public class AddTextUILayer : IUILayer
{
private static readonly string LayerName = "AddTextUILayer";
private readonly Canvas canvas;
private bool hasActiveTextBox;
private UILayerInitializeContext context;
private Point mouseLocation;
static AddTextUILayer()
{
IsEditModeEnabled = true;
}
public AddTextUILayer()
{
this.canvas = new Canvas();
this.canvas.MouseLeftButtonDown += this.Canvas_MouseLeftButtonDown;
this.canvas.MouseLeftButtonUp += this.Canvas_MouseLeftButtonUp;
}
public Canvas UIElement
{
get
{
return this.canvas;
}
}
public string Name
{
get
{
return LayerName;
}
}
public static bool IsEditModeEnabled { get; set; }
public void Initialize(UILayerInitializeContext context)
{
this.context = context;
double width = PageLayoutHelper.GetActualWidth(context.Page);
double height = PageLayoutHelper.GetActualHeight(context.Page);
this.canvas.Width = width;
this.canvas.Height = height;
this.canvas.Background = Brushes.Transparent;
}
public void Update(UILayerUpdateContext context)
{
}
public void Clear()
{
this.canvas.Children.Clear();
}
private void Canvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (!this.hasActiveTextBox && IsEditModeEnabled)
{
e.Handled = true;
}
}
private void Canvas_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (this.hasActiveTextBox)
{
return;
}
e.Handled = true;
this.mouseLocation = e.GetPosition(this.canvas);
TextBox textBox = new TextBox();
this.context.AddFocusableElement(textBox);
textBox.MinWidth = 200;
this.canvas.Children.Add(textBox);
Canvas.SetLeft(textBox, this.mouseLocation.X);
Canvas.SetTop(textBox, this.mouseLocation.Y);
textBox.LostFocus += this.TextBox_LostFocus;
textBox.KeyDown += this.TextBox_KeyDown;
Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() => textBox.Focus()), DispatcherPriority.Input);
this.hasActiveTextBox = true;
}
private void TextBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
this.SubmitChangesAndRemoveTextBox(sender);
}
}
private void TextBox_LostFocus(object sender, RoutedEventArgs e)
{
this.SubmitChangesAndRemoveTextBox(sender);
}
private void SubmitChangesAndRemoveTextBox(object sender)
{
TextBox textBox = (TextBox)sender;
textBox.LostFocus -= this.TextBox_LostFocus;
textBox.KeyDown -= this.TextBox_KeyDown;
this.canvas.Children.Remove(textBox);
string text = textBox.Text;
RadFixedPage page = this.context.Page;
FixedContentEditor editor = new FixedContentEditor(page);
editor.Position.Translate(this.mouseLocation.X, this.mouseLocation.Y);
editor.DrawText(text);
RadPdfViewer viewer = this.context.Presenter.Owner as RadPdfViewer;
if (viewer != null)
{
viewer.InvalidatePageUI(page);
}
this.hasActiveTextBox = false;
}
}
}

Просмотреть файл

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>

Просмотреть файл

@ -0,0 +1,9 @@
<Application x:Class="AddDocumentContent.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:AddDocumentContent"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

Просмотреть файл

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace AddDocumentContent
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

Просмотреть файл

@ -0,0 +1,14 @@
using Telerik.Windows.Documents.Fixed.UI.Layers;
namespace AddDocumentContent
{
public class CustomUILayersBuilder : UILayersBuilder
{
protected override void BuildUILayersOverride(IUILayerContainer uiLayerContainer)
{
base.BuildUILayersOverride(uiLayerContainer);
uiLayerContainer.UILayers.AddAfter(DefaultUILayers.ContentElementsUILayer, new AddTextUILayer());
}
}
}

Просмотреть файл

@ -0,0 +1,19 @@
using System;
using System.Globalization;
using System.Windows.Data;
namespace AddDocumentContent
{
public class InvertedNullToBooleanConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value != null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

Просмотреть файл

@ -0,0 +1,31 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace AddDocumentContent
{
public class MainPageViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public bool IsEditModeEnabled
{
get
{
return AddTextUILayer.IsEditModeEnabled;
}
set
{
if (AddTextUILayer.IsEditModeEnabled != value)
{
AddTextUILayer.IsEditModeEnabled = value;
this.OnProperyChanged();
}
}
}
protected void OnProperyChanged([CallerMemberName] string propertyName = null)
{
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}

Просмотреть файл

@ -0,0 +1,229 @@
<Window x:Class="AddDocumentContent.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:converters="clr-namespace:Telerik.Windows.Documents.Converters;assembly=Telerik.Windows.Controls.FixedDocumentViewers"
xmlns:fixedViewersUI="clr-namespace:Telerik.Windows.Controls.FixedDocumentViewersUI;assembly=Telerik.Windows.Controls.FixedDocumentViewersUI"
xmlns:local="clr-namespace:AddDocumentContent"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Window.Resources>
<telerik:IconSources x:Key="IconPaths" LightBasePath="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/"
DarkBasePath="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/Dark/"
ModernBasePath="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/Modern/" />
<converters:FixedDocumentViewerModeConverter x:Key="ModeConverter" />
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
<telerik:VisibilityToBooleanConverter x:Key="VisibilityToBooleanConverter" />
<telerik:InvertedBooleanConverter x:Key="InvertedBooleanConverter"/>
<local:InvertedNullToBooleanConverter x:Key="InvertedNullToBooleanConverter"/>
<local:MainPageViewModel x:Key="ViewModel" />
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition />
</Grid.RowDefinitions>
<telerik:RadToolBar DataContext="{Binding ElementName=pdfViewer, Path=CommandDescriptors}">
<telerik:RadButton Click="OpenRadButton_Click" Visibility="{Binding OpenCommandDescriptor.IsEnabled, Converter={StaticResource BoolToVisibilityConverter}}" HorizontalAlignment="Left" VerticalAlignment="Stretch" Margin="2" Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" IsBackgroundVisible="False">
<ToolTipService.ToolTip>
<TextBlock Text="Open" />
</ToolTipService.ToolTip>
<Image Source="{telerik:IconResource IconRelativePath=open.png, IconSources={StaticResource IconPaths}}" Stretch="None" />
</telerik:RadButton>
<telerik:RadButton Click="SaveRadButton_Click" IsEnabled="{Binding Path=Document, Source={x:Reference Name=pdfViewer}, Converter={StaticResource InvertedNullToBooleanConverter}}" Visibility="{Binding SaveAsCommandDescriptor.IsEnabled, Converter={StaticResource BoolToVisibilityConverter}}" HorizontalAlignment="Left" VerticalAlignment="Stretch" Margin="2" Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" IsBackgroundVisible="False">
<ToolTipService.ToolTip>
<TextBlock Text="Save As" />
</ToolTipService.ToolTip>
<Image Source="{telerik:IconResource IconRelativePath=save.png, IconSources={StaticResource IconPaths}}" Stretch="None" />
</telerik:RadButton>
<telerik:RadButton Command="{Binding PrintCommandDescriptor.Command}" Visibility="{Binding PrintCommandDescriptor.IsEnabled, Converter={StaticResource BoolToVisibilityConverter}}" HorizontalAlignment="Left" VerticalAlignment="Stretch" Margin="2" Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" IsBackgroundVisible="False">
<ToolTipService.ToolTip>
<TextBlock Text="Print" />
</ToolTipService.ToolTip>
<Image Source="{telerik:IconResource IconRelativePath=printer.png, IconSources={StaticResource IconPaths}}" Stretch="None" />
</telerik:RadButton>
<telerik:RadToolBarSeparator/>
<telerik:RadButton x:Name="counterClockwiseButton"
Command="{Binding RotateCounterClockwiseCommandDescriptor.Command}"
Margin="2" Padding="0" IsBackgroundVisible="False" HorizontalAlignment="Left" VerticalAlignment="Stretch">
<ToolTipService.ToolTip>
<TextBlock Text="Rotate counterclockwise" />
</ToolTipService.ToolTip>
<Image Source="pack://application:,,,/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/Modern/rotate-counterclockwise.png" Stretch="None" />
</telerik:RadButton>
<telerik:RadButton x:Name="clockwiseButton"
Command="{Binding RotateClockwiseCommandDescriptor.Command}"
Margin="2" Padding="0" IsBackgroundVisible="False" HorizontalAlignment="Left" VerticalAlignment="Stretch">
<ToolTipService.ToolTip>
<TextBlock Text="Rotate clockwise" />
</ToolTipService.ToolTip>
<Image Source="pack://application:,,,/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/Modern/rotate-clockwise.png" Stretch="None" />
</telerik:RadButton>
<telerik:RadToolBarSeparator/>
<telerik:RadButton Command="{Binding PageUpCommandDescriptor.Command}" Visibility="{Binding PageUpCommandDescriptor.IsEnabled, Converter={StaticResource BoolToVisibilityConverter}}" HorizontalAlignment="Left" VerticalAlignment="Stretch" Margin="2" Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" IsBackgroundVisible="False">
<ToolTipService.ToolTip>
<TextBlock Text="Previous page" />
</ToolTipService.ToolTip>
<Image Source="{telerik:IconResource IconRelativePath=previous.png, IconSources={StaticResource IconPaths}}" Stretch="None" />
</telerik:RadButton>
<telerik:RadButton Command="{Binding PageDownCommandDescriptor.Command}" Visibility="{Binding PageDownCommandDescriptor.IsEnabled, Converter={StaticResource BoolToVisibilityConverter}}" HorizontalAlignment="Left" VerticalAlignment="Stretch" Margin="2" Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" IsBackgroundVisible="False">
<ToolTipService.ToolTip>
<TextBlock Text="Next page" />
</ToolTipService.ToolTip>
<Image Source="{telerik:IconResource IconRelativePath=next.png, IconSources={StaticResource IconPaths}}" Stretch="None" />
</telerik:RadButton>
<TextBox Width="45" Margin="2" Text="{Binding FixedDocumentViewer.CurrentPageNumber, Mode=TwoWay}" HorizontalContentAlignment="Center" x:Name="tbCurrentPage" KeyDown="tbCurrentPage_KeyDown"/>
<TextBlock VerticalAlignment="Center" Margin="2" Text="/" />
<TextBlock VerticalAlignment="Center" Margin="2" Text="{Binding FixedDocumentViewer.PagesCount}" />
<telerik:RadToolBarSeparator/>
<telerik:RadButton Command="{Binding ZoomInCommandDescriptor.Command}" Visibility="{Binding ZoomInCommandDescriptor.IsEnabled, Converter={StaticResource BoolToVisibilityConverter}}" HorizontalAlignment="Left" VerticalAlignment="Stretch" Margin="2" Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" IsBackgroundVisible="False">
<ToolTipService.ToolTip>
<TextBlock Text="Zoom in" />
</ToolTipService.ToolTip>
<Image Source="{telerik:IconResource IconRelativePath=zoom-in.png, IconSources={StaticResource IconPaths}}" Stretch="None" />
</telerik:RadButton>
<telerik:RadButton x:Name="PART_btnZoomOut" Command="{Binding ZoomOutCommandDescriptor.Command}" Visibility="{Binding ZoomOutCommandDescriptor.IsEnabled, Converter={StaticResource BoolToVisibilityConverter}}" HorizontalAlignment="Left" VerticalAlignment="Stretch" Margin="2" Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" IsBackgroundVisible="False">
<ToolTipService.ToolTip>
<TextBlock Text="Zoom out" />
</ToolTipService.ToolTip>
<Image Source="{telerik:IconResource IconRelativePath=zoom-out.png, IconSources={StaticResource IconPaths}}" Stretch="None" />
</telerik:RadButton>
<fixedViewersUI:PercentComboBox Value="{Binding ElementName=pdfViewer, Path=ScaleFactor, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
RadPdfViewer="{Binding ElementName=pdfViewer}"
Margin="2">
<fixedViewersUI:PercentComboBox.PercentValues>
<fixedViewersUI:Percent Value="10"/>
<fixedViewersUI:Percent Value="25"/>
<fixedViewersUI:Percent Value="50"/>
<fixedViewersUI:Percent Value="75"/>
<fixedViewersUI:Percent Value="100"/>
<fixedViewersUI:Percent Value="150"/>
<fixedViewersUI:Percent Value="200"/>
<fixedViewersUI:Percent Value="500"/>
<fixedViewersUI:Percent Value="1000"/>
<fixedViewersUI:Percent Value="2000"/>
</fixedViewersUI:PercentComboBox.PercentValues>
</fixedViewersUI:PercentComboBox>
<telerik:RadToolBarSeparator />
<telerik:RadToggleButton x:Name="fitToWidthButton"
Command="{Binding FitToWidthFixedDocumentPagesPresenterCommandDescriptor.Command}"
IsEnabled="{Binding FitToWidthFixedDocumentPagesPresenterCommandDescriptor.IsEnabled, Converter={StaticResource InvertedBooleanConverter}, Mode=TwoWay}"
IsChecked="{Binding FitToWidthFixedDocumentPagesPresenterCommandDescriptor.IsEnabled, Mode=TwoWay}"
Margin="2" Padding="0" IsBackgroundVisible="False" HorizontalAlignment="Left" VerticalAlignment="Stretch">
<ToolTipService.ToolTip>
<TextBlock Text="Fit to window width and enable scrolling." />
</ToolTipService.ToolTip>
<Image Source="{telerik:IconResource IconRelativePath=document-fit-width.png, IconSources={StaticResource IconPaths}}" Stretch="None" />
</telerik:RadToggleButton>
<telerik:RadToggleButton x:Name="fitToPageButton"
Command="{Binding FitToPageFixedDocumentSinglePageViewPresenterCommandDescriptor.Command}"
IsEnabled="{Binding FitToPageFixedDocumentSinglePageViewPresenterCommandDescriptor.IsEnabled, Converter={StaticResource InvertedBooleanConverter}, Mode=TwoWay}"
IsChecked="{Binding FitToPageFixedDocumentSinglePageViewPresenterCommandDescriptor.IsEnabled, Mode=TwoWay}"
Margin="2" Padding="0" IsBackgroundVisible="False" HorizontalAlignment="Left" VerticalAlignment="Stretch">
<ToolTipService.ToolTip>
<TextBlock Text="Fit one full page to window." />
</ToolTipService.ToolTip>
<Image Source="{telerik:IconResource IconRelativePath=document-fit-page.png, IconSources={StaticResource IconPaths}}" Stretch="None" />
</telerik:RadToggleButton>
<telerik:RadToolBarSeparator />
<telerik:RadToggleButton IsChecked="{Binding Path=IsEditModeEnabled, Mode=TwoWay, Source={StaticResource ResourceKey=ViewModel}}" Margin="2" Padding="0" IsBackgroundVisible="False" HorizontalAlignment="Left" VerticalAlignment="Stretch">
<ToolTipService.ToolTip>
<TextBlock Text="Edit" />
</ToolTipService.ToolTip>
<Image Source="/AddDocumentContent;component/edit.png" Stretch="None" />
</telerik:RadToggleButton>
<telerik:RadToggleButton IsChecked="{Binding FixedDocumentViewer.Mode, Mode=TwoWay, Converter={StaticResource ModeConverter}, ConverterParameter=Pan}" Margin="2" Padding="0" IsBackgroundVisible="False" HorizontalAlignment="Left" VerticalAlignment="Stretch">
<ToolTipService.ToolTip>
<TextBlock Text="Pan" />
</ToolTipService.ToolTip>
<Image Source="{telerik:IconResource IconRelativePath=hand-free.png, IconSources={StaticResource IconPaths}}" Stretch="None" />
</telerik:RadToggleButton>
<telerik:RadToggleButton IsChecked="{Binding FixedDocumentViewer.Mode, Mode=TwoWay, Converter={StaticResource ModeConverter}, ConverterParameter=TextSelection}" Margin="2" Padding="0" IsBackgroundVisible="False" HorizontalAlignment="Left" VerticalAlignment="Stretch">
<ToolTipService.ToolTip>
<TextBlock Text="Text Selection" />
</ToolTipService.ToolTip>
<Image Source="{telerik:IconResource IconRelativePath=text-selection.png, IconSources={StaticResource IconPaths}}" Stretch="None" />
</telerik:RadToggleButton>
<telerik:RadToggleButton IsChecked="{Binding ElementName=signaturePanel, Path=Visibility, Mode=TwoWay, Converter={StaticResource VisibilityToBooleanConverter}}"
IsEnabled="{Binding ValidateSignaturesCommandDescriptor.IsEnabled}"
Margin="2" IsBackgroundVisible="False" HorizontalAlignment="Left" VerticalAlignment="Stretch">
<ToolTipService.ToolTip>
<TextBlock Text="Signature Panel" />
</ToolTipService.ToolTip>
<Image Source="{telerik:IconResource IconRelativePath=signature16x16.png, IconSources={StaticResource IconPaths}}" Stretch="None" />
</telerik:RadToggleButton>
</telerik:RadToolBar>
<fixedViewersUI:SignaturePanel Grid.Row="1" x:Name="signaturePanel" PdfViewer="{Binding ElementName=pdfViewer, Mode=OneWay}" />
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<telerik:RadPdfViewerNavigationPane RadPdfViewer="{Binding ElementName=pdfViewer, Mode=OneWay}" />
<telerik:RadPdfViewer Grid.Column="1" x:Name="pdfViewer" DataContext="{Binding ElementName=pdfViewer, Path=CommandDescriptors}" telerik:Analytics.Name="pdfViewer">
<telerik:RadContextMenu.ContextMenu>
<telerik:RadContextMenu x:Name="menu">
<telerik:RadMenuItem Header="Copy" Command="{Binding CopyCommandDescriptor.Command}"
Visibility="{Binding CopyCommandDescriptor.IsEnabled, Converter={StaticResource BoolToVisibilityConverter}}"/>
<telerik:RadMenuItem Header="Select All" Command="{Binding SelectAllCommandDescriptor.Command}"
Visibility="{Binding SelectAllCommandDescriptor.IsEnabled, Converter={StaticResource BoolToVisibilityConverter}}"/>
<telerik:RadMenuItem IsSeparator="True"
Visibility="{Binding TextSelectionCommandDescriptorsGroup.IsEnabled, Converter={StaticResource BoolToVisibilityConverter}}"/>
<telerik:RadMenuItem IsCheckable="True" IsChecked="{Binding FixedDocumentViewer.Mode, Mode=TwoWay, Converter={StaticResource ModeConverter}, ConverterParameter=Pan}" Header="Pan" />
<telerik:RadMenuItem IsCheckable="True" IsChecked="{Binding FixedDocumentViewer.Mode, Mode=TwoWay, Converter={StaticResource ModeConverter}, ConverterParameter=TextSelection}" Header="Text Selection" />
<telerik:RadMenuItem IsSeparator="True"
Visibility="{Binding ViewCommandDescriptorsGroup.IsEnabled, Converter={StaticResource BoolToVisibilityConverter}}"/>
<telerik:RadMenuItem Header="Zoom In" Command="{Binding ZoomInCommandDescriptor.Command}"
Visibility="{Binding ZoomInCommandDescriptor.IsEnabled, Converter={StaticResource BoolToVisibilityConverter}}"/>
<telerik:RadMenuItem Header="Zoom Out" Command="{Binding ZoomOutCommandDescriptor.Command}"
Visibility="{Binding ZoomOutCommandDescriptor.IsEnabled, Converter={StaticResource BoolToVisibilityConverter}}"/>
<telerik:RadMenuItem IsSeparator="True" />
<telerik:RadMenuItem Header="Print..." Command="{Binding PrintCommandDescriptor.Command}"
Visibility="{Binding PrintCommandDescriptor.IsEnabled, Converter={StaticResource BoolToVisibilityConverter}}"/>
<telerik:RadMenuItem Header="Find" Command="{Binding ShowFindDialogCommandDescriptor.Command}"
Visibility="{Binding ShowFindDialogCommandDescriptor.IsEnabled, Converter={StaticResource BoolToVisibilityConverter}}"/>
</telerik:RadContextMenu>
</telerik:RadContextMenu.ContextMenu>
</telerik:RadPdfViewer>
</Grid>
</Grid>
</Window>

Просмотреть файл

@ -0,0 +1,84 @@
using Microsoft.Win32;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Telerik.Windows.Controls.FixedDocumentViewersUI.Dialogs;
using Telerik.Windows.Documents.Fixed.FormatProviders.Pdf;
using Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import;
using Telerik.Windows.Documents.Fixed.Model;
using Telerik.Windows.Documents.Fixed.UI.Extensibility;
namespace AddDocumentContent
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
ExtensibilityManager.RegisterFindDialog(new FindDialog());
ExtensibilityManager.RegisterSignaturePropertiesDialog(new SignaturePropertiesDialog());
ExtensibilityManager.RegisterSignSignatureDialog(new SignSignatureDialog());
CustomUILayersBuilder uILayersBuilder = new CustomUILayersBuilder();
ExtensibilityManager.RegisterLayersBuilder(uILayersBuilder);
this.InitializeComponent();
this.OpenFile(File.OpenRead("../../SampleData/Sample.pdf"));
}
private void tbCurrentPage_KeyDown(object sender, KeyEventArgs e)
{
TextBox textBox = sender as TextBox;
if (textBox != null)
{
if (e.Key == Key.Enter)
{
textBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
}
}
}
private void OpenRadButton_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "PDF documents|*.pdf";
if (openFileDialog.ShowDialog() == true)
{
OpenFile(openFileDialog.OpenFile());
}
}
private void OpenFile(Stream stream)
{
using (stream)
{
PdfFormatProvider pdfFormatProvider = new PdfFormatProvider();
pdfFormatProvider.ImportSettings = PdfImportSettings.ReadOnDemand;
RadFixedDocument document = pdfFormatProvider.Import(stream);
this.pdfViewer.Document = document;
}
}
private void SaveRadButton_Click(object sender, RoutedEventArgs e)
{
PdfFormatProvider provider = new PdfFormatProvider();
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "PDF documents|*.pdf";
if (saveFileDialog.ShowDialog() == true)
{
using (Stream stream = saveFileDialog.OpenFile())
{
provider.Export(this.pdfViewer.Document, stream);
}
}
}
}
}

Просмотреть файл

@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("AddDocumentContent")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AddDocumentContent")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

63
PdfViewer/AddDocumentContent/Properties/Resources.Designer.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace AddDocumentContent.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AddDocumentContent.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

Просмотреть файл

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

26
PdfViewer/AddDocumentContent/Properties/Settings.Designer.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace AddDocumentContent.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

Просмотреть файл

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

Просмотреть файл

@ -0,0 +1,7 @@
## Add Document Content ##
The example shows how you can setup RadPdfViewer in a way that allows you to add text content to a document. Once a document is loaded, clicking on the page opens a text box allowing you to insert the desired text. After modifying the content, it can be later saved through the Save As button in the tool bar. The logic uses PdfProcessing and its integration with PdfViewer to achieve the goal.
To enable the UI, a custom UI layer is implemented (AddTextUILayer.cs).
<keywords: pdf,page,processign,edit>

Двоичные данные
PdfViewer/AddDocumentContent/SampleData/Sample.pdf Normal file

Двоичный файл не отображается.

Двоичные данные
PdfViewer/AddDocumentContent/edit.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 341 B

Просмотреть файл

@ -27,6 +27,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomDecoder_WPF", "Custom
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PdfViewerToolbarWithGlyphs_WPF", "PdfViewerToolbarWithGlyphs\PdfViewerToolbarWithGlyphs_WPF.csproj", "{A994D1BC-9634-408A-BB3F-9AFA3753461E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddDocumentContent_WPF", "AddDocumentContent\AddDocumentContent_WPF.csproj", "{77F53CE3-6B74-412A-BE7D-241A0F2E4F49}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

Просмотреть файл

@ -73,22 +73,28 @@
<Reference Include="System.Net" />
<Reference Include="System.Xml" />
<Reference Include="System.Windows.Browser" />
<Reference Include="Telerik.Windows.Controls">
<Reference Include="Telerik.Windows.Controls, Version=2020.1.330.40, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(TELERIKSLDIR)\Binaries.NoXaml\Silverlight\Telerik.Windows.Controls.dll</HintPath>
</Reference>
<Reference Include="Telerik.Windows.Controls.Input">
<Reference Include="Telerik.Windows.Controls.Input, Version=2020.1.330.40, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(TELERIKSLDIR)\Binaries.NoXaml\Silverlight\Telerik.Windows.Controls.Input.dll</HintPath>
</Reference>
<Reference Include="Telerik.Windows.Controls.Navigation">
<Reference Include="Telerik.Windows.Controls.Navigation, Version=2020.1.330.40, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(TELERIKSLDIR)\Binaries.NoXaml\Silverlight\Telerik.Windows.Controls.Navigation.dll</HintPath>
</Reference>
<Reference Include="Telerik.Windows.Controls.ScheduleView">
<Reference Include="Telerik.Windows.Controls.ScheduleView, Version=2020.1.330.40, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(TELERIKSLDIR)\Binaries.NoXaml\Silverlight\Telerik.Windows.Controls.ScheduleView.dll</HintPath>
</Reference>
<Reference Include="Telerik.Windows.Data">
<Reference Include="Telerik.Windows.Data, Version=2020.1.330.40, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(TELERIKSLDIR)\Binaries.NoXaml\Silverlight\Telerik.Windows.Data.dll</HintPath>
</Reference>
<Reference Include="Telerik.Windows.Themes.Office_Black">
<Reference Include="Telerik.Windows.Themes.Office_Black, Version=2020.1.330.40, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(TELERIKSLDIR)\Binaries.NoXaml\Silverlight\Telerik.Windows.Themes.Office_Black.dll</HintPath>
</Reference>
</ItemGroup>

Просмотреть файл

@ -48,28 +48,27 @@
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="Telerik.Windows.Controls, Version=2015.1.415.1050, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<Reference Include="Telerik.Windows.Controls, Version=2020.1.115.45, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(TELERIKWPFDIR)\Binaries.NoXaml\WPF40\Telerik.Windows.Controls.dll</HintPath>
</Reference>
<Reference Include="Telerik.Windows.Controls.Input, Version=2015.1.415.1050, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<Reference Include="Telerik.Windows.Controls.Input, Version=2020.1.115.45, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(TELERIKWPFDIR)\Binaries.NoXaml\WPF40\Telerik.Windows.Controls.Input.dll</HintPath>
</Reference>
<Reference Include="Telerik.Windows.Controls.Navigation, Version=2015.1.415.1050, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<Reference Include="Telerik.Windows.Controls.Navigation, Version=2020.1.115.45, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(TELERIKWPFDIR)\Binaries.NoXaml\WPF40\Telerik.Windows.Controls.Navigation.dll</HintPath>
</Reference>
<Reference Include="Telerik.Windows.Controls.ScheduleView, Version=2015.1.415.1050, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<Reference Include="Telerik.Windows.Controls.ScheduleView, Version=2020.1.115.45, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(TELERIKWPFDIR)\Binaries.NoXaml\WPF40\Telerik.Windows.Controls.ScheduleView.dll</HintPath>
</Reference>
<Reference Include="Telerik.Windows.Data, Version=2015.1.415.1050, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<Reference Include="Telerik.Windows.Data, Version=2020.1.115.45, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(TELERIKWPFDIR)\Binaries.NoXaml\WPF40\Telerik.Windows.Data.dll</HintPath>
</Reference>
<Reference Include="Telerik.Windows.Themes.Office_Black, Version=2015.1.415.1050, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<Reference Include="Telerik.Windows.Themes.Office_Black">
<HintPath>$(TELERIKWPFDIR)\Binaries.NoXaml\WPF40\Telerik.Windows.Themes.Office_Black.dll</HintPath>
</Reference>
<Reference Include="WindowsBase" />
@ -81,6 +80,7 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="InvertedAgendaViewDefinitionToVisibilityConverter.cs" />
<Compile Include="ViewDefinitionToVisibilityConverter.cs" />
<Page Include="Example.xaml">
<SubType>Designer</SubType>

Просмотреть файл

@ -17,7 +17,8 @@
<ResourceDictionary Source="/Telerik.Windows.Themes.Office_Black;component/Themes/Telerik.Windows.Controls.Input.xaml"/>
<ResourceDictionary Source="/Telerik.Windows.Themes.Office_Black;component/Themes/Telerik.Windows.Controls.ScheduleView.xaml"/>
</ResourceDictionary.MergedDictionaries>
<local:ViewDefinitionToVisibilityConverter x:Key="ViewDefinitionToVisibilityConverter"/>
<local:AgendaViewDefinitionToVisibilityConverter x:Key="AgendaViewDefinitionToVisibilityConverter"/>
<local:InvertedAgendaViewDefinitionToVisibilityConverter x:Key="InvertedAgendaViewDefinitionToVisibilityConverter"/>
<DataTemplate x:Key="ListBoxItemTemplate">
<Grid>
<Grid.ColumnDefinitions>
@ -167,7 +168,9 @@
Orientation="{TemplateBinding EffectiveOrientation}"
Offset="{Binding HorizontalOffset, RelativeSource={RelativeSource TemplatedParent}}"
ClipToBounds="True"/>
<telerikScheduleView:AppointmentsPanel x:Name="PART_ItemsHost" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Background="{x:Null}" Orientation="{TemplateBinding EffectiveOrientation}" Panel.ZIndex="1"/>
<telerikScheduleView:AppointmentsPanel x:Name="PART_ItemsHost" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Background="{x:Null}"
Orientation="{TemplateBinding EffectiveOrientation}" Panel.ZIndex="1"
Visibility="{Binding ActiveViewDefinition, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource InvertedAgendaViewDefinitionToVisibilityConverter}}"/>
<telerikPrimitives:LayoutTransformControl
Grid.Row="1"
Grid.Column="1"
@ -260,7 +263,7 @@
<Grid x:Name="AppointmentSourceWarning" Background="White" Visibility="{Binding AppointmentsSource, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource InvertedNullToVisibilityConverter}}">
<TextBlock telerik:LocalizationManager.ResourceKey="AppointmentSourceWarning" FontSize="32" Foreground="Black" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
<Grid x:Name="ListBoxAppointments" Visibility="{Binding ActiveViewDefinition, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ViewDefinitionToVisibilityConverter}}">
<Grid x:Name="ListBoxAppointments" Visibility="{Binding ActiveViewDefinition, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource AgendaViewDefinitionToVisibilityConverter}}">
<telerik:RadListBox x:Name="radListBox1"
ItemsSource="{Binding ListBoxAppointments}"
SelectedItem="{Binding SelectedAppointment, Mode=TwoWay}"

Просмотреть файл

@ -16,7 +16,7 @@
<ResourceDictionary Source="/Telerik.Windows.Themes.Office_Black;component/Themes/Telerik.Windows.Controls.Input.xaml"/>
<ResourceDictionary Source="/Telerik.Windows.Themes.Office_Black;component/Themes/Telerik.Windows.Controls.ScheduleView.xaml"/>
</ResourceDictionary.MergedDictionaries>
<local:ViewDefinitionToVisibilityConverter x:Key="ViewDefinitionToVisibilityConverter"/>
<local:AgendaViewDefinitionToVisibilityConverter x:Key="AgendaViewDefinitionToVisibilityConverter"/>
<DataTemplate x:Key="ListBoxItemTemplate">
<Grid>
<Grid.ColumnDefinitions>
@ -251,7 +251,7 @@
<Grid x:Name="AppointmentSourceWarning" Background="White" Visibility="{Binding AppointmentsSource, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource InvertedNullToVisibilityConverter}}">
<TextBlock telerik:LocalizationManager.ResourceKey="AppointmentSourceWarning" FontSize="32" Foreground="Black" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
<Grid x:Name="ListBoxAppointments" Visibility="{Binding ActiveViewDefinition, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ViewDefinitionToVisibilityConverter}}">
<Grid x:Name="ListBoxAppointments" Visibility="{Binding ActiveViewDefinition, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource AgendaViewDefinitionToVisibilityConverter}}">
<telerik:RadListBox x:Name="radListBox1"
ItemsSource="{Binding ListBoxAppointments}"
SelectedItem="{Binding SelectedAppointment, Mode=TwoWay}"

Просмотреть файл

@ -2,9 +2,6 @@
namespace AgendaViewDefinition
{
/// <summary>
/// Interaction logic for Example.xaml
/// </summary>
public partial class Example : UserControl
{
public Example()

Просмотреть файл

@ -0,0 +1,24 @@
using System;
using System.Windows;
using System.Windows.Data;
namespace AgendaViewDefinition
{
class InvertedAgendaViewDefinitionToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value.ToString().Equals("Agenda"))
{
return Visibility.Hidden;
}
return Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

Просмотреть файл

@ -1,4 +1,7 @@
##Agenda ViewDefinition##
## Agenda ViewDefinition ##
With the __R1 2020__ release a __built-in AgendaViewDefinition__ was introduced in RadScheduleView for WPF. Read more about this in the [Agenda View](https://docs.telerik.com/devtools/wpf/controls/radscheduleview/features/viewdefinitions/agenda-view-definition) article.
This example demonstrates how to implement an Agenda ViewDefinition for RadScheduleView using RadListBox.
<keywords: dayviewdefinition, custom, listbox, appointments>

Просмотреть файл

@ -4,7 +4,7 @@ using System.Windows.Data;
namespace AgendaViewDefinition
{
public class ViewDefinitionToVisibilityConverter : IValueConverter
public class AgendaViewDefinitionToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{