コード例 #1
0
        public CommandResponse Execute(GameState game, string[] args)
        {
            var updatedRegions = new Regions();

            // Update visible regions
            for (int i = 0; i < args.Length; i += 3)
            {
                int regionId = int.Parse(args[i]);
                int armies = int.Parse(args[i + 2]);
                string ownerId = args[i + 1];

                Region region = game.Map.Regions[regionId];

                region.Armies = armies;
                region.IsVisible = true;

                if (ownerId == "neutral")
                    region.Owner = null;
                else
                    region.Owner = ownerId == game.Bot.BotPlayer.Id ? game.Bot.BotPlayer : game.Opponents[args[i + 1]];

                updatedRegions.Add(region);
            }

            // Mark invisible regions as such.  Leave the previous info in place for now.
            game.Map.Regions.Except(updatedRegions).ToList().ForEach(r =>
            {
                r.IsVisible = false;
            });

            return new CommandResponse(CommandAction.None);
        }
コード例 #2
0
        public CommandResponse Execute(GameState game, string[] args)
        {
            var availableOptions = new Regions();

            for (int i = 1; i < args.Length; i++)
                availableOptions.Add(game.Map.Regions[int.Parse(args[i])]);

            Regions selectedRegions = game.Bot.PickStartingRegions(game.Map, availableOptions);

            return new CommandResponse(CommandAction.SendData,
                string.Join(" ", selectedRegions.Select(r => r.Id.ToString())));
        }
コード例 #3
0
ファイル: Map.cs プロジェクト: StepanoidTeam/PowerGridApi
 public Map AddRegion(Region region)
 {
     if (!Regions.ContainsKey(region.Id))
     {
         foreach (var city in region.Cities)
         {
             if (Cities.ContainsKey(city.Key))
             {
                 throw new Exception("Found city duplicates on the map");
             }
         }
         //region.MapRef = this;
         Regions.Add(region.Id, region);
     }
     return(this);
 }
コード例 #4
0
ファイル: CwaNoteBlank.cs プロジェクト: KrystofKolar/Cas
        public virtual void LoadContent(CwaScreensManager ScreensManager)
        {
            _sm = ScreensManager;

            LoadContentTextures();

            Result = new RenderTarget2D(_sm.GraphicsDevice, _Background.Width, _Background.Height);

            _posCreate = Vector2.Zero;
            _rCreate   = new Boundary(_posCreate, _ButtonCreate.Width, _ButtonCreate.Height);

            _Regions = new Regions <casId>();
            _Regions.Add(casId.markDetailEmpty_Create, _rCreate);

            _update = true;
        }
コード例 #5
0
        private static void FillRegions()
        {
            var cultureInfo = CultureInfo.GetCultures(CultureTypes.SpecificCultures);

            foreach (var ci in cultureInfo)
            {
                try
                {
                    var regionInfo = new RegionInfo(ci.LCID);
                    Regions.Add(regionInfo);
                }
                catch
                {
                    continue;
                }
            }
        }
コード例 #6
0
        private void ReadSingleRegion(IDataRecord record)
        {
            var aoGuid  = record.GetGuid(0);
            var code    = record.GetInt32(1);
            var offName = record.GetString(2);
            var prefix  = record.GetString(3);

            var region = new Region
            {
                Id     = code,
                Name   = offName,
                Prefix = $"{prefix}.",
                Guid   = aoGuid
            };

            Regions.Add(region);
        }
コード例 #7
0
        public void NewItemClicked(ButtonClickArgs e)
        {
            var title   = $"{e.Action} {e.ItemDescriptor}";
            var message = $"{e.Action} {e.ItemDescriptor}: ";

            var results = CrudDialogProvider.Show(new NestedViewModel <RegionViewModel>(title, message, new RegionViewModel(), DialogButtons.OkCancel));

            if (results.DialogResult != DialogResults.Ok)
            {
                return;
            }

            var newRegion = _regionController.Create(SelectedPreset.Id, results.InnerResults.Name);

            Regions.Add(newRegion);
            SelectedRegion = newRegion;
        }
コード例 #8
0
        /// <summary>
        /// Add a new region to the collection.
        /// </summary>
        /// <param name="newRegion">The region to be added.</param>
        public static void AddRegion(RatingRegion newRegion)
        {
            foreach (RatingRegion oldRegion in Regions)
            {
                if (oldRegion.Region == newRegion.Region)
                {
                    return;
                }

                if (oldRegion.Region > newRegion.Region)
                {
                    Regions.Insert(Regions.IndexOf(oldRegion), newRegion);
                    return;
                }
            }

            Regions.Add(newRegion);
        }
コード例 #9
0
        /// <summary>
        /// Specifies an AWS region to use.
        /// </summary>
        /// <param name="accountId">The AWS region to use.</param>
        /// <returns>
        /// The current <see cref="MessagingConfigurationBuilder"/>.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="accountId"/> is <see cref="null"/>.
        /// </exception>
        public MessagingConfigurationBuilder WithRegion(string region)
        {
            if (region == null)
            {
                throw new ArgumentNullException(nameof(region));
            }

            if (Regions == null)
            {
                Regions = new List <string>();
            }

            if (!Regions.Contains(region))
            {
                Regions.Add(region);
            }

            return(this);
        }
コード例 #10
0
 protected void AddRegion(string id, string typename, int start, int end, Sense sense)
 {
     try{
         if (typename.Equals("gene"))
         {
             Gene g = new Gene(id, typename, start, end, sense);
             Genes.Add(id, g);
         }
         else
         {
             Region r = new Region(id, typename, start, end, sense);
             Regions.Add(id, r);
         }
     }
     catch (Exception e) {
         MainData.ShowMessageWindow("Your Gff3 IDs are not consistent!\n " +
                                    "Change Gff3 loader options to fix them!\n Error: " + e.Message + "\n Offending id:" + id, true);
     }
 }
コード例 #11
0
ファイル: SudokuPuzzle.cs プロジェクト: Corniel/Sudoku
        /// <summary>Initializes all sub square regions.</summary>
        private void InitializeSubSquareRegions(int size)
        {
            for (var xSub = 0; xSub < size; xSub++)
            {
                for (var ySub = 0; ySub < size; ySub++)
                {
                    var region = new SudokuRegion(SudokuRegionType.Block);
                    Regions.Add(region);

                    for (var x = 0; x < size; x++)
                    {
                        for (var y = 0; y < size; y++)
                        {
                            region.Add(Grid[xSub * size + x, ySub * size + y]);
                        }
                    }
                }
            }
        }
コード例 #12
0
        private void ReadSingleRegion(IDataRecord record)
        {
            var aoguid  = record.GetGuid(0);
            var code    = record.GetString(1);
            var id      = int.Parse(code);
            var offname = record.GetString(2);
            var prefix  = record.GetString(3);

            var nRegion = new Region
            {
                Id     = id,
                Name   = offname,
                Slug   = _trans.Transliterate(offname).GetWebSafe(),
                Prefix = $"{prefix}.",
                Guid   = aoguid
            };

            Regions.Add(nRegion);
        }
コード例 #13
0
ファイル: Parser.cs プロジェクト: Bolukan/BollieAI2
        /// <summary>
        /// Starting regions to be chosen from are given, one region id is to be returned by your bot
        /// </summary>
        /// <param name="parts"></param>
        public void PickStartingRegion(String[] parts)
        {
            Map.Current.CurrentTimebank = int.Parse(parts[1]);

            // read possible regions
            Regions pickRegions = new Regions();

            for (int i = 2; i < parts.Length; i++)
            {
                Region pickRegion = Map.Current.Regions.Find(region => region.Id == int.Parse(parts[i]));
                pickRegions.Add(pickRegion);
            }

            // choose region
            Region iWantThisRegion = BollieAI2.Services.StartingRegions.PickFromRegions(pickRegions);

            // tell server
            Console.WriteLine("{0}", iWantThisRegion.Id);
        }
コード例 #14
0
        public void Setup()
        {
            _mockMap        = new Mock <IMap>();
            _mockWrite      = new Mock <IOutputWrite>();
            _mockSector     = new Mock <ISector>();
            _mockSettings   = new Mock <IStarTrekKGSettings>();
            _mockCoordinate = new Mock <ICoordinate>();
            _mockMap.Setup(m => m.Regions).Returns(new Regions(_mockMap.Object, _mockWrite.Object));

            var Regions = new Regions(_mockMap.Object, _mockWrite.Object);

            Regions.Add(new Region(new Coordinate()));

            _mockMap.Setup(m => m.Regions).Returns(Regions);
            _mockMap.Setup(m => m.Write).Returns(_mockWrite.Object);
            _mockSector.Setup(c => c.RegionDef).Returns(new Coordinate());

            _mockMap.Setup(m => m.Config).Returns(_mockSettings.Object);
        }
コード例 #15
0
        void AddRegion(Boct head, Guid?guid = null, int?regionId = null)
        {
            var region = new BoctRegion();

            region.GUID = guid ?? Guid.NewGuid();

            region.LUID = regionId ?? RegionIndex;

            BoctTools.FillRegionId(head, region.LUID);
            region.Head = head;

            Regions.Add(region.LUID, region);
            if (NewRegionIdList != null)
            {
                NewRegionIdList.Add(RegionIndex);
            }

            if (regionId == null)
            {
                RegionIndex++;
            }

            region.CurrentState.Subscribe(state =>
            {
                switch (state)
                {
                case BoctRegion.State.Ready:
                    break;

                case BoctRegion.State.Disposed:
                    Regions.Remove(region.LUID);
                    break;

                case BoctRegion.State.Dirty:
                    region.MaterialCounts = BoctMaterialTools.CountMaterials(region.Head, MaterialList.Materials);
                    break;
                }
            });

            // Call last time.
            RegionStream.OnNext(region);
        }
コード例 #16
0
        /// <summary>
        /// This method visits a KML Region element
        /// </summary>
        /// <param name="element">KML Region element to be visited</param>
        protected void VisitRegion(XmlElement element)
        {
            if (element == null)
            {
                return;
            }

            var r = new Region();

            VisitGeography(element, r);

            var latLonAltBoxElem = GetFirstChild(element, "LatLonAltBox");
            var latLonBoxElem    = GetFirstChild(element, "LatLonBox");
            var latLonQuadElem   = GetFirstChild(element, "gx:LatLonQuad");

            var numOfGeographiesBefore = Geographies.Count;

            if (latLonAltBoxElem != null)
            {
                VisitLatLonAltBox(latLonAltBoxElem);
            }
            else if (latLonBoxElem != null)
            {
                VisitLatLonBox(latLonBoxElem);
            }
            else if (latLonQuadElem != null)
            {
                VisitLatLonQuad(latLonQuadElem);
            }

            var numOfGeographiesAfter = Geographies.Count;

            if (numOfGeographiesAfter > numOfGeographiesBefore)
            {
                // Found region's box

                r.Box = Geographies[Geographies.Count - 1];
                Geographies.RemoveAt(Geographies.Count - 1);
            }

            Regions.Add(r);
        }
コード例 #17
0
ファイル: World.cs プロジェクト: seaboy1234/Craft.Net
 private Region CreateOrLoadRegion(Vector3 position)
 {
     lock (Regions)
     {
         if (!Regions.ContainsKey(position))
         {
             if (Directory == null)
             {
                 Regions.Add(position, new Region(position, this));
             }
             else
             {
                 Regions.Add(position,
                             new Region(position, this,
                                        Path.Combine(Directory, Region.GetRegionFileName(position))));
             }
         }
         return(Regions[position]);
     }
 }
コード例 #18
0
        public void add(string nameTown, int idTown, string nameDepartament, int idDept, int cantPeople, string covid, int cantConfirm, string region, double latitud, double longitud)
        {
            Region region1 = null;

            for (int i = 0; i < size; i++)
            {
                if (Regions.ElementAt(i).name.Equals(region))
                {
                    region1 = Regions.ElementAt(i);
                    break;
                }
            }
            if (region1 == null)
            {
                region1 = new Region(region);
                Regions.Add(region1);
                size++;
            }

            region1.add(nameTown, idTown, nameDepartament, idDept, cantPeople, covid, cantConfirm, latitud, longitud);
        }
コード例 #19
0
ファイル: RegionProvider.cs プロジェクト: lulzzz/DCAnalytics
        public Regions GetRegions(string questionaire_id)
        {
            Regions regions = new Regions();

            try
            {
                string query = $"select * from dsto_region where Deleted = 0 and yref_questionaire = '{ questionaire_id }'";
                var    table = DbInfo.ExecuteSelectQuery(query);
                if (table.Rows.Count > 0)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        Region region = regions.Add();
                        InitRegion(region, row);
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(regions);
        }
コード例 #20
0
 public void AddRegion(VehicleRegion region)
 {
     if (Regions.Contains(region))
     {
         Log.Error(string.Concat(new object[]
         {
             "Tried to add the same region twice to Room. region=",
             region,
             ", room=",
             this
         }));
         return;
     }
     Regions.Add(region);
     if (region.touchesMapEdge)
     {
         numRegionsTouchingMapEdge++;
     }
     if (Regions.Count == 1)
     {
         Map.GetCachedMapComponent <VehicleMapping>().VehicleRegionGrid.allRooms.Add(this);
     }
 }
コード例 #21
0
        public void Init(GameFileCache gameFileCache, Action <string> updateStatus)
        {
            var rpfman = gameFileCache.RpfMan;

            string filename = "common.rpf\\data\\levels\\gta5\\time.xml";

            XmlDocument timexml = rpfman.GetFileXml(filename);

            XmlElement  time     = timexml.DocumentElement;
            XmlNode     suninfo  = time.SelectSingleNode("suninfo");
            XmlNode     mooninfo = time.SelectSingleNode("mooninfo");
            XmlNodeList samples  = time.SelectNodes("sample");
            XmlNodeList regions  = time.SelectNodes("region");

            sun_roll           = Xml.GetFloatAttribute(suninfo, "sun_roll");
            sun_yaw            = Xml.GetFloatAttribute(suninfo, "sun_yaw");
            moon_roll          = Xml.GetFloatAttribute(mooninfo, "moon_roll");
            moon_wobble_freq   = Xml.GetFloatAttribute(mooninfo, "moon_wobble_freq");
            moon_wobble_amp    = Xml.GetFloatAttribute(mooninfo, "moon_wobble_amp");
            moon_wobble_offset = Xml.GetFloatAttribute(mooninfo, "moon_wobble_offset");

            Samples.Clear();
            for (int i = 0; i < samples.Count; i++)
            {
                TimecycleSample tcs = new TimecycleSample();
                tcs.Init(samples[i]);
                Samples.Add(tcs);
            }

            Regions.Clear();
            for (int i = 0; i < regions.Count; i++)
            {
                Regions.Add(Xml.GetStringAttribute(regions[i], "name"));
            }

            Inited = true;
        }
コード例 #22
0
ファイル: Wmap.cs プロジェクト: UniverseRealms/LOE-V6-SERVER
        public int Load(Stream stream, int idBase)
        {
            var ver = stream.ReadByte();

            if (ver < 0 || ver > 2)
            {
                throw new NotSupportedException("WMap version " + ver);
            }

            using (var rdr = new BinaryReader(new ZlibStream(stream, CompressionMode.Decompress)))
            {
                var dict = new List <WmapTile>();
                var c    = rdr.ReadInt16();
                for (var i = 0; i < c; i++)
                {
                    var tile = new WmapTile
                    {
                        TileId = rdr.ReadUInt16()
                    };
                    tile.TileDesc = data.Tiles[tile.TileId];
                    var obj = rdr.ReadString();
                    tile.ObjType = string.IsNullOrEmpty(obj) ? (ushort)0 : data.IdToObjectType[obj];
                    tile.Name    = rdr.ReadString();
                    tile.Terrain = (WmapTerrain)rdr.ReadByte();
                    tile.Region  = (TileRegion)rdr.ReadByte();
                    if (ver == 1)
                    {
                        tile.Elevation = rdr.ReadByte();
                    }
                    data.ObjectDescs.TryGetValue(tile.ObjType, out tile.ObjDesc);
                    dict.Add(tile);
                }

                Width         = rdr.ReadInt32();
                Height        = rdr.ReadInt32();
                tilesOriginal = new WmapTile[Width, Height];
                tiles         = new WmapTile[Width, Height];

                var enCount  = 0;
                var entities = new List <Tuple <IntPoint, ushort, string> >();
                for (var y = 0; y < Height; y++)
                {
                    for (var x = 0; x < Width; x++)
                    {
                        var tile = dict[rdr.ReadInt16()].Clone();
                        tile.UpdateCount = 1;
                        if (ver == 2)
                        {
                            tile.Elevation = rdr.ReadByte();
                        }

                        if (tile.Region != 0)
                        {
                            Regions.Add(new Tuple <IntPoint, TileRegion>(
                                            new IntPoint(x, y), tile.Region));
                        }

                        var desc = tile.ObjDesc;
                        if (tile.ObjType != 0 && (desc == null || !desc.Static || desc.Enemy))
                        {
                            entities.Add(new Tuple <IntPoint, ushort, string>(new IntPoint(x, y), tile.ObjType, tile.Name));
                            if (desc == null || !(desc.Enemy && desc.Static))
                            {
                                tile.ObjType = 0;
                            }
                        }

                        if (tile.ObjType != 0 && (desc == null || !(desc.Enemy && desc.Static)))
                        {
                            enCount++;
                            tile.ObjId = idBase + enCount;
                        }

                        tilesOriginal[x, y] = tile;
                        tiles[x, y]         = tile;
                    }
                }

                this.entities = entities.ToArray();
                return(enCount);
            }
        }
コード例 #23
0
        public render_model(CacheBase Cache, int Address)
        {
            cache = Cache;
            EndianReader Reader = Cache.Reader;

            Reader.SeekTo(Address);

            Name  = Cache.Strings.GetItemByID(Reader.ReadInt32());
            Flags = new Bitmask(Reader.ReadInt32());

            #region Regions Block
            Reader.SeekTo(Address + 12);
            int iCount  = Reader.ReadInt32();
            int iOffset = Reader.ReadInt32() - Cache.Magic;
            for (int i = 0; i < iCount; i++)
            {
                Regions.Add(new Region(Cache, iOffset + 16 * i));
            }
            #endregion

            Reader.SeekTo(Address + 28);
            InstancedGeometryIndex = Reader.ReadInt32();

            #region Instanced Geometry Block
            Reader.SeekTo(Address + 32);
            iCount  = Reader.ReadInt32();
            iOffset = Reader.ReadInt32() - Cache.Magic;
            for (int i = 0; i < iCount; i++)
            {
                GeomInstances.Add(new InstancedGeometry(Cache, iOffset + 60 * i));
            }
            #endregion

            #region Nodes Block
            Reader.SeekTo(Address + 48);
            iCount  = Reader.ReadInt32();
            iOffset = Reader.ReadInt32() - Cache.Magic;
            for (int i = 0; i < iCount; i++)
            {
                Nodes.Add(new Node(Cache, iOffset + 96 * i));
            }
            #endregion

            #region MarkerGroups Block
            Reader.SeekTo(Address + 60);
            iCount  = Reader.ReadInt32();
            iOffset = Reader.ReadInt32() - Cache.Magic;
            for (int i = 0; i < iCount; i++)
            {
                MarkerGroups.Add(new MarkerGroup(Cache, iOffset + 16 * i));
            }
            #endregion

            #region Shaders Block
            Reader.SeekTo(Address + 72);
            iCount  = Reader.ReadInt32();
            iOffset = Reader.ReadInt32() - Cache.Magic;
            for (int i = 0; i < iCount; i++)
            {
                Shaders.Add(new Shader(Cache, iOffset + 44 * i));
            }
            #endregion

            #region ModelSections Block
            Reader.SeekTo(Address + 104);
            iCount  = Reader.ReadInt32();
            iOffset = Reader.ReadInt32() - Cache.Magic;
            for (int i = 0; i < iCount; i++)
            {
                ModelSections.Add(new ModelSection(Cache, iOffset + 92 * i));
            }
            #endregion

            #region BoundingBox Block
            Reader.SeekTo(Address + 116);
            iCount  = Reader.ReadInt32();
            iOffset = Reader.ReadInt32() - Cache.Magic;
            for (int i = 0; i < iCount; i++)
            {
                BoundingBoxes.Add(new BoundingBox(Cache, iOffset + 52 * i));
            }
            #endregion

            #region NodeMapGroup Block
            Reader.SeekTo(Address + 176);
            iCount  = Reader.ReadInt32();
            iOffset = Reader.ReadInt32() - Cache.Magic;
            for (int i = 0; i < iCount; i++)
            {
                NodeIndexGroups.Add(new NodeIndexGroup(Cache, iOffset + 12 * i));
            }
            #endregion

            Reader.SeekTo(Address + 236);
            RawID = Reader.ReadInt32();
        }
コード例 #24
0
        public gbxmodel(CacheBase Cache, int Address)
        {
            cache = Cache;
            EndianReader Reader = Cache.Reader;

            Reader.SeekTo(Address);

            Name  = "gbxmodel";
            Flags = new Bitmask(Reader.ReadInt16());

            Reader.SeekTo(Address + 0x30);
            uScale = Reader.ReadSingle();
            vScale = Reader.ReadSingle();


            #region MarkerGroups Block
            Reader.SeekTo(Address + 0xAC);
            int iCount  = Reader.ReadInt32();
            int iOffset = Reader.ReadInt32() - Cache.Magic;
            for (int i = 0; i < iCount; i++)
            {
                MarkerGroups.Add(new MarkerGroup(Cache, iOffset + 64 * i));
            }
            #endregion

            #region Nodes Block
            Reader.SeekTo(Address + 0xB8);
            iCount  = Reader.ReadInt32();
            iOffset = Reader.ReadInt32() - Cache.Magic;
            for (int i = 0; i < iCount; i++)
            {
                Nodes.Add(new Node(Cache, iOffset + 156 * i));
            }
            #endregion

            #region Regions Block
            Reader.SeekTo(Address + 0xC4);
            iCount  = Reader.ReadInt32();
            iOffset = Reader.ReadInt32() - Cache.Magic;
            for (int i = 0; i < iCount; i++)
            {
                Regions.Add(new Region(Cache, iOffset + 76 * i));
            }
            #endregion

            #region ModelParts Block
            Reader.SeekTo(Address + 0xD0);
            iCount  = Reader.ReadInt32();
            iOffset = Reader.ReadInt32() - Cache.Magic;
            for (int i = 0; i < iCount; i++)
            {
                ModelSections.Add(new ModelSection(Cache, iOffset + 48 * i)
                {
                    FacesIndex = i, VertsIndex = i, NodeIndex = 255
                });
            }
            #endregion

            #region Shaders Block
            Reader.SeekTo(Address + 0xDC);
            iCount  = Reader.ReadInt32();
            iOffset = Reader.ReadInt32() - Cache.Magic;
            for (int i = 0; i < iCount; i++)
            {
                Shaders.Add(new Shader(Cache, iOffset + 32 * i));
            }
            #endregion

            #region BoundingBox Block
            BoundingBoxes.Add(new BoundingBox());
            #endregion
        }
コード例 #25
0
        // Summary:
        //     Load content, all textures are loaded here. For the note and the menu.
        //     clickregions are calculated
        //
        //     Values are not checked. Caller has to take care(performance, avoid double check)
        //
        // Parameters:
        //   gd:
        //     GraphicsDevice
        //   sb:
        //     Spritebatch
        //   cm:
        //     ContentManger
        //   texaNoteIsotexEmpty:
        //     default note
        //   texNoteAlpha:
        //     The alpha value for all Notes, the loaded textures and blank notes.
        //   texaNoteIsotexChecked:
        //     check texture on the note
        //   texaNoteIsotexUnChecked:
        //     uncheck texture on the note
        //   texMenu:
        //     note menu
        //   texMenu_ScenarioIter:
        //     note menu, button for scenario changes
        //   texMenu_DeleteNote:
        //     note menu, button for delete a note
        //   texMenu_CheckNote:
        //     note menu, button for check note
        //   texPin:
        //     note has an extra pin drawn above the note
        //   ptClickableCheckNote:
        //     note menu, clickable region to check a note
        //   ptClickableDeleteNote:
        //     note menu, clickable region to delete a note
        //   ptClickableScenarioIter:
        //     note menu, clickable region to change the scenario
        public virtual void LoadContent(GraphicsDevice gd,
                                        SpriteBatch sb,
                                        ContentManager cm,

                                        Texture2D[] texaNoteIsotexEmpty,
                                        Texture2D texNoteAlpha,

                                        Texture2D[] texaNoteIsotexChecked,
                                        Texture2D[] texaNoteIsotexUnChecked,

                                        Texture2D[] texMenu,
                                        Texture2D texMenu_ScenarioIter,
                                        Texture2D texMenu_DeleteNote,
                                        Texture2D texMenu_CheckNote,

                                        Texture2D texPin,

                                        Point ptClickableCheckNote,
                                        Point ptClickableDeleteNote,
                                        Point ptClickableScenarioIter)

        {
            _gd = gd;
            _sb = sb;
            _cm = cm;

            _texNoteIsotexEmpty = texaNoteIsotexEmpty;
            _texNoteAlpha       = texNoteAlpha;

            _texNoteIsotexChecked   = texaNoteIsotexChecked;
            _texNoteIsotexUnchecked = texaNoteIsotexUnChecked;

            _texMenu   = texMenu;
            _texScene  = texMenu_ScenarioIter;
            _texDelete = texMenu_DeleteNote;
            _texCheck  = texMenu_CheckNote;

            _texNotePin = texPin;

            FadeScene = new Fade(new Vector2(1F, 1F) * .52F,
                                 true,
                                 1,
                                 new Vector2(0F, 1F),
                                 false,
                                 Vector2.Zero,
                                 Vector2.Zero,
                                 false);

            _update                 = true;
            _updateMenu             = true;
            _updateCauseLoadPicture = false;

            _rCheck = new Boundary(ptClickableCheckNote, texMenu_CheckNote.Width, texMenu_CheckNote.Height);

            _rDelete = new Boundary(ptClickableDeleteNote, texMenu_DeleteNote.Width, texMenu_DeleteNote.Height);

            _rScene = new Boundary(ptClickableScenarioIter, texMenu_ScenarioIter.Width, texMenu_ScenarioIter.Height);

            MenuRegions = new Regions <casId>();

            MenuRegions.Add(casId.markDetail_Clickable_Delete, _rDelete);
            MenuRegions.Add(casId.markDetail_Clickable_IterScenario, _rScene);
            MenuRegions.Add(casId.markDetail_Clickable_Check, _rCheck);

            TexturesIsoLoaded = new Dictionary <DateTime, Texture2D>();

            rt = new RenderTarget2D(_gd,
                                    (int)(_texNoteIsotexEmpty[(int)casTextureVariant.Original].Width),
                                    (int)(_texNoteIsotexEmpty[(int)casTextureVariant.Original].Height));
        }
コード例 #26
0
ファイル: render_model.cs プロジェクト: XeCREATURE/TagTool
        public render_model(CacheBase Cache, int Address)
        {
            cache = Cache;
            EndianReader Reader = Cache.Reader;

            Reader.SeekTo(Address);

            Name = Cache.Strings.GetItemByID(Reader.ReadInt16());
            //Flags = new Bitmask(Reader.ReadInt32());

            #region BoundingBox Block
            Reader.SeekTo(Address + 20);
            int iCount  = Reader.ReadInt32();
            int iOffset = Reader.ReadInt32() - Cache.Magic;
            for (int i = 0; i < iCount; i++)
            {
                BoundingBoxes.Add(new BoundingBox(Cache, iOffset + 56 * i));
            }
            #endregion

            #region Regions Block
            Reader.SeekTo(Address + 28);
            iCount  = Reader.ReadInt32();
            iOffset = Reader.ReadInt32() - Cache.Magic;
            for (int i = 0; i < iCount; i++)
            {
                Regions.Add(new Region(Cache, iOffset + 16 * i));
            }
            #endregion

            #region ModelParts Block
            Reader.SeekTo(Address + 36);
            iCount  = Reader.ReadInt32();
            iOffset = Reader.ReadInt32() - Cache.Magic;
            for (int i = 0; i < iCount; i++)
            {
                ModelSections.Add(new ModelSection(Cache, iOffset + 92 * i)
                {
                    FacesIndex = i, VertsIndex = i, NodeIndex = 255
                });
            }
            Reader.SeekTo(Address + 72);
            #endregion

            #region Nodes Block
            iCount  = Reader.ReadInt32();
            iOffset = Reader.ReadInt32() - Cache.Magic;
            for (int i = 0; i < iCount; i++)
            {
                Nodes.Add(new Node(Cache, iOffset + 96 * i));
            }
            #endregion

            #region MarkerGroups Block
            Reader.SeekTo(Address + 88);
            iCount  = Reader.ReadInt32();
            iOffset = Reader.ReadInt32() - Cache.Magic;
            for (int i = 0; i < iCount; i++)
            {
                MarkerGroups.Add(new MarkerGroup(Cache, iOffset + 12 * i));
            }
            #endregion

            #region Shaders Block
            Reader.SeekTo(Address + 96);
            iCount  = Reader.ReadInt32();
            iOffset = Reader.ReadInt32() - Cache.Magic;
            for (int i = 0; i < iCount; i++)
            {
                Shaders.Add(new Shader(Cache, iOffset + 32 * i));
            }
            #endregion
        }
コード例 #27
0
ファイル: Templater.cs プロジェクト: angew74/GestionePEC
        /*/// <summary>
         * /// Process the Text template.
         * /// </summary>
         * private void ProcessTextTemplate(string content)
         * {
         *      ActiveUp.Net.Mail.Logger.AddEntry("Processing the TEXT template.", 1);
         *
         *      // Initialize strings to be used later
         *      string line = string.Empty, lineUpper = string.Empty;
         *
         *      // Initialize the StringReader to read line per line
         *      StringReader reader = new StringReader(content);
         *
         *      // Initialize the actual body count
         *      int bodyCount = _bodies.Count, lineNumber = 0;
         *
         *      // Read and parse each line. Append the data in the properties.
         *      while (reader.Peek() > -1)
         *      {
         *              ActiveUp.Net.Mail.Logger.AddEntry("Line parsed. Body count: + " + bodyCount.ToString() + ".", 0);
         *
         *              line = reader.ReadLine();
         *              lineNumber++;
         *              lineUpper = line.ToUpper();
         *
         *              // If a property, then set value
         *              if (lineUpper.StartsWith("TO:"))
         *              {
         *                      ActiveUp.Net.Mail.Logger.AddEntry("TO property found: + " + line + " (raw).", 0);
         *                      this.Message.To.Add(Parser.ParseAddress(ExtractValue(line)));
         *              }
         *              else if (lineUpper.StartsWith("BCC:"))
         *              {
         *                      ActiveUp.Net.Mail.Logger.AddEntry("BCC property found: + " + line + " (raw).", 0);
         *                      this.Message.Bcc.Add(Parser.ParseAddress(ExtractValue(line)));
         *              }
         *              else if (lineUpper.StartsWith("CC:"))
         *              {
         *                      ActiveUp.Net.Mail.Logger.AddEntry("CC property found: + " + line + " (raw).", 0);
         *                      this.Message.Cc.Add(Parser.ParseAddress(ExtractValue(line)));
         *              }
         *              else if (lineUpper.StartsWith("FROM:"))
         *              {
         *                      ActiveUp.Net.Mail.Logger.AddEntry("FROM property found: + " + line + " (raw).", 0);
         *                      this.Message.From = Parser.ParseAddress(ExtractValue(line));
         *              }
         *              else if (lineUpper.StartsWith("SUBJECT:"))
         *              {
         *                      ActiveUp.Net.Mail.Logger.AddEntry("SUBJECT property found: + " + line + " (raw).", 0);
         *                      this.Message.Subject += ExtractValue(line);
         *              }
         *              else if (lineUpper.StartsWith("SMTPSERVER:"))
         *              {
         *                      ActiveUp.Net.Mail.Logger.AddEntry("SMTPSERVER property found: + " + line + " (raw).", 0);
         *                      this.SmtpServers.Add(ExtractValue(line), 25);
         *              }
         *              else if (lineUpper.StartsWith("BODYTEXT:"))
         *              {
         *                      ActiveUp.Net.Mail.Logger.AddEntry("BODYTEXT property found: + " + line + " (raw).", 0);
         *                      this.Bodies.Add(ExtractValue(line), BodyFormat.Text);
         *                      bodyCount++;
         *              }
         *              else if (lineUpper.StartsWith("BODYHTML:"))
         *              {
         *                      ActiveUp.Net.Mail.Logger.AddEntry("BODYHTML property found: + " + line + " (raw).", 0);
         *                      this.Bodies.Add(ExtractValue(line), BodyFormat.Html);
         *                      bodyCount++;
         *              }
         *              else if (lineUpper.StartsWith("FIELDFORMAT:") && lineUpper.IndexOf("=") > -1)
         *              {
         *                      ActiveUp.Net.Mail.Logger.AddEntry("FIELDFORMAT property found: + " + line + " (raw).", 0);
         *                      this.FieldsFormats.Add(ExtractFormat(line));
         *              }
         *              else if (lineUpper.StartsWith("//"))
         *              {
         *                      ActiveUp.Net.Mail.Logger.AddEntry("COMMENT line found: + " + line + " (raw).", 0);
         *                      // Line is a comment, so do nothing
         *              }
         *                      // If not a property, then it's a message line
         *              else
         *              {
         *                      ActiveUp.Net.Mail.Logger.AddEntry("BODY line found: + " + line + " (raw).", 0);
         *                      this.Bodies[bodyCount-1].Content += line + "\r\n";
         *              }
         *      }
         * }*/

        /*/// <summary>
         * /// Extract the format options from a text template line.
         * /// </summary>
         * /// <param name="line">The text template line.</param>
         * /// <returns>A FieldFormat object with the options.</returns>
         * private FieldFormat ExtractFormat(string line)
         * {
         *      ActiveUp.Net.Mail.Logger.AddEntry("Extracting FieldFormat from line: + " + line + " (raw).", 0);
         *
         *      FieldFormat fieldFormat = new FieldFormat();
         *      string property, val;
         *
         *      foreach(string format in ExtractValue(line).Split(';'))
         *      {
         *              string[] lineSplit = format.Split('=');
         *
         *              if (lineSplit.Length > 1)
         *              {
         *                      property = lineSplit[0];
         *                      val = lineSplit[1];
         *
         *                      switch (property.ToUpper())
         *                      {
         *                              case "NAME": fieldFormat.Name = val; break;
         *                              case "FORMAT": fieldFormat.Format = val; break;
         *                              case "PADDINGDIR":
         *                                      if (val.ToUpper() == "LEFT")
         *                                              fieldFormat.PaddingDir = PaddingDirection.Left;
         *                                      else
         *                                              fieldFormat.PaddingDir = PaddingDirection.Right;
         *                                      break;
         *                              case "TOTALWIDTH":
         *                                      try
         *                                      {
         *                                              fieldFormat.TotalWidth = Convert.ToInt16(val);
         *                                      }
         *                                      catch
         *                                      {
         *                                              throw new Exception("Specified Total Width is not a valid number.");
         *                                      }
         *                                      break;
         *                              case "PADDINGCHAR": fieldFormat.PaddingChar = Convert.ToChar(val.Substring(0, 1)); break;
         *                      }
         *
         *              }// End if line split length > 1
         *      }
         *
         *      return fieldFormat;
         * }*/

        /// <summary>
        /// Process the Xml template.
        /// </summary>
        private void ProcessXmlTemplate(string content)
        {
            ActiveUp.Net.Mail.Logger.AddEntry("Processing the XML template.", 1);

            StringReader  stringReader = new StringReader(content);
            XmlTextReader reader       = new XmlTextReader(stringReader);

            string element = string.Empty;

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    element = reader.Name;
                    ActiveUp.Net.Mail.Logger.AddEntry("New element found: " + element + ".", 0);

                    switch (element.ToUpper())
                    {
                    case "MESSAGE":
                    {
                        if (reader.GetAttribute("PRIORITY") != null && reader.GetAttribute("PRIORITY") != string.Empty)
                        {
                            this.Message.Priority = (MessagePriority)Enum.Parse(typeof(MessagePriority), reader.GetAttribute("PRIORITY"), true);
                        }
                        else if (reader.GetAttribute("priority") != null && reader.GetAttribute("priority") != string.Empty)
                        {
                            this.Message.Priority = (MessagePriority)Enum.Parse(typeof(MessagePriority), reader.GetAttribute("priority"), true);
                        }
                    } break;

                    case "FIELDFORMAT":
                        if (reader.HasAttributes)
                        {
                            ActiveUp.Net.Mail.Logger.AddEntry("Element has attributes.", 0);
                            FieldFormat fieldFormat = new FieldFormat();

                            if (reader.GetAttribute("NAME") != null && reader.GetAttribute("NAME") != string.Empty)
                            {
                                fieldFormat.Name = reader.GetAttribute("NAME");
                                ActiveUp.Net.Mail.Logger.AddEntry("Attribute NAME: " + fieldFormat.Name, 0);
                            }

                            else if (reader.GetAttribute("name") != null && reader.GetAttribute("name") != string.Empty)
                            {
                                fieldFormat.Name = reader.GetAttribute("name");
                                ActiveUp.Net.Mail.Logger.AddEntry("Attribute name: " + fieldFormat.Name, 0);
                            }

                            if (reader.GetAttribute("FORMAT") != null && reader.GetAttribute("FORMAT") != string.Empty)
                            {
                                fieldFormat.Format = reader.GetAttribute("FORMAT");
                                ActiveUp.Net.Mail.Logger.AddEntry("Attribute FORMAT: " + fieldFormat.Format, 0);
                            }

                            else if (reader.GetAttribute("format") != null && reader.GetAttribute("format") != string.Empty)
                            {
                                fieldFormat.Format = reader.GetAttribute("format");
                                ActiveUp.Net.Mail.Logger.AddEntry("Attribute format: " + fieldFormat.Format, 0);
                            }

                            if (reader.GetAttribute("PADDINGDIR") != null && reader.GetAttribute("PADDINGDIR") != string.Empty)
                            {
                                if (reader.GetAttribute("PADDINGDIR").ToUpper() == "LEFT")
                                {
                                    fieldFormat.PaddingDir = PaddingDirection.Left;
                                }
                                else
                                {
                                    fieldFormat.PaddingDir = PaddingDirection.Right;
                                }
                                ActiveUp.Net.Mail.Logger.AddEntry("Attribute PADDINGDIR: " + reader.GetAttribute("PADDINGDIR"), 0);
                            }

                            else if (reader.GetAttribute("paddingdir") != null && reader.GetAttribute("paddingdir") != string.Empty)
                            {
                                if (reader.GetAttribute("paddingdir").ToUpper() == "left")
                                {
                                    fieldFormat.PaddingDir = PaddingDirection.Left;
                                }
                                else
                                {
                                    fieldFormat.PaddingDir = PaddingDirection.Right;
                                }
                                ActiveUp.Net.Mail.Logger.AddEntry("Attribute paddingdir: " + reader.GetAttribute("paddingdir"), 0);
                            }

                            if (reader.GetAttribute("TOTALWIDTH") != null && reader.GetAttribute("TOTALWIDTH") != string.Empty)
                            {
                                try
                                {
                                    fieldFormat.TotalWidth = Convert.ToInt16(reader.GetAttribute("TOTALWIDTH"));
                                }
                                catch
                                {
                                    throw new Exception("Specified Total Width is not a valid number.");
                                }
                                ActiveUp.Net.Mail.Logger.AddEntry("Attribute TOTALWIDTH: " + fieldFormat.TotalWidth.ToString(), 0);
                            }

                            else if (reader.GetAttribute("totalwidth") != null && reader.GetAttribute("totalwidth") != string.Empty)
                            {
                                try
                                {
                                    fieldFormat.TotalWidth = Convert.ToInt16(reader.GetAttribute("totalwidth"));
                                }
                                catch
                                {
                                    throw new Exception("Specified Total Width is not a valid number.");
                                }
                                ActiveUp.Net.Mail.Logger.AddEntry("Attribute totalwidth: " + fieldFormat.TotalWidth.ToString(), 0);
                            }

                            if (reader.GetAttribute("PADDINGCHAR") != null && reader.GetAttribute("PADDINGCHAR") != string.Empty)
                            {
                                fieldFormat.PaddingChar = Convert.ToChar(reader.GetAttribute("PADDINGCHAR").Substring(0, 1));
                                ActiveUp.Net.Mail.Logger.AddEntry("Attribute PADDINGCHAR: '" + fieldFormat.PaddingChar + "'", 0);
                            }

                            else if (reader.GetAttribute("paddingchar") != null && reader.GetAttribute("paddingchar") != string.Empty)
                            {
                                fieldFormat.PaddingChar = Convert.ToChar(reader.GetAttribute("paddingchar").Substring(0, 1));
                                ActiveUp.Net.Mail.Logger.AddEntry("Attribute paddingchar: '" + fieldFormat.PaddingChar + "'", 0);
                            }

                            this.FieldsFormats.Add(fieldFormat);
                        }

                        break;

                    case "FROM":
                    case "TO":
                    case "CC":
                    case "BCC":
                        if (reader.HasAttributes)
                        {
                            ActiveUp.Net.Mail.Address address = new ActiveUp.Net.Mail.Address();
                            if (reader.GetAttribute("NAME") != null && reader.GetAttribute("NAME") != string.Empty)
                            {
                                address.Name = reader.GetAttribute("NAME");
                            }
                            else if (reader.GetAttribute("name") != null && reader.GetAttribute("name") != string.Empty)
                            {
                                address.Name = reader.GetAttribute("name");
                            }
                            if (reader.GetAttribute("EMAIL") != null && reader.GetAttribute("EMAIL") != string.Empty)
                            {
                                address.Email = reader.GetAttribute("EMAIL");
                            }
                            else if (reader.GetAttribute("email") != null && reader.GetAttribute("email") != string.Empty)
                            {
                                address.Email = reader.GetAttribute("email");
                            }
                            if (element.ToUpper() == "FROM")
                            {
                                if (reader.GetAttribute("REPLYNAME") != null && reader.GetAttribute("REPLYNAME") != string.Empty)
                                {
                                    InitReplyTo();
                                    this.Message.ReplyTo.Name = reader.GetAttribute("REPLYNAME");
                                }
                                else if (reader.GetAttribute("replyname") != null && reader.GetAttribute("replyname") != string.Empty)
                                {
                                    InitReplyTo();
                                    this.Message.ReplyTo.Name = reader.GetAttribute("replyname");
                                }

                                if (reader.GetAttribute("REPLYEMAIL") != null && reader.GetAttribute("REPLYEMAIL") != string.Empty)
                                {
                                    InitReplyTo();
                                    this.Message.ReplyTo.Email = reader.GetAttribute("REPLYEMAIL");
                                }
                                else if (reader.GetAttribute("replyemail") != null && reader.GetAttribute("replyemail") != string.Empty)
                                {
                                    InitReplyTo();
                                    this.Message.ReplyTo.Email = reader.GetAttribute("replyemail");
                                }

                                if (reader.GetAttribute("RECEIPTEMAIL") != null && reader.GetAttribute("RECEIPTEMAIL") != string.Empty)
                                {
                                    this.Message.ReturnReceipt.Email = reader.GetAttribute("RECEIPTEMAIL");
                                }
                                else if (reader.GetAttribute("receiptemail") != null && reader.GetAttribute("receiptemail") != string.Empty)
                                {
                                    this.Message.ReturnReceipt.Email = reader.GetAttribute("receiptemail");
                                }
                            }

                            switch (reader.Name.ToUpper())
                            {
                            case "FROM": /*this.Message.From.Add(address);*/ this.Message.From = address; break;

                            case "TO": this.Message.To.Add(address); break;

                            case "CC": this.Message.Cc.Add(address); break;

                            case "BCC": this.Message.Bcc.Add(address); break;
                            }
                        }
                        break;

                    case "LISTTEMPLATE":
                    {
                        ListTemplate template = new ListTemplate();
                        string       RegionID = string.Empty;
                        string       NullText = string.Empty;
                        if (reader.GetAttribute("REGIONID") != null && reader.GetAttribute("REGIONID") != string.Empty)
                        {
                            RegionID = reader.GetAttribute("REGIONID");
                        }
                        else if (reader.GetAttribute("regionid") != null && reader.GetAttribute("regionid") != string.Empty)
                        {
                            RegionID = reader.GetAttribute("regionid");
                        }

                        if (reader.GetAttribute("NULLTEXT") != null && reader.GetAttribute("NULLTEXT") != string.Empty)
                        {
                            NullText = reader.GetAttribute("NULLTEXT");
                        }
                        else if (reader.GetAttribute("nulltext") != null && reader.GetAttribute("nulltext") != string.Empty)
                        {
                            NullText = reader.GetAttribute("nulltext");
                        }

                        if (reader.HasAttributes && reader.GetAttribute("NAME") != null && reader.GetAttribute("NAME") != string.Empty)
                        {
                            template = new ListTemplate(reader.GetAttribute("NAME"), reader.ReadString());
                        }
                        else if (reader.HasAttributes && reader.GetAttribute("name") != null && reader.GetAttribute("name") != string.Empty)
                        {
                            template = new ListTemplate(reader.GetAttribute("name"), reader.ReadString());
                        }

                        template.RegionID = RegionID;
                        template.NullText = NullText;

                        this.ListTemplates.Add(template);
                    } break;

                    case "SMTPSERVER":
                    {
                        Server server = new Server();

                        if (reader.GetAttribute("SERVER") != null && reader.GetAttribute("SERVER") != string.Empty)
                        {
                            server.Host = reader.GetAttribute("SERVER");
                        }
                        else if (reader.GetAttribute("server") != null && reader.GetAttribute("server") != string.Empty)
                        {
                            server.Host = reader.GetAttribute("server");
                        }

                        if (reader.GetAttribute("PORT") != null && reader.GetAttribute("PORT") != string.Empty)
                        {
                            server.Port = int.Parse(reader.GetAttribute("PORT"));
                        }
                        else if (reader.GetAttribute("port") != null && reader.GetAttribute("port") != string.Empty)
                        {
                            server.Port = int.Parse(reader.GetAttribute("port"));
                        }

                        if (reader.GetAttribute("USERNAME") != null && reader.GetAttribute("USERNAME") != string.Empty)
                        {
                            server.Username = reader.GetAttribute("USERNAME");
                        }
                        else if (reader.GetAttribute("username") != null && reader.GetAttribute("username") != string.Empty)
                        {
                            server.Username = reader.GetAttribute("username");
                        }

                        if (reader.GetAttribute("PASSWORD") != null && reader.GetAttribute("PASSWORD") != string.Empty)
                        {
                            server.Password = reader.GetAttribute("PASSWORD");
                        }
                        else if (reader.GetAttribute("password") != null && reader.GetAttribute("password") != string.Empty)
                        {
                            server.Password = reader.GetAttribute("password");
                        }

                        SmtpServers.Add(server);
                    } break;

                    case "CONDITION":
                    {
                        Condition condition = new Condition();

                        if (reader.GetAttribute("REGIONID") != null && reader.GetAttribute("REGIONID") != string.Empty)
                        {
                            condition.RegionID = reader.GetAttribute("REGIONID");
                        }
                        else if (reader.GetAttribute("regionid") != null && reader.GetAttribute("regionid") != string.Empty)
                        {
                            condition.RegionID = reader.GetAttribute("regionid");
                        }

                        if (reader.GetAttribute("OPERATOR") != null && reader.GetAttribute("OPERATOR") != string.Empty)
                        {
                            condition.Operator = (OperatorType)Enum.Parse(typeof(OperatorType), reader.GetAttribute("OPERATOR"), true);
                        }
                        else if (reader.GetAttribute("operator") != null && reader.GetAttribute("operator") != string.Empty)
                        {
                            condition.Operator = (OperatorType)Enum.Parse(typeof(OperatorType), reader.GetAttribute("operator"), true);
                        }

                        if (reader.GetAttribute("NULLTEXT") != null && reader.GetAttribute("NULLTEXT") != string.Empty)
                        {
                            condition.NullText = reader.GetAttribute("NULLTEXT");
                        }
                        else if (reader.GetAttribute("nulltext") != null && reader.GetAttribute("nulltext") != string.Empty)
                        {
                            condition.NullText = reader.GetAttribute("nulltext");
                        }

                        if (reader.GetAttribute("FIELD") != null && reader.GetAttribute("FIELD") != string.Empty)
                        {
                            condition.Field = reader.GetAttribute("FIELD");
                        }
                        else if (reader.GetAttribute("field") != null && reader.GetAttribute("field") != string.Empty)
                        {
                            condition.Field = reader.GetAttribute("field");
                        }

                        if (reader.GetAttribute("VALUE") != null && reader.GetAttribute("VALUE") != string.Empty)
                        {
                            condition.Value = reader.GetAttribute("VALUE");
                        }
                        else if (reader.GetAttribute("value") != null && reader.GetAttribute("value") != string.Empty)
                        {
                            condition.Value = reader.GetAttribute("value");
                        }

                        if (reader.GetAttribute("CASESENSITIVE") != null && reader.GetAttribute("CASESENSITIVE") != string.Empty)
                        {
                            condition.CaseSensitive = bool.Parse(reader.GetAttribute("CASESENSITIVE"));
                        }
                        else if (reader.GetAttribute("casesensitive") != null && reader.GetAttribute("casesensitive") != string.Empty)
                        {
                            condition.CaseSensitive = bool.Parse(reader.GetAttribute("casesensitive"));
                        }

                        Conditions.Add(condition);
                    } break;

                    case "REGION":
                    {
                        Region region = new Region();

                        if (reader.GetAttribute("REGIONID") != null && reader.GetAttribute("REGIONID") != string.Empty)
                        {
                            region.RegionID = reader.GetAttribute("REGIONID");
                        }
                        else if (reader.GetAttribute("regionid") != null && reader.GetAttribute("regionid") != string.Empty)
                        {
                            region.RegionID = reader.GetAttribute("regionid");
                        }

                        if (reader.GetAttribute("NULLTEXT") != null && reader.GetAttribute("NULLTEXT") != string.Empty)
                        {
                            region.NullText = reader.GetAttribute("NULLTEXT");
                        }
                        else if (reader.GetAttribute("nulltext") != null && reader.GetAttribute("nulltext") != string.Empty)
                        {
                            region.NullText = reader.GetAttribute("nulltext");
                        }

                        if (reader.GetAttribute("URL") != null && reader.GetAttribute("URL") != string.Empty)
                        {
                            region.URL = reader.GetAttribute("URL");
                        }
                        else if (reader.GetAttribute("url") != null && reader.GetAttribute("url") != string.Empty)
                        {
                            region.URL = reader.GetAttribute("url");
                        }

                        Regions.Add(region);
                    } break;
                    }
                    break;

                case XmlNodeType.Text:
                    switch (element.ToUpper())
                    {
                    case "SUBJECT":
                        this.Message.Subject += reader.Value;
                        break;

                    /*case "SMTPSERVER":
                     *      this.SmtpServers.Add(reader.Value, 25);
                     *      break;*/
                    case "BODYHTML":
                        //this.Bodies.Add(reader.Value, BodyFormat.Html);
                        this.Message.BodyHtml.Text += reader.Value;
                        break;

                    case "BODYTEXT":
                        //this.Bodies.Add(reader.Value, BodyFormat.Text);
                        this.Message.BodyText.Text += reader.Value;
                        break;
                    }
                    break;

                case XmlNodeType.EndElement:
                    element = string.Empty;
                    break;
                }
            }
        }
コード例 #28
0
 public void Add(IWorldRegion x) => Regions.Add(x);
コード例 #29
0
    private void SplitHorizontalAt(Stack <Region> regionsToSplit, Region beingSplitted, int splitY)
    {
        //Get the number of holes.
        int holes = Settings.HolesInLine(beingSplitted.Width + 1);

        if (holes < 1)
        {
            holes = 1;
        }
        if (holes >= beingSplitted.Width + 1)
        {
            Regions.Add(beingSplitted);
            return;
        }

        //First make the line.
        for (int i = beingSplitted.Left; i <= beingSplitted.Right; ++i)
        {
            Map[i, splitY] = true;
        }
        //Make sure the line isn't blocking a hole at the edge of the region.
        if (beingSplitted.Left > 0 && (!Map[beingSplitted.Left - 1, splitY] || Holes.Contains(new Location(beingSplitted.Left - 1, splitY))))
        {
            Map[beingSplitted.Left, splitY] = false;
            Holes.Add(new Location(beingSplitted.Left, splitY));
        }
        if (beingSplitted.Right < Map.GetLength(1) - 1 && (!Map[beingSplitted.Right + 1, splitY] || Holes.Contains(new Location(beingSplitted.Right + 1, splitY))))
        {
            Map[beingSplitted.Right, splitY] = false;
            Holes.Add(new Location(beingSplitted.Right, splitY));
        }
        //Now make holes.

        //Get the possible cells to put a hole in.
        List <int> cellXs = new List <int>(beingSplitted.Width + 1);

        for (int i = 0; i < beingSplitted.Width + 1; ++i)
        {
            cellXs.Add(i + beingSplitted.Left);
        }

        //Randomly pick from them.
        int randomIndex;

        for (int i = 0; i < holes; ++i)
        {
            randomIndex = MathF.R.Next(0, cellXs.Count);

            Map[cellXs[randomIndex], splitY] = false;
            Holes.Add(new Location(cellXs[randomIndex], splitY));

            cellXs.RemoveAt(randomIndex);
        }

        //Now split the region into two regions (assuming both regions are large enough). Move the regions around a bit to make sure the line we just made is not part of the regions.
        Region one = new Region(beingSplitted.TopLeft, new Location {
            X = beingSplitted.Right, Y = splitY - 1
        });
        Region two = new Region(new Location {
            X = beingSplitted.Left, Y = splitY + 1
        }, beingSplitted.BottomRight);

        if (one.Width >= 0 && one.Height >= 0 && one.Left >= 0 && one.Right < Map.GetLength(0) && one.Top >= 0 && one.Bottom < Map.GetLength(1))
        {
            regionsToSplit.Push(one);
        }
        if (two.Width >= 0 && two.Height >= 0 && two.Left >= 0 && two.Right < Map.GetLength(0) && two.Top >= 0 && two.Bottom < Map.GetLength(1))
        {
            regionsToSplit.Push(two);
        }
    }
コード例 #30
0
    public void IterateBase()
    {
        if (RegionsToSplit.Count > 0)
        {
            current = RegionsToSplit.Pop();

            //Possibly ignore the region.
            if (MathF.R.NextDouble() < Settings.IgnoreRegionChance(current))
            {
                Regions.Add(current);
                //Re-iterate so that this iteration doesn't appear to do nothing.
                IterateBase();
                return;
            }

            //Figure out how to split the region: horizontally or vertically.
            bool horizontal = Settings.ShouldSplitHorizontally(new Location {
                X = current.Width, Y = current.Height
            });
            if (current.Width < 2)
            {
                horizontal = true;
            }
            if (current.Height < 2)
            {
                horizontal = false;
            }

            //Split.
            if (horizontal)
            {
                int i = current.Top, j = current.Bottom;

                //If there's only one or two possible spots, just pick one.
                if (j - i < 3)
                {
                    SplitHorizontalAt(RegionsToSplit, current, (j + i) / 2);
                }
                //Otherwise use the function, but make sure the outer two lines won't be picked.
                else
                {
                    SplitHorizontalAt(RegionsToSplit, current, Settings.SplitLocation(i + 1, j - 1));
                }
            }
            else
            {
                int i = current.Left, j = current.Right;

                //If there's only one or two possible spots, just pick one.
                if (j - i < 3)
                {
                    SplitVerticalAt(RegionsToSplit, current, (j + i) / 2);
                }
                //Otherwise use the function, but make sure the outer two lines won't be picked.
                else
                {
                    SplitVerticalAt(RegionsToSplit, current, Settings.SplitLocation(i + 1, j - 1));
                }
            }
        }
    }
コード例 #31
0
        public override void VisitEndRegionDirectiveTrivia(EndRegionDirectiveTriviaSyntax node)
        {
            base.VisitEndRegionDirectiveTrivia(node);

            Regions.Add(node);
        }
コード例 #32
0
ファイル: EditModel.cs プロジェクト: scenicsoftware/Piranha
        private void GetRelated()
        {
            // Clear related
            Regions.Clear();
            Properties.Clear();
            AttachedContent.Clear();

            // Get group parents
            DisableGroups = SysGroup.GetParents(Page.GroupId);
            DisableGroups.Reverse();

            // Get template & permalink
            Template  = PageTemplate.GetSingle("pagetemplate_id = @0", Page.TemplateId);
            Permalink = Permalink.GetSingle(Page.PermalinkId);
            if (Permalink == null)
            {
                // Get the site tree
                using (var db = new DataContext()) {
                    var sitetree = db.SiteTrees.Where(s => s.Id == Page.SiteTreeId).Single();

                    Permalink = new Permalink()
                    {
                        Id = Guid.NewGuid(), Type = Permalink.PermalinkType.PAGE, NamespaceId = sitetree.NamespaceId
                    };
                    Page.PermalinkId = Permalink.Id;
                }
            }

            // Get placement ref title
            if (!IsSite)
            {
                if (Page.ParentId != Guid.Empty || Page.Seqno > 1)
                {
                    Page refpage = null;
                    if (Page.Seqno > 1)
                    {
                        if (Page.ParentId != Guid.Empty)
                        {
                            refpage = Page.GetSingle("page_parent_id = @0 AND page_seqno = @1", Page.ParentId, Page.Seqno - 1);
                        }
                        else
                        {
                            refpage = Page.GetSingle("page_parent_id IS NULL AND page_seqno = @0", Page.Seqno - 1);
                        }
                    }
                    else
                    {
                        refpage = Page.GetSingle(Page.ParentId, true);
                    }
                    PlaceRef = refpage.Title;
                }
            }

            if (Template != null)
            {
                // Only load regions & properties if this is an original
                if (Page.OriginalId == Guid.Empty)
                {
                    // Get regions
                    var regions = RegionTemplate.Get("regiontemplate_template_id = @0", Template.Id, new Params()
                    {
                        OrderBy = "regiontemplate_seqno"
                    });
                    foreach (var rt in regions)
                    {
                        var reg = Region.GetSingle("region_regiontemplate_id = @0 AND region_page_id = @1 and region_draft = @2",
                                                   rt.Id, Page.Id, Page.IsDraft);
                        if (reg != null)
                        {
                            Regions.Add(reg);
                        }
                        else
                        {
                            Regions.Add(new Region()
                            {
                                InternalId       = rt.InternalId,
                                Name             = rt.Name,
                                Type             = rt.Type,
                                PageId           = Page.Id,
                                RegiontemplateId = rt.Id,
                                IsDraft          = Page.IsDraft,
                                IsPageDraft      = Page.IsDraft
                            });
                        }
                    }

                    // Get Properties
                    foreach (string name in Template.Properties)
                    {
                        Property prp = Property.GetSingle("property_name = @0 AND property_parent_id = @1 AND property_draft = @2",
                                                          name, Page.Id, Page.IsDraft);
                        if (prp != null)
                        {
                            Properties.Add(prp);
                        }
                        else
                        {
                            Properties.Add(new Property()
                            {
                                Name = name, ParentId = Page.Id, IsDraft = Page.IsDraft
                            });
                        }
                    }
                }
            }
            else
            {
                throw new ArgumentException("Could not find page template for page {" + Page.Id.ToString() + "}");
            }

            // Only load attachments if this is an original
            if (Page.OriginalId == Guid.Empty)
            {
                // Get attached content
                if (Page.Attachments.Count > 0)
                {
                    // Content meta data is actually memcached, so this won't result in multiple queries
                    Page.Attachments.ForEach(a => {
                        Models.Content c = Models.Content.GetSingle(a, true);
                        if (c != null)
                        {
                            AttachedContent.Add(c);
                        }
                    });
                }
            }

            // Get page position
            Parents = BuildParentPages(Sitemap.GetStructure(Page.SiteTreeInternalId, false), Page);
            Parents.Insert(0, new PagePlacement()
            {
                Level = 1, IsSelected = Page.ParentId == Guid.Empty
            });
            Siblings = BuildSiblingPages(Page.Id, Page.ParentId, Page.Seqno, Page.ParentId, Page.SiteTreeInternalId);

            // Only load extensions if this is an original
            if (Page.OriginalId == Guid.Empty)
            {
                // Get extensions
                Extensions = Page.GetExtensions(true);
            }

            // Initialize regions
            foreach (var reg in Regions)
            {
                reg.Body.InitManager(this);
            }

            // Get whether comments should be enabled
            EnableComments = Areas.Manager.Models.CommentSettingsModel.Get().EnablePages;
            if (!Page.IsNew && EnableComments)
            {
                using (var db = new DataContext()) {
                    Comments = db.Comments.
                               Where(c => c.ParentId == Page.Id && c.ParentIsDraft == false).
                               OrderByDescending(c => c.Created).ToList();
                }
            }

            // Get the site if this is a site page
            if (Permalink.Type == Models.Permalink.PermalinkType.SITE)
            {
                using (var db = new DataContext()) {
                    SiteTree = db.SiteTrees.Where(s => s.Id == Page.SiteTreeId).Single();
                }
            }

            // Check if the page can be published
            if (Page.OriginalId != Guid.Empty)
            {
                CanPublish = Page.GetScalar("SELECT count(*) FROM page WHERE page_id=@0 AND page_draft=0", Page.OriginalId) > 0;
            }
        }