Ejemplo n.º 1
0
        private Unit CreateUnit(UnitConfig unitConfig, Vector3 position, UnitsManager unitsManager, ProjectilesManager projectilesManager)
        {
            Rigidbody instance;

            if (unitConfig.OnlyOne)
            {
                instance = Instantiate(unitConfig.Prefab, _unitsRoot);
            }
            else
            {
                if (!_unitPools.TryGetValue(unitConfig, out var pool))
                {
                    pool = new GameObjectPool <Rigidbody>(_unitsRoot, unitConfig.Prefab, 5);
                    _unitPools.Add(unitConfig, pool);
                }

                instance = pool.GetObject();
            }

            instance.transform.position = position;
            instance.gameObject.SetActive(true);

            var unit = unitConfig.CreateUnit(instance, unitsManager, projectilesManager);

            unit.Config = unitConfig;
            return(unit);
        }
Ejemplo n.º 2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            try
            {
                // show case in uCtrlCaseOrientation
                if (!(Globals.StackBuilderAddIn.Application.ActiveSheet is Excel.Worksheet xlSheet))
                {
                    return;
                }
                var caseLength = ReadDouble(xlSheet, Settings.Default.CellCaseLength, Resources.ID_CASE_LENGTH);
                var caseWidth  = ReadDouble(xlSheet, Settings.Default.CellCaseWidth, Resources.ID_CASE_WIDTH);
                var caseHeight = ReadDouble(xlSheet, Settings.Default.CellCaseHeight, Resources.ID_CASE_HEIGHT);

                var bProperties = new BoxProperties(null, caseLength, caseWidth, caseHeight);
                bProperties.SetColor(Color.Chocolate);
                bProperties.TapeWidth            = new OptDouble(true, UnitsManager.ConvertLengthFrom(50.0, UnitsManager.UnitSystem.UNIT_METRIC1));
                bProperties.TapeColor            = Color.Beige;
                uCtrlCaseOrientation.BProperties = bProperties;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Ejemplo n.º 3
0
        public FormNewPalletCap(Document document, PalletCapProperties capProperties)
            : base(document, capProperties)
        {
            InitializeComponent();
            // units
            UnitsManager.AdaptUnitLabels(this);

            if (null != capProperties)
            {
                CapLength = capProperties.Length;
                CapWidth  = capProperties.Width;
                CapHeight = capProperties.Height;

                CapInnerLength = capProperties.InsideLength;
                CapInnerWidth  = capProperties.InsideWidth;
                CapInnerHeight = capProperties.InsideHeight;

                CapWeight = capProperties.Weight;
                CapColor  = capProperties.Color;
            }
            else
            {
                CapLength = UnitsManager.ConvertLengthFrom(1200.0, UnitsManager.UnitSystem.UNIT_METRIC1);
                CapWidth  = UnitsManager.ConvertLengthFrom(1000.0, UnitsManager.UnitSystem.UNIT_METRIC1);
                CapHeight = UnitsManager.ConvertLengthFrom(50.0, UnitsManager.UnitSystem.UNIT_METRIC1);

                CapWeight = UnitsManager.ConvertSurfaceMassFrom(0.5, UnitsManager.UnitSystem.UNIT_METRIC1);
                CapColor  = Color.Khaki;
            }
            UpdateStatus(string.Empty);
        }
Ejemplo n.º 4
0
 public void TargetTellClientToFindNewPathForUnit(NetworkConnection target, Vector3 finalTarget)
 {
     //if (isLocalPlayer)
     //{
     UnitsManager.MakeActiveUnitMove_CLIENT(finalTarget);
     //  }
 }
Ejemplo n.º 5
0
 private void Start()
 {
     unitsManager  = FindObjectOfType <UnitsManager>();
     healthCanvas  = background.GetComponentInParent <Canvas>();
     controller    = transform.GetComponentInParent <UnitController>();
     currentHealth = MaxHealth;
 }
Ejemplo n.º 6
0
        public FormNewPallet(Document document, PalletProperties palletProperties)
            : base(document, palletProperties)
        {
            InitializeComponent();

            // fill type combo
            cbType.Items.AddRange(PalletData.TypeNames);
            // initialize data
            if (null != palletProperties)
            {
                PalletTypeName = palletProperties.TypeName;
                PalletLength   = palletProperties.Length;
                PalletWidth    = palletProperties.Width;
                PalletHeight   = palletProperties.Height;
                Weight         = palletProperties.Weight;
                PalletColor    = palletProperties.Color;
                AdmissibleLoad = palletProperties.AdmissibleLoadWeight;
            }
            else
            {
                // set selected item
                PalletTypeName = Properties.Settings.Default.PalletTypeName;
                OnPalletTypeChanged(this, null);
            }
            // set unit labels
            UnitsManager.AdaptUnitLabels(this);
        }
Ejemplo n.º 7
0
        public Unit StartLevel(UnitsManager unitsManager, ProjectilesManager projectilesManager)
        {
            var  positions  = RandomHelper.ShuffleList(_spawnPositions);
            var  nextPosIdx = 0;
            Unit player     = null;

            foreach (var ally in _allias)
            {
                var unit = CreateUnit(ally, positions[nextPosIdx++], unitsManager, projectilesManager);
                unit.Fraction = 0;
                unitsManager.Add(unit);
                if (ally.OnlyOne)
                {
                    player = unit;
                }
            }

            foreach (var enemy in _enemies)
            {
                var unit = CreateUnit(enemy, positions[nextPosIdx++], unitsManager, projectilesManager);
                unit.Fraction = 1;
                unitsManager.Add(unit);
            }

            unitsManager.UnitKilled += OnUnitKilled;

            return(player);
        }
Ejemplo n.º 8
0
 private void FormNewAnalysis_FormClosing(object sender, FormClosingEventArgs e)
 {
     try
     {
         // overhang
         Settings.Default.OverhangX = OverhangX;
         Settings.Default.OverhangY = OverhangY;
         // allowed position box
         Settings.Default.AllowVerticalX = AllowVerticalX;
         Settings.Default.AllowVerticalY = AllowVerticalY;
         Settings.Default.AllowVerticalZ = AllowVerticalZ;
         // alternate / aligned layers
         Settings.Default.AllowAlignedLayer   = AllowAlignedLayers;
         Settings.Default.AllowAlternateLayer = AllowAlternateLayers;
         // allowed patterns
         Settings.Default.AllowedPatterns = AllowedPatternsString;
         // Maximum pallet height / weight
         Settings.Default.MaximumPalletHeight = UnitsManager.ConvertLengthTo(MaximumPalletHeight, UnitsManager.UnitSystem.UNIT_METRIC1);
         Settings.Default.MaximumPalletWeight = UnitsManager.ConvertMassTo(MaximumPalletWeight, UnitsManager.UnitSystem.UNIT_METRIC1);
         // window position
         if (null == Settings.Default.FormNewAnalysisPosition)
         {
             Settings.Default.FormNewAnalysisPosition = new WindowSettings();
         }
         Settings.Default.FormNewAnalysisPosition.Record(this);
     }
     catch (Exception ex)
     { _log.Error(ex.ToString()); }
 }
Ejemplo n.º 9
0
        private void UpdateThicknesses(object sender, EventArgs e)
        {
            NumericUpDown nud = sender as NumericUpDown;

            if (null != nud)
            {
                double thickness = UnitsManager.ConvertLengthFrom(5.0, UnitsManager.UnitSystem.UNIT_METRIC1);
                if (nudCapLength == nud && CapLength > thickness)
                {
                    CapInnerLength = CapLength - thickness;
                }
                if (nudCapWidth == nud && CapWidth > thickness)
                {
                    CapInnerWidth = CapWidth - thickness;
                }
                if (nudCapHeight == nud && CapHeight > thickness)
                {
                    CapInnerHeight = CapHeight - thickness;
                }
            }
            // update
            UpdateStatus(string.Empty);
            // draw cap
            graphCtrl.Invalidate();
        }
Ejemplo n.º 10
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            // Graphics3DControl
            graphCtrl.DrawingContainer = this;
            graphCtrl.AngleHoriz       = 270.0;

            if (null != Item)
            {
                PalletLabelProperties palletLabel = Item as PalletLabelProperties;
                Color      = palletLabel.Color;
                Dimensions = palletLabel.Dimensions;
                Weight     = palletLabel.Weight;
                Bitmap     = palletLabel.Bitmap;
            }
            else
            {
                Color      = Color.White;
                Dimensions = new Vector2D(
                    UnitsManager.ConvertLengthFrom(210, UnitsManager.UnitSystem.UNIT_METRIC1),
                    UnitsManager.ConvertLengthFrom(297, UnitsManager.UnitSystem.UNIT_METRIC1));
                Weight = 0.0;
                Bitmap = Resources.PalletLabelDefault;
            }
        }
Ejemplo n.º 11
0
 public FormNewBag(Document document, BagProperties bag)
     : base(document, bag)
 {
     InitializeComponent();
     if (DesignMode)
     {
         return;
     }
     // properties
     if (null != bag)
     {
         uCtrlOuterDimensions.ValueX = bag.Length;
         uCtrlOuterDimensions.ValueY = bag.Width;
         uCtrlOuterDimensions.ValueZ = bag.Height;
         uCtrlRadius.Value           = bag.Radius;
         uCtrlWeight.Value           = bag.Weight;
         uCtrlNetWeight.Value        = bag.NetWeight;
         cbColor.Color = bag.ColorFill;
     }
     else
     {
         uCtrlOuterDimensions.ValueX = UnitsManager.ConvertLengthFrom(400.0, UnitsManager.UnitSystem.UNIT_METRIC1);
         uCtrlOuterDimensions.ValueY = UnitsManager.ConvertLengthFrom(300.0, UnitsManager.UnitSystem.UNIT_METRIC1);
         uCtrlOuterDimensions.ValueZ = UnitsManager.ConvertLengthFrom(100.0, UnitsManager.UnitSystem.UNIT_METRIC1);
         uCtrlRadius.Value           = UnitsManager.ConvertLengthFrom(40.0, UnitsManager.UnitSystem.UNIT_METRIC1);
         uCtrlWeight.Value           = UnitsManager.ConvertMassFrom(1.0, UnitsManager.UnitSystem.UNIT_METRIC1);
         uCtrlNetWeight.Value        = OptDouble.Zero;
         cbColor.Color = Color.Beige;
     }
     // units
     UnitsManager.AdaptUnitLabels(this);
 }
Ejemplo n.º 12
0
 public PickupsManager(UnitsManager unitsManager, UserInfo userInfo, Pickup pickupPrefab)
 {
     _unitsManager             = unitsManager;
     _userInfo                 = userInfo;
     _unitsManager.UnitKilled += OnUnitKilled;
     _pickupsPool              = new GameObjectPool <Pickup>(new GameObject("Pickups").transform, pickupPrefab, 5);
 }
Ejemplo n.º 13
0
        private void FillPalletList()
        {
            int rangeIndex    = 0;
            int numberOfItems = 0;

            using (WCFClient wcfClient = new WCFClient())
            {
                do
                {
                    DCSBPallet[] dcsbPallets = wcfClient.Client.GetAllPallets(rangeIndex++, ref numberOfItems);
                    foreach (var dcsbPallet in dcsbPallets)
                    {
                        UnitsManager.UnitSystem us = (UnitsManager.UnitSystem)dcsbPallet.UnitSystem;
                        var palletProperties       = new PalletProperties(null,
                                                                          dcsbPallet.PalletType,
                                                                          UnitsManager.ConvertLengthFrom(dcsbPallet.Dimensions.M0, us),
                                                                          UnitsManager.ConvertLengthFrom(dcsbPallet.Dimensions.M1, us),
                                                                          UnitsManager.ConvertLengthFrom(dcsbPallet.Dimensions.M2, us)
                                                                          )
                        {
                            Color  = Color.FromArgb(dcsbPallet.Color),
                            Weight = UnitsManager.ConvertMassFrom(dcsbPallet.Weight, us)
                        };
                        palletProperties.ID.SetNameDesc(dcsbPallet.Name, dcsbPallet.Description);

                        lbPallets.Items.Add(new ItemBaseWrapper(palletProperties), true);
                    }
                }while ((rangeIndex + 1) * 20 < numberOfItems);
            }
        }
Ejemplo n.º 14
0
        private void StartDynamo()
        {
            Level defaultLevel = null;
            var   fecLevel     = new FilteredElementCollector(RevitData.Document.Document);

            fecLevel.OfClass(typeof(Level));

            dynRevitSettings.Revit        = RevitData.Application;
            dynRevitSettings.Doc          = RevitData.Document;
            dynRevitSettings.DefaultLevel = defaultLevel;

            var units = new UnitsManager
            {
                HostApplicationInternalAreaUnit   = DynamoAreaUnit.SquareFoot,
                HostApplicationInternalLengthUnit = DynamoLengthUnit.DecimalFoot,
                HostApplicationInternalVolumeUnit = DynamoVolumeUnit.CubicFoot
            };

            //create dynamo
            var    r       = new Regex(@"\b(Autodesk |Structure |MEP |Architecture )\b");
            string context = r.Replace(RevitData.Application.Application.VersionName, "");

            var dynamoController = new DynamoController_Revit(DynamoRevitApp.env, DynamoRevitApp.Updater, typeof(DynamoRevitViewModel), context, units);

            DynamoController.IsTestMode = true;
        }
Ejemplo n.º 15
0
        public void CmdPerfomAttack(string defenderId, Team attackerTeam, float attackPoints)
        {
            GameActor defender = UnitsManager.GetInstance().GetByUniqueNetworkId(defenderId);

            if (defender == null)
            {
                defender = BuildingsManager.GetInstance().GetByUniqueNetworkId(defenderId);
            }

            VisibleLogger.GetInstance().LogDebug(
                string.Format("Damage [{0}] for {1}",
                              defender.GetId()
                              , attackPoints
                              ));

            defender.ActorAttributes.HealthPoints -= attackPoints;

            if (HpLessThanZero(defender) && defender.LifeState == GameActor.UnitLifeState.LIVING)
            {
                VisibleLogger.GetInstance().LogDebug(
                    string.Format("Changing [{0}] state {1} -> {2}",
                                  defender.GetId()
                                  , defender.LifeState,
                                  GameActor.UnitLifeState.WAITING_FOR_DEAD_ACTION
                                  ));

                PlayersManager.GetInstance().Get(attackerTeam).Gold += defender.ActorAttributes.KillReward;

                defender.LifeState = GameActor.UnitLifeState.WAITING_FOR_DEAD_ACTION;
            }
        }
Ejemplo n.º 16
0
        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);

            // save settings
            // default pallet height
            Settings.Default.PalletHeight = MaximumPalletHeight;
            // default wall numbers and thickness
            Settings.Default.OptHasWrapper     = HasWrapper;
            Settings.Default.NumberWallsLength = uCtrlWrapperWalls.NoX;
            Settings.Default.NumberWallsWidth  = uCtrlWrapperWalls.NoY;
            Settings.Default.NumberWallsHeight = uCtrlWrapperWalls.NoZ;
            Settings.Default.WrapperThickness  = WrapperWallThickness;
            Settings.Default.WrapperSurfMass   = WrapperWallSurfMass;

            Settings.Default.OptHasTray    = HasTray;
            Settings.Default.TrayThickness = UnitsManager.ConvertLengthTo(TrayWallThickness, UnitsManager.UnitSystem.UNIT_METRIC1);
            Settings.Default.TrayHeight    = UnitsManager.ConvertLengthTo(TrayHeight, UnitsManager.UnitSystem.UNIT_METRIC1);

            // default number of boxes
            Settings.Default.NumberBoxesPerCase = (int)nudNumber.Value;
            // default wrapper type
            Settings.Default.WrapperType = cbWrapperType.SelectedIndex;
            // window position
            Settings.Default.FormOptimizeCasePosition ??= new WindowSettings();
            Settings.Default.FormOptimizeCasePosition.Record(this);
        }
Ejemplo n.º 17
0
        public FormNewPalletFilm(Document doc, PalletFilmProperties item)
            : base(doc, item)
        {
            InitializeComponent();

            if (null != item)
            {
                chkbTransparency.Checked = item.UseTransparency;
                chkbHatching.Checked     = item.UseHatching;
                HatchSpacing             = UnitsManager.ConvertLengthFrom(item.HatchSpacing, UnitsManager.UnitSystem.UNIT_METRIC1);
                HatchAngle = item.HatchAngle;
                FilmColor  = item.Color;
                Weight     = item.Weight;
            }
            else
            {
                chkbTransparency.Checked = true;
                chkbHatching.Checked     = true;
                HatchSpacing             = UnitsManager.ConvertLengthFrom(150.0, UnitsManager.UnitSystem.UNIT_METRIC1);
                HatchAngle = 45.0;
                FilmColor  = Color.LightSkyBlue;
            }
            OnChkbHatchingCheckedChanged(this, null);
            UpdateStatus(string.Empty);
            // units
            UnitsManager.AdaptUnitLabels(this);
        }
Ejemplo n.º 18
0
        private void UpdateThicknesses(object sender, EventArgs e)
        {
            UCtrlTriDouble uCtrlDim = sender as UCtrlTriDouble;

            if (null != uCtrlDim)
            {
                double thickness = UnitsManager.ConvertLengthFrom(5.0, UnitsManager.UnitSystem.UNIT_METRIC1);
                if (uCtrlDimensionsOuter == uCtrlDim && CapLength > thickness)
                {
                    CapInnerLength = CapLength - thickness;
                }
                if (uCtrlDimensionsOuter == uCtrlDim && CapWidth > thickness)
                {
                    CapInnerWidth = CapWidth - thickness;
                }
                if (uCtrlDimensionsOuter == uCtrlDim && CapHeight > thickness)
                {
                    CapInnerHeight = CapHeight - thickness;
                }
            }
            // update
            UpdateStatus(string.Empty);
            // draw cap
            graphCtrl.Invalidate();
        }
Ejemplo n.º 19
0
 public void TargetTellClientUnitsHaveAllLoaded(NetworkConnection target)
 {
     //if (isLocalPlayer)
     //{
     UnitsManager.AllPlayerUnitsHaveBeenLoaded();
     // }
 }
Ejemplo n.º 20
0
 public FormNewCylinder(Document document, CylinderProperties cylinder)
     : base(document, cylinder)
 {
     InitializeComponent();
     // properties
     if (null != cylinder)
     {
         uCtrlDiameterOuter.Value = 2.0 * cylinder.RadiusOuter;
         uCtrlDiameterInner.Value = 2.0 * cylinder.RadiusInner;
         uCtrlHeight.Value        = cylinder.Height;
         uCtrlWeight.Value        = cylinder.Weight;
         cbColorWallOuter.Color   = cylinder.ColorWallOuter;
         cbColorWallInner.Color   = cylinder.ColorWallInner;
         cbColorTop.Color         = cylinder.ColorTop;
     }
     else
     {
         uCtrlDiameterOuter.Value = UnitsManager.ConvertLengthFrom(2.0 * 75.0, UnitsManager.UnitSystem.UNIT_METRIC1);
         uCtrlDiameterInner.Value = UnitsManager.ConvertLengthFrom(0.0, UnitsManager.UnitSystem.UNIT_METRIC1);
         uCtrlHeight.Value        = UnitsManager.ConvertLengthFrom(150.0, UnitsManager.UnitSystem.UNIT_METRIC1);
         uCtrlWeight.Value        = UnitsManager.ConvertMassFrom(1.0, UnitsManager.UnitSystem.UNIT_METRIC1);
         cbColorWallOuter.Color   = System.Drawing.Color.LightSkyBlue;
         cbColorWallInner.Color   = System.Drawing.Color.Chocolate;
         cbColorTop.Color         = System.Drawing.Color.Gray;
     }
     // disable Ok button
     UpdateStatus(string.Empty);
     // units
     UnitsManager.AdaptUnitLabels(this);
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Constructor (edit existing properties)
 /// </summary>
 /// <param name="document">Document to which the edited item belongs</param>
 /// <param name="truckProperties">Edited item</param>
 public FormNewTruck(Document document, TruckProperties truckProperties)
     : base(document, truckProperties)
 {
     InitializeComponent();
     // initialize data
     if (null != truckProperties)
     {
         TruckLength = truckProperties.Length;
         TruckWidth = truckProperties.Width;
         TruckHeight = truckProperties.Height;
         TruckAdmissibleLoadWeight = truckProperties.AdmissibleLoadWeight;
         TruckColor = truckProperties.Color;
     }
     else
     { 
         TruckLength = UnitsManager.ConvertLengthFrom(13600, UnitsManager.UnitSystem.UNIT_METRIC1);
         TruckWidth = UnitsManager.ConvertLengthFrom(2450, UnitsManager.UnitSystem.UNIT_METRIC1);
         TruckHeight = UnitsManager.ConvertLengthFrom(2700, UnitsManager.UnitSystem.UNIT_METRIC1);
         TruckAdmissibleLoadWeight = UnitsManager.ConvertMassFrom(38000, UnitsManager.UnitSystem.UNIT_METRIC1);
         TruckColor = Color.LightBlue;            
     }
     UpdateStatus(string.Empty);
     // units
     UnitsManager.AdaptUnitLabels(this);
 }
Ejemplo n.º 22
0
    void RpcUpdatePlayerUnitsOnAllClients(GameObject unit, int playerID, UnitData unitData, Vector3 nodeID)
    {
        //if (isLocalPlayer)
        //{
        if (unit != null)
        {
            // units need to be assigned a parent for the layermanager + camera shit

            AssignUnitDataToUnitScript(unit, playerID, unitData, nodeID);

            GameObject parent = LocationManager.GetNodeLocationScript_CLIENT(nodeID).gameObject;
            unit.transform.SetParent(parent.transform);

            UnitScript unitScript = unit.GetComponent <UnitScript>();
            Debug.Log("Unit Succesfully created on CLIENT: " + (int)unitScript.NetID.Value);
            UnitsManager.AddUnitToGame(playerID, (int)unitScript.NetID.Value, unitScript);     // add unit to generic unit manager pool

            LocationManager.SetUnitOnCube_CLIENT(unit.GetComponent <UnitScript>(), unitScript.UnitStartingWorldLoc);

            if (playerID == PlayerManager.PlayerID)
            {
                GetComponent <UnitsAgent>().AddUnitToUnitAgent(unitScript); // add unit to a more specific player unit pool

                if (unitData.UnitCombatStats[0] == 1)                       // if rank is 'Captain'???? then make active
                {
                    UnitsManager.SetUnitActive(true, playerID, (int)unitScript.NetID.Value);
                }
            }
        }
        else
        {
            Debug.Log("Unit cannot be created on CLIENT");
        }
        //}
    }
Ejemplo n.º 23
0
        public FormNewInterlayer(Document document, InterlayerProperties interlayerProperties)
            : base(document, interlayerProperties)
        {
            InitializeComponent();
            // initialize value
            if (null != interlayerProperties)
            {
                InterlayerLength = interlayerProperties.Length;
                InterlayerWidth  = interlayerProperties.Width;
                Thickness        = interlayerProperties.Thickness;
                Weight           = interlayerProperties.Weight;
                Color            = interlayerProperties.Color;
            }
            else
            {
                // initialize value
                InterlayerLength = UnitsManager.ConvertLengthFrom(1200.0, UnitsManager.UnitSystem.UNIT_METRIC1);
                InterlayerWidth  = UnitsManager.ConvertLengthFrom(1000.0, UnitsManager.UnitSystem.UNIT_METRIC1);
                Thickness        = UnitsManager.ConvertLengthFrom(1.0, UnitsManager.UnitSystem.UNIT_METRIC1);
                Weight           = UnitsManager.ConvertMassFrom(1.0, UnitsManager.UnitSystem.UNIT_METRIC1);
                Color            = Color.Beige;
            }
            // disable Ok button
            UpdateStatus(string.Empty);

            // units
            UnitsManager.AdaptUnitLabels(this);
        }
Ejemplo n.º 24
0
        public void UiRounding()
        {
            var units = new UnitsManager {
                LengthUnit = DynamoLengthUnit.FractionalFoot
            };

            var length = Units.Length.FromFeet(1.5, units);

            Assert.AreEqual("2' 0\"", ((Units.Length)length.Round()).ToString(DynamoLengthUnit.FractionalFoot));
            Assert.AreEqual("2' 0\"", ((Units.Length)length.Ceiling()).ToString(DynamoLengthUnit.FractionalFoot));
            Assert.AreEqual("1' 0\"", ((Units.Length)length.Floor()).ToString(DynamoLengthUnit.FractionalFoot));

            length = Units.Length.FromFeet(1.2, units);
            Assert.AreEqual("1' 0\"", ((Units.Length)length.Round()).ToString(DynamoLengthUnit.FractionalFoot));
            Assert.AreEqual("2' 0\"", ((Units.Length)length.Ceiling()).ToString(DynamoLengthUnit.FractionalFoot));
            Assert.AreEqual("1' 0\"", ((Units.Length)length.Floor()).ToString(DynamoLengthUnit.FractionalFoot));

            length = Units.Length.FromFeet(-1.5, units);
            Assert.AreEqual("-2' 0\"", ((Units.Length)length.Round()).ToString(DynamoLengthUnit.FractionalFoot));
            Assert.AreEqual("-1' 0\"", ((Units.Length)length.Ceiling()).ToString(DynamoLengthUnit.FractionalFoot));
            Assert.AreEqual("-2' 0\"", ((Units.Length)length.Floor()).ToString(DynamoLengthUnit.FractionalFoot));

            length = Units.Length.FromFeet(-1.2, units);
            Assert.AreEqual("-1' 0\"", ((Units.Length)length.Round()).ToString(DynamoLengthUnit.FractionalFoot));
            Assert.AreEqual("-1' 0\"", ((Units.Length)length.Ceiling()).ToString(DynamoLengthUnit.FractionalFoot));
            Assert.AreEqual("-2' 0\"", ((Units.Length)length.Floor()).ToString(DynamoLengthUnit.FractionalFoot));

            //this fails as explained here:
            //http://msdn.microsoft.com/en-us/library/wyk4d9cy(v=vs.110).aspx
            //length = Units.Length.FromFeet(.5);
            //Assert.AreEqual("1' 0\"", ((Units.Length)length.Round()).ToString(DynamoLengthUnit.FractionalFoot));
        }
Ejemplo n.º 25
0
        public void ToFractonialInchRepresentation()
        {
            var units = new UnitsManager();

            var length = new Dynamo.Units.Length(0.03175, units); //1.25"

            Assert.AreEqual("1 1/4\"", length.ToString(DynamoLengthUnit.FractionalInch));

            length.Value = -0.03175;
            Assert.AreEqual("-1 1/4\"", length.ToString(DynamoLengthUnit.FractionalInch));

            //test just the fractional case
            length.Value = 0.00635; //1/4"
            Assert.AreEqual("1/4\"", length.ToString(DynamoLengthUnit.FractionalInch));

            length.Value = -0.00635; //-1/4"
            Assert.AreEqual("-1/4\"", length.ToString(DynamoLengthUnit.FractionalInch));

            //test just the whole case
            length.Value = 0.0254; //1"
            Assert.AreEqual("1\"", length.ToString(DynamoLengthUnit.FractionalInch));

            length.Value = -0.0254;
            Assert.AreEqual("-1\"", length.ToString(DynamoLengthUnit.FractionalInch));

            //test some edge cases
            length.Value = 0.0;
            Assert.AreEqual("0\"", length.ToString(DynamoLengthUnit.FractionalInch));

            length.Value = 0.000396875; //1/64"
            Assert.AreEqual("1/64\"", length.ToString(DynamoLengthUnit.FractionalInch));

            length.Value = 0.025146; //.99"
            Assert.AreEqual("1\"", length.ToString(DynamoLengthUnit.FractionalInch));
        }
Ejemplo n.º 26
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            // Graphics3DControl
            graphCtrl.DrawingContainer = this;
            // list of packs
            ComboBoxHelpers.FillCombo(_boxes.ToArray(), cbInnerBox, null != _packProperties ? _packProperties.Box : _boxes[0]);
            // arrangement
            if (null != _packProperties)
            {
                cbDir.SelectedIndex          = (int)(_packProperties.BoxOrientation);
                Arrangement                  = _packProperties.Arrangement;
                Wrapper                      = _packProperties.Wrap;
                uCtrlOuterDimensions.Checked = _packProperties.HasForcedOuterDimensions;
                OuterDimensions              = _packProperties.OuterDimensions;
            }
            else
            {
                cbDir.SelectedIndex = 5; // HalfAxis.HAxis.AXIS_Z_P
                Arrangement         = new PackArrangement(3, 2, 1);
                Wrapper             = new WrapperPolyethilene(0.1, 0.010, Color.LightGray, true);

                uCtrlThickness.Value = UnitsManager.ConvertLengthFrom(0.1, UnitsManager.UnitSystem.UNIT_METRIC1);
                uCtrlHeight.Value    = UnitsManager.ConvertLengthFrom(40, UnitsManager.UnitSystem.UNIT_METRIC1);
            }
            // disable Ok button
            UpdateStatus(string.Empty);
        }
Ejemplo n.º 27
0
        public FormNewPalletCorners(Document doc, PalletCornerProperties palletCorners)
            : base(doc, palletCorners)
        {
            InitializeComponent();

            if (null != palletCorners)
            {
                CornerLength    = palletCorners.Length;
                CornerWidth     = palletCorners.Width;
                CornerThickness = palletCorners.Thickness;
                CornerWeight    = palletCorners.Weight;
                CornerColor     = palletCorners.Color;
            }
            else
            {
                CornerLength    = UnitsManager.ConvertLengthFrom(1200.0, UnitsManager.UnitSystem.UNIT_METRIC1);;
                CornerWidth     = UnitsManager.ConvertLengthFrom(40.0, UnitsManager.UnitSystem.UNIT_METRIC1);;
                CornerThickness = UnitsManager.ConvertLengthFrom(5.0, UnitsManager.UnitSystem.UNIT_METRIC1);
                CornerWeight    = UnitsManager.ConvertMassFrom(0.050, UnitsManager.UnitSystem.UNIT_METRIC1);
                CornerColor     = Color.Khaki;
            }
            UpdateStatus(string.Empty);
            // units
            UnitsManager.AdaptUnitLabels(this);
        }
Ejemplo n.º 28
0
        private static bool PalletMatchesDimensionsInMM(PalletProperties palletProperties, double length, double width)
        {
            double lengthInMM = UnitsManager.ConvertLengthTo(palletProperties.Length, UnitsManager.UnitSystem.UNIT_METRIC1);
            double widthInMM  = UnitsManager.ConvertLengthTo(palletProperties.Width, UnitsManager.UnitSystem.UNIT_METRIC1);

            return((Math.Abs(lengthInMM - length) < 1.0 && Math.Abs(widthInMM - width) < 1.0) ||
                   (Math.Abs(lengthInMM - width) < 1.0 && Math.Abs(widthInMM - length) < 1.0));
        }
 /// <summary>
 /// Constructor used when editing an existing analysis
 /// </summary>
 /// <param name="document">Parent document</param>
 /// <param name="truckAnalysis">Truck analysis</param>
 public FormNewTruckAnalysis(Document document, TruckAnalysis truckAnalysis)
 {
     InitializeComponent();
     // set unit labels
     UnitsManager.AdaptUnitLabels(this);
     // set truck analysis ref
     _truckAnalysis = truckAnalysis;
 }
Ejemplo n.º 30
0
 /// <summary>
 /// constructor takes document as argument
 /// </summary>
 public FormOptimizeCase(DocumentSB document)
 {
     InitializeComponent();
     // set unit labels
     UnitsManager.AdaptUnitLabels(this);
     // document
     _document = document;
 }
Ejemplo n.º 31
0
    void Awake()
    {
        //Singletone
        if (ins == null) { ins = this; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); }

        if (lifeController==null)
        lifeController = GetComponent<VisualLifeController>();

        if (unitsManager == null)
            unitsManager = GetComponent<UnitsManager>();
    }