Beispiel #1
0
        public void Read(out double Value, out UnitEnum Unit)
        {
            Value = double.NaN;
            Unit  = UnitEnum.dBm;

            var monkey = _query(CMD_READ);

            // split the value and the unit.
            var pig = monkey.Split(' ');

            try
            {
                var dog = Convert.ToDouble(pig[0]);
                Unit = (UnitEnum)Enum.Parse(typeof(UnitEnum), pig[1]);

                // filter the power.
                Value = fir_filter.Filter(dog);

                //if (Unit != UnitEnum.dBm)
                //    Value /= 1000;
            }
            catch
            {
                _throw_excpetion(monkey);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="TaskReminder" /> class.
 /// </summary>
 /// <param name="value">Value of time unit before reminder is to be sent (required).</param>
 /// <param name="unit">Unit of time before reminder is to be sent (required).</param>
 /// <param name="types">Type of task reminder (required).</param>
 public TaskReminder(int?value = default(int?), UnitEnum unit = default(UnitEnum), List <string> types = default(List <string>))
 {
     // to ensure "value" is required (not null)
     if (value == null)
     {
         throw new InvalidDataException("value is a required property for TaskReminder and cannot be null");
     }
     else
     {
         this.Value = value;
     }
     // to ensure "unit" is required (not null)
     if (unit == null)
     {
         throw new InvalidDataException("unit is a required property for TaskReminder and cannot be null");
     }
     else
     {
         this.Unit = unit;
     }
     // to ensure "types" is required (not null)
     if (types == null)
     {
         throw new InvalidDataException("types is a required property for TaskReminder and cannot be null");
     }
     else
     {
         this.Types = types;
     }
 }
Beispiel #3
0
        public static double FormatNumericValue(UnitEnum unit, double value)
        {
            switch (unit)
            {
            case UnitEnum.Number:
                return(value);

            case UnitEnum.Byte:
                return(value);

            case UnitEnum.Kilobyte:
                return(value / 1024.0);

            case UnitEnum.Megabyte:
                return(value / (1024.0 * 1024.0));

            case UnitEnum.Gigabyte:
                return(value / (1024.0 * 1024.0 * 1024.0));

            case UnitEnum.Second:
                return(value);

            case UnitEnum.Minute:
                return(value / 60.0);

            case UnitEnum.Hour:
                return(value / 3600.0);

            default:
                throw new ArgumentException("Invalid Unit in GetValueForNameAndDate", unit.ToString());
            }
        }
Beispiel #4
0
        public double?GetValueForNameAndDateInterpolated(string name, DateTime date, UnitEnum unit)
        {
            date = date.Date;

            DateTime prevDate  = date;
            DateTime nextDate  = date;
            double?  prevValue = null;
            double?  nextValue = null;

            do
            {
                prevDate  = prevDate.AddDays(-1);
                prevValue = GetValueForNameAndDate(name, prevDate, unit);
            } while ((prevValue == null) && (prevDate >= FromDate));

            do
            {
                nextDate  = nextDate.AddDays(+1);
                nextValue = GetValueForNameAndDate(name, nextDate, unit);
            } while ((nextValue == null) && (nextDate <= ToDate));

            if ((nextValue != null) && (prevValue != null))
            {
                return(prevValue + (nextValue - prevValue) / ((nextDate - prevDate).TotalDays * (date - prevDate).TotalDays));
            }

            return(null);
        }
Beispiel #5
0
        /// <summary>
        /// Gets the units from inputs to see
        /// what they are measured from and to
        /// </summary>
        public void GetUnit()
        {
            Console.WriteLine(" Please Enter 2 different Distance Units" +
                              " to measure from and to");

            FromUnit = Distance.ElementAt(ConsoleHelper.SelectChoice(" Please select the from distance unit \n", Measurement) - 1).Key;
            ToUnit   = Distance.ElementAt(ConsoleHelper.SelectChoice(" Please select the to distance unit \n", Measurement) - 1).Key;
        }
Beispiel #6
0
        public static Unit CreateUnit(UnitEnum unitType, double xPos, double yPos)
        {
            string className = "kipschieten.View." + unitType.ToString();

            Type t = Type.GetType(className);

            return(Activator.CreateInstance(t, xPos, yPos) as Unit);
        }
Beispiel #7
0
        public double?GetValueForNameAndDate(string name, DateTime date, UnitEnum unit)
        {
            var dateDict = this._internalDictionary[name];

            if (dateDict.ContainsKey(date))
            {
                return(FormatNumericValue(unit, dateDict[date]));
            }

            return(null);
        }
 // GET: Formulas/Create
 public ActionResult Create()
 {
     ViewBag.Sidebar = true;
     ViewBag.ActiveSidebar = "Formulas";
     ViewBag.LinkedFormulaID = new SelectList(db.Formulas, "FormulaID", "Name");
     ChartType chartTypes = new ChartType();
     ViewBag.ChartType = chartTypes.ToSelectList();
     UnitEnum unitEnum = new UnitEnum();
     ViewBag.Unit = unitEnum.ToSelectList();
     return View();
 }
Beispiel #9
0
 /// <summary>获取时间单位,如果时间单位为null,则返回defaultUnit</summary>
 /// <param name="defaultUnit"></param>
 /// <returns></returns>
 public UnitEnum getUnit(UnitEnum defaultUnit)
 {
     if (Unit == UnitEnum.Null)
     {
         return(defaultUnit);
     }
     else
     {
         return(Unit);
     }
 }
Beispiel #10
0
        public void GetUnit(out UnitEnum Unit)
        {
            Unit = UnitEnum.dBm;
            var monkey = _query($"{CMD_UNIT}?");

            try
            {
                Unit = (UnitEnum)Enum.Parse(typeof(UnitEnum), monkey);
            }
            catch
            {
                _throw_excpetion(monkey);
            }
        }
Beispiel #11
0
        /// <summary>获取换算成毫秒的时间间隔值</summary>
        /// <param name="defaultUnit"></param>
        /// <returns></returns>
        public long getDurationInMilliseconds(UnitEnum defaultUnit)
        {
            int      value = Value;
            UnitEnum unit  = getUnit(defaultUnit);

            if (value == 0)
            {
                return(value);
            }
            else
            {
                long duration = value * toMilliseconds(unit);
                return(duration);
            }
        }
Beispiel #12
0
        /// <summary>
        /// Format the optical power value accorrding to the Unit and Range.
        /// </summary>
        /// <param name="Unit"></param>
        /// <param name="Range"></param>
        /// <param name="Power"></param>
        /// <param name="Formatted"></param>
        public static void FormatOutputPower(UnitEnum Unit, RangeEnum Range, double Power, out string Formatted)
        {
            Formatted = "";

            switch (Unit)
            {
            case UnitEnum.dBm:
                Formatted = Power.ToString("F3");
                break;

            case UnitEnum.W:
            case UnitEnum.A:
            case UnitEnum.V:
                var tmp = Power.ToString("F10");
                Formatted = tmp.Remove(tmp.Length - 1 - (int)Range);
                break;
            }
        }
 public void SpawnUnit(UnitEnum unitEnum, Vector3 unitPos)
 {
     for (int i = 0; i < UnitPrefabDataList.Count; i++)
     {
         if (UnitPrefabDataList[i].type == unitEnum)
         {
             // if (money >= UnitPrefabDataList[i].unitValue)
             // {
             GameObject clone = Instantiate(UnitPrefabDataList[i].prefab);
             clone.transform.position = unitPos;
             UnitManager unitManager = clone.GetComponent <UnitManager>();
             unitManager.unitPos   = unitPos;
             unitManager.unitPrice = UnitPrefabDataList[i].unitValue;
             SpendMoney(UnitPrefabDataList[i].unitValue);
             // }
         }
     }
 }
        public ActionResult Create([Bind(Include = "FormulaID,Name,Description,ChartType,Unit,LinkedFormulaID,ToolTipDescription")] Formula formula)
        {
            ViewBag.Sidebar = true;
            ViewBag.ActiveSidebar = "Formulas";
            if (ModelState.IsValid)
            {
                db.Formulas.Add(formula);
                db.SaveChanges();
                return RedirectToAction("Index", new {status = "new" });
            }

            ViewBag.LinkedFormulaID = new SelectList(db.Formulas, "FormulaID", "Name",formula.LinkedFormulaID);
            ChartType chartTypes = formula.ChartType;
            ViewBag.ChartType = chartTypes.ToSelectList();
            UnitEnum unitEnum = new UnitEnum();
            ViewBag.Unit = unitEnum.ToSelectList();

            return View(formula);
        }
Beispiel #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StakepoolsMargin" /> class.
 /// </summary>
 /// <param name="quantity">quantity (required).</param>
 /// <param name="unit">unit (required).</param>
 public StakepoolsMargin(decimal?quantity = default(decimal?), UnitEnum unit = default(UnitEnum))
 {
     // to ensure "quantity" is required (not null)
     if (quantity == null)
     {
         throw new InvalidDataException("quantity is a required property for StakepoolsMargin and cannot be null");
     }
     else
     {
         this.Quantity = quantity;
     }
     // to ensure "unit" is required (not null)
     if (unit == null)
     {
         throw new InvalidDataException("unit is a required property for StakepoolsMargin and cannot be null");
     }
     else
     {
         this.Unit = unit;
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ApiNetworkParametersActiveSlotCoefficient" /> class.
 /// </summary>
 /// <param name="quantity">quantity (required).</param>
 /// <param name="unit">unit (required).</param>
 public ApiNetworkParametersActiveSlotCoefficient(decimal?quantity = default(decimal?), UnitEnum unit = default(UnitEnum))
 {
     // to ensure "quantity" is required (not null)
     if (quantity == null)
     {
         throw new InvalidDataException("quantity is a required property for ApiNetworkParametersActiveSlotCoefficient and cannot be null");
     }
     else
     {
         this.Quantity = quantity;
     }
     // to ensure "unit" is required (not null)
     if (unit == null)
     {
         throw new InvalidDataException("unit is a required property for ApiNetworkParametersActiveSlotCoefficient and cannot be null");
     }
     else
     {
         this.Unit = unit;
     }
 }
Beispiel #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ApiNetworkParametersEpochLength" /> class.
 /// </summary>
 /// <param name="quantity">quantity (required).</param>
 /// <param name="unit">unit (required).</param>
 public ApiNetworkParametersEpochLength(int?quantity = default(int?), UnitEnum unit = default(UnitEnum))
 {
     // to ensure "quantity" is required (not null)
     if (quantity == null)
     {
         throw new InvalidDataException("quantity is a required property for ApiNetworkParametersEpochLength and cannot be null");
     }
     else
     {
         this.Quantity = quantity;
     }
     // to ensure "unit" is required (not null)
     if (unit == null)
     {
         throw new InvalidDataException("unit is a required property for ApiNetworkParametersEpochLength and cannot be null");
     }
     else
     {
         this.Unit = unit;
     }
 }
Beispiel #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StakepoolsMetricsProducedBlocks" /> class.
 /// </summary>
 /// <param name="quantity">quantity (required).</param>
 /// <param name="unit">unit (required).</param>
 public StakepoolsMetricsProducedBlocks(int?quantity = default(int?), UnitEnum unit = default(UnitEnum))
 {
     // to ensure "quantity" is required (not null)
     if (quantity == null)
     {
         throw new InvalidDataException("quantity is a required property for StakepoolsMetricsProducedBlocks and cannot be null");
     }
     else
     {
         this.Quantity = quantity;
     }
     // to ensure "unit" is required (not null)
     if (unit == null)
     {
         throw new InvalidDataException("unit is a required property for StakepoolsMetricsProducedBlocks and cannot be null");
     }
     else
     {
         this.Unit = unit;
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ApiWalletMigrationInfoMigrationCost" /> class.
 /// </summary>
 /// <param name="quantity">quantity (required).</param>
 /// <param name="unit">unit (required).</param>
 public ApiWalletMigrationInfoMigrationCost(int?quantity = default(int?), UnitEnum unit = default(UnitEnum))
 {
     // to ensure "quantity" is required (not null)
     if (quantity == null)
     {
         throw new InvalidDataException("quantity is a required property for ApiWalletMigrationInfoMigrationCost and cannot be null");
     }
     else
     {
         this.Quantity = quantity;
     }
     // to ensure "unit" is required (not null)
     if (unit == null)
     {
         throw new InvalidDataException("unit is a required property for ApiWalletMigrationInfoMigrationCost and cannot be null");
     }
     else
     {
         this.Unit = unit;
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ByronwalletsBalanceTotal" /> class.
 /// </summary>
 /// <param name="quantity">quantity (required).</param>
 /// <param name="unit">unit (required).</param>
 public ByronwalletsBalanceTotal(int?quantity = default(int?), UnitEnum unit = default(UnitEnum))
 {
     // to ensure "quantity" is required (not null)
     if (quantity == null)
     {
         throw new InvalidDataException("quantity is a required property for ByronwalletsBalanceTotal and cannot be null");
     }
     else
     {
         this.Quantity = quantity;
     }
     // to ensure "unit" is required (not null)
     if (unit == null)
     {
         throw new InvalidDataException("unit is a required property for ByronwalletsBalanceTotal and cannot be null");
     }
     else
     {
         this.Unit = unit;
     }
 }
Beispiel #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WalletswalletIdpaymentfeesAmount" /> class.
 /// </summary>
 /// <param name="quantity">quantity (required).</param>
 /// <param name="unit">unit (required).</param>
 public WalletswalletIdpaymentfeesAmount(int?quantity = default(int?), UnitEnum unit = default(UnitEnum))
 {
     // to ensure "quantity" is required (not null)
     if (quantity == null)
     {
         throw new InvalidDataException("quantity is a required property for WalletswalletIdpaymentfeesAmount and cannot be null");
     }
     else
     {
         this.Quantity = quantity;
     }
     // to ensure "unit" is required (not null)
     if (unit == null)
     {
         throw new InvalidDataException("unit is a required property for WalletswalletIdpaymentfeesAmount and cannot be null");
     }
     else
     {
         this.Unit = unit;
     }
 }
Beispiel #22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WalletsBalanceAvailable" /> class.
 /// </summary>
 /// <param name="quantity">quantity (required).</param>
 /// <param name="unit">unit (required).</param>
 public WalletsBalanceAvailable(long?quantity = default(long?), UnitEnum unit = default(UnitEnum))
 {
     // to ensure "quantity" is required (not null)
     if (quantity == null)
     {
         throw new InvalidDataException("quantity is a required property for WalletsBalanceAvailable and cannot be null");
     }
     else
     {
         this.Quantity = quantity;
     }
     // to ensure "unit" is required (not null)
     if (unit == null)
     {
         throw new InvalidDataException("unit is a required property for WalletsBalanceAvailable and cannot be null");
     }
     else
     {
         this.Unit = unit;
     }
 }
Beispiel #23
0
        public long toMilliseconds(UnitEnum unit)
        {
            switch (unit)
            {
            case UnitEnum.Null: return(0L);

            case UnitEnum.YEAR: return(365 * 30 * 24 * 60 * 60 * 1000L);

            case UnitEnum.MONTH: return(30 * 24 * 60 * 60 * 1000L);

            case UnitEnum.WEEK: return(7 * 24 * 60 * 60 * 1000L);

            case UnitEnum.DAY: return(24 * 60 * 60 * 1000L);

            case UnitEnum.HOUR: return(60 * 60 * 1000L);

            case UnitEnum.MINUTE: return(60 * 1000L);

            case UnitEnum.SECOND: return(1 * 1000L);

            default: return(0L);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ProductForm" /> class.
        /// </summary>
        /// <param name="number">number(Produktnummer). \&quot;number\&quot; is a mandatory field when saving a product. If a new product is created and no \&quot;number\&quot; provided a value is generated and assigned to the product automatically..</param>
        /// <param name="name">name(Bezeichnung).</param>
        /// <param name="description">description(Beschreibung).</param>
        /// <param name="typeDisplay">typeDisplay(Produktart), default value is \&quot;Ware\&quot; if not set by the user..</param>
        /// <param name="invoicePostingMode">invoicePostingMode(Zuordnung Rechnungsart), default value is \&quot;Einzel-/Teil-/Schlussrechnung\&quot; if not set by the user  .</param>
        /// <param name="taxRate">taxRate(Steuersatz), default value is 0% if not set by the user..</param>
        /// <param name="revenueAccountMode">revenueAccountMode(0 &#x3D; Standard-Erlöskonten verwenden, 1 &#x3D; Manuelle Erlöskonten verwenden). If revenue accounts are provided (\&quot;revenueAccount0\&quot;, etc.), it is set automatically to 1. Default value is 0 Standard-Erlöskonten verwenden) if not set by the user explicitly. .</param>
        /// <param name="revenueAccount0">revenueAccount0(Manuelle erlöskonten verwenden - Inland).</param>
        /// <param name="revenueAccount1">revenueAccount1(Manuelle erlöskonten verwenden - EU Ausland).</param>
        /// <param name="revenueAccount2">revenueAccount2(Manuelle erlöskonten verwenden - Ausland).</param>
        /// <param name="revenueAccount3">revenueAccount3(Manuelle erlöskonten verwenden - Abschlagsrechnungen).</param>
        /// <param name="unit">Unit(Einheit). For more untits please check the Scopevisio client application, catalog Abrechnungsbelege -&gt; Einheit. (required).</param>
        /// <param name="asIfSold">asIfSold(As-if-sold) (default to false).</param>
        /// <param name="billable">billable(Fakturierbar) (default to false).</param>
        /// <param name="locked">locked(Gesperrt) (default to false).</param>
        /// <param name="planValue">planValue(Planwert).</param>
        /// <param name="costPrice">costPrice(Einkaufspreis).</param>
        /// <param name="singleAmount">singleAmount(Netto Preisgruppe 1).</param>
        /// <param name="singleAmount2">singleAmount2(Netto Preisgruppe 2).</param>
        /// <param name="singleAmount3">singleAmount3(Netto Preisgruppe 3).</param>
        /// <param name="singleAmountGross">singleAmountGross(Brutto Preisgruppe 1).</param>
        /// <param name="singleAmountGross2">singleAmountGross2(Brutto Preisgruppe 2).</param>
        /// <param name="singleAmountGross3">singleAmountGross3(Brutto Preisgruppe 3).</param>
        /// <param name="nameLng1">nameLng1(Englisch Bezeichnung).</param>
        /// <param name="descriptionLng1">descriptionLng1(Englisch Beschreibung).</param>
        /// <param name="productGroupName">productGroupName(Produktgruppen).</param>
        public ProductForm(string number = default(string), string name = default(string), string description = default(string), TypeDisplayEnum?typeDisplay = default(TypeDisplayEnum?), InvoicePostingModeEnum?invoicePostingMode = default(InvoicePostingModeEnum?), decimal taxRate = default(decimal), RevenueAccountModeEnum?revenueAccountMode = default(RevenueAccountModeEnum?), string revenueAccount0 = default(string), string revenueAccount1 = default(string), string revenueAccount2 = default(string), string revenueAccount3 = default(string), UnitEnum unit = default(UnitEnum), bool asIfSold = false, bool billable = false, bool locked = false, decimal planValue = default(decimal), decimal costPrice = default(decimal), decimal singleAmount = default(decimal), decimal singleAmount2 = default(decimal), decimal singleAmount3 = default(decimal), decimal singleAmountGross = default(decimal), decimal singleAmountGross2 = default(decimal), decimal singleAmountGross3 = default(decimal), string nameLng1 = default(string), string descriptionLng1 = default(string), string productGroupName = default(string))
        {
            // to ensure "unit" is required (not null)
            if (unit == null)
            {
                throw new InvalidDataException("unit is a required property for ProductForm and cannot be null");
            }
            else
            {
                this.Unit = unit;
            }

            this.Number             = number;
            this.Name               = name;
            this.Description        = description;
            this.TypeDisplay        = typeDisplay;
            this.InvoicePostingMode = invoicePostingMode;
            this.TaxRate            = taxRate;
            this.RevenueAccountMode = revenueAccountMode;
            this.RevenueAccount0    = revenueAccount0;
            this.RevenueAccount1    = revenueAccount1;
            this.RevenueAccount2    = revenueAccount2;
            this.RevenueAccount3    = revenueAccount3;
            // use default value if no "asIfSold" provided
            if (asIfSold == null)
            {
                this.AsIfSold = false;
            }
            else
            {
                this.AsIfSold = asIfSold;
            }
            // use default value if no "billable" provided
            if (billable == null)
            {
                this.Billable = false;
            }
            else
            {
                this.Billable = billable;
            }
            // use default value if no "locked" provided
            if (locked == null)
            {
                this.Locked = false;
            }
            else
            {
                this.Locked = locked;
            }
            this.PlanValue          = planValue;
            this.CostPrice          = costPrice;
            this.SingleAmount       = singleAmount;
            this.SingleAmount2      = singleAmount2;
            this.SingleAmount3      = singleAmount3;
            this.SingleAmountGross  = singleAmountGross;
            this.SingleAmountGross2 = singleAmountGross2;
            this.SingleAmountGross3 = singleAmountGross3;
            this.NameLng1           = nameLng1;
            this.DescriptionLng1    = descriptionLng1;
            this.ProductGroupName   = productGroupName;
        }
Beispiel #25
0
 /// <summary>获取时间单位,如果时间单位为null,则返回defaultUnit</summary>
 /// <param name="defaultUnit"></param>
 /// <returns></returns>
 public UnitEnum getUnit(UnitEnum defaultUnit)
 {
     if (Unit == UnitEnum.Null)
     {
         return defaultUnit;
     }
     else
     {
         return Unit;
     }
 }
Beispiel #26
0
 /// <summary>获取换算成毫秒的时间间隔值</summary>
 /// <param name="defaultUnit"></param>
 /// <returns></returns>
 public long getDurationInMilliseconds(UnitEnum defaultUnit)
 {
     int value = Value;
     UnitEnum unit = getUnit(defaultUnit);
     if (value == 0)
     {
         return value;
     }
     else
     {
         long duration = value * toMilliseconds(unit);
         return duration;
     }
 }
Beispiel #27
0
    public static void DoubleToStrUnitKeepNumber(double number, int keepNumber, out string outNumberStr, out UnitEnum outUnit)
    {
        string numberStr = number.ToString("f0");

        outUnit = GetUnitByLength(numberStr.Length);
        string tempNumberStr = number.ToString("f" + keepNumber + "");

        switch (outUnit)
        {
        case UnitEnum.None:
            outNumberStr = string.Format("{0:N" + keepNumber + "}", double.Parse(tempNumberStr));
            break;

        case UnitEnum.Max:
            outNumberStr = "∞";
            break;

        default:
            double tempNumber = (number / Math.Pow(10, 6 + (int)(outUnit - 1) * 3));
            outNumberStr = Math.Truncate(tempNumber * 1000) / 1000 + "";
            break;
        }
    }
 public void CreateUnit(UnitEnum unitType, Vector3 unitPosition)
 {
     unitPosition = new Vector3(unitPosition.x, 0.5f, unitPosition.z);
     SpawnUnit(unitType, unitPosition);
 }
 // GET: Formulas/Edit/5
 public ActionResult Edit(int? id)
 {
     ViewBag.Sidebar = true;
     ViewBag.ActiveSidebar = "Formulas";
     if (id == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     Formula formula = db.Formulas.Find(id);
     if (formula == null)
     {
         return HttpNotFound();
     }
     ViewBag.LinkedFormulaID = new SelectList(db.Formulas, "FormulaID", "Name", formula.LinkedFormulaID);
     ChartType chartTypes = formula.ChartType;
     ViewBag.ChartType = chartTypes.ToSelectList();
     UnitEnum unitEnum = new UnitEnum();
     SelectList unitSelectList = unitEnum.ToSelectList();
     //unitSelectList.SelectedValue = formula.Unit;
     //ViewBag.Unit = unitSelectList;
     return View(formula);
 }
Beispiel #30
0
        public void SetUnit(UnitEnum Unit)
        {
            var cmd = $"{CMD_UNIT} {Unit}";

            _write(cmd);
        }
Beispiel #31
0
 /// <summary>
 /// Double转换成带单位的字符
 /// </summary>
 /// <param name="number"></param>
 /// <param name="outNumberStr"></param>
 /// <param name="outUnit"></param>
 public static void DoubleToStrUnit(double number, out string outNumberStr, out UnitEnum outUnit)
 {
     DoubleToStrUnitKeepNumber(number, 0, out outNumberStr, out outUnit);
 }
Beispiel #32
0
        private void LoadTiles(string fileName)
        {
            string[] loadPathDirs      = fileName.Split('\\');
            string   relativeNotesPath = "notes_" + loadPathDirs.Last();

            string notesLoadPath = "";

            foreach (string dir in loadPathDirs)
            {
                if (dir != loadPathDirs.Last())
                {
                    notesLoadPath += dir + '\\';
                }
            }

            notesLoadPath += relativeNotesPath;

            using (StreamReader sr = new StreamReader(fileName)) {
                // Exception: Get first two lines differently
                // Line 1
                string   line        = sr.ReadLine();
                string[] line1Values = line.Split(' ');
                levelWidthInTiles  = Convert.ToInt32(line1Values[0]);
                levelHeightInTiles = Convert.ToInt32(line1Values[1]);

                textboxLevelWidth.Text  = levelWidthInTiles.ToString();
                textboxLevelHeight.Text = levelHeightInTiles.ToString();
                textboxNumLayers.Text   = (line1Values.Length - 2).ToString();

                // Line 2
                line = sr.ReadLine();
                Console.WriteLine(line);

                setImageSource(line);
                createTables();

                int count = 0;

                while ((line = sr.ReadLine()) != null)
                {
                    string[] splitLine = line.Split(' ');

                    if (splitLine[0].StartsWith("-"))
                    {
                        int skipValue = int.Parse(splitLine[0].Split('-').Last());
                        count += skipValue;
                        continue;
                    }

                    List <Button> buttonsAtLocation = new List <Button>(numLayers);
                    for (int i = 0; i < numLayers; i++)
                    {
                        buttonsAtLocation.Add(gameboardButtons[i][count]);
                    }

                    List <Tile> tilesAtLocation = new List <Tile>(numLayers);
                    for (int i = 0; i < numLayers; i++)
                    {
                        tilesAtLocation.Add(null);
                    }

                    int       currentLayer        = 0;
                    const int tileCoordFirstIndex = 10;
                    int       tileCoordLastIndex  = tileCoordFirstIndex - 1 + numLayers * 2;
                    for (int i = tileCoordFirstIndex; i <= tileCoordLastIndex; i++)
                    {
                        if (i >= splitLine.Length)
                        {
                            break;
                        }

                        if (splitLine[i] == "-1")
                        {
                            tileCoordLastIndex--;
                            currentLayer++;
                            continue;
                        }

                        if (i + 1 >= splitLine.Length)
                        {
                            Console.WriteLine("Looking past splitLine's length for the y-coord of a tile. This shouldn't happen.");
                            break;
                        }

                        tilesAtLocation[currentLayer] = srcTiles.SingleOrDefault(t => t.x * tileWidth == int.Parse(splitLine[i]) && t.y * tileHeight == int.Parse(splitLine[i + 1]));
                        currentLayer++;
                        i++;
                    }

                    UnitEnum unit = UnitEnum.None;
                    ItemEnum item = ItemEnum.None;

                    unit = (UnitEnum)Enum.Parse(typeof(UnitEnum), splitLine[8]);
                    item = (ItemEnum)Enum.Parse(typeof(ItemEnum), splitLine[9]);

                    // If has unit or item, indicate this via string in the button
                    // For now, let's assume that the best button to indicate this in is in the foremost layer
                    if (unit != UnitEnum.None)
                    {
                        foreach (Button button in buttonsAtLocation)
                        {
                            button.Content = unit.ToString();
                        }

                        int numNullsAtLocation    = numLayers - tilesAtLocation.Count(tile => tile != null);
                        int numNotNullsAtLocation = numLayers - numNullsAtLocation;

                        // If moving platform, set up that object as well
                        if (unit == UnitEnum.MovingPlatformRed || unit == UnitEnum.MovingPlatformPink)
                        {
                            int            platformDestFirstIndex = tileCoordFirstIndex + numNotNullsAtLocation * 2 + numNullsAtLocation;
                            MovingPlatform platform = GetOrCreatePlatform(count);

                            // Read in destinations from the last expected property to the end of the line
                            for (int i = platformDestFirstIndex; i < splitLine.Length; i += 2)
                            {
                                platform.tileDests.Add(new Tuple <int, int>(int.Parse(splitLine[i]), int.Parse(splitLine[i + 1])));
                            }

                            for (int i = 0; i < platform.tileDests.Count; i++)
                            {
                                Button destButton = (Button)FindName("levelTile" + GetButtonIndexFromCoordinates(platform.tileDests[i]));
                                destButton.Content = "D" + (i + 1);
                            }

                            platforms.Add(platform);
                        }
                    }
                    if (item != ItemEnum.None)
                    {
                        foreach (Button button in buttonsAtLocation)
                        {
                            button.Content = item.ToString();
                        }
                    }

                    // Set location properties
                    LocationData location = locations[count];
                    if (location != null)
                    {
                        location.unit = unit;
                        location.item = item;
                    }

                    // Set button images for each tile at location
                    for (int i = 0; i < tilesAtLocation.Count; i++)
                    {
                        if (tilesAtLocation[i] != null)
                        {
                            buttonsAtLocation[i].Background = new ImageBrush(tilesAtLocation[i].image.Source);
                        }
                    }

                    int?lastNonNullIndex = null;
                    for (int i = 0; i < tilesAtLocation.Count; i++)
                    {
                        if (tilesAtLocation[i] == null)
                        {
                            continue;
                        }

                        placedTiles[i][count] = tilesAtLocation[i];
                        lastNonNullIndex      = i;
                    }

                    // Set foremost-layer tile's properties
                    if (lastNonNullIndex.HasValue)
                    {
                        Tile lastTile = placedTiles[lastNonNullIndex.Value][count];
                        lastTile.leftHeight      = int.Parse(splitLine[0]);
                        lastTile.rightHeight     = int.Parse(splitLine[1]);
                        lastTile.topCollision    = splitLine[2].ToString() == "1" ? true : false;
                        lastTile.rightCollision  = splitLine[3].ToString() == "1" ? true : false;
                        lastTile.bottomCollision = splitLine[4].ToString() == "1" ? true : false;
                        lastTile.leftCollision   = splitLine[5].ToString() == "1" ? true : false;
                        lastTile.isEdge          = splitLine[6].ToString() == "1" ? true : false;

                        // Mutex properties will default to false, so only need to think about setting them to true
                        string mutexProperty = splitLine[7].ToString();
                        if (mutexProperty == "1")
                        {
                            lastTile.isPole = true;
                        }
                        else if (mutexProperty == "2")
                        {
                            lastTile.isPoleEdge = true;
                        }
                        else if (mutexProperty == "3")
                        {
                            lastTile.isDeadly = true;
                        }
                    }

                    count++;
                }
            }

            Console.WriteLine("File loaded.");
            isLevelLoaded = true;
        }
Beispiel #33
0
 public long toMilliseconds(UnitEnum unit)
 {
     switch (unit)
     {
         case UnitEnum.Null: return 0L;
         case UnitEnum.YEAR: return 365 * 30 * 24 * 60 * 60 * 1000L;
         case UnitEnum.MONTH: return 30 * 24 * 60 * 60 * 1000L;
         case UnitEnum.WEEK: return 7 * 24 * 60 * 60 * 1000L;
         case UnitEnum.DAY: return 24 * 60 * 60 * 1000L;
         case UnitEnum.HOUR: return 60 * 60 * 1000L;
         case UnitEnum.MINUTE: return 60 * 1000L;
         case UnitEnum.SECOND: return 1 * 1000L;
         default: return 0L;
     }
 }
Beispiel #34
0
 /// <summary>创建时间间隔对象</summary>
 /// <param name="value">时间值</param>
 /// <param name="unit">时间单位</param>
 public Duration(int value, UnitEnum unit)
 {
     this.Value = value;
     this.Unit = unit;
     this.IsBusinessTime = true;
 }
Beispiel #35
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Frequency" /> class.
 /// </summary>
 /// <param name="every">Rate of frequency. (required).</param>
 /// <param name="unit">Unit which defines the frequency. (required).</param>
 public Frequency(int every = default(int), UnitEnum unit = default(UnitEnum))
 {
     this.Every = every;
     this.Unit  = unit;
 }
namespace ifc {//==============================
    public class ifcUnitAtribute : Attribute { public ifcUnitAtribute(UnitEnum eUnitEnum = UnitEnum.USERDEFINED, DerivedUnitEnum eDerivedUnitEnum = DerivedUnitEnum.USERDEFINED)
                                               {
                                                   this.eUnitEnum = eUnitEnum; this.eDerivedUnitEnum = eDerivedUnitEnum;
                                               }
Beispiel #37
0
 /// <summary>创建时间间隔对象</summary>
 /// <param name="value">时间值</param>
 /// <param name="unit">时间单位</param>
 public Duration(int value, UnitEnum unit)
 {
     this.Value          = value;
     this.Unit           = unit;
     this.IsBusinessTime = true;
 }