/// <summary> /// Connect a logical stack to this GUI stack /// </summary> /// <param name="stack"></param> public void ConnectStack(StackObj stack) { _stack = stack; _stack.NoMoreCards += () => SetStackEmpty(true); if(_stack.TopCard == null) _stack.Draw(); card1.CardObject = _stack.TopCard; card1.CardObject.ShowBack = true; // Show back per default }
/// <summary> /// Initialize a new stack, this involves binding some events, watching the stack with the scaler /// (so that it resizes properly), and positioning the stack in the canvas. /// </summary> private void InitNewStack(StackObj replacement = null) { StackObj stack = null; if (replacement == null) stack = new StackObj(); else stack = replacement; stack11 = new Stack1(); stack11.ConnectStack(stack); CardSpawn.Children.Add(stack11); _scaler.Watch(stack11); btnNewStack.Click += (sender, args) => { stack.Destroy(); CardSpawn.Children.Remove(stack11); CardSpawn.Children.Clear(); NetworkedInitNewStack(); lstAces.Items.Clear(); }; stack11.card1.MouseDown += (sender, args) => NetworkedDrawNewCard(false); }
/// <summary> /// Aggregate all settings and finally generate the string that will be written to the text log. /// </summary> /// <returns></returns> public int GetPendingLevel() { Stack MessageStack = new Stack(); string ReturnString = ""; string PathString = ""; string FormattingString = ""; if (Indent > 0) { for (int i = 0; i < Indent; i++) { MessageStack.Push("INDENT"); } //if (Indent > 1) //{ // CurrentIndentLevel = CurrentIndentLevel - Indent + 1; //adjust, because INDENT;INDENT;INDENT really only causes one indent. //} //Indent = 0; } if (Unindent > 0) { for (int i = 0; i < Unindent; i++) { MessageStack.Push("UNINDENT"); } //Unindent = 0; } if (Root == true) { MessageStack.Push("ROOT"); //Root = false; } // Form the FormattingString foreach (Object StackObj in MessageStack) { //if (obj.ToString FormattingString = (StackObj.ToString() + ";" + FormattingString).TrimStart(';').TrimEnd(';'); } // Form ReturnString if (FormattingString == "" || FormattingString == null) { ReturnString = "<" + "TIMESTAMP:" + DateTime.Now.ToString(_TimestampFormat) + ">" + MessageStr; } else { ReturnString = "<" + FormattingString + ";TIMESTAMP:" + DateTime.Now.ToString(_TimestampFormat) + ">" + MessageStr; } //ResetDefaultValues(); indentModel.CalculatePendingLevel(ReturnString); //Console.WriteLine("GET_PENDING2: indentModel.CurrentLevel = " + indentModel.CurrentLevel + ", indentModel.PendingLevel = " + indentModel.PendingLevel); return(indentModel.PendingLevel + indentModel.CurrentLevel); //TOTAL PENDING LEVEL }
/// <summary> /// Aggregate all settings and finally generate the string that will be written to the text log. /// </summary> /// <returns></returns> public string FormMessageString(bool RICH_TEXT = true) { Stack MessageStack = new Stack(); string ReturnString = ""; string ReturnString2 = ""; string MessageString2 = ""; string SimpleMessageType = "INFO "; string PathString = ""; string FormattingString = ""; XmlConfigurationClass config = XmlConfigurationClass.Instance(); // Step 1: Write flags if (WatchdogStart == true) { MessageStack.Push("WATCHDOG_START"); Pass = false; } if (WatchdogEnd == true) { MessageStack.Push("WATCHDOG_END"); Pass = false; } if (Debug == true) { //MessageStack.Push("DEBUG"); Debug = false; SimpleMessageType = "DEBUG"; } if (Pass == true) { MessageStack.Push("PASS"); Pass = false; SimpleMessageType = "PASS "; } if (Fail == true) { MessageStack.Push("FAIL"); Fail = false; SimpleMessageType = "FAIL "; } if (Warning == true) { MessageStack.Push("WARNING"); Warning = false; SimpleMessageType = "WARN "; } if (Error == true) { MessageStack.Push("ERROR"); Error = false; SimpleMessageType = "ERROR"; } if (Fatal == true) { MessageStack.Push("ERROR"); Fatal = false; SimpleMessageType = "FATAL"; } if (Indent > 0) { for (int i = 0; i < Indent; i++) { MessageStack.Push("INDENT"); } if (Indent > 1) { CurrentIndentLevel = CurrentIndentLevel - Indent + 1; //adjust, because INDENT;INDENT;INDENT really only causes one indent. } Indent = 0; } if (Unindent > 0) { for (int i = 0; i < Unindent; i++) { MessageStack.Push("UNINDENT"); } Unindent = 0; } if (Root == true) { MessageStack.Push("ROOT"); Root = false; } if (RGB != null) { MessageStack.Push("RGB:" + RGB.red + "," + RGB.green + "," + RGB.blue); RGB = null; } if (DefaultRGB != null) { MessageStack.Push("DEFAULT_RGB:" + DefaultRGB.red + "," + DefaultRGB.green + "," + DefaultRGB.blue); DefaultRGB = null; } if ((Image != "") && (Image != null)) { MessageStack.Push("IMAGE:" + Image); Image = ""; } if ((File != "") && (File != null)) { MessageStack.Push("FILE:" + File); File = ""; } if ((Path != "") && (Path != null)) { MessageStack.Push("PATH:" + Path); Path = ""; } if ((Tab != "") && (Tab != null)) { MessageStack.Push("TAB:" + Tab); Tab = ""; } // Form the FormattingString foreach (Object StackObj in MessageStack) { //if (obj.ToString FormattingString = (StackObj.ToString() + ";" + FormattingString).TrimStart(';').TrimEnd(';'); } // Add line numbers if (ShowLineNumbers == true) { MessageStr = "Line " + LineNum++.ToString() + ": " + MessageStr; } else { LineNum++; } // Form ReturnString if (FormattingString == "" || FormattingString == null) { ReturnString = "<" + "TIMESTAMP:" + DateTime.Now.ToString(_TimestampFormat) + ">" + MessageStr; } else { ReturnString = "<" + FormattingString + ";TIMESTAMP:" + DateTime.Now.ToString(_TimestampFormat) + ">" + MessageStr; } MessageString2 = MessageStr; ResetDefaultValues(); if (EnableLogging) { indentModel.SimulateIndentations(ReturnString); } if (!RICH_TEXT) { for (int i = 0; i < CurrentIndentLevel; i++) { Padding = Padding + pad; } ReturnString2 = DateTime.Now.ToString(_TimestampFormat) + " | " + SimpleMessageType + " | " + Padding + MessageString2; Padding = ""; return(ReturnString2); } else { return(ReturnString); } }
/// <summary> /// Aggregate all settings and finally generate the string that will be written to the text log. /// </summary> /// <returns></returns> public string FormMessageString() { Stack MessageStack = new Stack(); string ReturnString = ""; string PathString = ""; string FormattingString = ""; // Step 1: Write flags if (WatchdogStart == true) { MessageStack.Push("WATCHDOG_START"); Pass = false; } if (WatchdogEnd == true) { MessageStack.Push("WATCHDOG_END"); Pass = false; } if (Pass == true) { MessageStack.Push("PASS"); Pass = false; } if (Fail == true) { MessageStack.Push("FAIL"); Fail = false; } if (Warning == true) { MessageStack.Push("WARNING"); Warning = false; } if (Error == true) { MessageStack.Push("ERROR"); Error = false; } if (Indent > 0) { for (int i = 0; i < Indent; i++) { MessageStack.Push("INDENT"); } if (Indent > 1) { CurrentIndentLevel = CurrentIndentLevel - Indent + 1; //adjust, because INDENT;INDENT;INDENT really only causes one indent. } Indent = 0; } if (Unindent > 0) { for (int i = 0; i < Unindent; i++) { MessageStack.Push("UNINDENT"); } Unindent = 0; } if (Root == true) { MessageStack.Push("ROOT"); Root = false; } if (RGB != null) { MessageStack.Push("RGB:" + RGB.red + "," + RGB.green + "," + RGB.blue); RGB = null; } if (DefaultRGB != null) { MessageStack.Push("DEFAULT_RGB:" + DefaultRGB.red + "," + DefaultRGB.green + "," + DefaultRGB.blue); DefaultRGB = null; } if ((Image != "") && (Image != null)) { MessageStack.Push("IMAGE:" + Image); Image = ""; } if ((File != "") && (File != null)) { MessageStack.Push("FILE:" + File); File = ""; } if ((Path != "") && (Path != null)) { MessageStack.Push("PATH:" + Path); Path = ""; } if ((Tab != "") && (Tab != null)) { MessageStack.Push("TAB:" + Tab); Tab = ""; } // Form the FormattingString foreach (Object StackObj in MessageStack) { //if (obj.ToString FormattingString = (StackObj.ToString() + ";" + FormattingString).TrimStart(';').TrimEnd(';'); } // Add line numbers if (ShowLineNumbers == true) { MessageStr = "Line " + LineNum++.ToString() + ": " + MessageStr; } else { LineNum++; } // Form ReturnString if (FormattingString == "" || FormattingString == null) { ReturnString = "<" + "TIMESTAMP:" + DateTime.Now.ToString(_TimestampFormat) + ">" + MessageStr; } else { ReturnString = "<" + FormattingString + ";TIMESTAMP:" + DateTime.Now.ToString(_TimestampFormat) + ">" + MessageStr; } ResetDefaultValues(); indentModel.SimulateIndentations(ReturnString); //Console.WriteLine("FORMAT_STR: indentModel.CurrentLevel = " + indentModel.CurrentLevel); return(ReturnString); }