Ejemplo n.º 1
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_2.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;
                    }
                }
            }
        }
Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 3
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_2.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);
        }
Ejemplo n.º 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();
 }
Ejemplo n.º 5
0
 private void custArray_MouseDown(object sender, MouseEventArgs e)
 {
     CharLCDmp_v1_2.CyCustomCharacter current    = (CharLCDmp_v1_2.CyCustomCharacter)sender;
     CharLCDmp_v1_2.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();
 }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 7
0
 private void custArray_MouseMove(object sender, MouseEventArgs e)
 {
     if ((e.Button == MouseButtons.Left) || (e.Button == MouseButtons.Right))
     {
         CharLCDmp_v1_2.CyCustomCharacter current    = (CharLCDmp_v1_2.CyCustomCharacter)sender;
         CharLCDmp_v1_2.CyBox             currentBox = current.GetBoxByLocation(e.X, e.Y);
         if (currentBox != null)
         {
             currentBox.IsActive = m_activate;
             current.Invalidate();
         }
     }
     this.m_highlighted.Invalidate();
 }
Ejemplo n.º 8
0
        private void CustomCharactersOn()
        {
            customCharacterGroupBox.Enabled = true;

            m_highlighted.Selected = true;
            for (int i = 0; i < this.panel1.Controls.Count; i++)
            {
                CharLCDmp_v1_2.CyCustomCharacter character = (CharLCDmp_v1_2.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();
            }
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
0
 private void CustomCharactersOff()
 {
     m_highlighted.Selected = false;
     for (int i = 0; i < this.panel1.Controls.Count; i++)
     {
         CharLCDmp_v1_2.CyCustomCharacter character = (CharLCDmp_v1_2.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;
 }
Ejemplo n.º 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_2.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);
        }
Ejemplo n.º 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++;
            }
        }
Ejemplo n.º 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
        }
Ejemplo n.º 14
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_2.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;
        }
Ejemplo n.º 15
0
        public CyCharLCDControl(ICyInstEdit_v1 component)
        {
            this.m_component = component;
            InitializeComponent();

            // Add Arrow Key Event Handling For customCharacterGroupBox
            customCharacterGroupBox.arrowPressedEvent +=
                new ArrowKeyPressEvent(customCharacterGroupBox_arrowPressedEvent);

            // Collections of each character set.
            m_userDefinedCharacters = new System.Collections.ArrayList();
            m_hbgCharacters = new System.Collections.ArrayList();
            m_vbgCharacters = new System.Collections.ArrayList();
            m_noneCharacters = new System.Collections.ArrayList();

            #region Populate Characters

            m_highlighted = this.character0;
            characterEditor.Match(m_highlighted);

            #region User Defined Characters

            m_userDefinedCharacters.Add(character0);
            m_userDefinedCharacters.Add(character1);
            m_userDefinedCharacters.Add(character2);
            m_userDefinedCharacters.Add(character3);
            m_userDefinedCharacters.Add(character4);
            m_userDefinedCharacters.Add(character5);
            m_userDefinedCharacters.Add(character6);
            m_userDefinedCharacters.Add(character7);
            #endregion

            LoadBarGraphs();
            CreateBarGraphs();

            #region Empty Characters for "None" character set
            m_noneCharacters.Add(customCharacter1);
            m_noneCharacters.Add(customCharacter2);
            m_noneCharacters.Add(customCharacter3);
            m_noneCharacters.Add(customCharacter4);
            m_noneCharacters.Add(customCharacter5);
            m_noneCharacters.Add(customCharacter6);
            m_noneCharacters.Add(customCharacter7);
            m_noneCharacters.Add(customCharacter8);
            #endregion
            #endregion
        }
Ejemplo n.º 16
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_2.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;
        }
Ejemplo n.º 17
0
 private void custArrayHighlight_Click(object sender, MouseEventArgs e)
 {
     CharLCDmp_v1_2.CyCustomCharacter selectedCharacter = (CharLCDmp_v1_2.CyCustomCharacter)sender;
     UpdateHighlighted(selectedCharacter);
 }
Ejemplo n.º 18
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;
 }
Ejemplo n.º 19
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_2.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;
                }
            }
        }
Ejemplo n.º 20
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();
 }