예제 #1
0
        private void build_all_keys_matrix()
        {
            int ToCount   = this.Rows * this.Cols;
            int FromCount = this.Entities.Count;

            //this.Entities.Clear();
            int ncount = ToCount - FromCount;

            if (ncount == 0)
            {
                return;
            }
            if (ncount >= 0)
            {
                for (int i = 0; i < ncount; i++)
                {
                    DiagramEntity entity = new DiagramKeyArea();
                    entity.OnEntityPropertiesChanged      += new DiagramEntity.EventEntityPropertiesChanged(OnSubEntityPropertiesChanged);
                    entity.OnEntityPropertiesBeforeChange += new DiagramEntity.EventEntityPropertiesBeforeChange(OnSubEntityPropertiesWillChange);

                    this.Entities.Add(entity);
                }
            }
            else
            {
                ncount = Math.Abs(ncount);
                this.Entities.RemoveRange(0, ncount);
            }
        }
예제 #2
0
        public override DiagramEntity Clone()
        {
            DiagramKeyArea obj = new DiagramKeyArea();

            obj.Copy(this);
            return(obj);
        }
예제 #3
0
        /// <summary>
        ///
        /// [Key rectangle][Beep pitch][Beep duration][Key content 0] ... [Key content n]<0x0d><0x0a>
        /// [126,26,154,42][0][0][S][u][m][m][a][r][y]<0x0d><0x0a>
        /// </summary>
        /// <param name="str"></param>
        private DiagramKeyArea parse_csv_key_area(string str)
        {
            DiagramKeyArea key = new DiagramKeyArea();

            if (!key.FromCSV(str))
            {
                return(null);
            }
            key.Title = CreateUniqueName(key.TypeName);

            return(key);
        }
예제 #4
0
        private object findSameItem(object obj, List <object> items)
        {
            if (obj is DiagramKeyArea)
            {
                DiagramKeyArea c = (DiagramKeyArea)obj;
                for (int i = 0; i < items.Count; i++)
                {
                    if (!(items[i] is DiagramKeyArea))
                    {
                        continue;
                    }
                    DiagramKeyArea d = (DiagramKeyArea)items[i];
                    if (c.isEqual(d))
                    {
                        return(d);
                    }
                }
            }
            else if (obj is DiagramKeySlideH)
            {
                DiagramKeySlideH c = (DiagramKeySlideH)obj;
                for (int i = 0; i < items.Count; i++)
                {
                    if (!(items[i] is DiagramKeySlideH))
                    {
                        continue;
                    }
                    DiagramKeySlideH d = (DiagramKeySlideH)items[i];
                    if (c.isEqual(d))
                    {
                        return(d);
                    }
                }
            }
            else if (obj is DiagramKeySlideV)
            {
                DiagramKeySlideV c = (DiagramKeySlideV)obj;
                for (int i = 0; i < items.Count; i++)
                {
                    if (!(items[i] is DiagramKeySlideV))
                    {
                        continue;
                    }
                    DiagramKeySlideV d = (DiagramKeySlideV)items[i];
                    if (c.isEqual(d))
                    {
                        return(d);
                    }
                }
            }

            return(null);
        }
예제 #5
0
        public override void Copy(DiagramEntity obj)
        {
            base.Copy(obj);
            DiagramKeyArea k = (DiagramKeyArea)obj;
            bool           b = k.ContentModified;

            this.KeyCode         = k.KeyCode;
            this.ContentModified = b;
            this.CapsEffect      = k.CapsEffect;

            //restore contentmodified property
        }
예제 #6
0
        public override bool isEqual(DiagramEntity key)
        {
            if (!(key is DiagramKeyArea))
            {
                return(false);
            }
            DiagramKeyArea k = (DiagramKeyArea)key;

            if (!base.isEqual(k))
            {
                return(false);
            }
            if (!this.KeyCode.ToString().Equals(k.KeyCode.ToString()))
            {
                return(false);
            }
            return(true);
        }
예제 #7
0
        /************************************************************************/

        /*
         * check key code error
         */
        /************************************************************************/
        public DiagramKey ErrorKeyUp()
        {
            int           ncount  = m_objs.GetSize();
            KB9Validation checker = new KB9Validation();

            for (int i = 0; i < ncount; i++)
            {
                DiagramEntity entity = m_objs.GetAt(i);
                if (entity.TypeName == DiagramKey.KEY_BUTTON)
                {
                    DiagramKeyArea key  = (DiagramKeyArea)entity;
                    string         code = key.KeyCode.GetKeyCodeString();
                    if (checker.ValidateKB9Keycodes(code) != KB9Validation.ERR_VALIDATION.OK)
                    {
                        return(key);
                    }
                }
                else if (entity.TypeName == DiagramKey.KEY_SLIDEH)
                {
                    DiagramKeySlideH key = (DiagramKeySlideH)entity;

                    string slideLeft = key.SlideLeft.GetKeyCodeString();
                    if (checker.ValidateKB9Keycodes(slideLeft) != KB9Validation.ERR_VALIDATION.OK)
                    {
                        return(key);
                    }
                    string slideLeftHold = key.SlideLeftHold.GetKeyCodeString();
                    if (checker.ValidateKB9Keycodes(slideLeftHold) != KB9Validation.ERR_VALIDATION.OK)
                    {
                        return(key);
                    }
                    string slideRight = key.SlideRight.GetKeyCodeString();
                    if (checker.ValidateKB9Keycodes(slideRight) != KB9Validation.ERR_VALIDATION.OK)
                    {
                        return(key);
                    }
                    string slideRightHold = key.SlideRightHold.GetKeyCodeString();
                    if (checker.ValidateKB9Keycodes(slideRightHold) != KB9Validation.ERR_VALIDATION.OK)
                    {
                        return(key);
                    }
                }
                else if (entity.TypeName == DiagramKey.KEY_SLIDEV)
                {
                    DiagramKeySlideV key = (DiagramKeySlideV)entity;

                    string slideUp = key.SlideUp.GetKeyCodeString();
                    if (checker.ValidateKB9Keycodes(slideUp) != KB9Validation.ERR_VALIDATION.OK)
                    {
                        return(key);
                    }
                    string slideUpHold = key.SlideUpHold.GetKeyCodeString();
                    if (checker.ValidateKB9Keycodes(slideUpHold) != KB9Validation.ERR_VALIDATION.OK)
                    {
                        return(key);
                    }
                    string slideDown = key.SlideDown.GetKeyCodeString();
                    if (checker.ValidateKB9Keycodes(slideDown) != KB9Validation.ERR_VALIDATION.OK)
                    {
                        return(key);
                    }
                    string slideDownHold = key.SlideDownHold.GetKeyCodeString();
                    if (checker.ValidateKB9Keycodes(slideDownHold) != KB9Validation.ERR_VALIDATION.OK)
                    {
                        return(key);
                    }
                }
            }
            return(null);
        }
예제 #8
0
        /// <summary>
        /// Load data from xml file.
        /// </summary>
        /// <param name="xml"></param>
        /// <returns></returns>
        public override bool FromXml(CLCIXML xml)
        {
            //load my entity properites
            if (!base.FromXml(xml))
            {
                return(false);
            }
            //load sub entities
            string s = "";

            xml.get_attribute("rows", ref s);
            this.Rows = Util.string2int(s, 0);

            xml.get_attribute("rowspacing", ref s);
            this.RowSpacing = Util.string2int(s, 0);

            xml.get_attribute("cols", ref s);
            this.Cols = Util.string2int(s, 0);

            xml.get_attribute("colspacing", ref s);
            this.ColSpacing = Util.string2int(s, 0);


            xml.get_attribute("count", ref s);
            int ncount = Util.string2int(s, 0);

            this.Entities.Clear();
            for (int i = 0; i < ncount; i++)
            {
                s = "k" + i.ToString();
                if (!xml.get_first_group(s))
                {
                    continue;
                }
                s = "";
                xml.get_attribute("keytype", ref s);
                DiagramEntity k = null;
                switch (s)
                {
                case DiagramKey.KEY_BUTTON:    // "BUTTON":
                {
                    k = new DiagramKeyArea();
                    k.FromXml(xml);
                }
                break;

                case DiagramKey.KEY_SLIDEV:
                {
                    k = new DiagramKeySlideV();
                    k.FromXml(xml);
                }
                break;

                case DiagramKey.KEY_SLIDEH:
                {
                    k = new DiagramKeySlideH();
                    k.FromXml(xml);
                }
                break;

                default:
                    continue;
                }

                xml.back_to_parent();
                k.OnEntityPropertiesChanged      += new EventEntityPropertiesChanged(OnSubEntityPropertiesChanged);
                k.OnEntityPropertiesBeforeChange += new DiagramEntity.EventEntityPropertiesBeforeChange(OnSubEntityPropertiesWillChange);
                this.Entities.Add(k);
            }


            return(true);
        }