Example #1
0
    IEnumerator SpawnNewUnit(units unit)
    {
        yield return(new WaitForSeconds(spawnTime));

        GameObject spwned;

        switch (unit)
        {
        case units.alpha:
            spwned        = Instantiate(unitPrefab);
            alpha         = spwned;
            spawningAlpha = false;
            break;

        case units.beta:
            spwned       = Instantiate(unitPrefab);
            beta         = spwned;
            spawningBeta = false;
            break;

        case units.gamma:
            spwned        = Instantiate(unitPrefab);
            gamma         = spwned;
            spawningGamma = false;
            break;

        default:
            throw new System.Exception("unspecified unit attempted to spawn");
        }
        spwned.gameObject.transform.position = rallyPoint;
        BaseUnitVariables u = GameManager._AlliedUnit;

        spwned.GetComponent <AlliedUnit>().Setup(u.maxHealth, u.moveType, u.faction, u.moveSpeed, u.damage, u.cooldown);
    }
Example #2
0
 public RenderSpecs(Layout layout, double dheight, double dwidth) : this(layout)
 {
     _desiredHeight = dheight;
     _desiredWidth  = dwidth;
     _widthUnits    = units.pts;
     _heightUnits   = units.pts;
 }
Example #3
0
 // Start is called before the first frame update
 void Awake()
 {
     rbPlayer     = this.GetComponent <Rigidbody2D>();
     anim         = this.GetComponent <Animator>();
     attackScript = GetComponent <attack>();
     unitsScripts = GetComponent <units>();
     speed        = walkSpeed;
 }
Example #4
0
 public RenderSpecs(Layout layout, double dheight, double dwidth)
     : this(layout)
 {
     _desiredHeight = dheight;
     _desiredWidth = dwidth;
     _widthUnits = units.pts;
     _heightUnits = units.pts;
 }
Example #5
0
 public void setDimensions(double h, double w, units hunits, units wunits)
 {
     _desiredHeight = h;
     _desiredWidth  = w;
     _heightUnits   = hunits;
     _widthUnits    = wunits;
     _size          = findOptimalSize(_desiredHeight, hunits, _desiredWidth, wunits);
 }
        public async Task SQL_File_FileCaseFindMUId_doesFindMUId()
        {
            Random rnd   = new Random();
            sites  site1 = await testHelpers.CreateSite("MySite", 22);

            DateTime    cl1_Ca = DateTime.Now;
            DateTime    cl1_Ua = DateTime.Now;
            check_lists cl1    = await testHelpers.CreateTemplate(cl1_Ca, cl1_Ua, "template1", "template_desc", "", "", 1, 1);

            string guid = Guid.NewGuid().ToString();


            DateTime c1_ca  = DateTime.Now.AddDays(-9);
            DateTime c1_da  = DateTime.Now.AddDays(-8).AddHours(-12);
            DateTime c1_ua  = DateTime.Now.AddDays(-8);
            workers  worker = await testHelpers.CreateWorker("*****@*****.**", "Arne", "Jensen", 21);

            site_workers site_workers = await testHelpers.CreateSiteWorker(55, site1, worker);

            units unit = await testHelpers.CreateUnit(48, 49, site1, 348);

            string microtingUId     = Guid.NewGuid().ToString();
            string microtingCheckId = Guid.NewGuid().ToString();
            cases  aCase1           = await testHelpers.CreateCase("case1UId", cl1, c1_ca, "custom1",
                                                                   c1_da, worker, rnd.Next(1, 255), rnd.Next(1, 255),
                                                                   site1, 1, "caseType1", unit, c1_ua, 1, worker, Constants.WorkflowStates.Created);

            uploaded_data ud = new uploaded_data
            {
                Checksum     = "checksum1",
                Extension    = "extension",
                CurrentFile  = "currentFile1",
                UploaderId   = 223,
                UploaderType = "uploader_type",
                FileLocation = "url",
                FileName     = "fileName"
            };

            dbContext.uploaded_data.Add(ud);
            await dbContext.SaveChangesAsync().ConfigureAwait(false);

            field_values fVs = new field_values
            {
                UploadedDataId = ud.Id,
                CaseId         = aCase1.Id
            };

            dbContext.field_values.Add(fVs);
            await dbContext.SaveChangesAsync().ConfigureAwait(false);


            // Act
            await sut.FileCaseFindMUId("url");


            Assert.NotNull(fVs);
            Assert.AreEqual(fVs.CaseId, aCase1.Id);
        }
Example #7
0
            /// <summary>
            /// Converts the given angle to gradians
            /// </summary>
            /// /// <param name="angle">The angle value of type double.</param>
            /// <param name="angleUnit">An object of type AngleConverter.unit that specifies the units of the given angle.</param>
            /// <returns></returns>
            public static double gradians(double angle, units angleUnit)
            {
                // Avoid extra computation
                if (angleUnit == units.GRADIANS)
                {
                    return(angle);
                }

                return(degrees(angle, angleUnit) * 10 / 9);
            }
Example #8
0
            /// <summary>
            /// Converts the given angle to radians
            /// </summary>
            /// /// <param name="angle">The angle value of type double.</param>
            /// <param name="angleUnit">An object of type AngleConverter.unit that specifies the units of the given angle.</param>
            /// <returns></returns>
            public static double radians(double angle, units angleUnit)
            {
                // Avoid extra computation
                if (angleUnit == units.RADIANS)
                {
                    return(angle);
                }

                return(degrees(angle, angleUnit) * Math.PI / 180);
            }
Example #9
0
        private void widthUnitsChanged(ListBox sender, TextBox target, units newUnit, units oldUnit)
        {
            if (conv.specs == null)
            {
                return;
            }
            double value = RenderSpecs.convertLengthUnits(conv.specs.width, newUnit, oldUnit);

            target.Text = Math.Truncate(value).ToString();
        }
Example #10
0
 public RenderSpecs(Layout layout)
 {
     _desiredHeight = layout.Dimensions.Height;
     _desiredWidth = layout.Dimensions.Width;
     _height = layout.Dimensions.Height;
     _width = layout.Dimensions.Width;
     _widthUnits = units.pts;
     _heightUnits = units.pts;
     setStandardPageSizes();
     _size = findOptimalSize(_desiredHeight, units.pts, _desiredWidth, units.pts);
 }
Example #11
0
 public RenderSpecs(Layout layout)
 {
     _desiredHeight = layout.Dimensions.Height;
     _desiredWidth  = layout.Dimensions.Width;
     _height        = layout.Dimensions.Height;
     _width         = layout.Dimensions.Width;
     _widthUnits    = units.pts;
     _heightUnits   = units.pts;
     setStandardPageSizes();
     _size = findOptimalSize(_desiredHeight, units.pts, _desiredWidth, units.pts);
 }
Example #12
0
 Models.GameObject createUnit(units unitType)
 {
     switch (unitType)
     {
         case units.enemy:
             return new Models.Enemy();
         case units.player:
             return new Models.Player();
         default:
             return null;
     }
 }
Example #13
0
 private static double convertToCm(double value, units unit)
 {
     if (unit.Equals(units.inches))
     {
         value = value / 0.393700787;
     }
     if (unit.Equals(units.pts))
     {
         value = value / 28.3464567;
     }
     return(value);
 }
Example #14
0
 private static double convertToInches(double value, units unit)
 {
     if (unit.Equals(units.cm))
     {
         value = value * 0.393700787;
     }
     if (unit.Equals(units.pts))
     {
         value = value * 0.013836;
     }
     return(value);
 }
Example #15
0
 private static double convertToPoints(double value, units unit)
 {
     if (unit.Equals(units.inches))
     {
         value = value / 0.013836;
     }
     if (unit.Equals(units.cm))
     {
         value = value * 28.3464567;
     }
     return(value);
 }
Example #16
0
        public void SQL_File_FileCaseFindMUId_doesFindMUId()
        {
            sites       site1  = testHelpers.CreateSite("MySite", 22);
            DateTime    cl1_Ca = DateTime.Now;
            DateTime    cl1_Ua = DateTime.Now;
            check_lists cl1    = testHelpers.CreateTemplate(cl1_Ca, cl1_Ua, "template1", "template_desc", "", "", 1, 1);

            string guid = Guid.NewGuid().ToString();


            DateTime     c1_ca        = DateTime.Now.AddDays(-9);
            DateTime     c1_da        = DateTime.Now.AddDays(-8).AddHours(-12);
            DateTime     c1_ua        = DateTime.Now.AddDays(-8);
            workers      worker       = testHelpers.CreateWorker("*****@*****.**", "Arne", "Jensen", 21);
            site_workers site_workers = testHelpers.CreateSiteWorker(55, site1, worker);
            units        unit         = testHelpers.CreateUnit(48, 49, site1, 348);

            string microtingUId     = Guid.NewGuid().ToString();
            string microtingCheckId = Guid.NewGuid().ToString();
            cases  aCase1           = testHelpers.CreateCase("case1UId", cl1, c1_ca, "custom1",
                                                             c1_da, worker, "microtingCheckUId1", "microtingUId1",
                                                             site1, 1, "caseType1", unit, c1_ua, 1, worker, Constants.WorkflowStates.Created);

            uploaded_data ud = new uploaded_data();

            ud.checksum      = "checksum1";
            ud.extension     = "extension";
            ud.current_file  = "currentFile1";
            ud.uploader_id   = 223;
            ud.uploader_type = "uploader_type";
            ud.file_location = "url";
            ud.file_name     = "fileName";
            //ud.id = 111;

            DbContext.uploaded_data.Add(ud);
            DbContext.SaveChanges();

            field_values fVs = new field_values();

            fVs.uploaded_data_id = ud.id;
            fVs.case_id          = aCase1.id;

            DbContext.field_values.Add(fVs);
            DbContext.SaveChanges();


            //Act
            sut.FileCaseFindMUId("url");


            Assert.NotNull(fVs);
            Assert.AreEqual(fVs.case_id, aCase1.id);
        }
        private string numToString(double num, units unit, int decimals)
        {
            string[] value = { "" };

            if (unit == units.kN)
            {
                value = (num * Math.Pow(10, -3)).ToString().Split(',');
            }
            else if (unit == units.kNm)
            {
                value = (num * Math.Pow(10, -3)).ToString().Split(',');
            }
            else if (unit == units.mm)
            {
                value = (num * Math.Pow(10, 3)).ToString().Split(',');
            }
            else if (unit == units.mm2)
            {
                value = (num * Math.Pow(10, 6)).ToString().Split(',');
            }
            else if (unit == units.MPa)
            {
                value = (num * Math.Pow(10, -6)).ToString().Split(',');
            }
            else if (unit == units.none)
            {
                value = (num * Math.Pow(10, 0)).ToString().Split(',');
            }

            if (decimals == 0)
            {
                return(value[0]);
            }
            else
            {
                if (value.Length != 1 && value[1] != "")
                {
                    if (value[1].Length >= decimals)
                    {
                        return(value[0] + "," + value[1].Substring(0, decimals));
                    }
                    else
                    {
                        return((value[0] + "," + value[1]).PadRight(value[0].Length + decimals + 1, '0'));
                    }
                }
                else
                {
                    return((value[0] + ",").PadRight(value[0].Length + decimals + 1, '0'));
                }
            }
        }
Example #18
0
        Models.GameObject createUnit(units unitType)
        {
            switch (unitType)
            {
            case units.enemy:
                return(new Models.Enemy());

            case units.player:
                return(new Models.Player());

            default:
                return(null);
            }
        }
Example #19
0
        private void Frm_Products_Load(object sender, EventArgs e)
        {
            Txt_Category.Properties.DisplayMember = "name";
            Txt_Category.Properties.ValueMember   = "id";
            Txt_Category.ProcessNewValue         += Txt_Category_ProcessNewValue;
            Txt_Category.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;

            Txt_Type.Properties.DataSource    = Master.ProductTypesList;
            Txt_Type.Properties.DisplayMember = "name";
            Txt_Type.Properties.ValueMember   = "id";


            dgv.OptionsView.ShowGroupPanel     = false;
            dgv.OptionsView.NewItemRowPosition = NewItemRowPosition.Top;

            dgv.Columns[nameof(ins.id)].Visible        = false;
            dgv.Columns[nameof(ins.productid)].Visible = false;

            Grid_Units.RepositoryItems.Add(calcEdit);
            dgv.Columns[nameof(ins.sellprice)].ColumnEdit    = calcEdit;
            dgv.Columns[nameof(ins.buyprice)].ColumnEdit     = calcEdit;
            dgv.Columns[nameof(ins.factor)].ColumnEdit       = calcEdit;
            dgv.Columns[nameof(ins.selldiscount)].ColumnEdit = calcEdit;

            dgv.Columns[nameof(ins.unitid)].Caption       = "إسم الوحدة";
            dgv.Columns[nameof(ins.factor)].Caption       = "معالج التحويل";
            dgv.Columns[nameof(ins.buyprice)].Caption     = "سعر الشراء";
            dgv.Columns[nameof(ins.sellprice)].Caption    = "سعر البيع";
            dgv.Columns[nameof(ins.selldiscount)].Caption = "قيمة التخفيض";
            dgv.Columns[nameof(ins.barcode)].Caption      = "الباركود";

            Grid_Units.RepositoryItems.Add(upEdit);
            dgv.Columns[nameof(ins.unitid)].ColumnEdit = upEdit;

            var unit = new units();

            upEdit.ValueMember   = nameof(unit.id);
            upEdit.DisplayMember = nameof(unit.name);
            upEdit.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;

            upEdit.ProcessNewValue          += UpEdit_ProcessNewValue;
            dgv.ValidateRow                 += Dgv_ValidateRow;
            dgv.InvalidRowException         += Dgv_InvalidRowException;
            dgv.FocusedRowChanged           += Dgv_FocusedRowChanged;
            dgv.RowCellStyle                += Dgv_RowCellStyle;
            dgv.CustomDrawColumnHeader      += Dgv_CustomDrawColumnHeader;
            dgv.CustomRowCellEditForEditing += Dgv_CustomRowCellEditForEditing;
        }
Example #20
0
        public void Core_Advanced_UnitRequestOtp_SetsNewOtp()
        {
            //Arrance
            sites site = testHelpers.CreateSite("test site 1", 1313);
            units unit = testHelpers.CreateUnit(564646, 0, site, 0);

            //Act
            sut.Advanced_UnitRequestOtp((int)unit.microting_uid);

            //Assert
            List <units> matches = DbContext.units.AsNoTracking().ToList();

            Assert.NotNull(matches);
            Assert.AreEqual(1, matches.Count);
            Assert.AreEqual(558877, matches[0].otp_code);
        }
Example #21
0
        /// <summary>
        /// 从字节大小构建
        /// </summary>
        public FileLen(long len)
        {
            Len = len;

            int i = 0;

            Num = len;
            while (len >= 1024 && i <= (int)(units.DB))
            {
                Num = len / 1024f;
                len = (int)Num;
                i++;
            }
            Ext = (units)i;

            Str = Num.ToString("F2") + " " + Ext.ToString();
        }
    void battlesetup()
    {
        GameObject playergetComp = Instantiate(Playerpf, playerbs);

        player = playergetComp.GetComponent <units>();

        GameObject enemygetComp = Instantiate(Enemypf, enemybs);

        enemy = enemygetComp.GetComponent <units>();


        battletext.text = "Start";
        playerhud.SetHUD(player);
        enemyhud.SetHUD(enemy);
        state = Battle.PLAYERTURN;
        playerturn();
    }
Example #23
0
        public async Task Core_Advanced_UnitRequestOtp_SetsNewOtp()
        {
            // Arrange
            sites site = await testHelpers.CreateSite("test site 1", 1313);

            units unit = await testHelpers.CreateUnit(564646, 0, site, 0);

            // Act
            await sut.Advanced_UnitRequestOtp((int)unit.MicrotingUid);

            // Assert
            List <units> matches = dbContext.units.AsNoTracking().ToList();

            Assert.NotNull(matches);
            Assert.AreEqual(1, matches.Count);
            Assert.AreEqual(558877, matches[0].OtpCode);
        }
Example #24
0
            public static units CreateUnitsElement(Nullable <UnitsTypeEnum> ut,
                                                   String ucode,
                                                   String unitAbbreivation,
                                                   String unitName)
            {
                units u = new units();

                if (ut.HasValue)
                {
                    u.unitsType          = ut.Value;
                    u.unitsTypeSpecified = true;
                }
                u.unitsCode         = ucode;
                u.unitsAbbreviation = unitAbbreivation;
                u.Value             = unitName;

                return(u);
            }
Example #25
0
 private void UpEdit_ProcessNewValue(object sender, DevExpress.XtraEditors.Controls.ProcessNewValueEventArgs e)
 {
     if (e.DisplayValue is string st && st.Trim() != string.Empty)
     {
         var newObject = new units()
         {
             name = st.Trim()
         };
         using (SalesDataContext db = new SalesDataContext())
         {
             db.units.InsertOnSubmit(newObject);
             db.SubmitChanges();
         }
         ((List <units>)upEdit.DataSource).Add(newObject);
         ((List <units>)(((LookUpEdit)sender).Properties.DataSource)).Add(newObject);
         e.Handled = true;
     }
 }
        public async Task <units> CreateUnit(int microtingUId, int otpCode, sites site, int customerNo)
        {
            units unit = new units();

            unit.MicrotingUid  = microtingUId;
            unit.OtpCode       = otpCode;
            unit.Site          = site;
            unit.SiteId        = site.Id;
            unit.CreatedAt     = DateTime.UtcNow;
            unit.CustomerNo    = customerNo;
            unit.UpdatedAt     = DateTime.UtcNow;
            unit.Version       = 9;
            unit.WorkflowState = Constants.WorkflowStates.Created;

            dbContext.units.Add(unit);
            await dbContext.SaveChangesAsync().ConfigureAwait(false);

            return(unit);
        }
Example #27
0
        public units CreateUnit(int microtingUId, int otpCode, sites site, int customerNo)
        {
            units unit = new units();

            unit.microting_uid  = microtingUId;
            unit.otp_code       = otpCode;
            unit.site           = site;
            unit.site_id        = site.id;
            unit.created_at     = DateTime.Now;
            unit.customer_no    = customerNo;
            unit.updated_at     = DateTime.Now;
            unit.version        = 9;
            unit.workflow_state = Constants.WorkflowStates.Created;

            DbContext.units.Add(unit);
            DbContext.SaveChanges();

            return(unit);
        }
        [Test]//Using Communicatorn needs httpMock
        public async Task Core_Site_SiteUpdate_returnsTrue()
        {
            // Arrange
            // Arrange
            #region site
            string siteName         = Guid.NewGuid().ToString();
            int    siteMicrotingUid = 1; // This needs to be 1 for our tests to pass through the FakeHttp
            // TODO: Improve the test for supporting random id.

            sites site = await testHelpers.CreateSite(siteName, siteMicrotingUid);

            SiteNameDto siteName_Dto = new SiteNameDto((int)site.MicrotingUid, site.Name, site.CreatedAt, site.UpdatedAt);
            #endregion

            #region worker
            string email     = Guid.NewGuid().ToString();
            string firstName = Guid.NewGuid().ToString();
            string lastName  = Guid.NewGuid().ToString();
            //int workerMicrotingUid = await testHelpers.GetRandomInt();
            int workerMicrotingUid = 1; // This needs to be 1 for our tests to pass through the FakeHttp
            // TODO: Improve the test for supporting random id.

            workers worker = await testHelpers.CreateWorker(email, firstName, lastName, workerMicrotingUid);

            #endregion

            #region site_worker
            site_workers site_worker = await testHelpers.CreateSiteWorker(1, site, worker);

            #endregion

            #region unit
            units unit = await testHelpers.CreateUnit(1, 1, site, 1);

            #endregion


            var match = await sut.SiteUpdate((int)site.MicrotingUid, site.Name, firstName, lastName, email);

            // Assert
            Assert.True(match);
        }
Example #29
0
        public static double convertLengthUnits(double value, units newUnit, units oldUnit)
        {
            if (newUnit.Equals(oldUnit))
            {
                return(value);
            }

            switch (newUnit)
            {
            case units.pts:
                return(convertToPoints(value, oldUnit));

            case units.inches:
                return(convertToInches(value, oldUnit));

            case units.cm:
                return(convertToCm(value, oldUnit));
            }
            return(0);
        }
Example #30
0
 /// <summary>
 /// Converts the given angle to degrees
 /// </summary>
 /// /// <param name="angle">The angle value of type double.</param>
 /// <param name="angleUnit">An object of type AngleConverter.unit that specifies the units of the given angle.</param>
 /// <returns></returns>
 public static double degrees(double angle, units angleUnit)
 {
     if (angleUnit == units.RADIANS)
     {
         return(angle * 180 / Math.PI);
     }
     else if (angleUnit == units.GRADIANS)
     {
         return(angle * 9 / 10);
     }
     else if (angleUnit == units.DEGREES)
     {
         return(angle);
     }
     else
     {
         Exception error = new Exception("Invalid parameters");
         throw error;
     }
 }
        public static units getUnitsElement(string unitsID, unitsDataset ds)
        {
            DataRow[] dr = ds.Tables["units"].Select("unitID = " + unitsID);

            if (dr.Length > 0)
            {
                unitsDataset.UnitsRow row = (unitsDataset.UnitsRow)dr[0];
                string uID        = row.UnitsID.ToString();
                string unitType   = String.IsNullOrEmpty(row.UnitsType) ? null : row.UnitsType;
                string unitAbbrev = String.IsNullOrEmpty(row.UnitsAbbreviation) ? null : row.UnitsAbbreviation;
                string unitName   = String.IsNullOrEmpty(row.UnitsName) ? null : row.UnitsName;

                units u = CuahsiBuilder.CreateUnitsElement(null, uID, unitAbbrev, unitName);
                return(u);
            }
            else
            {
                return(null);
            }
        }
Example #32
0
            public static VariableInfoType CreateVariableInfoType(
                string oid,
                string vocab,
                string vCode,
                string vName,
                string vDescription,
                units aUnit)
            {
                VariableInfoType vdt = CreateVariableDescriptionType();

                vdt.variableCode[0].Value            = vCode;
                vdt.variableCode[0].vocabulary       = vocab;
                vdt.variableCode[0].variableID       = oid;
                vdt.variableCode[0].defaultSpecified = true;
                vdt.variableCode[0].@default         = true;
                vdt.variableDescription = vDescription;
                vdt.variableName        = vName;
                vdt.units = aUnit;

                return(vdt);
            }
Example #33
0
        /// <summary>
        /// 从字符串构建, str形如"32.14 MB"
        /// </summary>
        public FileLen(string str)
        {
            string[] tmp = str.Split(' ');
            if (tmp.Length != 2)
            {
                return;
            }

            Str = str;
            Num = float.Parse(tmp[0]);
            Ext = (units)Enum.Parse(typeof(units), tmp[1]);

            Len = (long)Num;
            int i = (int)Ext;

            while (i > 0)
            {
                Len *= 1024;
                i--;
            }
        }
        /* Read a specific sample for a specified unit in a RAW format */
        /* Returns MinValue if fails */
        public short readRawValue(units unitType, sample sampleNum)
        {
            short result = short.MinValue;
            commands command = commands.CMD_UNKNOWN;

            switch (unitType)
            {
                case units.TEMPERATURE:
                    command = commands.CMD_GETTEMP_C_RAW;
                    break;

                case units.HUMIDITY:
                    command = commands.CMD_GETHUM_RAW;
                    break;

                case units.PRESSURE:
                    command = commands.CMD_GETPRESS_RAW;
                    break;
            }

            this.sendCommand(command, (Byte)sampleNum);
            if (this.readAnswer(command))
            {
                result = this.decodeShortValue();
            }

            return result;
        }
        /* Read an averaged value of specified unit (or MinValue if fails) */
        public float readAveragedValue(units unitType)
        {
            float result = float.MinValue;
            commands command = commands.CMD_UNKNOWN;

            switch (unitType)
            {
                case units.TEMPERATURE:
                    command = commands.CMD_GETTEMP_C_AVG;
                    break;

                case units.HUMIDITY:
                    command = commands.CMD_GETHUM_AVG;
                    break;

                case units.PRESSURE:
                    command = commands.CMD_GETPRESS_AVG;
                    break;
            }

            this.sendCommand(command, 0);
            if (this.readAnswer(command))
            {
                result = this.decodeFloatValue();
            }

            return result;
        }
Example #36
0
 /// <summary>
 /// Create a new units object.
 /// </summary>
 /// <param name="id">Initial value of id.</param>
 public static units Createunits(long id)
 {
     units units = new units();
     units.id = id;
     return units;
 }
Example #37
0
 private void widthUnitsChanged(ListBox sender, TextBox target, units newUnit, units oldUnit)
 {
     if (conv.specs == null) return;
     double value = RenderSpecs.convertLengthUnits(conv.specs.width, newUnit, oldUnit);
     target.Text = Math.Truncate(value).ToString();
 }
Example #38
0
        private papersize findOptimalSize(double height, units heightunits, double width, units widthunits)
        {
            double heightInInches = RenderSpecs.convertToInches(height, heightunits);
            double widthInInches = RenderSpecs.convertToInches(width, widthunits);

            int heightSize = 5;
            int widthSize = 5;
            for (int ii = 0; ii < allPaperHeightsInInch.Length-1; ii++)
            {
                if (heightInInches < allPaperHeightsInInch[ii] && heightInInches > allPaperHeightsInInch[ii + 1])
                {
                    heightSize = ii;
                }
                if (widthInInches < allPaperWidthsInInch[ii] && widthInInches > allPaperWidthsInInch[ii + 1])
                {
                    widthSize = ii;
                }
            }
            return (papersize) (Math.Min(heightSize, widthSize));
        }
Example #39
0
 /// <summary>
 /// There are no comments for units in the schema.
 /// </summary>
 public void AddTounits(units units)
 {
     base.AddObject("units", units);
 }
            public static units CreateUnitsElement(Nullable<UnitsTypeEnum> ut,
                                             String ucode,
                                             String unitAbbreivation,
                                             String unitName)
            {
                units u = new units();
                if (ut.HasValue)
                {
                u.unitsType = ut.Value;
                u.unitsTypeSpecified = true;
                } else
                {
                u.unitsTypeSpecified = false;
                }
                u.unitsCode = ucode;
                u.unitsAbbreviation = unitAbbreivation;
                u.Value = unitName;

                return u;
            }
Example #41
0
        public static double convertLengthUnits(double value, units newUnit, units oldUnit)
        {
            if (newUnit.Equals(oldUnit))
                return value;

            switch (newUnit)
            {
                case units.pts:
                    return convertToPoints(value, oldUnit);

                case units.inches:
                    return convertToInches(value, oldUnit);

                case units.cm:
                    return convertToCm(value, oldUnit);
            }
            return 0;
        }
Example #42
0
 public void setDimensions(double h, double w, units hunits, units wunits)
 {
     _desiredHeight = h;
     _desiredWidth = w;
     _heightUnits = hunits;
     _widthUnits = wunits;
     _size = findOptimalSize(_desiredHeight, hunits, _desiredWidth, wunits);
 }
        public override void CheckAndApplyCollision(units.PhysicalUnit unit)
        {
            Projectile p;
            for (int i = 0 ; i < _projectiles.Length ; i++)
            {
                p = _projectiles[i];
                if (_projectiles[i].Active)
                {
                    _hitDetectionRect.X = (int)_projectiles[i].Position.X;
                    _hitDetectionRect.Y = (int)_projectiles[i].Position.Y;
                    if (XnaHelper.RectsCollide(unit.HitRect, _hitDetectionRect))
                    {
                        applyProjectileHit(_projectiles[i], unit);
                    }
                }
                if (_projectiles[i].Splashing && _projectiles[i].ReadyToSplash)
                {
                    _splashDetectionRect.X = (int)_projectiles[i].Position.X;
                    _splashDetectionRect.Y = (int)_projectiles[i].Position.Y;
                    _splashDetectionRect.Width = (int)(_splashRadius * 2);
                    _splashDetectionRect.Height = (int)(_splashRadius * 2);
                    if (XnaHelper.RectsCollide(unit.HitRect, _splashDetectionRect))
                    {
                        unit.ApplyDamage(_splashDamage);
                        unit.ApplyForce(_splashForce * XnaHelper.DirectionBetween(_projectiles[i].Position, unit.Center));
                    }

                }
            }
        }
Example #44
0
 private static double convertToInches(double value, units unit)
 {
     if (unit.Equals(units.cm))
     {
         value = value * 0.393700787;
     }
     if (unit.Equals(units.pts))
     {
         value = value * 0.013836;
     }
     return value;
 }
Example #45
0
 private static double convertToPoints(double value, units unit)
 {
     if (unit.Equals(units.inches))
     {
         value = value / 0.013836;
     }
     if (unit.Equals(units.cm))
     {
         value = value * 28.3464567;
     }
     return value;
 }
            public static VariableInfoType CreateVariableInfoType(
            string oid,
            string vocab,
            string vCode,
            string vName,
            string vDescription,
            units aUnit)
            {
                VariableInfoType vdt = CreateVariableDescriptionType();
                vdt.variableCode[0].Value = vCode;
                vdt.variableCode[0].vocabulary = vocab;
                vdt.variableCode[0].variableID = oid;
                vdt.variableCode[0].defaultSpecified = true;
                vdt.variableCode[0].@default = true;
                vdt.variableDescription = vDescription;
                vdt.variableName = vName;
                vdt.units = aUnit;

                return vdt;
            }
Example #47
0
 private static double convertToCm(double value, units unit)
 {
     if (unit.Equals(units.inches))
     {
         value = value / 0.393700787;
     }
     if (unit.Equals(units.pts))
     {
         value = value / 28.3464567;
     }
     return value;
 }