Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ConsoleCommand : NotifyPropertyChanged, INotifyPropertyChanged
- {
- public ConsoleCommand(string ID)
- {
- this.ID = ID;
- CreationTime = HelpFunction.GetTimeNowPath();
- MessageList = new ObservableCollection<IConsoleMessage>();
- }
- public ConsoleCommand(string ID, eImage ImageType)
- {
- this.ID = ID;
- this.ImageType = ImageType;
- CreationTime = HelpFunction.GetTimeNowPath();
- MessageList = new ObservableCollection<IConsoleMessage>();
- }
- public ConsoleCommand(string ID, eImage ImageType, IConsoleMessage Message)
- {
- this.ID = ID;
- this.ImageType = ImageType;
- CreationTime = HelpFunction.GetTimeNowPath();
- MessageList = new ObservableCollection<IConsoleMessage>();
- MessageList.Add(Message);
- }
- public ConsoleCommand(string ID, eImage ImageType, IConsoleMessage[] Messages)
- {
- this.ID = ID;
- this.ImageType = ImageType;
- CreationTime = HelpFunction.GetTimeNowPath();
- MessageList = new ObservableCollection<IConsoleMessage>();
- if (Messages != null)
- foreach (IConsoleMessage m in Messages)
- MessageList.Add(m);
- }
- public string ID { get; set; }
- private eImage imageType;
- public eImage ImageType
- {
- get
- {
- return imageType;
- }
- set
- {
- imageType = value;
- OnPropertyChanged("ImageType");
- }
- }
- private string creationTime;
- public string CreationTime
- {
- get
- {
- return creationTime;
- }
- set
- {
- creationTime = value;
- OnPropertyChanged("CreationTime");
- }
- }
- private IList<IConsoleMessage> messageList;
- public IList<IConsoleMessage> MessageList
- {
- get
- {
- return messageList;
- }
- private set
- {
- messageList = value;
- OnPropertyChanged("MessageList");
- }
- }
- 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)
- {
- ConsoleMessage ErrorMessage = new ConsoleMessage(false, false, new CombinedText(new InformationText("Polecenie nieprawidłowe", InvalidForeground)));
- MessageList.Add(ErrorMessage);
- 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);
- }
- }
- MessageList.Add(Message);
- 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 ConsoleCommand Copy()
- {
- ConsoleCommand cmd = new ConsoleCommand(ID);
- cmd.CreationTime = CreationTime;
- cmd.ImageType = ImageType;
- cmd.ID = ID;
- foreach(IConsoleMessage m in MessageList)
- {
- cmd.Add(m.Copy());
- }
- return cmd;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement