Skip to content

Commit c589c0b

Browse files
committed
update version to 0.1.4.3
1 parent f3990c3 commit c589c0b

5 files changed

Lines changed: 83 additions & 38 deletions

File tree

DaxStudio.Controls.Example/QueryPlanTreeExample.xaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:ctrl="clr-namespace:DaxStudio.Controls;assembly=DaxStudio.Controls"
55
xmlns:conv="clr-namespace:DaxStudio.Controls.Converters;assembly=DaxStudio.Controls"
6-
xmlns:cal="http://caliburnmicro.com">
6+
xmlns:cal="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro.Platform">
77

88
<UserControl.Resources>
99
<ResourceDictionary>
@@ -13,8 +13,10 @@
1313
<SolidColorBrush x:Key="Theme.Brush.Control.Hover" Color="#F0F0F0"/>
1414
<SolidColorBrush x:Key="Theme.Brush.Control.Pressed" Color="#E0E0E0"/>
1515
<SolidColorBrush x:Key="Theme.Brush.Control.Disabled" Color="#A0A0A0"/>
16-
<SolidColorBrush x:Key="Theme.Brush.Accent" Color="#007ACC"/>
17-
16+
<SolidColorBrush x:Key="Theme.Brush.Accent" Color="#007ACC"/>
17+
18+
<FrameworkElement x:Key="Proxy" DataContext="{Binding RootItems}" />
19+
1820
<ControlTemplate x:Key="SnoopExpanderTemplate" TargetType="{x:Type ToggleButton}">
1921
<Border x:Name="Border"
2022
Width="19"
@@ -80,6 +82,12 @@
8082
Command="{Binding PlacementTarget.ExecuteCustomDescendantFilter,
8183
RelativeSource={RelativeSource FindAncestor,
8284
AncestorType={x:Type ContextMenu}}}"/>
85+
<MenuItem Header="Drill In" Click="DrillIn_Click"
86+
/>
87+
<MenuItem Header="Drill Out" Click="DrillOut_Click"
88+
/>
89+
<!--cal:Action.TargetWithoutContext="{Binding Source={StaticResource Proxy}, Path=DataContext}"
90+
cal:Message.Attach="[Event Click] = [Action TestContextMenuCommand($dataContext)]"-->
8391
</ContextMenu>
8492
</ctrl:TreeGrid.ContextMenu>
8593
<!-- Define columns -->

DaxStudio.Controls.Example/QueryPlanTreeExample.xaml.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,23 @@ private void TreeGrid_Sorting(object sender, DataGridSortingEventArgs e)
2929
{
3030

3131
}
32+
33+
private void DrillIn_Click(object sender, RoutedEventArgs e)
34+
{
35+
System.Diagnostics.Debug.WriteLine("Custom Command");
36+
//((QueryPlanTreeExampleViewModel)TreeGrid.DataContext).TestContextMenuCommand()
37+
var selectedRow = ((TreeGridRow<object>)TreeGrid.SelectedValue).GetDataAs<QPTreeItem>();
38+
((QueryPlanTreeExampleViewModel)TreeGrid.DataContext).RootItems.Clear();
39+
((QueryPlanTreeExampleViewModel)TreeGrid.DataContext).RootItems.Add(selectedRow);
40+
}
41+
42+
private void DrillOut_Click(object sender, RoutedEventArgs e)
43+
{
44+
System.Diagnostics.Debug.WriteLine("Custom Command");
45+
//((QueryPlanTreeExampleViewModel)TreeGrid.DataContext).TestContextMenuCommand()
46+
var selectedRow = ((TreeGridRow<object>)TreeGrid.SelectedValue).GetDataAs<QPTreeItem>();
47+
((QueryPlanTreeExampleViewModel)TreeGrid.DataContext).ResetTree();
48+
//((QueryPlanTreeExampleViewModel)TreeGrid.DataContext).RootItems.Add(selectedRow);
49+
}
3250
}
3351
}

DaxStudio.Controls.Example/QueryPlanTreeExampleViewModel.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,19 @@ namespace DaxStudio.Controls.Example
1111
{
1212
public class QueryPlanTreeExampleViewModel : PropertyChangedBase
1313
{
14+
15+
QueryPlan loadedItems;
1416
public QueryPlanTreeExampleViewModel()
1517
{
1618
var filePath = @"..\..\..\data\QueryPlan.json";
17-
//filePath = @"c:\temp\QueryPlan.json";
19+
filePath = @"c:\temp\QueryPlan.json";
1820
if (File.Exists(filePath))
1921
{
2022
try
2123
{
2224
var json = File.ReadAllText(filePath);
2325

24-
var loadedItems = JsonConvert.DeserializeObject<QueryPlan>(json);
26+
loadedItems = JsonConvert.DeserializeObject<QueryPlan>(json);
2527

2628
if (loadedItems != null)
2729
{
@@ -37,7 +39,15 @@ public QueryPlanTreeExampleViewModel()
3739

3840
}
3941

40-
42+
public void ResetTree()
43+
{
44+
RootItems.Clear();
45+
var tempItems = LoadItemsRecursively(loadedItems.PhysicalQueryPlanRows);
46+
foreach (var item in tempItems)
47+
{
48+
RootItems.Add(item);
49+
}
50+
}
4151

4252
private ObservableCollection<QPTreeItem> LoadItemsRecursively(List<QPTreeItem> loadedItems)
4353
{
@@ -115,6 +125,13 @@ public bool FindDescendantsWithHigherRecordCountsRecursive(TreeGridRow<object> i
115125
return false;
116126
}
117127

128+
public void TestContextMenuCommand(object parameter)
129+
{
130+
// This is just a test command to show how to handle context menu commands
131+
// You can implement your logic here
132+
System.Diagnostics.Debug.WriteLine($"Context menu command executed with parameter: {parameter}");
133+
}
134+
118135
}
119136

120137
public class QueryPlan

DaxStudio.Controls/Controls/TreeGrid/TreeGrid.cs

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class TreeGrid : DataGrid
3535
private readonly object _refreshLock = new object();
3636
private volatile bool _refreshPending = false;
3737
private DispatcherTimer _refreshTimer;
38-
private const int REFRESH_DEBOUNCE_MS = 50; // Debounce delay
38+
private const int REFRESH_DEBOUNCE_MS = 20; // Debounce delay
3939

4040
public ICommand ExecuteCustomDescendantFilter { get; private set; }
4141
// Add these fields to track bound collections
@@ -571,33 +571,35 @@ private static void SynchronizeCollections(ObservableCollection<TreeGridRow<obje
571571
List<TreeGridRow<object>> source)
572572
{
573573
// Using a direct synchronization approach to minimize UI updates
574-
575-
int commonLength = Math.Min(target.Count, source.Count);
576-
577-
// Step 1: Update existing items that match positions
578-
for (int i = 0; i < commonLength; i++)
574+
using (new DeferRefresh(target))
579575
{
580-
if (!ReferenceEquals(target[i], source[i]))
576+
int commonLength = Math.Min(target.Count, source.Count);
577+
578+
// Step 1: Update existing items that match positions
579+
for (int i = 0; i < commonLength; i++)
581580
{
582-
target[i] = source[i];
581+
if (!ReferenceEquals(target[i], source[i]))
582+
{
583+
target[i] = source[i];
584+
}
583585
}
584-
}
585-
586-
// Step 2: Remove extra items from end of target
587-
if (target.Count > source.Count)
588-
{
589-
for (int i = target.Count - 1; i >= source.Count; i--)
586+
587+
// Step 2: Remove extra items from end of target
588+
if (target.Count > source.Count)
590589
{
591-
target.RemoveAt(i);
590+
for (int i = target.Count - 1; i >= source.Count; i--)
591+
{
592+
target.RemoveAt(i);
593+
}
592594
}
593-
}
594-
595-
// Step 3: Add missing items to target
596-
if (source.Count > target.Count)
597-
{
598-
for (int i = target.Count; i < source.Count; i++)
595+
596+
// Step 3: Add missing items to target
597+
if (source.Count > target.Count)
599598
{
600-
target.Add(source[i]);
599+
for (int i = target.Count; i < source.Count; i++)
600+
{
601+
target.Add(source[i]);
602+
}
601603
}
602604
}
603605
}
@@ -970,10 +972,10 @@ private void SetupDefaultContextMenu()
970972
switch (menuItem.Header.ToString())
971973
{
972974
case "Expand Selected":
973-
menuItem.IsEnabled = selectedRow?.HasChildren == true && !selectedRow.IsExpanded;
975+
menuItem.IsEnabled = selectedRow?.HasChildren == true;// && !selectedRow.IsExpanded;
974976
break;
975977
case "Collapse Selected":
976-
menuItem.IsEnabled = selectedRow?.HasChildren == true && selectedRow.IsExpanded;
978+
menuItem.IsEnabled = selectedRow?.HasChildren == true;// && selectedRow.IsExpanded;
977979
break;
978980
case "Expand All":
979981
menuItem.IsEnabled = _itemToRowMap.Values.Any(r => r.HasChildren && !r.IsExpanded);
@@ -1186,11 +1188,11 @@ private void RemoveItemAndDescendants(object item)
11861188
private void OnChildCollectionChanged(object parentItem, NotifyCollectionChangedEventArgs e)
11871189
{
11881190
// For UI thread safety
1189-
if (!Dispatcher.CheckAccess())
1190-
{
1191-
Dispatcher.BeginInvoke(DispatcherPriority.Normal ,new Action(() => OnChildCollectionChanged(parentItem, e)));
1192-
return;
1193-
}
1191+
//if (!Dispatcher.CheckAccess())
1192+
//{
1193+
// Dispatcher.BeginInvoke(DispatcherPriority.Normal ,new Action(() => OnChildCollectionChanged(parentItem, e)));
1194+
// return;
1195+
//}
11941196

11951197
lock (_refreshLock)
11961198
{

Directory.Build.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project>
22
<PropertyGroup>
33
<Company>DAX Studio</Company>
4-
<AssemblyVersion>0.1.4.2</AssemblyVersion>
5-
<FileVersion>0.1.4.2</FileVersion>
6-
<version>0.1.4.2</version>
4+
<AssemblyVersion>0.1.4.3</AssemblyVersion>
5+
<FileVersion>0.1.4.3</FileVersion>
6+
<version>0.1.4.3</version>
77
</PropertyGroup>
88
</Project>

0 commit comments

Comments
 (0)