So I'm getting a weird error... I followed some steps to create a CircularProgressBar in my WPF C# App. It works fine on my desktop, it doesn't on my laptop.
I create a WindowsFormsHost and make the Circular Progress Bar the Child. I then make it the children of a grid called ProgressGrid.
Anyway, The error just says "Unhandled exception has occured in a component in your application. If you click Continue, the application will ignore this error" It runs perfectly fine if I click continue mind you.
The error details say "System.ArgumentException: Parameter is not valid" it goes on to list pretty much everything I wrote. I thought it had something to do with Dispose()... Heres the Code:
var SelectAll =
(from a in dc.GetTable<SR>()
select a).ToList();
int all = SelectAll .Count();
var ByGroup =
(from a in dc.GetTable<SR>()
where a.GroupID == GroupID
orderby a.ID
select a).ToList();
int SelectedGroup = ByGroup .Count();
System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost();
CircularProgressBar.CircularProgressBar ProgressCircle = new CircularProgressBar.CircularProgressBar();
host.Child = ProgressCircle;
ProgressGrid.Children.Add(host);
if (ShallMarquee == 1 || FilterByThisDivision == TheEmployee.Division)
{
ProgressCircle.Style = System.Windows.Forms.ProgressBarStyle.Marquee;
}
else
{
ProgressCircle.Style = System.Windows.Forms.ProgressBarStyle.Blocks;
}
ProgressCircle.MarqueeAnimationSpeed = 4000;
ProgressCircle.Text = Convert.ToString(NumOf + "%");
ProgressCircle.SubscriptText = "";
ProgressCircle.SuperscriptText = "";
ProgressCircle.Font = new Font("Arial", 22);
ProgressCircle.ProgressWidth = 10;
ProgressCircle.SuperscriptColor = System.Drawing.Color.Black;
ProgressCircle.ProgressColor = System.Drawing.ColorTranslator.FromHtml(MainColor);
System.Windows.Media.Color StandardBackgroundBlue = (System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString(BackgroundColor);
var drawingcolor = System.Drawing.Color.FromArgb(StandardBackgroundBlue.A, StandardBackgroundBlue.R, StandardBackgroundBlue.G, StandardBackgroundBlue.B);
ProgressCircle.BackColor = drawingcolor;
ProgressCircle.InnerColor = drawingcolor;
ProgressCircle.OuterColor = System.Drawing.Color.LightGray;
ProgressCircle.ForeColor = System.Drawing.Color.Black;
ProgressCircle.Value = NumOf;
ProgressCircle.Maximum = TotalNum;
//END CIRCLE
For now the gridjust displays a string as the number while I adjust things so you can ignore that. I also read something about GDI but I'm a bit lost.
P.S. I should note it also says "Invalid Parameter" which it most certainly is not.
P.P.S. I developed this on a Windows 7 64 bit. My laptop is a Windows 10 64bit. But it also doesn't work on my brothers Windows 7 64 bit. If that helps any...
Okay, so I was able to make it work. I'm not "exactly" sure why though. I loaded the grid that contains the WindowsFormsHost Grid with visibility set to false first and after it loaded I set it to true. For whatever reason, it works this way. If anyone could think of why that would be awesome. This way does work though!