Petr
Petr
CC#
Created by Petr on 12/25/2022 in #help
❔ Unable to change font in VS 2019
Hello, i have persisting problem in my c# project made in VS 2019. I made a custom class that is supposed to change font to any font available to my console:(FontChangerClass file added as an attachment). But it doesn't work. I use additional code to check for errors that is based on the FontManager class (attachment) and that looks like this:
static void Main(string[] args)
{


bool success = FontManager.SetFont("MS Gothic", 16, 12);

if (success)
{
Console.WriteLine("Font successfully set.");
}
else
{
Console.WriteLine("Failed to set font.");
}
Thread.Sleep(2500);
FontManager.PrintStdHandles();
Thread.Sleep(3000);
static void Main(string[] args)
{


bool success = FontManager.SetFont("MS Gothic", 16, 12);

if (success)
{
Console.WriteLine("Font successfully set.");
}
else
{
Console.WriteLine("Failed to set font.");
}
Thread.Sleep(2500);
FontManager.PrintStdHandles();
Thread.Sleep(3000);
My handles are standard -> Input = 8, Output = 12, Error = 16. But even if i enter all the information correctly, it still doesn't change the font and returns an Error: 87. My default console font is Consolas, 16 and i'm trying to change it to MS Gothic, 16. Only temporarily, otherwise i would do it through console properties setting. And i am aware that font changing is resolved much better in VS 2022, but i am unable install 2022 because it throws an installation error about NET 4.8 package while downloading. Thanks for taking the time to check out my code, Petr
2 replies
CC#
Created by Petr on 12/1/2022 in #help
❔ Variables from different classes not adding up 2
36 replies
CC#
Created by Petr on 11/30/2022 in #help
✅ Variables from different classes not adding up
Hello my name is Peter and i would like to ask for your help. In my code, i am unable to add variable from one class to variable from another class. I'll show you what i mean:
class Skret : Stvoreni
{
private int poskozeniSS { get; set; }
private int poskozeniU { get; set; }


public Skret()
{
sZdravi = 4 + sObrannaHodnota + sSila;
sInteligence = 2;
sSila = 2;
sObratnost = 2;
sStesti = 1;
maManu = false;
sUtocnaHodnota = 1 + Dyka.poskozeniZbrane;
sObrannaHodnota = 1 + Latkova.hodnotaBrneni;
}
}
------------------------------------------------------------------------------------
class Latkova : Zbroje
{
public Latkova()
{
hodnotaBrneni = 1;
}
}
------------------------------------------------------------------------------------
class Program
{
static void Main(string[] args)
{
Skret skret = new Skret();
Console.WriteLine(skret.sObrannaHodnota);
}

}
---------------------------------------------------------------------------------------
class Skret : Stvoreni
{
private int poskozeniSS { get; set; }
private int poskozeniU { get; set; }


public Skret()
{
sZdravi = 4 + sObrannaHodnota + sSila;
sInteligence = 2;
sSila = 2;
sObratnost = 2;
sStesti = 1;
maManu = false;
sUtocnaHodnota = 1 + Dyka.poskozeniZbrane;
sObrannaHodnota = 1 + Latkova.hodnotaBrneni;
}
}
------------------------------------------------------------------------------------
class Latkova : Zbroje
{
public Latkova()
{
hodnotaBrneni = 1;
}
}
------------------------------------------------------------------------------------
class Program
{
static void Main(string[] args)
{
Skret skret = new Skret();
Console.WriteLine(skret.sObrannaHodnota);
}

}
---------------------------------------------------------------------------------------
So if i try to print the value of
sObrannaHodnota
sObrannaHodnota
, it should return 2, since it's 1+1. But unfortunately it returns only 1, as it seems to completely ignore the variable from the other class added to it.
10 replies