Пример #1
0
        private ZoneContext GetZoneContextFromQuery(IQueryCollection query)
        {
            if (query.ContainsKey("zone[name]"))
            {
                var context = new ZoneContext
                {
                    Name = query["zone[name]"].ToString()
                };

                if (query.ContainsKey("zone[embedded]"))
                {
                    context.Embedded = bool.Parse(query["zone[embedded]"]);
                }

                if (query.ContainsKey("zone[allowContainers]"))
                {
                    context.AllowContainers = bool.Parse(query["zone[allowContainers]"]);
                }

                if (query.ContainsKey("zone[allowPadding]"))
                {
                    context.AllowContainers = bool.Parse(query["zone[allowPadding]"]);
                }

                return(context);
            }

            return(null);
        }
Пример #2
0
        /// <summary>
        /// Initializes the view model.
        /// </summary>
        private void InitializeViewModel()
        {
            MainContext mainContext = new MainContext(_graphic.Building);

            _mainView.DataContext = mainContext;

            FloorContext floorContext = new FloorContext(_graphic.Building.Floors, _graphic.Sources, _floorView);

            floorContext.Parent    = mainContext;
            mainContext.Child      = floorContext;
            _floorView.DataContext = floorContext;

            ZoneContext zoneContext = new ZoneContext(_graphic.Building.Floors[0].Zones, _graphic.Sources);

            zoneContext.Parent    = floorContext;
            floorContext.Child    = zoneContext;
            _zoneView.DataContext = zoneContext;

            _navigator       = new Navigator(mainContext);
            this.DataContext = _navigator;

            _mainView.Focus();
            _floorView.Focus();
            _zoneView.Focus();
        }
Пример #3
0
        private WSDynamicEntity ReadSession(/*WSDataContext ZoneContext*/)
        {
            WSDynamicEntity entity = null;

            if (Meta != null && !string.IsNullOrEmpty(SessionID) && ZoneContext != null)
            {
                long init_ticks = DateTime.Now.Ticks;
                try
                {
                    status.AddNote("Zone:" + Meta.Zone, WSConstants.ACCESS_LEVEL.READ);

                    System.Reflection.MethodInfo mInfo = ZoneContext.GetType().GetMethod("GetTable", new Type[] { });

                    var tObj = mInfo.MakeGenericMethod(new Type[] { Meta.SessionType }).Invoke(ZoneContext, new object[] { });

                    Func <WSDynamicEntity, bool> func = s => s.readPropertyValue(WSConstants.PARAMS.SESSIONID.NAME, "").ToString().ToLower().Equals(SessionID.ToLower());

                    System.Reflection.MethodInfo[] methods = typeof(Enumerable).GetMethods(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);

                    var method = methods.FirstOrDefault(m => m.Name == "FirstOrDefault" && m.GetParameters().Count() == 2).MakeGenericMethod(typeof(WSDynamicEntity));

                    entity = (WSDynamicEntity)method.Invoke(null, new object[] { tObj, func });
                }
                catch (Exception e) { CFunc.RegError(GetType(), e, ref status); }

                //if (ZoneContext != null) ZoneContext.Close(/*SessionID*/);

                TimeSpan ticks1 = new TimeSpan(DateTime.Now.Ticks - init_ticks); init_ticks = DateTime.Now.Ticks;
            }
            return(entity);
        }
Пример #4
0
        /// <summary>
        /// Left mouse button up handler. Triggers the 'Browse down' command (Browse down to the zone view).
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void _polygonArea_OnMouseLeftButtonUp(object sender, RoutedEventArgs e)
        {
            ZoneContext zoneContext = this.DataContext as ZoneContext;

            if ((zoneContext != null) && ((string)(e.Source as FrameworkElement).Tag == "Zone"))
            {
                if (CustomCommands.BrowseDown.CanExecute(zoneContext.ObjectId, null))
                {
                    CustomCommands.BrowseDown.Execute(zoneContext.ObjectId, null);
                }
            }
        }
Пример #5
0
 private void InitTreeContext(ContentNode node, ZoneContext zone)
 {
     // Tree Context
     // design mode = true, otherwise we wouldn't be here
     // set allowcontainers at the root to be same as zone's current settings
     ViewData.SetTreeContext(new TreeContext
     {
         TreeId          = node.ContentTreeId,
         NodeId          = node.Id,
         Editable        = true,
         AllowContainers = zone.AllowContainers,
         Zone            = zone
     });
 }
Пример #6
0
        /// <summary>
        /// Creates the specified zone of a floor view.
        /// </summary>
        /// <param name="zone">The zone to create.</param>
        /// <param name="sources">All available sources</param>
        private void CreateFloorZone(ZoneGraphic zone, List <SourceGraphic> sources)
        {
            int xOffset;
            int yOffset;

            CalculateOffset(zone.FloorPlanCoordinates, out xOffset, out yOffset);
            List <Point>       relativeCoordinates = ShiftCoordinates(zone.FloorPlanCoordinates, xOffset, yOffset);
            ZoneGraphic        zoneMod             = new ZoneGraphic(zone.Id, zone.Name, zone.PicturePath, zone.PictureType, relativeCoordinates, zone.ZoneControlCoordinate);
            ZoneControl        zoneControl         = new ZoneControl();
            ZoneState          state = new ZoneState();
            List <ZoneGraphic> zones = new List <ZoneGraphic>();

            zones.Add(zoneMod);
            ZoneContext zoneContext = new ZoneContext(zones, sources);

            zoneControl.DataContext = zoneContext;
            Canvas.SetLeft(zoneControl, xOffset);
            Canvas.SetTop(zoneControl, yOffset);
            _canvasFloor.Children.Add(zoneControl);
            zoneContext.ZoneLoaded();
        }