Skip to content

Commit d4e87b6

Browse files
committed
Added: [template] unify global option-sets (thanks https://github.com/ClemensWon).
Updated: libraries to more recent versions. Fixed: Use Display Names option not saved correctly. Fixed: [template] ActivityParty naming issue (thanks https://github.com/ClemensWon). Fixed: [template] multiselect option-sets mapping to global option-sets (thanks https://github.com/ClemensWon). Fixed: [template] consider the 'use display names' setting for global option-sets.
1 parent 6f5be3a commit d4e87b6

32 files changed

Lines changed: 404 additions & 116 deletions

README.md

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
[![Join the chat at https://gitter.im/yagasoft/DynamicsCrm-TemplateBasedCodeGeneratorPlugin](https://badges.gitter.im/yagasoft/DynamicsCrm-TemplateBasedCodeGeneratorPlugin.svg)](https://gitter.im/yagasoft/DynamicsCrm-TemplateBasedCodeGeneratorPlugin?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
44

5-
### Version: 2.3.1.1
65
---
76

87
An XrmToolBox plugin that can be used to generate Early-bound code from a CRM Schema using a customisable T4 Template.
@@ -49,33 +48,27 @@ The engine for this Plugin and the VS Extension is the same. The settings and T4
4948
You can read a quick overview of the tool and its functionality [here](http://blog.yagasoft.com/2020/09/dynamics-template-based-code-generator-supercharged).
5049

5150
## Changes
52-
53-
#### _v2.3.1.1 (2021-04-30)_
54-
+ Improved: filtering feature now works over logical and display names, and renames
55-
+ Updated: latest custom libraries
56-
+ Fixed: template issues
57-
#### _v2.2.2.1 (2020-10-04)_
58-
+ Fixed: mishandling errors
59-
#### _v2.2.1.1 (2020-10-01)_
60-
+ Added: Filter Details window row filtering
61-
+ Fixed: generated code 'labels' syntax error
62-
#### _v2.1.0.1 (2020-09-28)_
51+
+ Check Releases page for the later changes
52+
#### _v1.0.0.3 to v2.3.1.1 (since 2020-08-25)_
53+
+ Added: all missing features from VS extension (click on 'Quick Guide' for more info), except Contracts
54+
+ Added: keep track of paths (settings, template, and code) used in previous sessions and the links between them
6355
+ Added: recent settings list (load history)
6456
+ Added: reset option for the template text
6557
+ Added: toast notification for clearer status
58+
+ Added: Filter Details window row filtering
6659
+ Improved: load and save logic
60+
+ Improved: filtering feature now works over logical and display names, and renames
61+
+ Changed: updated package name
62+
+ Updated: latest custom libraries
63+
+ Fixed: assembly issues
64+
+ Fixed: layout issues
6765
+ Fixed: fixed cancel button
6866
+ Fixed: issues
69-
#### _v2.0.0.1 (2020-09-26)_
70-
+ Added: all missing features from VS extension (click on 'Quick Guide' for more info), except Contracts
71-
+ Added: keep track of paths (settings, template, and code) used in previous sessions and the links between them
72-
+ Fixed: layout issues
73-
#### _v1.0.0.5 (2020-08-28)_
74-
+ Fixed: assembly issues
75-
#### _v1.0.0.3 (2020-08-25)_
76-
+ Changed: updated package name
67+
+ Fixed: generated code 'labels' syntax error
68+
+ Fixed: mishandling errors
69+
+ Fixed: template issues
7770
#### _v1.0.0.1 (2020-08-24)_
7871
+ Initial release
7972

8073
---
81-
**Copyright © by Ahmed Elsawalhy ([Yagasoft](http://yagasoft.com))** -- _GPL v3 Licence_
74+
**Copyright © by Ahmed Elsawalhy ([Yagasoft](https://yagasoft.com))** -- _GPL v3 Licence_

TemplateCodeGeneratorPlugin/Control/XrmMockGeneratorPluginControl.cs renamed to TemplateCodeGeneratorPlugin/Control/TemplateCodeGeneratorPluginControl.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,12 @@ public PluginControl()
131131
workerHelper = new WorkerHelper(
132132
(s, work, callback) => InvokeSafe(() => RunAsync(s, work, callback)),
133133
(s, work, callback) => InvokeSafe(() => RunAsync(s, work, callback)));
134-
connectionManager = new ConnectionManager(() => Service);
134+
connectionManager = new ConnectionManager(
135+
() =>
136+
{
137+
Service.Require(nameof(Service), "A CRM connection is required to proceed.");
138+
return Service;
139+
});
135140
fileHelper = new FileHelper(pluginSettings,
136141
(filetype, savedFileGroup) =>
137142
{
@@ -1117,7 +1122,7 @@ void MapperOnStatusUpdate(object o, MapperEventArgs args)
11171122
context.Namespace = settings.Namespace;
11181123
context.SplitFiles = settings.SplitFiles;
11191124
context.SplitContractFiles = settings.SplitContractFiles;
1120-
context.UseDisplayNames = settings.UseDisplayNames;
1125+
context.UseDisplayNames = settings.UseDisplayNames == true;
11211126
context.IsUseCustomDictionary = settings.IsUseCustomDictionary;
11221127
context.IsUseCustomEntityReference = settings.IsUseCustomEntityReference;
11231128
context.IsAddEntityAnnotations = settings.IsAddEntityAnnotations;

TemplateCodeGeneratorPlugin/Control/XrmMockGeneratorPluginControl.resx renamed to TemplateCodeGeneratorPlugin/Control/TemplateCodeGeneratorPluginControl.resx

File renamed without changes.

TemplateCodeGeneratorPlugin/Dialogues/EntitySelection.xaml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
77
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
88
xmlns:t="clr-namespace:CrmCodeGenerator.VSPackage.Dialogs"
9+
xmlns:helpers="clr-namespace:CrmCodeGenerator.VSPackage.Helpers"
910
mc:Ignorable="d"
1011
ScrollViewer.VerticalScrollBarVisibility="Disabled">
1112

@@ -35,6 +36,19 @@
3536
<Setter Property="BorderBrush" Value="Transparent" />
3637
<Setter Property="Background" Value="Transparent" />
3738
</Trigger>
39+
<Trigger Property="helpers:DataGridBehavior.IsCellHighlighted" Value="True">
40+
<Setter Property="Background" Value="{x:Static helpers:DataGridBehavior.HighlightColour}"/>
41+
</Trigger>
42+
<Trigger Property="IsMouseOver" Value="True">
43+
<Setter Property="helpers:DataGridBehavior.HighlightColumn" Value="True"/>
44+
</Trigger>
45+
</Style.Triggers>
46+
</Style>
47+
<Style TargetType="{x:Type DataGridColumnHeader}">
48+
<Style.Triggers>
49+
<Trigger Property="helpers:DataGridBehavior.IsCellHighlighted" Value="True">
50+
<Setter Property="Background" Value="{x:Static helpers:DataGridBehavior.HighlightColour}"/>
51+
</Trigger>
3852
</Style.Triggers>
3953
</Style>
4054
<Style TargetType="{x:Type DataGridRow}">
@@ -113,11 +127,9 @@
113127
IsReadOnly="True" Width="*" />
114128
<DataGridTextColumn Binding="{Binding Path=DisplayName}" Header="Display Name"
115129
IsReadOnly="True" Width="*" />
116-
<DataGridTextColumn
117-
Binding="{Binding Path=Rename, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
118-
Header="New Name" Width="*" />
119-
<DataGridTextColumn
120-
Binding="{Binding Path=Annotations, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
130+
<DataGridTextColumn Binding="{Binding Path=Rename, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
131+
Header="New Name" Width="*"/>
132+
<DataGridTextColumn Binding="{Binding Path=Annotations, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
121133
Header="Annotations" Width="0.75*" />
122134
<DataGridTemplateColumn>
123135
<DataGridTemplateColumn.Header>

TemplateCodeGeneratorPlugin/Dialogues/EntitySelection.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ private void InitEntityList(List<string> filter = null)
239239
Rename = profile?.EntityRename,
240240
Annotations = profile?.EntityAnnotations,
241241
DisplayName =
242-
entityAsync.DisplayName?.UserLocalizedLabel == null || !Settings.UseDisplayNames
242+
entityAsync.DisplayName?.UserLocalizedLabel == null || Settings.UseDisplayNames != true
243243
? Naming.GetProperHybridName(entityAsync.SchemaName, entityAsync.LogicalName)
244244
: Naming.Clean(entityAsync.DisplayName.UserLocalizedLabel.Label),
245245
IsGenerateMeta = Settings.PluginMetadataEntitiesSelected.Contains(entityAsync.LogicalName),

TemplateCodeGeneratorPlugin/Dialogues/FilterDetails.xaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
55
xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid"
66
xmlns:t="clr-namespace:CrmCodeGenerator.VSPackage.Dialogs"
7+
xmlns:helpers="clr-namespace:CrmCodeGenerator.VSPackage.Helpers"
78
Loaded="Window_Loaded" ScrollViewer.VerticalScrollBarVisibility="Disabled">
89

910
<UserControl.Resources>
@@ -36,6 +37,19 @@
3637
<Setter Property="Background" Value="Transparent" />
3738
<Setter Property="Foreground" Value="Black" />
3839
</Trigger>
40+
<Trigger Property="helpers:DataGridBehavior.IsCellHighlighted" Value="True">
41+
<Setter Property="Background" Value="{x:Static helpers:DataGridBehavior.HighlightColour}"/>
42+
</Trigger>
43+
<Trigger Property="IsMouseOver" Value="True">
44+
<Setter Property="helpers:DataGridBehavior.HighlightColumn" Value="True"/>
45+
</Trigger>
46+
</Style.Triggers>
47+
</Style>
48+
<Style TargetType="{x:Type DataGridColumnHeader}">
49+
<Style.Triggers>
50+
<Trigger Property="helpers:DataGridBehavior.IsCellHighlighted" Value="True">
51+
<Setter Property="Background" Value="{x:Static helpers:DataGridBehavior.HighlightColour}"/>
52+
</Trigger>
3953
</Style.Triggers>
4054
</Style>
4155
<Style TargetType="{x:Type DataGridRow}">

TemplateCodeGeneratorPlugin/Dialogues/FilterDetails.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ private void GenerateLists(string controlName = null)
374374
{
375375
IsSelected = EntityProfile.Attributes?.Contains(attributeAsync.LogicalName) == true,
376376
Name = attributeAsync.LogicalName,
377-
DisplayName = attributeAsync.DisplayName?.UserLocalizedLabel == null || !Settings.UseDisplayNames
377+
DisplayName = attributeAsync.DisplayName?.UserLocalizedLabel == null || Settings.UseDisplayNames != true
378378
? Naming.GetProperVariableName(attributeAsync, Settings.TitleCaseLogicalNames)
379379
: Naming.Clean(attributeAsync.DisplayName.UserLocalizedLabel.Label),
380380
Rename = EntityProfile.AttributeRenames?.FirstNotNullOrEmpty(attributeAsync.LogicalName),
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#region Imports
2+
3+
using System;
4+
using System.Windows;
5+
using System.Windows.Controls;
6+
using System.Windows.Controls.Primitives;
7+
using System.Windows.Media;
8+
9+
#endregion
10+
11+
namespace CrmCodeGenerator.VSPackage.Helpers
12+
{
13+
/// <summary>
14+
/// Credit: https://stackoverflow.com/a/3702183/1919456 (ASanch)
15+
/// </summary>
16+
public class DataGridBehavior : DependencyObject
17+
{
18+
public static readonly Brush HighlightColour = new SolidColorBrush(Color.FromRgb(235, 249, 255));
19+
20+
public static bool GetHighlightColumn(DependencyObject obj)
21+
{
22+
return (bool)obj.GetValue(HighlightColumnProperty);
23+
}
24+
25+
public static void SetHighlightColumn(DependencyObject obj, bool value)
26+
{
27+
obj.SetValue(HighlightColumnProperty, value);
28+
}
29+
30+
// Using a DependencyProperty as the backing store for HighlightColumn. This enables animation, styling, binding, etc...
31+
public static readonly DependencyProperty HighlightColumnProperty =
32+
DependencyProperty.RegisterAttached("HighlightColumn", typeof(bool),
33+
typeof(DataGridBehavior), new FrameworkPropertyMetadata(false, OnHighlightColumnPropertyChanged));
34+
35+
public static bool GetIsCellHighlighted(DependencyObject obj)
36+
{
37+
return (bool)obj.GetValue(IsCellHighlightedProperty);
38+
}
39+
40+
public static void SetIsCellHighlighted(DependencyObject obj, bool value)
41+
{
42+
obj.SetValue(IsCellHighlightedProperty, value);
43+
}
44+
45+
// Using a DependencyProperty as the backing store for IsCellHighlighted. This enables animation, styling, binding, etc...
46+
public static readonly DependencyProperty IsCellHighlightedProperty =
47+
DependencyProperty.RegisterAttached("IsCellHighlighted", typeof(bool), typeof(DataGridBehavior),
48+
new UIPropertyMetadata(false));
49+
50+
private static void OnHighlightColumnPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
51+
{
52+
if (sender is not DataGridCell cell)
53+
{
54+
return;
55+
}
56+
57+
cell.SetValue(IsCellHighlightedProperty, e.NewValue);
58+
cell.GetParent<DataGrid>().GetChild<DataGridColumnHeader>(cell.Column.DisplayIndex).SetValue(IsCellHighlightedProperty, e.NewValue);
59+
cell.GetParent<DataGridRow>().GetChild<DataGridCell>(1).SetValue(IsCellHighlightedProperty, e.NewValue);
60+
}
61+
}
62+
}

TemplateCodeGeneratorPlugin/Helpers/WpfHelpers.cs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
using System.Linq;
44
using System.Windows;
55
using System.Windows.Controls;
6+
using System.Windows.Controls.Primitives;
67
using System.Windows.Input;
78
using System.Windows.Media;
8-
99
using Yagasoft.Libraries.Common;
1010

1111
namespace CrmCodeGenerator.VSPackage.Helpers
@@ -112,18 +112,30 @@ public static bool IsCheckboxClickedChildrenCheck(this DependencyObject dep, str
112112
return false;
113113
}
114114

115-
public static T GetChild<T>(this DependencyObject depObj) where T : DependencyObject
115+
public static T GetChild<T>(this DependencyObject depObj, int? index = null) where T : DependencyObject
116116
{
117117
if (depObj == null)
118118
{
119119
return null;
120120
}
121121

122-
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
122+
var count = VisualTreeHelper.GetChildrenCount(depObj);
123+
124+
for (var i = 0; i < count; i++)
123125
{
124126
var child = VisualTreeHelper.GetChild(depObj, i);
125127

126-
var result = (child as T) ?? GetChild<T>(child);
128+
if (child is T childT)
129+
{
130+
if (!index.HasValue || index == i)
131+
{
132+
return childT;
133+
}
134+
135+
continue;
136+
}
137+
138+
var result = GetChild<T>(child, index);
127139

128140
if (result != null)
129141
{
@@ -146,7 +158,7 @@ public static IEnumerable<TControl> GetChildren<TControl>(this DependencyObject
146158
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
147159
{
148160
var child = VisualTreeHelper.GetChild(depObj, i);
149-
children.AddRange(child is TControl childAsTControl ? new[] { childAsTControl } : GetChildren<TControl>(child));
161+
children.AddRange(child is TControl childAsTControl ? new [] { childAsTControl } : GetChildren<TControl>(child));
150162
}
151163

152164
return children;

TemplateCodeGeneratorPlugin/Model/Constants.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,10 @@ public static class Constants
44
{
55
public const string AppName = "Dynamics Template-based Code Generator";
66
public const string AppId = "xrmtoolbox-code-gen-plugin";
7-
public const string AppVersion = "2.3.1.1";
7+
public const string AppVersion = "2.4.1.2";
88

99
public const string SettingsVersion = "2.0.0.1";
1010

11-
public const string MinTemplateVersion = "2.0.0.1";
12-
public const string LatestTemplateVersion = "2.3.1.1";
13-
14-
public const string MetaCacheMemKey = "ys_CrmGen_Meta_639156";
15-
public const string ConnCacheMemKey = "ys_CrmGen_Conn_185599";
16-
1711
public const string ReleaseNotes = AppName + "\r\n" +
1812
" v" + AppVersion + "\r\n" +
1913
"~~~~~~~~~~\r\n" +
@@ -22,6 +16,12 @@ public static class Constants
2216
- FIX: If you are using an unmodified template, please reset (button) the template to get the latest version; otherwise, backup yours, reset, and then using CodeCompare or a similar tool, check the updates.
2317
- REQUEST: Please report issues and improvement suggestions on the generator's GitHub repository. Use the 'Help' menu above to access the page.
2418
19+
* 2.4.1.2
20+
Added: [template] unify global option-sets (thanks https://github.com/ClemensWon)
21+
Fixed: Use Display Names option not saved correctly
22+
Fixed: [template] ActivityParty naming issue (thanks https://github.com/ClemensWon)
23+
Fixed: [template] multiselect option-sets mapping to global option-sets (thanks https://github.com/ClemensWon)
24+
Fixed: [template] consider the 'use display names' setting for global option-sets
2525
* 2.3.1.1
2626
Improved: filtering feature now works over logical and display names, and renames
2727
Updated: latest custom libraries

0 commit comments

Comments
 (0)