Estal
Estal
Explore posts from servers
CC#
Created by Estal on 1/22/2023 in #help
❔ Transitional Timer
I'm Trying to create an animated Menu Expansion and to do so I opted for a winforms timer and have the following code:
WinForms.Timer menuTimer = new WinForms.Timer();

private void settingsDock_MouseDown(object sender, MouseButtonEventArgs e)
{
if(menuBorder.Height == 0)
{
menuTimer.Tick += new EventHandler(MenuTimerOpen);
} else
{
menuTimer.Tick += new EventHandler(MenuTimerClose);
}
menuTimer.Interval = 1;
menuTimer.Start();

}
private void MenuTimerClose(object sender, EventArgs e)
{
if(menuBorder.Height == 0)
{
menuTimer.Stop();
}
else
{
menuBorder.Height = menuBorder.Height - 10;
}
}

private void MenuTimerOpen(object sender, EventArgs e)
{
if(menuBorder.Height == 150)
{
menuTimer.Stop();
}
else
{
menuBorder.Height = menuBorder.Height + 10;
}
}
WinForms.Timer menuTimer = new WinForms.Timer();

private void settingsDock_MouseDown(object sender, MouseButtonEventArgs e)
{
if(menuBorder.Height == 0)
{
menuTimer.Tick += new EventHandler(MenuTimerOpen);
} else
{
menuTimer.Tick += new EventHandler(MenuTimerClose);
}
menuTimer.Interval = 1;
menuTimer.Start();

}
private void MenuTimerClose(object sender, EventArgs e)
{
if(menuBorder.Height == 0)
{
menuTimer.Stop();
}
else
{
menuBorder.Height = menuBorder.Height - 10;
}
}

private void MenuTimerOpen(object sender, EventArgs e)
{
if(menuBorder.Height == 150)
{
menuTimer.Stop();
}
else
{
menuBorder.Height = menuBorder.Height + 10;
}
}
If I have the menuBorder set to 150 when I begin debugging it has no problem closing, but has a problem opening. If I set it to 0 when I begin debugging then it has no problem opening, but has issues closing. Any ideas what I'm doing wrong here?
2 replies
CC#
Created by Estal on 1/20/2023 in #help
❔ Centering in dockpanel
I'm using the WPF Fontawesome package and am looking to center some of the font awesome icons in dock panels. I've tried running HorizontalAlignment="Center" on the dock and on the fa source and it still goes to the right. Does anyone know how to do this with DockPanel.Dock="Right" Setup?
2 replies
CC#
Created by Estal on 1/13/2023 in #help
❔ Replace multiple Lines
What I had before was
C#
string SessionName = File.ReadAllText(ConfigFile);
SessionName = SessionName.Replace("SessionName=\"" + LoadSetting(ConfigFile, "SessionName") + "\"", "SessionName=\"" + serverName.Text + "\"");
File.WriteAllText(ConfigFile, SessionName);

string Password = File.ReadAllText(ConfigFile);
Password = Password.Replace("JoinPassword=\"" + LoadSetting(ConfigFile, "JoinPassword") + "\"", "JoinPassword=\"" + serverPass.Text + "\"");
File.WriteAllText(ConfigFile, Password);
C#
string SessionName = File.ReadAllText(ConfigFile);
SessionName = SessionName.Replace("SessionName=\"" + LoadSetting(ConfigFile, "SessionName") + "\"", "SessionName=\"" + serverName.Text + "\"");
File.WriteAllText(ConfigFile, SessionName);

string Password = File.ReadAllText(ConfigFile);
Password = Password.Replace("JoinPassword=\"" + LoadSetting(ConfigFile, "JoinPassword") + "\"", "JoinPassword=\"" + serverPass.Text + "\"");
File.WriteAllText(ConfigFile, Password);
I now realize that I'm essentially opening the file every iteration. What I'm trying to figure out is how I can go through multiple lines and write them all at once time. If anyone knows it'd be appreciated. Gonna keep trying to figure it out for the time being.
12 replies
CC#
Created by Estal on 1/12/2023 in #help
❔ Updating text on main thread from running application WPF C Sharp
Heyo All. I have a wrapper I'm wrapping steamcmd in and the launcher is supposed to intercept the text output by steamcmd and put it into the launcher. The current code works
private void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
{
if (!String.IsNullOrEmpty(outLine.Data))
{

App.Current.Dispatcher.Invoke((Action)delegate
{
textbox.AppendText(outLine.Data + Environment.NewLine);
});
}
}
private void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
{
if (!String.IsNullOrEmpty(outLine.Data))
{

App.Current.Dispatcher.Invoke((Action)delegate
{
textbox.AppendText(outLine.Data + Environment.NewLine);
});
}
}
It works in the fact that it outputs and changes the textbox data on the main GUI. What I'm having issues with is it waits until the output is complete rather than a running line of information coming from the console. Does anyone by chance have any suggestions as to what I'm doing wrong?
6 replies