public MainEncyclopedia()
        {
            InitializeComponent();
            LoadEncyclopedia();
            var n1 = new TreeNodeViewModel("General");
            n1.PropertyChanged += UpdateTextBox;

            using (var context = new Db1Entities())
            {
                var raceList = ( from c in context.Aliens select c ).ToList();
                var raceNodeList = new List<TreeNodeViewModel>();
                foreach (var t1 in raceList.Select(item => new TreeNodeViewModel(item.Name)))
                {
                    t1.PropertyChanged += UpdateTextBox;
                    raceNodeList.Add(t1);
                }
                var n2 = new TreeNodeViewModel("Races", raceNodeList, null);
                n2.PropertyChanged += UpdateTextBox;
                var settings = new SettingsViewModel(new[]
                {
                    n1, n2
                });

                DataContext = settings;
            }
        }
Example #2
0
 private void btDel_Click( object sender, RoutedEventArgs e )
 {
     var context = new Db1Entities();
     var query = from c in context.Attribute where c.Name == TbStat.Text select c;
     var foundstat = query.FirstOrDefault();
     if (TbStat.Text == "")
     {
         MessageBox.Show("Please input Stat!");
     }
     else
     {
         if (foundstat != null && foundstat.Id != 0)
         {
             context.Attribute.Remove(foundstat);
             context.SaveChanges();
             FillListbox();
             MessageBox.Show("'" + TbStat.Text + "' deleted from the Database");
             TbStat.Text = "";
         }
         else
         {
             MessageBox.Show("No Stat with that Name found in the Database");
         }
     }
 }
 private void btAdd_Click( object sender, RoutedEventArgs e )
 {
     using (var context = new Db1Entities())
     {
         var req = new Requirements
         {
             SourceItemID = _sourceItemId,
             TargetRequirementID = _targetItemId,
             TargetType = _targetType,
             SourceType = _sourceType,
             Condition = CbConditions.SelectedValue.ToString(),
             SourceName = TbObject.Text,
             TargetName = TbTarget.Text,
             ConditionValue = TbConditionValue.Text
         };
         context.Requirements.Add(req);
         context.SaveChanges();
     }
     var treeViewItem = TvObjects.SelectedItem as TreeViewItem;
     if (treeViewItem != null)
     {
         treeViewItem.IsSelected = false;
     }
     var viewItem = TvTargets.SelectedItem as TreeViewItem;
     if (viewItem != null)
     {
         viewItem.IsSelected = false;
     }
     TbConditionValue.Text = "";
     TbObject.Text = "";
     TbTarget.Text = "";
     LoadSetPrereqList();
 }
 private static void newTextbox_KeyDown( object sender, KeyEventArgs e )
 {
     if (e.Key != Key.Enter)
     {
         return;
     }
     using (var context = new Db1Entities())
     {
         var textBox = sender as TextBox;
         if (textBox != null)
         {
             var encyclopedia = new Encyclopedia
             {
                 Name = textBox.Text
             };
             context.Encyclopedia.Add(encyclopedia);
         }
         context.SaveChanges();
         var box = sender as TextBox;
         if (box != null)
         {
             MessageBox.Show("The Encyclopedia '" + box.Text + "' has been added to the Database");
         }
     }
     var grid = ( (TextBox) sender ).Parent as Grid;
     ( grid?.Parent as Window )?.Close();
 }
Example #5
0
 private void btAdd_Click( object sender, RoutedEventArgs e )
 {
     int result;
     int.TryParse(TbPoints.Text, out result);
     using (var context = new Db1Entities())
     {
         var addSkill = new Skills
         {
             SkillName = TbSkillName.Text,
             DifficultyLevel = TbDifficultyLevel.Text,
             notes = TbNotes.Text,
             points = result,
             reference = TbReference.Text,
             tech_level = TbTechLevel.Text,
             ControllingAttribute = TbControllingAttribute.Text,
             Description = TbDiscription.Text,
             Defaults = TbDefault.Text,
             Prerequisites = TbPrerequisite.Text
         };
         //AddSkill.specialization = tbSpecialization.Text;
         //AddSkill.Modifiers = tbModifiers.Text;
         context.Skills.Add(addSkill);
         context.SaveChanges();
     }
     InitForm();
     btClear_Click(this, null);
 }
Example #6
0
 public static DateTime GetCurrentDateTime()
 {
     var timecontext = new Db1Entities();
     var query = from c in timecontext.UDateTime orderby c.Id descending select c;
     var filterquery = query.FirstOrDefault();
     return filterquery?.CurrentDateTime ?? new DateTime();
 }
Example #7
0
 private void btAdd_Click( object sender, RoutedEventArgs e )
 {
     var findcontext = new Db1Entities();
     var query = from c in findcontext.Attribute where c.Name == TbStat.Text select c;
     var foundstat = query.FirstOrDefault();
     if (foundstat == null)
     {
         if (TbStat.Text == "")
         {
             MessageBox.Show("Please input Stat!");
         }
         else
         {
             using (var context = new Db1Entities())
             {
                 var newStat = new Attribute
                 {
                     Name = TbStat.Text
                 };
                 context.Attribute.Add(newStat);
                 context.SaveChanges();
             }
             MessageBox.Show("'" + TbStat.Text + "' added to the Database");
             FillListbox();
             TbStat.Text = "";
         }
     }
     else
     {
         MessageBox.Show("That Stat allready exists in the Database!");
     }
 }
Example #8
0
        public static List <StarSystems> LoadAllSystems()
        {
            var context    = new Db1Entities();
            var query      = from c in context.StarSystems select c;
            var allSystems = query.ToList();

            return(allSystems);
        }
Example #9
0
 private void btDelete_Click( object sender, RoutedEventArgs e )
 {
     using (var context = new Db1Entities())
     {
         var delFaction = ( from c in context.Factions where c.Id == LoadedId select c ).FirstOrDefault();
         context.Entry(delFaction).State = EntityState.Deleted;
         context.SaveChanges();
     }
     MessageBox.Show("The Faction '" + TbName.Text + "' has been deleted from the Database");
     btClear_Click(this, null);
 }
Example #10
0
 private void btApply_Click( object sender, RoutedEventArgs e )
 {
     if (TbIsOuter.Text == "true")
     {
         OuterMoonlets updatemoonlet;
         using (var ctx = new Db1Entities())
         {
             updatemoonlet = ctx.OuterMoonlets.FirstOrDefault(s => s.Id.ToString() == TbMoonletId.Text);
         }
         if (updatemoonlet != null)
         {
             updatemoonlet.name = TbMoonletName.Text;
             updatemoonlet.planetRadius = double.Parse(TbMoonletRadius.Text);
             updatemoonlet.blackbodyTemp = double.Parse(TbMoonletblackbodyTemp.Text);
             updatemoonlet.planetRadius = double.Parse(TbMoonletRadius.Text);
             updatemoonlet.orbitalEccent = double.Parse(TbMoonletorbitalEccent.Text);
             updatemoonlet.orbitalPeriod = double.Parse(TbMoonletorbitalPeriod.Text);
             updatemoonlet.orbitalRadius = double.Parse(TbMoonletorbitalRadius.Text);
         }
         using (var dbCtx = new Db1Entities())
         {
             dbCtx.Entry(updatemoonlet).State = EntityState.Modified;
             dbCtx.SaveChanges();
         }
         SystemSelector.CurrentInstance.LoadSystemsFromSql();
     }
     else
     {
         InnerMoonlets updatemoonlet;
         using (var ctx = new Db1Entities())
         {
             updatemoonlet = ctx.InnerMoonlets.FirstOrDefault(s => s.Id.ToString() == TbMoonletId.Text);
         }
         if (updatemoonlet != null)
         {
             if (TbMoonletName.Text != "")
             {
                 updatemoonlet.name = TbMoonletName.Text;
             }
             updatemoonlet.planetRadius = double.Parse(TbMoonletRadius.Text);
             updatemoonlet.blackbodyTemp = double.Parse(TbMoonletblackbodyTemp.Text);
             updatemoonlet.planetRadius = double.Parse(TbMoonletRadius.Text);
             updatemoonlet.orbitalEccent = double.Parse(TbMoonletorbitalEccent.Text);
             updatemoonlet.orbitalPeriod = double.Parse(TbMoonletorbitalPeriod.Text);
             updatemoonlet.orbitalRadius = double.Parse(TbMoonletorbitalRadius.Text);
         }
         using (var dbCtx = new Db1Entities())
         {
             dbCtx.Entry(updatemoonlet).State = EntityState.Modified;
             dbCtx.SaveChanges();
         }
         SystemSelector.CurrentInstance.LoadSystemsFromSql();
     }
 }
Example #11
0
 public static void SetCurrentDateTime( DateTime dt )
 {
     using (var context = new Db1Entities())
     {
         var uDateTime = new UDateTime
         {
             CurrentDateTime = dt,
             SystemTime = DateTime.Now
         };
         context.UDateTime.Add(uDateTime);
         context.SaveChanges();
     }
 }
Example #12
0
        private void btApply_Click( object sender, RoutedEventArgs e )
        {
            Planets updateplanet;
            using (var ctx = new Db1Entities())
            {
                updateplanet = ctx.Planets.FirstOrDefault(s => s.Id.ToString() == TbPlanetId.Text);
            }
            if (updateplanet != null)
            {
                updateplanet.name = TbPlanetName.Text;
                updateplanet.atmCate = int.Parse(TbPlanetatmCate.Text);
                updateplanet.atmMass = double.Parse(TbPlanetatmMass.Text);
                updateplanet.atmPres = TbPlanetatmPres.Text;
                updateplanet.atmnote = TbPlanetatmNote.Text;
                updateplanet.axialTilt = double.Parse(TbPlanetaxialTilt.Text);
                updateplanet.mass = double.Parse(TbPlanetPlanetMass.Text);
                updateplanet.RVM = TbPlanetRvm.Text;
                updateplanet.orbitalPeriod = double.Parse(TbPlanetorbitalPeriod.Text);
                updateplanet.orbitalRadius = double.Parse(TbPlanetorbitalRadius.Text);
                updateplanet.orbitalEccent = double.Parse(TbPlanetorbitalEccent.Text);
                updateplanet.moonRadius = double.Parse(TbPlanetRadius.Text);
                updateplanet.baseType = int.Parse(TbPlanetType.Text);
                updateplanet.SatelliteSize = int.Parse(TbPlanetSite.Text);
                updateplanet.blackbodyTemp = double.Parse(TbPlanetbbt.Text);
                updateplanet.dayFaceMod = int.Parse(TbPlanetdayFaceMod.Text);
                updateplanet.density = double.Parse(TbPlanetDensity.Text);
                updateplanet.diameter = double.Parse(TbPlanetDiameter.Text);
                updateplanet.gravity = double.Parse(TbPlanetGravity.Text);
                updateplanet.hydCoverage = TbPlanethydCov.Text;
                updateplanet.isResonant = bool.Parse(TbPlanetisRes.Text);
                updateplanet.isTideLocked = bool.Parse(TbPlanetisTideLock.Text);
                updateplanet.retrogradeMotion = bool.Parse(TbPlanetretrogradeMotion.Text);
                updateplanet.rotationalPeriod = double.Parse(TbPlanetrotPeriod.Text);
                updateplanet.SatelliteSize = int.Parse(TbPlanetSite.Text);
                updateplanet.siderealPeriod = double.Parse(TbPlanetsiderealPeriod.Text);
                updateplanet.surfaceTemp = double.Parse(TbPlanetsurfaceTemp.Text);
                updateplanet.tecActivity = double.Parse(TbPlanettecActivity.Text);
                updateplanet.tideForce = double.Parse(TbPlanettideForce.Text);
                updateplanet.volActivity = double.Parse(TbPlanetvolActivity.Text);
                updateplanet.orbitalCycle = double.Parse(TbPlanetOrbitalCycle.Text);
            }
            using (var dbCtx = new Db1Entities())
            {
                //3. Mark entity as modified
                dbCtx.Entry(updateplanet).State = EntityState.Modified;

                //4. call SaveChanges
                dbCtx.SaveChanges();
            }
            SystemSelector.CurrentInstance.LoadSystemsFromSql();
        }
Example #13
0
 private void btAdd_Click( object sender, RoutedEventArgs e )
 {
     using (var context = new Db1Entities())
     {
         var sg = new StatGroup
         {
             Name = TbGroupName.Text
         };
         context.StatGroup.Add(sg);
         context.SaveChanges();
     }
     LoadListBoxContent();
     TbGroupName.Text = "";
     TbGroupName1.Text = "";
 }
Example #14
0
        private void btDel1_Click( object sender, RoutedEventArgs e )
        {
            var context = new Db1Entities();
            var groups = LbGroups.SelectedItem as StatGroup;
            var query = from c in context.StatSubGroup where groups.Id == c.GroupId select c;
            var delSubGroup = query.FirstOrDefault();

            using (context)
            {
                var ssg = delSubGroup;
                context.Entry(ssg).State = EntityState.Deleted;
                context.SaveChanges();
            }
            LoadSubListBoxContent();
        }
Example #15
0
 private void LoadCompleteSystem()
 {
     if (CbSelectSystem.SelectedItem == null)
     {
     }
     else
     {
         var context = new Db1Entities();
         context.Configuration.ProxyCreationEnabled = false;
         var query = ( from p in context.StarSystems.Include("Stars").Include("Stars").Include("Stars.Planets").Include("Stars.Planets.InnerMoonlets1").Include("Stars.Planets.OuterMoonlets1").Include("Stars.Planets.MajorMoons1")
             where p.Id == (int) CbSelectSystem.SelectedValue
             select p ).FirstOrDefault();
         _loadedSystem = query;
     }
 }
Example #16
0
        private void btDelete_Click( object sender, RoutedEventArgs e )
        {
            var context = new Db1Entities();
            var id = int.Parse(TbId.Text);
            var queryModifier = from c in context.Modifier where c.Id == id select c;

            using (context)
            {
                var deleteModifier = queryModifier.FirstOrDefault();
                context.Entry(deleteModifier).State = EntityState.Deleted;
                context.SaveChanges();
            }
            InitForm();
            btClear_Click(this, null);
        }
Example #17
0
 private void btApply_Click( object sender, RoutedEventArgs e )
 {
     MajorMoons updateplanet;
     using (var ctx = new Db1Entities())
     {
         updateplanet = ctx.MajorMoons.FirstOrDefault(s => s.Id.ToString() == TbMoonId.Text);
     }
     if (updateplanet != null)
     {
         updateplanet.name = TbMoonName.Text;
         updateplanet.atmCate = int.Parse(TbMoonatmCate.Text);
         updateplanet.atmMass = double.Parse(TbMoonatmMass.Text);
         updateplanet.axialTilt = double.Parse(TbMoonaxialTilt.Text);
         updateplanet.mass = double.Parse(TbMoonMoonMass.Text);
         updateplanet.RVM = double.Parse(TbMoonRvm.Text);
         updateplanet.orbitalPeriod = double.Parse(TbMoonorbitalPeriod.Text);
         updateplanet.orbitalRadius = double.Parse(TbMoonorbitalRadius.Text);
         updateplanet.orbitalEccent = double.Parse(TbMoonorbitalEccent.Text);
         updateplanet.moonRadius = double.Parse(TbMoonRadius.Text);
         updateplanet.baseType = int.Parse(TbMoonType.Text);
         updateplanet.SatelliteSize = int.Parse(TbMoonSite.Text);
         updateplanet.blackbodyTemp = double.Parse(TbMoonbbt.Text);
         updateplanet.dayFaceMod = int.Parse(TbMoondayFaceMod.Text);
         updateplanet.density = double.Parse(TbMoonDensity.Text);
         updateplanet.diameter = double.Parse(TbMoonDiameter.Text);
         updateplanet.gravity = double.Parse(TbMoonGravity.Text);
         updateplanet.hydCoverage = TbMoonhydCov.Text;
         updateplanet.isResonant = bool.Parse(TbMoonisRes.Text);
         updateplanet.isTideLocked = bool.Parse(TbMoonisTideLock.Text);
         updateplanet.retrogradeMotion = bool.Parse(TbMoonretrogradeMotion.Text);
         updateplanet.rotationalPeriod = double.Parse(TbMoonrotPeriod.Text);
         updateplanet.SatelliteSize = int.Parse(TbMoonSite.Text);
         updateplanet.siderealPeriod = double.Parse(TbMoonsiderealPeriod.Text);
         updateplanet.surfaceTemp = double.Parse(TbMoonsurfaceTemp.Text);
         updateplanet.tecActivity = double.Parse(TbMoontecActivity.Text);
         updateplanet.tideForce = int.Parse(TbMoontideForce.Text);
         updateplanet.tideTotal = int.Parse(TbMoontideTotal.Text);
         updateplanet.volActivity = double.Parse(TbMoonvolActivity.Text);
         updateplanet.orbitalCycle = double.Parse(TbMoonOrbitalCycle.Text);
     }
     using (var dbCtx = new Db1Entities())
     {
         dbCtx.Entry(updateplanet).State = EntityState.Modified;
         dbCtx.SaveChanges();
     }
     SystemSelector.CurrentInstance.LoadSystemsFromSql();
 }
Example #18
0
        private static bool UserExists( string userName )
        {
            //grundsätzlich existiert er nicht
            var userExists = false;
            //Neue SQL verbindung

            var context = new Db1Entities();
            var query = from c in context.Registration where c.Username == userName select c;
            var adv = query.FirstOrDefault();

            if (adv != null)
            {
                //User existiert
                userExists = true;
            }
            return userExists;
        }
Example #19
0
 private void btAdd1_Click( object sender, RoutedEventArgs e )
 {
     using (var context = new Db1Entities())
     {
         var statGroup = LbGroups.SelectedItem as StatGroup;
         if (statGroup != null)
         {
             var ssg = new StatSubGroup
             {
                 Name = TbSubGroupName.Text,
                 GroupId = statGroup.Id
             };
             context.StatSubGroup.Add(ssg);
         }
         context.SaveChanges();
     }
     LoadSubListBoxContent();
     TbSubGroupName.Text = "";
 }
Example #20
0
        public static bool LoginCheck( Client cl )
        {
            using (var regcontext = new Db1Entities())
            {
                var query = from c in regcontext.Registration where c.Username == cl.UserName && c.Password == cl.EncPassword select c;
                try
                {
                    var firstOrDefault = query.FirstOrDefault();
                    var userId = firstOrDefault?.Id;

                    return userId > 0;
                }
                catch (Exception)
                {
                    // ignored
                }
            }
            return false;
        }
 private void btApply_Click( object sender, RoutedEventArgs e )
 {
     StarSystems updatesystem;
     using (var ctx = new Db1Entities())
     {
         updatesystem = ctx.StarSystems.FirstOrDefault(s => s.Id.ToString() == TbSysId.Text);
     }
     if (updatesystem != null)
     {
         updatesystem.sysName = TbSysName.Text;
         updatesystem.sysAge = double.Parse(TbSysAge.Text);
     }
     using (var dbCtx = new Db1Entities())
     {
         dbCtx.Entry(updatesystem).State = EntityState.Modified;
         dbCtx.SaveChanges();
     }
     SystemSelector.CurrentInstance.LoadSystemsFromSql();
 }
Example #22
0
 private void btAdd_Click( object sender, RoutedEventArgs e )
 {
     using (var context = new Db1Entities())
     {
         var addModifier = new Modifier
         {
             Name = TbModifierName.Text,
             Notes = TbNotes.Text,
             Description = TbDiscription.Text,
             Modifying_Property = TbModProp.Text,
             Group = CbGroup.Text,
             SubGroup = CbSubGroup.Text
         };
         context.Modifier.Add(addModifier);
         context.SaveChanges();
     }
     InitForm();
     btClear_Click(this, null);
 }
Example #23
0
 public void UpdateAdvantage( AdvantageControl advControl )
 {
     //Reads out of the Database to Edit
     LbModifier.Items.Clear();
     BtAddAdvantage.IsEnabled = false;
     BtEditAdvantage.IsEnabled = true;
     using (var context = new Db1Entities())
     {
         var loadItem = context.Advantages.SingleOrDefault(x => x.Id == advControl.AdvantageId);
         //returns a single item.
         if (loadItem != null)
         {
             _updateId = loadItem.Id;
             TbName.Text = loadItem.Name;
             TbDiscription.Text = loadItem.Discription;
             CbisEnabled.IsChecked = loadItem.isEnabled;
             TbPointCost.Text = loadItem.PointCost.ToString();
             CbisPhysical.IsChecked = loadItem.isPhysical;
             CbisMental.IsChecked = loadItem.isMental;
             CbisSocial.IsChecked = loadItem.isSocial;
             CbisExotic.IsChecked = loadItem.isExotic;
             CbisSuperNatural.IsChecked = loadItem.isSuperNatural;
             CbisMundane.IsChecked = loadItem.isMundane;
             CbhasLevels.IsChecked = loadItem.hasLevels != null && (bool) loadItem.hasLevels;
             CbisCreationLocked.IsChecked = loadItem.isCreationLocked != null && (bool) loadItem.isCreationLocked;
             TbReference.Text = loadItem.Reference;
             TbLimitation.Text = loadItem.Limitation;
         }
         var usedModifers = ( from c in context.UsedModifier where c.ForeignId == loadItem.Id select c ).ToList();
         foreach (var umod in usedModifers)
         {
             var mod = ( from c in context.Modifier where c.Id == umod.ModifierId select c ).FirstOrDefault();
             LbModifier.Items.Add(mod);
             LbModifier.DisplayMemberPath = "Name";
             if (mod != null)
             {
                 _dictMod.Add(mod, umod);
             }
         }
         CheckRequirement();
     }
 }
Example #24
0
        public bool RegistrationCheck( Client c )
        {
            var vUserExists = UserExists(c.UserName);

            if (vUserExists)
            {
                return false;
            }
            using (var context = new Db1Entities())
            {
                var newReg = new Registration
                {
                    Username = c.UserName,
                    EMail = c.EMail,
                    Password = c.EncPassword
                };
                context.Registration.Add(newReg);
                context.SaveChanges();
            }
            return true;
        }
Example #25
0
 private void btCreate_Click( object sender, RoutedEventArgs e )
 {
     using (var context = new Db1Entities())
     {
         var faction = new Factions
         {
             Name = TbName.Text,
             HomePlanet = TbHomeplanet.Text,
             Race = CbRace.SelectedValue.ToString(),
             Cunning = IudCunning.Value,
             Force = IudForce.Value,
             Wealth = IudWealth.Value,
             Income = IudIncome.Value,
             MaxHp = IudMaxHp.Value
         };
         context.Factions.Add(faction);
         context.SaveChanges();
     }
     MessageBox.Show("The Faction '" + TbName.Text + "' has been saved to the Database");
     btClear_Click(this, null);
 }
Example #26
0
        public void DeleteAdvantage( AdvantageControl advControl )
        {
            using (var context = new Db1Entities())
            {
                var itemToRemove = context.Advantages.SingleOrDefault(x => x.Id == advControl.AdvantageId);
                //returns a single item.
                var moddelist = ( from c in context.UsedModifier where c.ForeignId == itemToRemove.Id select c ).ToList();

                if (itemToRemove != null)
                {
                    context.Entry(itemToRemove).State = EntityState.Deleted;
                    foreach (var item in moddelist)
                    {
                        context.Entry(item).State = EntityState.Deleted;
                    }
                    context.SaveChanges();
                }
            }
            MessageBox.Show("Deleted!");
            LoadStackPanelContent();
            ClearControls();
        }
Example #27
0
 public static Character GetBlankCharacter( Client client )
 {
     var c = new Character
     {
         Age = 18,
         Name = "",
         Strenght = 10,
         Intelligence = 10,
         Dexterity = 10,
         Health = 10
     };
     if (c.Strenght != null)
     {
         c.BasicLift = CalcBasicLift((int) c.Strenght);
         c.HitPoints = CalcHp((int) c.Strenght);
     }
     if (c.Intelligence != null)
     {
         c.WillPower = CalcWillPower((int) c.Intelligence);
         c.Perception = CalcPerception((int) c.Intelligence);
     }
     if (c.Health != null)
     {
         c.FatiguePoints = CalcBaseFatiguePoints((int) c.Health);
         if (c.Dexterity != null)
         {
             c.BasicSpeed = CalcBasicSpeed((int) c.Health, (int) c.Dexterity);
         }
     }
     if (c.BasicSpeed != null)
     {
         c.BasicMove = CalcBasicMove((double) c.BasicSpeed);
     }
     c.PlayerName = client.UserName;
     c.PointTotal = 100;
     var context = new Db1Entities();
     c.PlayerId = ( from cn in context.Registration where cn.Username == client.UserName select cn.Id ).FirstOrDefault();
     return c;
 }
Example #28
0
 private void btAddSpec_Click( object sender, RoutedEventArgs e )
 {
     if (TbSpecName.Text != "")
     {
         using (var context = new Db1Entities())
         {
             var ss = new SkillSpecialization
             {
                 Name = TbSpecName.Text,
                 Prerequisites = TbSpecPrereq.Text,
                 SkillId = int.Parse(TbId.Text),
                 Default = TbSpecDefault.Text,
                 Discription = TbSpecDiscription.Text,
                 Modifiers = TbSpecModifiers.Text,
                 IsOptional = CbSpecIsOptional.IsChecked
             };
             context.SkillSpecialization.Add(ss);
             context.SaveChanges();
         }
         CleanControls();
     }
     PreparePage1();
 }
Example #29
0
        private void btApply_Click( object sender, RoutedEventArgs e )
        {
            Stars updatestar;
            using (var ctx = new Db1Entities())
            {
                updatestar = ctx.Stars.Where(s => s.Id.ToString() == TbStarId.Text).FirstOrDefault();
            }
            if (updatestar != null)
            {
                if (TbStarName.Text != "")
                {
                    updatestar.name = TbStarName.Text;
                }
                updatestar.currLumin = double.Parse(TbStarLum.Text);
                updatestar.distFromPrimary = double.Parse(TbStarDistFromPrim.Text);
                updatestar.effTemp = double.Parse(TbStareffTemp.Text);
                updatestar.initLumin = double.Parse(TbStarinitLum.Text);
                updatestar.initMass = double.Parse(TbStarinitMass.Text);
                updatestar.isFlareStar = bool.Parse(TbStarisFlare.Text);
                updatestar.orbitalEccent = double.Parse(TbStarorbitalEccent.Text);
                updatestar.orbitalPeriod = double.Parse(TbStarorbitalPeriod.Text);
                updatestar.orbitalRadius = double.Parse(TbStarorbitalRadius.Text);
                updatestar.radius = double.Parse(TbStarRadius.Text);
                updatestar.specType = TbStarSpecType.Text;
                updatestar.starColor = TbStarDistFromPrim.Text;
            }
            using (var dbCtx = new Db1Entities())
            {
                //3. Mark entity as modified
                dbCtx.Entry(updatestar).State = EntityState.Modified;

                //4. call SaveChanges
                dbCtx.SaveChanges();
            }
            SystemSelector.CurrentInstance.LoadSystemsFromSql();
        }
Example #30
0
 //Specialization TAB
 private void PreparePage1()
 {
     TbSkillNameP1.Text = TbSkillName.Text = _selectedSkill.SkillName;
     var id = int.Parse(TbId.Text);
     var context = new Db1Entities();
     var query = from c in context.SkillSpecialization where c.SkillId == id select c;
     var foundSpecializations = query.ToList();
     TabItemSpecializations.Foreground = foundSpecializations.Count > 0 ? Brushes.Green : Brushes.White;
     LbSpecializations.ItemsSource = foundSpecializations;
     LbSpecializations.DisplayMemberPath = "Name";
 }
Example #31
0
 private void InitForm()
 {
     var context = new Db1Entities();
     var query = from c in context.Skills select c;
     _loadedSkills = query.ToList();
     CbExistingSkill.ItemsSource = _loadedSkills.OrderBy(skills => skills.SkillName);
     CbExistingSkill.DisplayMemberPath = "SkillName";
 }
Example #32
0
        public static void InsertSystem(StarSystem system)
        {
            using (var context = new Db1Entities())
            {
                var newSystem = new StarSystems
                {
                    sysName                = system.SysName,
                    habitableZones         = system.HabitableZones.Count,
                    maxMass                = system.MaxMass,
                    numDwarfPlanets        = system.NumDwarfPlanets,
                    star2index             = system.Star2Index,
                    star3index             = system.Star3Index,
                    subCompanionStar2index = system.SubCompanionStar2Index,
                    subCompanionStar3index = system.SubCompanionStar3Index,
                    sysAge   = system.SysAge,
                    sysStars = system.SysStars.Count
                };
                foreach (var star in system.SysStars)
                {
                    var newStar = new Stars
                    {
                        currLumin       = Math.Round(star.CurrLumin, 4),
                        distFromPrimary = star.DistFromPrimary,
                        effTemp         = Math.Round(star.EffTemp, 4),
                        gasGiantFlag    = star.GasGiantFlag,
                        initLumin       = star.InitLumin,
                        initMass        = star.InitMass,
                        isFlareStar     = star.IsFlareStar,
                        name            = star.Name,
                        orbitalEccent   = star.OrbitalEccent,
                        orbitalPeriod   = Math.Round(star.OrbitalPeriod, 4),
                        orbitalRadius   = star.OrbitalRadius,
                        orbitalSep      = star.OrbitalSep,
                        orderID         = star.OrderId,
                        parentID        = star.ParentId,
                        parentName      = star.ParentName,
                        radius          = Math.Round(star.GetRadiusAu(), 4),
                        selfID          = star.SelfId,
                        specType        = star.SpecType,
                        starAge         = star.StarAge,
                        starColor       = star.StarColor,
                        sysPlanets      = star.SysPlanets.Count,
                        StarOrder       = Star.GetDescFromFlag(star.SelfId)
                    };
                    newStar.StarOrder      = star.ReturnCurrentBranchDesc();
                    newStar.OrbitalDetails = star.PrintOrbitalDetails();
                    newStar.StarString     = star.ToString();

                    foreach (var sat in star.SysPlanets)
                    {
                        var newSatellite = new Planets();
                        var type         = "";
                        var pressure     = "";
                        if (OptionCont.ExpandAsteroidBelt != null && (sat.BaseType != Satellite.BasetypeAsteroidbelt || (bool)OptionCont.ExpandAsteroidBelt))
                        {
                            type = sat.DescSizeType();
                        }
                        if (sat.BaseType == Satellite.BasetypeAsteroidbelt)
                        {
                            type = "Asteroid Belt";
                        }

                        if (sat.BaseType == Satellite.BasetypeAsteroidbelt)
                        {
                            pressure = "None.";
                        }

                        if (sat.BaseType == Satellite.BasetypeGasgiant)
                        {
                            pressure = "Superdense Atmosphere.";
                        }

                        if (sat.BaseType == Satellite.BasetypeMoon || sat.BaseType == Satellite.BasetypeTerrestial)
                        {
                            pressure = sat.GetDescAtmCategory() + "(" + Math.Round(sat.AtmPres, 2) + ")";
                        }

                        newSatellite.SatelliteSize    = sat.SatelliteSize;
                        newSatellite.SatelliteType    = sat.SatelliteType;
                        newSatellite.atmCate          = sat.AtmCate.Count;
                        newSatellite.atmMass          = sat.AtmMass;
                        newSatellite.atmPres          = pressure;
                        newSatellite.axialTilt        = sat.AxialTilt;
                        newSatellite.baseType         = sat.BaseType;
                        newSatellite.blackbodyTemp    = sat.BlackbodyTemp;
                        newSatellite.dayFaceMod       = Convert.ToInt32(sat.DayFaceMod);
                        newSatellite.density          = sat.Density;
                        newSatellite.diameter         = Math.Round(sat.DiameterInKm(), 2);
                        newSatellite.gravity          = Math.Round(sat.Gravity * Satellite.Gforce, 2);
                        newSatellite.hydCoverage      = sat.HydCoverage * 100 + "%";
                        newSatellite.innerMoonlets    = sat.InnerMoonlets.Count;
                        newSatellite.isResonant       = sat.IsResonant;
                        newSatellite.isTideLocked     = sat.IsTideLocked;
                        newSatellite.majorMoons       = sat.MajorMoons.Count;
                        newSatellite.mass             = sat.Mass;
                        newSatellite.masterOrderID    = sat.MasterOrderId;
                        newSatellite.moonRadius       = sat.MoonRadius;
                        newSatellite.name             = sat.Name;
                        newSatellite.nightFaceMod     = Convert.ToInt32(sat.NightFaceMod);
                        newSatellite.orbitalCycle     = sat.OrbitalCycle;
                        newSatellite.orbitalEccent    = sat.OrbitalEccent;
                        newSatellite.orbitalPeriod    = sat.OrbitalPeriod;
                        newSatellite.orbitalRadius    = Math.Round(sat.OrbitalRadius, 2);
                        newSatellite.outerMoonlets    = sat.OuterMoonlets.Count;
                        newSatellite.parentDiam       = sat.ParentDiam;
                        newSatellite.parentID         = sat.ParentId;
                        newSatellite.parentName       = sat.ParentName;
                        newSatellite.retrogradeMotion = sat.RetrogradeMotion;
                        newSatellite.rotationalPeriod = sat.RotationalPeriod;
                        newSatellite.selfID           = sat.SelfId;
                        newSatellite.siderealPeriod   = sat.SiderealPeriod;
                        newSatellite.surfaceTemp      = sat.SurfaceTemp;
                        newSatellite.tecActivity      = sat.TecActivity;
                        newSatellite.tideTotal        = sat.TideTotal;
                        newSatellite.volActivity      = sat.VolActivity;
                        newSatellite.sattype          = type;
                        newSatellite.atmnote          = sat.DescAtm();
                        newSatellite.RVM          = sat.GetRvmDesc();
                        newSatellite.planetString = sat.ToString();

                        foreach (var innerMoonlet in sat.InnerMoonlets)
                        {
                            var newInnerMoonlet = new InnerMoonlets
                            {
                                blackbodyTemp   = innerMoonlet.BlackbodyTemp,
                                name            = innerMoonlet.Name,
                                orbitalEccent   = innerMoonlet.OrbitalEccent,
                                orbitalPeriod   = innerMoonlet.OrbitalPeriod,
                                orbitalRadius   = Math.Round(innerMoonlet.OrbitalRadius, 2),
                                parentID        = innerMoonlet.ParentId,
                                parentName      = innerMoonlet.ParentName,
                                planetRadius    = innerMoonlet.PlanetRadius,
                                selfID          = innerMoonlet.SelfId,
                                innerMoonString = innerMoonlet.ToString()
                            };
                            newSatellite.InnerMoonlets1.Add(newInnerMoonlet);
                        }
                        foreach (var outerMoonlet in sat.OuterMoonlets)
                        {
                            var newOuterMoonlet = new OuterMoonlets
                            {
                                blackbodyTemp   = outerMoonlet.BlackbodyTemp,
                                name            = outerMoonlet.Name,
                                orbitalEccent   = outerMoonlet.OrbitalEccent,
                                orbitalPeriod   = outerMoonlet.OrbitalPeriod,
                                orbitalRadius   = Math.Round(outerMoonlet.OrbitalRadius, 2),
                                parentID        = outerMoonlet.ParentId,
                                parentName      = outerMoonlet.ParentName,
                                planetRadius    = outerMoonlet.PlanetRadius,
                                selfID          = outerMoonlet.SelfId,
                                outerMoonString = outerMoonlet.ToString()
                            };
                            newSatellite.OuterMoonlets1.Add(newOuterMoonlet);
                        }
                        foreach (var majorMoon in sat.MajorMoons)
                        {
                            var newMajorMoon = new MajorMoons
                            {
                                RVM              = majorMoon.Rvm,
                                SatelliteSize    = majorMoon.SatelliteSize,
                                SatelliteType    = majorMoon.SatelliteType,
                                atmCate          = majorMoon.AtmCate.Count,
                                atmMass          = majorMoon.AtmMass,
                                axialTilt        = majorMoon.AxialTilt,
                                baseType         = majorMoon.BaseType,
                                blackbodyTemp    = majorMoon.BlackbodyTemp,
                                dayFaceMod       = Convert.ToInt32(majorMoon.DayFaceMod),
                                density          = majorMoon.Density,
                                diameter         = Math.Round(majorMoon.DiameterInKm(), 2),
                                gravity          = Math.Round(majorMoon.Gravity * Satellite.Gforce, 2),
                                hydCoverage      = sat.HydCoverage * 100 + "%",
                                innerMoonlets    = majorMoon.InnerMoonlets.Count,
                                isResonant       = majorMoon.IsResonant,
                                isTideLocked     = majorMoon.IsTideLocked,
                                majorMoons1      = majorMoon.MajorMoons.Count,
                                mass             = majorMoon.Mass,
                                moonRadius       = majorMoon.MoonRadius,
                                name             = majorMoon.Name,
                                nightFaceMod     = Convert.ToInt32(majorMoon.NightFaceMod),
                                orbitalCycle     = majorMoon.OrbitalCycle,
                                orbitalEccent    = majorMoon.OrbitalEccent,
                                orbitalPeriod    = majorMoon.OrbitalPeriod,
                                orbitalRadius    = Math.Round(majorMoon.OrbitalRadius, 2),
                                outerMoonlets    = majorMoon.OuterMoonlets.Count,
                                parentDiam       = majorMoon.ParentDiam,
                                parentID         = majorMoon.ParentId,
                                parentName       = majorMoon.ParentName,
                                retrogradeMotion = majorMoon.RetrogradeMotion,
                                rotationalPeriod = majorMoon.RotationalPeriod,
                                selfID           = majorMoon.SelfId,
                                siderealPeriod   = majorMoon.SiderealPeriod,
                                surfaceTemp      = majorMoon.SurfaceTemp,
                                tecActivity      = majorMoon.TecActivity,
                                tideForce        = majorMoon.TideForce.Count,
                                tideTotal        = majorMoon.TideTotal,
                                volActivity      = majorMoon.VolActivity,
                                MajorMoonString  = majorMoon.ToString()
                            };
                            newSatellite.MajorMoons1.Add(newMajorMoon);
                        }
                        newStar.Planets.Add(newSatellite);
                    }
                    context.Stars.Add(newStar);
                }
                context.StarSystems.Add(newSystem);
                context.SaveChanges();
            }
        }