I am currently making the switch from VB to C# AND Forms to WPF. I am looking for some help or direction on where to find how to interact with a WPF Window from a class library.
I have the Following SetUp:
And Then I have the following Class:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualBasic;
using System.Drawing;
using System.Windows.Media;
using C3D_Plug_In_UI.Windows;
using System.Windows.Controls;
namespace C3D_Plug_In_Library.Classes
{
public class MessageServices
{
public static void DisplayError(string messageTitle, string messageBody, Exception errorException)
{
DisplayMessageWindow(" - Error", messageTitle, messageBody, My.Resources.imgError, Color.FromRgb(74, 74, 77), errorException);
}
public static void DisplayAttention(string messageTitle, string messageBody)
{
DisplayMessageWindow(" - Attention", messageTitle, messageBody, My.Resources.imgAttention, Color.FromRgb(37, 64, 143), null/* TODO Change to default(_) if this is not a reference type */);
}
public static void DisplayInformation(string messageTitle, string messageBody)
{
DisplayMessageWindow(" - Information", messageTitle, messageBody, My.Resources.imgInformation, Color.FromRgb(37, 64, 143), null/* TODO Change to default(_) if this is not a reference type */);
}
public static void DisplayComplete(string messageTitle, string messageBody)
{
DisplayMessageWindow(" - Complete", messageTitle, messageBody, My.Resources.imgComplete, Color.FromRgb(37, 64, 143), null/* TODO Change to default(_) if this is not a reference type */);
}
private static void DisplayMessageWindow(string headerText, string messageTitle, string messageBody, Image messageImage, Color headerColor, Exception errorException)
{
string programTitle = "Program Title";
WinMessage winMessage = new WinMessage();
winMessage.LblHeader.Text = programTitle + headerText;
winMessage.PnlHeader.BackColor = headerColor;
winMessage.LblMessageTitle.Text = messageTitle;
winMessage.LblMessageBody.Text = messageBody;
winMessage.PicIcon.Image = messageImage;
if (errorException == null)
{
winMessage.Height = 160 + winMessage.LblMessageBody.Height / (double)2;
winMessage.TbxException.Visible = false;
}
else
{
winMessage.Height = 300 + winMessage.LblMessageBody.Height / (double)2;
winMessage.TbxException.Visible = true;
winMessage.TbxException.Text = errorException.ToString();
}
winMessage.ShowDialog();
}
}
}
I cannot seem to access the WPF window from the class. How should this be done or where can I learn the appropriate way to do this?