Example #1
0
 public int ResetAllOtherTabs(Tab tab)
 {
     int currentYOffset = 0;
     foreach (Tab tab2 in this.Tabs)
     {
         if ((tab2 != tab) && tab2.Selected)
         {
             currentYOffset = tab2.CurrentYOffset;
             tab2.ResetSelected();
         }
     }
     return currentYOffset;
 }
Example #2
0
        private void screen_OnMouseLeftUp(Point position)
        {
            //有時滑動滾動條時點到按鈕範圍,縮小點,以後看有沒更完美的修正辦法
            var recSmall = new Rectangle(base.RealClient.X, base.RealClient.Y, base.RealClient.Width - 50, base.RealClient.Height);

            if ((Session.MainGame.mainGameScreen.PeekUndoneWork().Kind == UndoneWorkKind.Frame) && StaticMethods.PointInRectangle(position, recSmall))
            {
                if (position.Y < this.listKindToDisplay.ColumnsTop)
                {
                    Tab tab = this.FindTabByPosition(position);
                    if (tab != null)
                    {
                        tab.Selected = true;
                    }
                }
                else if (position.Y < (this.listKindToDisplay.ColumnsTop + this.columnheaderHeight))
                {
                    Column columnByPosition = this.GetColumnByPosition(position);
                    if (columnByPosition != null)
                    {
                        PropertyComparer comparer = new PropertyComparer(columnByPosition.Name, columnByPosition.IsNumber, columnByPosition.SmallToBig, columnByPosition.ItemID);
                        this.gameObjectList.StableSort(comparer);
                        this.listKindToDisplay.ResetAllTextures();
                        columnByPosition.SmallToBig = !columnByPosition.SmallToBig;
                    }
                }
                else
                {
                    GameObject gameObjectByPosition;
                    if (this.ShowCheckBox)
                    {
                        gameObjectByPosition = this.GetGameObjectByPosition(position);
                        if (gameObjectByPosition != null)
                        {
                            if (this.listKindToDisplay.IsInEditableColumn(position))
                            {
                                if ((gameObjectByPosition.Selected || (this.SelectedItemMaxCount <= 0)) || (this.gameObjectList.GetSelectedList().Count < this.SelectedItemMaxCount))
                                {
                                    if (this.MultiSelecting)
                                    {
                                        /*
                                         * this.SelectingRows = true;
                                         * this.SelectingBool = gameObjectByPosition.Selected;
                                         * this.SelectedItemList = this.gameObjectList.GetSelectedList();
                                         */
                                    }
                                    else
                                    {
                                        gameObjectByPosition.Selected = !gameObjectByPosition.Selected;

                                        this.gameObjectList.SetOtherUnSelected(gameObjectByPosition);
                                    }
                                    base.OKButtonEnabled = this.gameObjectList.HasSelectedItem() || (gameObjectByPosition is Faction);
                                    this.ResetEditableTextures();
                                    if (gameObjectByPosition.Selected)
                                    {
                                        this.SelectedItem = gameObjectByPosition;
                                        if (!(this.MultiSelecting || !Setting.Current.GlobalVariables.SingleSelectionOneClick))
                                        {
                                            this.iGameFrame.OK();
                                        }
                                        else
                                        {
                                            //Session.MainGame.mainGameScreen.PlayNormalSound(this.SelectSoundFile);
                                        }
                                    }
                                    else
                                    {
                                        this.SelectedItem = null;
                                    }
                                }
                            }
                            else
                            {
                                if (gameObjectByPosition is Troop)
                                {
                                    if ((this.iTroopDetail != null) && (base.Function != FrameFunction.Jump))
                                    {
                                        this.iTroopDetail.SetPosition(ShowPosition.Center);
                                        this.iTroopDetail.SetTroop(gameObjectByPosition);
                                        this.iTroopDetail.IsShowing = true;
                                    }
                                    Session.MainGame.mainGameScreen.JumpTo((gameObjectByPosition as Troop).Position);
                                }
                                else if (gameObjectByPosition is Person)
                                {
                                    if ((this.iPersonDetail != null) && (base.Function != FrameFunction.Jump))
                                    {
                                        this.iPersonDetail.SetPosition(ShowPosition.Center);
                                        this.iPersonDetail.SetPerson(gameObjectByPosition);
                                        this.iPersonDetail.IsShowing = true;
                                    }
                                    if (!(gameObjectByPosition as Person).IsCaptive)
                                    {
                                        Session.MainGame.mainGameScreen.JumpTo((gameObjectByPosition as Person).Position);
                                    }
                                }
                                else if (gameObjectByPosition is Architecture)
                                {
                                    if ((this.iArchitectureDetail != null) && (base.Function != FrameFunction.Jump))
                                    {
                                        this.iArchitectureDetail.SetPosition(ShowPosition.Center);
                                        this.iArchitectureDetail.SetArchitecture(gameObjectByPosition);
                                        this.iArchitectureDetail.IsShowing = true;
                                    }
                                    Session.MainGame.mainGameScreen.JumpTo((gameObjectByPosition as Architecture).Position);
                                }
                                else if (gameObjectByPosition is Military)
                                {
                                    Session.MainGame.mainGameScreen.JumpTo((gameObjectByPosition as Military).Position);
                                }
                                else if (gameObjectByPosition is Faction)
                                {
                                    if ((this.iFactionTechniques != null) && (base.Function != FrameFunction.Jump))
                                    {
                                        this.iFactionTechniques.SetArchitecture(null);
                                        this.iFactionTechniques.SetFaction(gameObjectByPosition, false);
                                        this.iFactionTechniques.SetPosition(ShowPosition.Center);
                                        this.iFactionTechniques.IsShowing = true;
                                    }
                                    Session.MainGame.mainGameScreen.JumpTo((gameObjectByPosition as Faction).Leader.Position);
                                }
                                else if (gameObjectByPosition is Captive)
                                {
                                    if ((this.iPersonDetail != null) && (base.Function != FrameFunction.Jump))
                                    {
                                        this.iPersonDetail.SetPosition(ShowPosition.Center);
                                        this.iPersonDetail.SetPerson((gameObjectByPosition as Captive).CaptivePerson);
                                        this.iPersonDetail.IsShowing = true;
                                    }
                                }
                                else if (gameObjectByPosition is Treasure)
                                {
                                    if ((this.iTreasureDetail != null) && (base.Function != FrameFunction.Jump))
                                    {
                                        this.iTreasureDetail.SetPosition(ShowPosition.Center);
                                        this.iTreasureDetail.SetTreasure(gameObjectByPosition);
                                        this.iTreasureDetail.IsShowing = true;
                                    }
                                    if ((gameObjectByPosition as Treasure).BelongedPerson != null)
                                    {
                                        Session.MainGame.mainGameScreen.JumpTo((gameObjectByPosition as Treasure).BelongedPerson.Position);
                                    }
                                }
                                else if (gameObjectByPosition is Information)
                                {
                                    if (base.Function != FrameFunction.Jump)
                                    {
                                        Session.MainGame.mainGameScreen.JumpTo((gameObjectByPosition as Information).Position);
                                    }
                                }
                                else if (this.listKindToDisplay.SelectedTab.ListMethod != null)
                                {
                                    this.PushSubKindByName(this.listKindToDisplay.SelectedTab.ListKind, StaticMethods.GetListMethodValue(gameObjectByPosition, this.listKindToDisplay.SelectedTab.ListMethod) as GameObjectList);
                                }
                                if (gameObjectByPosition != null)
                                {
                                    base.TriggerItemClick();
                                }
                            }
                        }
                    }
                    else
                    {
                        gameObjectByPosition = this.GetGameObjectByPosition(position);
                        if (gameObjectByPosition != null)
                        {
                            if (this.listKindToDisplay.SelectedTab.ListMethod != null)
                            {
                                this.PushSubKindByName(this.listKindToDisplay.SelectedTab.ListKind, StaticMethods.GetListMethodValue(gameObjectByPosition, this.listKindToDisplay.SelectedTab.ListMethod) as GameObjectList);
                            }
                            else
                            {
                                if (gameObjectByPosition is Troop)
                                {
                                    if ((this.iTroopDetail != null) && (base.Function != FrameFunction.Jump))
                                    {
                                        this.iTroopDetail.SetPosition(ShowPosition.Center);
                                        this.iTroopDetail.SetTroop(gameObjectByPosition);
                                        this.iTroopDetail.IsShowing = true;
                                    }
                                    Session.MainGame.mainGameScreen.JumpTo((gameObjectByPosition as Troop).Position);
                                }
                                else if (gameObjectByPosition is Person)
                                {
                                    if ((this.iPersonDetail != null) && (base.Function != FrameFunction.Jump))
                                    {
                                        this.iPersonDetail.SetPosition(ShowPosition.Center);
                                        this.iPersonDetail.SetPerson(gameObjectByPosition);
                                        this.iPersonDetail.IsShowing = true;
                                    }
                                    if (!(gameObjectByPosition as Person).IsCaptive)
                                    {
                                        Session.MainGame.mainGameScreen.JumpTo((gameObjectByPosition as Person).Position);
                                    }
                                }
                                else if (gameObjectByPosition is Architecture)
                                {
                                    if ((this.iArchitectureDetail != null) && (base.Function != FrameFunction.Jump))
                                    {
                                        this.iArchitectureDetail.SetPosition(ShowPosition.Center);
                                        this.iArchitectureDetail.SetArchitecture(gameObjectByPosition);
                                        this.iArchitectureDetail.IsShowing = true;
                                    }
                                    Session.MainGame.mainGameScreen.JumpTo((gameObjectByPosition as Architecture).Position);
                                }
                                else if (gameObjectByPosition is Military)
                                {
                                    Session.MainGame.mainGameScreen.JumpTo((gameObjectByPosition as Military).Position);
                                }
                                else if (gameObjectByPosition is Faction)
                                {
                                    if ((this.iFactionTechniques != null) && (base.Function != FrameFunction.Jump))
                                    {
                                        this.iFactionTechniques.SetArchitecture(null);
                                        this.iFactionTechniques.SetFaction(gameObjectByPosition, false);
                                        this.iFactionTechniques.SetPosition(ShowPosition.Center);
                                        this.iFactionTechniques.IsShowing = true;
                                    }
                                    Session.MainGame.mainGameScreen.JumpTo((gameObjectByPosition as Faction).Leader.Position);
                                }
                                else if (gameObjectByPosition is Captive)
                                {
                                    if ((this.iPersonDetail != null) && (base.Function != FrameFunction.Jump))
                                    {
                                        this.iPersonDetail.SetPosition(ShowPosition.Center);
                                        this.iPersonDetail.SetPerson((gameObjectByPosition as Captive).CaptivePerson);
                                        this.iPersonDetail.IsShowing = true;
                                    }
                                }
                                else if (gameObjectByPosition is Treasure)
                                {
                                    if ((this.iTreasureDetail != null) && (base.Function != FrameFunction.Jump))
                                    {
                                        this.iTreasureDetail.SetPosition(ShowPosition.Center);
                                        this.iTreasureDetail.SetTreasure(gameObjectByPosition);
                                        this.iTreasureDetail.IsShowing = true;
                                    }
                                    if ((gameObjectByPosition as Treasure).BelongedPerson != null)
                                    {
                                        Session.MainGame.mainGameScreen.JumpTo((gameObjectByPosition as Treasure).BelongedPerson.Position);
                                    }
                                }
                                else if (gameObjectByPosition is Information)
                                {
                                    if (base.Function != FrameFunction.Jump)
                                    {
                                        Session.MainGame.mainGameScreen.JumpTo((gameObjectByPosition as Information).Position);
                                    }
                                }
                                if (gameObjectByPosition != null)
                                {
                                    base.TriggerItemClick();
                                }
                            }
                        }
                    }
                }
            }


            /////////////////////////////////////////////////

            if (Session.MainGame.mainGameScreen.PeekUndoneWork().Kind == UndoneWorkKind.Frame)
            {
                this.MovingHorizontalScrollBar = false;
                this.MovingVerticalScrollBar   = false;
                this.SelectingRows             = false;
            }
        }
Example #3
0
 public void LoadFromXMLNode(XmlNode rootNode)
 {
     XmlNode node = rootNode.ChildNodes.Item(0);
     foreach (XmlNode node2 in node.ChildNodes)
     {
         Font font;
         Microsoft.Xna.Framework.Graphics.Color color;
         Column item = new Column(this.tabList);
         item.ID = int.Parse(node2.Attributes.GetNamedItem("ID").Value);
         item.Name = node2.Attributes.GetNamedItem("Name").Value;
         item.IsNumber = bool.Parse(node2.Attributes.GetNamedItem("IsNumber").Value);
         item.DisplayName = node2.Attributes.GetNamedItem("DisplayName").Value;
         item.MinWidth = int.Parse(node2.Attributes.GetNamedItem("MinWidth").Value);
         item.DetailLevel = int.Parse(node2.Attributes.GetNamedItem("DetailLevel").Value);
         if (node2.Attributes.GetNamedItem("CountToDisplay") != null)
         {
             item.CountToDisplay = bool.Parse(node2.Attributes.GetNamedItem("CountToDisplay").Value);
         }
         if (node2.Attributes.GetNamedItem("ItemID") != null)
         {
             item.ItemID = int.Parse(node2.Attributes.GetNamedItem("ItemID").Value);
         }
         item.SmallToBig = !item.IsNumber;
         StaticMethods.LoadFontAndColorFromXMLNode(node2, out font, out color);
         item.ColumnTextList = new FreeTextList(this.tabList.graphicsDevice, font);
         item.ColumnTextList.TextColor = color;
         item.ColumnTextList.Align = (TextAlign) Enum.Parse(typeof(TextAlign), node2.Attributes.GetNamedItem("Align").Value);
         item.Text.Text = item.DisplayName;
         this.AllColumns.Add(item);
     }
     node = rootNode.ChildNodes.Item(1);
     this.tabMargin = int.Parse(node.Attributes.GetNamedItem("Margin").Value);
     foreach (XmlNode node2 in node.ChildNodes)
     {
         Tab tab = new Tab(this.tabList, this);
         tab.ID = int.Parse(node2.Attributes.GetNamedItem("ID").Value);
         tab.Name = node2.Attributes.GetNamedItem("Name").Value;
         tab.DisplayName = node2.Attributes.GetNamedItem("DisplayName").Value;
         if (node2.Attributes.GetNamedItem("ListKind") != null)
         {
             tab.ListKind = node2.Attributes.GetNamedItem("ListKind").Value;
         }
         if (node2.Attributes.GetNamedItem("ListMethod") != null)
         {
             tab.ListMethod = node2.Attributes.GetNamedItem("ListMethod").Value;
         }
         tab.LoadColumnsFromString(node2.Attributes.GetNamedItem("Columns").Value);
         if (node2.Attributes.GetNamedItem("SortColumnID") != null)
         {
             tab.SortColumnID = int.Parse(node2.Attributes.GetNamedItem("SortColumnID").Value);
         }
         if (node2.Attributes.GetNamedItem("SmallToBig") != null)
         {
             tab.SmallToBig = bool.Parse(node2.Attributes.GetNamedItem("SmallToBig").Value);
         }
         tab.Text.Text = tab.DisplayName;
         this.Tabs.Add(tab);
     }
 }