Esempio n. 1
0
        /// <summary>
        /// インスタンスを生成します。
        /// </summary>
        /// <param name="settings">チャンク設定。</param>
        /// <param name="graphicsDevice">グラフィックス デバイス。</param>
        /// <param name="regionManager">リージョン マネージャ。</param>
        /// <param name="sceneManager">シーン マネージャ。</param>
        public ChunkManager(
            ChunkSettings settings,
            GraphicsDevice graphicsDevice,
            RegionManager regionManager,
            SceneManager sceneManager)
            : base(settings.PartitionManager)
        {
            if (graphicsDevice == null) throw new ArgumentNullException("graphicsDevice");
            if (regionManager == null) throw new ArgumentNullException("regionManager");

            ChunkSize = settings.ChunkSize;
            this.graphicsDevice = graphicsDevice;
            this.regionManager = regionManager;
            SceneManager = sceneManager;

            switch (settings.ChunkStoreType)
            {
                case ChunkStoreType.Storage:
                    ChunkStore = StorageChunkStore.Instance;
                    break;
                default:
                    ChunkStore = NullChunkStore.Instance;
                    break;
            }

            EmptyData = new ChunkData(this);

            BaseNode = sceneManager.CreateSceneNode("ChunkRoot");
            sceneManager.RootNode.Children.Add(BaseNode);

            meshManager = new ChunkMeshManager(this, settings.VertexBuildConcurrencyLevel, settings.UpdateBufferCountPerFrame);
        }
        public override void ViewDidLoad()
        {
            var mapView = new MKMapView();
            View = mapView;

            base.ViewDidLoad();

            var firstViewModel = (FourthViewModel)ViewModel;
            _regionManager = new RegionManager(mapView);

            var button = new UIButton(UIButtonType.RoundedRect);
            button.Frame = new RectangleF(10, 10, 300, 40);
            button.SetTitle("move", UIControlState.Normal);
            Add(button);

            var lat = new UITextField(new RectangleF(10, 50, 130, 40));
            lat.KeyboardType = UIKeyboardType.DecimalPad;
            Add(lat);

            var lng = new UITextField(new RectangleF(160, 50, 130, 40));
            lng.KeyboardType = UIKeyboardType.DecimalPad;
            Add(lng);

            var set = this.CreateBindingSet<FourthView, Core.ViewModels.FourthViewModel>();
            set.Bind(button).To(vm => vm.UpdateCenterCommand);
            set.Bind(lat).To(vm => vm.Lat);
            set.Bind(lng).To(vm => vm.Lng);
            set.Bind(_regionManager).For(r => r.Center).To(vm => vm.Location);
            set.Apply();
        }
        public override void ViewDidLoad()
        {
            var mapView = new MKMapView();
            View = mapView;

            base.ViewDidLoad();

            // ios7 layout
            if (RespondsToSelector(new Selector("edgesForExtendedLayout")))
                EdgesForExtendedLayout = UIRectEdge.None;

            var regionManager = new RegionManager(mapView);
            mapView.Delegate = regionManager;

            var button = new UIButton(UIButtonType.RoundedRect);
            button.Frame = new RectangleF(10, 10, 300, 40);
            button.SetTitle("move", UIControlState.Normal);
            Add(button);


            var set = this.CreateBindingSet<FifthView, Core.ViewModels.FifthViewModel>();
            set.Bind(regionManager).For(r => r.TheLocation).To(vm => vm.Location);
            set.Bind(button).For("Title").To(vm => vm.Location);
            set.Apply();
        }
Esempio n. 4
0
        public void AddPassesItselfAsTheRegionManagerOfTheRegion()
        {
            var regionManager = new RegionManager();
            var region = new MockRegion();
            regionManager.Regions.Add("region", region);

            Assert.AreSame(regionManager, region.RegionManager);
        }
 public LocalizationEngineController(UniversityManager universityManager, RegionManager regionManager,
     SpecialityManager specialityManager, CityManager cityManager, FacultyManager facultyManager)
 {
     this.universityManager = universityManager;
     this.regionManager = regionManager;
     this.facultyManager = facultyManager;
     this.specialityManager = specialityManager;
     this.cityManager = cityManager;
 }
Esempio n. 6
0
        public void CanAddRegion()
        {
            IRegion region1 = new MockRegion();

            RegionManager regionManager = new RegionManager();
            regionManager.Regions.Add("MainRegion", region1);

            IRegion region2 = regionManager.Regions["MainRegion"];
            Assert.AreSame(region1, region2);
        }
Esempio n. 7
0
    void Start()
    {
        if (!statusText)
            statusText = GetComponentInChildren<Text>();

        if (!gameManager)
            gameManager = GameObject.FindObjectOfType<GameManager>();

        if (!regionManager)
            regionManager = GameObject.FindObjectOfType<RegionManager>();
    }
Esempio n. 8
0
        /// <summary>
        /// Creates an instance of a <see cref="Region"/> for a given set of coordinates.
        /// </summary>
        /// <param name="rm">The <see cref="RegionManager"/> that should be managing this region.</param>
        /// <param name="cache">A shared cache for holding chunks.</param>
        /// <param name="rx">The global X-coordinate of the region.</param>
        /// <param name="rz">The global Z-coordinate of the region.</param>
        /// <remarks><para>The constructor will not actually open or parse any region files.  Given just the region coordinates, the
        /// region will be able to determien the correct region file to look for based on the naming pattern for regions:
        /// r.x.z.mcr, given x and z are integers representing the region's coordinates.</para>
        /// <para>Regions require a <see cref="ChunkCache"/> to be provided because they do not actually store any chunks or references
        /// to chunks on their own.  This allows regions to easily pass off requests outside of their bounds, if necessary.</para></remarks>
        public Region(RegionManager rm, ChunkCache cache, int rx, int rz)
        {
            _regionMan = rm;
            _cache = cache;
            _regionFile = new WeakReference(null);
            _rx = rx;
            _rz = rz;

            if (!File.Exists(GetFilePath())) {
                throw new FileNotFoundException();
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Creates an instance of a <see cref="Region"/> for the given region file.
        /// </summary>
        /// <param name="rm">The <see cref="RegionManager"/> that should be managing this region.</param>
        /// <param name="cache">A shared cache for holding chunks.</param>
        /// <param name="filename">The region file to derive the region from.</param>
        /// <remarks><para>The constructor will not actually open or parse the region file.  It will only read the file's name in order
        /// to derive the region's coordinates, based on a strict naming pattern for regions: r.x.z.mcr, given x and z are integers
        /// representing the region's coordinates.</para>
        /// <para>Regions require a <see cref="ChunkCache"/> to be provided because they do not actually store any chunks or references
        /// to chunks on their own.  This allows regions to easily pass off requests outside of their bounds, if necessary.</para></remarks>
        public Region(RegionManager rm, ChunkCache cache, string filename)
        {
            _regionMan = rm;
            _cache = cache;
            _regionFile = new WeakReference(null);

            ParseFileName(filename, out _rx, out _rz);

            if (!File.Exists(Path.Combine(_regionMan.GetRegionPath(), filename))) {
                throw new FileNotFoundException();
            }
        }
Esempio n. 10
0
        public void CanCheckTheExistenceOfARegion()
        {
            RegionManager regionManager = new RegionManager();
            bool result = regionManager.Regions.ContainsKey("noRegion");

            Assert.IsFalse(result);

            IRegion region = new MockRegion();

            regionManager.Regions.Add("noRegion", region);

            result = regionManager.Regions.ContainsKey("noRegion");

            Assert.IsTrue(result);
        }
Esempio n. 11
0
        public DataImportController(CityManager cityManager, RegionManager regionManager, UniversityManager universityManager, FacultyManager facultyManager, SpecialityManager specialityManager,
            IFacultyToSpecialityDataProvider facToSpecProvider)
        {
            this.facultyManager = facultyManager;

            this.specialityManager = specialityManager;

            this.facToSpecProvider = facToSpecProvider;

            this.regionManager = regionManager;

            this.cityManager = cityManager;

            this.universityManager = universityManager;
        }
    void Start()
    {
        gameObject.SetActive(false);

        playerSpellStatus.GetComponent<Text>().text = "";

        if (!nameText)
            nameText = transform.FindChild("Name").GetComponent<Text>();

        if (!regionSpellsList)
            regionSpellsList = transform.FindChild("Region Spells").GetComponent<RegionSpellsUI>();

        if (!regionManager)
            regionManager = GameObject.FindObjectOfType<RegionManager>();

        if (!gameManager)
            gameManager = GameObject.FindObjectOfType<GameManager>();
    }
    public void Awake()
    {
        if (!menuManager)
            menuManager = GameObject.FindObjectOfType<MenuManager>();

        if (!notificationManager)
            notificationManager = GameObject.FindObjectOfType<NotificationManager>();

        if (!spellHistoryMenu)
            spellHistoryMenu = GameObject.FindObjectOfType<SpellHistoryMenu>();

        if (!regionDetailsMenu)
            regionDetailsMenu = GameObject.FindObjectOfType<RegionDetailsMenu>();

        if (!wizardIcon)
            wizardIcon = GameObject.FindObjectOfType<WizardIcon>();

        spellManager = GetComponent<SpellManager>();
        wizardManager = GetComponent<WizardManager>();
        regionManager = GetComponent<RegionManager>();
    }
Esempio n. 14
0
        public override void Initialize()
        {
            HandleCommandLine(Environment.GetCommandLineArgs());

            if (!Directory.Exists(SavePath))
                Directory.CreateDirectory(SavePath);

            DateTime now = DateTime.Now;
            string logFilename;
            try
            {
                logFilename = Path.Combine(SavePath, now.ToString(LogFormat)+".log");
            }
            catch(Exception)
            {
                // Problem with the log format use the default
                logFilename = Path.Combine(SavePath, now.ToString(LogFormatDefault) + ".log");
            }
            #if DEBUG
            Log.Initialize(logFilename, LogLevel.All, false);
            #else
            Log.Initialize(logFilename, LogLevel.All & ~LogLevel.Debug, LogClear);
            #endif
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            try
            {
                if (File.Exists(Path.Combine(SavePath, "tshock.pid")))
                {
                    Log.ConsoleInfo(
                        "TShock was improperly shut down. Please use the exit command in the future to prevent this.");
                    File.Delete(Path.Combine(SavePath, "tshock.pid"));
                }
                File.WriteAllText(Path.Combine(SavePath, "tshock.pid"), Process.GetCurrentProcess().Id.ToString(CultureInfo.InvariantCulture));

                ConfigFile.ConfigRead += OnConfigRead;
                FileTools.SetupConfig();

                HandleCommandLinePostConfigLoad(Environment.GetCommandLineArgs());

                if (Config.StorageType.ToLower() == "sqlite")
                {
                    string sql = Path.Combine(SavePath, "tshock.sqlite");
                    DB = new SqliteConnection(string.Format("uri=file://{0},Version=3", sql));
                }
                else if (Config.StorageType.ToLower() == "mysql")
                {
                    try
                    {
                        var hostport = Config.MySqlHost.Split(':');
                        DB = new MySqlConnection();
                        DB.ConnectionString =
                            String.Format("Server={0}; Port={1}; Database={2}; Uid={3}; Pwd={4};",
                                          hostport[0],
                                          hostport.Length > 1 ? hostport[1] : "3306",
                                          Config.MySqlDbName,
                                          Config.MySqlUsername,
                                          Config.MySqlPassword
                                );
                    }
                    catch (MySqlException ex)
                    {
                        Log.Error(ex.ToString());
                        throw new Exception("MySql not setup correctly");
                    }
                }
                else
                {
                    throw new Exception("Invalid storage type");
                }

                Backups = new BackupManager(Path.Combine(SavePath, "backups"));
                Backups.KeepFor = Config.BackupKeepFor;
                Backups.Interval = Config.BackupInterval;
                Bans = new BanManager(DB);
                Warps = new WarpManager(DB);
                Users = new UserManager(DB);
                Groups = new GroupManager(DB);
                Regions = new RegionManager(DB);
                Itembans = new ItemManager(DB);
                RememberedPos = new RemeberedPosManager(DB);
                InventoryDB = new InventoryManager(DB);
                RestApi = new SecureRest(Netplay.serverListenIP, Config.RestApiPort);
                RestApi.Verify += RestApi_Verify;
                RestApi.Port = Config.RestApiPort;
                RestManager = new RestManager(RestApi);
                RestManager.RegisterRestfulCommands();

                var geoippath = Path.Combine(SavePath, "GeoIP.dat");
                if (Config.EnableGeoIP && File.Exists(geoippath))
                    Geo = new GeoIPCountry(geoippath);

                Log.ConsoleInfo(string.Format("TerrariaShock Version {0} ({1}) now running.", Version, VersionCodename));

                GameHooks.PostInitialize += OnPostInit;
                GameHooks.Update += OnUpdate;
                ServerHooks.Connect += OnConnect;
                ServerHooks.Join += OnJoin;
                ServerHooks.Leave += OnLeave;
                ServerHooks.Chat += OnChat;
                ServerHooks.Command += ServerHooks_OnCommand;
                NetHooks.GetData += OnGetData;
                NetHooks.SendData += NetHooks_SendData;
                NetHooks.GreetPlayer += OnGreetPlayer;
                NpcHooks.StrikeNpc += NpcHooks_OnStrikeNpc;
                NpcHooks.SetDefaultsInt += OnNpcSetDefaults;
                ProjectileHooks.SetDefaults += OnProjectileSetDefaults;
                WorldHooks.StartHardMode += OnStartHardMode;
                WorldHooks.SaveWorld += SaveManager.Instance.OnSaveWorld;

                GetDataHandlers.InitGetDataHandler();
                Commands.InitCommands();
                //RconHandler.StartThread();

                if (Config.RestApiEnabled)
                    RestApi.Start();

                if (Config.BufferPackets)
                    PacketBuffer = new PacketBufferer();

                Log.ConsoleInfo("AutoSave " + (Config.AutoSave ? "Enabled" : "Disabled"));
                Log.ConsoleInfo("Backups " + (Backups.Interval > 0 ? "Enabled" : "Disabled"));

                if (Initialized != null)
                    Initialized();
            }
            catch (Exception ex)
            {
                Log.Error("Fatal Startup Exception");
                Log.Error(ex.ToString());
                Environment.Exit(1);
            }
        }
Esempio n. 15
0
        public void Initialize()
        {
            TShock.Config = new ConfigFile();
            TShock.Config.StorageType = "sqlite";

            DB = new SqliteConnection(string.Format("uri=file://{0},Version=3", "tshock.test.sqlite"));
            DB.Open();

            manager = new RegionManager(DB);
            TShock.Regions = manager;
            manager.ReloadForUnitTest("test");
        }
Esempio n. 16
0
        public override void Initialize()
        {
            if (!Directory.Exists(SavePath))
                Directory.CreateDirectory(SavePath);

            #if DEBUG
            Log.Initialize(Path.Combine(SavePath, "log.txt"), LogLevel.All, false);
            #else
            Log.Initialize(Path.Combine(SavePath, "log.txt"), LogLevel.All & ~LogLevel.Debug, false);
            #endif
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            try
            {

                if (File.Exists(Path.Combine(SavePath, "tshock.pid")))
                {
                    Log.ConsoleInfo("TShock was improperly shut down. Deleting invalid pid file...");
                    File.Delete(Path.Combine(SavePath, "tshock.pid"));
                }
                File.WriteAllText(Path.Combine(SavePath, "tshock.pid"), Process.GetCurrentProcess().Id.ToString());

                ConfigFile.ConfigRead += OnConfigRead;
                FileTools.SetupConfig();

                HandleCommandLine(Environment.GetCommandLineArgs());

                if (Config.StorageType.ToLower() == "sqlite")
                {
                    string sql = Path.Combine(SavePath, "tshock.sqlite");
                    DB = new SqliteConnection(string.Format("uri=file://{0},Version=3", sql));
                }
                else if (Config.StorageType.ToLower() == "mysql")
                {
                    try
                    {
                        var hostport = Config.MySqlHost.Split(':');
                        DB = new MySqlConnection();
                        DB.ConnectionString =
                            String.Format("Server='{0}'; Port='{1}'; Database='{2}'; Uid='{3}'; Pwd='{4}';",
                                          hostport[0],
                                          hostport.Length > 1 ? hostport[1] : "3306",
                                          Config.MySqlDbName,
                                          Config.MySqlUsername,
                                          Config.MySqlPassword
                                );
                    }
                    catch (MySqlException ex)
                    {
                        Log.Error(ex.ToString());
                        throw new Exception("MySql not setup correctly");
                    }
                }
                else
                {
                    throw new Exception("Invalid storage type");
                }

                Backups = new BackupManager(Path.Combine(SavePath, "backups"));
                Backups.KeepFor = Config.BackupKeepFor;
                Backups.Interval = Config.BackupInterval;
                Bans = new BanManager(DB);
                Warps = new WarpManager(DB);
                Users = new UserManager(DB);
                Groups = new GroupManager(DB);
                Groups.LoadPermisions();
                Regions = new RegionManager(DB);
                Itembans = new ItemManager(DB);
                RememberedPos = new RemeberedPosManager(DB);

                Log.ConsoleInfo(string.Format("TShock Version {0} ({1}) now running.", Version, VersionCodename));

                GameHooks.PostInitialize += OnPostInit;
                GameHooks.Update += OnUpdate;
                ServerHooks.Join += OnJoin;
                ServerHooks.Leave += OnLeave;
                ServerHooks.Chat += OnChat;
                ServerHooks.Command += ServerHooks_OnCommand;
                NetHooks.GetData += GetData;
                NetHooks.GreetPlayer += OnGreetPlayer;
                NpcHooks.StrikeNpc += NpcHooks_OnStrikeNpc;

                GetDataHandlers.InitGetDataHandler();
                Commands.InitCommands();
                //RconHandler.StartThread();

                if (Config.BufferPackets)
                    bufferer = new PacketBufferer();

                Log.ConsoleInfo("AutoSave " + (Config.AutoSave ? "Enabled" : "Disabled"));
                Log.ConsoleInfo("Backups " + (Backups.Interval > 0 ? "Enabled" : "Disabled"));

            }
            catch (Exception ex)
            {
                Log.Error("Fatal Startup Exception");
                Log.Error(ex.ToString());
                Environment.Exit(1);
            }
        }
Esempio n. 17
0
 public void ShouldFailIfRegionDoesntExists()
 {
     RegionManager regionManager = new RegionManager();
     IRegion       region        = regionManager.Regions["nonExistentRegion"];
 }
Esempio n. 18
0
 public SupervisorModule(RegionManager regionManager, IUnityContainer container)
 {
     _regionManager = regionManager;
     _container     = container;
 }
Esempio n. 19
0
        public void ShouldAttachNewRegionByUsingRegisteredRegionAdapterMappings()
        {
            var mappings = new RegionAdapterMappings();
            var mockRegionAdapter = new MockRegionAdapter();
            mappings.RegisterMapping(typeof(DependencyObject), mockRegionAdapter);
            var regionManager = new RegionManager(mappings);
            var control = new ContentControl();

            regionManager.AttachNewRegion(control, "TestRegionName");

            Assert.IsTrue(mockRegionAdapter.InitializeCalled);
            Assert.AreEqual(control, mockRegionAdapter.InitializeArgument);
        }
 public MainStationViewModel()
 {
     RegionManager = new RegionManager();
 }
Esempio n. 21
0
 public MainModule(RegionManager regionManager, IUnityContainer container)
 {
     _regionManager = regionManager;
     _container     = container;
 }
        public HyperspinFileModule(IUnityContainer container, IRegionManager manager) : base(container, manager)
        {
            _regionManager = manager;

            RegionManager.RegisterViewWithRegion(RegionNames.FilesRegion, typeof(Views.HyperspinFilesView));
        }
 public CompanyMenuViewModel(RegionManager regionManager) : base(regionManager)
 {
 }
 private void Awake()
 {
     Instence = this;
 }
Esempio n. 25
0
 protected override void InitializeModule()
 {
     RegionManager.RegisterViewWithRegion(RegionNames.ContentRegion, typeof(SubCategoryView));
 }
Esempio n. 26
0
 private void SetRegionManager(IRegionManager regionManager, DependencyObject regionTarget, string regionName)
 {
     RegionManager.SetRegionName(regionTarget, regionName);
     RegionManager.SetRegionManager(regionTarget, regionManager);
 }
Esempio n. 27
0
        /// <summary>
        /// Run the bootstrapper process.
        /// </summary>
        /// <param name="runWithDefaultConfiguration">If <see langword="true"/>, registers default Prism Library services in the container. This is the default behavior.</param>
        public override void Run(bool runWithDefaultConfiguration)
        {
            _useDefaultConfiguration = runWithDefaultConfiguration;

            Logger = CreateLogger();
            if (Logger == null)
            {
                throw new InvalidOperationException(Resources.NullLoggerFacadeException);
            }

            Logger.Log(Resources.LoggerCreatedSuccessfully, Category.Debug, Priority.Low);

            Logger.Log(Resources.CreatingModuleCatalog, Category.Debug, Priority.Low);
            ModuleCatalog = CreateModuleCatalog();
            if (ModuleCatalog == null)
            {
                throw new InvalidOperationException(Resources.NullModuleCatalogException);
            }

            Logger.Log(Resources.ConfiguringModuleCatalog, Category.Debug, Priority.Low);
            ConfigureModuleCatalog();

            Logger.Log(Resources.CreatingStructureMapContainer, Category.Debug, Priority.Low);
            Container = CreateContainer();
            if (Container == null)
            {
                throw new InvalidOperationException(Resources.NullStructureMapContainerException);
            }

            ContainerExtension = CreateContainerExtension();

            Logger.Log(Resources.ConfiguringStructureMapContainer, Category.Debug, Priority.Low);
            ConfigureContainer();

            Logger.Log(Resources.ConfiguringServiceLocatorSingleton, Category.Debug, Priority.Low);
            ConfigureServiceLocator();

            Logger.Log(Resources.ConfiguringViewModelLocator, Category.Debug, Priority.Low);
            ConfigureViewModelLocator();

            Logger.Log(Resources.ConfiguringRegionAdapters, Category.Debug, Priority.Low);
            ConfigureRegionAdapterMappings();

            Logger.Log(Resources.ConfiguringDefaultRegionBehaviors, Category.Debug, Priority.Low);
            ConfigureDefaultRegionBehaviors();

            Logger.Log(Resources.RegisteringFrameworkExceptionTypes, Category.Debug, Priority.Low);
            RegisterFrameworkExceptionTypes();

            Logger.Log(Resources.CreatingShell, Category.Debug, Priority.Low);
            Shell = CreateShell();
            if (Shell != null)
            {
                Logger.Log(Resources.SettingTheRegionManager, Category.Debug, Priority.Low);
                RegionManager.SetRegionManager(Shell, Container.GetInstance <IRegionManager>());

                Logger.Log(Resources.UpdatingRegions, Category.Debug, Priority.Low);
                RegionManager.UpdateRegions();

                Logger.Log(Resources.InitializingShell, Category.Debug, Priority.Low);
                InitializeShell();
            }

            if (Container.Model.HasImplementationsFor <IModuleManager>())
            {
                Logger.Log(Resources.InitializingModules, Category.Debug, Priority.Low);
                InitializeModules();
            }

            Logger.Log(Resources.BootstrapperSequenceCompleted, Category.Debug, Priority.Low);
        }
Esempio n. 28
0
        public void ShouldRemoveRegionManagerWhenRemoving()
        {
            var regionManager = new RegionManager();
            var region = new MockRegion();
            regionManager.Regions.Add("TestRegion", region);

            regionManager.Regions.Remove("TestRegion");

            Assert.IsNull(region.RegionManager);
        }
Esempio n. 29
0
 public EngineModule(IUnityContainer container, RegionManager regionManager)
 {
     _container = container;
 }
Esempio n. 30
0
        /// <summary>
        /// Run the bootstrapper process.
        /// </summary>
        /// <param name="runWithDefaultConfiguration">If <see langword="true"/>, registers default Prism Library services in the container. This is the default behavior.</param>
        public override void Run(bool runWithDefaultConfiguration)
        {
            this.useDefaultConfiguration = runWithDefaultConfiguration;

            this.Logger = this.CreateLogger();
            if (this.Logger == null)
            {
                throw new InvalidOperationException(Resources.NullLoggerFacadeException);
            }

            this.Logger.Log(Resources.LoggerCreatedSuccessfully, Category.Debug, Priority.Low);

            this.Logger.Log(Resources.CreatingModuleCatalog, Category.Debug, Priority.Low);
            this.ModuleCatalog = this.CreateModuleCatalog();
            if (this.ModuleCatalog == null)
            {
                throw new InvalidOperationException(Resources.NullModuleCatalogException);
            }

            this.Logger.Log(Resources.ConfiguringModuleCatalog, Category.Debug, Priority.Low);
            this.ConfigureModuleCatalog();

            this.Logger.Log(Resources.CreatingContainer, Category.Debug, Priority.Low);
            this.Container = this.CreateContainer();
            if (this.Container == null)
            {
                throw new InvalidOperationException(Resources.NullUnityContainerException);
            }

            ContainerLocator.SetContainerExtension(CreateContainerExtension);
            ContainerExtension = ContainerLocator.Current;

            this.Logger.Log(Resources.ConfiguringContainer, Category.Debug, Priority.Low);
            this.ConfigureContainer();

            this.Logger.Log(Resources.ConfiguringViewModelLocator, Category.Debug, Priority.Low);
            this.ConfigureViewModelLocator();

            this.Logger.Log(Resources.ConfiguringRegionAdapters, Category.Debug, Priority.Low);
            this.ConfigureRegionAdapterMappings();

            this.Logger.Log(Resources.ConfiguringDefaultRegionBehaviors, Category.Debug, Priority.Low);
            this.ConfigureDefaultRegionBehaviors();

            this.Logger.Log(Resources.RegisteringFrameworkExceptionTypes, Category.Debug, Priority.Low);
            this.RegisterFrameworkExceptionTypes();

            this.Logger.Log(Resources.CreatingShell, Category.Debug, Priority.Low);
            this.Shell = this.CreateShell();
            if (this.Shell != null)
            {
                this.Logger.Log(Resources.SettingTheRegionManager, Category.Debug, Priority.Low);
                RegionManager.SetRegionManager(this.Shell, this.Container.Resolve <IRegionManager>());

                this.Logger.Log(Resources.UpdatingRegions, Category.Debug, Priority.Low);
                RegionManager.UpdateRegions();

                this.Logger.Log(Resources.InitializingShell, Category.Debug, Priority.Low);
                this.InitializeShell();
            }

            if (this.Container.IsRegistered <IModuleManager>())
            {
                this.Logger.Log(Resources.InitializingModules, Category.Debug, Priority.Low);
                this.InitializeModules();
            }

            this.Logger.Log(Resources.BootstrapperSequenceCompleted, Category.Debug, Priority.Low);
        }
 /// <summary>
 ///     <see cref="IRegionConfigurator.InitializeShell" />
 /// </summary>
 public void InitializeShell(DependencyObject shell, IRegionManager rm)
 {
     //RegionManager.UpdateRegions();
     RegionManager.SetRegionManager(shell, rm);
 }
Esempio n. 32
0
 public Task ShowDesignTemplates()
 {
     RegionManager.RequestNavigate(Regions.CruiseContentRegion, nameof(StratumTemplateListView));
     return(Task.CompletedTask);
 }
Esempio n. 33
0
        public async override Task OnDestroyAsync()
        {
            await RegionManager.DestroyRegions("ContentRegion1", "ContentRegion2");

            await base.OnDestroyAsync();
        }
Esempio n. 34
0
 public Task ShowCuttingUnitList()
 {
     RegionManager.RequestNavigate(Regions.CruiseContentRegion, nameof(CuttingUnitListView));
     return(Task.CompletedTask);
 }
Esempio n. 35
0
 public Task ShowCruiseLandingLayout()
 {
     RegionManager.Regions[Regions.ContentRegion].RemoveAll();
     RegionManager.RequestNavigate(Regions.ContentRegion, nameof(CruiseMasterView));
     return(Task.CompletedTask);
 }
Esempio n. 36
0
 public Task ShowAuditRules()
 {
     RegionManager.RequestNavigate(Regions.CruiseContentRegion, nameof(TreeAuditRuleListView));
     return(Task.CompletedTask);
 }
Esempio n. 37
0
        public override void Initialize()
        {
            HandleCommandLine(Environment.GetCommandLineArgs());

            if (!Directory.Exists(SavePath))
                Directory.CreateDirectory(SavePath);

            #if DEBUG
            Log.Initialize(Path.Combine(SavePath, "log.txt"), LogLevel.All, false);
            #else
            Log.Initialize(Path.Combine(SavePath, "log.txt"), LogLevel.All & ~LogLevel.Debug, false);
            #endif
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            try
            {
                if (File.Exists(Path.Combine(SavePath, "tshock.pid")))
                {
                    Log.ConsoleInfo(
                        "TShock was improperly shut down. Please avoid this in the future, world corruption may result from this.");
                    File.Delete(Path.Combine(SavePath, "tshock.pid"));
                }
                File.WriteAllText(Path.Combine(SavePath, "tshock.pid"), Process.GetCurrentProcess().Id.ToString(CultureInfo.InvariantCulture));

                ConfigFile.ConfigRead += OnConfigRead;
                FileTools.SetupConfig();

                HandleCommandLine_Port(Environment.GetCommandLineArgs());

                if (Config.StorageType.ToLower() == "sqlite")
                {
                    string sql = Path.Combine(SavePath, "tshock.sqlite");
                    DB = new SqliteConnection(string.Format("uri=file://{0},Version=3", sql));
                }
                else if (Config.StorageType.ToLower() == "mysql")
                {
                    try
                    {
                        var hostport = Config.MySqlHost.Split(':');
                        DB = new MySqlConnection();
                        DB.ConnectionString =
                            String.Format("Server={0}; Port={1}; Database={2}; Uid={3}; Pwd={4};",
                                          hostport[0],
                                          hostport.Length > 1 ? hostport[1] : "3306",
                                          Config.MySqlDbName,
                                          Config.MySqlUsername,
                                          Config.MySqlPassword
                                );
                    }
                    catch (MySqlException ex)
                    {
                        Log.Error(ex.ToString());
                        throw new Exception("MySql not setup correctly");
                    }
                }
                else
                {
                    throw new Exception("Invalid storage type");
                }

                Backups = new BackupManager(Path.Combine(SavePath, "backups"));
                Backups.KeepFor = Config.BackupKeepFor;
                Backups.Interval = Config.BackupInterval;
                Bans = new BanManager(DB);
                Warps = new WarpManager(DB);
                Users = new UserManager(DB);
                Groups = new GroupManager(DB);
                Groups.LoadPermisions();
                Regions = new RegionManager(DB);
                Itembans = new ItemManager(DB);
                RememberedPos = new RemeberedPosManager(DB);
                Inventory = new InventoryManager(DB);
                HomeManager = new HomeManager(DB);
                ArmorShopManager = new ArmorShopManager(DB);
                WeaponShopManager = new WeaponShopManager(DB);
                ItemShopManager = new ItemShopManager(DB);
                BlockShopManager = new BlockShopManager(DB);
                OtherShopManager = new OtherShopManager(DB);
                Towns = new TownManager(DB);
                Chat = new ChatManager(DB);
                Restart = new RestartManager();
                RestApi = new SecureRest(Netplay.serverListenIP, 8080);
                RestApi.Verify += RestApi_Verify;
                RestApi.Port = Config.RestApiPort;
                RestManager = new RestManager(RestApi);
                RestManager.RegisterRestfulCommands();

                var geoippath = Path.Combine(SavePath, "GeoIP.dat");
                if (Config.EnableGeoIP && File.Exists(geoippath))
                    Geo = new GeoIPCountry(geoippath);

                    profiles = @"Z:\profiles\";
                    temp = @"Z:\profiles\temp\";

                Console.Title = string.Format("TerrariaShock Version {0} ({1})", Version, VersionCodename);
                Log.ConsoleInfo(string.Format("TerrariaShock Version {0} ({1}) now running.", Version, VersionCodename));

                GameHooks.PostInitialize += OnPostInit;
                GameHooks.Update += OnUpdate;
                ServerHooks.Connect += OnConnect;
                ServerHooks.Join += OnJoin;
                ServerHooks.Leave += OnLeave;
                ServerHooks.Chat += OnChat;
                ServerHooks.Command += ServerHooks_OnCommand;
                NetHooks.GetData += OnGetData;
                NetHooks.SendData += NetHooks_SendData;
                NetHooks.GreetPlayer += OnGreetPlayer;
                NpcHooks.StrikeNpc += NpcHooks_OnStrikeNpc;
                NpcHooks.SetDefaultsInt += OnNpcSetDefaults;
                ProjectileHooks.SetDefaults += OnProjectileSetDefaults;
                WorldHooks.StartHardMode += OnStartHardMode;
                WorldHooks.SaveWorld += OnSaveWorld;

                GetDataHandlers.InitGetDataHandler();
                Commands.InitCommands();

                if (Config.BufferPackets)
                    PacketBuffer = new PacketBufferer();

                Users.DeletePlayersAfterMinutes(TShock.Config.DeleteUserAfterMinutes, 30, false);
                Users.DeletePlayersAfterMinutes(TShock.Config.DeleteUserAfterMinutes * 2, 100, false);
                Users.DeletePlayersAfterMinutes(TShock.Config.DeleteUserAfterMinutes * 3, 10000, true);

                Log.ConsoleInfo("AutoSave " + (Config.AutoSave ? "Enabled" : "Disabled"));
                Log.ConsoleInfo("Backups " + (Backups.Interval > 0 ? "Enabled" : "Disabled"));

                if (Initialized != null)
                    Initialized();
            }
            catch (Exception ex)
            {
                Log.Error("Fatal Startup Exception");
                Log.Error(ex.ToString());
                TShock.Backups.Backup();
                Environment.Exit(1);
            }
        }
Esempio n. 38
0
 public Task ShowTreeDefaultValues()
 {
     RegionManager.RequestNavigate(Regions.CruiseContentRegion, nameof(TreeDefaultValueListView));
     return(Task.CompletedTask);
 }
Esempio n. 39
0
 private RegionManager GetRegionManager()
 {
     if (regionManager == null)
         regionManager = FindObjectOfType<RegionManager>();
     return regionManager;
 }
Esempio n. 40
0
 public Task ShowSpecies()
 {
     RegionManager.RequestNavigate(Regions.CruiseContentRegion, nameof(SpeciesListView));
     return(Task.CompletedTask);
 }
Esempio n. 41
0
        public override void Initialize()
        {
            string logFilename;
            string logPathSetupWarning;

            try
            {
                HandleCommandLine(Environment.GetCommandLineArgs());

                if (!Directory.Exists(SavePath))
                    Directory.CreateDirectory(SavePath);

                ConfigFile.ConfigRead += OnConfigRead;
                FileTools.SetupConfig();

                Main.ServerSideCharacter = ServerSideCharacterConfig.Enabled;

                DateTime now = DateTime.Now;
                // Log path was not already set by the command line parameter?
                if (LogPath == LogPathDefault)
                    LogPath = Config.LogPath;
                try
                {
                    logFilename = Path.Combine(LogPath, now.ToString(LogFormat) + ".log");
                    if (!Directory.Exists(LogPath))
                        Directory.CreateDirectory(LogPath);
                }
                catch (Exception ex)
                {
                    logPathSetupWarning =
                        "Could not apply the given log path / log format, defaults will be used. Exception details:\n" + ex;

                    ServerApi.LogWriter.PluginWriteLine(this, logPathSetupWarning, TraceLevel.Error);

                    // Problem with the log path or format use the default
                    logFilename = Path.Combine(LogPathDefault, now.ToString(LogFormatDefault) + ".log");
                }

                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            }
            catch (Exception ex)
            {
                // Will be handled by the server api and written to its crashlog.txt.
                throw new Exception("Fatal TShock initialization exception. See inner exception for details.", ex);
            }

            // Further exceptions are written to TShock's log from now on.
            try
            {
                if (Config.StorageType.ToLower() == "sqlite")
                {
                    string sql = Path.Combine(SavePath, "tshock.sqlite");
                    DB = new SqliteConnection(string.Format("uri=file://{0},Version=3", sql));
                }
                else if (Config.StorageType.ToLower() == "mysql")
                {
                    try
                    {
                        var hostport = Config.MySqlHost.Split(':');
                        DB = new MySqlConnection();
                        DB.ConnectionString =
                            String.Format("Server={0}; Port={1}; Database={2}; Uid={3}; Pwd={4};",
                                hostport[0],
                                hostport.Length > 1 ? hostport[1] : "3306",
                                Config.MySqlDbName,
                                Config.MySqlUsername,
                                Config.MySqlPassword
                                );
                    }
                    catch (MySqlException ex)
                    {
                        ServerApi.LogWriter.PluginWriteLine(this, ex.ToString(), TraceLevel.Error);
                        throw new Exception("MySql not setup correctly");
                    }
                }
                else
                {
                    throw new Exception("Invalid storage type");
                }

                if (Config.UseSqlLogs)
                    Log = new SqlLog(DB, logFilename, LogClear);
                else
                    Log = new TextLog(logFilename, LogClear);

                if (File.Exists(Path.Combine(SavePath, "tshock.pid")))
                {
                    Log.ConsoleInfo(
                        "TShock was improperly shut down. Please use the exit command in the future to prevent this.");
                    File.Delete(Path.Combine(SavePath, "tshock.pid"));
                }
                File.WriteAllText(Path.Combine(SavePath, "tshock.pid"),
                    Process.GetCurrentProcess().Id.ToString(CultureInfo.InvariantCulture));

                HandleCommandLinePostConfigLoad(Environment.GetCommandLineArgs());

                Backups = new BackupManager(Path.Combine(SavePath, "backups"));
                Backups.KeepFor = Config.BackupKeepFor;
                Backups.Interval = Config.BackupInterval;
                Bans = new BanManager(DB);
                Warps = new WarpManager(DB);
                Regions = new RegionManager(DB);
                Users = new UserManager(DB);
                Groups = new GroupManager(DB);
                Itembans = new ItemManager(DB);
                ProjectileBans = new ProjectileManagager(DB);
                TileBans = new TileManager(DB);
                RememberedPos = new RememberedPosManager(DB);
                CharacterDB = new CharacterManager(DB);
                RestApi = new SecureRest(Netplay.ServerIP, Config.RestApiPort);
                RestManager = new RestManager(RestApi);
                RestManager.RegisterRestfulCommands();

                var geoippath = Path.Combine(SavePath, "GeoIP.dat");
                if (Config.EnableGeoIP && File.Exists(geoippath))
                    Geo = new GeoIPCountry(geoippath);

                Log.ConsoleInfo("TShock {0} ({1}) now running.", Version, VersionCodename);

                ServerApi.Hooks.GamePostInitialize.Register(this, OnPostInit);
                ServerApi.Hooks.GameUpdate.Register(this, OnUpdate);
                ServerApi.Hooks.GameHardmodeTileUpdate.Register(this, OnHardUpdate);
                ServerApi.Hooks.GameStatueSpawn.Register(this, OnStatueSpawn);
                ServerApi.Hooks.ServerConnect.Register(this, OnConnect);
                ServerApi.Hooks.ServerJoin.Register(this, OnJoin);
                ServerApi.Hooks.ServerLeave.Register(this, OnLeave);
                ServerApi.Hooks.ServerChat.Register(this, OnChat);
                ServerApi.Hooks.ServerCommand.Register(this, ServerHooks_OnCommand);
                ServerApi.Hooks.NetGetData.Register(this, OnGetData);
                ServerApi.Hooks.NetSendData.Register(this, NetHooks_SendData);
                ServerApi.Hooks.NetGreetPlayer.Register(this, OnGreetPlayer);
                ServerApi.Hooks.NpcStrike.Register(this, NpcHooks_OnStrikeNpc);
                ServerApi.Hooks.ProjectileSetDefaults.Register(this, OnProjectileSetDefaults);
                ServerApi.Hooks.WorldStartHardMode.Register(this, OnStartHardMode);
                ServerApi.Hooks.WorldSave.Register(this, SaveManager.Instance.OnSaveWorld);
                ServerApi.Hooks.WorldChristmasCheck.Register(this, OnXmasCheck);
                ServerApi.Hooks.WorldHalloweenCheck.Register(this, OnHalloweenCheck);
                ServerApi.Hooks.NetNameCollision.Register(this, NetHooks_NameCollision);
                Hooks.PlayerHooks.PlayerPreLogin += OnPlayerPreLogin;
                Hooks.PlayerHooks.PlayerPostLogin += OnPlayerLogin;
                Hooks.AccountHooks.AccountDelete += OnAccountDelete;
                Hooks.AccountHooks.AccountCreate += OnAccountCreate;

                GetDataHandlers.InitGetDataHandler();
                Commands.InitCommands();

                if (Config.RestApiEnabled)
                    RestApi.Start();

                if (Config.BufferPackets)
                    PacketBuffer = new PacketBufferer(this);

                Log.ConsoleInfo("AutoSave " + (Config.AutoSave ? "Enabled" : "Disabled"));
                Log.ConsoleInfo("Backups " + (Backups.Interval > 0 ? "Enabled" : "Disabled"));

                if (Initialized != null)
                    Initialized();

                Log.ConsoleInfo("Welcome to TShock for Terraria. Initialization complete.");
            }
            catch (Exception ex)
            {
                Log.Error("Fatal Startup Exception");
                Log.Error(ex.ToString());
                Environment.Exit(1);
            }
        }
Esempio n. 42
0
        protected override void Initialized(object state)
        {
            if (!Directory.Exists(RegionsFolder))
                Directory.CreateDirectory(RegionsFolder);

            rProperties = new Properties(RegionsFolder + Path.DirectorySeparatorChar + "regions.properties");
            rProperties.Load();

            rProperties.AddHeaderLine("Use 'rectify=false' to ignore world alterations from");
            rProperties.AddHeaderLine("players who are blocked; Possibly saving bandwidth.");

            rProperties.pushData();
            rProperties.Save(false);

            if (rProperties.RectifyChanges)
                WorldAlter = HookResult.RECTIFY;

            SelectorItem = rProperties.SelectionToolID;
            #region set up mysql properties

            string pluginFolder = Statics.PluginPath + Path.DirectorySeparatorChar + "mysql";
            if (!Directory.Exists(pluginFolder))
            {
                Directory.CreateDirectory(pluginFolder);
            }

            mysql = new PropertiesFile(pluginFolder + Path.DirectorySeparatorChar + "mysql.properties");
            mysql.Load();
            var dummy1 = mysqlenabled;
            var dummy2 = mysqlserver;
            var dummy3 = mysqldatabase;
            var dummy4 = mysqluser;
            var dummy5 = mysqlpassword;
            var dummy6 = imported;
            mysql.Save(false);

            #endregion

            #region check if mysql table exists
            if (mysqlenabled)
            {
                try
                {
                    checkTable(connectionString, "terraria_regions");
                }
                catch (MySqlException e)
                {
                    if (e.Number == 1042)
                    {
                        ProgramLog.Error.Log("[Regions] Could not connect to mysql server. Falling back to using regions files");
                        mysql.setValue("mysql-enabled", "False");
                        mysql.Save();
                    }
                    else
                    {
                        ProgramLog.Error.Log("[Regions] MYSQL ERROR CODE: " + e.Number);
                        ProgramLog.Error.Log(e.StackTrace);
                    }
                }
            }
            #endregion

            regionManager = new RegionManager(DataFolder);
            selection = new Selection();

            commands = new Commands();
            commands.regionManager = regionManager;
            commands.RegionsPlugin = this;
            commands.selection = selection;

            commands.Node_Create        = Node.FromPath("region.create");
            commands.Node_Here          = Node.FromPath("region.here");
            commands.Node_List          = Node.FromPath("region.list");
            commands.Node_Npcres        = Node.FromPath("region.npcres");
            commands.Node_Opres         = Node.FromPath("region.opres");
            commands.Node_Projectile    = Node.FromPath("region.projectile");
            commands.Node_ProtectAll    = Node.FromPath("region.protectall");
            commands.Node_Select        = Node.FromPath("region.select");
            commands.Node_User          = Node.FromPath("region.user");

            AddCommand("region")
                .WithAccessLevel(AccessLevel.OP)
                .WithHelpText("Usage:    region [select, create, user, list, npcres, opres]")
                .WithDescription("Region Management.")
                .WithPermissionNode("regions")
                .Calls(commands.Region);

            AddCommand("regions")
                .WithAccessLevel(AccessLevel.OP)
                .WithHelpText("Usage:    regions [select, create, user, list, npcres, opres]")
                .WithDescription("Region Management.")
                .WithPermissionNode("regions") //Need another method to split the commands up.
                .Calls(commands.Region);

            ChestBreak      = AddAndCreateNode("region.chestbreak");
            ChestOpen       = AddAndCreateNode("region.chestopen");
            DoorChange      = AddAndCreateNode("region.doorchange");
            LiquidFlow      = AddAndCreateNode("region.liquidflow");
            ProjectileUse   = AddAndCreateNode("region.projectileuse");
            SignEdit        = AddAndCreateNode("region.signedit");
            TileBreak       = AddAndCreateNode("region.tilebreak");
            TilePlace       = AddAndCreateNode("region.tileplace");
        }
Esempio n. 43
0
        public void CanRemoveRegion()
        {
            var regionManager = new RegionManager();
            IRegion region = new MockRegion();
            regionManager.Regions.Add("TestRegion", region);

            regionManager.Regions.Remove("TestRegion");

            Assert.IsFalse(regionManager.Regions.ContainsKey("TestRegion"));
        }
Esempio n. 44
0
        /// <summary>
        /// Run the bootstrapper process.
        /// </summary>
        /// <param name="runWithDefaultConfiguration">If <see langword="true"/>, registers default Prism Library services in the container. This is the default behavior.</param>
        public override void Run(bool runWithDefaultConfiguration)
        {
            _useDefaultConfiguration = runWithDefaultConfiguration;

            Logger = CreateLogger();
            if (Logger == null)
            {
                throw new InvalidOperationException(Resources.NullLoggerFacadeException);
            }

            Logger.Log(Resources.LoggerCreatedSuccessfully, Category.Debug, Priority.Low);

            Logger.Log(Resources.CreatingModuleCatalog, Category.Debug, Priority.Low);
            ModuleCatalog = CreateModuleCatalog();
            if (ModuleCatalog == null)
            {
                throw new InvalidOperationException(Resources.NullModuleCatalogException);
            }

            Logger.Log(Resources.ConfiguringModuleCatalog, Category.Debug, Priority.Low);
            ConfigureModuleCatalog();

            Logger.Log(Resources.CreatingAutofacContainerBuilder, Category.Debug, Priority.Low);
            ContainerBuilder builder = CreateContainerBuilder();

            if (builder == null)
            {
                throw new InvalidOperationException(Resources.NullAutofacContainerBuilderException);
            }

            _containerExtension = CreateContainerExtension();

            Logger.Log(Resources.ConfiguringAutofacContainerBuilder, Category.Debug, Priority.Low);
            // Make sure any not specifically registered concrete type can resolve.
            builder.RegisterSource(new AnyConcreteTypeNotAlreadyRegisteredSource());
            ConfigureContainerBuilder(builder);

            Logger.Log(Resources.CreatingAutofacContainer, Category.Debug, Priority.Low);
            Container = CreateContainer(builder);
            if (Container == null)
            {
                throw new InvalidOperationException(Resources.NullAutofacContainerException);
            }

            Logger.Log(Resources.ConfiguringServiceLocatorSingleton, Category.Debug, Priority.Low);
            ConfigureServiceLocator();

            Logger.Log(Resources.ConfiguringViewModelLocator, Category.Debug, Priority.Low);
            ConfigureViewModelLocator();

            Logger.Log(Resources.ConfiguringRegionAdapters, Category.Debug, Priority.Low);
            ConfigureRegionAdapterMappings();

            Logger.Log(Resources.ConfiguringDefaultRegionBehaviors, Category.Debug, Priority.Low);
            ConfigureDefaultRegionBehaviors();

            Logger.Log(Resources.RegisteringFrameworkExceptionTypes, Category.Debug, Priority.Low);
            RegisterFrameworkExceptionTypes();

            Logger.Log(Resources.CreatingShell, Category.Debug, Priority.Low);
            Shell = CreateShell();
            if (Shell != null)
            {
                Logger.Log(Resources.SettingTheRegionManager, Category.Debug, Priority.Low);
                RegionManager.SetRegionManager(Shell, Container.Resolve <IRegionManager>());

                Logger.Log(Resources.UpdatingRegions, Category.Debug, Priority.Low);
                RegionManager.UpdateRegions();

                Logger.Log(Resources.InitializingShell, Category.Debug, Priority.Low);
                InitializeShell();
            }

            if (Container.IsRegistered <IModuleManager>())
            {
                Logger.Log(Resources.InitializingModules, Category.Debug, Priority.Low);
                InitializeModules();
            }

            Logger.Log(Resources.BootstrapperSequenceCompleted, Category.Debug, Priority.Low);
        }
Esempio n. 45
0
        public void RegionGetsRemovedFromRegionManagerWhenRemovedFromScope()
        {
            var mappings = new RegionAdapterMappings();
            mappings.RegisterMapping(typeof(DependencyObject), new MockRegionAdapter());

            RegionManager regionManager = new RegionManager(mappings);
            var regionScopeControl = new ContentControl();
            RegionManager.SetRegionManager(regionScopeControl, regionManager);
            var control = new ItemsControl();
            control.SetValue(RegionManager.RegionNameProperty, "TestRegion");
            regionScopeControl.Content = control;
            Assert.IsTrue(regionManager.Regions.ContainsKey("TestRegion"));

            regionScopeControl.Content = null;

            Assert.IsFalse(regionManager.Regions.ContainsKey("TestRegion"));
        }
Esempio n. 46
0
 public SyutsouModule(RegionManager regionManager)
 {
     _regionManager = regionManager;
 }
Esempio n. 47
0
 public void ShouldFailIfRegionDoesntExists()
 {
     RegionManager regionManager = new RegionManager();
     IRegion region = regionManager.Regions["nonExistentRegion"];
 }
 private void InitializeDrawerRegion()
 {
     RegionManager.SetRegionName(DrawerContent, "DrawerContent");
     RegionManager.SetRegionManager(DrawerContent, regionManager);
 }
Esempio n. 49
0
 public void AddingMultipleRegionsWithSameNameThrowsArgumentException()
 {
     var regionManager = new RegionManager();
     regionManager.Regions.Add("region name", new MockRegion());
     regionManager.Regions.Add("region name", new MockRegion());
 }
 private void ExecuteNavigateToSettings()
 {
     RegionManager.RequestNavigate(AppRegions.ViewRegion, typeof(SettingsView).FullName);
 }
Esempio n. 51
0
 public void CreateRegionManagerCreatesANewInstance()
 {
     var regionManager = new RegionManager();
     var createdRegionManager = regionManager.CreateRegionManager();
     Assert.IsNotNull(createdRegionManager);
     Assert.IsInstanceOfType(createdRegionManager, typeof(RegionManager));
     Assert.AreNotSame(regionManager, createdRegionManager);
 }
 private void ExecuteNavigateToHome()
 {
     RegionManager.RequestNavigate(AppRegions.ViewRegion, typeof(StationsView).FullName);
 }
Esempio n. 53
0
        private void OpenDimension(int dim)
        {
            string path = Path;
            if (dim == Dimension.DEFAULT) {
                path = IO.Path.Combine(path, _REGION_DIR);
            }
            else {
                path = IO.Path.Combine(path, "DIM" + dim);
                path = IO.Path.Combine(path, _REGION_DIR);
            }

            if (!Directory.Exists(path)) {
                Directory.CreateDirectory(path);
            }

            ChunkCache cc = new ChunkCache();

            RegionManager rm = new RegionManager(path, cc);
            BetaChunkManager cm = new BetaChunkManager(rm, cc);
            BlockManager bm = new BlockManager(cm);

            _regionMgrs[dim] = rm;
            _chunkMgrs[dim] = cm;
            _blockMgrs[dim] = bm;
        }
Esempio n. 54
0
 private void ExecuteDetailsCommand()
 {
     RegionManager.RequestNavigate("MainRegion", $"{PageTokens.PRODUCT_DETAILS_WINDOW}?parameter={Id}");
 }
Esempio n. 55
0
 protected virtual void LogoutEvent(object o)
 {
     ChatConnection.Disconnect();
     RegionManager.RequestNavigate(Shell.MainRegion,
                                   new Uri(CharacterSelectViewModel.CharacterSelectViewName, UriKind.Relative));
 }
Esempio n. 56
0
 public AGV_Control_Center_HomeViewModel(RegionManager regionManager, EventAggregator eventAggregator)
 {
     _eventAggregator = eventAggregator;
     _regionManager   = regionManager;
 }
        protected override void Initialized(object state)
        {
            if (!Directory.Exists(RegionsFolder))
                Directory.CreateDirectory(RegionsFolder);

            rProperties = new Properties(RegionsFolder + Path.DirectorySeparatorChar + "regions.properties");
            rProperties.Load();

            rProperties.AddHeaderLine("Use 'rectify=false' to ignore world alterations from");
            rProperties.AddHeaderLine("players who are blocked; Possibly saving bandwidth.");

            rProperties.pushData();
            rProperties.Save(false);

            if (rProperties.RectifyChanges)
                WorldAlter = HookResult.RECTIFY;

            SelectorItem = rProperties.SelectionToolID;

            regionManager = new RegionManager(DataFolder);

            selection = new Selection();

            commands = new Commands();
            commands.regionManager = regionManager;
            commands.RegionsPlugin = this;
            commands.selection = selection;

            commands.Node_Create        = Node.FromPath("region.create");
            commands.Node_Here          = Node.FromPath("region.here");
            commands.Node_List          = Node.FromPath("region.list");
            commands.Node_Npcres        = Node.FromPath("region.npcres");
            commands.Node_Opres         = Node.FromPath("region.opres");
            commands.Node_Projectile    = Node.FromPath("region.projectile");
            commands.Node_ProtectAll    = Node.FromPath("region.protectall");
            commands.Node_Select        = Node.FromPath("region.select");
            commands.Node_User          = Node.FromPath("region.user");

            AddCommand("region")
                .WithAccessLevel(AccessLevel.OP)
                .WithHelpText("Usage:    region [select, create, user, list, npcres, opres]")
                .WithDescription("Region Management.")
                .WithPermissionNode("regions")
                .Calls(commands.Region);

            AddCommand("regions")
                .WithAccessLevel(AccessLevel.OP)
                .WithHelpText("Usage:    regions [select, create, user, list, npcres, opres]")
                .WithDescription("Region Management.")
                .WithPermissionNode("regions") //Need another method to split the commands up.
                .Calls(commands.Region);

            ChestBreak      = AddAndCreateNode("region.chestbreak");
            ChestOpen       = AddAndCreateNode("region.chestopen");
            DoorChange      = AddAndCreateNode("region.doorchange");
            LiquidFlow      = AddAndCreateNode("region.liquidflow");
            ProjectileUse   = AddAndCreateNode("region.projectileuse");
            SignEdit        = AddAndCreateNode("region.signedit");
            TileBreak       = AddAndCreateNode("region.tilebreak");
            TilePlace       = AddAndCreateNode("region.tileplace");
        }
 public ModuleUsersModule(RegionManager regionManager)
 {
     _regionManager = regionManager;
 }
Esempio n. 59
0
        void OnInitialize()
        {
            TShockAPI.Commands.ChatCommands.Add(new Command("worldedit", All, "/all"));
            TShockAPI.Commands.ChatCommands.Add(new Command("worldedit", Biome, "/biome"));
            TShockAPI.Commands.ChatCommands.Add(new Command("butcher", ButcherNear, "/butchernear"));
            TShockAPI.Commands.ChatCommands.Add(new Command("worldedit", ClearClipboard, "/clearclipboard"));
            TShockAPI.Commands.ChatCommands.Add(new Command("worldedit", ClearHistory, "/clearhistory"));
            TShockAPI.Commands.ChatCommands.Add(new Command("worldedit", Contract, "/contract"));
            TShockAPI.Commands.ChatCommands.Add(new Command("worldedit", Copy, "/copy"));
            TShockAPI.Commands.ChatCommands.Add(new Command("worldedit", Cut, "/cut"));
            TShockAPI.Commands.ChatCommands.Add(new Command("worldedit", Drain, "/drain"));
            TShockAPI.Commands.ChatCommands.Add(new Command("worldedit", Expand, "/expand"));
            TShockAPI.Commands.ChatCommands.Add(new Command("worldedit", FixGrass, "/fixgrass"));
            TShockAPI.Commands.ChatCommands.Add(new Command("worldedit", Flip, "/flip"));
            TShockAPI.Commands.ChatCommands.Add(new Command("worldedit", Flood, "/flood"));
            TShockAPI.Commands.ChatCommands.Add(new Command("worldedit", Inset, "/inset"));
            TShockAPI.Commands.ChatCommands.Add(new Command("worldedit", Outset, "/outset"));
            TShockAPI.Commands.ChatCommands.Add(new Command("worldedit", Paste, "/paste"));
            TShockAPI.Commands.ChatCommands.Add(new Command("worldedit", PointCmd, "/point"));
            TShockAPI.Commands.ChatCommands.Add(new Command("worldedit", Redo, "/redo"));
            TShockAPI.Commands.ChatCommands.Add(new Command("worldedit", Region, "/region"));
            TShockAPI.Commands.ChatCommands.Add(new Command("worldedit", Replace, "/replace"));
            TShockAPI.Commands.ChatCommands.Add(new Command("worldedit", ReplaceWall, "/replacewall"));
            TShockAPI.Commands.ChatCommands.Add(new Command("worldedit", Rotate, "/rotate"));
            TShockAPI.Commands.ChatCommands.Add(new Command("worldedit", Schematic, "/schematic", "/schem"));
            TShockAPI.Commands.ChatCommands.Add(new Command("worldedit", Select, "/select"));
            TShockAPI.Commands.ChatCommands.Add(new Command("worldedit", Set, "/set"));
            TShockAPI.Commands.ChatCommands.Add(new Command("worldedit", SetWall, "/setwall"));
            TShockAPI.Commands.ChatCommands.Add(new Command("worldedit", Shift, "/shift"));
            TShockAPI.Commands.ChatCommands.Add(new Command("worldedit", Size, "/size"));
            TShockAPI.Commands.ChatCommands.Add(new Command("worldedit", Undo, "/undo"));
            regionManager = TShock.Regions;
            #region Biomes
            // 255 => remove
            byte[] Corruption = { 0, 25, 112, 23, 24, 255, 32 };
            byte[] Hallow = { 0, 117, 116, 109, 110, 113, 255 };
            byte[] Jungle = { 59, 1, 53, 60, 61, 74, 69 };
            byte[] Mushroom = { 59, 1, 53, 70, 71, 255, 255 };
            byte[] Normal = { 0, 1, 53, 2, 3, 73, 255 };
            BiomeConversions.Add(Corruption);
            BiomeConversions.Add(Hallow);
            BiomeConversions.Add(Jungle);
            BiomeConversions.Add(Mushroom);
            BiomeConversions.Add(Normal);
            BiomeNames.Add("corruption");
            BiomeNames.Add("hallow");
            BiomeNames.Add("jungle");
            BiomeNames.Add("mushroom");
            BiomeNames.Add("normal");
            #endregion
            #region Invalid Tiles
            InvalidTiles.Add(33);
            InvalidTiles.Add(49);
            InvalidTiles.Add(78);
            #endregion
            #region Selections
            Selections.Add((i, j, plr) => ((i + j) & 1) == 0);
            Selections.Add((i, j, plr) => ((i + j) & 1) == 1);
            Selections.Add((i, j, plr) =>
            {
                PlayerInfo info = Players[plr];

                int X = Math.Min(info.x, info.x2);
                int Y = Math.Min(info.y, info.y2);
                int X2 = Math.Max(info.x, info.x2);
                int Y2 = Math.Max(info.y, info.y2);

                Vector2 center = new Vector2((float)(X2 - X) / 2, (float)(Y2 - Y) / 2);
                float major = Math.Max(center.X, center.Y);
                float minor = Math.Min(center.X, center.Y);
                if (center.Y > center.X)
                {
                    float temp = major;
                    major = minor;
                    minor = temp;
                }
                return (i - center.X - X) * (i - center.X - X) / (major * major) + (j - center.Y - Y) * (j - center.Y - Y) / (minor * minor) <= 1;
            });
            Selections.Add((i, j, plr) => true);
            Selections.Add((i, j, plr) =>
            {
                return i == Players[plr].x || i == Players[plr].x2 || j == Players[plr].y || j == Players[plr].y2;
            });
            SelectionNames.Add("altcheckers");
            SelectionNames.Add("checkers");
            SelectionNames.Add("ellipse");
            SelectionNames.Add("normal");
            SelectionNames.Add("outline");
            #endregion
            #region Tile Names
            TileNames.Add("dirt", 0);
            TileNames.Add("stone", 1);
            TileNames.Add("grass", 2);
            TileNames.Add("iron", 6);
            TileNames.Add("copper", 7);
            TileNames.Add("gold", 8);
            TileNames.Add("silver", 9);
            TileNames.Add("platform", 19);
            TileNames.Add("demonite", 22);
            TileNames.Add("corrupt grass", 23);
            TileNames.Add("ebonstone", 25);
            TileNames.Add("wood", 30);
            TileNames.Add("meteorite", 37);
            TileNames.Add("gray brick", 38);
            TileNames.Add("red brick", 39);
            TileNames.Add("clay", 40);
            TileNames.Add("blue brick", 41);
            TileNames.Add("green brick", 43);
            TileNames.Add("pink brick", 44);
            TileNames.Add("gold brick", 45);
            TileNames.Add("silver brick", 46);
            TileNames.Add("copper brick", 47);
            TileNames.Add("spike", 48);
            TileNames.Add("cobweb", 51);
            TileNames.Add("sand", 53);
            TileNames.Add("glass", 54);
            TileNames.Add("obsidian", 56);
            TileNames.Add("ash", 57);
            TileNames.Add("hellstone", 58);
            TileNames.Add("mud", 59);
            TileNames.Add("jungle grass", 60);
            TileNames.Add("sapphire", 63);
            TileNames.Add("ruby", 64);
            TileNames.Add("emerald", 65);
            TileNames.Add("topaz", 66);
            TileNames.Add("amethyst", 67);
            TileNames.Add("diamond", 68);
            TileNames.Add("mushroom grass", 70);
            TileNames.Add("obsidian brick", 75);
            TileNames.Add("hellstone brick", 76);
            TileNames.Add("cobalt", 107);
            TileNames.Add("mythril", 108);
            TileNames.Add("hallowed grass", 109);
            TileNames.Add("adamantite", 111);
            TileNames.Add("ebonsand", 112);
            TileNames.Add("pearlsand", 116);
            TileNames.Add("pearlstone", 117);
            TileNames.Add("pearlstone brick", 118);
            TileNames.Add("iridescent brick", 119);
            TileNames.Add("mudstone block", 120);
            TileNames.Add("cobalt brick", 121);
            TileNames.Add("mythril brick", 122);
            TileNames.Add("silt", 123);
            TileNames.Add("wooden beam", 124);
            TileNames.Add("ice", 127);
            TileNames.Add("active stone", 130);
            TileNames.Add("inactive stone", 131);
            TileNames.Add("demonite brick", 140);
            TileNames.Add("candy cane", 145);
            TileNames.Add("green candy cane", 146);
            TileNames.Add("snow", 147);
            TileNames.Add("snow brick", 148);
            // These are not actually correct, but are for ease of usage.
            TileNames.Add("air", 149);
            TileNames.Add("lava", 150);
            TileNames.Add("water", 151);
            TileNames.Add("wire", 152);
            #endregion
            #region Wall Names
            WallNames.Add("air", 0);
            WallNames.Add("stone", 1);
            WallNames.Add("ebonstone", 3);
            WallNames.Add("wood", 4);
            WallNames.Add("gray brick", 5);
            WallNames.Add("red brick", 6);
            WallNames.Add("gold brick", 10);
            WallNames.Add("silver brick", 11);
            WallNames.Add("copper brick", 12);
            WallNames.Add("hellstone brick", 13);
            WallNames.Add("mud", 15);
            WallNames.Add("dirt", 16);
            WallNames.Add("blue brick", 17);
            WallNames.Add("green brick", 18);
            WallNames.Add("pink brick", 19);
            WallNames.Add("obsidian brick", 20);
            WallNames.Add("glass", 21);
            WallNames.Add("pearlstone brick", 22);
            WallNames.Add("iridescent brick", 23);
            WallNames.Add("mudstone brick", 24);
            WallNames.Add("cobalt brick", 25);
            WallNames.Add("mythril brick", 26);
            WallNames.Add("planked", 27);
            WallNames.Add("pearlstone", 28);
            WallNames.Add("candy cane", 29);
            WallNames.Add("green candy cane", 30);
            WallNames.Add("snow brick", 31);
            #endregion
            CommandQueueThread = new Thread(QueueCallback);
            CommandQueueThread.Name = "WorldEdit Callback";
            CommandQueueThread.Start();
            Directory.CreateDirectory("worldedit");
        }
Esempio n. 60
0
 public MapTestModule(RegionManager regionManager)
 {
     _regionManager = regionManager;
 }