Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ConsoleMessage : NotifyPropertyChanged, INotifyPropertyChanged, IConsoleMessage
- {
- public ConsoleMessage()
- {
- IsExpanded = false;
- IsExpandedEnable = false;
- MessageList = new ObservableCollection<IConsoleMessage>();
- Information = null;
- }
- public ConsoleMessage(string Message, Brush Foreground)
- {
- IsExpanded = false;
- IsExpandedEnable = false;
- MessageList = new ObservableCollection<IConsoleMessage>();
- Information = null;
- Add(Message, Foreground);
- }
- public ConsoleMessage(CombinedText Message)
- {
- this.IsExpanded = false;
- this.IsExpandedEnable = false;
- MessageList = new ObservableCollection<IConsoleMessage>();
- Information = Message;
- }
- public ConsoleMessage(bool IsExpandedEnable)
- {
- this.IsExpanded = false;
- this.IsExpandedEnable = IsExpandedEnable;
- MessageList = new ObservableCollection<IConsoleMessage>();
- Information = null;
- }
- public ConsoleMessage(bool IsExpandedEnable, bool IsExpanded)
- {
- this.IsExpanded = IsExpanded;
- this.IsExpandedEnable = IsExpandedEnable;
- MessageList = new ObservableCollection<IConsoleMessage>();
- Information = null;
- }
- public ConsoleMessage(bool IsExpandedEnable, bool IsExpanded, CombinedText Header)
- {
- this.IsExpanded = IsExpanded;
- this.IsExpandedEnable = IsExpandedEnable;
- MessageList = new ObservableCollection<IConsoleMessage>();
- Information = Header;
- }
- public ConsoleMessage(bool IsExpandedEnable, bool IsExpanded, CombinedText Header, IConsoleMessage[] MessageList)
- {
- this.IsExpanded = IsExpanded;
- this.IsExpandedEnable = IsExpandedEnable;
- this.MessageList = new ObservableCollection<IConsoleMessage>();
- if(MessageList != null)
- foreach (IConsoleMessage m in MessageList)
- Add(m);
- Information = Header;
- }
- private bool isExpanded;
- public bool IsExpanded
- {
- get
- {
- return isExpanded;
- }
- set
- {
- isExpanded = value;
- OnPropertyChanged("IsExpanded");
- }
- }
- private bool isExpandedEnable;
- public bool IsExpandedEnable
- {
- get
- {
- return isExpandedEnable;
- }
- private set
- {
- isExpandedEnable = value;
- OnPropertyChanged("IsExpandedEnable");
- }
- }
- private CombinedText information;
- public CombinedText Information
- {
- get
- {
- return information;
- }
- set
- {
- information = value;
- OnPropertyChanged("Information");
- }
- }
- private IList<IConsoleMessage> messageList;
- public IList<IConsoleMessage> MessageList
- {
- get
- {
- return messageList;
- }
- private set
- {
- messageList = value;
- OnPropertyChanged("MessageList");
- }
- }
- public void SetHeader(CombinedText combinedText)
- {
- Information = combinedText;
- }
- public IConsoleMessage Add(IConsoleMessage Message)
- {
- if (Message == null)
- return null;
- MessageList.Add(Message);
- return Message;
- }
- public IConsoleMessage Add(string Message, Brush Foreground)
- {
- IConsoleMessage msg = new ConsoleMessage(new CombinedText(
- new InformationText(Message, Foreground)
- ));
- MessageList.Add(msg);
- return msg;
- }
- public void Add(IConsoleMessage[] Messages)
- {
- if (Messages == null)
- return;
- foreach (IConsoleMessage m in Messages)
- {
- MessageList.Add(m);
- }
- }
- public IConsoleMessage Add(CombinedText Message)
- {
- if (Message == null)
- return null;
- IConsoleMessage m = new ConsoleMessage(Message);
- MessageList.Add(m);
- return m;
- }
- public IConsoleMessage AddCommandInformation(CommandValue Command)
- {
- if (Command == null)
- return null;
- CombinedText Header = new CombinedText(new InformationText(((Command.Direction == eCommandDirection.Send) ? "Informacje o wysyłanym poleceniu:" : "Informacje o przychodzącym poleceniu:"), HeaderForeground, Command.ToString()));
- IConsoleMessage Message = new ConsoleMessage(true, false, Header);
- Message.Add(
- new ConsoleMessage(false, false, new CombinedText(new InformationText("Nazwa polecenia: "),
- new InformationText(Command.BaseCommand.Name, ((Command.IsValidate) ? ValidForeground : InvalidForeground), Command.BaseCommand.Description)))
- );
- if(Command.Arguments.Count() > 0)
- {
- Message.Add(
- new ConsoleMessage(true, false, new CombinedText(new InformationText("Argumenty: "),
- new InformationText(Command.BaseCommand.Name, HeaderForeground, Command.BaseCommand.Description)))
- );
- foreach (ArgumentValue a in Command.Arguments)
- {
- CombinedText Argument = new CombinedText();
- Argument.Add(" > ");
- Argument.Add(a.BaseArgument.Name, ValidForeground, a.BaseArgument.Description);
- if(a.HasValue)
- {
- Argument.Add(" = ");
- Argument.Add(a.Value, (a.Validate) ? ValidForeground : InvalidForeground);
- }
- Message.Add(Argument);
- }
- }
- return Message;
- }
- public IConsoleMessage AddInputCommand(CommandValue Command)
- {
- if (Command == null)
- return null;
- IConsoleMessage Message = new ConsoleMessage(new CombinedText(
- new InformationText("Wprowadzono: ", HeaderForeground),
- new InformationText(Command.ToString(), DefaultForeground)
- ));
- MessageList.Add(Message);
- return Message;
- }
- public IConsoleMessage Copy()
- {
- IConsoleMessage msg = new ConsoleMessage(IsExpandedEnable, IsExpanded, Information);
- foreach (IConsoleMessage m in MessageList)
- {
- IConsoleMessage newM = m.Copy();
- msg.Add(m.Copy());
- }
- return msg;
- }
- public static IConsoleMessage GenerateCommandInformation(CommandValue Command)
- {
- if (Command == null)
- {
- ConsoleMessage ErrorMessage = new ConsoleMessage(false, false, new CombinedText(new InformationText("Polecenie nieprawidłowe", InvalidForeground)));
- return ErrorMessage;
- }
- CombinedText Header = new CombinedText(new InformationText(((Command.Direction == eCommandDirection.Send) ? "Informacje o wysyłanym poleceniu:" : "Informacje o przychodzącym poleceniu:"), DefaultForeground, Command.ToString()));
- IConsoleMessage Message = new ConsoleMessage(true, false, Header);
- Message.Add(
- new ConsoleMessage(false, false, new CombinedText(new InformationText("Nazwa polecenia: "),
- new InformationText(Command.BaseCommand.Name, ((Command.IsValidate) ? ValidForeground : InvalidForeground), Command.BaseCommand.Description)))
- );
- if (Command.Arguments.Count() > 0)
- {
- Message.Add(
- new ConsoleMessage(true, false, new CombinedText(
- new InformationText("Argumenty: ")))
- );
- foreach (ArgumentValue a in Command.Arguments)
- {
- CombinedText Argument = new CombinedText();
- Argument.Add(" > ");
- Argument.Add(a.BaseArgument.Name, HeaderForeground, a.BaseArgument.Description);
- if (a.HasValue)
- {
- Argument.Add(" = ");
- Argument.Add(a.Value, (a.Validate) ? ValidForeground : InvalidForeground);
- }
- Message.Add(Argument);
- }
- }
- return Message;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement