Ejemplo n.º 1
0
        void Application_KeyPress(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case KeyCode.Up:
                _curColor = (_curColor + colors.Length - 1) % colors.Length;
                UpdateHilight((Application)sender);
                e.Handled = true;
                break;

            case KeyCode.Down:
                _curColor = (_curColor + colors.Length + 1) % colors.Length;
                UpdateHilight((Application)sender);
                e.Handled = true;
                break;

            case KeyCode.Right:
                byte[] savedData = new byte[1];
                savedData[0] = (byte)_curColor;
                TivoTree forwardParameters = new TivoTree();
                forwardParameters.Add("entry", _curColor.ToString());
                forwardParameters.Add("depth", _depth.ToString());
                ((Application)sender).TransitionForward(BaseUri, forwardParameters, savedData);
                e.Handled = true;
                break;

            case KeyCode.Left:
                TivoTree backParameters = new TivoTree();
                backParameters.Add("return", _curColor.ToString());
                backParameters.Add("depth", (_depth - 1).ToString());
                ((Application)sender).TransitionBack(backParameters);
                e.Handled = true;
                break;
            }
        }
Ejemplo n.º 2
0
 internal static void WriteParameters(HmeConnection connection, TivoTree _parameters)
 {
     // TODO: values must be sorted when there is a child (ie, this is a dictionary entry)
     foreach (string key in _parameters)
     {
         connection.Writer.Write(key);
         if (_parameters.GetValueCount(key) == 0)
         {
             connection.Writer.Write(endMarker);
         }
         else
         {
             foreach (var child in _parameters.GetValues(key))
             {
                 TivoTree childTree = child as TivoTree;
                 if (childTree == null)
                 {
                     connection.Writer.Write(stringMarker);
                     connection.Writer.Write(GetFirstAndOnly(child));
                 }
                 else
                 {
                     connection.Writer.Write(treeMarker);
                     WriteParameters(connection, childTree);
                 }
             }
             connection.Writer.Write(endMarker);
         }
     }
     connection.Writer.Write(string.Empty);
 }
Ejemplo n.º 3
0
 public ReceiverTransition(string destination, Transition type, TivoTree parameters, byte[] savedData)
 {
     // back - destination and data ignored
     // teleport - data ignored
     _destination = destination;
     _type        = type;
     _parameters  = parameters;
     _savedData   = savedData;
 }
Ejemplo n.º 4
0
        public override void Read(HmeReader reader)
        {
            long streamId = reader.ReadInt64();

            System.Diagnostics.Debug.Assert(_rootStreamId == streamId);

            TivoTree currentLevel = _parameters;

            ReadParameters(reader, currentLevel);
            _data = reader.ReadBytes((int)reader.ReadInt64());
            reader.ReadTerminator();
        }
Ejemplo n.º 5
0
        internal static void ReadParameters(HmeReader reader, TivoTree currentLevel)
        {
            for (string value = reader.ReadString(); value.Length != 0; value = reader.ReadString())
            {
                currentLevel.AddKey(value);
                for (sbyte marker = reader.ReadSByte(); marker != endMarker; marker = reader.ReadSByte())
                {
                    switch (marker)
                    {
                    case stringMarker:
                        currentLevel.Add(value, reader.ReadString());
                        break;

                    case treeMarker:
                        TivoTree tree = new TivoTree();
                        ReadParameters(reader, tree);
                        currentLevel.Add(value, tree);
                        break;
                    }
                }
            }
        }