Beispiel #1
0
        public override void Initialize()
        {
            Logger.LogWelcome();
            //Globals.CheckForUpdate();
            Globals.CheckRPHVersion(0.34f);

            MenuCommon.InitializeAllMenus();

            Functions.OnOnDutyStateChanged += Functions_OnOnDutyStateChanged;
            Game.FrameRender += Main.Process;
        }
        private void getCurrentMenuItem()
        {
            string strMode = Request.QueryString["cpmode"];

            if (strMode.IndexOf(",") > 0)
            {
                strMode = strMode.Substring(0, strMode.IndexOf(","));
            }
            //else if (strMode.IndexOf("_") > 0) strMode = strMode.Split('_')[1];

            XmlDocument doc         = MenuCommon.getXML();
            XmlNode     ownerCpMode = (XmlNode)doc.SelectSingleNode("//Cpmode[text() ='" + strMode + "']");

            if (ownerCpMode != null)
            {
                CurrentMenuItem = strMode;
                var parentNode = ownerCpMode.ParentNode;
                if (parentNode != null && parentNode.Attributes["ownerCpMode"] != null && !string.IsNullOrEmpty(parentNode.Attributes["ownerCpMode"].InnerText))
                {
                    CurrentMenuItem = parentNode.Attributes["ownerCpMode"].InnerText;
                }
            }
        }
Beispiel #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["cpmode"] != null)
            {
                string strMode = Request.QueryString["cpmode"];
                if (strMode.IndexOf(",") > 0)
                {
                    strMode = strMode.Substring(0, strMode.IndexOf(","));
                }

                Control ctrNewslist = null;

                // user cpMode to get path of usercontrol from xml config
                XmlDocument doc  = MenuCommon.getXML();
                XmlNode     node = doc.SelectSingleNode("//row[Cpmode='" + strMode + "']");
                if (node != null)
                {
                    XmlNode path = node.SelectSingleNode("path");
                    bool    ischeckpermission = bool.Parse(node.SelectSingleNode("../../@checkpermission").InnerText);

                    if (path != null)
                    {
                        if (ischeckpermission)
                        {
                            XmlNode permissionId = node.SelectSingleNode("Permission_ID");
                            // check permission in database
                            MainSecurity mainSecurity   = new MainSecurity();
                            DataTable    tblPermissions = mainSecurity.GetPermissionAsTable(HttpContext.Current.User.Identity.Name);
                            if (tblPermissions.Select("Permission_ID=" + permissionId.InnerText).Length == 1)
                            {
                                try
                                {
                                    ctrNewslist = LoadControl(path.InnerText);
                                    plcMain.Controls.Add(ctrNewslist);
                                }
                                catch (SecurityException sEx)
                                {
                                    plcMain.Controls.Clear();
                                    ctrNewslist = LoadControl("Statistic/MsgPermission.ascx");
                                    plcMain.Controls.Add(ctrNewslist);
                                }
                            }
                            else
                            {
                                ctrNewslist = LoadControl("Statistic/MsgPermission.ascx");
                                plcMain.Controls.Add(ctrNewslist);
                            }
                        }
                        else
                        {
                            try
                            {
                                ctrNewslist = LoadControl(path.InnerText);
                                plcMain.Controls.Add(ctrNewslist);
                            }
                            catch { }
                        }
                    }
                }
                if (ctrNewslist == null)
                {
                    ctrNewslist = LoadControl("OnLoad/onload.ascx");
                    plcMain.Controls.Add(ctrNewslist);
                }
            }
        }
Beispiel #4
0
        public override void ProcessMouseEvent(Vector2 location, InputManager.LogicalButtonState buttons)
        {
            if (Math.Abs(buttons.WheelTick) > 0 && TextLabels.Count > 1)
            {
                SetSelectedIndex(SelectedIndex + buttons.WheelTick);
            }

            if (!buttons.PrimaryClick || ParentCanvas == null || ParentCanvas.PopupEnabled() || TextLabels.Count < 2)
            {
                return;
            }

            float width  = Rect.GetPixelSize().X;
            float height = Rect.GetPixelSize().Y;

            Vector2 origin = Rect.GetPixelOrigin();

            float availableDist = width - (height * 2);

            if (location.X < origin.X + height || location.X > origin.X + availableDist + height)
            {
                return;
            }

            Vector2 thisOrigin = GetScreenOrigin();

            float thisCenterY = thisOrigin.Y + (height * 0.5f);

            float totalheight = (MenuCommon.ButtonSpacing.Paramater + (height * 1)) * TextLabels.Count;

            totalheight += MenuCommon.ButtonSpacing.Paramater * 1;

            float halfHeight = totalheight * 0.5f;

            float screenHeight = ParentCanvas.BoundWindow.Height;

            // see where the popup will land on the screen.

            OriginLocation originAllignment = OriginLocation.LowerLeft;

            if (totalheight > screenHeight)  // it won't fit, center it
            {
                originAllignment = OriginLocation.MiddleLeft;
            }
            else
            {
                if (thisCenterY - halfHeight > 0 && thisCenterY + halfHeight <= screenHeight)
                {
                    originAllignment = OriginLocation.MiddleLeft; // it'll fit centered, that looks better
                }
                else
                {
                    // it won't fit centered, so put it on the other side of the screen from where the button is
                    if (thisCenterY > halfHeight)
                    {
                        originAllignment = OriginLocation.UpperLeft;
                    }
                    else
                    {
                        originAllignment = OriginLocation.LowerLeft;
                    }
                }
            }

            if (originAllignment == OriginLocation.UpperLeft)
            {
                thisOrigin.Y += height;
            }
            else if (originAllignment == OriginLocation.MiddleLeft)
            {
                thisOrigin.Y += height * 0.5f;
            }

            RelativeRect rect = new RelativeRect(new RelativeLoc(thisOrigin.X, RelativeLoc.Edge.Raw), new RelativeLoc(thisOrigin.Y, RelativeLoc.Edge.Raw), RelativeSize.FixedPixelSize(width), RelativeSize.FixedPixelSize(totalheight), originAllignment);

            var popup = new UIPanel(rect, ThemeManager.GetThemeAsset("ui/SelectorPopupBackground.png"));

            popup.FillMode    = UIFillModes.SmartStprite;
            popup.IgnoreMouse = false;

            VerticalLayoutGroup vertgroup = MenuCommon.SetupCommonColumn(new RelativeRect(RelativeLoc.XCenter, RelativeLoc.YCenter, RelativeSize.ThreeQuarterWidth, rect.Height, OriginLocation.Center));

            vertgroup.FirstElementHasSpacing = true;

            foreach (var label in TextLabels)
            {
                MenuButton button = new MenuButton(new RelativeRect(), label);
                button.Tag      = label;
                button.Clicked += PopupButton_Clicked;
                if (label == GetText())
                {
                    button.Check();
                }

                vertgroup.AddChild(button);
            }
            popup.AddChild(vertgroup);

            ParentCanvas.SetPopupElement(popup);
        }
 public virtual void DeleteMenuCommon(MenuCommon entity)
 {
     entityDao.DeleteMenuCommon(entity);
 }
 public virtual void UpdateMenuCommon(MenuCommon entity)
 {
     entityDao.UpdateMenuCommon(entity);
 }
 public virtual void CreateMenuCommon(MenuCommon entity)
 {
     entityDao.CreateMenuCommon(entity);
 }
 public virtual void DeleteMenuCommon(MenuCommon entity)
 {
     Delete(entity);
 }
 public virtual void UpdateMenuCommon(MenuCommon entity)
 {
     Update(entity);
 }
 public virtual void CreateMenuCommon(MenuCommon entity)
 {
     Create(entity);
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                getCurrentMenuItem();
                string       userName       = HttpContext.Current.User.Identity.Name;
                MainSecurity mainSecurity   = new MainSecurity();
                DataTable    tblPermissions = mainSecurity.GetPermissionAsTable(userName);
                bool         isClear        = Request.RawUrl == "/office.aspx" ? true : false;
                if (tblPermissions != null)
                {
                    doc = MenuCommon.getXML();
                    XmlNodeList boxes = doc.SelectNodes("boxes/box[@isvisible='true']");

                    bool        isCheckPermisson = false, isCount = false;
                    XmlNodeList rows = null;
                    string      a = string.Empty;
                    foreach (XmlNode box in boxes)
                    {
                        StringBuilder html        = new StringBuilder();
                        bool          isPermision = false;
                        StringBuilder htmlHeader  = new StringBuilder();
                        htmlHeader.AppendLine("<li class=\"\"><a href=\"javascript:;\"><i class=\"icon-folder-open\"></i><span class=\"title\">");
                        htmlHeader.AppendLine(box.SelectSingleNode("name").InnerText);
                        htmlHeader.AppendLine("</span><span class=\"arrow\"></span></a>");
                        htmlHeader.AppendLine("<ul class=\"sub-menu\">");
                        isCheckPermisson = bool.Parse(box.SelectSingleNode("@checkpermission").InnerText);
                        rows             = box.SelectNodes("rows/row");
                        foreach (XmlNode row in rows)
                        {
                            if (isCheckPermisson && tblPermissions.Select("Permission_ID=" + row.SelectSingleNode("Permission_ID").InnerText).Length == 1 || !isCheckPermisson)
                            {
                                isPermision = true;
                                html.AppendLine("<li class=\"" + ((row.Attributes["isvisible"] != null) ? "hidden" : string.Empty) + " " + (row.SelectSingleNode("Cpmode").InnerText == CurrentMenuItem ? "active" : string.Empty) + "\">");
                                isCount = bool.Parse(row.SelectSingleNode("IsCount").InnerText);
                                a       = "<a href=\"/office/{0}.aspx\">{1} {2}</a>";
                                if (isCount)
                                {
                                    a = string.Format(a, row.SelectSingleNode("Cpmode").InnerText, row.SelectSingleNode("MenuName").InnerText, "(<span>" + MenuCommon.getNewsCountStr(row.SelectSingleNode("Cpmode").InnerText, isClear) + "</span>)");
                                }
                                else
                                {
                                    a = string.Format(a, row.SelectSingleNode("Cpmode").InnerText, row.SelectSingleNode("MenuName").InnerText, string.Empty);
                                }

                                html.AppendLine(a);
                                html.AppendLine("</li>");
                            }
                        }
                        if (isPermision)
                        {
                            htmlHeader.Append(html.ToString());
                        }
                        htmlHeader.AppendLine("</ul></li>");

                        if (isPermision)
                        {
                            ltrHtml.Text += htmlHeader.ToString();
                        }
                    }
                }

                MainSecurity objSecurity = new MainSecurity();
                Role         objRole     = objSecurity.GetRole(Page.User.Identity.Name);

                if (Page.User.Identity.Name == "admin" || objRole.isAdministrator || objRole.isTongBienTap || objRole.isQuanTriKenh)
                {
                    aUser.Visible = true;
                }
            }
        }