protected override void HandleUnauthorizedRequest(AuthorizationContext context)
 {
     if (context.HttpContext.Request.IsAjaxRequest())
     {
         context.HttpContext.Response.StatusCode = 200;
         context.Result = new JsonResult
         {
             Data = new
             {
                 @ok   = false,
                 error = "抱歉,您没有权限操作此功能"
             },
             JsonRequestBehavior = JsonRequestBehavior.AllowGet
         };
     }
     else
     {
         base.HandleUnauthorizedRequest(context);
         if (AreaName.Equals("webadmin") && ControllerName.Equals("home") && ActionName.Equals("index"))
         {
             context.Result = new RedirectResult("/webadmin/home/login");
         }
         else
         {
             context.Result = new RedirectResult("/ErrorPage/401.html");
         }
     }
 }
        public bool Equals(UrlModel urlModel)
        {
            if (urlModel == null)
            {
                return(false);
            }

            return(((string.IsNullOrEmpty(AreaName) && string.IsNullOrEmpty(urlModel.AreaName)) || (string.Equals(AreaName, urlModel.AreaName, StringComparison.InvariantCultureIgnoreCase))) &&
                   ((string.IsNullOrEmpty(ControllerName)) || (ControllerName.Equals(urlModel.ControllerName, StringComparison.InvariantCultureIgnoreCase)) &&
                    ((ActionName == null) || ActionName.Equals(urlModel.ActionName, StringComparison.InvariantCultureIgnoreCase))));
        }
Exemple #3
0
        public HtmlString RenderSubMenuItem(string functionName, string text, string actionName, string controllerName = null, object routeValues = null, object htmlAtts = null)
        {
            string format = @"<li><a href=""{URL}"" {ATTR}>{TEXT}</a></li>";


            if (ControllerName.Equals(controllerName, StringComparison.InvariantCultureIgnoreCase) && ActionName.Equals(actionName, StringComparison.InvariantCultureIgnoreCase))
            {
                return(RenderItemFormat(functionName, format, text, actionName, controllerName, routeValues, htmlAtts, "active"));
            }

            return(RenderItemFormat(functionName, format, text, actionName, controllerName, routeValues, htmlAtts));
        }
Exemple #4
0
        public HtmlString RenderMainMenuItem(string functionName, string text, string actionName, string controllerName = null, object routeValues = null, object htmlAtts = null)
        {
            string format = ""; // @"<li><a href=""{URL}"" {ATTR}>{TEXT}</a></li>";

            format += @"<li class=''>";
            format += @"<a href=""{URL}"" {ATTR} ><span class='menu-text'>{TEXT}</span></a>";
            format += @"</li>";

            if (ControllerName.Equals(controllerName, StringComparison.InvariantCultureIgnoreCase))
            {
                return(RenderItemFormat(functionName, format, text, actionName, controllerName, routeValues, htmlAtts, "active"));
            }

            var renderItemHtml = RenderItemFormat(functionName, format, text, actionName, controllerName, routeValues, htmlAtts);

            return(renderItemHtml);
        }
        protected virtual bool GetSelected()
        {
            try
            {
                var action     = HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString();
                var controller = HttpContext.Current.Request.RequestContext.RouteData.Values["controller"].ToString();

                if (Controller != null)
                {
                    bool selected = ControllerName.Equals(controller, StringComparison.OrdinalIgnoreCase) &&
                                    Action.Equals(action, StringComparison.OrdinalIgnoreCase);

                    selected |= SubMenu.Any(x => x.Selected);

                    return(selected);
                }
            }
            catch {}
            return(false);
        }
Exemple #6
0
        private void ProcessData()
        {
            // First, process buttons
            Debug.WriteLine(BitConverter.ToString(m_State));

            // First, process the buttons
            byte newButtonA         = (byte)((m_State[0] >> 2) & 1);    // A
            byte newButtonB         = (byte)((m_State[0] >> 1) & 1);    // B
            byte newButtonX         = (byte)((m_State[0] >> 3) & 1);    // X
            byte newButtonY         = (byte)((m_State[0] >> 0) & 1);    // Y
            byte newButtonL1        = (byte)((m_State[0] >> 6) & 1);    // L1
            byte newButtonR1        = (byte)((m_State[0] >> 7) & 1);    // R1
            byte newButtonL2        = (byte)((m_State[1] >> 4) & 1);    // L2
            byte newButtonR2        = (byte)((m_State[1] >> 5) & 1);    // R2
            byte newButtonSelect    = (byte)((m_State[0] >> 5) & 1);    // Select
            byte newButtonStart     = (byte)((m_State[0] >> 4) & 1);    // Start
            byte newButtonDPadUp    = (byte)(m_State[1] & 1);           // DPad Up
            byte newButtonDPadDown  = (byte)((m_State[1] >> 1) & 1);    // DPad Down
            byte newButtonDPadLeft  = (byte)((m_State[1] >> 2) & 1);    // DPad Left
            byte newButtonDPadRight = (byte)((m_State[1] >> 3) & 1);    // DPad Right

            if (buttonA != newButtonA)
            {
                KeyChanged?.Invoke(new KeyEvent(KeyCode.A, newButtonA > 0 ? ControllerAction.Pressed : ControllerAction.Unpressed));
            }
            if (buttonB != newButtonB)
            {
                KeyChanged?.Invoke(new KeyEvent(KeyCode.B, newButtonB > 0 ? ControllerAction.Pressed : ControllerAction.Unpressed));
            }
            if (buttonX != newButtonX)
            {
                KeyChanged?.Invoke(new KeyEvent(KeyCode.X, newButtonX > 0 ? ControllerAction.Pressed : ControllerAction.Unpressed));
            }
            if (buttonY != newButtonY)
            {
                KeyChanged?.Invoke(new KeyEvent(KeyCode.Y, newButtonY > 0 ? ControllerAction.Pressed : ControllerAction.Unpressed));
            }
            if (buttonL1 != newButtonL1)
            {
                KeyChanged?.Invoke(new KeyEvent(KeyCode.L1, newButtonL1 > 0 ? ControllerAction.Pressed : ControllerAction.Unpressed));
            }
            if (buttonR1 != newButtonR1)
            {
                KeyChanged?.Invoke(new KeyEvent(KeyCode.R1, newButtonR1 > 0 ? ControllerAction.Pressed : ControllerAction.Unpressed));
            }
            if (buttonL2 != newButtonL2)
            {
                KeyChanged?.Invoke(new KeyEvent(KeyCode.L2, newButtonL2 > 0 ? ControllerAction.Pressed : ControllerAction.Unpressed));
            }
            if (buttonR2 != newButtonR2)
            {
                KeyChanged?.Invoke(new KeyEvent(KeyCode.R2, newButtonR2 > 0 ? ControllerAction.Pressed : ControllerAction.Unpressed));
            }
            if (buttonSelect != newButtonSelect)
            {
                KeyChanged?.Invoke(new KeyEvent(KeyCode.Select, newButtonSelect > 0 ? ControllerAction.Pressed : ControllerAction.Unpressed));
            }
            if (buttonStart != newButtonStart)
            {
                KeyChanged?.Invoke(new KeyEvent(KeyCode.Start, newButtonStart > 0 ? ControllerAction.Pressed : ControllerAction.Unpressed));
            }
            if (buttonDPadUp != newButtonDPadUp)
            {
                KeyChanged?.Invoke(new KeyEvent(KeyCode.DPadUp, newButtonDPadUp > 0 ? ControllerAction.Pressed : ControllerAction.Unpressed));
            }
            if (buttonDPadDown != newButtonDPadDown)
            {
                KeyChanged?.Invoke(new KeyEvent(KeyCode.DPadDown, newButtonDPadDown > 0 ? ControllerAction.Pressed : ControllerAction.Unpressed));
            }
            if (buttonDPadLeft != newButtonDPadLeft)
            {
                KeyChanged?.Invoke(new KeyEvent(KeyCode.DPadLeft, newButtonDPadLeft > 0 ? ControllerAction.Pressed : ControllerAction.Unpressed));
            }
            if (buttonDPadRight != newButtonDPadRight)
            {
                KeyChanged?.Invoke(new KeyEvent(KeyCode.DPadRight, newButtonDPadRight > 0 ? ControllerAction.Pressed : ControllerAction.Unpressed));
            }

            buttonA         = newButtonA;
            buttonB         = newButtonB;
            buttonX         = newButtonX;
            buttonY         = newButtonY;
            buttonL1        = newButtonL1;
            buttonR1        = newButtonR1;
            buttonL2        = newButtonL2;
            buttonR2        = newButtonR2;
            buttonSelect    = newButtonSelect;
            buttonStart     = newButtonStart;
            buttonDPadUp    = newButtonDPadUp;
            buttonDPadDown  = newButtonDPadDown;
            buttonDPadLeft  = newButtonDPadLeft;
            buttonDPadRight = newButtonDPadRight;

            // Is it "Moga Mobile" controller?
            if (ControllerName.Equals("BD&A"))
            {
                // Next, process joystick/d-pad axes
                int   newAxisX = 0;
                sbyte newDataX = (sbyte)m_State[2];
                if ((byte)(m_State[1] & 0x04) == 0x04 || (byte)(m_State[1] & 0x08) == 0x08)
                {
                    newAxisX = (byte)(m_State[1] & 0x04) == 0x04 ? 1 : -1;
                }
                if (axisX != newAxisX || (newAxisX != 0 && dataX != newDataX) || (axisX != 0 && newAxisX == 0))
                {
                    AxisChanged?.Invoke(new MotionEvent(Axis.X, newAxisX == 0 ? 0 : newDataX));
                }
                axisX = newAxisX;
                dataX = newDataX;

                int   newAxisY = 0;
                sbyte newDataY = (sbyte)m_State[3];
                if ((byte)(m_State[1] & 0x01) == 0x01 || (byte)(m_State[1] & 0x02) == 2)
                {
                    newAxisY = (byte)(m_State[1] & 0x01) == 0x01 ? 1 : -1;
                }
                if (axisY != newAxisY || (newAxisY != 0 && dataY != newDataY) || (axisY != 0 && newAxisY == 0))
                {
                    AxisChanged?.Invoke(new MotionEvent(Axis.Y, newAxisY == 0 ? 0 : newDataY));
                }
                axisY = newAxisY;
                dataY = newDataY;

                int   newAxisZ = 0;
                sbyte newDataZ = (sbyte)m_State[5];
                if ((byte)(m_State[1] & 0x10) == 0x10 || (byte)(m_State[1] & 0x20) == 0x20)
                {
                    newAxisZ = (byte)(m_State[1] & 0x10) == 0x10 ? 1 : -1;
                }
                if (axisZ != newAxisZ || (newAxisZ != 0 && dataZ != newDataZ) || (axisZ != 0 && newAxisZ == 0))
                {
                    AxisChanged?.Invoke(new MotionEvent(Axis.Z, newAxisZ == 0 ? 0 : newDataZ));
                }
                axisZ = newAxisZ;
                dataZ = newDataZ;

                int   newAxisRZ = 0;
                sbyte newDataRZ = (sbyte)m_State[4];
                if ((byte)(m_State[1] & 0x40) == 0x40 || (byte)(m_State[1] & 0x80) == 0x80)
                {
                    newAxisRZ = (byte)(m_State[1] & 0x40) == 0x40 ? 1 : -1;
                }
                if (axisRZ != newAxisRZ || (newAxisRZ != 0 && dataRZ != newDataRZ) || (axisRZ != 0 && newAxisRZ == 0))
                {
                    AxisChanged?.Invoke(new MotionEvent(Axis.RZ, newAxisRZ == 0 ? 0 : newDataRZ));
                }
                axisRZ = newAxisRZ;
                dataRZ = newDataRZ;
            }
            else
            {
                // Next, process joystick/d-pad axes
                int   newAxisX = 0;
                sbyte newDataX = (sbyte)m_State[2];
                if ((byte)(m_State[2] & 0x80) == 0x80 || (byte)(m_State[2] & 0x40) == 0x40)
                {
                    newAxisX = (byte)(m_State[2] & 0x80) == 0x80 ? 1 : -1;
                }
                if (axisX != newAxisX || (newAxisX != 0 && dataX != newDataX) || (axisX != 0 && newAxisX == 0))
                {
                    AxisChanged?.Invoke(new MotionEvent(Axis.X, newDataX));
                }
                axisX = newAxisX;
                dataX = newDataX;

                int   newAxisY = 0;
                sbyte newDataY = (sbyte)m_State[3];
                if ((byte)(m_State[3] & 0x80) == 0x80 || (byte)(m_State[3] & 0x40) == 0x40)
                {
                    newAxisY = (byte)(m_State[3] & 0x80) == 0x80 ? 1 : -1;
                }
                if (axisY != newAxisY || (newAxisY != 0 && dataY != newDataY) || (axisY != 0 && newAxisY == 0))
                {
                    AxisChanged?.Invoke(new MotionEvent(Axis.Y, newDataY));
                }
                axisY = newAxisY;
                dataY = newDataY;

                int   newAxisZ = 0;
                sbyte newDataZ = (sbyte)m_State[5];
                if ((byte)(m_State[5] & 0x80) == 0x80 || (byte)(m_State[5] & 0x40) == 0x40)
                {
                    newAxisZ = (byte)(m_State[5] & 0x80) == 0x80 ? 1 : -1;
                }
                if (axisZ != newAxisZ || (newAxisZ != 0 && dataZ != newDataZ) || (axisZ != 0 && newAxisZ == 0))
                {
                    AxisChanged?.Invoke(new MotionEvent(Axis.Z, newAxisZ == 0 ? 0 : newDataZ));
                }
                axisZ = newAxisZ;
                dataZ = newDataZ;

                int   newAxisRZ = 0;
                sbyte newDataRZ = (sbyte)m_State[4];
                if ((byte)(m_State[4] & 0x80) == 0x80 || (byte)(m_State[4] & 0x40) == 0x40)
                {
                    newAxisRZ = (byte)(m_State[4] & 0x80) == 0x80 ? 1 : -1;
                }
                if (axisRZ != newAxisRZ || (newAxisRZ != 0 && dataRZ != newDataRZ) || (axisRZ != 0 && newAxisRZ == 0))
                {
                    AxisChanged?.Invoke(new MotionEvent(Axis.RZ, newAxisRZ == 0 ? 0 : newDataRZ));
                }
                axisRZ = newAxisRZ;
                dataRZ = newDataRZ;
            }
        }