86 Replies
What am i missing? Why can't it initializeComponent?
build your solution if it builds its just $vsdrunk
* close VS
* remove the hidden folder
.vs
* remove all bin
and obj
folder next to each csproj (DO NOT TOUCH THE .git
FOLDER OR WHAT'S INSIDE)
* restart vsalso is that wpf?winui3? or what
I have no idea what those are
I did manage to fix it
but i'm unsure about
what kind of project u create
What should be written here if my .cs file is called
SetupGameDialog.xaml.cs`
Othello gameno
double click your project in the solution explorer
then paste it here
and we will know what kind of project it is
Doubleclick my project?
ok so yeah that is wrong indeed
Severity Code Description Project File Line Suppression State
Error (active) CS1061 'SetupGameDialog' does not contain a definition for 'HumanVsHuman_Click' and no accessible extension method 'HumanVsHuman_Click' accepting a first argument of type 'SetupGameDialog' could be found (are you missing a using directive or an assembly reference?) Assignment2 C:\Users\aljom\Documents\Plugg Programmering filer\OOP\Assignment2\Assignment2Repository\Assignment2\Assignment2\View\SetupGameDialog.xaml 12
should have been Othello.View.MainWindow
because u moved it
you double click that it opens the csproj
and with the contents of it u can tell what kind of projec it is
ok so its WPF π
'SetupGameDialog' does not contain a definition for 'HumanVsHuman_Click'
you have a click event in your xaml
but not in the .xaml.cs file
I did define it
Is it because my namespace is wrong?
yes
Othello.View is what u had
you only have 1 MainWindow.xaml and MainWindow.xaml.cs correct?
Yes i think so
I've made definitions for the buttons
and changed the namespace
ok you changed the file name but not the class name hehe its ok
so yeah they should both have the .View
once u change that do a build to ensure its ok or what other errors u have
I'm not sure i understand.
I changed the namespace to
Assignment2.view
Is it
That's the problem?
aaaah
That seems to solve itu might have changed something esle too glad u figured out π
Do you know if it's possible to move xaml files?
like i want WinnerDialog.xaml to be ontop, then DrawDialog etc
drag and drop doesn't seem to work lol
yes it is but if u want to also have the right structure u would have to rename the namespace
drag and drop should work yes
I'm a little bit stuck
So this is the code behind my three buttons. They aren't implemented yet
However when the user presses the HumanVsHuman button i want it to start a game
sure then u would have to write the logic for that to happen
what part of that are u stuck with
Honestly this assignment is so complicated that i'm even unsure on what i'm unsure about
These 3 are what i'm trying to make right now
I already make the 5.1
SetUpGameDialog
fk
i realiezd i don't take their names
ok so SetupGameDialog should be a window with two textbox and either a checkbox under each textbox indication if its a computer or not, or a combobox and a button as I understood
so you fill in the name on textbox 1
then you fill in the name on textbox 2
then u click the checkbox if player 1 or 2 are computer
then u hit the button
so for now I would just implement that
and try to print the output when u click the button
then u work out how it passes it back to the GameWindow
damn
so there is no comptuer vs computer
good
But right so when they click human vs human
a new window comes up?
and asks for names
there is just 1 button
not 3
so you click start or register or something
it would go back to the previous window
GameWindow is apparently the main window that should open
from what is written there
as setupgamedialog is a child of it
π
This is what i had in mind?
Human vs Human -> enter names -> confirm window
pretty close
now have a checkbox that says "Is Computer" for example
and if check then its a computer if not a player
:harold:
self explanatory
you're trying to give value to a dialog result before its create
I don't get it
what you don't get, show code etc might be easier for me to explain
When i press ok
the window has already been up
`
You can resume that to
IsChecked already returns true or false
As far as i can see it looks fine?
looks fine yes
Can't implicitly convert type bool? to bool
you can 1 extra } at the end
This seemed to fix it
however i'm still getting the same error?
ah its nullable I see ok, just IsChecked.Value
anyway so the problem is when u click ok it does no close?
exactly
what u do here is you set a breakpoint
then u walk thru the method to see what is wrong
you see the red circle?
you go to the line where u have
Player1Name = Player1NameTextBox.Text;
and click on the gray are near the number
and it will set that red circle
then you run your project
and fill in the information and press the OK
then it will stop at that line
then you press slowly F11
and it will walk down your codePlayer1Name "a" string
yeah it does get set
and player2 name gets set to computer
yes then u check everything and see where its skipping
It's not skipping anywhere?
Both player1 and player2 name gets set appropriately
ok it reached the result?
so it should close
does it reach the
this.Close()
if u keep hitting F11?No.
We get the exception on this.DialogResult = true;
what exception?
I clicked the button "OK" so it should then close
same exception
the window has been created
and shown as a dialog
weird
son idk why it's casting an exception
click view details
and its pointing at the DialogResult from that files? SetupGameDialog?
Can't i just remove it?
seems to work lol
technically yes you can
but you lose the ability to tell from the ShowDialog result if it worked or not
I only care to finish the assignment xd
for example
sure
can u show me this thou
I did like to see why its not working for u
i'm never gonna finish this
teachers are psychotic for making an assignment this hard
its not hard you're just overthinking it π like u were thinking u had to do a computer vs computer
that u needed 3 buttons
Well the setupgamewindow works
you're luck that your material explains and even tells u what to use to make the stuff
some teachers are way more vague than that
ok i got a problem now
because i removed that line
It's not returning
true
form the setup game dialog
ok i added it back
and it WORKS?!
:aaaa:hahahaha
I thou so
that was such a random issue
for sure
it does add the names at the bottom now
If you have no further questions, please use /close to mark the forum thread as answered