Kippachu
Kippachu
CC#
Created by Kippachu on 5/3/2023 in #help
❔ Need help with WPF Prism app
🆙 Thanks in advance !
5 replies
CC#
Created by Kippachu on 5/3/2023 in #help
❔ Need help with WPF Prism app
Hello, I didn't get an answer so I'm doing a little up, thanks in advance !
5 replies
CC#
Created by Abderahman Magdy on 5/3/2023 in #help
✅ Converting project
Why ? Isn't GPT good to understand the context and give advices on top of converting a code snippet, it's not as good as a professional that knows the languages perfectly but it can help a beginner
17 replies
CC#
Created by Abderahman Magdy on 5/3/2023 in #help
✅ Converting project
You could ask GPT to convert C code snippets to C++
17 replies
CC#
Created by Kippachu on 5/3/2023 in #help
❔ Need help with WPF Prism app
Then, within the OnPreviewContentPropertyChanged method, I have to use a switch statement based on the key value and update the corresponding property in the PreviewTextService dictionary. This means that every time I create a new form implementing Preview Text, I have to manually add all cases inside the switch statement. I am unsure how to replace this code with a more efficient pattern. If anyone could help me improve my code, I would greatly appreciate it!
5 replies
CC#
Created by BambiAria on 4/12/2023 in #help
Problem with my project
There are many ways of doing this, the simplest way would be to create a private field inside the class (outside the methods)
private double _timeOfFlight;
private double _timeOfFlight;
Change timeOfFlight to _timeOfFlight inside NoHorizontalAccelerationCalculation() method this way you are setting the value outside your method and so it becomes usable in others methods of the same class (private field) This means now you can do
private double _timeOfFlight;

private void GraphPanel_Click(object sender, EventArgs e)
{
NoHorizontalAccelerationCalculation() //This will set the _timeofFlight value
var drawingGraphLogic = DrawingGraphLogic(_timeOfFlight, 1, 1) //here you use the method from your first attachment, using the timeOfFlight value set inside NoHorizontalAccelerationCalculation() ie third attachment
[...] //continue your code
}
private double _timeOfFlight;

private void GraphPanel_Click(object sender, EventArgs e)
{
NoHorizontalAccelerationCalculation() //This will set the _timeofFlight value
var drawingGraphLogic = DrawingGraphLogic(_timeOfFlight, 1, 1) //here you use the method from your first attachment, using the timeOfFlight value set inside NoHorizontalAccelerationCalculation() ie third attachment
[...] //continue your code
}
Note : This will work but is totally not the best way to do, you'll have to change this behaviour later., just gave you an easy solution in many solutions. Is it ok for you ?
3 replies
CC#
Created by mblla on 4/12/2023 in #help
❔ Illuminate buttons pressing a row of a DataGrid
Hey I just came back, I'm glad to hear you made it If you don't understand something in the code you can ask me
20 replies
CC#
Created by mblla on 4/12/2023 in #help
❔ Illuminate buttons pressing a row of a DataGrid
No problem, tell me if it worked, now i can go to eat ^^
20 replies
CC#
Created by mblla on 4/12/2023 in #help
❔ Illuminate buttons pressing a row of a DataGrid
I'm still learning also
20 replies
CC#
Created by mblla on 4/12/2023 in #help
❔ Illuminate buttons pressing a row of a DataGrid
Maybe the triggers way was better and it does everything you need in two lines, but i don't know i did it like this
20 replies
CC#
Created by mblla on 4/12/2023 in #help
❔ Illuminate buttons pressing a row of a DataGrid
Basically when you select a row then your variable "selectedPerson" in DataGrid_SelectedCellsChanged will not be null, so inside UpdateButtonColors the else case will be run, changing the color of every people in your MyPeopleList, and as you binded the buttons colors to your people color, it will also change, else if unselect the row the selectedPerson will be null and will set the buttons color back to grey
20 replies
CC#
Created by mblla on 4/12/2023 in #help
❔ Illuminate buttons pressing a row of a DataGrid
I don't know if my solution is the best, maybe it's bad idk but it works, tell me if you succeeded
20 replies
CC#
Created by mblla on 4/12/2023 in #help
❔ Illuminate buttons pressing a row of a DataGrid
You'll need to implement INotifyPropertyChanged inside People class then add :
private SolidColorBrush _buttonColor;
public SolidColorBrush ButtonColor
{
get => _buttonColor;
set
{
_buttonColor = value;
OnPropertyChanged(nameof(ButtonColor));
}
}
protected void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
private SolidColorBrush _buttonColor;
public SolidColorBrush ButtonColor
{
get => _buttonColor;
set
{
_buttonColor = value;
OnPropertyChanged(nameof(ButtonColor));
}
}
protected void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
In MainWindow.xaml bind Button Background to ButtonColor property, also in DataGrid properties, add SelectedCellsChanged and create the method DataGrid_SelectedCellsChanged Like this : <DataGrid Margin="20,5,20,5" SelectedCellsChanged="DataGrid_SelectedCellsChanged" Height="200" Width="600" ItemsSource="{Binding MyListOfPeopleForBinding}" AutoGenerateColumns="False"> You have to create this method inside MainWindow.xaml.cs private void DataGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e) { if (sender is not DataGrid dataGrid) return; var vm = DataContext as MainViewModel; var selectedPerson = dataGrid.SelectedItem as People; vm?.UpdateButtonColors(selectedPerson); } Add the method UpdateButtonColors(People selectedPerson) in your viewModel or it will not work : public void UpdateButtonColors(People selectedPeople) { foreach (var person in MyListOfPeople) { if (selectedPeople == null) { person.ButtonColor = Brushes.Gray; // Default color } else { person.ButtonColor = person.IsOk ? Brushes.Green : Brushes.Red; } } }
20 replies
CC#
Created by mblla on 4/12/2023 in #help
❔ Illuminate buttons pressing a row of a DataGrid
20 replies
CC#
Created by mblla on 4/12/2023 in #help
❔ Illuminate buttons pressing a row of a DataGrid
I found the solution 🙂
20 replies
CC#
Created by mblla on 4/12/2023 in #help
❔ Illuminate buttons pressing a row of a DataGrid
When you select a row, does all buttons have to change color, or only the one with the same name on it ?
20 replies
CC#
Created by Athariqk on 4/7/2023 in #help
✅ Does arithmetic in a `const float` gets recomputed each time you access it?
When you declare a const float and initialize it with a value or an arithmetic expression, the value is computed at compile-time, and it remains constant throughout the program. The compiler treats constant expressions as fixed values, and it may optimize the code further by replacing the constant variable with its value directly in the compiled code. Here's an example:
const float pi = 3.14159;
const float doublePi = pi * 2;
const float pi = 3.14159;
const float doublePi = pi * 2;
In this example, doublePi will be calculated at compile-time, and its value will be stored as a constant. Each time you access doublePi, the value will not be recomputed – it will simply return the precomputed constant value.
6 replies
CC#
Created by Kippachu on 10/31/2022 in #help
WPF Find Action IDialogResult using it's string name (Reflection)
I thought it would be a better idea but i don't think it is possible
5 replies