예제 #1
0
 protected void AddMessage(string msg, MessageType msgType, MessageSource src)
 {
     if (!m_bActive) return;
     string imageKey = "";
     switch (msgType)
     {
         case MessageType.Error:
             imageKey = "Error";
             break;
         case MessageType.Note:
             imageKey = "Info";
             break;
         case MessageType.Warning:
             imageKey = "Warning";
             break;
     }
     string source = "Global";
     if (src != null)
         source = src.Source;
     ListViewItem lvi = new ListViewItem(new string[] { source, msg }, imageKey);
     lvi.Tag = src;
     listView1.Items.Add(lvi);
     listView1.EnsureVisible(lvi.Index);
     //listView1.AutoScrollOffset = new Point(0);//(lvi.Position);
 }
예제 #2
0
 public void SetSource(MessageSource src)
 {
     sourceStack.Push(src);
 }
예제 #3
0
 public void Message(string msg, MessageType msgType, MessageSource src)
 {
     AddMessage(msg, msgType, src);
 }
예제 #4
0
 public void Message(string msg, MessageType msgType, MessageSource src)
 {
   Console.WriteLine(msg + ", " + msgType + ", " + src.Source);
 }
예제 #5
0
    public void SetRegex(Match rxnMatch, MessageSource source, string title)
    {
      Group grpComment = rxnMatch.Groups["Comment"];
      if (grpComment.Success)
        this.Comment = grpComment.Captures[0].Value.Trim();

      Group grpReactants = rxnMatch.Groups["Reactants"];
      if (grpReactants.Success)
        this.ParseReactants(grpReactants.Captures[0].Value, true);


      Group grpDirection = rxnMatch.Groups["Direction"];
      if (grpDirection.Success)
        this.DirectionString = grpDirection.Captures[0].Value;

      Group grpProducts = rxnMatch.Groups["Products"];
      if (grpProducts.Success)
        this.ParseProducts(grpProducts.Captures[0].Value, true);

      source.Source = title + ": " + this;

      Group grpExtent = rxnMatch.Groups["Extent"];
      if (grpExtent.Success)
        try
        {
          this.ParseExtent(grpExtent.Captures[0].Value);
        }
        catch (Exception ex)
        {
          Program.Log.Message("Unable to parse extent (" + grpExtent.Value + "). Reason: " + ex.Message, MessageType.Warning);
        }
      else
        Program.Log.Message("Extent not found for reaction", MessageType.Warning);

      Group grpSequence = rxnMatch.Groups["Sequence"];
      if (grpSequence.Success)
      {
        Match sequenceMatch = SimpleReaction.s_SequenceRegex.Match(grpSequence.Captures[0].Value.Trim());
        if (sequenceMatch.Success)
            m_nSequence = int.Parse(sequenceMatch.Groups["Value"].Captures[0].Value, CultureInfo.InvariantCulture);
        else
          Program.Log.Message("Unable to parse sequence '" + grpSequence.Value + "'", MessageType.Warning);
      }

      Group grpHOR = rxnMatch.Groups["HOR"];
      if (grpHOR.Success)
        try
        {
          this.ParseHOR(grpHOR.Captures[0].Value.Trim());
        }
        catch (Exception ex)
        {
          Program.Log.Message("Unable to parse HeatOfReaction '" + grpHOR.Value + "' Reason: " + ex.Message, MessageType.Warning);
        }

      this.Enabled = !rxnMatch.Groups["Disabled"].Success;
    }