Skip to content

Commit

Permalink
Doubleclick in Demo view
Browse files Browse the repository at this point in the history
  • Loading branch information
netquick committed Jul 20, 2024
1 parent 8909b01 commit 1699259
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 3 deletions.
2 changes: 2 additions & 0 deletions DeFRaG_Helper/UserControls/HighLightCard.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
e.Handled = true;

// Call your connection logic here
MapViewModel.GetInstanceAsync().Result.SelectedMap = Map;
PlayMap();

}

}
Expand Down
2 changes: 1 addition & 1 deletion DeFRaG_Helper/UserControls/MiniView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xmlns:local="clr-namespace:DeFRaG_Helper.UserControls"
mc:Ignorable="d"
d:DesignHeight="120" d:DesignWidth="120">
<Border CornerRadius="10" Background="#2c2c2c" MouseUp="Border_MouseUp">
<Border CornerRadius="10" Background="#2c2c2c" MouseUp="Border_MouseUp" MouseLeftButtonDown="Border_MouseLeftButtonDown">
<Grid>
<Image Margin="5,5,5,45" Source="{Binding ImagePath}"/>
<Border Margin="0,75,0,0" Background="#333" CornerRadius="0,0,10,10">
Expand Down
41 changes: 40 additions & 1 deletion DeFRaG_Helper/UserControls/MiniView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ public Map Map
}
private static void OnMapPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var control = d as HighLightCard;
var control = d as MiniView; // Corrected from HighLightCard to MiniView
if (control != null)
{
control.DataContext = e.NewValue;
}
}

private async void Border_MouseUp(object sender, MouseButtonEventArgs e)
{
// Cast the DataContext to a Map object
Expand All @@ -56,6 +57,44 @@ private async void Border_MouseUp(object sender, MouseButtonEventArgs e)

}
}
private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (e.ClickCount == 2)
{
// Prevent event from bubbling up to parent elements
e.Handled = true;
var map = this.DataContext as Map;

// Call your connection logic here
PlayMap();
}

}


private void PlayMap()
{
var map = this.DataContext as Map; // Correctly assigned to a local variable

if (map == null)
{
MessageHelper.Log("Map data is not available.");
return; // Exit the method if map is null
}

var mainWindow = Application.Current.MainWindow as MainWindow;
if (mainWindow == null)
{
MessageHelper.Log("Main window is not accessible.");
return; // Exit the method if mainWindow is null
}

int physicsSetting = mainWindow.GetPhysicsSetting(); // method in MainWindow
// Use the local variable 'map' instead of the property 'Map'
System.Diagnostics.Process.Start(AppConfig.GameDirectoryPath + "\\oDFe.x64.exe", $"+set fs_game defrag +df_promode {physicsSetting} +map {System.IO.Path.GetFileNameWithoutExtension(map.Mapname)}");
}



}
}
6 changes: 5 additions & 1 deletion DeFRaG_Helper/Views/Demos.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ public Demos()
{
await InitializeAsync();
LoadDataAsync();
var mainWindow = Application.Current.MainWindow as MainWindow;
if (mainWindow != null)
{
mainWindow.customDropDownButton.MapPlayed += (s, e) => RefreshMapListAsync();
}
};
var mapHistoryManager = MapHistoryManager.GetInstance("DeFRaG_Helper");
MapHistoryManager.MapHistoryUpdated += async () => await RefreshMapListAsync();
Expand Down

0 comments on commit 1699259

Please sign in to comment.