Inheritance: WaterBase
Beispiel #1
0
        public static string GetInspectWaterTypeString(WaterType waterType)
        {
            switch (waterType)
            {
            case WaterType.NoWater:
                return(MizuStrings.InspectWaterTypeNo.Translate());

            case WaterType.ClearWater:
                return(MizuStrings.InspectWaterTypeClear.Translate());

            case WaterType.NormalWater:
                return(MizuStrings.InspectWaterTypeNormal.Translate());

            case WaterType.RawWater:
                return(MizuStrings.InspectWaterTypeRaw.Translate());

            case WaterType.MudWater:
                return(MizuStrings.InspectWaterTypeMud.Translate());

            case WaterType.SeaWater:
                return(MizuStrings.InspectWaterTypeSea.Translate());

            default:
                Log.Error("unknown water type");
                return("unknown");
            }
        }
        public static IEnumerable <KeyValuePair <int, FishData> > GetPossibleFish(int depth, int mineLevel = -1)
        {
            Season    s = Helpers.ToSeason(Game1.currentSeason) ?? Season.SPRINGSUMMERFALLWINTER;
            WaterType w = Helpers.ConvertWaterType(Game1.currentLocation.getFishingLocation(Game1.player.getTileLocation())) ?? WaterType.BOTH;

            return(FishHelper.GetPossibleFish(Game1.currentLocation.name, w, s, Game1.isRaining ? Weather.RAINY : Weather.SUNNY, Game1.timeOfDay, depth, Game1.player.FishingLevel, mineLevel));
        }
Beispiel #3
0
        /// <inheritdoc />
        public IEnumerable <IWeightedElement <int?> > GetPossibleFish(Farmer who)
        {
            WaterType w         = SDVHelpers.ToWaterType(who.currentLocation?.getFishingLocation(who.getTileLocation()) ?? -1) ?? WaterType.Both;
            int       mineLevel = who.currentLocation is MineShaft mine ? mine.mineLevel : -1;

            return(this.GetPossibleFish(who, who.currentLocation?.Name ?? "", w, SDate.Now(), Game1.isRaining ? Weather.Rainy : Weather.Sunny, Game1.timeOfDay, Game1.player.FishingLevel, mineLevel));
        }
        //---------------------------------------------------------------------
        public static void Initialize(IInputParameters parameters)
        {
            LitterParameters = new LitterType[2];

            LitterType litterParmsSurface = new LitterType();
            LitterType litterParmsSoil    = new LitterType();

            // Structural decomposition rate, the fraction of the pool that turns over each year.
            litterParmsSurface.DecayRateStrucC = 3.9; //DEC1(1)
            litterParmsSoil.DecayRateStrucC    = 4.9; //DEC1(2)

            // Metabolic decomposition rate, the fraction of the pool that turns over each year.
            litterParmsSurface.DecayRateMetabolicC = 1.48; //DEC2(1)  //modified assuming they meant, 'percentage'
            litterParmsSoil.DecayRateMetabolicC    = 1.85; //DEC2(2)  //modified assuming they meant, 'percentage'

            // Decomposition rate of organic matter with active turnover, the fraction of the pool
            // that turns over each year (SOM1)
            litterParmsSurface.DecayRateMicrobes = 1.0; // 6.0; //DEC3(1)  set to 1.0 until meaning of 'fraction' is determined.
            litterParmsSoil.DecayRateMicrobes    = 1.0; // 7.3; //DEC3(2)

            LitterParameters[0] = litterParmsSurface;
            LitterParameters[1] = litterParmsSoil;

            CalibrateMode = parameters.CalibrateMode;
            WType         = parameters.WType;
            //ProbEstablishAdjust = parameters.ProbEstablishAdjustment;
            //FractionSOM2toCO2   = parameters.FractionSOM2toCO2;
            //FractionSOM3toCO2   = parameters.FractionSOM3toCO2;
            //DecayRateSOM2       = parameters.DecayRateSOM2;
            //DecayRateSOM3       = parameters.DecayRateSOM3;
        }
        //---------------------------------------------------------------------
        public static void Initialize(IInputParameters parameters)
        {
            LitterParameters = new LitterType[2];

            LitterType litterParmsSurface = new LitterType();
            LitterType litterParmsSoil    = new LitterType();

            CalibrateMode      = parameters.CalibrateMode;
            SoilWaterVersion64 = parameters.SoilWater64;
            WaterDecayFunction = parameters.WType;

            // Structural decomposition rate, the fraction of the pool that turns over each year.
            litterParmsSurface.DecayRateStrucC = 3.9 / 100.0; //DEC1(1)
            litterParmsSoil.DecayRateStrucC    = 4.9 / 100.0; //DEC1(2)

            // Metabolic decomposition rate, the fraction of the pool that turns over each year.
            litterParmsSurface.DecayRateMetabolicC = 14.8 / 100.0; //DEC2(1)  //modified assuming they meant, 'percentage'
            litterParmsSoil.DecayRateMetabolicC    = 18.5 / 100;   //DEC2(2)  //modified assuming they meant, 'percentage'

            // Decomposition rate of organic matter with active turnover, the fraction of the pool
            // that turns over each year (SOM1)
            litterParmsSurface.DecayRateMicrobes = 6.0 / 100.0; //DEC3(1)  set to 1.0 until meaning of 'fraction' is determined.
            litterParmsSoil.DecayRateMicrobes    = 7.3 / 100.0; //DEC3(2)

            LitterParameters[0] = litterParmsSurface;
            LitterParameters[1] = litterParmsSoil;
        }
    public static void main(string[] args)
    {
        // Create our combatants:
        ElementalType cerberus = new FireType();
        ElementalType hydra    = new WaterType();
        ElementalType heracles = new NormalType();

        // persephone attacks poseidon:
        float multiplier = cerberus.Attack(hydra);

        Console.WriteLine("Persephone attacks Poseidon and deals " + multiplier + " x damage!");

        // poseidon attacks back:
        multiplier = hydra.Attack(cerberus);
        Console.WriteLine("Poseidon attacks back and deals " + multiplier + " x damage!");

        // Heracles attacks Poseidon:
        multiplier = heracles.Attack(hydra);
        Console.WriteLine("Heracles attacks Poseidon and deals " + multiplier + " x damage!");

        // Persephone attacks Heracles:
        multiplier = cerberus.Attack(heracles);
        Console.WriteLine("Persephone attacks Heracles and deals " + multiplier + " x damage!");

        Console.WriteLine("The battle has ended!");
    }
Beispiel #7
0
 public WaterTypeTest()
 {
     sut = new WaterType()
     {
         Name = ""
     };
 }
Beispiel #8
0
        public static void SetWater(MapData[,] heightMap, Vector2 pos, WaterType waterType)
        {
            int x = Math.Max(Math.Min((int)pos.X, heightMap.GetLength(0) - 1), 0);
            int y = Math.Max(Math.Min((int)pos.Y, heightMap.GetLength(1) - 1), 0);

            heightMap[x, y].Water = waterType;
        }
Beispiel #9
0
 public UndergroundWaterPool(MapComponent_WaterGrid waterGrid, float maxWaterVolume, WaterType waterType, float baseRegenRate, float rainRegenRatePerCell) : this(waterGrid)
 {
     this.maxWaterVolume       = maxWaterVolume;
     this.currentWaterVolume   = maxWaterVolume;
     this.waterType            = waterType;
     this.baseRegenRate        = baseRegenRate;
     this.rainRegenRatePerCell = rainRegenRatePerCell;
 }
    protected WaterSettings createWaterSettings(WaterType type, string material)
    {
        var ws = new WaterSettings();

        ws.Type     = type;
        ws.Material = (Material)Resources.Load(material, typeof(Material));
        return(ws);
    }
 public bool MeetsCriteria(Farmer who, string locationName, WaterType waterType, SDate date, Weather weather, int time, int fishingLevel, int?mineLevel)
 {
     return((this.InvertLocations ^ (this.Location == null || locationName == this.Location)) &&
            (this.WaterType & waterType) != 0 &&
            (this.Season & date.GetSeason()) != 0 &&
            (this.Weather & weather) != 0 &&
            this.FishingLevel <= fishingLevel &&
            (this.MineLevel == null || this.MineLevel == mineLevel));
 }
Beispiel #12
0
 // constructor
 public Livestock(CareLevel _careLevel, Temperment _temperment, WaterType _waterType, string _colours, string _waterConditions, string _maxSize, string _name, string _description, double _price) : base(_name, _description, _price)
 {
     CareLevel       = _careLevel;
     Temperment      = _temperment;
     WaterType       = _waterType;
     Colours         = _colours;
     WaterConditions = _waterConditions;
     MaxSize         = _maxSize;
 }
Beispiel #13
0
 public bool MeetsCriteria(int fish, WaterType waterType, SDate date, Weather weather, int time, int level)
 {
     // Note: HasFlag won't work because these are checking for an intersection, not for a single bit
     return((this.WaterType & waterType) > 0 &&
            (this.Season & date.GetSeason()) > 0 &&
            (this.Weather & weather) > 0 &&
            level >= this.MinLevel &&
            this.Times.Any(t => time >= t.Start && time < t.Finish));
 }
Beispiel #14
0
 public GridTile(int x, int y)
 {
     XCoord          = x;
     YCoord          = y;
     thisTerrainType = GridTerrain.Grass;
     thisRoadType    = RoadType.None;
     thisNodeType    = GridNode.None;
     thisWaterType   = WaterType.None;
 }
 public FishData(double chance, WaterType waterType, Season season, int minTime = 600, int maxTime = 2600, int minDepth = 0, int minLevel = 0, Weather weather = Weather.BOTH, int mineLevel = -1)
 {
     this.Chance = chance;
     this.WaterType = waterType;
     this.Season = season;
     this.MinTime = minTime;
     this.MaxTime = maxTime;
     this.MinCastDistance = minDepth;
     this.MinLevel = minLevel;
     this.Weather = weather;
     this.MineLevel = mineLevel;
 }
Beispiel #16
0
 public FishData(double chance, IEnumerable <TimeInterval> times, WaterType waterType, Season season, int minLevel = 0, Weather?weather = null, int?mineLevel = null)
 {
     this.Chance    = chance;
     this.WaterType = waterType;
     this.Season    = season;
     this.MinLevel  = minLevel;
     this.Weather   = weather ?? Weather.Sunny | Weather.Rainy;
     this.MineLevel = mineLevel;
     if (times != null)
     {
         this.Times = new List <TimeInterval>(times);
     }
 }
Beispiel #17
0
        private void CreateGameObject(WaterType kind, MeshData meshdata, Transform parent)
        {
            var go   = new GameObject(kind + " Waters");
            var mesh = go.AddComponent <MeshFilter>().mesh;

            go.AddComponent <MeshRenderer>();
            mesh.vertices  = meshdata.Vertices.ToArray();
            mesh.triangles = meshdata.Indices.ToArray();
            mesh.RecalculateNormals();
            go.GetComponent <MeshRenderer>().material = FactorySettings.GetSettingsFor <WaterSettings>(kind).Material;
            go.transform.position += Vector3.up * Order;
            go.transform.SetParent(parent, true);
        }
Beispiel #18
0
        public void WaterPokemon()
        {
            //arrange
            var Vaporeon = new WaterType("Vaporeon");
            var actual   = Vaporeon.Type;
            //act
            var expect = "Water";

            Console.WriteLine(Vaporeon.Attack);

            Assert.AreEqual(Vaporeon.Attack, "Vaporeon, Water Pistol");
            Assert.AreEqual(expect, actual);
        }
Beispiel #19
0
        private void CreateGameObject(WaterType kind, List <Vector3> vertices, List <int> indices, GameObject main)
        {
            var go   = new GameObject(kind + " Waters");
            var mesh = go.AddComponent <MeshFilter>().mesh;

            go.AddComponent <MeshRenderer>();
            mesh.vertices  = vertices.ToArray();
            mesh.triangles = indices.ToArray();
            mesh.RecalculateNormals();
            go.GetComponent <MeshRenderer>().material = _settings.GetSettingsFor(kind).Material;
            go.transform.position += Vector3.up * Order;
            go.transform.SetParent(main.transform, true);
        }
Beispiel #20
0
    public void ChangePathType(PathType newType)
    {
        PathTypeState state = null;

        lastSetType = newType;
        switch (newType)
        {
        case PathType.city:
            state = new CityType();
            break;

        case PathType.desert:
            state = new DesertType();
            break;

        case PathType.field:
            state = new FieldType();
            break;

        case PathType.forest:
            state = new ForestType();
            break;

        case PathType.mountain:
            state = new MountainType();
            break;

        case PathType.road:
            state = new RoadType();
            break;

        case PathType.rocks:
            state = new RocksType();
            break;

        case PathType.swamp:
            state = new SwampType();
            break;

        case PathType.water:
            state = new WaterType();
            break;
        }

        if (_pathType != null)
        {
            _pathType.OnExitState();
        }
        _pathType = state;
        _pathType.OnEnterState(this);
    }
 public override void WriteData(ESPWriter writer)
 {
     if (EditorID != null)
     {
         EditorID.WriteBinary(writer);
     }
     if (ObjectBounds != null)
     {
         ObjectBounds.WriteBinary(writer);
     }
     if (Name != null)
     {
         Name.WriteBinary(writer);
     }
     if (Model != null)
     {
         Model.WriteBinary(writer);
     }
     if (Script != null)
     {
         Script.WriteBinary(writer);
     }
     if (Destructable != null)
     {
         Destructable.WriteBinary(writer);
     }
     if (LoopingSound != null)
     {
         LoopingSound.WriteBinary(writer);
     }
     if (ActivationSound != null)
     {
         ActivationSound.WriteBinary(writer);
     }
     if (RadioTemplate != null)
     {
         RadioTemplate.WriteBinary(writer);
     }
     if (RadioStation != null)
     {
         RadioStation.WriteBinary(writer);
     }
     if (WaterType != null)
     {
         WaterType.WriteBinary(writer);
     }
     if (ActivationPrompt != null)
     {
         ActivationPrompt.WriteBinary(writer);
     }
 }
Beispiel #22
0
        public WaterNet()
        {
            this.ID = nextID;
            nextID++;

            this.waterType       = WaterType.NoWater;
            this.storedWaterType = WaterType.NoWater;

            this.inputterTypeDic[CompProperties_WaterNetInput.InputType.WaterNet]  = new HashSet <IBuilding_WaterNet>();
            this.inputterTypeDic[CompProperties_WaterNetInput.InputType.Rain]      = new HashSet <IBuilding_WaterNet>();
            this.inputterTypeDic[CompProperties_WaterNetInput.InputType.WaterPool] = new HashSet <IBuilding_WaterNet>();
            this.inputterTypeDic[CompProperties_WaterNetInput.InputType.Terrain]   = new HashSet <IBuilding_WaterNet>();

            this.tankTypeDic[CompProperties_WaterNetTank.DrawType.Self]   = new HashSet <IBuilding_WaterNet>();
            this.tankTypeDic[CompProperties_WaterNetTank.DrawType.Faucet] = new HashSet <IBuilding_WaterNet>();
        }
Beispiel #23
0
        public IWell GenerateRandomInjectionWell(int id)
        {
            // Get random water type: http://stackoverflow.com/a/3132151
            Array     values     = Enum.GetValues(typeof(WaterType));
            Random    random     = new Random();
            WaterType randomType = (WaterType)values.GetValue(random.Next(values.Length));

            // Get random datetime: http://stackoverflow.com/a/194870
            DateTime start      = new DateTime(2005, 1, 1);
            int      range      = (DateTime.Today - start).Days;
            DateTime randomDate = start.AddDays(random.Next(range));

            return(new InjectionWell {
                Id = id, SpudDate = randomDate, WaterType = randomType
            });
        }
        void Parcels_OnParcelsDownloaded(Simulator simulator, Dictionary <int, Parcel> Parcels, int[,] map)
        {
            foreach (KeyValuePair <int, Parcel> parcel in Parcels)
            {
                WaterType type      = ParcelDownloader.GetWaterType(map, parcel.Value.LocalID);
                float     delta     = ParcelDownloader.GetHeightRange(map, parcel.Value.LocalID);
                int       deviation = ParcelDownloader.GetRectangularDeviation(parcel.Value.AABBMin, parcel.Value.AABBMax,
                                                                               parcel.Value.Area);

                Console.WriteLine("Parcels[{0}]: Name: \"{1}\", Description: \"{2}\" ACL Count: {3}, " +
                                  "Location: {4}, Height Range: {5}, Shape Deviation: {6}", parcel.Key, parcel.Value.Name,
                                  parcel.Value.Desc, parcel.Value.AccessList.Count, type.ToString(), delta, deviation);
            }

            ParcelCount = Parcels.Count;
            ParcelsDownloaded.Set();
        }
Beispiel #25
0
    //string waterpic = ImageDealLib.makewatermark(suoluepic, "/images/w.png", ImageDealLib.WaterType.Random, "/images/", ImageDealLib.ImageType.JPEG, ImageDealLib.FileCache.Save, out warning2);
    public static string makewatermark(string picpath, string waterspath, WaterType watermodel, string spath, ImageType imgtype, FileCache filecache, out string warning, int trans = 100)
    {
        System.Text.StringBuilder checkmessage     = new System.Text.StringBuilder();
        System.Drawing.Image      _sourceimg_water = null;
        //检测水印源文件
        string _sourceimg_water_mappath = "";
        bool   checkfilewater           = false;

        checkfilewater = FileExistMapPath(waterspath, FileCheckModel.C, out _sourceimg_water_mappath);
        if (checkfilewater == true)
        {
            //从指定源文件,创建image对象
            _sourceimg_water = System.Drawing.Image.FromFile(_sourceimg_water_mappath);
        }
        else
        {
            checkmessage.Append("error:找不到需要水印图片!" + waterspath + ";");
        }
        return(makewatermark(picpath, _sourceimg_water, watermodel, spath, imgtype, filecache, out warning, trans));
    }
Beispiel #26
0
        static private Effect[] GetWaterEffects(WaterType waterType)
        {
            switch (waterType)
            {
            case WaterType.Clean: return(Global.WaterDistributor.m_cleanWaterEffects);

            case WaterType.Fresh: return(Global.WaterDistributor.m_freshWaterEffects);

            case WaterType.Salt: return(Global.WaterDistributor.m_saltWaterEffects);

            case WaterType.Rancid: return(Global.WaterDistributor.m_rancidWaterEffects);

            case WaterType.Magic: return(Global.WaterDistributor.m_magicWaterEffects);

            case WaterType.Pure: return(Global.WaterDistributor.m_pureWaterEffects);

            case WaterType.Healing: return(Global.WaterDistributor.m_healingWaterEffects);

            default: return(null);
            }
        }
Beispiel #27
0
        public async Task TypeTest()
        {
            ContextIds idList = new ContextIds(Context);

            var attack = new WaterType(true);
            List <BasicType> defense = new List <BasicType>()
            {
                new WaterType(true),
                new FireType(true)
            };

            var effect = attack.ParseEffectiveness(defense);

            string defstr = $"{defense[0].Type}";

            if (defense.Count > 1)
            {
                defstr += $"/{defense[1].Type}";
            }

            await MessageHandler.SendMessage(idList, $"{attack.Type} is {effect}x effective against {defstr}");
        }
Beispiel #28
0
        public void ExposeData()
        {
            Scribe_Values.Look <int>(ref this.ID, "ID");
            Scribe_Values.Look <float>(ref this.maxWaterVolume, "maxWaterVolume");
            Scribe_Values.Look <float>(ref this.currentWaterVolume, "currenteWaterVolume");
            Scribe_Values.Look <WaterType>(ref this.waterType, "waterType");
            Scribe_Values.Look <float>(ref this.baseRegenRate, "baseRegenRate");
            Scribe_Values.Look <float>(ref this.rainRegenRatePerCell, "rainRegenRatePerCell");
            Scribe_Values.Look <int>(ref this.lastTick, "lastTick");
            Scribe_Values.Look <float>(ref this.outputWaterFlow, "outputWaterFlow");

            if (this.debugFlag)
            {
                this.debugFlag = false;
                if (MizuDef.GlobalSettings.forDebug.enableChangeWaterPoolType)
                {
                    this.waterType = MizuDef.GlobalSettings.forDebug.changeWaterPoolType;
                }
                if (MizuDef.GlobalSettings.forDebug.enableChangeWaterPoolVolume)
                {
                    this.maxWaterVolume     *= MizuDef.GlobalSettings.forDebug.waterPoolVolumeRate;
                    this.currentWaterVolume *= MizuDef.GlobalSettings.forDebug.waterPoolVolumeRate;
                }
                if (MizuDef.GlobalSettings.forDebug.enableResetRegenRate)
                {
                    if (this.waterGrid is MapComponent_ShallowWaterGrid)
                    {
                        this.baseRegenRate        = MizuDef.GlobalSettings.forDebug.resetBaseRegenRateRangeForShallow.RandomInRange;
                        this.rainRegenRatePerCell = MizuDef.GlobalSettings.forDebug.resetRainRegenRatePerCellForShallow;
                    }
                    if (this.waterGrid is MapComponent_DeepWaterGrid)
                    {
                        this.baseRegenRate        = MizuDef.GlobalSettings.forDebug.resetBaseRegenRateRangeForDeep.RandomInRange;
                        this.rainRegenRatePerCell = MizuDef.GlobalSettings.forDebug.resetRainRegenRatePerCellForDeep;
                    }
                }
            }
        }
Beispiel #29
0
        public static WaterPreferability ToWaterPreferability(this WaterType waterType)
        {
            switch (waterType)
            {
            case WaterType.ClearWater:
                return(WaterPreferability.ClearWater);

            case WaterType.NormalWater:
                return(WaterPreferability.NormalWater);

            case WaterType.RawWater:
                return(WaterPreferability.RawWater);

            case WaterType.MudWater:
                return(WaterPreferability.MudWater);

            case WaterType.SeaWater:
                return(WaterPreferability.SeaWater);

            default:
                return(WaterPreferability.Undefined);
            }
        }
Beispiel #30
0
        public static ThingDef GetWaterThingDefFromWaterType(WaterType waterType)
        {
            // 水の種類→水アイテム
            switch (waterType)
            {
            case WaterType.ClearWater:
                return(MizuDef.Thing_ClearWater);

            case WaterType.NormalWater:
                return(MizuDef.Thing_NormalWater);

            case WaterType.RawWater:
                return(MizuDef.Thing_RawWater);

            case WaterType.MudWater:
                return(MizuDef.Thing_MudWater);

            case WaterType.SeaWater:
                return(MizuDef.Thing_SeaWater);

            default:
                return(null);
            }
        }
Beispiel #31
0
 public Water( WaterType type )
 {
     this.type = type;
 }
        //---------------------------------------------------------------------
        public static void Initialize(IInputParameters parameters)
        {
            //LitterParameters        = parameters.LitterParameters;
            LitterParameters = new LitterType[2];

            LitterType litterParmsSurface = new LitterType();
            LitterType litterParmsSoil = new LitterType();

            // Structural decomposition rate, the fraction of the pool that turns over each year.
            litterParmsSurface.DecayRateStrucC = 3.9;//DEC1(1)
            litterParmsSoil.DecayRateStrucC = 4.9; //DEC1(2)

            // Metabolic decomposition rate, the fraction of the pool that turns over each year.
            litterParmsSurface.DecayRateMetabolicC = 14.8; //DEC2(1)
            litterParmsSoil.DecayRateMetabolicC = 18.5; //DEC2(2)

            // Decomposition rate of organic matter with active turnover, the fraction of the pool
            // that turns over each year
            litterParmsSurface.DecayRateMicrobes = 6.0; //DEC3(1)
            litterParmsSoil.DecayRateMicrobes = 7.3; //DEC3(2)

            LitterParameters[0] = litterParmsSurface;
            LitterParameters[1] = litterParmsSoil;

            CalibrateMode       = parameters.CalibrateMode;
            WType = parameters.WType;
            //FractionSOM2toCO2   = parameters.FractionSOM2toCO2;
            //FractionSOM3toCO2   = parameters.FractionSOM3toCO2;
            //DecayRateSOM2       = parameters.DecayRateSOM2;
            //DecayRateSOM3       = parameters.DecayRateSOM3;
        }
Beispiel #33
0
 /// <summary>
 /// 构造函数 初始化生成图的宽高, 水印类型, 裁剪模式
 /// </summary>
 /// <param name="width">宽</param>
 /// <param name="height">高</param>
 /// <param name="type">水印类型</param>
 /// <param name="mode">裁剪模式</param>
 public mImage(int width, int height, int type, int mode)
 {
     widthImage = width;
     heightImage = height;
     this.cMode = (CutMode)mode;
     this.wType = (WaterType)type;
 }
Beispiel #34
0
        public static void AddWatermarkImage(string path, string targetPath, string markerfile, string character, WaterType wType, WatermarkPosition wp)
        {
            if (!File.Exists(path)) throw new FileNotFoundException((path == null ? "" : path) + " Not Find!");
            System.Drawing.Image originalImage = System.Drawing.Image.FromFile(path);

            //ImageCodecInfo ici = Getco
            long lngDefinition = 90;
            EncoderParameters parameters = new EncoderParameters(1);
            parameters.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, lngDefinition);
            int towidth = originalImage.Width;
            int toheight = originalImage.Height;

            //新建一个bmp图片
            System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(towidth, toheight, PixelFormat.Format32bppArgb);

            //新建一个画板
            System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap);

            //设置高质量插值法
            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;

            //设置高质量,低速度呈现平滑程度
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
            g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;

            //System.Drawing.Imaging.ImageCodecInfo codec = System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders()[1];
            //System.Drawing.Imaging.EncoderParameters eParams = new System.Drawing.Imaging.EncoderParameters(1);
            //eParams.Param[0] = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100L);

            //清空画布并以白色背景色填充
            g.Clear(System.Drawing.Color.White);

            g.DrawImage(originalImage, new System.Drawing.Rectangle(0, 0, towidth, toheight),
             new System.Drawing.Rectangle(0, 0, towidth, toheight),
             System.Drawing.GraphicsUnit.Pixel);

            if (wp != WatermarkPosition.None)
            {
                if (WaterType.Text == wType)
                {
                    if (character == null) character = "NULL";
                    AddWatermarkText(ref g, towidth, toheight, character, wp);
                }
                else if (markerfile != null)
                {
                    Image wimg = Image.FromFile(markerfile);
                    AddWatermarkImage(ref g, towidth, toheight, wimg, wp);
                }
            }
            try
            {
                SaveImage(bitmap, 100L, targetPath);
            }
            catch (System.Exception e)
            {
                throw e;
            }
            finally
            {
                originalImage.Dispose();
                bitmap.Dispose();
                g.Dispose();
            }
        }
Beispiel #35
0
        /// <summary>
        /// 水印图片
        /// 【如果图片需要缩略,请使用skeletonize.Resizepic()方法对图片进行缩略】
        /// 返回图片虚拟路径,和一个警告信息,可根据此信息获取图片合成信息
        /// </summary>
        /// <param name="picpath">需要水印的图片路径</param>
        /// <param name="waterspath">水印图片路径</param>
        /// <param name="watermodel">水印模式</param>
        /// <param name="spath">文件保存路径</param>
        /// <param name="imgtype">保存文件类型</param>
        /// <param name="filecache">原文件处理方式</param>
        /// <param name="warning">处理警告信息</param>
        /// <returns>错误,返回错误信息;成功,返回图片路径</returns>
        public static string makewatermark(string picpath, string waterspath, WaterType watermodel, string spath, ImageType imgtype, FileCache filecache, out string warning)
        {
            #region
            //反馈信息
            System.Text.StringBuilder checkmessage = new System.Text.StringBuilder();

            //检测源文件
            string _sourceimg_common_mappath = "";
            bool checkfile = false;

            //检测水印源文件
            string _sourceimg_water_mappath = "";
            bool checkfilewater = false;

            checkfile = FileExistMapPath(picpath, FileCheckModel.C, out _sourceimg_common_mappath);
            checkfilewater = FileExistMapPath(waterspath, FileCheckModel.C, out _sourceimg_water_mappath);

            System.Drawing.Image _sourceimg_common = null;
            System.Drawing.Image _sourceimg_water = null;

            if (checkfile == true)
            {
                //从指定源文件,创建image对象
                _sourceimg_common = System.Drawing.Image.FromFile(_sourceimg_common_mappath);
            }
            else
            {
                checkmessage.Append("error:找不到需要的水印图片!" + picpath + ";");
            }
            if (checkfilewater == true)
            {
                //从指定源文件,创建image对象
                _sourceimg_water = System.Drawing.Image.FromFile(_sourceimg_water_mappath);
            }
            else
            {
                checkmessage.Append("error:找不到需要水印图片!" + waterspath + ";");
            }
            #endregion

            #region
            if (string.IsNullOrEmpty(checkmessage.ToString()))
            {
                //源图宽、高
                int _sourceimg_common_width = _sourceimg_common.Width;
                int _sourceimg_common_height = _sourceimg_common.Height;

                //水印图片宽、高
                int _sourceimg_water_width = _sourceimg_water.Width;
                int _sourceimg_water_height = _sourceimg_water.Height;

                #region 水印坐标
                //水印坐标
                int _sourceimg_water_point_x = 0;
                int _sourceimg_water_point_y = 0;

                switch (watermodel)
                {
                    case WaterType.Center:
                        _sourceimg_water_point_x = (_sourceimg_common_width - _sourceimg_water_width) / 2;
                        _sourceimg_water_point_y = (_sourceimg_common_height - _sourceimg_water_height) / 2;
                        ; break;
                    case WaterType.CenterDown:
                        _sourceimg_water_point_x = (_sourceimg_common_width - _sourceimg_water_width) / 2;
                        _sourceimg_water_point_y = _sourceimg_common_height - _sourceimg_water_height;
                        ; break;
                    case WaterType.CenterUp:
                        _sourceimg_water_point_x = (_sourceimg_common_width - _sourceimg_water_width) / 2;
                        _sourceimg_water_point_y = 0;
                        ; break;
                    case WaterType.LeftDown:
                        _sourceimg_water_point_x = 0;
                        _sourceimg_water_point_y = _sourceimg_common_height - _sourceimg_water_height;
                        ; break;
                    case WaterType.LeftUp:
                        ; break;
                    case WaterType.Random:
                        Random r = new Random();
                        int x_random = r.Next(0, _sourceimg_common_width);
                        int y_random = r.Next(0, _sourceimg_common_height);

                        _sourceimg_water_point_x = x_random > (_sourceimg_common_width - _sourceimg_water_width)
                            ? _sourceimg_common_width - _sourceimg_water_width : x_random;

                        _sourceimg_water_point_y = y_random > (_sourceimg_common_height - _sourceimg_water_height)
                            ? _sourceimg_common_height - _sourceimg_water_height : y_random;

                        ; break;
                    case WaterType.RightDown:
                        _sourceimg_water_point_x = _sourceimg_common_width - _sourceimg_water_width;
                        _sourceimg_water_point_y = _sourceimg_common_height - _sourceimg_water_height;
                        ; break;
                    case WaterType.RightUp:
                        _sourceimg_water_point_x = _sourceimg_common_width - _sourceimg_water_width;
                        _sourceimg_water_point_y = 0;
                        ; break;
                }
                #endregion

                //从源图创建画板
                System.Drawing.Graphics _g_common = Graphics.FromImage(_sourceimg_common);

                //设置画笔
                _g_common.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;
                _g_common.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                _g_common.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half;

                //绘制水印图片
                _g_common.DrawImage(_sourceimg_water, new Rectangle(_sourceimg_water_point_x, _sourceimg_water_point_y, _sourceimg_water_width, _sourceimg_water_height), new Rectangle(0, 0, _sourceimg_water_width, _sourceimg_water_height), GraphicsUnit.Pixel);

                //保存图片
                string _spath_common_mappath = "";
                //全局文件名

                //获取图片类型的hashcode值,生成图片后缀名
                int extro = imgtype.GetHashCode();
                string extend = extro == 0 ? ".jpg" : (extro == 1 ? ".gif" : (extro == 2 ? ".png" : ".jpg"));

                spath = spath + Guid.NewGuid().ToString() + extend;

                FileExistMapPath(spath, FileCheckModel.M, out _spath_common_mappath);

                switch (imgtype)
                {
                    case ImageType.JPEG: _sourceimg_common.Save(_spath_common_mappath, System.Drawing.Imaging.ImageFormat.Jpeg); break;
                    case ImageType.GIF: _sourceimg_common.Save(_spath_common_mappath, System.Drawing.Imaging.ImageFormat.Gif); break;
                    case ImageType.PNG: _sourceimg_common.Save(_spath_common_mappath, System.Drawing.Imaging.ImageFormat.Png); break;
                }

                //释放
                _sourceimg_common.Dispose();
                _sourceimg_water.Dispose();
                _g_common.Dispose();

                //处理原文件
                int filecachecode = filecache.GetHashCode();
                //删除原文件
                if (filecachecode == 1)
                {
                    System.IO.File.Delete(_sourceimg_common_mappath);
                }

                warning = "";
                return spath;

            }
            #endregion

            //释放
            if (_sourceimg_common != null)
            {
                _sourceimg_common.Dispose();
            }
            if (_sourceimg_water != null)
            {
                _sourceimg_water.Dispose();
            }

            warning = checkmessage.ToString().TrimEnd(';');
            return "";
        }
        //---------------------------------------------------------------------
        public static void Initialize(IInputParameters parameters)
        {
            LitterParameters = new LitterType[2];

            LitterType litterParmsSurface = new LitterType();
            LitterType litterParmsSoil = new LitterType();

            // Structural decomposition rate, the fraction of the pool that turns over each year.
            litterParmsSurface.DecayRateStrucC = 3.9;//DEC1(1)
            litterParmsSoil.DecayRateStrucC = 4.9; //DEC1(2)

            // Metabolic decomposition rate, the fraction of the pool that turns over each year.
            //wangM. in V3 they used 1.48 and 1.85
            litterParmsSurface.DecayRateMetabolicC = 14.8; //DEC2(1)
            litterParmsSoil.DecayRateMetabolicC = 18.5; //DEC2(2)

            // Decomposition rate of organic matter with active turnover, the fraction of the pool
            // that turns over each year
            litterParmsSurface.DecayRateMicrobes = 3.84; //DEC3(1)
            litterParmsSoil.DecayRateMicrobes = 4.672; //DEC3(2)

            //wangM. new version 3 code
            /*
            litterParmsSurface.DecayRateMicrobes = 1.0; // 6.0; //DEC3(1)  set to 1.0 until meaning of 'fraction' is determined.
            litterParmsSoil.DecayRateMicrobes = 1.0; // 7.3; //DEC3(2)
            */

            LitterParameters[0] = litterParmsSurface;
            LitterParameters[1] = litterParmsSoil;

            CalibrateMode       = parameters.CalibrateMode;
            WType = parameters.WType;
            //ProbEstablishAdjust = parameters.ProbEstablishAdjustment;
            //FractionSOM2toCO2   = parameters.FractionSOM2toCO2;
            //FractionSOM3toCO2   = parameters.FractionSOM3toCO2;
            //DecayRateSOM2       = parameters.DecayRateSOM2;
            //DecayRateSOM3       = parameters.DecayRateSOM3;
        }
Beispiel #37
0
 public InjWell(int id, DateTime sprudDate, WaterType wt)
 {
     _id = id;
     _sprudDate = sprudDate;
     _waterType = wt;
 }
        //---------------------------------------------------------------------
        public static void Initialize(IInputParameters parameters)
        {
            LitterParameters = new LitterType[2];

            LitterType litterParmsSurface = new LitterType();
            LitterType litterParmsSoil = new LitterType();

            // Structural decomposition rate, the fraction of the pool that turns over each year.
            litterParmsSurface.DecayRateStrucC = 3.9;//DEC1(1)
            litterParmsSoil.DecayRateStrucC = 4.9; //DEC1(2)

            // Metabolic decomposition rate, the fraction of the pool that turns over each year.
            litterParmsSurface.DecayRateMetabolicC = 1.48; //DEC2(1)  //modified assuming they meant, 'percentage'
            litterParmsSoil.DecayRateMetabolicC = 1.85; //DEC2(2)  //modified assuming they meant, 'percentage'

            // Decomposition rate of organic matter with active turnover, the fraction of the pool
            // that turns over each year (SOM1)
            litterParmsSurface.DecayRateMicrobes = 1.0; // 6.0; //DEC3(1)  set to 1.0 until meaning of 'fraction' is determined.
            litterParmsSoil.DecayRateMicrobes = 1.0; // 7.3; //DEC3(2)

            LitterParameters[0] = litterParmsSurface;
            LitterParameters[1] = litterParmsSoil;

            CalibrateMode       = parameters.CalibrateMode;
            WType = parameters.WType;
            //ProbEstablishAdjust = parameters.ProbEstablishAdjustment;
            //FractionSOM2toCO2   = parameters.FractionSOM2toCO2;
            //FractionSOM3toCO2   = parameters.FractionSOM3toCO2;
            //DecayRateSOM2       = parameters.DecayRateSOM2;
            //DecayRateSOM3       = parameters.DecayRateSOM3;
        }
Beispiel #39
0
 public static void SetWater(MapData[,] heightMap, Vector2 pos, WaterType waterType)
 {
     int x = Math.Max(Math.Min((int) pos.X, heightMap.GetLength(0) - 1), 0);
     int y = Math.Max(Math.Min((int) pos.Y, heightMap.GetLength(1) - 1), 0);
     heightMap[x, y].Water = waterType;
 }