Skip to content

Commit

Permalink
removed workarounds
Browse files Browse the repository at this point in the history
.net core 3 build 9748 has fixed the type converter and inheritance issues
  • Loading branch information
brianlagunas committed Nov 14, 2018
1 parent 5976a1e commit 8cf7727
Show file tree
Hide file tree
Showing 17 changed files with 133 additions and 417 deletions.
57 changes: 57 additions & 0 deletions IgOutlook.Core/Controls/XamRichTextEditorBehavior.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using Infragistics.Controls.Editors;
using Infragistics.Documents.RichText;
using Infragistics.Documents.RichText.Rtf;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows;

namespace IgOutlook.Core.Controls
{
public class XamRichTextEditorBehavior : DependencyObject
{
#region InsertRtfContent

public static readonly DependencyProperty InsertRtfContentProperty = DependencyProperty.RegisterAttached("InsertRtfContent", typeof(string), typeof(XamRichTextEditorBehavior), new PropertyMetadata(null, OnInsertRtfContentChanged));

public static void SetInsertRtfContent(XamRichTextEditor editor, object value)
{
editor.SetValue(InsertRtfContentProperty, value);
}

public static string GetInsertRtfContent(XamRichTextEditor editor)
{
return editor.GetValue(InsertRtfContentProperty) as string;
}

private static void OnInsertRtfContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
XamRichTextEditor editor = (XamRichTextEditor)d;
editor.DocumentContentChanged -= Document_ContentChanged;
editor.DocumentContentChanged += Document_ContentChanged;
}

static void Document_ContentChanged(object sender, DocumentContentChangedEventArgs e)
{
if (e.ChangeType == Infragistics.Documents.RichText.DocumentChangeType.Content)
{
var xamRichTextEditor = sender as XamRichTextEditor;

xamRichTextEditor.DocumentContentChanged -= Document_ContentChanged;

var rtfString = (string)xamRichTextEditor.GetValue(XamRichTextEditorBehavior.InsertRtfContentProperty);

RichTextDocument doc = new RichTextDocument();
var stream = new MemoryStream(Encoding.UTF8.GetBytes(rtfString));
doc.LoadFromRtf(stream);

string error;

xamRichTextEditor.Document.InsertContent(0, doc.RootNode, out error, true, true);
}
}

#endregion //InsertRtfContent
}
}
1 change: 1 addition & 0 deletions IgOutlook.Core/IgOutlook.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<PackageReference Include="Infragistics.WPF.DataTree" Version="18.2.137" />
<PackageReference Include="Infragistics.WPF.Ribbon" Version="18.2.137" />
<PackageReference Include="Infragistics.WPF.RichTextEditor" Version="18.2.137" />
<PackageReference Include="Infragistics.WPF.RichTextDocument.Rtf" Version="18.2.137" />
<PackageReference Include="Infragistics.WPF.Schedules" Version="18.2.137" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Infragistics.Controls.Editors;
using Infragistics.Controls.Schedules;
using System;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Windows.Data;

namespace IgOutlook.Modules.Calendar.Converters
{
public class XamDateNavigatorSelectedDatesConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var dateNav = parameter as XamDateNavigator;
if (dateNav != null)
return new ObservableCollection<DateTime>(dateNav.SelectedDates);

else
{
var args = (SelectedDatesChangedEventArgs)value;
return new ObservableCollection<DateTime>(args.AddedDates);
}
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
18 changes: 11 additions & 7 deletions IgOutlook.Modules.Calendar/OutlookGroups/CalendarGroup.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,24 @@
<igOutlookBar:OutlookBarGroup.Resources>
<coreConverters:XamDataTreeActiveNodeChangedConverter x:Key="ActiveNodeChangedConverter" />
<conveters:XamDataTreeSelectedNodesCollectionChangedConverter x:Key="SelectedNodesCollectionChangedConverter" />
<conveters:XamDateNavigatorSelectedDatesConverter x:Key="SelectedDatesConverter" />
</igOutlookBar:OutlookBarGroup.Resources>

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="200"/>
<RowDefinition Height="*" MinHeight="100"/>
</Grid.RowDefinitions>
<Grid x:Name="_dateNavigatorPlaceholder">
<!-- TODO: Fix when Core 3 can compile XAML properly -->
<!--<ig:XamDateNavigator Grid.Row="0" Margin="5" HighlightDayCriteria="DaysWithActivity" Background="Transparent" DataManager="{Binding DataManager}"
convertToEventToCommand:XamDateNavigatorSelectedDates.Command="{Binding DateNavigatorSelectedDatesCommand}"
coreControls:XamDateNavigatorProperties.SelectedDates="{Binding SelectedDates}"/>-->
</Grid>


<ig:XamDateNavigator x:Name="_dateNavigator" Grid.Row="0" Margin="5" HighlightDayCriteria="DaysWithActivity" Background="Transparent" DataManager="{Binding DataManager}"
coreControls:XamDateNavigatorProperties.SelectedDates="{Binding SelectedDates}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectedDatesChanged">
<coreBehaviors:EventToCommand Command="{Binding DateNavigatorSelectedDatesCommand}" EventArgsConverter="{StaticResource SelectedDatesConverter}" EventArgsConverterParameter="{Binding ElementName=_dateNavigator}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</ig:XamDateNavigator>

<GridSplitter Grid.Row="0" ResizeDirection="Rows" Height="5" HorizontalAlignment="Stretch" VerticalAlignment="Bottom">
<GridSplitter.Template>
<ControlTemplate>
Expand Down
31 changes: 0 additions & 31 deletions IgOutlook.Modules.Calendar/OutlookGroups/CalendarGroup.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,6 @@ public string DefaultNavigationPath
public CalendarGroup()
{
InitializeComponent();

//workaround for XAML build error in Core 3
XamDateNavigator dateNav = new XamDateNavigator();
dateNav.Margin = new Thickness(5);
dateNav.HighlightDayCriteria = HighlightDayCriteria.DaysWithActivity;
dateNav.Background = new SolidColorBrush(Colors.Transparent);

Binding dataManagerBinding = new Binding();
dataManagerBinding.Source = DataContext;
dataManagerBinding.Path = new PropertyPath("DataManager");
dateNav.SetBinding(XamDateNavigator.DataManagerProperty, dataManagerBinding);

Binding selectedDatesBinding = new Binding();
selectedDatesBinding.Source = DataContext;
selectedDatesBinding.Path = new PropertyPath("SelectedDates");
dateNav.SetBinding(XamDateNavigatorProperties.SelectedDatesProperty, selectedDatesBinding);

Binding commandBinding = new Binding();
commandBinding.Source = DataContext;
commandBinding.Path = new PropertyPath("DateNavigatorSelectedDatesCommand");

EventToCommand eventToCommand = new EventToCommand();
eventToCommand.EventArgsConverter = new DateNavigatorSelectedDatesConverter();
BindingOperations.SetBinding(eventToCommand, EventToCommand.CommandProperty, commandBinding);

var triggers = Interaction.GetTriggers(dateNav);
var eventTrigger = new System.Windows.Interactivity.EventTrigger() { EventName = "SelectedDatesChanged" };
eventTrigger.Actions.Add(eventToCommand);
triggers.Add(eventTrigger);

_dateNavigatorPlaceholder.Children.Add(dateNav);
}

private void ActiveNodeChanging(object sender, ActiveNodeChangingEventArgs e)
Expand Down
13 changes: 5 additions & 8 deletions IgOutlook.Modules.Calendar/Views/AppointmentView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xmlns:resources="clr-namespace:IgOutlook.Modules.Calendar.Resources"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True">

<UserControl.Resources>
<converters:ActivityUtcToLocalTimeConverter x:Key="ActivityUtcToLocalTimeConverter"/>
<converters:InverseBooleanConverter x:Key="InverseBooleanConverter"/>
Expand Down Expand Up @@ -53,8 +53,8 @@
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding Activity.Location, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Stretch" Margin="2,4" Grid.ColumnSpan="10"/>

<!--Start\End Date-->
<!--<ig:XamDateTimeInput Grid.Row="3" Grid.Column="1" Value="{Binding Activity.Start, Converter={StaticResource ActivityUtcToLocalTimeConverter}}" Margin="2,4" DropDownButtonStyle="{StaticResource DropDownButtonStyle}" DropDownButtonDisplayMode="Always"/>
<ig:XamDateTimeInput Grid.Row="4" Grid.Column="1" Value="{Binding Activity.End, Converter={StaticResource ActivityUtcToLocalTimeConverter}}" Margin="2,4" DropDownButtonStyle="{StaticResource DropDownButtonStyle}" DropDownButtonDisplayMode="Always"/>-->
<ig:XamDateTimeInput Grid.Row="3" Grid.Column="1" Value="{Binding Activity.Start, Converter={StaticResource ActivityUtcToLocalTimeConverter}}" Margin="2,4" DropDownButtonStyle="{StaticResource DropDownButtonStyle}" DropDownButtonDisplayMode="Always"/>
<ig:XamDateTimeInput Grid.Row="4" Grid.Column="1" Value="{Binding Activity.End, Converter={StaticResource ActivityUtcToLocalTimeConverter}}" Margin="2,4" DropDownButtonStyle="{StaticResource DropDownButtonStyle}" DropDownButtonDisplayMode="Always"/>

<!--Start\End TimeIntervals-->
<ComboBox Grid.Row="3" Grid.Column="2" ItemStringFormat="{}{0:HH:mm tt}" ItemsSource="{Binding StartTimeIntervals}" IsEnabled="{Binding ElementName=cbAllDayEvent, Path=IsChecked, Converter={StaticResource InverseBooleanConverter}}"
Expand All @@ -71,15 +71,12 @@
<!--All day event-->
<CheckBox Grid.Row="4" Grid.Column="4" IsChecked="{Binding Activity.IsTimeZoneNeutral}" Content="{x:Static resources:ResourceStrings.ActivityDialog_AllDayEvent_Text}" Name="cbAllDayEvent" VerticalAlignment="Center" Margin="5,0,0,0" Foreground="{StaticResource LightTextBrush}"/>

<Grid x:Name="_rtePlaceholder" Grid.Row="5" Grid.ColumnSpan="10" Grid.RowSpan="10">
<!-- TODO: Uncomment this when .NET Core 3 can build it without error -->
<!--<ig:RtfDocumentAdapter Document="{Binding Document, ElementName=_richTextEditor}" Value="{Binding Activity.Description}" Grid.Row="1" RefreshTrigger="ContentChanged"/>
<ig:RtfDocumentAdapter Document="{Binding Document, ElementName=_richTextEditor}" Value="{Binding Activity.Description}" Grid.Row="1" RefreshTrigger="ContentChanged"/>
<ig:XamRichTextEditor x:Name="_richTextEditor" AllowDocumentViewSplitting="False" Grid.Row="5" Grid.ColumnSpan="10" Grid.RowSpan="10">
<ig:XamRichTextEditor.ClipboardSerializationProviders>
<ig:RtfSerializationProvider/>
</ig:XamRichTextEditor.ClipboardSerializationProviders>
</ig:XamRichTextEditor>-->
</Grid>
</ig:XamRichTextEditor>
</Grid>

</UserControl>
65 changes: 2 additions & 63 deletions IgOutlook.Modules.Calendar/Views/AppointmentView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using IgOutlook.Core;
using IgOutlook.Modules.Calendar.Converters;
using IgOutlook.Modules.Calendar.TabItems;
using Infragistics.Controls.Editors;
using Infragistics.Documents.RichText.Rtf;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System;

namespace IgOutlook.Modules.Calendar.Views
{
Expand All @@ -15,68 +11,11 @@ namespace IgOutlook.Modules.Calendar.Views
[DependentView(typeof(AppointmentHomeTab), RegionNames.RibbonTabRegion)]
public partial class AppointmentView : ISupportDataContext, ISupportRichText
{
public XamRichTextEditor RichTextEditor { get; set; }
public XamRichTextEditor RichTextEditor { get { return _richTextEditor; } set { throw new NotImplementedException(); } }

public AppointmentView()
{
InitializeComponent();

//date/time inputs
XamDateTimeInput dti1 = new XamDateTimeInput();
dti1.Margin = new System.Windows.Thickness(2, 4, 2, 4);
dti1.DropDownButtonStyle = (Style)Resources["DropDownButtonStyle"];
dti1.DropDownButtonDisplayMode = DropDownButtonDisplayMode.Always;

Binding dtiValueBinding = new Binding();
dtiValueBinding.Source = DataContext;
dtiValueBinding.Path = new System.Windows.PropertyPath("Activity.Start");
dtiValueBinding.Converter = new ActivityUtcToLocalTimeConverter();
dti1.SetBinding(XamDateTimeInput.ValueProperty, dtiValueBinding);

Grid.SetRow(dti1, 3);
Grid.SetColumn(dti1, 1);

_grid.Children.Add(dti1);

XamDateTimeInput dti2 = new XamDateTimeInput();
dti2.Margin = new System.Windows.Thickness(2, 4, 2, 4);
dti2.DropDownButtonStyle = (Style)Resources["DropDownButtonStyle"];
dti2.DropDownButtonDisplayMode = DropDownButtonDisplayMode.Always;

Binding dtiValueBinding2 = new Binding();
dtiValueBinding2.Source = DataContext;
dtiValueBinding2.Path = new System.Windows.PropertyPath("Activity.End");
dtiValueBinding2.Converter = new ActivityUtcToLocalTimeConverter();
dti2.SetBinding(XamDateTimeInput.ValueProperty, dtiValueBinding2);

Grid.SetRow(dti2, 4);
Grid.SetColumn(dti2, 1);

_grid.Children.Add(dti2);

//RichTextEditor
RichTextEditor = new XamRichTextEditor();
RichTextEditor.Name = "_rte";
RichTextEditor.AllowDocumentViewSplitting = false;
//rte.ClipboardSerializationProviders.Add(new RtfSerializationProvider());

RtfDocumentAdapter docAdapter = new RtfDocumentAdapter();
docAdapter.RefreshTrigger = Infragistics.Documents.RichText.Serialization.RichTextRefreshTrigger.ContentChanged;

Binding docBinding = new Binding();
docBinding.Source = RichTextEditor;
docBinding.Path = new System.Windows.PropertyPath("Document");

docAdapter.SetBinding(RtfDocumentAdapter.DocumentProperty, docBinding);

Binding valueBinding = new Binding();
valueBinding.Source = DataContext;
valueBinding.Path = new System.Windows.PropertyPath("Activity.Description");

docAdapter.SetBinding(RtfDocumentAdapter.ValueProperty, valueBinding);

_rtePlaceholder.Children.Add(docAdapter);
_rtePlaceholder.Children.Add(RichTextEditor);
}
}
}
11 changes: 4 additions & 7 deletions IgOutlook.Modules.Calendar/Views/MeetingView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
<ComboBox Grid.Row="2" Grid.Column="2" SelectedValuePath="Name" SelectedValue="{Binding Activity.Location}" ItemsSource="{Binding LocationsList}" DisplayMemberPath="Name" VerticalAlignment="Stretch" Margin="2,4" Grid.ColumnSpan="10"/>

<!--Start\End Date-->
<!--<ig:XamDateTimeInput Grid.Row="3" Grid.Column="2" Value="{Binding Activity.Start, Converter={StaticResource ActivityUtcToLocalTimeConverter}}" Margin="2,4" DropDownButtonStyle="{StaticResource DropDownButtonStyle}" DropDownButtonDisplayMode="Always"/>
<ig:XamDateTimeInput Grid.Row="4" Grid.Column="2" Value="{Binding Activity.End, Converter={StaticResource ActivityUtcToLocalTimeConverter}}" Margin="2,4" DropDownButtonStyle="{StaticResource DropDownButtonStyle}" DropDownButtonDisplayMode="Always"/>-->
<ig:XamDateTimeInput Grid.Row="3" Grid.Column="2" Value="{Binding Activity.Start, Converter={StaticResource ActivityUtcToLocalTimeConverter}}" Margin="2,4" DropDownButtonStyle="{StaticResource DropDownButtonStyle}" DropDownButtonDisplayMode="Always"/>
<ig:XamDateTimeInput Grid.Row="4" Grid.Column="2" Value="{Binding Activity.End, Converter={StaticResource ActivityUtcToLocalTimeConverter}}" Margin="2,4" DropDownButtonStyle="{StaticResource DropDownButtonStyle}" DropDownButtonDisplayMode="Always"/>

<!--Start\End TimeIntervals-->
<ComboBox Grid.Row="3" Grid.Column="3" ItemStringFormat="{}{0:HH:mm tt}" ItemsSource="{Binding StartTimeIntervals}" IsEnabled="{Binding ElementName=cbAllDayEvent, Path=IsChecked, Converter={StaticResource InverseBooleanConverter}}"
Expand All @@ -94,15 +94,12 @@
<CheckBox Grid.Row="4" Grid.Column="5" IsChecked="{Binding Activity.IsTimeZoneNeutral}" Content="{x:Static resources:ResourceStrings.ActivityDialog_AllDayEvent_Text}" Name="cbAllDayEvent" VerticalAlignment="Center" Margin="5,0,0,0" Foreground="{StaticResource LightTextBrush}"/>

<!--Description-->
<Grid x:Name="_rtePlaceholder" Grid.Row="5" Grid.ColumnSpan="10" Grid.RowSpan="10" Grid.Column="0">
<!-- TODO: Uncomment this when .NET Core 3 can build it without error -->
<!--<ig:RtfDocumentAdapter Document="{Binding Document, ElementName=_richTextEditor}" Value="{Binding Activity.Description}" Grid.Row="1" RefreshTrigger="ContentChanged" Grid.Column="1"/>
<ig:RtfDocumentAdapter Document="{Binding Document, ElementName=_richTextEditor}" Value="{Binding Activity.Description}" Grid.Row="1" RefreshTrigger="ContentChanged" Grid.Column="1"/>
<ig:XamRichTextEditor x:Name="_richTextEditor" AllowDocumentViewSplitting="False" Grid.Row="5" Grid.ColumnSpan="10" Grid.RowSpan="10" Grid.Column="0">
<ig:XamRichTextEditor.ClipboardSerializationProviders>
<ig:RtfSerializationProvider/>
</ig:XamRichTextEditor.ClipboardSerializationProviders>
</ig:XamRichTextEditor>-->
</Grid>
</ig:XamRichTextEditor>

</Grid>
</UserControl>
Loading

0 comments on commit 8cf7727

Please sign in to comment.