Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _u3dPlayerControl_UnityCall(object sender, AxUnityWebPlayerAXLib._DUnityWebPlayerAXEvents_OnExternalCallEvent e)
        {
            try
            {
                string   message = e.value;
                string[] list    = message.Split('"');
                for (int i = 0; i < list.Length; i++)
                {
                    if (list[i].StartsWith("@"))
                    {
                        iS3UnityMessage myMessage = MessageConverter.DeSerializeMessage(list[i]);
                        switch (myMessage.type)
                        {
                        case MessageType.SendUnityLayer:
                            break;

                        case MessageType.SetObjSelectState:
                            SetObjSelectStateMessage _message = myMessage as SetObjSelectStateMessage;
                            string   _path      = _message.path;
                            int      id         = int.Parse(_path.Split('/')[_path.Split('/').Length - 1]);
                            bool     isSelected = _message.iSSelected;
                            DGObject obj        = null;
                            foreach (string key in prj.objsLayerIndex.Keys)
                            {
                                DGObjects objs = prj.objsLayerIndex[key];
                                if ((objs.definition.Has3D) && (_path.StartsWith(objs.definition.Layer3DName)))
                                {
                                    foreach (DGObject _obj in objs.values)
                                    {
                                        if (_obj.fullName == id.ToString())
                                        {
                                            obj = _obj;
                                            break;
                                        }
                                    }
                                }
                            }
                            if (obj != null && objSelectionChangedTrigger != null)
                            {
                                ObjSelectionChangedEventArgs args = new ObjSelectionChangedEventArgs();
                                if (isSelected)
                                {
                                    args.addedObjs = new Dictionary <string, IEnumerable <DGObject> >();
                                    List <DGObject> objs = new List <DGObject>()
                                    {
                                        obj
                                    };
                                    args.addedObjs.Add(obj.parent.definition.GISLayerName, objs);
                                }
                                else
                                {
                                    args.removedObjs = new Dictionary <string, IEnumerable <DGObject> >();
                                    List <DGObject> objs = new List <DGObject>()
                                    {
                                        obj
                                    };
                                    args.removedObjs.Add(obj.parent.definition.GISLayerName, objs);
                                }
                                objSelectionChangedTrigger(this, args);
                            }
                            break;

                        case MessageType.SetObjShowState:
                            break;

                        default: break;
                        }
                    }
                }
            }
            catch { }
        }