Example #1
0
        public MapPluginBlock(View hostView, Node parentNode, BlockBase parentBlock, BlockDefinition definition, FieldList content, bool isRoot)
            : base(hostView, parentNode, parentBlock, definition, content, isRoot)
        {
            data = Definition as MapPluginBlockDefinition;

            // creating map control
            map = new Map();
            map.CredentialsProvider = new ApplicationIdCredentialsProvider(BingAppID);

            Children.Add(map);

            if (data != null)
            {
                map.AnimationLevel = data.IsAnimationEnabled ? AnimationLevel.Full : AnimationLevel.None;

                switch (data.Mode)
                {
                default:
                case WaveMapMode.Standard:
                    map.Mode = new RoadMode();
                    break;

                case WaveMapMode.Satellite:
                    map.Mode = new AerialMode(false);
                    break;

                case WaveMapMode.Hybrid:
                    map.Mode = new AerialMode(true);
                    break;
                }
            }

            if (Content != null)
            {
                int latitude  = Content[DefAgentFieldID.MapLatitude].AsNumber() ?? -1;
                int longitude = Content[DefAgentFieldID.MapLongitude].AsNumber() ?? -1;

                if ((latitude != -1) && (longitude != -1))
                {
                    map.Center = new GeoCoordinate(
                        (double)latitude / (double)LocationObserver.DegreesToMicrodegrees,
                        (double)longitude / (double)LocationObserver.DegreesToMicrodegrees);
                }

                map.ZoomLevel = 15; //HACK
            }
        }
Example #2
0
        private DefinitionBase CreateDefinition(FieldList source)
        {
            if (source == null)
            {
                return(null);
            }

            int   defID                   = source[MessageOutFieldID.DefinitionID].AsInteger() ?? 0;
            short primitiveType           = source[DefAgentFieldID.DefinitionType].AsShort() ?? 0;
            short secondaryCharacteristic = 0;

            DefinitionBase res = null;

            switch ((DefinitionType)primitiveType)
            {
            case DefinitionType.AtomicBlock:
            {
                FieldList firstStateData = (FieldList)source[DefAgentFieldID.DataPerComponentState];

                if (firstStateData != null)
                {
                    secondaryCharacteristic = firstStateData[DefAgentFieldID.LayoutType].AsByte() ?? 0;

                    switch ((LayoutType)secondaryCharacteristic)
                    {
                    case LayoutType.Table:
                        AtomicBlockDefinition ab = new AtomicBlockDefinition();
                        ab.Unpack(source);

                        res = ab;
                        break;

                    case LayoutType.SingleSlot:
                        SingleSlotBlockDefinition ssb = new SingleSlotBlockDefinition();
                        ssb.Unpack(source);

                        res = ssb;
                        break;

                    case LayoutType.ScrollingText:
                        ScrollingTextBlockDefinition stbd = new ScrollingTextBlockDefinition();
                        stbd.Unpack(source);

                        res = stbd;
                        break;

                    default:
                        DebugHelper.Out("Unsupported layout type for atomic: {0}", ((LayoutType)secondaryCharacteristic).ToString());
                        break;
                    }
                }

                break;
            }

            case DefinitionType.Container:
            {
                secondaryCharacteristic = source[DefAgentFieldID.LayoutType].AsByte() ?? 0;

                switch ((LayoutType)secondaryCharacteristic)
                {
                case LayoutType.Box:
                    BoxLayoutBlockDefinition bx = new BoxLayoutBlockDefinition();
                    bx.Unpack(source);

                    res = bx;
                    break;

                case LayoutType.Flow:
                    ListBlockDefinition fl = new ListBlockDefinition();
                    fl.Unpack(source);

                    res = fl;
                    break;

                case LayoutType.Grid:
                    GridBlockDefinition gr = new GridBlockDefinition();
                    gr.Unpack(source);

                    res = gr;
                    break;

                default:
                    DebugHelper.Out("Unsupported layout type for container: {0}", ((LayoutType)secondaryCharacteristic).ToString());
                    break;
                }

                break;
            }

            case DefinitionType.Frame:
            {
                FrameDefinition fd = new FrameDefinition();
                fd.Unpack(source);

                res = fd;
                break;
            }

            case DefinitionType.Plugin:
            {
                secondaryCharacteristic = source[DefAgentFieldID.PluginType].AsByte() ?? 0;

                switch ((PluginType)secondaryCharacteristic)
                {
                case PluginType.Map:
                    MapPluginBlockDefinition mpbd = new MapPluginBlockDefinition();
                    mpbd.Unpack(source);

                    res = mpbd;
                    break;

                default:
                    DebugHelper.Out("Unsupported plug-in type: {0}", ((PluginType)secondaryCharacteristic).ToString());
                    break;
                }

                break;
            }

            case DefinitionType.Palette:
            {
                PaletteDefinition palette = new PaletteDefinition();
                palette.Unpack(source);

                res = palette;
                break;
            }

            case DefinitionType.Font:
            {
                FontDefinition font = new FontDefinition();
                font.Unpack(source);

                res = font;
                break;
            }

            case DefinitionType.ApplicationEvents:
            {
                ApplicationEventsDefinition appEvents = new ApplicationEventsDefinition();
                appEvents.Unpack(source);

                res = appEvents;
                break;
            }

            default:
                DebugHelper.Out("Unsupported definition type: {0}", ((DefinitionType)primitiveType).ToString());
                break;
            }

            if ((res != null) && res.IsUnpacked)
            {
                return(res);
            }
            else
            {
                return(null);
            }
        }