Skip to content

Commit

Permalink
[addon] Add links in dynamic and ComObj section (#48)
Browse files Browse the repository at this point in the history
* [addon] Add links in dynamic and ComObj section

Add links for quick access from dynamic to ParameterRef and ComObjectRef items

* fix: TextFilter NullReferenceException

* fix: check module type is main application

* adapt margin to comboboxes

Comboboxes were too high due to wrong margin for textblocks from the links

* fix: index idynitems

---------

Co-authored-by: Mike <45664417+thewhobox@users.noreply.github.com>
  • Loading branch information
olterion and thewhobox authored Sep 10, 2024
1 parent 2d6c398 commit 915a5a2
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 11 deletions.
3 changes: 2 additions & 1 deletion Kaenx.Creator/Classes/TextFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public void Hide()
public void Show()
{
Query = _query;
view.Refresh();
if(view != null)
view.Refresh();
}
}
}
13 changes: 11 additions & 2 deletions Kaenx.Creator/Controls/ComObjectRefView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,16 @@
</HeaderedContentControl>

<HeaderedContentControl Header="{x:Static p:Resources.prop_como}">
<ComboBox IsEditable="true" ItemsSource="{Binding Module.ComObjects, ElementName=ViewControl}" DisplayMemberPath="Name" SelectedItem="{Binding ComObjectObject}" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<ComboBox IsEditable="true" ItemsSource="{Binding Module.ComObjects, ElementName=ViewControl}" DisplayMemberPath="Name" SelectedItem="{Binding ComObjectObject}" />
<TextBlock Grid.Column="1" VerticalAlignment="Center" Margin="10 0 0 4">
<Hyperlink ToolTip="{x:Static p:Resources.tcheck_tooltip}" NavigateUri="https://example.com" RequestNavigate="ComObjectHyperlink">&lt;--</Hyperlink>
</TextBlock>
</Grid>
</HeaderedContentControl>

<HeaderedContentControl Header="{x:Static p:Resources.tcom_para}" Visibility="{Binding Module.IsComObjectRefAuto, ElementName=ViewControl, Converter={StaticResource BoolToVis}, ConverterParameter=true}">
Expand All @@ -127,7 +136,7 @@
<CheckBox IsChecked="{Binding UseTextParameter}" VerticalAlignment="Center" />
<ComboBox Grid.Column="1" IsEnabled="{Binding UseTextParameter}" ItemsSource="{Binding Module.ParameterRefs, ElementName=ViewControl}" SelectedItem="{Binding ParameterRefObject, Mode=TwoWay}" DisplayMemberPath="Name" />
<TextBlock Grid.Column="2" VerticalAlignment="Center" Margin="10 0 0 4">
<Hyperlink ToolTip="{x:Static p:Resources.tcheck_tooltip}" NavigateUri="https://example.com" RequestNavigate="ClickCheckHyperlink">&lt;--</Hyperlink>
<Hyperlink ToolTip="{x:Static p:Resources.tcheck_tooltip}" NavigateUri="https://example.com" RequestNavigate="ComObjParaRefHyperlink">&lt;--</Hyperlink>
</TextBlock>
</Grid>
</HeaderedContentControl>
Expand Down
8 changes: 7 additions & 1 deletion Kaenx.Creator/Controls/ComObjectRefView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,18 @@ private void ClickRemove(object sender, RoutedEventArgs e)
ClearHelper.ClearIDs(Module.Dynamics[0], cref);
}

private void ClickCheckHyperlink(object sender, RoutedEventArgs e)
private void ComObjParaRefHyperlink(object sender, RoutedEventArgs e)
{
Models.ComObjectRef com = (sender as System.Windows.Documents.Hyperlink).DataContext as Models.ComObjectRef;
MainWindow.Instance.GoToItem(com.ParameterRefObject, Module);
}

private void ComObjectHyperlink(object sender, RoutedEventArgs e)
{
Models.ComObjectRef com = (sender as System.Windows.Documents.Hyperlink).DataContext as Models.ComObjectRef;
MainWindow.Instance.GoToItem(com.ComObjectObject, Module);
}

private void ResetId(object sender, RoutedEventArgs e)
{
((sender as Button).DataContext as Models.ComObjectRef).Id = -1;
Expand Down
42 changes: 36 additions & 6 deletions Kaenx.Creator/Controls/DynamicView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,16 @@
<TextBox Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}" />
</HeaderedContentControl>
<HeaderedContentControl Header="{x:Static p:Resources.tdyn_pararef}">
<ComboBox IsEditable="true" ItemsSource="{Binding Module.ParameterRefs, ElementName=ViewControl}" SelectedItem="{Binding ParameterRefObject}" DisplayMemberPath="Name" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<ComboBox IsEditable="true" ItemsSource="{Binding Module.ParameterRefs, ElementName=ViewControl}" SelectedItem="{Binding ParameterRefObject}" DisplayMemberPath="Name" />
<TextBlock Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="10 0 0 4">
<Hyperlink ToolTip="{x:Static p:Resources.tcheck_tooltip}" NavigateUri="https://example.com" RequestNavigate="DynParameterParaRefLink">&lt;--</Hyperlink>
</TextBlock>
</Grid>
</HeaderedContentControl>
<HeaderedContentControl Header="{x:Static p:Resources.tdyn_paraname}">
<TextBlock Text="{Binding ParameterRefObject.ParameterObject.Name}" />
Expand Down Expand Up @@ -166,7 +175,16 @@
<TextBox Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}" />
</HeaderedContentControl>
<HeaderedContentControl Header="{x:Static p:Resources.tdyn_comref}">
<ComboBox IsEditable="true" ItemsSource="{Binding Module.ComObjectRefs, ElementName=ViewControl}" SelectedItem="{Binding ComObjectRefObject}" DisplayMemberPath="Name" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<ComboBox IsEditable="true" ItemsSource="{Binding Module.ComObjectRefs, ElementName=ViewControl}" SelectedItem="{Binding ComObjectRefObject}" DisplayMemberPath="Name" />
<TextBlock Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="10 0 0 4">
<Hyperlink ToolTip="{x:Static p:Resources.tcheck_tooltip}" NavigateUri="https://example.com" RequestNavigate="DyComObjectRefLink">&lt;--</Hyperlink>
</TextBlock>
</Grid>
</HeaderedContentControl>
<HeaderedContentControl Header="{x:Static p:Resources.tdyn_comname}">
<TextBlock Text="{Binding ComObjectRefObject.ComObjectObject.Name}" />
Expand Down Expand Up @@ -261,10 +279,13 @@
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>

<CheckBox IsChecked="{Binding UseParameterRef}" VerticalAlignment="Center" />
<ComboBox Grid.Column="1" IsEditable="true" IsEnabled="{Binding UseParameterRef}" ItemsSource="{Binding Module.ParameterRefs, ElementName=ViewControl}" SelectedItem="{Binding ParameterRefObject, Mode=TwoWay}" DisplayMemberPath="Name" />
<ComboBox Grid.Column="1" IsEditable="true" IsEnabled="{Binding UseParameterRef}" ItemsSource="{Binding Module.ParameterRefs, ElementName=ViewControl}" SelectedItem="{Binding ParameterRefObject, Mode=TwoWay}" DisplayMemberPath="Name" />
<TextBlock Grid.Column="2" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="10 0 0 4">
<Hyperlink ToolTip="{x:Static p:Resources.tcheck_tooltip}" NavigateUri="https://example.com" RequestNavigate="DynBlockParaRefLink">&lt;--</Hyperlink>
</TextBlock>
</Grid>
</HeaderedContentControl>
<HeaderedContentControl Header="{x:Static p:Resources.tdyn_textpara}">
Expand Down Expand Up @@ -430,8 +451,17 @@
<HeaderedContentControl Header="{x:Static p:Resources.tdyn_pararef}">
<StackPanel>
<CheckBox Content="IsGlobal" IsChecked="{Binding IsGlobal}" Margin="0 3" />
<ComboBox Visibility="{Binding IsGlobal, Converter={StaticResource BoolToVis}, ConverterParameter=true}" IsEditable="true" ItemsSource="{Binding Module.ParameterRefs, ElementName=ViewControl}" SelectedItem="{Binding ParameterRefObject}" DisplayMemberPath="Name"/>
<ComboBox Visibility="{Binding IsGlobal, Converter={StaticResource BoolToVis}}" IsEditable="true" ItemsSource="{Binding Version.ParameterRefs, ElementName=ViewControl}" SelectedItem="{Binding ParameterRefObject}" DisplayMemberPath="Name"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<ComboBox Grid.Column="0" Visibility="{Binding IsGlobal, Converter={StaticResource BoolToVis}, ConverterParameter=true}" IsEditable="true" ItemsSource="{Binding Module.ParameterRefs, ElementName=ViewControl}" SelectedItem="{Binding ParameterRefObject}" DisplayMemberPath="Name"/>
<ComboBox Grid.Column="0" Visibility="{Binding IsGlobal, Converter={StaticResource BoolToVis}}" IsEditable="true" ItemsSource="{Binding Version.ParameterRefs, ElementName=ViewControl}" SelectedItem="{Binding ParameterRefObject}" DisplayMemberPath="Name"/>
<TextBlock Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="10 0 0 4">
<Hyperlink ToolTip="{x:Static p:Resources.tcheck_tooltip}" NavigateUri="https://example.com" RequestNavigate="DynChooseParaRefLink">&lt;--</Hyperlink>
</TextBlock>
</Grid>
</StackPanel>
</HeaderedContentControl>
</StackPanel>
Expand Down
24 changes: 24 additions & 0 deletions Kaenx.Creator/Controls/DynamicView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,30 @@ private void ClickEditButtonFunction(object sender, RoutedEventArgs e)
item.Script = code.CodeNew;
}

private void DynChooseParaRefLink(object sender, RoutedEventArgs e)
{
Models.ParameterRef paraRef = ((sender as System.Windows.Documents.Hyperlink).DataContext as Models.Dynamic.DynChooseBlock).ParameterRefObject;
MainWindow.Instance.GoToItem(paraRef, Module);
}

private void DynBlockParaRefLink(object sender, RoutedEventArgs e)
{
Models.ParameterRef paraRef = ((sender as System.Windows.Documents.Hyperlink).DataContext as Models.Dynamic.DynParaBlock).ParameterRefObject;
MainWindow.Instance.GoToItem(paraRef, Module);
}

private void DynParameterParaRefLink(object sender, RoutedEventArgs e)
{
Models.ParameterRef paraRef = ((sender as System.Windows.Documents.Hyperlink).DataContext as Models.Dynamic.DynParameter).ParameterRefObject;
MainWindow.Instance.GoToItem(paraRef, Module);
}

private void DyComObjectRefLink(object sender, RoutedEventArgs e)
{
Models.ComObjectRef comRef = ((sender as System.Windows.Documents.Hyperlink).DataContext as Models.Dynamic.DynComObject).ComObjectRefObject;
MainWindow.Instance.GoToItem(comRef, Module);
}

Dictionary<string, List<string>> SubTypes = new Dictionary<string, List<string>>() {
{"DynamicMain",
new List<string>() {
Expand Down
2 changes: 1 addition & 1 deletion Kaenx.Creator/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private async void AutoCheckUpdate()

public void GoToItem(object item, object module)
{
if(module != null)
if(module != null && module.GetType() == typeof(Kaenx.Creator.Models.Module))
{
VersionTabs.SelectedIndex = 7;
int index2 = item switch {
Expand Down

0 comments on commit 915a5a2

Please sign in to comment.