Beispiel #1
0
 public Form1()
 {
     InitializeComponent();
     //Initialize the list of wanted columns
     wantedcolumns = new List<Column>();
     //values for the last measured result
     XmlManager<DataCol> columnloader = new XmlManager<DataCol>();
     datacolumns = columnloader.Load("Content/XMLFile1.xml");
     realpowerdict = new Dictionary<string, Column>();
     //columnobjectlist = new List<Baselist>();
     colobjinterflistbl = new List<IBaselist>();//!
     colobjinterflist = new List<IBaselist>();//!
     //diff variable here baseline values and loaders
     XmlManager<DataCol> columnloaderbl = new XmlManager<DataCol>();
     datacolumnsbl = columnloaderbl.Load("Content/XMLFile1.xml");
     realpowerdictbl = new Dictionary<string, Column>();
     wantedcolumnsbl = new List<Column>();
     phasebuttonarray = new Button[] { button6, button7, button8, button9, button10, button11, button12 };
     phasebuttonlist = new List<Button>(phasebuttonarray);
     phasemarkerstyles = new MarkerStyle[] { MarkerStyle.Circle, MarkerStyle.Cross, MarkerStyle.Diamond, 
         MarkerStyle.Square, MarkerStyle.Triangle, MarkerStyle.Star4, MarkerStyle.Star10 };
     phasemarkerlist = new List<MarkerStyle>(phasemarkerstyles);
     //some files to play with should remove/make another plan later
     filenamedata = "C:/values/2015y09m24d_13h35m42s_SN121538001575_S230_60_LN_LoL_HiL_119.csv";//some test files
     populatedatatestunit(filenamedata);
     //****************************************populate the diff data******************************************************
     filenamebl = "C:/values/2015y09m24d_13h35m42s_SN121538001575_S230_60_LN_LoL_HiL_119.csv";//some test files
     populatedatabaseline(filenamebl);
     //************************************************
     //test for some answers
     Richtextedit();
     setupploatarea();
     //plotIdc();
     this.textBox1.Text = "0°";
 }
Beispiel #2
0
 public TestSuite()
 {
     TestSuiteManager = new XmlManager();
     TestSuiteFinder = new TestSuiteFinder();
     ConnectionStringsFinder = new ConnectionStringsFinder();
     ConfigurationFinder = new ConfigurationFinder();
 }
Beispiel #3
0
        public override void LoadContent()
        {
            base.LoadContent();

            _content = new ContentManager(ScreenManager.Instance.Content.ServiceProvider, "Content");

            XmlManager<Player> playerLoader = new XmlManager<Player>();
            _player = playerLoader.Load("Content/Data/Gameplay/Player.xml");
            _player.LoadContent();

            _alterverse = new Alterverse(OnAlternativeChange);
            _alterverse.LoadContent();

            _levelView = new LevelView(_alterverse.CurrentLevel);
            _levelView.LoadContent();

            _alterIcons = new List<AlternativeIcon>();
            AlternativeIcon altIcon = new AlternativeIcon(new Vector2(100, 50), "1");
            altIcon.LoadContent();
            altIcon.IsActive = true;
            _alterIcons.Add(altIcon);

            //XmlManager<Map> mapLoader = new XmlManager<Map>();
            //_map = mapLoader.Load("Load/Gameplay/Maps/Map1.xml");
            //_map.LoadContent();

            _mouseState = Mouse.GetState();

            _accessedTiles = new List<Tile>();
        }
        public void Load_ValidFile_TwoTestsLoaded()
        {
            var manager = new XmlManager();
            manager.Load(filename, true);

            Assert.That(manager.TestSuite.Tests, Has.Count.EqualTo(2));
        }
        public void Load_ValidFile_Success()
        {
            var manager = new XmlManager();
            manager.Load(filename, true);

            Assert.That(manager.TestSuite, Is.Not.Null);
        }
        public static void CheckForUpdates()
        {
            SerializableVersion version;
            _xmlManager = new XmlManager<SerializableVersion>() { Type = typeof(SerializableVersion) };

            try
            {
                version = _xmlManager.Load("Version.xml");
            }
            catch (Exception e)
            {
                MessageBox.Show(
                    e.Message + "\n\n" + e.InnerException + "\n\n If you don't know how to fix this, please verwrite Version.xml with the default file.", "Error loading Version.xml");
                return;
            }

            var versionXmlUrl =
                @"https://raw.githubusercontent.com/Epix37/Hearthstone-Deck-Tracker/master/Hearthstone%20Deck%20Tracker/Version.xml";

            var xml = new WebClient().DownloadString(versionXmlUrl);

            var currentVersion = new Version(version.ToString());
            var newVersion = new Version(_xmlManager.LoadFromString(xml).ToString());

            if (newVersion > currentVersion)
            {
                var releaseDownloadUrl = @"https://github.com/Epix37/Hearthstone-Deck-Tracker/releases";
                if (
                    MessageBox.Show("New version available at: \n" + releaseDownloadUrl, "New version available!",
                                    MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                {
                    System.Diagnostics.Process.Start(releaseDownloadUrl);
                }
            }
        }
Beispiel #7
0
        public void Load_InvalidFile_Successfully()
        {
            var filename = DiskOnFile.CreatePhysicalFile("TestSuiteInvalidSyntax.xml", "NBi.Testing.Unit.Xml.Resources.XmlManagerInvalidSyntax.xml");

            var manager = new XmlManager();
            Assert.Throws<ArgumentException>(delegate { manager.Load(filename); });
        }
        public ScreenManager()
        {
            //Dimensions = new Vector2(640, 480);
            //CurrentScreen = new SplashScreen();
            ////CurrentScreen = new GameplayScreen();
            ////currentScreen = new SongismScreen();
            //xmlGameScreenManager = new XmlManager<GameScreen>();
            //xmlGameScreenManager.Type = CurrentScreen.Type;
            ////CurrentScreen = xmlGameScreenManager.Load("Load/SplashScreen.xml");
            //CurrentScreen = xmlGameScreenManager.Load(Path.Combine(Globals.LoadGameplayScreensDirectory, "SplashScreen.xml"));

            /* Start game at splash screen */
            //Dimensions = new Vector2(640, 480);
            //CurrentScreen = new SplashScreen();
            //xmlGameScreenManager = new XmlManager<GameScreen>();
            //xmlGameScreenManager.Type = CurrentScreen.Type;
            //CurrentScreen = xmlGameScreenManager.Load(Path.Combine(Globals.LoadGameplayScreensDirectory, "SplashScreen.xml"));

            /* Start game at title screen */
            Dimensions = new Vector2(640, 480);
            CurrentScreen = new TitleScreen();
            //CurrentScreen = new LoadingScreen();
            xmlGameScreenManager = new XmlManager<GameScreen>();
            xmlGameScreenManager.Type = CurrentScreen.Type;

            /* Start game at gameplay screen */
            //Dimensions = new Vector2(640, 480);
            //CurrentScreen = new GameplayScreen();
            //xmlGameScreenManager = new XmlManager<GameScreen>();
            //xmlGameScreenManager.Type = CurrentScreen.Type;
        }
 public void Open(string fullPath)
 {
     var manager = new XmlManager();
     manager.Load(fullPath);
     listTestXml =  manager.TestSuite.Tests;
     settingsXml = manager.TestSuite.Settings;
 }
Beispiel #10
0
 public ScreenManager()
 {
     Dimensions = new Vector2(800, 600);
     _CurrentScreen = new SplashScreen();
     _XmlGameScreenManager = new XmlManager<BaseScreen>();
     _CurrentScreen = _XmlGameScreenManager.Load("Content/SplashScreen/splashScreen.xml", typeof(SplashScreen));
 }
        public void Load_ValidFile_Success()
        {
            var manager = new XmlManager();
            manager.Load(testSuite, settings, false);

            Assert.That(manager.TestSuite, Is.Not.Null);
        }
Beispiel #12
0
 private void LoadPlayer()
 {
     var playerLoader = new XmlManager<Player>();
     Player = playerLoader.Load("Load/Gameplay/Player.xml");
     Player.LoadContent();
     ScreenManager.Instance.CenterImage(Player.Image);
 }
Beispiel #13
0
 public Form1()
 {
     //for running processe/tests
     testrunnernostop = new TestrunnerNOstop();
     storedvalues = new List<string>();
     status = "unknown";
     error = ".";
     //test = ".";
     Serverreporter = new Report();
     CmdReader = new Readcmd();
     InitializeComponent();
     //tests = new Parameter();//I do not need this
     report1 = new Report();
     keepreporting = true;
     xmltestmanager = new XmlManager<Parameter>();
     // the the xmlfile the start off serialization
     //a instance of Parameter will be assigned to tests
     tests = xmltestmanager.Load("Content/rackparameterv2.xml");
     //Add the tests that does not have a quick test parameter in xml
     foreach (Parameter.Test t in tests.Tests())
     {
         /*saves all test name here so that it can be filtered later
         when the product selection is done*/
         storedvalues.Add(t.id);
     }
     textBox1.Focus();
 }
 public override void LoadContent()
 {
     base.LoadContent();
     SoundManager.Instance.LoadContent();
     ///The player class variables gets stored in a defferent class
     /// Two different xml loader for 2 kinds of xml classes
     XmlManager<Loader.parameter> playerloader = new XmlManager<Loader.parameter>();
     XmlManager<map> mapLoader = new XmlManager<map>();
     //loadedparams = paramloader.Load("Content/Gameplay/Explosion/parameters.xml");
     //player loader is the xml manager instance for manual created xml
     playerparameters = playerloader.Load("Content/Gameplay/Player.xml");
     enemygreenbulletparameter = playerloader.Load("Content/Gameplay/Enemy/Enemyweapons.xml");//Enemybullets
     playerbulletparameter = playerloader.Load("Content/Gameplay/Playergadgets.xml");//bullet
     animatedparameter = playerloader.Load("Content/Gameplay/Animatedgraphics.xml");
     smallexplosion = playerloader.Load("Content/Gameplay/Smallexplotion.xml");
     //use map loader for xml created in Tiled.exe
     tilesandenemies = mapLoader.Load("Content/Gameplay/Map/doodle_ink.xml");
     //playerbulletparam has set shorthand
     BulletHandler.Instance.Playerbulletparam = playerbulletparameter;//instance
     BulletHandler.Instance.Enemygreenbulletparam = enemygreenbulletparameter;//instance
     BulletHandler.Instance.Animatedgraphicsparam = animatedparameter;//instance
     BulletHandler.Instance.Addloaderparameter(smallexplosion);
     LoadTilesandEnemies();//Load player
     //Load all images and sounds
     tilesandenemies.LoadContent();
     player.LoadContent();
 }
Beispiel #15
0
        public void LoadContent()
        {
            XmlManager<Level> levelLoader = new XmlManager<Level>();
            Level level = levelLoader.Load("Content/Data/Gameplay/Level.xml");
            level.Initialization();

            _alternatives.Add(level);
        }
Beispiel #16
0
 public ScreenManager()
 {
     Dimensions = new Vector2(640, 480);
     currentScreen = new SplashScreen();
     xmlGameScreenManager = new XmlManager<GameScreen>();
     xmlGameScreenManager.Type = currentScreen.Type;
     currentScreen = xmlGameScreenManager.Load("Load/SplashScreen.xml");
 }
 void menu_OnMenuChange(object sender, EventArgs e)
 {
     XmlManager<Menu> XmlMenuManager = new XmlManager<Menu>();
     menu.UnloadContent();
     // Adding Transistions if needed //
     menu = XmlMenuManager.Load(menu.ID);
     menu.LoadContent();
 }
Beispiel #18
0
 private ScreenManager()
 {
     Dimensions = new Vector2(640, 480);
     currentScreen = new MenuScreen();
     xmlGameScreenManager = new XmlManager<GameScreen>();
     xmlGameScreenManager.Type = currentScreen.Type;
     //currentScreen = xmlGameScreenManager.Load("Data/sprites_level1.xml");
 }
Beispiel #19
0
 private ScreenManager()
 {
     Dimensions = new Vector2(639, 480); //640
     currentScreen = new SplashScreen();
     xmlGameScreenManager = new XmlManager<GameScreen>();
     xmlGameScreenManager.Type = currentScreen.Type;
     currentScreen = xmlGameScreenManager.Load("Content/SplashScreen.xml");
 }
        private Inventory()
        {
            XmlManager<List<Songism>> songBookLoader = new XmlManager<List<Songism>>();
            SongBook = songBookLoader.Load(System.IO.Path.Combine(Globals.LoadGameplayDirectory, "SongBook.xml"));

            XmlManager<List<InventoryItem>> xmItemsLoader = new XmlManager<List<InventoryItem>> ();
            Items = xmItemsLoader.Load (System.IO.Path.Combine (Globals.LoadGameplayDirectory, "InventoryItems.xml"));
        }
 public OverworldSprite Load()
 {
     OverworldSprite playerToBeLoaded = new OverworldSprite();
     XmlManager<OverworldSprite> playerLoader = new XmlManager<OverworldSprite>();
     playerToBeLoaded = playerLoader.Load("Load/Gameplay/SavedGames/Player4.xml");
     //playerToBeLoaded.Image = playerToSave.Image;
     return playerToBeLoaded;
 }
        public override void LoadContent()
        {
            base.LoadContent();

            XmlManager<Menu> menuLoader = new XmlManager<Menu>();
            currentMenu = menuLoader.Load(Path);
            currentMenu.LoadContent();
        }
Beispiel #23
0
 private ScreenManager()
 {
     Dimensions = new Vector2(640, 480);
     _xmlGameScreenManager = new XmlManager<GameScreen>();
     _xmlGameScreenManager.Type = typeof(SplashScreen);
     _currentScreen = _xmlGameScreenManager.Load("Content/Data/SplashScreen.xml");
     Random = new Random();
 }
Beispiel #24
0
        public void Load_InvalidFormat_ThrowException()
        {
            var filename = DiskOnFile.CreatePhysicalFile("InvalidFormat.nbits", "NBi.Testing.Unit.Xml.Resources.XmlManagerInvalidFormat.xml");

            var manager = new XmlManager();
            var ex = Assert.Throws<ArgumentException>(delegate { manager.Load(filename); });
            Assert.That(ex.Message, Is.StringContaining("At line 14"));
        }
Beispiel #25
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            player = new Player();
            spriteXmlManager = new XmlManager(typeof(List<Sprite>));
            rectangleXmlManager = new XmlManager(typeof(List<Rectangle>));

            base.Initialize();
        }
Beispiel #26
0
        public void LoadContent(ContentManager content)
        {
            Font = content.Load<SpriteFont>(pathToFont);

            XmlManager<Cursor> manager = new XmlManager<Cursor>();
            manager.type = typeof(Cursor);
            cursor = manager.Load(@"Content\Xml\Cursor.xml");
            cursor.LoadContent(content);
        }
 public void ChangeScreen(string screenName)
 {
     newScreen = ScreenFactory.CreateScreen(screenName);
     xmlGameScreenManager = new XmlManager<GameScreen>();
     xmlGameScreenManager.Type = newScreen.Type;
     currentScreen.UnloadContent();
     currentScreen = xmlGameScreenManager.Load("Loads/" + screenName + ".xml");
     currentScreen.LoadContent(Content);
 }
Beispiel #28
0
 void menu_OnMenuChange(object sender, EventArgs e)
 {
     XmlManager<Menu> xmlMenuManager = new XmlManager<Menu>();
     menu.UnloadContent();
     menu = xmlMenuManager.Load(menu.ID);
     menu.LoadContent();
     menu.OnMenuChange += menu_OnMenuChange;
     menu.Transition(0.0f);
 }
Beispiel #29
0
        public void Load_ValidFile_TestContentIsCorrect()
        {
            var filename = DiskOnFile.CreatePhysicalFile("TestContentIsCorrect.xml", "NBi.Testing.Unit.Xml.Resources.XmlManagerSample.xml");

            var manager = new XmlManager();
            manager.Load(filename);

            Assert.That(manager.TestSuite.Tests[0].Content, Is.Not.Null);
        }
Beispiel #30
0
        public void Load_InvalidFile_ExceptionHasCorrectInformation()
        {
            var filename = DiskOnFile.CreatePhysicalFile("TestSuiteInvalidSyntax.xml", "NBi.Testing.Unit.Xml.Resources.XmlManagerInvalidSyntax.xml");

            var manager = new XmlManager();
            var exception = Assert.Throws<ArgumentException>(delegate { manager.Load(filename); });
            Assert.That(exception.Message, Is.StringContaining("1 error has been found during the validation of the test-suite"));
            Assert.That(exception.Message, Is.StringContaining("\tAt line 4: The element 'test' in namespace 'http://NBi/TestSuite' has invalid child element 'syntacticallyCorrect' in namespace 'http://NBi/TestSuite'."));
        }
Beispiel #31
0
        /// <summary>
        /// Load the VehicleMod from the XmlNode.
        /// </summary>
        /// <param name="objNode">XmlNode to load.</param>
        /// <param name="objVehicle">Vehicle that the mod is attached to.</param>
        /// <param name="blnCopy">Indicates whether a new item will be created as a copy of this one.</param>
        public void Load(XmlNode objNode, Vehicle objVehicle, bool blnCopy = false)
        {
            if (blnCopy)
            {
                _guiID = Guid.NewGuid();
            }
            else
            {
                objNode.TryGetField("guid", Guid.TryParse, out _guiID);
            }
            objNode.TryGetStringFieldQuickly("name", ref _strName);
            if (!objNode.TryGetStringFieldQuickly("sourceid", ref _strSourceId))
            {
                _strSourceId = XmlManager.Load("vehicles.xml").SelectSingleNode("/chummer/weaponmounts/weaponmount[name = \"" + _strName + "\"]/id")?.InnerText ?? Guid.NewGuid().ToString("D");
            }
            objNode.TryGetStringFieldQuickly("category", ref _strCategory);
            objNode.TryGetStringFieldQuickly("limit", ref _strLimit);
            objNode.TryGetInt32FieldQuickly("slots", ref _intSlots);
            objNode.TryGetStringFieldQuickly("weaponmountcategories", ref _strAllowedWeaponCategories);
            objNode.TryGetStringFieldQuickly("allowedweapons", ref _strAllowedWeapons);
            objNode.TryGetStringFieldQuickly("page", ref _strPage);
            objNode.TryGetStringFieldQuickly("avail", ref _strAvail);
            objNode.TryGetStringFieldQuickly("cost", ref _strCost);
            objNode.TryGetDecFieldQuickly("markup", ref _decMarkup);
            objNode.TryGetStringFieldQuickly("source", ref _strSource);
            objNode.TryGetStringFieldQuickly("location", ref _strLocation);
            objNode.TryGetBoolFieldQuickly("included", ref _blnIncludeInVehicle);
            objNode.TryGetBoolFieldQuickly("equipped", ref _blnEquipped);
            if (!_blnEquipped)
            {
                objNode.TryGetBoolFieldQuickly("installed", ref _blnEquipped);
            }

            XmlNode xmlChildrenNode = objNode["weapons"];

            if (xmlChildrenNode != null)
            {
                using (XmlNodeList xmlWeaponList = xmlChildrenNode.SelectNodes("weapon"))
                    if (xmlWeaponList != null)
                    {
                        foreach (XmlNode xmlWeaponNode in xmlWeaponList)
                        {
                            Weapon objWeapon = new Weapon(_objCharacter)
                            {
                                ParentVehicle = Parent,
                                ParentMount   = this
                            };
                            objWeapon.Load(xmlWeaponNode, blnCopy);
                            _lstWeapons.Add(objWeapon);
                        }
                    }
            }
            xmlChildrenNode = objNode["weaponmountoptions"];
            if (xmlChildrenNode != null)
            {
                using (XmlNodeList xmlWeaponMountOptionList = xmlChildrenNode.SelectNodes("weaponmountoption"))
                    if (xmlWeaponMountOptionList != null)
                    {
                        foreach (XmlNode xmlWeaponMountOptionNode in xmlWeaponMountOptionList)
                        {
                            WeaponMountOption objWeaponMountOption = new WeaponMountOption(_objCharacter);
                            objWeaponMountOption.Load(xmlWeaponMountOptionNode);
                            WeaponMountOptions.Add(objWeaponMountOption);
                        }
                    }
            }
            xmlChildrenNode = objNode["mods"];
            if (xmlChildrenNode != null)
            {
                using (XmlNodeList xmlModList = xmlChildrenNode.SelectNodes("mod"))
                    if (xmlModList != null)
                    {
                        foreach (XmlNode xmlModNode in xmlModList)
                        {
                            VehicleMod objMod = new VehicleMod(_objCharacter)
                            {
                                Parent            = Parent,
                                WeaponMountParent = this
                            };
                            objMod.Load(xmlModNode);
                            _lstMods.Add(objMod);
                        }
                    }
            }
            objNode.TryGetStringFieldQuickly("notes", ref _strNotes);
            objNode.TryGetBoolFieldQuickly("discountedcost", ref _blnDiscountCost);
            objNode.TryGetStringFieldQuickly("extra", ref _strExtra);
        }
Beispiel #32
0
        /// <summary>
        /// Performs actions based on the character's last loaded AppVersion attribute.
        /// </summary>
        private void LegacyShim()
        {
            //Unstored Cost and LP values prior to 5.190.2 nightlies.
            if (_objCharacter.LastSavedVersion <= Version.Parse("5.190.0"))
            {
                XmlDocument objXmlDocument          = XmlManager.Load("lifestyles.xml");
                XmlNode     objLifestyleQualityNode = objXmlDocument.SelectSingleNode("/chummer/qualities/quality[id = \"" + _guiID + "\"]") ??
                                                      objXmlDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + _strName + "\"]");
                if (objLifestyleQualityNode == null)
                {
                    var lstQualities = new List <ListItem>();
                    lstQualities.AddRange(
                        from XmlNode objNode in
                        objXmlDocument.SelectNodes("/chummer/qualities/quality")
                        select new ListItem
                    {
                        Value = objNode["name"].InnerText,
                        Name  = objNode["translate"]?.InnerText ?? objNode["name"].InnerText
                    });
                    var frmSelect = new frmSelectItem
                    {
                        DropdownItems = lstQualities,
                        Description   =
                            LanguageManager.GetString("String_CannotFindLifestyleQuality").Replace("{0}", _strName)
                    };
                    frmSelect.ShowDialog();
                    if (frmSelect.DialogResult == DialogResult.Cancel)
                    {
                        return;
                    }

                    objLifestyleQualityNode = objXmlDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + frmSelect.SelectedItem + "\"]");
                }
                int     intTemp = 0;
                decimal decTemp = 0;
                if (objLifestyleQualityNode.TryGetDecFieldQuickly("cost", ref decTemp))
                {
                    Cost = decTemp;
                }
                if (objLifestyleQualityNode.TryGetInt32FieldQuickly("lp", ref intTemp))
                {
                    LP = intTemp;
                }
                if (objLifestyleQualityNode.TryGetInt32FieldQuickly("area", ref intTemp))
                {
                    AreaCost = intTemp;
                }
                if (objLifestyleQualityNode.TryGetInt32FieldQuickly("comforts", ref intTemp))
                {
                    ComfortCost = intTemp;
                }
                if (objLifestyleQualityNode.TryGetInt32FieldQuickly("security", ref intTemp))
                {
                    SecurityCost = intTemp;
                }
                if (objLifestyleQualityNode.TryGetInt32FieldQuickly("areaminimum", ref intTemp))
                {
                    AreaMinimum = intTemp;
                }
                if (objLifestyleQualityNode.TryGetInt32FieldQuickly("comfortsminimum", ref intTemp))
                {
                    ComfortMinimum = intTemp;
                }
                if (objLifestyleQualityNode.TryGetInt32FieldQuickly("securityminimum", ref intTemp))
                {
                    SecurityMinimum = intTemp;
                }
                if (objLifestyleQualityNode.TryGetInt32FieldQuickly("multiplier", ref intTemp))
                {
                    Multiplier = intTemp;
                }
                if (objLifestyleQualityNode.TryGetInt32FieldQuickly("multiplierbaseonly", ref intTemp))
                {
                    BaseMultiplier = intTemp;
                }
            }
        }
Beispiel #33
0
        //public List<ExcelField> Fields { get { return _fields == null ? _fields = GetFields() : _fields; } }
        private List <ExcelField> GetFields()
        {
            var list  = new List <ExcelField>();
            var nodeP = XmlManager.GetSingle(string.Format("/Tables/Excel[@Name='{0}']", CollectTable.Name), XmlEnum.Field);

            if (nodeP != null)
            {
                var nodes = nodeP.SelectNodes("Field");
                if (nodes != null && nodes.Count > 0)
                {
                    for (var i = 0; i < nodes.Count; i++)
                    {
                        var node = nodes[i];
                        var val  = new ExcelField
                        {
                            TableName = CollectTable.Name,
                            Name      = node.Attributes["Name"].Value,
                            Title     = node.Attributes["Title"].Value,
                            Index     = int.Parse(node.Attributes["Index"].Value),
                            Type      = node.Attributes["Type"].Value.ToLower() == "int" ? ExcelType.Int : ExcelType.Double,
                            Compute   = node.Attributes["Compute"].Value.ToLower() == "sum" ? Compute.Sum : Compute.Count,
                        };
                        if (node.Attributes["Unit"] != null)
                        {
                            val.Unit = node.Attributes["Unit"].Value.Trim();
                        }

                        if (node.Attributes["View"] != null)
                        {
                            val.View = node.Attributes["View"].Value;
                        }
                        if (node.Attributes["WhereClause"] != null)
                        {
                            val.WhereClause = node.Attributes["WhereClause"].Value;
                        }
                        if (node.Attributes["TableName"] != null)
                        {
                            val.FieldTableName = node.Attributes["TableName"].Value;
                        }
                        if (node.Attributes["Indexs"] != null)
                        {
                            var indexs = node.Attributes["Indexs"].Value;
                            if (!string.IsNullOrEmpty(indexs))
                            {
                                var temps = indexs.Split(',');
                                var res   = new int[temps.Length];
                                for (var j = 0; j < temps.Length; j++)
                                {
                                    var a = 0;
                                    res[j] = int.TryParse(temps[j], out a) ? a : 0;
                                }
                                val.Indexs = res;
                            }
                        }
                        list.Add(val);
                    }
                }
            }

            return(list);
        }
Beispiel #34
0
        private Control GetUserInputControl(SearchTag stag)
        {
            string          switchname = stag.TagName;
            string          typename   = stag.MyRuntimePropertyValue.GetType().ToString();
            FlowLayoutPanel flp        = new FlowLayoutPanel();
            TextBox         tb;
            Button          b;
            NumericUpDown   nud;
            ComboBox        cb;

            switch (typename)
            {
            case "System.Boolean":
            {
                RadioButtonListItem itrue = new RadioButtonListItem
                {
                    Text = bool.TrueString
                };
                RadioButtonListItem ifalse = new RadioButtonListItem
                {
                    Text = bool.FalseString
                };
                RadioButtonList rdb = new RadioButtonList
                {
                    Text = stag.TagName
                };
                rdb.Items.Add(itrue);
                rdb.Items.Add(ifalse);
                rdb.SelectedIndexChanged += (sender, e) =>
                {
                    PropertyInfo info = stag.MyPropertyInfo;
                    info.SetValue(stag.MyParentTag.MyRuntimePropertyValue, itrue.Checked);
                    MySetTags.Add(stag);
                    UpdateDialog();
                };
                return(rdb);
            }

            case "System.String":
            {
                tb = new TextBox();
                flp.Controls.Add(tb);
                b = new Button
                {
                    Text = "OK"
                };
                b.Click += (sender, e) =>
                {
                    PropertyInfo info = stag.MyPropertyInfo;
                    info.SetValue(stag.MyParentTag.MyRuntimePropertyValue, tb.Text);
                    MySetTags.Add(stag);
                    UpdateDialog();
                };
                flp.Controls.Add(b);
                return(flp);
            }

            case "System.Int32":
            {
                nud = new NumericUpDown
                {
                    Minimum = int.MinValue,
                    Maximum = int.MaxValue
                };
                flp.Controls.Add(nud);
                b = new Button
                {
                    Text = "OK"
                };
                b.Click += (sender, e) =>
                {
                    PropertyInfo info = stag.MyPropertyInfo;
                    info.SetValue(stag.MyParentTag.MyRuntimePropertyValue, (int)nud.Value);
                    MySetTags.Add(stag);
                    UpdateDialog();
                };
                flp.Controls.Add(b);
                return(flp);
            }

            case "Chummer.Backend.Uniques.Tradition":
            {
                var traditions = Tradition.GetTraditions(MySearchCharacter.MyCharacter);
                cb = new ComboBox
                {
                    DataSource    = traditions,
                    DropDownStyle = ComboBoxStyle.DropDownList,
                    FlatStyle     = FlatStyle.Standard,
                    DisplayMember = "Name"
                };
                cb.SelectedValueChanged += (sender, e) =>
                {
                    if (_loading)
                    {
                        return;
                    }
                    PropertyInfo info = stag.MyPropertyInfo;
                    info.SetValue(stag.MyParentTag.MyRuntimePropertyValue, cb.SelectedValue);
                    stag.TagValue = (cb.SelectedValue as Tradition)?.Name ?? string.Empty;
                    MySetTags.Add(stag);
                    UpdateDialog();
                };
                flp.Controls.Add(cb);
                return(flp);
            }
            }
            object obj = stag.MyRuntimePropertyValue;

            if (!(obj is string))
            {
                if (obj is IList)
                {
                    Type listtype = StaticUtils.GetListType(obj);
                    if (listtype != null)
                    {
                        switchname = listtype.Name;
                    }
                }
            }

            switch (switchname)
            {
            //these are sample implementations to get added one by one...
            case "Spell":
            {
                Button button = new Button
                {
                    Text = "select Spell"
                };
                button.Click += (sender, e) =>
                {
                    var frmPickSpell = new frmSelectSpell(MySearchCharacter.MyCharacter);
                    frmPickSpell.ShowDialog();
                    // Open the Spells XML file and locate the selected piece.
                    XmlDocument objXmlDocument = XmlManager.Load("spells.xml");
                    XmlNode     objXmlSpell    = objXmlDocument.SelectSingleNode("/chummer/spells/spell[id = \"" + frmPickSpell.SelectedSpell + "\"]");
                    Spell       objSpell       = new Spell(MySearchCharacter.MyCharacter);
                    if (string.IsNullOrEmpty(objSpell.Name))
                    {
                        return;
                    }
                    objSpell.Create(objXmlSpell, string.Empty, frmPickSpell.Limited, frmPickSpell.Extended, frmPickSpell.Alchemical);
                    MySearchCharacter.MyCharacter.Spells.Add(objSpell);
                    SearchTag spellsearch = new SearchTag(stag.MyPropertyInfo, stag.MyRuntimeHubClassTag)
                    {
                        MyRuntimePropertyValue = objSpell,
                        MyParentTag            = stag,
                        TagName        = objSpell.Name,
                        TagValue       = string.Empty,
                        SearchOperator = "exists"
                    };
                    MySetTags.Add(spellsearch);
                    UpdateDialog();
                };
                return(button);
            }

            case "Quality":
            {
                Button button = new Button
                {
                    Text = "select Quality"
                };
                button.Click += ((sender, e) =>
                    {
                        var frmPick = new frmSelectQuality(MySearchCharacter.MyCharacter);
                        frmPick.ShowDialog();
                        // Open the Spells XML file and locate the selected piece.
                        XmlDocument objXmlDocument = XmlManager.Load("qualities.xml");
                        XmlNode objXmlNode = objXmlDocument.SelectSingleNode("/chummer/qualities/quality[id = \"" + frmPick.SelectedQuality + "\"]");
                        Quality objQuality = new Quality(MySearchCharacter.MyCharacter);
                        List <Weapon> lstWeapons = new List <Weapon>();
                        objQuality.Create(objXmlNode, QualitySource.Selected, lstWeapons);
                        MySearchCharacter.MyCharacter.Qualities.Add(objQuality);
                        SearchTag newtag = new SearchTag(stag.MyPropertyInfo, stag.MyRuntimeHubClassTag)
                        {
                            MyRuntimePropertyValue = objQuality,
                            MyParentTag = stag,
                            TagName = objQuality.Name,
                            TagValue = string.Empty,
                            SearchOperator = "exists"
                        };
                        MySetTags.Add(newtag);
                        UpdateDialog();
                    });
                return(button);
            }
            }
            return(null);
        }
Beispiel #35
0
        private static List <StockTable> GetStockTables()
        {
            var list   = new List <StockTable>();
            var tables = XmlManager.GetList("/Tables/Table", XmlEnum.Field);

            if (tables != null)
            {
                var length = 0;
                for (var i = 0; i < tables.Count; i++)
                {
                    var table      = tables[i];
                    var stockTable = new StockTable
                    {
                        Name    = table.Attributes["Name"].Value,
                        Title   = table.Attributes["Title"].Value,
                        IsSpace = table.Attributes["IsSpace"].Value == "true" ? true : false
                    };
                    if (table.Attributes["Type"] != null)
                    {
                        stockTable.Type = table.Attributes["Type"].Value;
                    }

                    var fields = table.SelectNodes("Field");
                    if (fields != null)
                    {
                        var ff = new List <Models.Field>();
                        for (var j = 0; j < fields.Count; j++)
                        {
                            var fi  = fields[j];
                            var str = fi.Attributes["Type"].Value;
                            if (!string.IsNullOrEmpty(str))
                            {
                                var item = new Models.Field()
                                {
                                    Name   = fi.Attributes["Name"].Value,
                                    Title  = fi.Attributes["Title"].Value,
                                    Length = int.TryParse(fi.Attributes["Length"].Value, out length) ? length : 0,
                                };
                                switch (str.ToLower())
                                {
                                case "int":
                                    item.Type = Models.FieldType.Int;
                                    break;

                                case "float":
                                    item.Type = Models.FieldType.Float;
                                    break;

                                case "char":
                                    item.Type = Models.FieldType.Char;
                                    break;
                                }
                                if (fi.Attributes["Min"] != null && int.TryParse(fi.Attributes["Min"].Value, out length))
                                {
                                    item.Min = length;
                                }
                                ff.Add(item);
                            }
                        }
                        stockTable.Fields = ff;
                    }
                    list.Add(stockTable);
                }
            }
            return(list);
        }
Beispiel #36
0
        private string GenerateItemName(ItemClass itemClass, EqType eqType)
        {
            string       result       = string.Empty;
            ItemNameData itemNameData = new ItemNameData();

            if (!XmlManager.Load <ItemNameData>(SaveInfo.Paths.Resources.ItemNameData.ItemNames, out itemNameData))
            {
                return(result);
            }

            if (eqType == EqType.None)
            {
                return(result);
            }

            switch (eqType)
            {
            case EqType.Body:
            {
                int itemIndex = CryptoRandom.Next(0, itemNameData.ArmorBodyItemNames.Count - 1);
                result = itemNameData.ArmorBodyItemNames[itemIndex];
                break;
            }

            case EqType.Boots:
            {
                int itemIndex = CryptoRandom.Next(0, itemNameData.ArmorBootsItemNames.Count - 1);
                result = itemNameData.ArmorBootsItemNames[itemIndex];
                break;
            }

            case EqType.Gloves:
            {
                int itemIndex = CryptoRandom.Next(0, itemNameData.ArmorGlovesItemNames.Count - 1);
                result = itemNameData.ArmorGlovesItemNames[itemIndex];
                break;
            }

            case EqType.Helmet:
            {
                int itemIndex = CryptoRandom.Next(0, itemNameData.ArmorHelmetItemNames.Count - 1);
                result = itemNameData.ArmorHelmetItemNames[itemIndex];
                break;
            }

            case EqType.Shield:
            {
                int itemIndex = CryptoRandom.Next(0, itemNameData.ArmorShieldItemNames.Count - 1);
                result = itemNameData.ArmorShieldItemNames[itemIndex];
                break;
            }

            case EqType.Trinket:
            {
                int itemIndex = CryptoRandom.Next(0, itemNameData.TrinketItemNames.Count - 1);
                result = itemNameData.TrinketItemNames[itemIndex];
                break;
            }

            case EqType.Weapon:
            {
                if (itemClass == ItemClass.None)
                {
                    return(result);
                }

                switch (itemClass)
                {
                case ItemClass.Magic:
                {
                    int itemIndex = CryptoRandom.Next(0, itemNameData.WeaponMagicItemNames.Count - 1);
                    result = itemNameData.WeaponMagicItemNames[itemIndex];
                    break;
                }

                case ItemClass.Ranged:
                {
                    int itemIndex = CryptoRandom.Next(0, itemNameData.WeaponRangedItemNames.Count - 1);
                    result = itemNameData.WeaponRangedItemNames[itemIndex];
                    break;
                }

                case ItemClass.Melle:
                {
                    int itemIndex = CryptoRandom.Next(0, itemNameData.WeaponMelleItemNames.Count - 1);
                    result = itemNameData.WeaponMelleItemNames[itemIndex];
                    break;
                }
                }

                break;
            }
            }

            return(result);
        }
Beispiel #37
0
        public void Load_NotExistingSettingFile_ArgumentException()
        {
            var manager = new XmlManager();

            Assert.Throws <ArgumentException>(delegate { manager.Load(testSuite, "NotFoundSettings.nbiset", false); });
        }
Beispiel #38
0
        public void LoadFromHeroLab(XmlNode xmlStatBlockBaseNode)
        {
            Timekeeper.Start("load_char_attrib");
            foreach (CharacterAttrib objAttribute in AttributeList.Concat(SpecialAttributeList))
            {
                objAttribute.UnbindAttribute();
            }
            AttributeList.Clear();
            SpecialAttributeList.Clear();
            XmlDocument objXmlDocument  = XmlManager.Load(_objCharacter.IsCritter ? "critters.xml" : "metatypes.xml");
            XmlNode     xmlMetatypeNode = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]");
            XmlNode     xmlCharNode     = xmlMetatypeNode?.SelectSingleNode("metavariants/metavariant[name = \"" + _objCharacter.Metavariant + "\"]") ?? xmlMetatypeNode;
            // We only want to remake attributes for shifters in career mode, because they only get their second set of attributes when exporting from create mode into career mode
            XmlNode xmlCharNodeAnimalForm = _objCharacter.MetatypeCategory == "Shapeshifter" && _objCharacter.Created ? xmlMetatypeNode : null;

            foreach (string strAttribute in AttributeStrings)
            {
                // First, remake the attribute
                CharacterAttrib objAttribute = new CharacterAttrib(_objCharacter, strAttribute);
                objAttribute = RemakeAttribute(objAttribute, xmlCharNode);
                switch (CharacterAttrib.ConvertToAttributeCategory(objAttribute.Abbrev))
                {
                case CharacterAttrib.AttributeCategory.Special:
                    SpecialAttributeList.Add(objAttribute);
                    break;

                case CharacterAttrib.AttributeCategory.Standard:
                    AttributeList.Add(objAttribute);
                    break;
                }
                if (xmlCharNodeAnimalForm != null)
                {
                    objAttribute = new CharacterAttrib(_objCharacter, strAttribute, CharacterAttrib.AttributeCategory.Shapeshifter);
                    objAttribute = RemakeAttribute(objAttribute, xmlCharNodeAnimalForm);
                    switch (CharacterAttrib.ConvertToAttributeCategory(objAttribute.Abbrev))
                    {
                    case CharacterAttrib.AttributeCategory.Special:
                        SpecialAttributeList.Add(objAttribute);
                        break;

                    case CharacterAttrib.AttributeCategory.Standard:
                        AttributeList.Add(objAttribute);
                        break;
                    }
                }

                // Then load in attribute karma levels (we'll adjust these later if the character is in Create mode)
                if (strAttribute == "ESS") // Not Essence though, this will get modified automatically instead of having its value set to the one HeroLab displays
                {
                    continue;
                }
                XmlNode xmlHeroLabAttributeNode = xmlStatBlockBaseNode.SelectSingleNode("attributes/attribute[@name = \"" + GetAttributeEnglishName(strAttribute) + "\"]");
                XmlNode xmlAttributeBaseNode    = xmlHeroLabAttributeNode?.SelectSingleNode("@base");
                if (xmlAttributeBaseNode != null &&
                    int.TryParse(xmlAttributeBaseNode.InnerText, out int intHeroLabAttributeBaseValue))
                {
                    int intAttributeMinimumValue = GetAttributeByName(strAttribute).MetatypeMinimum;
                    if (intHeroLabAttributeBaseValue != intAttributeMinimumValue)
                    {
                        objAttribute.Karma = intHeroLabAttributeBaseValue - intAttributeMinimumValue;
                    }
                }
            }

            if (!_objCharacter.Created && _objCharacter.BuildMethodHasSkillPoints)
            {
                // Allocate Attribute Points
                int             intAttributePointCount = _objCharacter.TotalAttributes;
                CharacterAttrib objAttributeToPutPointsInto;
                // First loop through attributes where costs can be 100% covered with points
                do
                {
                    objAttributeToPutPointsInto = null;
                    int intAttributeToPutPointsIntoTotalKarmaCost = 0;
                    foreach (CharacterAttrib objLoopAttribute in AttributeList)
                    {
                        if (objLoopAttribute.Karma == 0)
                        {
                            continue;
                        }
                        // Put points into the attribute with the highest total karma cost.
                        // In case of ties, pick the one that would need more points to cover it (the other one will hopefully get picked up at a later cycle)
                        int intLoopTotalKarmaCost = objLoopAttribute.TotalKarmaCost;
                        if (objAttributeToPutPointsInto == null || (objLoopAttribute.Karma <= intAttributePointCount &&
                                                                    (intLoopTotalKarmaCost > intAttributeToPutPointsIntoTotalKarmaCost ||
                                                                     (intLoopTotalKarmaCost == intAttributeToPutPointsIntoTotalKarmaCost && objLoopAttribute.Karma > objAttributeToPutPointsInto.Karma))))
                        {
                            objAttributeToPutPointsInto = objLoopAttribute;
                            intAttributeToPutPointsIntoTotalKarmaCost = intLoopTotalKarmaCost;
                        }
                    }

                    if (objAttributeToPutPointsInto != null)
                    {
                        objAttributeToPutPointsInto.Base  = objAttributeToPutPointsInto.Karma;
                        intAttributePointCount           -= objAttributeToPutPointsInto.Karma;
                        objAttributeToPutPointsInto.Karma = 0;
                    }
                } while (objAttributeToPutPointsInto != null && intAttributePointCount > 0);

                // If any points left over, then put them all into the attribute with the highest karma cost
                if (intAttributePointCount > 0 && AttributeList.Any(x => x.Karma != 0))
                {
                    int intHighestTotalKarmaCost = 0;
                    foreach (CharacterAttrib objLoopAttribute in AttributeList)
                    {
                        if (objLoopAttribute.Karma == 0)
                        {
                            continue;
                        }
                        // Put points into the attribute with the highest total karma cost.
                        // In case of ties, pick the one that would need more points to cover it (the other one will hopefully get picked up at a later cycle)
                        int intLoopTotalKarmaCost = objLoopAttribute.TotalKarmaCost;
                        if (objAttributeToPutPointsInto == null ||
                            intLoopTotalKarmaCost > intHighestTotalKarmaCost ||
                            (intLoopTotalKarmaCost == intHighestTotalKarmaCost && objLoopAttribute.Karma > objAttributeToPutPointsInto.Karma))
                        {
                            objAttributeToPutPointsInto = objLoopAttribute;
                            intHighestTotalKarmaCost    = intLoopTotalKarmaCost;
                        }
                    }

                    if (objAttributeToPutPointsInto != null)
                    {
                        objAttributeToPutPointsInto.Base   = intAttributePointCount;
                        objAttributeToPutPointsInto.Karma -= intAttributePointCount;
                    }
                }

                // Allocate Special Attribute Points
                intAttributePointCount = _objCharacter.TotalSpecial;
                // First loop through attributes where costs can be 100% covered with points
                do
                {
                    objAttributeToPutPointsInto = null;
                    int intAttributeToPutPointsIntoTotalKarmaCost = 0;
                    foreach (CharacterAttrib objLoopAttribute in SpecialAttributeList)
                    {
                        if (objLoopAttribute.Karma == 0)
                        {
                            continue;
                        }
                        // Put points into the attribute with the highest total karma cost.
                        // In case of ties, pick the one that would need more points to cover it (the other one will hopefully get picked up at a later cycle)
                        int intLoopTotalKarmaCost = objLoopAttribute.TotalKarmaCost;
                        if (objAttributeToPutPointsInto == null || (objLoopAttribute.Karma <= intAttributePointCount &&
                                                                    (intLoopTotalKarmaCost > intAttributeToPutPointsIntoTotalKarmaCost ||
                                                                     (intLoopTotalKarmaCost == intAttributeToPutPointsIntoTotalKarmaCost && objLoopAttribute.Karma > objAttributeToPutPointsInto.Karma))))
                        {
                            objAttributeToPutPointsInto = objLoopAttribute;
                            intAttributeToPutPointsIntoTotalKarmaCost = intLoopTotalKarmaCost;
                        }
                    }

                    if (objAttributeToPutPointsInto != null)
                    {
                        objAttributeToPutPointsInto.Base  = objAttributeToPutPointsInto.Karma;
                        intAttributePointCount           -= objAttributeToPutPointsInto.Karma;
                        objAttributeToPutPointsInto.Karma = 0;
                    }
                } while (objAttributeToPutPointsInto != null);

                // If any points left over, then put them all into the attribute with the highest karma cost
                if (intAttributePointCount > 0 && SpecialAttributeList.Any(x => x.Karma != 0))
                {
                    int intHighestTotalKarmaCost = 0;
                    foreach (CharacterAttrib objLoopAttribute in SpecialAttributeList)
                    {
                        if (objLoopAttribute.Karma == 0)
                        {
                            continue;
                        }
                        // Put points into the attribute with the highest total karma cost.
                        // In case of ties, pick the one that would need more points to cover it (the other one will hopefully get picked up at a later cycle)
                        int intLoopTotalKarmaCost = objLoopAttribute.TotalKarmaCost;
                        if (objAttributeToPutPointsInto == null ||
                            intLoopTotalKarmaCost > intHighestTotalKarmaCost ||
                            (intLoopTotalKarmaCost == intHighestTotalKarmaCost && objLoopAttribute.Karma > objAttributeToPutPointsInto.Karma))
                        {
                            objAttributeToPutPointsInto = objLoopAttribute;
                            intHighestTotalKarmaCost    = intLoopTotalKarmaCost;
                        }
                    }

                    if (objAttributeToPutPointsInto != null)
                    {
                        objAttributeToPutPointsInto.Base   = intAttributePointCount;
                        objAttributeToPutPointsInto.Karma -= intAttributePointCount;
                    }
                }
            }
            ResetBindings();
            Timekeeper.Finish("load_char_attrib");
        }
 public static void SaveCollection(List <BasicSetCollectionInfo> collections, string saveFilePath)
 {
     XmlManager <List <BasicSetCollectionInfo> > .Save(saveFilePath, collections);
 }
Beispiel #40
0
        public void Load(XmlNode xmlSavedCharacterNode)
        {
            Timekeeper.Start("load_char_attrib");
            foreach (CharacterAttrib objAttribute in AttributeList.Concat(SpecialAttributeList))
            {
                objAttribute.UnbindAttribute();
            }
            AttributeList.Clear();
            SpecialAttributeList.Clear();
            XmlDocument objXmlDocument  = XmlManager.Load(_objCharacter.IsCritter ? "critters.xml" : "metatypes.xml");
            XmlNode     xmlMetatypeNode = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]");
            XmlNode     xmlCharNode     = xmlMetatypeNode?.SelectSingleNode("metavariants/metavariant[name = \"" + _objCharacter.Metavariant + "\"]") ?? xmlMetatypeNode;
            // We only want to remake attributes for shifters in career mode, because they only get their second set of attributes when exporting from create mode into career mode
            XmlNode xmlCharNodeAnimalForm = _objCharacter.MetatypeCategory == "Shapeshifter" && _objCharacter.Created ? xmlMetatypeNode : null;

            foreach (string strAttribute in AttributeStrings)
            {
                XmlNodeList lstAttributeNodes = xmlSavedCharacterNode.SelectNodes("attributes/attribute[name = \"" + strAttribute + "\"]");
                // Couldn't find the appopriate attribute in the loaded file, so regenerate it from scratch.
                if (lstAttributeNodes == null || lstAttributeNodes.Count == 0 || xmlCharNodeAnimalForm != null && _objCharacter.LastSavedVersion < new Version("5.200.25"))
                {
                    CharacterAttrib objAttribute = new CharacterAttrib(_objCharacter, strAttribute);
                    objAttribute = RemakeAttribute(objAttribute, xmlCharNode);
                    switch (CharacterAttrib.ConvertToAttributeCategory(objAttribute.Abbrev))
                    {
                    case CharacterAttrib.AttributeCategory.Special:
                        SpecialAttributeList.Add(objAttribute);
                        break;

                    case CharacterAttrib.AttributeCategory.Standard:
                        AttributeList.Add(objAttribute);
                        break;
                    }
                    if (xmlCharNodeAnimalForm != null)
                    {
                        objAttribute = new CharacterAttrib(_objCharacter, strAttribute, CharacterAttrib.AttributeCategory.Shapeshifter);
                        objAttribute = RemakeAttribute(objAttribute, xmlCharNodeAnimalForm);
                        switch (CharacterAttrib.ConvertToAttributeCategory(objAttribute.Abbrev))
                        {
                        case CharacterAttrib.AttributeCategory.Special:
                            SpecialAttributeList.Add(objAttribute);
                            break;

                        case CharacterAttrib.AttributeCategory.Standard:
                            AttributeList.Add(objAttribute);
                            break;
                        }
                    }
                }
                else
                {
                    foreach (XmlNode xmlAttributeNode in lstAttributeNodes)
                    {
                        CharacterAttrib att = new CharacterAttrib(_objCharacter, strAttribute);
                        att.Load(xmlAttributeNode);
                        switch (CharacterAttrib.ConvertToAttributeCategory(att.Abbrev))
                        {
                        case CharacterAttrib.AttributeCategory.Special:
                            SpecialAttributeList.Add(att);
                            break;

                        case CharacterAttrib.AttributeCategory.Standard:
                            AttributeList.Add(att);
                            break;
                        }
                    }
                }
            }
            ResetBindings();
            Timekeeper.Finish("load_char_attrib");
        }
Beispiel #41
0
 internal Manager(XmlManager m)
 {
     this.mgr_ = m;
 }
Beispiel #42
0
        /// <summary>
        /// Performs actions based on the character's last loaded AppVersion attribute.
        /// </summary>
        private void LegacyShim()
        {
            //Unstored Cost and LP values prior to 5.190.2 nightlies.
            if (_objCharacter.LastSavedVersion <= new Version("5.190.0"))
            {
                XmlDocument objXmlDocument          = XmlManager.Load("lifestyles.xml");
                XmlNode     objLifestyleQualityNode = GetNode() ??
                                                      objXmlDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + _strName + "\"]");
                if (objLifestyleQualityNode == null)
                {
                    List <ListItem> lstQualities = new List <ListItem>();
                    using (XmlNodeList xmlQualityList = objXmlDocument.SelectNodes("/chummer/qualities/quality"))
                        if (xmlQualityList != null)
                        {
                            foreach (XmlNode xmlNode in xmlQualityList)
                            {
                                lstQualities.Add(new ListItem(xmlNode["id"]?.InnerText, xmlNode["translate"]?.InnerText ?? xmlNode["name"]?.InnerText));
                            }
                        }
                    frmSelectItem frmSelect = new frmSelectItem
                    {
                        GeneralItems = lstQualities,
                        Description  = LanguageManager.GetString("String_CannotFindLifestyleQuality", GlobalOptions.Language).Replace("{0}", _strName)
                    };
                    frmSelect.ShowDialog();
                    if (frmSelect.DialogResult == DialogResult.Cancel)
                    {
                        return;
                    }

                    objLifestyleQualityNode = objXmlDocument.SelectSingleNode("/chummer/qualities/quality[id = \"" + frmSelect.SelectedItem + "\"]");
                }
                int    intTemp = 0;
                string strTemp = string.Empty;
                if (objLifestyleQualityNode.TryGetStringFieldQuickly("cost", ref strTemp))
                {
                    CostString = strTemp;
                }
                if (objLifestyleQualityNode.TryGetInt32FieldQuickly("lp", ref intTemp))
                {
                    LP = intTemp;
                }
                if (objLifestyleQualityNode.TryGetInt32FieldQuickly("areamaximum", ref intTemp))
                {
                    AreaMaximum = intTemp;
                }
                if (objLifestyleQualityNode.TryGetInt32FieldQuickly("comfortsmaximum", ref intTemp))
                {
                    ComfortMaximum = intTemp;
                }
                if (objLifestyleQualityNode.TryGetInt32FieldQuickly("securitymaximum", ref intTemp))
                {
                    SecurityMaximum = intTemp;
                }
                if (objLifestyleQualityNode.TryGetInt32FieldQuickly("area", ref intTemp))
                {
                    Area = intTemp;
                }
                if (objLifestyleQualityNode.TryGetInt32FieldQuickly("comforts", ref intTemp))
                {
                    Comfort = intTemp;
                }
                if (objLifestyleQualityNode.TryGetInt32FieldQuickly("security", ref intTemp))
                {
                    Security = intTemp;
                }
                if (objLifestyleQualityNode.TryGetInt32FieldQuickly("multiplier", ref intTemp))
                {
                    Multiplier = intTemp;
                }
                if (objLifestyleQualityNode.TryGetInt32FieldQuickly("multiplierbaseonly", ref intTemp))
                {
                    BaseMultiplier = intTemp;
                }
            }
        }
Beispiel #43
0
        /// <summary>
        ///     Performs actions based on the character's last loaded AppVersion attribute.
        /// </summary>
        private void LegacyShim()
        {
            //Unstored Cost and LP values prior to 5.190.2 nightlies.
            if (_objCharacter.LastSavedVersion > new Version(5, 190, 0))
            {
                return;
            }
            var objXmlDocument          = XmlManager.Load("lifestyles.xml");
            var objLifestyleQualityNode = GetNode() ??
                                          objXmlDocument.SelectSingleNode(
                "/chummer/qualities/quality[name = \"" + _strName + "\"]");

            if (objLifestyleQualityNode == null)
            {
                List <ListItem> lstQualities = new List <ListItem>(1);
                using (var xmlQualityList = objXmlDocument.SelectNodes("/chummer/qualities/quality"))
                {
                    if (xmlQualityList != null)
                    {
                        foreach (XmlNode xmlNode in xmlQualityList)
                        {
                            lstQualities.Add(new ListItem(xmlNode["id"]?.InnerText,
                                                          xmlNode["translate"]?.InnerText ?? xmlNode["name"]?.InnerText));
                        }
                    }
                }

                using (frmSelectItem frmSelect = new frmSelectItem
                {
                    Description = string.Format(GlobalOptions.CultureInfo, LanguageManager.GetString("String_intCannotFindLifestyleQuality"), _strName)
                })
                {
                    frmSelect.SetGeneralItemsMode(lstQualities);
                    frmSelect.ShowDialog(Program.MainForm);
                    if (frmSelect.DialogResult == DialogResult.Cancel)
                    {
                        return;
                    }

                    objLifestyleQualityNode =
                        objXmlDocument.SelectSingleNode("/chummer/qualities/quality[id = \"" + frmSelect.SelectedItem +
                                                        "\"]");
                }
            }

            var intTemp = 0;
            var strTemp = string.Empty;

            if (objLifestyleQualityNode.TryGetStringFieldQuickly("cost", ref strTemp))
            {
                CostString = strTemp;
            }
            if (objLifestyleQualityNode.TryGetInt32FieldQuickly("lp", ref intTemp))
            {
                LP = intTemp;
            }
            if (objLifestyleQualityNode.TryGetInt32FieldQuickly("areamaximum", ref intTemp))
            {
                AreaMaximum = intTemp;
            }
            if (objLifestyleQualityNode.TryGetInt32FieldQuickly("comfortsmaximum", ref intTemp))
            {
                ComfortMaximum = intTemp;
            }
            if (objLifestyleQualityNode.TryGetInt32FieldQuickly("securitymaximum", ref intTemp))
            {
                SecurityMaximum = intTemp;
            }
            if (objLifestyleQualityNode.TryGetInt32FieldQuickly("area", ref intTemp))
            {
                Area = intTemp;
            }
            if (objLifestyleQualityNode.TryGetInt32FieldQuickly("comforts", ref intTemp))
            {
                Comfort = intTemp;
            }
            if (objLifestyleQualityNode.TryGetInt32FieldQuickly("security", ref intTemp))
            {
                Security = intTemp;
            }
            if (objLifestyleQualityNode.TryGetInt32FieldQuickly("multiplier", ref intTemp))
            {
                Multiplier = intTemp;
            }
            if (objLifestyleQualityNode.TryGetInt32FieldQuickly("multiplierbaseonly", ref intTemp))
            {
                BaseMultiplier = intTemp;
            }
        }
Beispiel #44
0
        /// <summary>
        /// Load the CharacterAttribute from the XmlNode.
        /// </summary>
        /// <param name="objNode">XmlNode to load.</param>
        /// <param name="blnCopy"></param>
        public void Load(XmlNode objNode, bool blnCopy = false)
        {
            if (blnCopy || !objNode.TryGetField("guid", Guid.TryParse, out _guiID))
            {
                _guiID = Guid.NewGuid();
            }
            objNode.TryGetStringFieldQuickly("name", ref _strName);
            if (!objNode.TryGetGuidFieldQuickly("sourceid", ref _guiSourceID))
            {
                XmlNode node = GetNode(GlobalOptions.Language);
                node?.TryGetGuidFieldQuickly("id", ref _guiSourceID);
            }
            if (blnCopy)
            {
                _intIncrements = 0;
            }
            else
            {
                objNode.TryGetInt32FieldQuickly("months", ref _intIncrements);
                objNode.TryGetField("guid", Guid.TryParse, out _guiID);
            }

            objNode.TryGetDecFieldQuickly("cost", ref _decCost);
            objNode.TryGetInt32FieldQuickly("dice", ref _intDice);
            objNode.TryGetDecFieldQuickly("multiplier", ref _decMultiplier);

            objNode.TryGetInt32FieldQuickly("area", ref _intArea);
            objNode.TryGetInt32FieldQuickly("comforts", ref _intComforts);
            objNode.TryGetInt32FieldQuickly("security", ref _intSecurity);
            objNode.TryGetInt32FieldQuickly("basearea", ref _intBaseArea);
            objNode.TryGetInt32FieldQuickly("basecomforts", ref _intBaseComforts);
            objNode.TryGetInt32FieldQuickly("basesecurity", ref _intBaseSecurity);
            objNode.TryGetDecFieldQuickly("costforarea", ref _decCostForArea);
            objNode.TryGetDecFieldQuickly("costforcomforts", ref _decCostForComforts);
            objNode.TryGetDecFieldQuickly("costforsecurity", ref _decCostForSecurity);
            objNode.TryGetInt32FieldQuickly("roommates", ref _intRoommates);
            objNode.TryGetDecFieldQuickly("percentage", ref _decPercentage);
            objNode.TryGetStringFieldQuickly("baselifestyle", ref _strBaseLifestyle);
            objNode.TryGetInt32FieldQuickly("sortorder", ref _intSortOrder);
            if (XmlManager.Load("lifestyles.xml").SelectSingleNode($"/chummer/lifestyles/lifestyle[name =\"{_strBaseLifestyle}\"]") == null && XmlManager.Load("lifestyles.xml").SelectSingleNode($"/chummer/lifestyles/lifestyle[name =\"{_strName}\"]") != null)
            {
                string baselifestyle = _strName;
                _strName          = _strBaseLifestyle;
                _strBaseLifestyle = baselifestyle;
            }
            if (string.IsNullOrWhiteSpace(_strBaseLifestyle))
            {
                objNode.TryGetStringFieldQuickly("lifestylename", ref _strBaseLifestyle);
                if (string.IsNullOrWhiteSpace(_strBaseLifestyle))
                {
                    List <ListItem> lstQualities = new List <ListItem>();
                    using (XmlNodeList xmlLifestyleList = XmlManager.Load("lifestyles.xml").SelectNodes("/chummer/lifestyles/lifestyle"))
                        if (xmlLifestyleList != null)
                        {
                            foreach (XmlNode xmlLifestyle in xmlLifestyleList)
                            {
                                string strName = xmlLifestyle["name"]?.InnerText ?? LanguageManager.GetString("String_Error", GlobalOptions.Language);
                                lstQualities.Add(new ListItem(strName, xmlLifestyle["translate"]?.InnerText ?? strName));
                            }
                        }
                    frmSelectItem frmSelect = new frmSelectItem
                    {
                        GeneralItems = lstQualities,
                        Description  = string.Format(LanguageManager.GetString("String_CannotFindLifestyle", GlobalOptions.Language), _strName)
                    };
                    frmSelect.ShowDialog();
                    if (frmSelect.DialogResult == DialogResult.Cancel)
                    {
                        return;
                    }
                    _strBaseLifestyle = frmSelect.SelectedItem;
                }
            }
            if (_strBaseLifestyle == "Middle")
            {
                _strBaseLifestyle = "Medium";
            }
            if (!objNode.TryGetBoolFieldQuickly("allowbonuslp", ref _blnAllowBonusLP))
            {
                GetNode()?.TryGetBoolFieldQuickly("allowbonuslp", ref _blnAllowBonusLP);
            }
            if (!objNode.TryGetInt32FieldQuickly("bonuslp", ref _intBonusLP) && _strBaseLifestyle == "Traveler")
            {
                _intBonusLP = 1 + GlobalOptions.RandomGenerator.NextD6ModuloBiasRemoved();
            }
            objNode.TryGetStringFieldQuickly("source", ref _strSource);
            objNode.TryGetBoolFieldQuickly("trustfund", ref _blnTrustFund);
            if (objNode["primarytenant"] == null)
            {
                _blnIsPrimaryTenant = _intRoommates == 0;
            }
            else
            {
                objNode.TryGetBoolFieldQuickly("primarytenant", ref _blnIsPrimaryTenant);
            }
            objNode.TryGetStringFieldQuickly("page", ref _strPage);

            // Lifestyle Qualities
            using (XmlNodeList xmlQualityList = objNode.SelectNodes("lifestylequalities/lifestylequality"))
                if (xmlQualityList != null)
                {
                    foreach (XmlNode xmlQuality in xmlQualityList)
                    {
                        LifestyleQuality objQuality = new LifestyleQuality(_objCharacter);
                        objQuality.Load(xmlQuality, this);
                        _lstLifestyleQualities.Add(objQuality);
                    }
                }

            // Free Grids provided by the Lifestyle
            using (XmlNodeList xmlQualityList = objNode.SelectNodes("freegrids/lifestylequality"))
                if (xmlQualityList != null)
                {
                    foreach (XmlNode xmlQuality in xmlQualityList)
                    {
                        LifestyleQuality objQuality = new LifestyleQuality(_objCharacter);
                        objQuality.Load(xmlQuality, this);
                        _lstFreeGrids.Add(objQuality);
                    }
                }

            objNode.TryGetStringFieldQuickly("notes", ref _strNotes);

            string strTemp = string.Empty;

            if (objNode.TryGetStringFieldQuickly("type", ref strTemp))
            {
                _eType = ConvertToLifestyleType(strTemp);
            }
            if (objNode.TryGetStringFieldQuickly("increment", ref strTemp))
            {
                _eIncrement = ConvertToLifestyleIncrement(strTemp);
            }
            else if (_eType == LifestyleType.Safehouse)
            {
                _eIncrement = LifestyleIncrement.Week;
            }
            else
            {
                XmlNode xmlLifestyleNode = GetNode();
                if (xmlLifestyleNode != null && xmlLifestyleNode.TryGetStringFieldQuickly("increment", ref strTemp))
                {
                    _eIncrement = ConvertToLifestyleIncrement(strTemp);
                }
            }
            LegacyShim(objNode);
        }
        private static List <Tuple <string, Predicate <Skill> > > GenerateDropdownFilter(Character objCharacter)
        {
            List <Tuple <string, Predicate <Skill> > > ret = new List <Tuple <string, Predicate <Skill> > >(7)
            {
                new Tuple <string, Predicate <Skill> >(LanguageManager.GetString("String_Search"),
                                                       null),
                new Tuple <string, Predicate <Skill> >(LanguageManager.GetString("String_SkillFilterAll"),
                                                       skill => true),
                new Tuple <string, Predicate <Skill> >(LanguageManager.GetString("String_SkillFilterRatingAboveZero"),
                                                       skill => skill.Rating > 0),
                new Tuple <string, Predicate <Skill> >(LanguageManager.GetString("String_SkillFilterTotalRatingAboveZero"),
                                                       skill => skill.Pool > 0),
                new Tuple <string, Predicate <Skill> >(LanguageManager.GetString("String_SkillFilterRatingZero"),
                                                       skill => skill.Rating == 0),
                new Tuple <string, Predicate <Skill> >(LanguageManager.GetString("String_SkillFilterNoSkillGroup"),
                                                       skill => skill.SkillGroup.Length == 0),
                new Tuple <string, Predicate <Skill> >(LanguageManager.GetString("String_SkillFilterBrokenSkillGroup"),
                                                       skill => skill.Pool > 0 && (skill.SkillGroup.Length == 0 || (skill.SkillGroupObject != null && skill.Rating > skill.SkillGroupObject.Rating)))
            };
            //TODO: TRANSLATIONS

            string strSpace = LanguageManager.GetString("String_Space");
            string strColon = LanguageManager.GetString("String_Colon");

            string strCategory = LanguageManager.GetString("Label_Category");

            foreach (XPathNavigator xmlCategoryNode in XmlManager.LoadXPath("skills.xml", objCharacter?.Options.EnabledCustomDataDirectoryPaths)
                     .Select("/chummer/categories/category[@type = \"active\"]"))
            {
                string strName = xmlCategoryNode.Value;
                if (!string.IsNullOrEmpty(strName))
                {
                    ret.Add(new Tuple <string, Predicate <Skill> >(
                                strCategory + strSpace + (xmlCategoryNode.SelectSingleNode("@translate")?.Value ?? strName),
                                skill => skill.SkillCategory == strName));
                }
            }

            string strAttributeLabel = LanguageManager.GetString("String_ExpenseAttribute");

            foreach (string strAttribute in AttributeSection.AttributeStrings)
            {
                string strAttributeShort = LanguageManager.GetString("String_Attribute" + strAttribute + "Short", GlobalOptions.Language, false);
                if (!string.IsNullOrEmpty(strAttributeShort))
                {
                    ret.Add(new Tuple <string, Predicate <Skill> >(strAttributeLabel + strColon + strSpace + strAttributeShort,
                                                                   skill => skill.Attribute == strAttribute));
                }
            }

            string strSkillGroupLabel = LanguageManager.GetString("String_ExpenseSkillGroup");

            foreach (XPathNavigator xmlSkillGroupNode in XmlManager.LoadXPath("skills.xml", objCharacter?.Options.EnabledCustomDataDirectoryPaths)
                     .Select("/chummer/skillgroups/name"))
            {
                string strName = xmlSkillGroupNode.Value;
                if (!string.IsNullOrEmpty(strName))
                {
                    ret.Add(new Tuple <string, Predicate <Skill> >(
                                strSkillGroupLabel + strSpace + (xmlSkillGroupNode.SelectSingleNode("@translate")?.Value ?? strName),
                                skill => skill.SkillGroup == strName));
                }
            }

            return(ret);
        }
Beispiel #46
0
        /// <summary>
        /// Converts old lifestyle structures to new standards.
        /// </summary>
        private void LegacyShim(XmlNode xmlLifestyleNode)
        {
            //Lifestyles would previously store the entire calculated value of their Cost, Area, Comforts and Security. Better to have it be a volatile Complex Property.
            if (_objCharacter.LastSavedVersion <= new Version("5.197.0") && xmlLifestyleNode["costforarea"] == null)
            {
                XmlDocument objXmlDocument          = XmlManager.Load("lifestyles.xml");
                XmlNode     objLifestyleQualityNode = objXmlDocument.SelectSingleNode("/chummer/lifestyles/lifestyle[name = \"" + _strBaseLifestyle + "\"]");
                if (objLifestyleQualityNode != null)
                {
                    decimal decTemp = 0.0m;
                    if (objLifestyleQualityNode.TryGetDecFieldQuickly("cost", ref decTemp))
                    {
                        Cost = decTemp;
                    }
                    if (objLifestyleQualityNode.TryGetDecFieldQuickly("costforarea", ref decTemp))
                    {
                        CostForArea = decTemp;
                    }
                    if (objLifestyleQualityNode.TryGetDecFieldQuickly("costforcomforts", ref decTemp))
                    {
                        CostForComforts = decTemp;
                    }
                    if (objLifestyleQualityNode.TryGetDecFieldQuickly("costforsecurity", ref decTemp))
                    {
                        CostForSecurity = decTemp;
                    }
                }

                int intMinArea    = 0;
                int intMinComfort = 0;
                int intMinSec     = 0;

                // Calculate the limits of the 3 aspects.
                // Area.
                XmlNode objXmlNode = objXmlDocument.SelectSingleNode("/chummer/neighborhoods/neighborhood[name = \"" + _strBaseLifestyle + "\"]");
                objXmlNode.TryGetInt32FieldQuickly("minimum", ref intMinArea);
                BaseArea = intMinArea;
                // Comforts.
                objXmlNode = objXmlDocument.SelectSingleNode("/chummer/comforts/comfort[name = \"" + _strBaseLifestyle + "\"]");
                objXmlNode.TryGetInt32FieldQuickly("minimum", ref intMinComfort);
                BaseComforts = intMinComfort;
                // Security.
                objXmlNode = objXmlDocument.SelectSingleNode("/chummer/securities/security[name = \"" + _strBaseLifestyle + "\"]");
                objXmlNode.TryGetInt32FieldQuickly("minimum", ref intMinSec);
                BaseSecurity = intMinSec;

                xmlLifestyleNode.TryGetInt32FieldQuickly("area", ref intMinArea);
                xmlLifestyleNode.TryGetInt32FieldQuickly("comforts", ref intMinComfort);
                xmlLifestyleNode.TryGetInt32FieldQuickly("security", ref intMinSec);

                // Calculate the cost of Positive Qualities.
                foreach (LifestyleQuality objQuality in LifestyleQualities)
                {
                    intMinArea    -= objQuality.Area;
                    intMinComfort -= objQuality.Comfort;
                    intMinSec     -= objQuality.Security;
                }
                Area     = Math.Max(intMinArea - BaseArea, 0);
                Comforts = Math.Max(intMinComfort - BaseComforts, 0);
                Security = Math.Max(intMinSec - BaseSecurity, 0);
            }
        }
Beispiel #47
0
        /// Create a Vehicle Modification from an XmlNode and return the TreeNodes for it.
        /// <param name="objXmlMod">XmlNode to create the object from.</param>
        /// <param name="objNode">TreeNode to populate a TreeView.</param>
        /// <param name="objParent">Vehicle that the mod will be attached to.</param>
        /// <param name="decMarkup">Discount or markup that applies to the base cost of the mod.</param>
        public void Create(XmlNode objXmlMod, TreeNode objNode, Vehicle objParent, decimal decMarkup = 0)
        {
            if (objParent == null)
            {
                throw new ArgumentNullException(nameof(objParent));
            }
            Parent = objParent;
            if (objXmlMod == null)
            {
                Utils.BreakIfDebug();
            }
            objXmlMod.TryGetStringFieldQuickly("name", ref _strName);
            objXmlMod.TryGetStringFieldQuickly("category", ref _strCategory);
            objXmlMod.TryGetStringFieldQuickly("limit", ref _strLimit);
            objXmlMod.TryGetStringFieldQuickly("slots", ref _strSlots);
            objXmlMod.TryGetStringFieldQuickly("weaponmountcategories", ref _strWeaponMountCategories);
            objXmlMod.TryGetStringFieldQuickly("avail", ref _strAvail);

            // Check for a Variable Cost.
            if (objXmlMod["cost"] != null)
            {
                _strCost = objXmlMod["cost"].InnerText;
                if (_strCost.StartsWith("Variable"))
                {
                    decimal decMin  = 0;
                    decimal decMax  = decimal.MaxValue;
                    string  strCost = _strCost.TrimStart("Variable", true).Trim("()".ToCharArray());
                    if (strCost.Contains('-'))
                    {
                        string[] strValues = strCost.Split('-');
                        decMin = Convert.ToDecimal(strValues[0], GlobalOptions.InvariantCultureInfo);
                        decMax = Convert.ToDecimal(strValues[1], GlobalOptions.InvariantCultureInfo);
                    }
                    else
                    {
                        decMin = Convert.ToDecimal(strCost.FastEscape('+'), GlobalOptions.InvariantCultureInfo);
                    }

                    if (decMin != 0 || decMax != decimal.MaxValue)
                    {
                        frmSelectNumber frmPickNumber = new frmSelectNumber();
                        if (decMax > 1000000)
                        {
                            decMax = 1000000;
                        }
                        frmPickNumber.Minimum     = decMin;
                        frmPickNumber.Maximum     = decMax;
                        frmPickNumber.Description = LanguageManager.GetString("String_SelectVariableCost").Replace("{0}", DisplayNameShort);
                        frmPickNumber.AllowCancel = false;
                        frmPickNumber.ShowDialog();
                        _strCost = frmPickNumber.SelectedValue.ToString();
                    }
                }
            }
            _decMarkup = decMarkup;

            objXmlMod.TryGetStringFieldQuickly("source", ref _strSource);
            objXmlMod.TryGetStringFieldQuickly("page", ref _strPage);

            if (GlobalOptions.Language != "en-us")
            {
                XmlNode objModNode = MyXmlNode;
                if (objModNode != null)
                {
                    objModNode.TryGetStringFieldQuickly("translate", ref _strAltName);
                    objModNode.TryGetStringFieldQuickly("altpage", ref _strAltPage);
                }

                XmlDocument objXmlDocument = XmlManager.Load("vehicles.xml");
                objModNode      = objXmlDocument.SelectSingleNode("/chummer/categories/category[. = \"" + _strCategory + "\"]");
                _strAltCategory = objModNode?.Attributes?["translate"]?.InnerText;
            }

            objNode.Text = DisplayName;
            objNode.Tag  = _guiID.ToString();
        }
Beispiel #48
0
 public void colombineEvent(string eventName)
 {
     XmlManager.launchEvent(eventName, "colombine_scene_2");
 }
 public static void Save() => XmlManager <DefaultDeckStats> .Save(Config.Instance.DataDir + "DefaultDeckStats.xml", Instance);
Beispiel #50
0
        void txt_MouseDownCicli(object sender, MouseButtonEventArgs e)
        {
            if (e.ClickCount == 2)
            {
                MasterFile mf = MasterFile.Create();

                Hashtable revisioneNow           = mf.GetRevisioneFromFileData(Sessioni[SessioneNow].ToString());
                string    revisioneAssociata     = App.AppDataDataFolder + "\\" + revisioneNow["FileData"].ToString();
                string    revisioneTreeAssociata = App.AppDataDataFolder + "\\" + revisioneNow["File"].ToString();
                string    revisioneIDAssociata   = revisioneNow["ID"].ToString();
                string    IDCliente = revisioneNow["Cliente"].ToString();

                if (revisioneAssociata == "")
                {
                    e.Handled = true;
                    return;
                }

                XmlDataProviderManager _xNew = new XmlDataProviderManager(revisioneAssociata);

                WindowWorkArea wa = new WindowWorkArea(ref _xNew);

                //Nodi
                wa.NodeHome = 0;

                RevisoftApplication.XmlManager xt = new XmlManager();
                xt.TipoCodifica = RevisoftApplication.XmlManager.TipologiaCodifica.Normale;
                XmlDataProvider TreeXmlProvider = new XmlDataProvider();
                TreeXmlProvider.Document = xt.LoadEncodedFile(revisioneTreeAssociata);

                if (TreeXmlProvider.Document != null && TreeXmlProvider.Document.SelectSingleNode("/Tree") != null)
                {
                    foreach (XmlNode item in TreeXmlProvider.Document.SelectNodes("/Tree//Node"))
                    {
                        if (item.Attributes["Codice"].Value == ((TextBlock)(sender)).ToolTip.ToString().Replace("Fare Doppio CLick per aprire la Carta di lavoro ", ""))
                        {
                            wa.Nodes.Add(0, item);
                        }
                    }
                }

                if (wa.Nodes.Count == 0)
                {
                    e.Handled = true;
                    return;
                }

                wa.NodeNow = wa.NodeHome;

                wa.Owner = Window.GetWindow(this);

                //posizione e dimensioni finestra
                wa.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
                wa.Height    = System.Windows.SystemParameters.PrimaryScreenHeight * 90.0 / 100.0;
                wa.Width     = System.Windows.SystemParameters.PrimaryScreenWidth * 90.0 / 100.0;
                wa.MaxHeight = System.Windows.SystemParameters.PrimaryScreenHeight * 90.0 / 100.0;
                wa.MaxWidth  = System.Windows.SystemParameters.PrimaryScreenWidth * 90.0 / 100.0;
                wa.MinHeight = System.Windows.SystemParameters.PrimaryScreenHeight * 90.0 / 100.0;
                wa.MinWidth  = System.Windows.SystemParameters.PrimaryScreenWidth * 90.0 / 100.0;

                //Sessioni
                wa.Sessioni.Clear();
                wa.Sessioni.Add(0, revisioneAssociata);

                wa.SessioniTitoli.Clear();
                wa.SessioniTitoli.Add(0, "");

                wa.SessioniID.Clear();
                wa.SessioniID.Add(0, revisioneIDAssociata);

                wa.SessioneHome = 0;
                wa.SessioneNow  = 0;

                //Variabili
                wa.ReadOnly            = true;
                wa.ReadOnlyOLD         = true;
                wa.ApertoInSolaLettura = true;

                //passaggio dati
                wa.IDTree     = IDTree;
                wa.IDSessione = revisioneIDAssociata;
                wa.IDCliente  = IDCliente;

                wa.Stato        = App.TipoTreeNodeStato.Sconosciuto;
                wa.OldStatoNodo = wa.Stato;

                //apertura
                wa.Load();

                wa.ShowDialog();
            }
        }
        public void Load(XmlNode xmlSavedCharacterNode)
        {
            Timekeeper.Start("load_char_attrib");
            AttributeList.Clear();
            SpecialAttributeList.Clear();
            XmlDocument objXmlDocument = XmlManager.Load(_character.IsCritter ? "critters.xml" : "metatypes.xml");
            XmlNode     objCharNode    = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _character.Metatype + "\"]/metavariants/metavariant[name = \"" + _character.Metavariant + "\"]")
                                         ?? objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _character.Metatype + "\"]");
            XmlNode objCharNodeAnimalForm = null;

            // We only want to remake attributes for shifters in career mode, because they only get their second set of attributes when exporting from create mode into career mode
            if (_character.MetatypeCategory == "Shapeshifter" && _character.Created)
            {
                objCharNodeAnimalForm = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _character.Metatype + "\"]");
            }
            foreach (string s in AttributeStrings)
            {
                XmlNodeList attNodeList = xmlSavedCharacterNode.SelectNodes("attributes/attribute[name = \"" + s + "\"]");
                // Couldn't find the appopriate attribute in the loaded file, so regenerate it from scratch.
                if (attNodeList.Count == 0)
                {
                    CharacterAttrib att = new CharacterAttrib(_character, s);
                    att = RemakeAttribute(att, objCharNode);
                    switch (CharacterAttrib.ConvertToAttributeCategory(att.Abbrev))
                    {
                    case CharacterAttrib.AttributeCategory.Special:
                        SpecialAttributeList.Add(att);
                        break;

                    case CharacterAttrib.AttributeCategory.Standard:
                        AttributeList.Add(att);
                        break;
                    }
                    if (objCharNodeAnimalForm != null)
                    {
                        att = new CharacterAttrib(_character, s, CharacterAttrib.AttributeCategory.Shapeshifter);
                        att = RemakeAttribute(att, objCharNodeAnimalForm);
                        switch (CharacterAttrib.ConvertToAttributeCategory(att.Abbrev))
                        {
                        case CharacterAttrib.AttributeCategory.Special:
                            SpecialAttributeList.Add(att);
                            break;

                        case CharacterAttrib.AttributeCategory.Standard:
                            AttributeList.Add(att);
                            break;
                        }
                    }
                }
                else
                {
                    foreach (XmlNode attNode in attNodeList)
                    {
                        CharacterAttrib att = new CharacterAttrib(_character, s);
                        att.Load(attNode);
                        switch (CharacterAttrib.ConvertToAttributeCategory(att.Abbrev))
                        {
                        case CharacterAttrib.AttributeCategory.Special:
                            SpecialAttributeList.Add(att);
                            break;

                        case CharacterAttrib.AttributeCategory.Standard:
                            AttributeList.Add(att);
                            break;
                        }
                    }
                }
            }
            ResetBindings();
            Timekeeper.Finish("load_char_attrib");
        }
Beispiel #52
0
        public void Load(XmlNode xmlSavedCharacterNode)
        {
            //Timekeeper.Start("load_char_attrib");
            foreach (CharacterAttrib objAttribute in AttributeList.Concat(SpecialAttributeList))
            {
                objAttribute.UnbindAttribute();
            }
            AttributeList.Clear();
            SpecialAttributeList.Clear();
            XmlDocument objXmlDocument  = XmlManager.Load(_objCharacter.IsCritter ? "critters.xml" : "metatypes.xml");
            XmlNode     xmlMetatypeNode = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]");
            XmlNode     xmlCharNode     = xmlMetatypeNode?.SelectSingleNode("metavariants/metavariant[name = \"" + _objCharacter.Metavariant + "\"]") ?? xmlMetatypeNode;
            // We only want to remake attributes for shifters in career mode, because they only get their second set of attributes when exporting from create mode into career mode
            XmlNode xmlCharNodeAnimalForm = _objCharacter.MetatypeCategory == "Shapeshifter" && _objCharacter.Created ? xmlMetatypeNode : null;

            foreach (string strAttribute in AttributeStrings)
            {
                XmlNodeList lstAttributeNodes = xmlSavedCharacterNode.SelectNodes("attributes/attribute[name = \"" + strAttribute + "\"]");
                // Couldn't find the appopriate attribute in the loaded file, so regenerate it from scratch.
                if (lstAttributeNodes == null || lstAttributeNodes.Count == 0 || xmlCharNodeAnimalForm != null && _objCharacter.LastSavedVersion < new Version("5.200.25"))
                {
                    CharacterAttrib objAttribute;
                    switch (CharacterAttrib.ConvertToAttributeCategory(strAttribute))
                    {
                    case CharacterAttrib.AttributeCategory.Special:
                        objAttribute = new CharacterAttrib(_objCharacter, strAttribute, CharacterAttrib.AttributeCategory.Special);
                        objAttribute = RemakeAttribute(objAttribute, xmlCharNode);
                        SpecialAttributeList.Add(objAttribute);
                        break;

                    case CharacterAttrib.AttributeCategory.Standard:
                        objAttribute = new CharacterAttrib(_objCharacter, strAttribute, CharacterAttrib.AttributeCategory.Standard);
                        objAttribute = RemakeAttribute(objAttribute, xmlCharNode);
                        AttributeList.Add(objAttribute);
                        break;
                    }

                    if (xmlCharNodeAnimalForm == null)
                    {
                        continue;
                    }
                    objAttribute = new CharacterAttrib(_objCharacter, strAttribute, CharacterAttrib.AttributeCategory.Shapeshifter);
                    objAttribute = RemakeAttribute(objAttribute, xmlCharNodeAnimalForm);
                    switch (CharacterAttrib.ConvertToAttributeCategory(objAttribute.Abbrev))
                    {
                    case CharacterAttrib.AttributeCategory.Special:
                        SpecialAttributeList.Add(objAttribute);
                        break;

                    case CharacterAttrib.AttributeCategory.Shapeshifter:
                        AttributeList.Add(objAttribute);
                        break;
                    }
                }
                else
                {
                    foreach (XmlNode xmlAttributeNode in lstAttributeNodes)
                    {
                        CharacterAttrib objAttribute;
                        switch (CharacterAttrib.ConvertToAttributeCategory(strAttribute))
                        {
                        case CharacterAttrib.AttributeCategory.Special:
                            objAttribute = new CharacterAttrib(_objCharacter, strAttribute, CharacterAttrib.AttributeCategory.Special);
                            objAttribute.Load(xmlAttributeNode);
                            SpecialAttributeList.Add(objAttribute);
                            break;

                        case CharacterAttrib.AttributeCategory.Standard:
                            objAttribute = new CharacterAttrib(_objCharacter, strAttribute, CharacterAttrib.AttributeCategory.Standard);
                            objAttribute.Load(xmlAttributeNode);
                            AttributeList.Add(objAttribute);
                            break;
                        }
                    }
                }
            }

            Attributes = new ObservableCollection <CharacterAttrib>
            {
                _objCharacter.BOD,
                _objCharacter.AGI,
                _objCharacter.REA,
                _objCharacter.STR,
                _objCharacter.CHA,
                _objCharacter.INT,
                _objCharacter.LOG,
                _objCharacter.WIL,
                _objCharacter.EDG
            };
            if (_objCharacter.MAGEnabled)
            {
                Attributes.Add(_objCharacter.MAG);
                if (_objCharacter.Options.MysAdeptSecondMAGAttribute && _objCharacter.IsMysticAdept)
                {
                    Attributes.Add(_objCharacter.MAGAdept);
                }
            }
            if (_objCharacter.RESEnabled)
            {
                Attributes.Add(_objCharacter.RES);
            }
            if (_objCharacter.DEPEnabled)
            {
                Attributes.Add(_objCharacter.DEP);
            }
            ResetBindings();
            _objCharacter.RefreshAttributeBindings();
            //Timekeeper.Finish("load_char_attrib");
        }
Beispiel #53
0
        //----------------------------------------------------------------------------+
        //                                    Load                                    |
        //----------------------------------------------------------------------------+
        public void Load(ref XmlDataProviderManager x, string ID, string FileRevisione,
                         Hashtable _Sessioni, Hashtable _SessioniTitoli, Hashtable _SessioniID, int
                         _SessioneNow, string _IDTree, string _IDCliente, string _IDSessione)
        {
            AltoMedioBasso valore;
            DataTable      dt;
            Image          img;
            int            i, id_scheda, j, k, row;
            string         qry, val, xml;
            TextBlock      txt;
            Uri            uriSource;

            //----------------------------------------------- recupero dati da 2.9.1 .. 5
            id        = int.Parse(ID.ToString());
            id_scheda = cBusinessObjects.GetIDTree(id);
            cBusinessObjects.idcliente  = int.Parse(_IDCliente.ToString());
            cBusinessObjects.idsessione = int.Parse(_IDSessione.ToString());
            qry = string.Format(
                "select ID_SCHEDA,value from clsAltoMedioBasso " +
                "where (ID_SCHEDA in (10000205,10000217,10000218,10000219,10000220)) " +
                "and (ID_CLIENTE={0}) and (ID_SESSIONE={1}) " +
                "order by ID_SCHEDA ",
                cBusinessObjects.idcliente, cBusinessObjects.idsessione);
            dt = cBusinessObjects.ExecutesqlDataTable(qry);

            Sessioni       = _Sessioni;
            SessioniTitoli = _SessioniTitoli;
            SessioniID     = _SessioniID;
            SessioneNow    = _SessioneNow;
            IDTree         = _IDTree;
            IDCliente      = _IDCliente;
            IDSessione     = _IDSessione;

            _x  = x.Clone();
            _ID = ID;

            ArrayList Nodi = new ArrayList();

            Nodi.Add("205");
            Nodi.Add("217");
            Nodi.Add("218");
            Nodi.Add("219");
            Nodi.Add("220");

            Hashtable NodiAlias = new Hashtable();

            NodiAlias.Add("205", "204");
            NodiAlias.Add("217", "213");
            NodiAlias.Add("218", "214");
            NodiAlias.Add("219", "215");
            NodiAlias.Add("220", "216");

            #region xaml_objects1

            row = 1;

            Grid             grd = new Grid();
            ColumnDefinition cd  = new ColumnDefinition();
            cd.Width = GridLength.Auto;
            grd.ColumnDefinitions.Add(cd);
            cd       = new ColumnDefinition();
            cd.Width = new GridLength(1, GridUnitType.Star);
            grd.ColumnDefinitions.Add(cd);
            cd       = new ColumnDefinition();
            cd.Width = new GridLength(1, GridUnitType.Star);
            grd.ColumnDefinitions.Add(cd);
            cd       = new ColumnDefinition();
            cd.Width = new GridLength(1, GridUnitType.Star);
            grd.ColumnDefinitions.Add(cd);

            RowDefinition rd = new RowDefinition();
            grd.RowDefinitions.Add(rd);

            txt = new TextBlock();
            grd.Children.Add(txt);
            Grid.SetRow(txt, 0);
            Grid.SetColumn(txt, 0);

            Border brd = new Border();
            brd.BorderThickness = new Thickness(1.0);
            brd.BorderBrush     = Brushes.LightGray;
            brd.Background      = Brushes.LightGray;
            brd.Padding         = new Thickness(2.0);

            txt               = new TextBlock();
            txt.Text          = "Alto";
            txt.FontSize      = 14;
            txt.TextAlignment = TextAlignment.Center;
            txt.FontWeight    = FontWeights.Bold;
            txt.Margin        = new Thickness(0, 0, 0, 10);

            brd.Child = txt;

            grd.Children.Add(brd);
            Grid.SetRow(brd, 0);
            Grid.SetColumn(brd, 1);

            brd = new Border();
            brd.BorderThickness = new Thickness(1.0);
            brd.BorderBrush     = Brushes.LightGray;
            brd.Background      = Brushes.LightGray;
            brd.Padding         = new Thickness(2.0);

            txt               = new TextBlock();
            txt.Text          = "Medio";
            txt.FontSize      = 14;
            txt.TextAlignment = TextAlignment.Center;
            txt.FontWeight    = FontWeights.Bold;
            txt.Margin        = new Thickness(0, 0, 0, 10);

            brd.Child = txt;

            grd.Children.Add(brd);
            Grid.SetRow(brd, 0);
            Grid.SetColumn(brd, 2);

            brd = new Border();
            brd.BorderThickness = new Thickness(1.0);
            brd.BorderBrush     = Brushes.LightGray;
            brd.Background      = Brushes.LightGray;
            brd.Padding         = new Thickness(2.0);

            txt               = new TextBlock();
            txt.Text          = "Basso";
            txt.FontSize      = 14;
            txt.TextAlignment = TextAlignment.Center;
            txt.FontWeight    = FontWeights.Bold;
            txt.Margin        = new Thickness(0, 0, 0, 10);

            brd.Child = txt;

            grd.Children.Add(brd);
            Grid.SetRow(brd, 0);
            Grid.SetColumn(brd, 3);

            #endregion

            //---------------------------------------------------------- scansione valori
            for (i = 0; i < 5; i++)
            {
                //---------------------------------------------------------- lettura valore
                k = -1; valore = AltoMedioBasso.Sconosciuto;
                for (j = 0; j < dt.Rows.Count && k < 0; j++)
                {
                    if (dt.Rows[j].ItemArray[0].ToString().EndsWith(Nodi[i].ToString()))
                    {
                        k = j;
                    }
                }
                if (k > -1)
                {
                    val = dt.Rows[k].ItemArray[1].ToString();
                    if (!string.IsNullOrEmpty(val))
                    {
                        valore = (AltoMedioBasso)Convert.ToInt32(val);
                    }
                }

                //---------------------------------------------- impostazione prima colonna
                rd = new RowDefinition();
                grd.RowDefinitions.Add(rd);

                RevisoftApplication.XmlManager xt = new XmlManager();
                xt.TipoCodifica = RevisoftApplication.XmlManager.TipologiaCodifica.Normale;
                XmlDataProvider TreeXmlProvider = new XmlDataProvider();
                TreeXmlProvider.Document = xt.LoadEncodedFile(App.AppTemplateTreeRevisione);
                XmlNode tnode = TreeXmlProvider.Document.SelectSingleNode(
                    "/Tree//Node[@ID=" + NodiAlias[Nodi[i]].ToString() + "]");

                brd = new Border();
                brd.BorderThickness = new Thickness(1.0);
                brd.BorderBrush     = Brushes.LightGray;
                brd.Background      = (row % 2 == 0) ?
                                      new SolidColorBrush(Color.FromArgb(126, 241, 241, 241)) : Brushes.White;
                brd.Padding = new Thickness(2.0);

                txt      = new TextBlock();
                txt.Text = tnode.Attributes["Codice"].Value + "\t"
                           + tnode.Attributes["Titolo"].Value;
                txt.ToolTip = "Fare Doppio CLick per aprire la Carta di lavoro "
                              + tnode.Attributes["Codice"].Value;
                txt.MouseDown += new MouseButtonEventHandler(txt_MouseDownCicli);
                txt.FontSize   = 13;

                //---------------------------------------------- impostazione nodo "Valore"
                XmlNode nodeNodo = null;
                //   XmlNode nodeNodo = _x.Document.SelectSingleNode(
                //   "/Dati//Dato[@ID='" + _ID + "']/Valore[@ID='" + Nodi[i] + "']");

                if (nodeNodo == null)
                {
                    xml = "<Valore ID='" + Nodi[i].ToString() + "'/>";
                    XmlDocument doctmp = new XmlDocument();
                    doctmp.LoadXml(xml);
                    XmlNode tmpNode_int = doctmp.SelectSingleNode("Valore");
                    XmlNode node_imp    = _x.Document.ImportNode(tmpNode_int, true);
                    _x.Document.SelectSingleNode(
                        "/Dati//Dato[@ID='" + _ID + "']").AppendChild(node_imp);
                    nodeNodo = _x.Document.SelectSingleNode(
                        "/Dati//Dato[@ID='" + _ID + "']/Valore[@ID='"
                        + Nodi[i].ToString() + "']");
                }

                if (nodeNodo.Attributes["name"] == null)
                {
                    XmlAttribute attr = _x.Document.CreateAttribute("name");
                    nodeNodo.Attributes.Append(attr);
                }
                nodeNodo.Attributes["name"].Value = tnode.Attributes["Codice"].Value
                                                    + " " + tnode.Attributes["Titolo"].Value;

                if (nodeNodo.Attributes["value"] == null)
                {
                    XmlAttribute attr = _x.Document.CreateAttribute("value");
                    nodeNodo.Attributes.Append(attr);
                }
                nodeNodo.Attributes["value"].Value = (Convert.ToInt32(valore)).ToString();

                #region xaml_objects2

                brd.Child = txt;
                grd.Children.Add(brd);
                Grid.SetRow(brd, row);
                Grid.SetColumn(brd, 0);

                brd = new Border();
                brd.BorderThickness = new Thickness(1.0);
                brd.BorderBrush     = Brushes.LightGray;
                brd.Background      = (row % 2 == 0) ?
                                      new SolidColorBrush(Color.FromArgb(126, 241, 241, 241)) : Brushes.White;
                brd.Padding = new Thickness(2.0);

                img       = new Image();
                uriSource = (valore == AltoMedioBasso.Alto) ?
                            new Uri(check, UriKind.Relative) : new Uri(uncheck, UriKind.Relative);
                img.Source = new BitmapImage(uriSource);
                img.Width  = 16.0;
                brd.Child  = img;
                grd.Children.Add(brd);
                Grid.SetRow(brd, row);
                Grid.SetColumn(brd, 1);

                brd = new Border();
                brd.BorderThickness = new Thickness(1.0);
                brd.BorderBrush     = Brushes.LightGray;
                brd.Background      = (row % 2 == 0) ?
                                      new SolidColorBrush(Color.FromArgb(126, 241, 241, 241)) : Brushes.White;
                brd.Padding = new Thickness(2.0);

                img       = new Image();
                uriSource = (valore == AltoMedioBasso.Medio) ?
                            new Uri(check, UriKind.Relative) : new Uri(uncheck, UriKind.Relative);
                img.Source = new BitmapImage(uriSource);
                img.Width  = 16.0;
                brd.Child  = img;
                grd.Children.Add(brd);
                Grid.SetRow(brd, row);
                Grid.SetColumn(brd, 2);

                brd = new Border();
                brd.BorderThickness = new Thickness(1.0);
                brd.BorderBrush     = Brushes.LightGray;
                brd.Background      = (row % 2 == 0) ?
                                      new SolidColorBrush(Color.FromArgb(126, 241, 241, 241)) : Brushes.White;
                brd.Padding = new Thickness(2.0);

                img       = new Image();
                uriSource = (valore == AltoMedioBasso.Basso) ?
                            new Uri(check, UriKind.Relative) : new Uri(uncheck, UriKind.Relative);
                img.Source = new BitmapImage(uriSource);
                img.Width  = 16.0;
                brd.Child  = img;
                grd.Children.Add(brd);
                Grid.SetRow(brd, row);
                Grid.SetColumn(brd, 3);

                #endregion

                row++;
            }
            brdMain.Child = grd;
        }
Beispiel #54
0
        public static void Save()
        {
            var file = Config.Instance.DataDir + "DefaultDeckStats.xml";

            XmlManager <DefaultDeckStats> .Save(file, Instance);
        }
Beispiel #55
0
 private void Save()
 {
     XmlManager <List <TurnStats> > .Save(_gameFile, TurnStats);
 }
Beispiel #56
0
 public ApiXml2MdConverter(IDocumentProcessor documentProcessor)
 {
     this.documentProcessor = documentProcessor;
     xmlManager             = new XmlManager();
 }
        public void SaveSettings(string dataDir)
        {
            string settingsFilePath = Path.Combine(dataDir, STORAGE_FILE_NAME);

            XmlManager <PluginSettings> .Save(settingsFilePath, this);
        }
Beispiel #58
0
        /// Create a Weapon Accessory from an XmlNode and return the TreeNodes for it.
        /// <param name="objXmlAccessory">XmlNode to create the object from.</param>
        /// <param name="strMount">Mount slot that the Weapon Accessory will consume.</param>
        /// <param name="intRating">Rating of the Weapon Accessory.</param>
        /// <param name="blnCreateChildren">Whether or not child items should be created.</param>
        /// <param name="blnCreateImprovements">Whether or not bonuses should be created.</param>
        /// <param name="blnSkipCost">Whether or not forms asking to determine variable costs should be displayed.</param>
        public void Create(XmlNode objXmlAccessory, Tuple <string, string> strMount, int intRating, bool blnSkipCost = false, bool blnCreateChildren = true, bool blnCreateImprovements = true)
        {
            if (objXmlAccessory.TryGetStringFieldQuickly("name", ref _strName))
            {
                _objCachedMyXmlNode = null;
            }
            _strMount      = strMount.Item1;
            _strExtraMount = strMount.Item2;
            _intRating     = intRating;
            objXmlAccessory.TryGetStringFieldQuickly("avail", ref _strAvail);
            // Check for a Variable Cost.
            if (blnSkipCost)
            {
                _strCost = "0";
            }
            else
            {
                _strCost = objXmlAccessory["cost"]?.InnerText ?? "0";
                if (_strCost.StartsWith("Variable("))
                {
                    decimal decMin;
                    decimal decMax  = decimal.MaxValue;
                    string  strCost = _strCost.TrimStartOnce("Variable(", true).TrimEndOnce(')');
                    if (strCost.Contains('-'))
                    {
                        string[] strValues = strCost.Split('-');
                        decMin = Convert.ToDecimal(strValues[0], GlobalOptions.InvariantCultureInfo);
                        decMax = Convert.ToDecimal(strValues[1], GlobalOptions.InvariantCultureInfo);
                    }
                    else
                    {
                        decMin = Convert.ToDecimal(strCost.FastEscape('+'), GlobalOptions.InvariantCultureInfo);
                    }

                    if (decMin != 0 || decMax != decimal.MaxValue)
                    {
                        string strNuyenFormat   = _objCharacter.Options.NuyenFormat;
                        int    intDecimalPlaces = strNuyenFormat.IndexOf('.');
                        if (intDecimalPlaces == -1)
                        {
                            intDecimalPlaces = 0;
                        }
                        else
                        {
                            intDecimalPlaces = strNuyenFormat.Length - intDecimalPlaces - 1;
                        }
                        frmSelectNumber frmPickNumber = new frmSelectNumber(intDecimalPlaces);
                        if (decMax > 1000000)
                        {
                            decMax = 1000000;
                        }
                        frmPickNumber.Minimum     = decMin;
                        frmPickNumber.Maximum     = decMax;
                        frmPickNumber.Description = LanguageManager.GetString("String_SelectVariableCost", GlobalOptions.Language).Replace("{0}", DisplayNameShort(GlobalOptions.Language));
                        frmPickNumber.AllowCancel = false;
                        frmPickNumber.ShowDialog();
                        _strCost = frmPickNumber.SelectedValue.ToString(GlobalOptions.InvariantCultureInfo);
                    }
                }
            }

            objXmlAccessory.TryGetStringFieldQuickly("source", ref _strSource);
            objXmlAccessory.TryGetStringFieldQuickly("page", ref _strPage);
            _nodAllowGear = objXmlAccessory["allowgear"];
            if (!objXmlAccessory.TryGetStringFieldQuickly("altnotes", ref _strNotes))
            {
                objXmlAccessory.TryGetStringFieldQuickly("notes", ref _strNotes);
            }
            objXmlAccessory.TryGetStringFieldQuickly("rc", ref _strRC);
            objXmlAccessory.TryGetBoolFieldQuickly("rcdeployable", ref _blnDeployable);
            objXmlAccessory.TryGetInt32FieldQuickly("rcgroup", ref _intRCGroup);
            objXmlAccessory.TryGetStringFieldQuickly("conceal", ref _strConceal);
            objXmlAccessory.TryGetInt32FieldQuickly("ammoslots", ref _intAmmoSlots);
            objXmlAccessory.TryGetStringFieldQuickly("ammoreplace", ref _strAmmoReplace);
            objXmlAccessory.TryGetInt32FieldQuickly("accuracy", ref _intAccuracy);
            objXmlAccessory.TryGetStringFieldQuickly("dicepool", ref _strDicePool);
            objXmlAccessory.TryGetStringFieldQuickly("damagetype", ref _strDamageType);
            objXmlAccessory.TryGetStringFieldQuickly("damage", ref _strDamage);
            objXmlAccessory.TryGetStringFieldQuickly("damagereplace", ref _strDamageReplace);
            objXmlAccessory.TryGetStringFieldQuickly("firemode", ref _strFireMode);
            objXmlAccessory.TryGetStringFieldQuickly("firemodereplace", ref _strFireModeReplace);
            objXmlAccessory.TryGetStringFieldQuickly("ap", ref _strAP);
            objXmlAccessory.TryGetStringFieldQuickly("apreplace", ref _strAPReplace);
            objXmlAccessory.TryGetStringFieldQuickly("addmode", ref _strAddMode);
            objXmlAccessory.TryGetInt32FieldQuickly("fullburst", ref _intFullBurst);
            objXmlAccessory.TryGetInt32FieldQuickly("suppressive", ref _intSuppressive);
            objXmlAccessory.TryGetInt32FieldQuickly("rangebonus", ref _intRangeBonus);
            objXmlAccessory.TryGetStringFieldQuickly("extra", ref _strExtra);
            objXmlAccessory.TryGetInt32FieldQuickly("ammobonus", ref _intAmmoBonus);
            objXmlAccessory.TryGetInt32FieldQuickly("accessorycostmultiplier", ref _intAccessoryCostMultiplier);

            // Add any Gear that comes with the Weapon Accessory.
            XmlNode xmlGearsNode = objXmlAccessory["gears"];

            if (xmlGearsNode != null && blnCreateChildren)
            {
                XmlDocument objXmlGearDocument = XmlManager.Load("gear.xml");
                using (XmlNodeList xmlGearsList = xmlGearsNode.SelectNodes("usegear"))
                    if (xmlGearsList != null)
                    {
                        foreach (XmlNode objXmlAccessoryGear in xmlGearsList)
                        {
                            XmlNode objXmlAccessoryGearName = objXmlAccessoryGear["name"];
                            XmlAttributeCollection objXmlAccessoryGearNameAttributes = objXmlAccessoryGearName?.Attributes;
                            int     intGearRating           = 0;
                            decimal decGearQty              = 1;
                            string  strChildForceSource     = objXmlAccessoryGear["source"]?.InnerText ?? string.Empty;
                            string  strChildForcePage       = objXmlAccessoryGear["page"]?.InnerText ?? string.Empty;
                            string  strChildForceValue      = objXmlAccessoryGearNameAttributes?["select"]?.InnerText ?? string.Empty;
                            bool    blnChildCreateChildren  = objXmlAccessoryGearNameAttributes?["createchildren"]?.InnerText != bool.FalseString;
                            bool    blnAddChildImprovements = objXmlAccessoryGearNameAttributes?["addimprovements"]?.InnerText != bool.FalseString && blnCreateImprovements;
                            if (objXmlAccessoryGear["rating"] != null)
                            {
                                intGearRating = Convert.ToInt32(objXmlAccessoryGear["rating"].InnerText);
                            }
                            if (objXmlAccessoryGearNameAttributes?["qty"] != null)
                            {
                                decGearQty = Convert.ToDecimal(objXmlAccessoryGearNameAttributes["qty"].InnerText, GlobalOptions.InvariantCultureInfo);
                            }

                            XmlNode objXmlGear = objXmlGearDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + objXmlAccessoryGearName?.InnerText + "\" and category = \"" + objXmlAccessoryGear["category"].InnerText + "\"]");
                            Gear    objGear    = new Gear(_objCharacter);

                            List <Weapon> lstWeapons = new List <Weapon>();

                            objGear.Create(objXmlGear, intGearRating, lstWeapons, strChildForceValue, blnAddChildImprovements, blnChildCreateChildren);

                            objGear.Quantity  = decGearQty;
                            objGear.Cost      = "0";
                            objGear.MinRating = intGearRating;
                            objGear.MaxRating = intGearRating;
                            objGear.ParentID  = InternalId;
                            if (!string.IsNullOrEmpty(strChildForceSource))
                            {
                                objGear.Source = strChildForceSource;
                            }
                            if (!string.IsNullOrEmpty(strChildForcePage))
                            {
                                objGear.Page = strChildForcePage;
                            }
                            _lstGear.Add(objGear);

                            // Change the Capacity of the child if necessary.
                            if (objXmlAccessoryGear["capacity"] != null)
                            {
                                objGear.Capacity = '[' + objXmlAccessoryGear["capacity"].InnerText + ']';
                            }
                        }
                    }
            }
        }
Beispiel #59
0
        /// Create a Armor Modification from an XmlNode.
        /// <param name="objXmlArmorNode">XmlNode to create the object from.</param>
        /// <param name="intRating">Rating of the selected ArmorMod.</param>
        /// <param name="lstWeapons">List of Weapons that are created by the Armor.</param>
        /// <param name="blnSkipCost">Whether or not creating the ArmorMod should skip the Variable price dialogue (should only be used by frmSelectArmor).</param>
        /// <param name="blnSkipSelectForms">Whether or not to skip selection forms (related to improvements) when creating this ArmorMod.</param>
        public void Create(XmlNode objXmlArmorNode, int intRating, List <Weapon> lstWeapons, bool blnSkipCost = false, bool blnSkipSelectForms = false)
        {
            if (objXmlArmorNode.TryGetStringFieldQuickly("name", ref _strName))
            {
                _objCachedMyXmlNode = null;
            }
            objXmlArmorNode.TryGetStringFieldQuickly("category", ref _strCategory);
            objXmlArmorNode.TryGetStringFieldQuickly("armorcapacity", ref _strArmorCapacity);
            objXmlArmorNode.TryGetStringFieldQuickly("gearcapacity", ref _strGearCapacity);
            _intRating = intRating;
            objXmlArmorNode.TryGetInt32FieldQuickly("armor", ref _intArmorValue);
            objXmlArmorNode.TryGetInt32FieldQuickly("maxrating", ref _intMaxRating);
            objXmlArmorNode.TryGetStringFieldQuickly("avail", ref _strAvail);
            objXmlArmorNode.TryGetStringFieldQuickly("source", ref _strSource);
            objXmlArmorNode.TryGetStringFieldQuickly("page", ref _strPage);
            if (!objXmlArmorNode.TryGetStringFieldQuickly("altnotes", ref _strNotes))
            {
                objXmlArmorNode.TryGetStringFieldQuickly("notes", ref _strNotes);
            }
            _nodBonus         = objXmlArmorNode["bonus"];
            _nodWirelessBonus = objXmlArmorNode["wirelessbonus"];
            _blnWirelessOn    = _nodWirelessBonus != null;

            objXmlArmorNode.TryGetStringFieldQuickly("cost", ref _strCost);

            // Check for a Variable Cost.
            if (!blnSkipCost && _strCost.StartsWith("Variable("))
            {
                string strFirstHalf   = _strCost.TrimStartOnce("Variable(", true).TrimEndOnce(')');
                string strSecondHalf  = string.Empty;
                int    intHyphenIndex = strFirstHalf.IndexOf('-');
                if (intHyphenIndex != -1)
                {
                    if (intHyphenIndex + 1 < strFirstHalf.Length)
                    {
                        strSecondHalf = strFirstHalf.Substring(intHyphenIndex + 1);
                    }
                    strFirstHalf = strFirstHalf.Substring(0, intHyphenIndex);
                }

                if (!blnSkipSelectForms)
                {
                    decimal decMin;
                    decimal decMax = decimal.MaxValue;
                    if (intHyphenIndex != -1)
                    {
                        decMin = Convert.ToDecimal(strFirstHalf, GlobalOptions.InvariantCultureInfo);
                        decMax = Convert.ToDecimal(strSecondHalf, GlobalOptions.InvariantCultureInfo);
                    }
                    else
                    {
                        decMin = Convert.ToDecimal(strFirstHalf.FastEscape('+'), GlobalOptions.InvariantCultureInfo);
                    }

                    if (decMin != decimal.MinValue || decMax != decimal.MaxValue)
                    {
                        frmSelectNumber frmPickNumber = new frmSelectNumber(_objCharacter.Options.NuyenDecimals);
                        if (decMax > 1000000)
                        {
                            decMax = 1000000;
                        }
                        frmPickNumber.Minimum     = decMin;
                        frmPickNumber.Maximum     = decMax;
                        frmPickNumber.Description = LanguageManager.GetString("String_SelectVariableCost", GlobalOptions.Language).Replace("{0}", DisplayNameShort(GlobalOptions.Language));
                        frmPickNumber.AllowCancel = false;
                        frmPickNumber.ShowDialog();
                        _strCost = frmPickNumber.SelectedValue.ToString(GlobalOptions.InvariantCultureInfo);
                    }
                    else
                    {
                        _strCost = strFirstHalf;
                    }
                }
                else
                {
                    _strCost = strFirstHalf;
                }
            }

            if (objXmlArmorNode["bonus"] != null && !blnSkipSelectForms)
            {
                if (!ImprovementManager.CreateImprovements(_objCharacter, Improvement.ImprovementSource.ArmorMod, _guiID.ToString("D"), objXmlArmorNode["bonus"], false, intRating, DisplayNameShort(GlobalOptions.Language)))
                {
                    _guiID = Guid.Empty;
                    return;
                }
                if (!string.IsNullOrEmpty(ImprovementManager.SelectedValue))
                {
                    _strExtra = ImprovementManager.SelectedValue;
                }
            }

            // Add any Gear that comes with the Armor.
            XmlNode xmlChildrenNode = objXmlArmorNode["gears"];

            if (xmlChildrenNode != null)
            {
                XmlDocument objXmlGearDocument = XmlManager.Load("gear.xml");
                using (XmlNodeList xmlUseGearList = xmlChildrenNode.SelectNodes("usegear"))
                    if (xmlUseGearList != null)
                    {
                        foreach (XmlNode objXmlArmorGear in xmlUseGearList)
                        {
                            intRating = 0;
                            string strForceValue = string.Empty;
                            objXmlArmorGear.TryGetInt32FieldQuickly("rating", ref intRating);
                            objXmlArmorGear.TryGetStringFieldQuickly("select", ref strForceValue);

                            XmlNode objXmlGear = objXmlGearDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + objXmlArmorGear.InnerText + "\"]");
                            Gear    objGear    = new Gear(_objCharacter);

                            objGear.Create(objXmlGear, intRating, lstWeapons, strForceValue, !blnSkipSelectForms);

                            objGear.Capacity      = "[0]";
                            objGear.ArmorCapacity = "[0]";
                            objGear.Cost          = "0";
                            objGear.MaxRating     = objGear.Rating;
                            objGear.MinRating     = objGear.Rating;
                            objGear.ParentID      = InternalId;
                            _lstGear.Add(objGear);
                        }
                    }
            }

            // Add Weapons if applicable.
            if (objXmlArmorNode.InnerXml.Contains("<addweapon>"))
            {
                XmlDocument objXmlWeaponDocument = XmlManager.Load("weapons.xml");

                // More than one Weapon can be added, so loop through all occurrences.
                using (XmlNodeList xmlAddWeaponList = objXmlArmorNode.SelectNodes("addweapon"))
                    if (xmlAddWeaponList != null)
                    {
                        foreach (XmlNode objXmlAddWeapon in xmlAddWeaponList)
                        {
                            string  strLoopID    = objXmlAddWeapon.InnerText;
                            XmlNode objXmlWeapon = strLoopID.IsGuid()
                                ? objXmlWeaponDocument.SelectSingleNode("/chummer/weapons/weapon[id = \"" + strLoopID + "\"]")
                                : objXmlWeaponDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + strLoopID + "\"]");

                            Weapon objGearWeapon = new Weapon(_objCharacter);
                            objGearWeapon.Create(objXmlWeapon, lstWeapons, true, !blnSkipSelectForms, blnSkipCost);
                            objGearWeapon.ParentID = InternalId;
                            objGearWeapon.Cost     = "0";
                            lstWeapons.Add(objGearWeapon);

                            Guid.TryParse(objGearWeapon.InternalId, out _guiWeaponID);
                        }
                    }
            }
            SourceDetail = new SourceString(_strSource, _strPage);
        }
        public void Program()
        {
            QuestionManager.Init();//质检问题初始化

            if (!System.IO.Directory.Exists(Folder))
            {
                Console.WriteLine(string.Format("质检路径不存在:{0},请核对!", Folder));
                QuestionManager.Add(new Question()
                {
                    Code = "1102", Name = "质检路径不存在", Project = CheckProject.目录及文件规范性, Description = string.Format("质检路径不存在:{0},请核对!", Folder)
                });
                return;
            }
            var folderTool = new FolderTool {
                Folder = Folder
            };                                                  //对质检路径进行命名规范检查

            if (!folderTool.Check())
            {
                return;
            }
            _code     = folderTool.Code;
            _district = folderTool.CityName;

            var resultComplete = new ResultComplete(Folder)
            {
                Children = XmlManager.Get("/Folders/Folder", "Name", XmlEnum.DataTree)
            };

            resultComplete.Check();//对质检路径下的文件夹、文件是否存在,是否能够打开进行检查
            QuestionManager.AddRange(resultComplete.Messages.Select(e => new Question {
                Code = "1102", Name = "成果数据丢露", Project = CheckProject.目录及文件规范性, Description = e
            }).ToList());
            _folderTools.AddRange(resultComplete.ExistPath.Select(e => new FileFolder()
            {
                Folder    = e,
                FileNames = XmlManager.GetChildren(string.Format("/Folders/Folder[@Name='{0}']", new DirectoryInfo(e).Name), "Name", XmlEnum.DataTree),
                CityName  = folderTool.CityName,
                Code      = folderTool.Code
            }));

            Parallel.ForEach(_folderTools, tool =>
            {
                tool.Check();
            });

            var path = System.IO.Path.Combine(Folder, DataBase);
            //获取空间数据库文件夹下的单位代码表文件,并获取单位代码信息
            var codefileTool = new FileTool {
                Folder = path, Filter = "*.xls", RegexString = @"^[\u4e00-\u9fa5]+\(\d{6}\)单位代码表.xls$"
            };
            var currentCodeFile = codefileTool.GetFile();

            if (string.IsNullOrEmpty(currentCodeFile))
            {
                Console.WriteLine("未识别到单位代码表文件,请核对空间数据库文件下的文件");
            }
            else
            {
                ExcelManager.Init(currentCodeFile);
            }
            //获取空间数据库文件夹下的空间数据库文件,并对数据库进行检查
            var mdbfileTool = new FileTool()
            {
                Folder = path, Filter = "*.mdb", RegexString = @"^[\u4e00-\u9fa5]+\(\d{6}\)农村存量建设用地调查成功空间数据库.mdb$"
            };
            var currentMdbFile = mdbfileTool.GetFile();

            if (string.IsNullOrEmpty(currentMdbFile))
            {
                Console.WriteLine("未识别到数据库文件,请核对农村存量建设用地调查成功空间数据库.mdb文件");
                QuestionManager.Add(new Question {
                    Code = "2101", Name = "适量数据文件", Project = CheckProject.目录及文件规范性, Description = "未识别到数据库文件,请核对农村存量建设用地调查成功空间数据库.mdb文件"
                });
            }
            else
            {
                TableHeart.Program(currentMdbFile, IDS);
                var gisheart = new ArcGISHeart()
                {
                    MDBFilePath = currentMdbFile, FeatureClassNames = XmlManager.Get("/Tables/Table[@IsSpace='true']", "Name", XmlEnum.Field)
                };
                gisheart.Program();
            }
            Console.WriteLine("开始对统计表格进行质检......");
            var collectfolder = System.IO.Path.Combine(_folder, Collect);

            if (!System.IO.Directory.Exists(collectfolder))
            {
                QuestionManager.Add(new Question {
                    Code = "1101", Name = "统计表格文件夹", Project = CheckProject.目录及文件规范性, Description = string.Format("目录:{0}不存在", collectfolder)
                });
            }
            else
            {
                //汇总表质检
                var excel = new ExcelHeart()
                {
                    Folder = collectfolder, MDBFilePath = currentMdbFile, District = folderTool.CityName, Code = folderTool.Code
                };
                excel.Program();
                QuestionManager.AddRange(excel.Questions);
            }
        }