Exemplo n.º 1
0
        public IActionResult Index(int part = 1)
        {
            var profileList = ProfilesManager.SelectAll(_sqlConnection);                                                                                       //получаем наш список из таблички
            var model       = new ProfileViewModel(profileList.Count, part, pageSize, profileList.Skip((part - 1) * pageSize).Take(pageSize).ToList(), false); //конструируем модельку вьюшки

            return(View(model));
        }
Exemplo n.º 2
0
        void mainMenu_OnLoadGameClick(object sender, MainMenuEventArgs e)
        {
            mainMenu.Hide();

            //IOManagerEventReceiver will test if the CommandCenter Graphics is already loaded
            IOManager.LoadGame(this, e);

            //sets the selected profile
            ProfilesManager.SetProfile(e.UserName, false);
        }
Exemplo n.º 3
0
        void mainMenu_OnNewGameStartClick(object sender, MainMenuEventArgs e)
        {
            mainMenu.Hide();

            //sets the input profile
            ProfilesManager.SetProfile(e.UserName, true);

            //IOManagerEventReceiver will test if the CommandCenter Graphics is already loaded
            IOManager.NewGame(e, new MainMenuEventArgs(e.UserName));
        }
 public AvailableGamesWindow(Mutex m, DatabaseContext_Main db, Service_JsonParser jsp,
                             NamedPipeManager npm, List <DatabaseContext_Profile> profiles, ProfilesManager profMng)
     : this(db, ConfigurationPurpose.FirstTime)
 {
     _mutex            = m;
     _jsonParser       = jsp;
     _namedPipeManager = npm;
     _dbProfiles       = profiles;
     _profilesManager  = profMng;
 }
Exemplo n.º 5
0
        private void FindAndLoadProfile(string profileString)
        {
            Logger.Debug($"Searching for profile to load: {{{profileString}}}");
            var search  = profileString.Split(',').ToList();
            var profile = ProfilesManager.FindProfile(search);

            if (profile != null)
            {
                SubscriptionsManager.ActivateProfile(profile);
            }
        }
Exemplo n.º 6
0
        public void CopyProfile()
        {
            var profileManager = new ProfilesManager(_context, _context.Profiles);
            var profile        = _context.Profiles[0];

            profileManager.CopyProfile(profile, "Copy");
            var newProfile = _context.Profiles[1];

            Assert.That(newProfile.Guid, Is.Not.EqualTo(profile.Guid));
            Assert.That(newProfile.Title, Is.EqualTo("Copy"));
            Assert.That(newProfile.ParentProfile, Is.Null);
            Assert.That(newProfile.Context, Is.Not.Null);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Saves current settings as a profile.
        /// </summary>
        /// <param name="profileName">Profile name.</param>
        /// <returns>New profile object.</returns>
        public Profile SaveCurrentProfile(string profileName)
        {
            Profile profile = _profiles.Profiles.Where(p => p.Name == profileName).FirstOrDefault();

            if (profile == null)
            {
                profile = new Profile(profileName);
                _profiles.Profiles.Add(profile);
            }

            profile.InterTests = View.SettingsView.TimeBetweenTests;
            profile.Reboot     = View.SettingsView.RebootTimeout;
            profile.Message    = View.SettingsView.MessageTimeout;

            profile.OperationDelay = View.SettingsView.OperationDelay;
            profile.RecoveryDelay  = View.SettingsView.RecoveryDelay;

            profile.DnsIpv4     = View.SettingsView.DnsIpv4;
            profile.NtpIpv4     = View.SettingsView.NtpIpv4;
            profile.GatewayIpv4 = View.SettingsView.GatewayIpv4;

            profile.DnsIpv6     = View.SettingsView.DnsIpv6;
            profile.NtpIpv6     = View.SettingsView.NtpIpv6;
            profile.GatewayIpv6 = View.SettingsView.GatewayIpv6;

            profile.UseEmbeddedPassword = View.SettingsView.UseEmbeddedPassword;
            profile.Password1           = View.SettingsView.Password1;
            profile.Password2           = View.SettingsView.Password2;
            profile.SecureMethod        = View.SettingsView.SecureMethod;

            profile.PTZNodeToken     = View.SettingsView.PTZNodeToken;
            profile.VideoSourceToken = View.SettingsView.VideoSourceToken;

            profile.EventTopic           = View.SettingsView.EventTopic;
            profile.TopicNamespaces      = View.SettingsView.TopicNamespaces;
            profile.SubscriptionTimeout  = View.SettingsView.SubscriptionTimeout;
            profile.RelayOutputDelayTime = View.SettingsView.RelayOutputDelayTimeMonostable;

            TestOptions options = ContextController.GetTestOptions();

            profile.TestCases  = options.Tests;
            profile.TestGroups = options.Groups;

            /*******************************/
            profile.AdvancedSettings = GetAdvancedSettings();

            /********************************/

            ProfilesManager.Save(_profiles);
            return(profile);
        }
Exemplo n.º 8
0
        private void Init()
        {
            IsNotSaved   = false;
            Profiles     = new List <Profile>();
            InputGroups  = new List <DeviceGroup>();
            OutputGroups = new List <DeviceGroup>();

            IOController         = new IOController();
            ProfilesManager      = new ProfilesManager(this, Profiles);
            DevicesManager       = new DevicesManager(this);
            DeviceGroupsManager  = new DeviceGroupsManager(this, InputGroups, OutputGroups);
            SubscriptionsManager = new SubscriptionsManager(this);
            PluginManager        = new PluginsManager(PluginPath);
        }
Exemplo n.º 9
0
 public ModListView()
 {
     InitializeComponent();
     DataContext         = this;
     modDirectoryManager = new ModDirectoryManager();
     if (ModListBox.HasItems)
     {
         ModListBox.SelectedIndex = 0;
     }
     ModListBox.AllowDrop = true;
     profilesManager      = new ProfilesManager();
     SetProfilesOptions();
     OriginalBannerSource = ModBannerImg.Source;
 }
Exemplo n.º 10
0
 void Start()
 {
     _profilesManager = GetComponent <ProfilesManager>();
     _profilesManager.Load();
     _menuMediator.PushPanel(gameObject);
     if (_profilesManager.Container.profiles.Any())
     {
         _loginButton.GetComponentInChildren <Text>().text = _profilesManager.ActiveProfile.name;
     }
     else
     {
         Notify("Login");
     }
 }
Exemplo n.º 11
0
 public ModListView()
 {
     InitializeComponent();
     DataContext         = this;
     modDirectoryManager = new ModDirectoryManager();
     if (ModListBox.HasItems)
     {
         ModListBox.SelectedIndex = 0;
     }
     ModListBox.AllowDrop = true;
     profilesManager      = new ProfilesManager();
     SetProfilesOptions();
     OriginalBannerSource = ModBannerImg.Source;
     LanguageManager.Instance.LanguageChanged += LanguageChanged;
     activeMods = "500";
 }
Exemplo n.º 12
0
        public void CopyChildProfile()
        {
            var profileManager = new ProfilesManager(_context, _context.Profiles);
            var parentProfile  = _context.Profiles[0];
            var childProfile   = _context.ProfilesManager.CreateProfile("Child", null, null);

            parentProfile.AddChildProfile(childProfile);
            var profile = parentProfile.ChildProfiles[0];

            profileManager.CopyProfile(profile, "Copy");
            var newProfile = parentProfile.ChildProfiles[1];

            Assert.That(newProfile.Guid, Is.Not.EqualTo(profile.Guid));
            Assert.That(newProfile.Title, Is.EqualTo("Copy"));
            Assert.That(newProfile.ParentProfile.Guid, Is.EqualTo(parentProfile.Guid));
            Assert.That(newProfile.Context, Is.Not.Null);
        }
Exemplo n.º 13
0
        internal StraightBeam(Autodesk.DesignScript.Geometry.Point ptStart, Autodesk.DesignScript.Geometry.Point ptEnd, Autodesk.DesignScript.Geometry.Vector vOrientation)
        {
            //use lock just to be safe
            //AutoCAD does not support multithreaded access
            lock (myLock)
            {
                //lock the document and start transaction
                using (var _CADAccess = new AdvanceSteel.Services.ObjectAccess.CADContext())
                {
                    string handle = AdvanceSteel.Services.ElementBinder.GetHandleFromTrace();

                    Point3d beamStart = Utils.ToAstPoint(ptStart, true);
                    Point3d beamEnd   = Utils.ToAstPoint(ptEnd, true);

                    if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null)
                    {
                        ProfileName profName = new ProfileName();
                        ProfilesManager.GetProfTypeAsDefault("I", out profName);
                        var myBeam = new Autodesk.AdvanceSteel.Modelling.StraightBeam(profName.Name, beamStart, beamEnd, Vector3d.kXAxis);

                        myBeam.WriteToDb();
                        handle = myBeam.Handle;
                    }

                    Beam beam = Utils.GetObject(handle) as Beam;

                    if (beam != null && beam.IsKindOf(FilerObject.eObjectType.kStraightBeam))
                    {
                        Utils.AdjustBeamEnd(beam, beamStart);
                        beam.SetSysStart(beamStart);
                        beam.SetSysEnd(beamEnd);

                        Utils.SetOrientation(beam, Utils.ToAstVector3d(vOrientation, true));
                    }
                    else
                    {
                        throw new System.Exception("Not a straight Beam");
                    }

                    this.Handle = handle;

                    AdvanceSteel.Services.ElementBinder.CleanupAndSetElementForTrace(beam);
                }
            }
        }
Exemplo n.º 14
0
 /// <summary>
 /// A wrapper of the CreateAndShowCommandCenter/CreateAndShowGUI/CreateGameMap method,
 /// called by the Thread.QueueUserWorkItem method.
 /// </summary>
 private void InstanciateInterfaceWrapper(Object data)
 {
     if ((IOOperation)data == IOOperation.GameInterface_Instance)
     {
         preloader.Status = ((IOOperation)data);
         CreateAndShowGUI();
     }
     if ((IOOperation)data == IOOperation.GameMap_Instance)
     {
         CreateGameMap();
     }
     if ((IOOperation)data == IOOperation.CommandCenter)
     {
         ShowPreloaderTimerMode((IOOperation)data);
         commandCenter.Show();
         ProfilesManager.LoadProfile();
     }
 }
Exemplo n.º 15
0
        public IActionResult GetProfilesByFilter(string fullName, string is_Active, int part = 1)
        {
            if (is_Active == null)
            {
                return(StatusCode(404));
            }
            var profileList = ProfilesManager.GetFilteredProfiles(_sqlConnection, fullName ?? "", is_Active);
            var model       = new ProfileViewModel(profileList.Count, part, pageSize, profileList.Skip((part - 1) * pageSize).Take(pageSize).ToList(), true)
            {
                filter = new FilterObject()
                {
                    fullName = fullName,
                    isActive = is_Active
                }
            };

            return(View("Index", model));
        }
Exemplo n.º 16
0
        // custom function here
        private void CreateStraightBeam()
        {
            ProfileName pn = new ProfileName();

            ProfilesManager.GetProfTypeAsDefault("I", out pn);

            ASGeo.Point3d s1 = ASGeo.Point3d.kOrigin;
            ASGeo.Point3d e1 = new ASGeo.Point3d(0, 0, 3500);

            ASMod.StraightBeam b1 = new ASMod.StraightBeam(pn.Name, s1, e1, ASGeo.Vector3d.kXAxis);
            b1.WriteToDb();

            ASGeo.Point3d s2 = new ASGeo.Point3d(0, 0, 3500);
            ASGeo.Point3d e2 = new ASGeo.Point3d(0, 3000, 3500);

            ASMod.StraightBeam b2 = new ASMod.StraightBeam("AISC 14.1 W Shape#@§@#W10x33", s2, e2, ASGeo.Vector3d.kXAxis);
            // ASMod.StraightBeam b2 = new ASMod.StraightBeam("HEA  DIN18800-1#@§@#HEA200", s2, e2, ASGeo.Vector3d.kXAxis);
            b2.WriteToDb();
        }
Exemplo n.º 17
0
        void CreateAndShowCommandCenter()
        {
            CameraFreeze();
            commandCenter            = new CommandCenter(this.Game);
            commandCenter.StackOrder = 5;
            root.AddChild(commandCenter);

            commandCenter.OnEnterZone += new EventHandler <CommandCenterEventArgs>(commandCenter_OnEnterZone);
            commandCenter.OnSaveGame  += new EventHandler <CommandCenterEventArgs>(commandCenter_OnSaveGame);
            commandCenter.OnLogOut    += new EventHandler(commandCenter_OnLogOut);
            commandCenter.OnExitGame  += new EventHandler(commandCenter_OnExitGame);
            commandCenter.Show(); //the MAP button will initially be pressed, this way

            //loads the selected profile (if the profile already exists)
            //or creates and then loades the input profile (if it is a new profile)
            ProfilesManager.LoadProfile();

            CommandCenterLoaded = true;
        }
Exemplo n.º 18
0
        /// <summary>
        /// Saves current settings as a profile.
        /// </summary>
        /// <param name="profileName">Profile name.</param>
        /// <returns>New profile object.</returns>
        public Profile SaveCurrentProfile(string profileName)
        {
            Profile profile = _profiles.Profiles.Where(p => p.Name == profileName).FirstOrDefault();

            if (profile == null)
            {
                profile = new Profile(profileName);
                _profiles.Profiles.Add(profile);
            }

            //profile.UserName = View.UserName;
            //profile.Password = View.Password;
            //profile.UtcTimeStamp = View.UtcTimestamp;

            profile.InterTests = View.TimeBetweenTests;
            profile.Reboot     = View.RebootTimeout;
            profile.Message    = View.MessageTimeout;

            profile.DnsIpv4     = View.DnsIpv4;
            profile.NtpIpv4     = View.NtpIpv4;
            profile.GatewayIpv4 = View.GatewayIpv4;

            profile.DnsIpv6     = View.DnsIpv6;
            profile.NtpIpv6     = View.NtpIpv6;
            profile.GatewayIpv6 = View.GatewayIpv6;

            profile.UseEmbeddedPassword = View.UseEmbeddedPassword;
            profile.Password1           = View.Password1;
            profile.Password2           = View.Password2;

            profile.OperationDelay = View.OperationDelay;

            TestOptions options = ContextController.GetTestOptions();

            profile.TestCases        = options.Tests;
            profile.InteractiveFirst = options.InteractiveFirst;
            profile.TestGroups       = options.Groups;

            profile.Features = new List <Feature>(View.Features);

            ProfilesManager.Save(_profiles);
            return(profile);
        }
Exemplo n.º 19
0
        internal StraightBeam(Autodesk.DesignScript.Geometry.Point ptStart, Autodesk.DesignScript.Geometry.Point ptEnd, Autodesk.DesignScript.Geometry.Vector vOrientation)
        {
            lock (access_obj)
            {
                using (var ctx = new SteelServices.DocContext())
                {
                    string handle = SteelServices.ElementBinder.GetHandleFromTrace();

                    Point3d  beamStart = Utils.ToAstPoint(ptStart, true);
                    Point3d  beamEnd   = Utils.ToAstPoint(ptEnd, true);
                    Vector3d refVect   = Utils.ToAstVector3d(vOrientation, true);

                    Autodesk.AdvanceSteel.Modelling.StraightBeam beam = null;
                    if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null)
                    {
                        ProfileName profName = new ProfileName();
                        ProfilesManager.GetProfTypeAsDefault("I", out profName);
                        beam = new Autodesk.AdvanceSteel.Modelling.StraightBeam(profName.Name, beamStart, beamEnd, refVect);
                        beam.WriteToDb();
                    }
                    else
                    {
                        beam = Utils.GetObject(handle) as Autodesk.AdvanceSteel.Modelling.StraightBeam;

                        if (beam != null && beam.IsKindOf(FilerObject.eObjectType.kStraightBeam))
                        {
                            Utils.AdjustBeamEnd(beam, beamStart);
                            beam.SetSysStart(beamStart);
                            beam.SetSysEnd(beamEnd);

                            Utils.SetOrientation(beam, refVect);
                        }
                        else
                        {
                            throw new System.Exception("Not a straight Beam");
                        }
                    }
                    Handle = beam.Handle;
                    SteelServices.ElementBinder.CleanupAndSetElementForTrace(beam);
                }
            }
        }
Exemplo n.º 20
0
        public Launcher(
            SettingsManager settings,
            VersionsManager versions,
            ProfilesManager profiles,
            HttpClient httpClient,
            TtyhClient ttyhClient,
            GameRunner runner,
            ILauncherUi ui,
            ILogger logger,
            string launcherName)
        {
            var translationsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Translations");

            _tr = new Translator(new Catalog("core", translationsPath));

            _settings = settings;
            _versions = versions;
            _profiles = profiles;

            _ttyhClient = ttyhClient;
            _runner     = runner;

            _hashChecker = new HashChecker(logger);
            _downloader  = new Downloader(httpClient, logger);

            _ui = ui;

            _logger        = logger;
            _logger.OnLog += _ui.AppendLog;

            _log = new WrappedLogger(logger, launcherName);

            _ui.OnExit += HandleExit;
            _ui.OnPlayButtonClicked += HandlePlayButtonClicked;
            _ui.OnOfflineModeToggle += HandleOfflineModeToggle;

            _ui.OnUploadSkinClicked += HandleSkinUploadClicked;

            _ui.OnEditProfileClicked   += HandleEditProfile;
            _ui.OnAddProfileClicked    += HandleAddProfile;
            _ui.OnRemoveProfileClicked += HandleRemoveProfile;
        }
Exemplo n.º 21
0
        private void Init()
        {
            IsNotSaved = false;
            Profiles   = new List <Profile>();

            try
            {
                IOController = new IOController();
            }
            catch (DirectoryNotFoundException e)
            {
                Logger.Error("IOWrapper provider directory not found", e);
            }

            ProfilesManager      = new ProfilesManager(this, Profiles);
            DevicesManager       = new DevicesManager(this);
            SubscriptionsManager = new SubscriptionsManager(this);
            PluginManager        = new PluginsManager(PluginPath);
            BindingManager       = new BindingManager(this);
        }
Exemplo n.º 22
0
        /// <summary>
        /// The GameMap and GameInterface_Graphics instances are removed
        /// and the CommandCenter is shown
        /// </summary>
        public void ReturnToCommandCenter()
        {
            CameraFreeze();
            SoundManager.StopBackgroundSong();

            camera.ChangeResolution(1024, 768);
            camera.Fullscreen = false;
            camera.Position   = new Vector2(0, 0);
            commandCenter.Show();

            IOManager.SaveGameAndZone(this, commandCenter.GetCurrentSettings, gameMap.SlotList, GameManager.GetConsumptionCoverage(GameManager.CurrentYear), GameManager.ResearchList);

            root.RemoveChild(gameMap);
            Game.Services.RemoveService(typeof(GameMap));
            gameMap = null;
            root.RemoveChild(gameInterface);
            Game.Services.RemoveService(typeof(GameInterface));

            ProfilesManager.LoadProfile();
            CameraFreeze();
        }
Exemplo n.º 23
0
        public void Run()
        {
            AppContext.SetSwitch("System.Net.Http.UseSocketsHttpHandler", false);

            const string appName    = "TtyhLauncher2";
            const string appVersion = "0.0.1";
            const string appUrl     = "https://github.com/dngulin/ttyhlauncher2";

            const string storeUrl  = "https://ttyh.ru/files/newstore";
            const string masterUrl = "https://master.ttyh.ru";
            const string directory = "ttyhlauncher2";

            const int logRotateCount = 3;
            const int requestTimeOut = 5;

            var serializer = new JsonSerializer {
                Formatting             = Formatting.Indented,
                ObjectCreationHandling = ObjectCreationHandling.Replace
            };
            var json = new JsonParser(serializer);

            using (var logger = new FileLogger(directory, logRotateCount))
                using (var settings = new SettingsManager(directory, json, logger))
                    using (var httpClient = new HttpClient()) {
                        httpClient.Timeout = TimeSpan.FromSeconds(requestTimeOut);
                        logger.OnLog      += Console.Out.WriteLine;

                        var versions   = new VersionsManager(storeUrl, directory, httpClient, json, logger);
                        var profiles   = new ProfilesManager(directory, json, logger);
                        var ttyhClient = new TtyhClient(masterUrl, appVersion, settings.Ticket, httpClient, serializer, logger);
                        var runner     = new GameRunner(directory, json, logger, appName, appVersion);

                        var ui       = CreateUi(appName, appVersion, appUrl);
                        var launcher = new Launcher(settings, versions, profiles, httpClient, ttyhClient, runner, ui, logger, appName);

                        launcher.Start();
                        RunEventLoop();
                    }
        }
        public MainWindow(Mutex mutex, DatabaseContext_Main db, Service_JsonParser jsonParser,
                          NamedPipeManager npm, List <DatabaseContext_Profile> profiles, ProfilesManager profMngr, Nexus.NexusUrl modUri = null)
        {
            InitializeComponent();

            _mutex            = mutex;
            _jsonParser       = jsonParser;
            _db               = db;
            _dbProfiles       = profiles;
            _currProfileDb    = _dbProfiles.FirstOrDefault(x => _currGame.Id == x.GameId);
            _namedPipeManager = npm;
            _profilesManager  = profMngr;
            _mulConverter     = new MultiplicationMathConverter();
            _addConverter     = new AdditionMathConverter();

            _namedPipeManager.ChangeMessageReceivedHandler(HandlePipeMessage);

            mainGrid.Dispatcher.BeginInvoke((Action)(() =>
            {
                InitGamePicker();
                _accountHandler = new AccountHandler(WhenLogsIn);
                _accountHandler.Init();
                _modManager = new ModManager(_currProfileDb, ModList_View, Downloads_View, _accountHandler);
                profilePicker.SelectionChanged += profilePicker_SelectionChanged;

                if (modUri != null)
                {
                    _modManager.CreateMod(_currGame, modUri).GetAwaiter();
                }
                _db.UpdateCurrentGame(_currGame, SetGame);
            }));

            if (!_namedPipeManager.IsRunning)
            {
                Task.Run(async() => await _namedPipeManager.Listen_NamedPipe(Dispatcher));
            }
        }
Exemplo n.º 25
0
 public JsonResult GetProfileById(int id)
 {
     return(new JsonResult(ProfilesManager.SelectProfileById(_sqlConnection, id)));
 }
Exemplo n.º 26
0
 /// <summary>
 /// Loads profiles.
 /// </summary>
 /// <returns>list of profiles.</returns>
 public List <Profile> Load()
 {
     _profiles = ProfilesManager.Load();
     return(_profiles.Profiles);
 }
Exemplo n.º 27
0
 void commandCenter_OnLogOut(object sender, EventArgs e)
 {
     commandCenter.Hide();
     ProfilesManager.LogOut();
     mainMenu.Show();
 }
Exemplo n.º 28
0
        public void FirstTimeSetup(Mutex m, Service_JsonParser jsp,
                                   NamedPipeManager npm, List <DatabaseContext_Profile> profiles, ProfilesManager profileManager)
        {
            if (GetCollection <Game>("games").Count() > 0)
            {
                GetCollection <Game>("games").Delete(x => true);
            }

            if (GetCollection <GameApplication>("game_apps").Count() > 0)
            {
                GetCollection <GameApplication>("game_apps").Delete(x => true);
            }
            foreach (var item in profiles)
            {
                item.Dispose();
            }
            profiles.Clear();

            foreach (var item in GetCollection <UserProfile>("profiles").FindAll())
            {
                profileManager.DeleteProfile(item.ProfileId);
            }

            AvailableGamesWindow chooseGames = new AvailableGamesWindow(m, this, jsp, npm, profiles, profileManager);

            chooseGames.Show();
        }
Exemplo n.º 29
0
        internal PolyBeam(Polyline3d poly,
                          Autodesk.DesignScript.Geometry.Vector vOrientation,
                          List <Property> beamProperties)
        {
            lock (access_obj)
            {
                using (var ctx = new SteelServices.DocContext())
                {
                    List <Property> defaultData     = beamProperties.Where(x => x.Level == ".").ToList <Property>();
                    List <Property> postWriteDBData = beamProperties.Where(x => x.Level == "Z_PostWriteDB").ToList <Property>();
                    Property        foundProfName   = beamProperties.FirstOrDefault <Property>(x => x.Name == "ProfName");
                    string          sectionName     = "";
                    if (foundProfName != null)
                    {
                        sectionName = (string)foundProfName.InternalValue;
                    }

                    string handle = SteelServices.ElementBinder.GetHandleFromTrace();

                    if (string.IsNullOrEmpty(sectionName))
                    {
                        ProfileName profName = new ProfileName();
                        ProfilesManager.GetProfTypeAsDefault("I", out profName);
                        sectionName = profName.Name;
                    }

                    Vector3d refVect = Utils.ToAstVector3d(vOrientation, true);

                    Autodesk.AdvanceSteel.Modelling.PolyBeam beam = null;
                    if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null)
                    {
                        beam = new Autodesk.AdvanceSteel.Modelling.PolyBeam(sectionName, poly, refVect);

                        if (defaultData != null)
                        {
                            Utils.SetParameters(beam, defaultData);
                        }

                        beam.WriteToDb();

                        if (postWriteDBData != null)
                        {
                            Utils.SetParameters(beam, postWriteDBData);
                        }
                    }
                    else
                    {
                        beam = Utils.GetObject(handle) as Autodesk.AdvanceSteel.Modelling.PolyBeam;

                        if (beam != null && beam.IsKindOf(FilerObject.eObjectType.kPolyBeam))
                        {
                            beam.SetPolyline(poly);

                            if (defaultData != null)
                            {
                                Utils.SetParameters(beam, defaultData);
                            }

                            Utils.SetOrientation(beam, refVect);

                            if (postWriteDBData != null)
                            {
                                Utils.SetParameters(beam, postWriteDBData);
                            }
                        }
                        else
                        {
                            throw new System.Exception("Not an UnFolded Straight Beam");
                        }
                    }
                    Handle = beam.Handle;
                    SteelServices.ElementBinder.CleanupAndSetElementForTrace(beam);
                }
            }
        }
Exemplo n.º 30
0
        public GameMap(Game game, string Zone)
            : base(game)
        {
            changesMade = false;

            mapFile = zonesFolder + "\\" + Zone + "\\" + mapFile;

            //Loading the Map
            xmlLoaderMap = XElement.Load(mapFile);
            IEnumerable <XElement> mapData = from element in xmlLoaderMap.Elements() select element;
            int elementCount = 0;

            int w = 0;
            int h = 0;

            slotList = new List <Slot>();

            foreach (XElement data in mapData)
            {
                numberOfItemsToRead += data.Elements().Count();
            }

            List <Slot> historySlotList = ProfilesManager.LoadZoneHistory();

            numberOfItemsToRead += historySlotList.Count;

            foreach (XElement data in mapData) //3 categories: Map Dimensions, Map Elements, Slots
            {
                switch (elementCount)
                {
                case 0:     //reads the map dimensions and loades the ground

                    w = Convert.ToInt32(data.Element("Width").Value);
                    h = Convert.ToInt32(data.Element("Height").Value);

                    for (int i = 0; i < w; i++)
                    {
                        for (int j = 0; j < h; j++)
                        {
                            Sprite ground = new Sprite(game, GraphicsCollection.GetPack("ground"));
                            ground.StackOrder  = stackOrder_map;
                            ground.XRelative   = ground.Width * i;
                            ground.YRelative   = ground.Height * j;
                            ground.FrameNumber = 0;
                            AddChild(ground);

                            width  = w * ground.Width;
                            height = h * ground.Height;
                        }
                    }
                    numberOfItemsRead++;
                    DisplayManager.ChangePreloaderPercent(PercentCreated);
                    break;

                case 1:     //reads the map elements
                    IEnumerable <XElement> mapElements = from element in data.Elements() select element;

                    foreach (XElement mapElement in mapElements)
                    {
                        string TexturePack = Convert.ToString(mapElement.Element("TexturePack").Value);
                        int    frameNumber = Convert.ToInt32(mapElement.Element("FrameNumber").Value);
                        int    X           = Convert.ToInt32(mapElement.Element("X").Value);
                        int    Y           = Convert.ToInt32(mapElement.Element("Y").Value);

                        Sprite mapSpriteElement = new Sprite(game, GraphicsCollection.GetPack(TexturePack).Frames[frameNumber]);
                        mapSpriteElement.StackOrder  = stackOrder_map;
                        mapSpriteElement.XRelative   = X;
                        mapSpriteElement.YRelative   = Y;
                        mapSpriteElement.FrameNumber = 0;
                        AddChild(mapSpriteElement);

                        numberOfItemsRead++;
                        DisplayManager.ChangePreloaderPercent(PercentCreated);
                    }
                    break;

                case 2:     //reads the slots
                    IEnumerable <XElement> slotsData = from element in data.Elements() select element;

                    foreach (XElement slotElement in slotsData)
                    {
                        ConstructionType slot_constructionType = (ConstructionType)Enum.Parse(typeof(ConstructionType), Convert.ToString(slotElement.Element("ConstructionType").Value));

                        int X = Convert.ToInt32(slotElement.Element("X").Value);
                        int Y = Convert.ToInt32(slotElement.Element("Y").Value);

                        Slot slot;
                        slot             = new Slot(game, slot_constructionType);
                        slot.StackOrder  = stackOrder_slots;
                        slot.XSlotCenter = X;
                        slot.YSlotCenter = Y;
                        slot.Visible     = false;
                        slot.OnSelected += new EventHandler(slot_OnSelected);
                        AddChild(slot);
                        slotList.Add(slot);

                        numberOfItemsRead++;
                        DisplayManager.ChangePreloaderPercent(PercentCreated);
                    }
                    break;
                    //case 3, se det slot-ul dupa x si y si se face instanta slot
                    // se face instanta reservation
                    //se trimit SetConstructionReservation(slot+reservation)
                }
                elementCount++;
            }

            //reading zone history
            for (int i = 0; i < slotList.Count; i++)
            {
                for (int j = 0; j < historySlotList.Count; j++)
                {
                    if (slotList[i].ConstructionType == historySlotList[j].ConstructionType &&
                        slotList[i].XSlotCenter == historySlotList[j].XSlotCenter &&
                        slotList[i].YSlotCenter == historySlotList[j].YSlotCenter)
                    {
                        slotList[i].ReservationList = historySlotList[j].ReservationList;
                        numberOfItemsRead++;
                        DisplayManager.ChangePreloaderPercent(PercentCreated);
                        break;
                    }
                }
            }

            Game.Services.AddService(typeof(GameMap), this);

            //test only, the population will be loaded from the saved game
            GameManager.LoadHistory();
            changesMade = true;
            GameManager.UpdateYear(2010);

            HideSlots();

            DisplayManager.GameMap_HidePreloader();
        }