Skip to content

Commit

Permalink
Merge branch 'private-dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
NizamLZ committed Aug 30, 2017
2 parents e4e3438 + 2ce7695 commit 7696d03
Show file tree
Hide file tree
Showing 21 changed files with 356 additions and 102 deletions.
2 changes: 1 addition & 1 deletion ANAConversationSimulator/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
<Identity Name="44cabbc3-0a2f-4255-b5bb-b099cd5762f9" Publisher="CN=ProjectANA" Version="2.1.1.0" />
<Identity Name="44cabbc3-0a2f-4255-b5bb-b099cd5762f9" Publisher="CN=ProjectANA" Version="2.2.0.0" />
<mp:PhoneIdentity PhoneProductId="44cabbc3-0a2f-4255-b5bb-b099cd5762f9" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>ANA Conversation Simulator</DisplayName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public async void Execute(object parameter)
if (Utils.IsSectionTypePresentInNode(parentNode, SectionTypeEnum.PrintOTP))
button.VariableValue = PrintOTPSection.OTP;

if (string.IsNullOrWhiteSpace(button.ButtonText))
button.ButtonText = button.ButtonName;

var userData = new Dictionary<string, string>();
switch (button.ButtonType)
{
Expand Down
10 changes: 5 additions & 5 deletions ANAConversationSimulator/Styles/Custom.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
<DataTemplate x:Key="ClickChatButtonTemplate">
<!--Content="{Binding ButtonText}"-->
<Button HorizontalAlignment="Stretch" Visibility="{Binding Visible, Converter={StaticResource C4FB2V}}" MinWidth="150" HorizontalContentAlignment="Stretch" Command="{Binding Action}" CommandParameter="{Binding}" Background="{StaticResource ButtonBackgroundBrush}">
<TextBlock Text="{Binding ButtonText}" TextWrapping="Wrap" TextAlignment="Center" />
<TextBlock Text="{Binding ButtonName}" TextWrapping="Wrap" TextAlignment="Center" />
</Button>
</DataTemplate>

Expand All @@ -218,7 +218,7 @@
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
</TextBox>
<Button Grid.Column="1" MaxWidth="120" Content="{Binding ButtonText, FallbackValue=Send}" Margin="5,0,0,0" Background="{StaticResource ButtonBackgroundBrush}">
<Button Grid.Column="1" MaxWidth="120" Content="{Binding ButtonName, FallbackValue=Send}" Margin="5,0,0,0" Background="{StaticResource ButtonBackgroundBrush}">
<Interactivity:Interaction.Behaviors>
<Behaviors:EventTriggerBehaviorBase EventName="Tapped" >
<Core:InvokeCommandAction Command="{Binding Action}" CommandParameter="{Binding}"/>
Expand Down Expand Up @@ -252,7 +252,7 @@
<TextBlock Text="{Binding PostfixText}" VerticalAlignment="Center"/>
</StackPanel>
</ScrollViewer>
<Button Grid.Column="1" MaxWidth="120" Content="{Binding ButtonText, FallbackValue=Send}" Margin="5,0,0,0" Background="{StaticResource ButtonBackgroundBrush}">
<Button Grid.Column="1" MaxWidth="120" Content="{Binding ButtonName, FallbackValue=Send}" Margin="5,0,0,0" Background="{StaticResource ButtonBackgroundBrush}">
<Interactivity:Interaction.Behaviors>
<Behaviors:EventTriggerBehaviorBase EventName="Tapped" >
<Core:InvokeCommandAction Command="{Binding Action}" CommandParameter="{Binding}"/>
Expand Down Expand Up @@ -294,7 +294,7 @@
<TextBlock Text="{Binding PostfixText}" VerticalAlignment="Center"/>
</StackPanel>
</ScrollViewer>
<Button Grid.Column="1" MaxWidth="120" Content="{Binding ButtonText, FallbackValue=Send}" Margin="5,0,0,0" Background="{StaticResource ButtonBackgroundBrush}">
<Button Grid.Column="1" MaxWidth="120" Content="{Binding ButtonName, FallbackValue=Send}" Margin="5,0,0,0" Background="{StaticResource ButtonBackgroundBrush}">
<Interactivity:Interaction.Behaviors>
<Behaviors:EventTriggerBehaviorBase EventName="Tapped" >
<Core:InvokeCommandAction Command="{Binding Action}" CommandParameter="{Binding}"/>
Expand Down Expand Up @@ -330,7 +330,7 @@
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
</AutoSuggestBox>
<Button Grid.Column="1" MaxWidth="120" Content="{Binding ButtonText, FallbackValue=Send}" Margin="5,0,0,0" Background="{StaticResource ButtonBackgroundBrush}">
<Button Grid.Column="1" MaxWidth="120" Content="{Binding ButtonName, FallbackValue=Send}" Margin="5,0,0,0" Background="{StaticResource ButtonBackgroundBrush}">
<Interactivity:Interaction.Behaviors>
<Behaviors:EventTriggerBehaviorBase EventName="Tapped" >
<Core:InvokeCommandAction Command="{Binding Action}" CommandParameter="{Binding}"/>
Expand Down
6 changes: 6 additions & 0 deletions ANAConversationSimulator/ViewModels/MainPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@ public async Task ProcessButtonsAsync(JToken node)
var allButtons = node["Buttons"].ToObject<List<Button>>();
foreach (var btnSrc in allButtons.Where(x => x.Kind == ButtonKind.ClickInput))
{
if (string.IsNullOrWhiteSpace(btnSrc.ButtonName))
btnSrc.ButtonName = btnSrc.ButtonText;

var btn = btnSrc.DeepCopy();
if (btn.DoesRepeat)
{
Expand Down Expand Up @@ -359,6 +362,9 @@ public async Task ProcessButtonsAsync(JToken node)

foreach (var btn in allButtons.Where(x => x.Kind == ButtonKind.TextInput))
{
if (string.IsNullOrWhiteSpace(btn.ButtonName))
btn.ButtonName = btn.ButtonText;

btn.VariableName = node["VariableName"] + "";
btn.NodeId = parsedNode.Id;
btn.ButtonName = VerbProcessor.Process(btn.ButtonName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3346,19 +3346,19 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:ANA Conversation Studio"
"ProductCode" = "8:{C4240BA0-EC0E-4E57-BE05-9C372AEDC6A2}"
"PackageCode" = "8:{8D94ADE5-44E6-4737-BEA8-156389EA5C60}"
"ProductCode" = "8:{044D4B65-4A17-4D7E-BD97-3F9FF5F6F7C0}"
"PackageCode" = "8:{81B3B63F-1E15-41BC-ABC6-6F3653D5B1A0}"
"UpgradeCode" = "8:{1BD9D39A-BCB0-4988-88FE-7481A5494FFF}"
"AspNetVersion" = "8:4.0.30319.0"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:FALSE"
"ProductVersion" = "8:4.4.0"
"ProductVersion" = "8:4.5.0"
"Manufacturer" = "8:Project ANA"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:http://ana.chat"
"Title" = "8:ANA Conversation Studio 4.4.0"
"Title" = "8:ANA Conversation Studio 4.5.0"
"Subject" = "8:"
"ARPCONTACT" = "8:Project ANA"
"Keywords" = "8:"
Expand Down
5 changes: 4 additions & 1 deletion ANAConversationStudio/ANAConversationStudio.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Helpers\ChatFlowBuilder.cs" />
<Compile Include="Models\ChatFlowSearchItem.cs" />
<Compile Include="Views\NodeEditWindow.xaml.cs">
<DependentUpon>NodeEditWindow.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -304,7 +305,9 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
2 changes: 1 addition & 1 deletion ANAConversationStudio/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<!-- Chat Designer Colors -->
<!-- The border brush for nodes. -->
<SolidColorBrush x:Key="nodeBorderBrush" Color="Transparent" />
<SolidColorBrush x:Key="startNodeBorderBrush" Color="{Binding Color, Source={StaticResource PrimaryHueDarkBrush}}" />
<SolidColorBrush x:Key="startNodeHeaderBrush" Color="#AD4833" />
<SolidColorBrush x:Key="nodeHeaderBorderBrush" Color="{Binding Color, Source={StaticResource PrimaryHueDarkBrush}}" />
<!-- The fill brush for nodes. -->
<SolidColorBrush x:Key="nodeFillBrush" Color="{Binding Color, Source={StaticResource PrimaryHueLightBrush}}"/>
Expand Down
54 changes: 53 additions & 1 deletion ANAConversationStudio/Helpers/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Newtonsoft.Json.Converters;
using ANAConversationStudio.ViewModels;
using System.Linq;
using System.Text.RegularExpressions;

namespace ANAConversationStudio.Helpers
{
Expand Down Expand Up @@ -111,6 +112,7 @@ public static List<BaseContent> ExtractContentFromChatNodes(List<ChatNode> chatN
{
ButtonId = btn._id,
ButtonText = btn.ButtonText,
ButtonName = btn.ButtonName,
NodeId = node.Id,
_id = btn.ContentId,
Emotion = btn.ContentEmotion,
Expand Down Expand Up @@ -242,7 +244,11 @@ public static void FillConnectionsFromButtonsOfChatNode(NodeViewModel node)
var destNode = node.Network.Nodes.FirstOrDefault(x => x.ChatNode.Id == btn.NextNodeId);
if (destNode != null)
{
var conn = new ConnectionViewModel { SourceConnector = node.OutputConnectors.FirstOrDefault(x => x.Button._id == btn._id), DestConnector = destNode.InputConnectors.FirstOrDefault() };
var conn = new ConnectionViewModel
{
SourceConnector = node.OutputConnectors.FirstOrDefault(x => x.Button._id == btn._id),
DestConnector = destNode.InputConnectors.FirstOrDefault()
};
conn.ConnectionChanged += ConnectionViewModelConnectionChanged;
if (conn.SourceConnector == null || conn.DestConnector == null) continue;
node.Network.Connections.Add(conn);
Expand All @@ -268,6 +274,52 @@ public static void ConnectionViewModelConnectionChanged(object s, EventArgs e)

public static class Exts
{
public static Models.ChatFlowSearchItem SearchNode(this ChatNode node, string searchKeywords)
{
if (node.ToString().IsMatch(searchKeywords))
{
return new Models.ChatFlowSearchItem
{
NodeId = node.Id,
NodeText = node.ToString()
};
}

foreach (var btn in node.Buttons)
{
if (btn.ToString().IsMatch(searchKeywords))
{
return (new Models.ChatFlowSearchItem
{
NodeId = node.Id,
NodeText = node.ToString(),
ButtonText = btn.ToString()
});
}
}

foreach (var sec in node.Sections)
{
if (sec.ToString().IsMatch(searchKeywords))
{
return (new Models.ChatFlowSearchItem
{
NodeId = node.Id,
NodeText = node.ToString(),
SectionText = sec.ToString()
});
}
}

return null;
}
public static bool IsMatch(this string text, string searchKeywords)
{
return Regex.IsMatch(text,
string.Join("|", searchKeywords.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries)
.Select(x => x.Trim())), RegexOptions.IgnoreCase);
}

public static T DeepCopy<T>(this T source)
{
var json = source.ToJson();
Expand Down
14 changes: 14 additions & 0 deletions ANAConversationStudio/Models/Chat/BaseContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,20 @@ public string ButtonText
}
}
}

private string _ButtonName;
public string ButtonName
{
get { return _ButtonName; }
set
{
if (_ButtonName != value)
{
_ButtonName = value;
OnPropertyChanged();
}
}
}
}

public class CarouselButtonContent : BaseContent
Expand Down
13 changes: 10 additions & 3 deletions ANAConversationStudio/Models/Chat/BaseEntity.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Newtonsoft.Json;
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;

Expand Down Expand Up @@ -58,10 +59,15 @@ public DateTime UpdatedOn
public class BaseEntity : BaseIdEntity
{
private string _Alias;
[Category("Important")]
[JsonIgnore]
public string Alias
{
get { return _Alias; }
get
{
if (string.IsNullOrWhiteSpace(_Alias))
FillAlias();
return _Alias;
}
set
{
if (_Alias != value)
Expand All @@ -72,6 +78,7 @@ public string Alias
}
}

protected virtual void FillAlias() { }
public override string ToString()
{
return Alias;
Expand Down
25 changes: 19 additions & 6 deletions ANAConversationStudio/Models/Chat/Button.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ namespace ANAConversationStudio.Models.Chat
{
public class Button : RepeatableBaseEntity
{
public Button()
{
FillAlias();
}

#region Important
private ButtonTypeEnum _ButtonType = ButtonTypeEnum.NextNode;
Expand Down Expand Up @@ -252,6 +248,23 @@ public string ButtonText
}
}

private string _ButtonName;
[JsonIgnore]
public string ButtonName
{
get { return _ButtonName; }
set
{
if (_ButtonName != value)
{
_ButtonName = value;

FillAlias();
OnPropertyChanged();
}
}
}

[JsonIgnore]
[BsonIgnore]
public IEnumerable<ButtonTypeEnum> ButtonTypes => Enum.GetValues(typeof(ButtonTypeEnum)).Cast<ButtonTypeEnum>();
Expand Down Expand Up @@ -304,9 +317,9 @@ public ChatNode ParentNode
[BsonIgnore]
public string ContentEmotion { get; set; }

private void FillAlias()
protected override void FillAlias()
{
Alias = Utilities.TrimText(string.IsNullOrWhiteSpace(ButtonText) ? ButtonType + "" : ButtonText);
Alias = Utilities.TrimText(string.IsNullOrWhiteSpace(ButtonName) ? (string.IsNullOrWhiteSpace(ButtonText) ? ButtonType + "" : ButtonText) : ButtonName);
}

public override string ToString()
Expand Down
2 changes: 1 addition & 1 deletion ANAConversationStudio/Models/Chat/Sections/Section.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public bool Hidden
}
}

protected virtual void FillAlias()
protected override void FillAlias()
{
Alias = Utilities.TrimText(SectionType + "");
}
Expand Down
11 changes: 11 additions & 0 deletions ANAConversationStudio/Models/ChatFlowSearchItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace ANAConversationStudio.Models
{
public class ChatFlowSearchItem
{
public string NodeId { get; set; }
public string NodeText { get; set; }
public string SectionText { get; set; }
public string ButtonText { get; set; }
public bool NoResults { get; set; }
}
}
4 changes: 2 additions & 2 deletions ANAConversationStudio/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// 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("4.4.0.0")]
[assembly: AssemblyFileVersion("4.4.0.0")]
[assembly: AssemblyVersion("4.5.0.0")]
[assembly: AssemblyFileVersion("4.5.0.0")]
9 changes: 7 additions & 2 deletions ANAConversationStudio/Styles/EditorTemplates.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<ui:ButtonSectionTypeSymbolConverter x:Key="ButtonSectionTypeSymbolConverter"/>
<views:ButtonTypeToFieldVisibilityConverter x:Key="ButtonTypeToFieldVisibilityConverter"/>
<BooleanToVisibilityConverter x:Key="B2V"/>

<Style x:Key="SectionTypeIconTextblockStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="{StaticResource MDL2Assets}"/>
<Setter Property="FontSize" Value="20"/>
Expand Down Expand Up @@ -50,7 +50,7 @@
<Setter Property="Foreground" Value="White" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>

<Style x:Key="MoveUpButtonStyle" BasedOn="{StaticResource ToolButtonStyle}" TargetType="Button">
<Setter Property="Content" Value="&#xE96D;" />
<Setter Property="Command" Value="{Binding MoveUp}" />
Expand Down Expand Up @@ -169,6 +169,11 @@
</uc:TableRowUserControl.Field>
</uc:TableRowUserControl>
<uc:TableRowUserControl Label="Text">
<uc:TableRowUserControl.Field>
<TextBox Text="{Binding ButtonName, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
</uc:TableRowUserControl.Field>
</uc:TableRowUserControl>
<uc:TableRowUserControl Label="Message">
<uc:TableRowUserControl.Field>
<TextBox Text="{Binding ButtonText, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
</uc:TableRowUserControl.Field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
{
var isStartNode = (bool)value;

return isStartNode ? Application.Current.Resources["startNodeBorderBrush"] : Application.Current.Resources["nodeBorderBrush"];
return isStartNode ? Application.Current.Resources["startNodeHeaderBrush"] : Application.Current.Resources["nodeHeaderBorderBrush"];
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
Expand Down
Loading

0 comments on commit 7696d03

Please sign in to comment.