コード例 #1
0
        private void ReadAllShips(List <FileInfo> xmlShipsList)
        {
            string folderPath = this.UIModel.Path.Replace(@"\\", @"\");

            if (!Directory.Exists(folderPath + PathToShips))
            {
                MessageBox.Show("No valid ships found.", "No data found.");
            }
            else
            {
                this.UIModel.UIModelShipsVanilla.Clear();
                foreach (var item in xmlShipsList)
                {
                    UIModelShip ship = m_XmlExtractor.ReadSingleShipFile(item);
                    if (ship != null && ship.Name.Length > 1 && ship.Class != "storage" && ship.Class != "cockpit")
                    {
                        this.UIModel.UIModelShips.Add(ship);
                    }
                }
                foreach (var item in this.UIModel.UIModelShips)
                {
                    this.UIModel.UIModelShipsVanilla.Add(item.Copy());
                }
            }
        }
コード例 #2
0
ファイル: UIModelShip.cs プロジェクト: PascalWauer/X4_Editor
        public UIModelShip Copy()
        {
            UIModelShip clone = (UIModelShip)this.MemberwiseClone();

            if (this.Cargo != null)
            {
                clone.Cargo = this.Cargo.Copy();
            }
            else
            {
                clone.Cargo = null;
            }
            return(clone);
        }
コード例 #3
0
        private bool FilterShipsData(object item)
        {
            if (!Ships || item == null)
            {
                return(false);
            }

            UIModelShip ship = item as UIModelShip;

            if ((Size_S && ship.Size == "S") || (m_Size_M && ship.Size == "M") || (m_Size_L && ship.Size == "L") || (m_Size_XL && ship.Size == "XL") || (m_Size_Other && (ship.Size != "S" && ship.Size != "M" && ship.Size != "L" && ship.Size != "XL")))
            {
                List <string> searchArray = new List <string>();
                List <string> searchArrayExceptNegatives = new List <string>();
                if (this.SearchText != null && this.SearchText.Length > 0)
                {
                    searchArray = this.SearchText.Split(' ').ToList();
                    searchArrayExceptNegatives = searchArray.Where(x => !x.StartsWith("-")).ToList();
                }
                // filter entered
                if (searchArray.Count > 0)
                {
                    bool found = false;
                    foreach (string searchString in searchArray)
                    {
                        if (searchString.Length > 0)
                        {
                            if (searchString.StartsWith("-"))
                            {
                                if (ship.Name.ToUpper().Contains(searchString.Replace("-", "").ToUpper()))
                                {
                                    return(false);
                                }
                            }
                            if (searchArrayExceptNegatives.Count == 0 || ship.Name.ToUpper().Contains(searchString.ToUpper()) || ship.IGName.ToUpper().Contains(searchString.ToUpper()))
                            {
                                found = true;
                            }
                        }
                    }
                    return(found);
                }
                return(true);
            }
            return(false);
        }
コード例 #4
0
        private bool FilterWaresData(object item)
        {
            UIModelWare ware = item as UIModelWare;

            if (Wares)
            {
                if ((Size_S && ware.Size == "S") || (m_Size_M && ware.Size == "M") || (m_Size_L && ware.Size == "L") || (m_Size_XL && ware.Size == "XL") || (m_Size_Other && (ware.Size != "S" && ware.Size != "M" && ware.Size != "L" && ware.Size != "XL")))
                {
                    List <string> searchArray = new List <string>();
                    List <string> searchArrayExceptNegatives = new List <string>();
                    if (this.SearchText != null && this.SearchText.Length > 0)
                    {
                        searchArray = this.SearchText.Split(' ').ToList();
                        searchArrayExceptNegatives = searchArray.Where(x => !x.StartsWith("-")).ToList();
                    }
                    // filter entered
                    if (searchArray.Count > 0)
                    {
                        bool found = false;
                        foreach (string searchString in searchArray)
                        {
                            if (searchString.Length > 0)
                            {
                                if (searchString.StartsWith("-"))
                                {
                                    if (ware.Name.ToUpper().Contains(searchString.Replace("-", "").ToUpper()))
                                    {
                                        return(false);
                                    }
                                }
                                if (searchArrayExceptNegatives.Count == 0 || ware.Name.ToUpper().Contains(searchString.ToUpper()))
                                {
                                    found = true;
                                }
                            }
                        }
                        return(found);
                    }
                    return(true);
                }
                return(false);
            }
            else
            {
                bool found = false;

                foreach (var s in m_ShipsDataView)
                {
                    UIModelShip ship = s as UIModelShip;
                    if (ship != null && ship.Name.Contains(ware.Name))
                    {
                        return(true);
                    }
                }
                foreach (var e in m_EnginesDataView)
                {
                    UIModelEngine engine = e as UIModelEngine;
                    if (engine != null && engine.Name.Contains(ware.Name))
                    {
                        return(true);
                    }
                }
                foreach (var s in m_ShieldsDataView)
                {
                    UIModelShield shield = s as UIModelShield;
                    if (shield != null && shield.Name.Contains(ware.Name))
                    {
                        return(true);
                    }
                }
                foreach (var p in m_ProjectilesDataView)
                {
                    UIModelProjectile weapon = p as UIModelProjectile;
                    if (weapon != null && weapon.Name.Contains(ware.Name))
                    {
                        return(true);
                    }
                }
                foreach (var w in m_WeaponsDataView)
                {
                    UIModelWeapon weapon = w as UIModelWeapon;
                    if (weapon != null && weapon.Name.Contains(ware.Name))
                    {
                        return(true);
                    }
                }
                foreach (var w in m_ProjectilesDataView)
                {
                    UIModelWeapon weapon = w as UIModelWeapon;
                    if (weapon != null && weapon.Name.Contains(ware.Name))
                    {
                        return(true);
                    }
                }
                foreach (var m in m_MissilesDataView)
                {
                    UIModelMissile missile = m as UIModelMissile;
                    if (missile != null && missile.Name.Contains(ware.Name))
                    {
                        return(true);
                    }
                }
                return(found);
            }
        }