/// <summary>
        /// The Selected has changed.
        /// </summary>
        /// <param name="control"></param>
        /// <param name="selectedIndex"></param>
        public void OnTextChanged(Control control, string text)
        {
            // first attempt casting the control as LabelTextBoxControl
            LabelTextBoxControl sender = control as LabelTextBoxControl;

            // if the sender and Options objects both exist
            if (NullHelper.Exists(sender, Options))
            {
                // if this is the ResolutionControl
                if (sender.Name == ResolutionControl.Name)
                {
                    // Set the Resolution
                    Options.Resolution = NumericHelper.ParseInteger(text, 0, -1);
                }
            }

            // now try LabelTextBoxBrowserControl
            LabelTextBoxBrowserControl sender2 = control as LabelTextBoxBrowserControl;

            // if the sender2 and Options objects both exist
            if (NullHelper.Exists(sender2, Options))
            {
                // verify we have the correct control
                if (sender2.Name == DirectoryControl.Name)
                {
                    // Set the Directory
                    Options.Directory = text;
                }
            }

            // Enable or disable the StartButton
            UIControl();
        }
Beispiel #2
0
        /// <summary>
        /// This event is fired BEFORE the collection is initialized.
        /// An example of this is the replacements (plural) node.
        /// </summary>
        /// <param name="xmlNode"></param>
        /// <returns>True if cancelled else false if not.</returns>
        public bool Parsing(XmlNode xmlNode)
        {
            // initial value
            bool cancel = false;

            try
            {
                // set the commentID
                int commentID = NumericHelper.ParseInteger(xmlNode.ParentNode.ChildNodes[0].FormattedNodeValue, 0, -1);

                // if this is the Comment being sought
                if (commentID != this.CommentID)
                {
                    // Set the value for the cancel to true
                    cancel = true;
                }
            }
            catch (Exception error)
            {
                // for debugging only
                string err = error.ToString();
            }

            // return value
            return(cancel);
        }
        /// <summary>
        /// This method is used to parse Response objects.
        /// </summary>
        public Response ParseResponse(ref Response response, XmlNode xmlNode)
        {
            // if the response object exists and the xmlNode exists
            if ((response != null) && (xmlNode != null))
            {
                // get the full name of this node
                string fullName = xmlNode.GetFullName();

                // Check the name of this node to see if it is mapped to a property
                switch (fullName)
                {
                case "ResponseDoc.response.entitylineNumber":

                    // Set the value for response.EntitylineNumber
                    response.EntitylineNumber = NumericHelper.ParseInteger(xmlNode.FormattedNodeValue, 0, -1);

                    // required
                    break;

                case "ResponseDoc.response.entityMark":

                    // Set the value for response.EntityMark
                    response.EntityMark = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "ResponseDoc.response.entityUid":

                    // Set the value for response.EntityUID
                    response.EntityUID = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "ResponseDoc.response.statusCode":

                    // Set the value for response.StatusCode
                    response.StatusCode = xmlNode.FormattedNodeValue;

                    // required
                    break;
                }

                // if there are ChildNodes
                if (xmlNode.HasChildNodes)
                {
                    // iterate the child nodes
                    foreach (XmlNode childNode in xmlNode.ChildNodes)
                    {
                        // append to this Response
                        response = ParseResponse(ref response, childNode);
                    }
                }
            }

            // return value
            return(response);
        }
        /// <summary>
        /// This method is used to parse Note objects.
        /// </summary>
        public Note ParseNote(ref Note note, XmlNode xmlNode)
        {
            // if the note object exists and the xmlNode exists
            if ((note != null) && (xmlNode != null))
            {
                // get the full name of this node
                string fullName = xmlNode.GetFullName();

                // Check the name of this node to see if it is mapped to a property
                switch (fullName)
                {
                case "Notes.Note.Description":

                    // Set the value for note.Description
                    note.Description = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "Notes.Note.Id":

                    // Set the value for note.Id
                    note.Id = NumericHelper.ParseInteger(xmlNode.FormattedNodeValue, 0, -1);

                    // required
                    break;

                case "Notes.Note.Priority":

                    // Set the value for note.Priority
                    note.Priority = EnumHelper.GetEnumValue <NoteBoard.Model.PriorityEnum>(xmlNode.FormattedNodeValue, NoteBoard.Model.PriorityEnum.Normal);

                    // required
                    break;

                case "Notes.Note.Title":

                    // Set the value for note.Title
                    note.Title = xmlNode.FormattedNodeValue;

                    // required
                    break;
                }

                // if there are ChildNodes
                if (xmlNode.HasChildNodes)
                {
                    // iterate the child nodes
                    foreach (XmlNode childNode in xmlNode.ChildNodes)
                    {
                        // append to this Note
                        note = ParseNote(ref note, childNode);
                    }
                }
            }

            // return value
            return(note);
        }
Beispiel #5
0
        /// <summary>
        /// This class is used to Shuffle a list of type 'T'.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="list"></param>
        public static List <T> Shuffle <T>(this IList <T> list)
        {
            // List
            List <T> shuffledList = new List <T>();

            // Use the RNGCryptoServiceProvider to create random zeros or 1
            RNGCryptoServiceProvider crypto = new RNGCryptoServiceProvider();

            // Create the byte array that serves asa
            byte[] container = new byte[1];

            // if the list exists
            if (list != null)
            {
                // we can't use the collection count it changes
                int listCount = list.Count;

                // now we have to 'Randomly' pull items and add them to the end results
                for (int x = 0; x < listCount; x++)
                {
                    // Fill the topOrBottom byteArray
                    crypto.GetBytes(container);

                    // Get the value of topOrBottom
                    object randomByte = container.GetValue(0);

                    // if the randomByte exists
                    if (NullHelper.Exists(randomByte))
                    {
                        // local
                        int randomValue = NumericHelper.ParseInteger(randomByte.ToString(), 0, -1);

                        // set the randomIndex to the modulas of the the listCount
                        int randomIndex = randomValue % list.Count;

                        // verify the index is in range (should always be true)
                        if ((randomIndex >= 0) && (randomIndex < list.Count))
                        {
                            // Add the card from the top half of the list
                            shuffledList.Add(list[randomIndex]);
                        }

                        // Remove the item from the sourceList now that we have it
                        list.RemoveAt(randomIndex);
                    }
                }
            }

            // return value
            return(shuffledList);
        }
Beispiel #6
0
        /// <summary>
        /// This method is used to parse StoredProcedureParameter objects.
        /// </summary>
        public StoredProcedureParameter ParseStoredProcedureParameter(ref StoredProcedureParameter storedProcedureParameter, XmlNode xmlNode)
        {
            // if the storedProcedureParameter object exists and the xmlNode exists
            if ((storedProcedureParameter != null) && (xmlNode != null))
            {
                // get the full name of this node
                string fullName = xmlNode.GetFullName();

                // Check the name of this node to see if it is mapped to a property
                switch (fullName)
                {
                case "Database.StoredProcedures.StoredProcedure.Parameters.StoredProcedureParameter.DataType":

                    // Set the value for storedProcedureParameter.DataType
                    storedProcedureParameter.DataType = EnumHelper.GetEnumValue <DataManager.DataTypeEnum>(xmlNode.FormattedNodeValue, DataManager.DataTypeEnum.NotSupported);

                    // required
                    break;

                case "Database.StoredProcedures.StoredProcedure.Parameters.StoredProcedureParameter.Length":

                    // Set the value for storedProcedureParameter.Length
                    storedProcedureParameter.Length = NumericHelper.ParseInteger(xmlNode.FormattedNodeValue, 0, -1);

                    // required
                    break;

                case "Database.StoredProcedures.StoredProcedure.Parameters.StoredProcedureParameter.ParameterName":

                    // Set the value for storedProcedureParameter.ParameterName
                    storedProcedureParameter.ParameterName = xmlNode.FormattedNodeValue;

                    // required
                    break;
                }

                // if there are ChildNodes
                if (xmlNode.HasChildNodes)
                {
                    // iterate the child nodes
                    foreach (XmlNode childNode in xmlNode.ChildNodes)
                    {
                        // append to this StoredProcedureParameter
                        storedProcedureParameter = ParseStoredProcedureParameter(ref storedProcedureParameter, childNode);
                    }
                }
            }

            // return value
            return(storedProcedureParameter);
        }
        /// <summary>
        /// This method is used to parse IgnoreFolderException objects.
        /// </summary>
        public IgnoreFolderException ParseIgnoreFolderException(ref IgnoreFolderException ignoreFolderException, XmlNode xmlNode)
        {
            // if the ignoreFolderException object exists and the xmlNode exists
            if ((ignoreFolderException != null) && (xmlNode != null))
            {
                // get the full name of this node
                string fullName = xmlNode.GetFullName();

                // Check the name of this node to see if it is mapped to a property
                switch (fullName)
                {
                case "Shipment.Options.DoNotCopyContentFolders.Folder.Exceptions.Exception.ExceptionType":

                    // Set the value for ignoreFolderException.ExceptionTypeValue
                    ignoreFolderException.ExceptionTypeValue = NumericHelper.ParseInteger(xmlNode.FormattedNodeValue, 0, -1);

                    // required
                    break;

                case "Shipment.Options.DoNotCopyContentFolders.Folder.Exceptions.Exception.Name":

                    // Set the value for ignoreFolderException.Name
                    ignoreFolderException.Name = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "Shipment.Options.DoNotCopyContentFolders.Folder.Exceptions.Exception.Text":

                    // Set the value for ignoreFolderException.Text
                    ignoreFolderException.Text = xmlNode.FormattedNodeValue;

                    // required
                    break;
                }

                // if there are ChildNodes
                if (xmlNode.HasChildNodes)
                {
                    // iterate the child nodes
                    foreach (XmlNode childNode in xmlNode.ChildNodes)
                    {
                        // append to this IgnoreFolderException
                        ignoreFolderException = ParseIgnoreFolderException(ref ignoreFolderException, childNode);
                    }
                }
            }

            // return value
            return(ignoreFolderException);
        }
Beispiel #8
0
        /// <summary>
        /// This method returns the Bet Amount
        /// </summary>
        internal double GetBetAmount()
        {
            // initial value
            double betAmount = 0;

            // Remove any dollar signs or commas if present
            string betAmountText = this.BetAmountTextBox.Text.Replace("$", "").Replace(",", "");

            // set the return value
            betAmount = NumericHelper.ParseInteger(betAmountText, 0, -1);

            // return value
            return(betAmount);
        }
Beispiel #9
0
        /// <summary>
        /// This event registers with the chat server
        /// </summary>
        public void RegisterWithServer()
        {
            SubscriberCallback callback = new SubscriberCallback(SubscriberName);

            callback.Callback = Listen;
            callback.Name     = SubscriberName;

            // Get a message back
            SubscriberMessage message = SubscriberService.Subscribe(callback);

            // if message.Text exists and equals Subscribed
            if ((NullHelper.Exists(message)) && (message.HasText) && (TextHelper.IsEqual(message.Text, "Subscribed")))
            {
                // Set to true
                Connected = true;

                // Set the Id the Server assigned
                this.Id = message.ToId;
            }

            // Convert the Subscribers to Names
            this.Names = SubscriberService.GetSubscriberNames();

            // get the count
            int count = NumericHelper.ParseInteger(message.Data.ToString(), 0, -1);

            // if there are two people online or more
            if (count > 1)
            {
                // send a message to everyone else this user has joined
                SubscriberMessage newMessage = new SubscriberMessage();

                // set the text
                newMessage.FromId          = Id;
                newMessage.FromName        = SubscriberName;
                newMessage.Text            = SubscriberName + " has joined the conversation.";
                newMessage.ToId            = Guid.Empty;
                newMessage.ToName          = "Room";
                newMessage.IsSystemMessage = true;

                // Send the message
                SubscriberService.BroadcastMessage(newMessage);

                // 6.5.2020: Get the Messages as you connect now
                this.Messages = SubscriberService.GetBroadcastMessages(this.Id, DisplayMessagesCount);
            }

            // Update
            Refresh();
        }
        /// <summary>
        /// This method Parse Numbers
        /// </summary>
        public static void ParseNumbers(string text, ref int number1, ref int number2, ref int number3, ref int number4)
        {
            // locals
            int count = 0;

            // only use a space as a delimiter character
            char[] delimiterChars = { ' ' };

            // if the words exists
            List <Word> words = WordParser.GetWords(text, delimiterChars);

            // If the words collection exists and has one or more items
            if (ListHelper.HasOneOrMoreItems(words))
            {
                // Iterate the collection of Word objects
                foreach (Word word in words)
                {
                    // if this word is a number
                    if (NumericHelper.IsNumeric(word.Text))
                    {
                        // Increment the value for count
                        count++;

                        // if this is the firstNumber
                        if (count == 1)
                        {
                            // set number1
                            number1 = NumericHelper.ParseInteger(word.Text, -1000, -1001);
                        }
                        else if (count == 2)
                        {
                            // set number2
                            number2 = NumericHelper.ParseInteger(word.Text, -1000, -1001);
                        }
                        else if (count == 3)
                        {
                            // set number3
                            number3 = NumericHelper.ParseInteger(word.Text, -1000, -1001);
                        }
                        else if (count == 4)
                        {
                            // set number4
                            number4 = NumericHelper.ParseInteger(word.Text, -1000, -1001);
                        }
                    }
                }
            }
        }
Beispiel #11
0
        /// <summary>
        /// This method returns the Game Manager
        /// </summary>
        private GameManager CaptureGameManager()
        {
            // initial value
            GameManager gameManager = null;

            // If the Table object exists
            if (this.HasTable)
            {
                // Create the return value
                gameManager = new GameManager(NumericHelper.ParseInteger(Properties.Resources.TimesToShuffle, 0, -1), this.Table);

                // Capture the Seated Players
                gameManager.Players = this.SelectPlayersControl.CaptureSeatedPlayers();

                // Capture the House Rules
                gameManager.HouseRules = this.OptionsControl.CaptureHouseRules();
                gameManager.HouseRules.SaveSettingsOnThisComputer = this.SaveSettingsRadioButton.Checked;
            }

            // return value
            return(gameManager);
        }
Beispiel #12
0
        /// <summary>
        /// This method is used to parse CodeComment objects.
        /// </summary>
        public CodeComment ParseCodeComment(ref CodeComment codeComment, XmlNode xmlNode)
        {
            // if the codeComment object exists and the xmlNode exists
            if ((codeComment != null) && (xmlNode != null))
            {
                // get the full name of this node
                string fullName = xmlNode.GetFullName();

                // Check the name of this node to see if it is mapped to a property
                switch (fullName)
                {
                case "CommentDictionary.CommentItem.Comment":

                    // Set the value for codeComment.Comment
                    codeComment.Comment = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "CommentDictionary.CommentItem.HasReplacements":

                    // Set the value for codeComment.Comment
                    codeComment.HasReplacements = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "CommentDictionary.CommentItem.ID":

                    // Set the value for codeComment.Name
                    codeComment.ID = NumericHelper.ParseInteger(xmlNode.FormattedNodeValue, 0, -1);

                    // required
                    break;

                case "CommentDictionary.CommentItem.Name":

                    // Set the value for codeComment.Name
                    codeComment.Name = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "CommentDictionary.CommentItem.Pattern":

                    // Set the value for codeComment.Pattern
                    codeComment.Pattern = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "CommentDictionary.CommentItem.TargetPattern":

                    // Set the value for codeComment.TargetPattern
                    codeComment.TargetPattern = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "CommentDictionary.CommentItem.TargetPattern2":

                    // Set the value for codeComment.TargetPattern2
                    codeComment.TargetPattern2 = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "CommentDictionary.CommentItem.Type":

                    // Set the value for codeComment.CommentType
                    // codeComment.CommentType = // this field must be parsed manually.

                    // required
                    break;
                }

                // if there are ChildNodes
                if (xmlNode.HasChildNodes)
                {
                    // iterate the child nodes
                    foreach (XmlNode childNode in xmlNode.ChildNodes)
                    {
                        // append to this CodeComment
                        codeComment = ParseCodeComment(ref codeComment, childNode);
                    }
                }
            }

            // return value
            return(codeComment);
        }
        /// <summary>
        /// This method Set Update Parameters
        /// </summary>
        public static void SetUpdateParameters(string updateText, ref PixelQuery pixelQuery)
        {
            // if the updateText exists and the pixelQuery object exists
            if ((TextHelper.Exists(updateText)) && (NullHelper.Exists(pixelQuery)))
            {
                // if the updateText starts with the word set (else this is not a proper BQL Update query).
                if (updateText.StartsWith("set"))
                {
                    // only use a space as a delimiter character
                    char[] delimiterChars = { ' ' };

                    // Get a list of words from this text
                    List <Word> words = WordParser.GetWords(updateText);

                    // If the words collection exists and has one or more items
                    if (ListHelper.HasOneOrMoreItems(words))
                    {
                        // if there are six words.
                        // Example: Set Color 100 150 200 40 - (Red = 100, Green = 150, Blue = 200, Alpha = 40)
                        if (words.Count == 6)
                        {
                            // Set to red
                            pixelQuery.Red   = NumericHelper.ParseInteger(words[2].Text, -1, -2);
                            pixelQuery.Green = NumericHelper.ParseInteger(words[3].Text, -1, -2);
                            pixelQuery.Blue  = NumericHelper.ParseInteger(words[4].Text, -1, -2);
                            pixelQuery.Alpha = NumericHelper.ParseInteger(words[5].Text, -1, -2);

                            // verify everything is valid
                            if ((pixelQuery.Red >= 0) && (pixelQuery.Green >= 0) && (pixelQuery.Red >= 0) && (pixelQuery.Alpha >= 0))
                            {
                                // Set the Color
                                pixelQuery.Color = Color.FromArgb(pixelQuery.Alpha, pixelQuery.Red, pixelQuery.Green, pixelQuery.Blue);
                            }
                        }
                        // if there are 5 words
                        // Example: Set Color 100 150 200 - (Red = 100, Green = 150, Blue = 200, Alpha = 255 default value)
                        else if (words.Count == 5)
                        {
                            // Set to red
                            pixelQuery.Red   = NumericHelper.ParseInteger(words[2].Text, -1, -2);
                            pixelQuery.Green = NumericHelper.ParseInteger(words[3].Text, -1, -2);
                            pixelQuery.Blue  = NumericHelper.ParseInteger(words[4].Text, -1, -2);
                            pixelQuery.Alpha = 255;

                            // verify everything is valid
                            if ((pixelQuery.Red >= 0) && (pixelQuery.Green >= 0) && (pixelQuery.Red >= 0) && (pixelQuery.Alpha >= 0))
                            {
                                // Set the Color
                                pixelQuery.Color = Color.FromArgb(pixelQuery.Alpha, pixelQuery.Red, pixelQuery.Green, pixelQuery.Blue);
                            }

                            // Set the Color
                            pixelQuery.Color = Color.FromArgb(pixelQuery.Alpha, pixelQuery.Red, pixelQuery.Green, pixelQuery.Blue);
                        }
                        // if there are 3 words
                        // Example: Set Color Orchid (the color must be a named color)
                        else if (words.Count == 3)
                        {
                            // Set the Color
                            pixelQuery.Color = Color.FromName(words[2].Text);
                            pixelQuery.Alpha = 255;
                        }
                    }
                }
            }
        }
Beispiel #14
0
        /// <summary>
        /// This method is used to parse DataField objects.
        /// </summary>
        public DataField ParseDataField(ref DataField dataField, XmlNode xmlNode)
        {
            // if the dataField object exists and the xmlNode exists
            if ((dataField != null) && (xmlNode != null))
            {
                // get the full name of this node
                string fullName = xmlNode.GetFullName();

                // Check the name of this node to see if it is mapped to a property
                switch (fullName)
                {
                case "Database.Tables.DataTable.Fields.DataField.DataType":

                    // Set the value for dataField.DataType
                    dataField.DataType = EnumHelper.GetEnumValue <DataJuggler.Net.DataManager.DataTypeEnum>(xmlNode.FormattedNodeValue, DataJuggler.Net.DataManager.DataTypeEnum.NotSupported);

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.DBDataType":

                    // Set the value for dataField.DBDataType
                    dataField.DBDataType = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.DBFieldName":

                    // Set the value for dataField.DBFieldName
                    dataField.DBFieldName = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.DecimalPlaces":

                    // Set the value for dataField.DecimalPlaces
                    dataField.DecimalPlaces = NumericHelper.ParseInteger(xmlNode.FormattedNodeValue, 0, -1);

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.DefaultValue":

                    // Set the value for dataField.DefaultValue
                    dataField.DefaultValue = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.EnumDataTypeName":

                    // Set the value for dataField.EnumDataTypeName
                    dataField.EnumDataTypeName = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.FieldName":

                    // Set the value for dataField.FieldName
                    dataField.FieldName = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.HasDefault":

                    // Set the value for dataField.HasDefault
                    dataField.HasDefault = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.IsAutoIncrement":

                    // Set the value for dataField.IsAutoIncrement
                    dataField.IsAutoIncrement = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.IsEnumeration":

                    // Set the value for dataField.IsEnumeration
                    dataField.IsEnumeration = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.IsNullable":

                    // Set the value for dataField.IsNullable
                    dataField.IsNullable = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.IsReadOnly":

                    // Set the value for dataField.IsReadOnly
                    dataField.IsReadOnly = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.Precision":

                    // Set the value for dataField.Precision
                    dataField.Precision = NumericHelper.ParseInteger(xmlNode.FormattedNodeValue, 0, -1);

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.PrimaryKey":

                    // Set the value for dataField.PrimaryKey
                    dataField.PrimaryKey = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.Required":

                    // Set the value for dataField.Required
                    dataField.Required = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.Scale":

                    // Set the value for dataField.Scale
                    dataField.Scale = NumericHelper.ParseInteger(xmlNode.FormattedNodeValue, 0, -1);

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.Size":

                    // Set the value for dataField.Size
                    dataField.Size = NumericHelper.ParseInteger(xmlNode.FormattedNodeValue, 0, -1);

                    // required
                    break;
                }

                // if there are ChildNodes
                if (xmlNode.HasChildNodes)
                {
                    // iterate the child nodes
                    foreach (XmlNode childNode in xmlNode.ChildNodes)
                    {
                        // append to this DataField
                        dataField = ParseDataField(ref dataField, childNode);
                    }
                }
            }

            // return value
            return(dataField);
        }
        /// <summary>
        /// This method returns the Number
        /// </summary>
        public int PullNumber()
        {
            // initial value
            int pullNumber = -3;

            try
            {
                // locals
                bool firstNonZeroPulled = false;
                int  temp = 0;

                // if the Shufflers exist
                if (this.HasShufflers)
                {
                    // Create a string builder
                    StringBuilder sb = new StringBuilder();

                    // Iterate the collection of RandomShuffler objects
                    foreach (RandomShuffler shuffler in Shufflers)
                    {
                        // Pull the next value
                        temp = shuffler.PullNextItem();

                        // if we already have the first non zero
                        if (firstNonZeroPulled)
                        {
                            // Add this item
                            sb.Append(temp);
                        }
                        else
                        {
                            // If the value for temp is greater than zero
                            if (temp > 0)
                            {
                                // Set to true
                                firstNonZeroPulled = true;

                                // Add this item
                                sb.Append(temp);
                            }
                            else
                            {
                                // do nothing for preceding zeros
                            }
                        }
                    }

                    // Get a temporary string to hold the number
                    string tempString = sb.ToString();

                    // Now set the return value
                    pullNumber = NumericHelper.ParseInteger(tempString, -1, -2);

                    // if this is not the defaultValue or the errorValue
                    if (pullNumber >= 0)
                    {
                        // Increment the value for pullNumber because the needed range is 1 - 1,000,000 and this code returns 0 - 999,999
                        pullNumber++;
                    }

                    // if the number is out of range
                    if ((pullNumber < this.MinValue) || (pullNumber > this.MaxValue))
                    {
                        // if raise error is supposed to happen
                        if (this.NumberOutOfRangeOption == NumberOutOfRangeOptionEnum.RaiseError)
                        {
                            // Raise the error
                            throw new Exception("The number generated " + pullNumber + " is out of range.");
                        }
                        else if (this.NumberOutOfRangeOption == NumberOutOfRangeOptionEnum.Repull)
                        {
                            // Increment the value for this
                            this.RepullNumber++;

                            // Do not try more than 10 times in case bad min and max values were set
                            if (this.RepullNumber < 11)
                            {
                                // Call this method recursively
                                pullNumber = PullNumber();
                            }
                        }
                        else if (this.NumberOutOfRangeOption == NumberOutOfRangeOptionEnum.ReturnModulus)
                        {
                            // if the MaxValue is set
                            if (this.MaxValue > 0)
                            {
                                // Get the modulus
                                pullNumber = (pullNumber % this.MaxValue) + 1;
                            }
                        }
                    }
                }
            }
            catch (Exception error)
            {
                // Set to a bad value to indicate an error
                pullNumber = -4;

                // Write to the error console
                DebugHelper.WriteDebugError("PullNumber", "LargeNumberShuffler", error);
            }

            // return value
            return(pullNumber);
        }
Beispiel #16
0
        /// <summary>
        /// This method is used to parse DataIndex objects.
        /// </summary>
        public DataIndex ParseDataIndex(ref DataIndex dataIndex, XmlNode xmlNode)
        {
            // if the dataIndex object exists and the xmlNode exists
            if ((dataIndex != null) && (xmlNode != null))
            {
                // get the full name of this node
                string fullName = xmlNode.GetFullName();

                // Check the name of this node to see if it is mapped to a property
                switch (fullName)
                {
                case "Database.Tables.DataTable.Indexes.DataIndex.AllowPageLocks":

                    // Set the value for dataIndex.AllowPageLocks
                    dataIndex.AllowPageLocks = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.AllowRowLocks":

                    // Set the value for dataIndex.AllowRowLocks
                    dataIndex.AllowRowLocks = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.Clustered":

                    // Set the value for dataIndex.Clustered
                    dataIndex.Clustered = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.DataSpaceID":

                    // Set the value for dataIndex.DataSpaceID
                    dataIndex.DataSpaceID = NumericHelper.ParseInteger(xmlNode.FormattedNodeValue, 0, -1);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.FillFactor":

                    // Set the value for dataIndex.FillFactor
                    dataIndex.FillFactor = NumericHelper.ParseInteger(xmlNode.FormattedNodeValue, 0, -1);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.FilterDefinition":

                    // Set the value for dataIndex.FilterDefinition
                    dataIndex.FilterDefinition = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.HasFilter":

                    // Set the value for dataIndex.HasFilter
                    dataIndex.HasFilter = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.IgnoreDuplicateKey":

                    // Set the value for dataIndex.IgnoreDuplicateKey
                    dataIndex.IgnoreDuplicateKey = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.IndexID":

                    // Set the value for dataIndex.IndexID
                    dataIndex.IndexID = NumericHelper.ParseInteger(xmlNode.FormattedNodeValue, 0, -1);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.IndexType":

                    // Set the value for dataIndex.IndexType
                    dataIndex.IndexType = EnumHelper.GetEnumValue <DataJuggler.Net.Enumerations.IndexTypeEnum>(xmlNode.FormattedNodeValue, DataJuggler.Net.Enumerations.IndexTypeEnum.Unknown);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.IsDisabled":

                    // Set the value for dataIndex.IsDisabled
                    dataIndex.IsDisabled = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.IsHypothetical":

                    // Set the value for dataIndex.IsHypothetical
                    dataIndex.IsHypothetical = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.IsPadded":

                    // Set the value for dataIndex.IsPadded
                    dataIndex.IsPadded = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.IsPrimary":

                    // Set the value for dataIndex.IsPrimary
                    dataIndex.IsPrimary = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.IsUnique":

                    // Set the value for dataIndex.IsUnique
                    dataIndex.IsUnique = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.IsUniqueConstraint":

                    // Set the value for dataIndex.IsUniqueConstraint
                    dataIndex.IsUniqueConstraint = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.Name":

                    // Set the value for dataIndex.Name
                    dataIndex.Name = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.ObjectID":

                    // Set the value for dataIndex.ObjectID
                    dataIndex.ObjectID = NumericHelper.ParseInteger(xmlNode.FormattedNodeValue, 0, -1);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.TypeDescription":

                    // Set the value for dataIndex.TypeDescription
                    dataIndex.TypeDescription = xmlNode.FormattedNodeValue;

                    // required
                    break;
                }

                // if there are ChildNodes
                if (xmlNode.HasChildNodes)
                {
                    // iterate the child nodes
                    foreach (XmlNode childNode in xmlNode.ChildNodes)
                    {
                        // append to this DataIndex
                        dataIndex = ParseDataIndex(ref dataIndex, childNode);
                    }
                }
            }

            // return value
            return(dataIndex);
        }
Beispiel #17
0
        /// <summary>
        /// This method returns the GameManager. It first attempts to load the values from the settings
        /// and if not found the default GameManager.Options and GameManager.Players are created.
        /// </summary>
        private GameManager LoadGameManager()
        {
            // initial value
            GameManager gameManager = null;

            // local so the Settings file only has to be loaded once
            SecureUserData security = new SecureUserData();

            // this is used during development so everything default is restored, this has to be taken out or commented out
            // security.LastSavedDate = new DateTime(1900, 1, 1);

            // save (this needs to be taken out or commented out also)
            // security.Save();

            // We must load our five PlayerControls
            List <BlackJackPlayerControl> playerControls = GetPlayerControls();

            // if the security object has a LastSavedDate we can load a GameManager from it
            if (security.HasLastSavedDate)
            {
                // convert the settings to a gameManager object
                gameManager = SecureUserDataFactory.Export(security, playerControls, this);
            }
            else
            {
                // Create a new instance of a 'GameManager' object.
                gameManager = new GameManager(NumericHelper.ParseInteger(Properties.Resources.TimesToShuffle, 0, -1), this);

                // Now we must load the Options and Players from the Settings
                gameManager.HouseRules = Options.CreateDefault();

                // Load the players from the Settings or create them
                gameManager.Players = CreateDefaultPlayers(gameManager.HouseRules);
            }

            //// Create a new instance of an 'OptionsForm' object.
            OptionsForm optionsForm = new OptionsForm(this);

            // Setup the form
            optionsForm.Setup(gameManager);

            //// Show the dialog
            optionsForm.ShowDialog();

            // if the user did not cancel
            if (!optionsForm.UserCancelled)
            {
                // set the return value
                this.GameManager = optionsForm.GameManager;
            }
            else
            {
                // if the GameManager does not exist
                if (!this.HasGameManager)
                {
                    // Close this app
                    Environment.Exit(0);
                }
            }

            // return value
            return(gameManager);
        }
Beispiel #18
0
        /// <summary>
        /// This class is used to Shuffle a list of type 'T'.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="list"></param>
        public static List <T> Shuffle <T>(this IList <T> list)
        {
            // List
            List <T> shuffledList = new List <T>();

            // locals
            int randomIndex = -1;
            int cycles      = 1;

            // create
            RandomNumberGenerator crypto = RandomNumberGenerator.Create();

            // Create the byte array that serves asa
            byte[] container = new byte[1];

            // if the list exists
            if ((list != null) && (list.Count > 0))
            {
                // we can't use the collection count it changes
                int listCount = list.Count;

                // set the cycles
                cycles = (listCount / 255) + 1;

                // now we have to 'Randomly' pull items and add them to the end results
                for (int x = 0; x < listCount; x++)
                {
                    // reset
                    randomIndex = -1;

                    // Fill the topOrBottom byteArray
                    crypto.GetBytes(container);

                    // iterate the cycles
                    for (int c = 0; c < cycles; c++)
                    {
                        // Get the value of topOrBottom
                        object randomByte = container.GetValue(0);

                        // if the randomByte exists
                        if (NullHelper.Exists(randomByte))
                        {
                            // get a randomValue
                            int randomValue = NumericHelper.ParseInteger(randomByte.ToString(), -1, -1);

                            // set the randomIndex to the modulas of the the listCount
                            randomIndex += randomValue;
                        }
                    }

                    // ensure in range
                    randomIndex = (randomIndex % list.Count);

                    // verify the index is in range
                    if ((randomIndex < list.Count) && (randomIndex >= 0))
                    {
                        // Add this integer
                        shuffledList.Add(list[randomIndex]);

                        // if the index is in rage
                        if ((list.Count > 0) && (list.Count > randomIndex))
                        {
                            // Remove the item from the sourceList now that we have it
                            list.RemoveAt(randomIndex);
                        }
                    }
                }
            }

            // return value
            return(shuffledList);
        }
Beispiel #19
0
        /// <summary>
        /// This method is used to load a GameManager object from the values from this object
        /// so that the controls be can be loaded when the program starts
        /// </summary>
        /// <returns></returns>
        public static GameManager Export(SecureUserData security, List <BlackJackPlayerControl> playerControls, MainForm table)
        {
            // initial value
            GameManager gameManager = null;

            // local
            BlackJackPlayerControl playerControl = null;

            // If the security object exists
            if (NullHelper.Exists(security, playerControls, table))
            {
                // Create a new instance of a 'GameManager' object.
                gameManager = new GameManager(NumericHelper.ParseInteger(Properties.Resources.TimesToShuffle, 0, -1), table);

                // create a houseRules object
                Options houseRules = new Options();

                // set the properties from this form
                houseRules.AllowDoubleDown              = security.AllowDoubleDown;
                houseRules.AllowDoubleOnSplit           = security.AllowDoubleOnSplit;
                houseRules.AllowDoubleOnTenOrElevenOnly = security.AllowDoubleOnTenOrElevenOnly;
                houseRules.AllowInsurance   = security.AllowInsurance;
                houseRules.AllowResplitAces = security.AllowResplitAces;
                houseRules.AllowSplit       = security.AllowSplit;
                houseRules.AllowSplitAces   = security.AllowSplitAces;
                houseRules.AllowSurrender   = security.AllowSurrender;
                houseRules.ComputerPlayersUnlimitedRebuys = security.ComputerPlayersUnlimitedRebuys;
                houseRules.DealerMustHitSoft17            = security.DealerMustHitSoft17;
                houseRules.DefaultBankRoll         = security.DefaultBankRoll;
                houseRules.DefaultComputerBankRoll = security.DefaultComputerBankRoll;
                houseRules.GameSpeed = security.GameSpeed;
                houseRules.HumanPlayerUnlimitedRebuys = security.HumanPlayerUnlimitedRebuys;
                houseRules.NumberDecks = security.NumberDecks;
                houseRules.Penetration = security.Penetration;
                houseRules.SaveSettingsOnThisComputer = security.SaveSettingsOnThisComputer;
                houseRules.TableMaximum = security.TableMaximum;
                houseRules.TableMinimum = security.TableMinimum;

                // Create a list of players
                List <Player> players = new List <Player>();

                // if Player1's Name is set that is consider playing
                if (TextHelper.Exists(security.Player1Name))
                {
                    // Find the PlayerControl
                    playerControl = FindPlayerControl(playerControls, SeatNumberEnum.Seat1);

                    // if the control was found
                    if (NullHelper.Exists(playerControl))
                    {
                        // create player 1
                        Player player1 = new Player(security.Player1Name, security.Player1Chips, security.Player1IsComputerPlayer, playerControl);

                        // Setup the SeatNumber
                        player1.SeatNumber = SeatNumberEnum.Seat1;

                        // Is Player1 Sitting Out
                        player1.SittingOut = security.Player1SittingOut;

                        // Set the CountingSystem
                        string countingSystemName = security.Player1CountingSystem;
                        player1.CardCountingSystem = CardCountingSystemFactory.FindCardCountingSystem(countingSystemName);

                        // add this player
                        players.Add(player1);
                    }
                }

                // if Player2's Name is set that is consider playing
                if (TextHelper.Exists(security.Player2Name))
                {
                    // Find the PlayerControl
                    playerControl = FindPlayerControl(playerControls, SeatNumberEnum.Seat2);

                    // if the control was found
                    if (NullHelper.Exists(playerControl))
                    {
                        // create player 2
                        Player player2 = new Player(security.Player2Name, security.Player2Chips, security.Player2IsComputerPlayer, playerControl);

                        // Setup the SeatNumber
                        player2.SeatNumber = SeatNumberEnum.Seat2;

                        // Is Player2 Sitting Out
                        player2.SittingOut = security.Player2SittingOut;

                        // Set the CountingSystem
                        string countingSystemName = security.Player2CountingSystem;
                        player2.CardCountingSystem = CardCountingSystemFactory.FindCardCountingSystem(countingSystemName);

                        // add this player
                        players.Add(player2);
                    }
                }

                // if Player3's Name is set that is consider playing
                if (TextHelper.Exists(security.Player3Name))
                {
                    // Find the PlayerControl
                    playerControl = FindPlayerControl(playerControls, SeatNumberEnum.Seat3);

                    // if the control was found
                    if (NullHelper.Exists(playerControl))
                    {
                        // create player 3
                        Player player3 = new Player(security.Player3Name, security.Player3Chips, security.Player3IsComputerPlayer, playerControl);

                        // Setup the SeatNumber
                        player3.SeatNumber = SeatNumberEnum.Seat3;

                        // Is Player3 Sitting Out
                        player3.SittingOut = security.Player3SittingOut;

                        // Set the CountingSystem
                        string countingSystemName = security.Player3CountingSystem;
                        player3.CardCountingSystem = CardCountingSystemFactory.FindCardCountingSystem(countingSystemName);

                        // add this player
                        players.Add(player3);
                    }
                }

                // if Player4's Name is set that is consider playing
                if (TextHelper.Exists(security.Player4Name))
                {
                    // Find the PlayerControl
                    playerControl = FindPlayerControl(playerControls, SeatNumberEnum.Seat4);

                    // if the control was found
                    if (NullHelper.Exists(playerControl))
                    {
                        // create player 4
                        Player player4 = new Player(security.Player4Name, security.Player4Chips, security.Player4IsComputerPlayer, playerControl);

                        // Setup the SeatNumber
                        player4.SeatNumber = SeatNumberEnum.Seat4;

                        // Is Player4 Sitting Out
                        player4.SittingOut = security.Player4SittingOut;

                        // Set the CountingSystem
                        string countingSystemName = security.Player4CountingSystem;
                        player4.CardCountingSystem = CardCountingSystemFactory.FindCardCountingSystem(countingSystemName);

                        // add this player
                        players.Add(player4);
                    }
                }

                // if Player5's Name is set that is consider playing
                if (TextHelper.Exists(security.Player5Name))
                {
                    // Find the PlayerControl
                    playerControl = FindPlayerControl(playerControls, SeatNumberEnum.Seat5);

                    // if the control was found
                    if (NullHelper.Exists(playerControl))
                    {
                        // create player 5
                        Player player5 = new Player(security.Player5Name, security.Player5Chips, security.Player5IsComputerPlayer, playerControl);

                        // Setup the SeatNumber
                        player5.SeatNumber = SeatNumberEnum.Seat5;

                        // Is Player5 Sitting Out
                        player5.SittingOut = security.Player5SittingOut;

                        // Set the CountingSystem
                        string countingSystemName = security.Player5CountingSystem;
                        player5.CardCountingSystem = CardCountingSystemFactory.FindCardCountingSystem(countingSystemName);

                        // add this player
                        players.Add(player5);
                    }
                }

                // set the HouseRules & players
                gameManager.HouseRules = houseRules;
                gameManager.Players    = players;

                // if the HouseRules exist
                if (gameManager.HasHouseRules)
                {
                    // create
                    BlackJackCardValueBase blackJackCardValueBase = new BlackJackCardValueBase();

                    // Set the times to shuffle
                    int timesToShuffle = NumericHelper.ParseInteger(Properties.Resources.TimesToShuffle, 0, -1);

                    // Create the Shuffler
                    gameManager.Shuffler = new RandomShuffler(houseRules.NumberDecks, blackJackCardValueBase, 0);
                }
            }

            // return value
            return(gameManager);
        }
Beispiel #20
0
        /// <summary>
        /// This method Start Simulation
        /// </summary>
        private void StartSimulation()
        {
            // Create a
            RandomDoorCallBack dealer = new RandomDoorCallBack(CanPullNextItem, PullNextItem);

            // Create a report
            this.Report = new RandomReport(PickADoorSimulator.MinValue, PickADoorSimulator.MaxValue);

            // You can't start a second simulation without restarting.
            this.StartSimulationButton.Enabled = false;

            // Show the initializing label
            this.InitializingLabel.Visible = true;
            this.Graph.Visible             = true;

            // Show the Setup
            RefreshUI();

            // locals
            DoorSelectOptionEnum doorSelectOption     = GetDoorSelectOption();
            PickADoorSimulator   simulatorWithoutSwap = null;
            PickADoorSimulator   simulatorWithSwap    = null;

            // Get the number of simulations to run
            int simulations = NumericHelper.ParseInteger(this.SimulationsControl.Text.Replace(",", ""), 0, -1);

            // If the value for simulations is greater than zero
            if (simulations > 0)
            {
                // create the total possibilities to choose from
                int possibilities = PickADoorSimulator.MaxValue * 10;

                // Create a Shuffler
                this.Shuffler = new RandomShuffler(PickADoorSimulator.MinValue, PickADoorSimulator.MaxValue, possibilities, PickADoorSimulator.TimesToShuffle, 1);

                // Set the report
                this.Shuffler.Report = this.Report;

                // Create the two lists
                this.SimulationsSwapping    = new List <PickADoorSimulator>();
                this.SimulationsNotSwapping = new List <PickADoorSimulator>();

                // Set the maximum
                this.Graph.Maximum = simulations;

                // iterate the number of simuations to create them
                for (int x = 1; x <= simulations; x++)
                {
                    // Create a simulation for Without Swap
                    simulatorWithoutSwap = new PickADoorSimulator(doorSelectOption, false, dealer);

                    // Create a simulation for Swap
                    simulatorWithSwap = new PickADoorSimulator(doorSelectOption, true, dealer);

                    // Add each simulation
                    this.SimulationsNotSwapping.Add(simulatorWithoutSwap);
                    this.SimulationsSwapping.Add(simulatorWithSwap);

                    // Set the graph value
                    this.Graph.Value = x;

                    // Refresh everything
                    this.RefreshUI();
                }

                // Hide the setup
                this.InitializingLabel.Visible = false;
                this.Graph.Visible             = false;

                // refresh the UI
                RefreshUI();

                // for debugging only
                // StringBuilder sb = new StringBuilder();

                // Now run the simulations
                for (int x = 0; x < simulations; x++)
                {
                    // Run the simulations
                    this.SimulationsNotSwapping[x].RunSimulation();
                    this.SimulationsSwapping[x].RunSimulation();

                    // if it was a correct guess
                    if (this.SimulationsNotSwapping[x].CorrectGuess)
                    {
                        // Increment the value for this
                        this.DoNotSwapCorrect++;
                    }
                    else
                    {
                        // Increment the value for this
                        this.DoNotSwapWrong++;
                    }

                    // if it was a correct guess
                    if (this.SimulationsSwapping[x].CorrectGuess)
                    {
                        // Increment the value for this
                        this.SwapCorrect++;
                    }
                    else
                    {
                        // Increment the value for this
                        this.SwapWrong++;
                    }

                    // Display the results
                    this.DoNotSwapCorrectValueLabel.Text = String.Format("{0:n0}", DoNotSwapCorrect);
                    this.DoNotSwapWrongValueLabel.Text   = String.Format("{0:n0}", DoNotSwapWrong);
                    this.SwapCorrectValueLabel.Text      = String.Format("{0:n0}", SwapCorrect);
                    this.SwapWrongValueLabel.Text        = String.Format("{0:n0}", SwapWrong);

                    // refresh the user interface
                    RefreshUI();
                }

                // Get the report
                if (this.Report.HasOccurrences)
                {
                    // local
                    int tempCount = 0;

                    // iterate the occurrences
                    foreach (NumberOccurrence occurrence in this.Report.Occurrences)
                    {
                        // local
                        int thisNumber = occurrence.Number;
                        tempCount = occurrence.Count;

                        // write out the number
                        Console.WriteLine(thisNumber + ": " + tempCount + " of " + this.Report.TotalItemsPulled);
                    }
                }
            }
            else
            {
                // Show the user a message
                MessageBoxHelper.ShowMessage("You must enter the number of simulations", "Invalid Input");
            }

            // Add Finished so we know it is done.
            this.Text = this.Text + " - Finished";
        }
        /// <summary>
        /// This method returns the Pixel Criteria
        /// </summary>
        public static PixelCriteria CreatePixelCriteria(string text, ActionTypeEnum actionType, int lineNumber, PixelCriteria existingCriteria = null)
        {
            // initial value
            PixelCriteria pixelCriteria = null;

            // only use a space as a delimiter character
            char[] delimiterChars = { ' ' };

            // If the text string exists
            if (TextHelper.Exists(text))
            {
                // Set the BackColor
                if (actionType == ActionTypeEnum.SetBackColor)
                {
                    // Create a new instance of a 'PixelCriteria' object.
                    pixelCriteria = new PixelCriteria();

                    // Get the words
                    List <Word> words = WordParser.GetWords(text, delimiterChars);

                    // If the words collection exists and has one or more items
                    if (ListHelper.HasOneOrMoreItems(words))
                    {
                        // if there are 3 words
                        if (words.Count == 3)
                        {
                            // if the third word is null
                            if (words[2].Text.ToLower() == "null")
                            {
                                // Set the value for the property 'RemoveBackColor' to true
                                pixelCriteria.RemoveBackColor = true;
                            }
                            else
                            {
                                // Set the BackColor
                                pixelCriteria.BackColor = Color.FromName(words[2].Text);
                            }
                        }
                        else if (words.Count == 5)
                        {
                            // set the value for Red, Green & Blue
                            int red   = NumericHelper.ParseInteger(words[2].Text, -1, -1);
                            int green = NumericHelper.ParseInteger(words[3].Text, -1, -1);
                            int blue  = NumericHelper.ParseInteger(words[4].Text, -1, -1);

                            // if all the RGB values are set
                            if ((red >= 0) && (green >= 0) && (blue >= 0))
                            {
                                // Set the BackColor
                                pixelCriteria.BackColor = Color.FromArgb(red, green, blue);
                            }
                        }
                    }
                }
                // if this is a draw line
                else if (actionType == ActionTypeEnum.DrawLine)
                {
                    // if the existingCriteria
                    if (NullHelper.IsNull(existingCriteria))
                    {
                        // Create a new instance of a 'PixelCriteria' object.
                        pixelCriteria = new PixelCriteria();
                    }
                    else
                    {
                        // use the existing criteria so more properties can be set on it
                        pixelCriteria = existingCriteria;
                    }

                    // Set to DrawLine
                    pixelCriteria.PixelType = PixelTypeEnum.DrawLine;

                    // if this is the first line
                    if (lineNumber == 1)
                    {
                        // Get the words
                        List <Word> words = WordParser.GetWords(text, delimiterChars);

                        // If the words collection exists and has one or more items
                        if (ListHelper.HasOneOrMoreItems(words))
                        {
                            // Get the lastWord
                            Word lastWord = words[words.Count - 1];

                            // Set the thickness
                            pixelCriteria.Thickness = NumericHelper.ParseInteger(lastWord.Text, -1000, -1001);
                        }
                    }
                    else if (lineNumber == 3)
                    {
                        // Set the RepeatType and the repeating attributes
                        pixelCriteria.RepeatType = SetRepeatType(text);

                        // if the repeat type was found
                        if (pixelCriteria.RepeatType != RepeatTypeEnum.NoRepeat)
                        {
                            // get the text after the repeat
                            string repeatText = GetRepeatText(text, pixelCriteria.RepeatType);

                            // get the words
                            List <Word> words = WordParser.GetWords(repeatText);

                            // if there are exactly two words
                            if ((ListHelper.HasOneOrMoreItems(words)) && (words.Count == 2))
                            {
                                // set the repititions
                                pixelCriteria.Repititions = NumericHelper.ParseInteger(words[0].Text, 0, -1);

                                // set the Distance
                                pixelCriteria.Distance = NumericHelper.ParseInteger(words[1].Text, 0, -1);
                            }
                        }
                    }
                }
                else if (lineNumber > 1)
                {
                    // Create a new instance of a 'PixelCriteria' object.
                    pixelCriteria = new PixelCriteria();

                    // if this text contains bluegreen
                    if (text.Contains("x"))
                    {
                        // Set the PixelType
                        pixelCriteria.PixelType = PixelTypeEnum.X;
                    }
                    else if (text.Contains("y"))
                    {
                        // Set the PixelType
                        pixelCriteria.PixelType = PixelTypeEnum.Y;
                    }
                    else if (text.Contains("bluegreen"))
                    {
                        // Set the PixelType
                        pixelCriteria.PixelType = PixelTypeEnum.BlueGreen;
                    }
                    // if this text contains bluegreen
                    else if (text.Contains("bluered"))
                    {
                        // Set the PixelType
                        pixelCriteria.PixelType = PixelTypeEnum.BlueRed;
                    }
                    // if this text contains bluegreen
                    else if (text.Contains("greenred"))
                    {
                        // Set the PixelType
                        pixelCriteria.PixelType = PixelTypeEnum.GreenRed;
                    }
                    else if (text.Contains("red"))
                    {
                        // Set the PixelType
                        pixelCriteria.PixelType = PixelTypeEnum.Red;
                    }
                    else if (text.Contains("green"))
                    {
                        // Set the PixelType
                        pixelCriteria.PixelType = PixelTypeEnum.Green;
                    }
                    else if (text.Contains("blue"))
                    {
                        // Set the PixelType
                        pixelCriteria.PixelType = PixelTypeEnum.Blue;
                    }
                    else if (text.Contains("total"))
                    {
                        // Set the PixelType
                        pixelCriteria.PixelType = PixelTypeEnum.Total;
                    }
                }
            }

            // return value
            return(pixelCriteria);
        }