Exemple #1
0
        /// <summary>
        /// This method takes a user defined custom character and converts the locations of active
        /// pixels to an array of bytes, cast into a string to be stored on the LCD component object in CyDesigner.
        /// </summary>
        /// <param name="customCharacter"> The string representing byte array from CyDesigner.</param>
        public string CharacterToCYString(CyCustomCharacter customCharacter)
        {
            // Comma Seperated String of Hex Values
            string cyCharacterString = "";

            CharLCDmp_v1_00.CyBox[,] pixelArray = customCharacter.GetBoxArray();

            // Indivudual row value to be calculated
            byte rowValue;

            for (int row = 0; row < customCharacter.Rows; row++)
            {
                rowValue = 0;

                for (int column = 0; column < customCharacter.Columns; column++)
                {
                    if (pixelArray[row, column].IsActive)
                    {
                        // If active find out which pixel it is.  The 0th is the furthest right
                        // and has a value of 1.  'customCharacter.Columns - 1' is the furthest left
                        // and has a value of 2^(customCharacter.Columns -1).  Values in between are
                        // Exponential powers of 2 based on position.
                        rowValue += (byte)getExponent(customCharacter.Columns - 1 - column);
                    }
                }
                cyCharacterString += rowValue.ToString("X") + ",";
            }
            // Convert Char arry to string and return it.
            return(cyCharacterString);
        }
Exemple #2
0
        // Calls CyStringToCharacter Foreach Character
        private void UnpackageCyStrings()
        {
            int    stringIndex = 0;
            string value;

            for (int index = 0; index < 8; index++)
            {
                value = m_component.GetCommittedParam(CHARACTER_PARAM_NAME + index).Value.Trim('"');
                m_cyCharacterStrings.Add(new KeyValuePair <string, string>(CHARACTER_PARAM_NAME + index, value));
            }

            //if (m_userDefinedCharacters.Count != m_cyCharacterStrings.Count)
            //    throw new Exception(
            //       "Number of custom characters in CyDesigner does not match number supported by the the LCD Wizard");

            for (int i = 0; i < m_userDefinedCharacters.Count; i++)
            {
                CyCustomCharacter             character = (CyCustomCharacter)m_userDefinedCharacters[i];
                KeyValuePair <string, string> kvp       = (KeyValuePair <string, string>)m_cyCharacterStrings[stringIndex++];
                string cyCharacterString = kvp.Value;

                if (cyCharacterString != null)
                {
                    CYStringToCharacter(character, cyCharacterString);
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// This method takes a string with each char (byte) representing the locations of active
        /// on a CyCustomCharacterArray.
        /// </summary>
        /// <param name="customCharacter"> The instance of a character to be updated from CyDesigner data.</param>
        /// <param name="cyCharacterString"> The string representing byte array from CyDesigner.</param>
        public void CYStringToCharacter(CyCustomCharacter customCharacter, string cyCharacterString)
        {
            char[] chars = new char[customCharacter.Rows];
            int    index = 0;

            // Remove last comma and seperate into indivudual strings.
            string[] hexCharacterArray = cyCharacterString.TrimEnd(',').Split(',');
            for (int i = 0; i < hexCharacterArray.Length; i++)
            {
                chars[index++] = (char)byte.Parse(hexCharacterArray[i], System.Globalization.NumberStyles.HexNumber);
            }

            CharLCDmp_v1_00.CyBox[,] boxes = customCharacter.GetBoxArray();

            for (int row = 0; row < customCharacter.Rows; row++)
            {
                for (int column = 0; column < customCharacter.Columns; column++)
                {
                    if ((((byte)chars[row]) & getExponent(customCharacter.Columns - 1 - column)) != 0)
                    {
                        boxes[row, column].IsActive = true;
                    }
                }
            }
        }
Exemple #4
0
 private void UpdateHighlighted(CyCustomCharacter selectedCharacter)
 {
     m_highlighted.Match(characterEditor);
     m_highlighted.Selected = false;
     m_highlighted.Invalidate();
     m_highlighted          = selectedCharacter;
     m_highlighted.Selected = true;
     m_highlighted.Invalidate();
     currentEditableCharacter.Text = m_highlighted.DisplayName;
     this.characterEditor.Match(selectedCharacter);
     this.characterEditor.Invalidate();
 }
Exemple #5
0
 private void custArray_MouseDown(object sender, MouseEventArgs e)
 {
     CharLCDmp_v1_00.CyCustomCharacter current    = (CharLCDmp_v1_00.CyCustomCharacter)sender;
     CharLCDmp_v1_00.CyBox             clickedBox = current.GetBoxByLocation(e.X, e.Y);
     if (clickedBox != null)
     {
         clickedBox.IsActive = !clickedBox.IsActive;
         m_activate          = clickedBox.IsActive;
         current.Invalidate();
     }
     this.m_highlighted.Invalidate();
 }
Exemple #6
0
        // Convert userDefined Characters to CyStrings
        private void ConvertUserDefinedCharactersToCY()
        {
            int stringIndex = 0;

            for (int i = 0; i < m_userDefinedCharacters.Count; i++)
            {
                CyCustomCharacter             character = (CyCustomCharacter)m_userDefinedCharacters[i];
                KeyValuePair <string, string> kvp       = (KeyValuePair <string, string>)m_cyCharacterStrings[stringIndex++];
                string cyStringName  = kvp.Key;
                string cyStringValue = "\"" + CharacterToCYString(character) + "\"";
                m_component.SetParamExpr(cyStringName, cyStringValue);
            }
        }
Exemple #7
0
        private void CustomCharactersOn()
        {
            customCharacterGroupBox.Enabled = true;

            m_highlighted.Selected = true;
            for (int i = 0; i < this.panel1.Controls.Count; i++)
            {
                CharLCDmp_v1_00.CyCustomCharacter character = (CharLCDmp_v1_00.CyCustomCharacter) this.panel1.Controls[i];
                character.BorderBrush   = new SolidBrush(Color.LightGray);
                character.ActiveBrush   = new SolidBrush(Color.Black);
                character.InactiveBrush = new SolidBrush(Color.White);
                character.Invalidate();
            }
        }
Exemple #8
0
 private void custArray_MouseMove(object sender, MouseEventArgs e)
 {
     if ((e.Button == MouseButtons.Left) || (e.Button == MouseButtons.Right))
     {
         CharLCDmp_v1_00.CyCustomCharacter current    = (CharLCDmp_v1_00.CyCustomCharacter)sender;
         CharLCDmp_v1_00.CyBox             currentBox = current.GetBoxByLocation(e.X, e.Y);
         if (currentBox != null)
         {
             currentBox.IsActive = m_activate;
             current.Invalidate();
         }
     }
     this.m_highlighted.Invalidate();
 }
Exemple #9
0
 private void CustomCharactersOff()
 {
     m_highlighted.Selected = false;
     for (int i = 0; i < this.panel1.Controls.Count; i++)
     {
         CharLCDmp_v1_00.CyCustomCharacter character = (CharLCDmp_v1_00.CyCustomCharacter) this.panel1.Controls[i];
         if (character.Visible == true)
         {
             character.ActiveBrush   = new SolidBrush(Color.LightGray);
             character.InactiveBrush = new SolidBrush(Color.WhiteSmoke);
             character.BorderBrush   = new SolidBrush(Color.LightGray);
             character.Invalidate();
         }
     }
     customCharacterGroupBox.Enabled = false;
 }
Exemple #10
0
        // Load the User Defined Characters into CharLCDCustomizer ArrayList userDefinedCharacters.
        ArrayList LoadUserDefinedCharacters(Dictionary <string, string> parameters)
        {
            int       index      = 0;
            string    temp       = "";
            ArrayList characters = new ArrayList();

            while (parameters.TryGetValue(UD_PARAM + index.ToString(), out temp))
            {
                CyCustomCharacter character = new CyCustomCharacter();
                temp = temp.Trim('"').TrimEnd(',');
                CyParameterToCustomCharacter(character, temp);
                characters.Add(character);
                index++;
            }
            return(characters);
        }
Exemple #11
0
        // Given a CustomCharacter, convert it into the lines of code to build an LCD custom char Array.
        string CharacterToCCode(CyCustomCharacter customCharacter)
        {
            // "characterString" represents the character after conversion to C Code
            String characterString = "";

            CharLCDmp_v1_00.CyBox[,] pixelArray = customCharacter.GetBoxArray();

            // Indivudual row value to be calculated
            byte rowValue;

            for (int row = 0; row < customCharacter.Rows; row++)
            {
                rowValue = 0;
                for (int column = 0; column < customCharacter.Columns; column++)
                {
                    if (pixelArray[row, column].IsActive)
                    {
                        // If active find out which pixel it is.  The 0th is the furthest right
                        // and has a value of 1.  'customCharacter.Columns - 1' is the furthest left
                        // and has a value of 2^(customCharacter.Columns -1).  Values in between are
                        // Exponential powers of 2 based on position.
                        rowValue += (byte)getExponent(customCharacter.Columns - 1 - column);
                    }
                }
                // Convert to 2 digit hex. Build Code for this row of the character.
                string temp = rowValue.ToString("X");
                if (temp.Length != 2)
                {
                    characterString += String.Format("    0x0{0}u", rowValue.ToString("X"));
                }
                else
                {
                    characterString += String.Format("    0x{0}u", rowValue.ToString("X"));
                }
                // No Comma after the last hex value
                if (row != customCharacter.Rows - 1)
                {
                    characterString += ",";
                }
            }
            return(characterString);
        }
Exemple #12
0
        // Given an ArrayList of Characters, convert array list into a C Data File.
        private void ConvertCharacters(ArrayList customCharacters, Dictionary <string, string> dict)
        {
            int    stringIndex = 0;
            string key         = "";
            string value       = "";

            for (int i = 0; i < customCharacters.Count; i++)
            {
                CyCustomCharacter character = (CyCustomCharacter)customCharacters[i];

                // Define Value
                value = CharacterToCCode(character);

                // Define Key Name
                key = CUST_CHAR_MACRONAME + stringIndex.ToString();

                dict.Add(key, value);

                stringIndex++;
            }
        }
Exemple #13
0
        // Create bar graphs activates the appropriate pixels on two bargraph
        // Sets, horizontal and vertical: May need adjustments in future.

        private void CreateBarGraphs()
        {
            #region Horizontal Bargraph
            int largestColumn = 0;

            // Loop returns items in the order they were added to the ArrayList.
            for (int i = 0; i < m_hbgCharacters.Count; i++)
            {
                CyCustomCharacter character = (CyCustomCharacter)m_hbgCharacters[i];
                for (int index = 0; index < largestColumn; index++)
                {
                    character.SetColumn(index);
                }

                largestColumn++;

                if (largestColumn > character.Columns)
                {
                    break;
                }
            }
            #endregion

            #region Vertical Bargraph
            // Does not leave an empty character in the Custom Fonts
            int lastRow = 7;

            for (int i = 0; i < m_vbgCharacters.Count; i++)
            {
                CyCustomCharacter character = (CyCustomCharacter)m_vbgCharacters[i];
                for (int index = 7; index >= lastRow; index--)
                {
                    character.SetRow(index);
                }
                lastRow--;
            }
            #endregion
        }
Exemple #14
0
 private void custArrayHighlight_Click(object sender, MouseEventArgs e)
 {
     CharLCDmp_v1_00.CyCustomCharacter selectedCharacter = (CharLCDmp_v1_00.CyCustomCharacter)sender;
     UpdateHighlighted(selectedCharacter);
 }