Beispiel #1
0
        /// <summary>
        /// Create a IAdjustmentPage from the string.
        /// </summary>
        /// <param name="assemblyType"> The type for assembly. </param>
        /// <param name="type"> The source type. </param>
        /// <returns> The created IAdjustmentPage. </returns>
        public static IAdjustmentPage CreateAdjustmentPage(Type assemblyType, AdjustmentType type)
        {
            if (XML.AdjustmentPages.ContainsKey(type))
            {
                return(XML.AdjustmentPages[type]);
            }

            if (type != AdjustmentType.Gray)
            {
                Assembly assembly = assemblyType.GetTypeInfo().Assembly;
                IEnumerable <TypeInfo> typeInfos = assembly.DefinedTypes;

                TypeInfo typeInfo = typeInfos.FirstOrDefault(t => t.FullName == $"Retouch_Photo2.Adjustments.Pages.{type}Page");
                if ((typeInfo is null) == false)
                {
                    object obj = Activator.CreateInstance(typeInfo.AsType());
                    if (obj is IAdjustmentPage adjustmentPage)
                    {
                        XML.AdjustmentPages.Add(type, adjustmentPage);
                        return(adjustmentPage);
                    }
                }
            }

            return(new GrayPage());
        }
Beispiel #2
0
        private void Window_KeyDown(object sender, KeyEventArgs e)
        {
            if (Adjustment != AdjustmentType.None && (e.Key == Key.Escape || e.Key == Key.Enter))
            {
                Adjustment          = AdjustmentType.None;
                EditMask.Visibility = Visibility.Collapsed;
                return;
            }

            if (e.IsRepeat)
            {
                double t = Step;
                d     = (t *= 0.5) * t * t;
                Step += 0.075;
            }
            else
            {
                Step = 0.1;
                d    = 0.1;
            }

            switch (Adjustment)
            {
            case AdjustmentType.Move:
                Adj_Move(e.Key);
                break;

            case AdjustmentType.Resize:
                Adj_Resize(e.Key);
                break;
            }
        }
Beispiel #3
0
 public ColorComponentAdjuster(ColorComponentAdjuster other)
 {
     this.channel        = other.channel;
     this.colorComponent = other.colorComponent;
     this.adjustment     = other.adjustment;
     this.adjustmentType = other.adjustmentType;
 }
Beispiel #4
0
        public static AdjustObsMatrix BuildATtest(int paramCount, int obsCount, AdjustmentType adjustmentType = AdjustmentType.参数平差)
        {
            bool isParamOrCondition = adjustmentType == AdjustmentType.参数平差;
            int  restCount          = obsCount - paramCount;
            int  rowOfCoeef         = isParamOrCondition ? obsCount : restCount;
            int  colOfCoeef         = isParamOrCondition ? paramCount : obsCount;

            AdjustObsMatrix obsMatrix = new AdjustObsMatrix();

            obsMatrix.Observation = WeightedVector.GenerateATest(obsCount);
            obsMatrix.Apriori     = WeightedVector.GenerateATest(paramCount);
            obsMatrix.Coefficient = BuildACoeefient(rowOfCoeef, colOfCoeef);
            obsMatrix.Transfer    = new WeightedMatrix(Matrix.CreateIdentity(paramCount), Matrix.CreateIdentity(paramCount));

            obsMatrix.FreeVector         = new Vector(rowOfCoeef, 1);
            obsMatrix.SecondFreeVector   = new Vector(paramCount, 1);
            obsMatrix.ApproxVector       = new Vector(paramCount, 1);
            obsMatrix.SecondApproxVector = new Vector(paramCount, 1);

            if (adjustmentType == AdjustmentType.具有参数的条件平差)
            {
                obsMatrix.SecondCoefficient = BuildACoeefient(rowOfCoeef, colOfCoeef);
            }


            return(obsMatrix);
        }
        private async Task ProcessItemAdjustmentAsync(long itemId, int quantity, AdjustmentType adjustmentType, QuantityType quantityType = QuantityType.Both)
        {
            var item = await context.Items.FindAsync(itemId);

            if (item == null)
            {
                throw new ArgumentException("Item does not exist.");
            }

            switch (quantityType)
            {
            case QuantityType.Quantity:
                AdjustQuantity(item, adjustmentType, quantity);
                break;

            case QuantityType.StockQuantity:
                AdjustStockQuantity(item, adjustmentType, quantity);
                break;

            case QuantityType.Both:
                AdjustQuantity(item, adjustmentType, quantity);
                AdjustStockQuantity(item, adjustmentType, quantity);
                break;
            }

            if (item.Quantity < 0)
            {
                throw new QuantityBelowZeroException("Insufficient quantity.");
            }

            context.Entry(item).State = EntityState.Modified;
        }
Beispiel #6
0
        public static decimal CalculateSaleValue(AdjustmentType type, decimal adjValue, decimal originalValue)
        {
            decimal retVal = 0;

            try
            {
                switch (type)
                {
                case AdjustmentType.Add:
                    retVal = originalValue + adjValue;
                    retVal = (retVal > Decimal.MaxValue ? Decimal.MaxValue : retVal);
                    break;

                case AdjustmentType.Multiply:
                    retVal = originalValue * adjValue;
                    retVal = (retVal > Decimal.MaxValue ? Decimal.MaxValue : retVal);
                    break;

                case AdjustmentType.Subtract:
                    decimal subtractedValue = originalValue - adjValue;
                    retVal = subtractedValue < 0 ? 0 : subtractedValue;
                    break;
                }
            }
            catch (OverflowException ex)
            {
                string msg = "An exception occured trying to apply the adjustment action";
                OutputLoggerHelper.WriteToOutput(ExceptionHelper.GetUnifiedExceptionMessage(msg, ex));

                // we will throw this error, this is serious. this will trigger the skip of the message
                throw ex;
            }

            return(retVal);
        }
Beispiel #7
0
        private async Task UpdateQuantityDelivered(DeliveryLineItem lineItem, AdjustmentType adjustmentType)
        {
            var orderLineItem = await FetchLineItem(lineItem.OrderLineItemId);

            var tempQuantityDelivered = orderLineItem.QuantityDelivered;

            orderLineItem.QuantityDelivered = adjustmentType == AdjustmentType.Add ?
                                              orderLineItem.QuantityDelivered + lineItem.Quantity :
                                              orderLineItem.QuantityDelivered - lineItem.Quantity;

            // Quantity delivered cannot be more than original order quantity
            if (orderLineItem.QuantityDelivered > orderLineItem.Quantity)
            {
                var errorBuilder = new StringBuilder("Quantity delivered cannot be more than the quantity ordered.<br />");
                if (tempQuantityDelivered != 0)
                {
                    errorBuilder.Append($"{orderLineItem.Item.Name} of order {orderLineItem.Order.Code} already has {tempQuantityDelivered}/{orderLineItem.Quantity} delivered.");
                }
                else
                {
                    errorBuilder.Append($"{orderLineItem.Item.Name} of order {orderLineItem.Order.Code} only has {orderLineItem.Quantity} quantity ordered.");
                }

                throw new QuantityDeliveredException(errorBuilder.ToString());
            }
        }
Beispiel #8
0
        public bool ExecuteSale()
        {
            decimal        adjValue = SaleAdjustment.AdjustmentValue;
            AdjustmentType adjType  = SaleAdjustment.AdjustmentType;

            // Add the sale first
            if (!DataManager.AddSale(Sale))
            {
                return(false);
            }

            // fetch only sales relevent to the adjustment product
            var productSales = DataManager.GetReadOnlySaleList().Where(s => s.Product.Equals(SaleAdjustment.Product, StringComparison.OrdinalIgnoreCase)).ToList();

            // and adjust them. for each adjusted there will be a sale adjustment history log
            productSales.ForEach(s =>
            {
                // create the adjustment object to log
                SaleAdjustmentLog adjLog = new SaleAdjustmentLog(s.SaleId, s.SaleValue, 0, null, SaleAdjustment);
                // change the sale value
                s.SaleValue = SaleAdjustmentHelper.CalculateSaleValue(adjType, adjValue, s.SaleValue);
                // and log the adjustment
                adjLog.NewValue  = s.SaleValue;
                adjLog.OccuredAt = DateTime.Now;
                DataManager.AddSaleAdjustment(adjLog);
            });

            return(true);
        }
Beispiel #9
0
 public ColorComponentAdjuster(int channel, int colorComponent, float adjustment, AdjustmentType adjustmentType = AdjustmentType.Adjust)
 {
     this.channel        = channel;
     this.colorComponent = colorComponent;
     this.adjustment     = adjustment;
     this.adjustmentType = adjustmentType;
 }
        /// <summary>
        /// Generates random combinations of messages
        /// </summary>
        public void CreateMessages()
        {
            Random r = new Random();

            for (int j = 0; j < 4; j++)
            {
                for (int i = 0; i < 10; i++)
                {
                    Sale    s = new Sale($"product { i }", decimal.Round(Convert.ToDecimal(r.NextDouble() * (20 - 0)), 2));
                    Message m = new Message(s, MessageType.Single, null);

                    DataManager.AddPendingMessage(m);
                }

                for (int i = 0; i < 10; i++)
                {
                    Sale    s = new Sale($"product { i }", decimal.Round(Convert.ToDecimal(r.NextDouble() * 1), 2), r.Next(10));
                    Message m = new Message(s, MessageType.Multi, null);

                    DataManager.AddPendingMessage(m);
                }

                AdjustmentType[] types = new AdjustmentType[] { AdjustmentType.Add, AdjustmentType.Multiply, AdjustmentType.Subtract };

                for (int i = 0; i < 10; i++)
                {
                    Sale           s  = new Sale($"product { i }", decimal.Round(Convert.ToDecimal(r.NextDouble() * 1), 2));
                    SaleAdjustment sa = new SaleAdjustment($"product { i }", decimal.Round(Convert.ToDecimal(r.NextDouble() * 10), 2), types[r.Next(3)]);
                    Message        m  = new Message(s, MessageType.Adjustment, sa);

                    DataManager.AddPendingMessage(m);
                }
            }
        }
Beispiel #11
0
 /// <summary>
 /// Apply adjustment on target
 /// </summary>
 /// <param name="target">such as fiscal item or sale document</param>
 /// <param name="type">fee or discount</param>
 /// <param name="input">amount or percentage</param>
 /// <param name="cashierId">id of cashier who aplies adjustment</param>
 public Adjustment(IAdjustable target, AdjustmentType type, Decimal input, String cashierId)
     : this(target, type, input)
 {
     if (cashierId != null && cashierId != "")
     {
         authorizingCashierId = cashierId;
     }
 }
Beispiel #12
0
        /// <summary>
        /// 生产平差器
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static MatrixAdjuster Create(AdjustmentType type)
        {
            MatrixAdjuster Adjustment = null;

            switch (type)
            {
            case AdjustmentType.参数平差:
                Adjustment = new ParamAdjuster();
                break;

            case AdjustmentType.条件平差:
                Adjustment = new ConditionalAdjuster();
                break;

            case AdjustmentType.具有参数的条件平差:
                Adjustment = new ConditionalAdjusterWithParam();
                break;

            case AdjustmentType.具有条件的参数平差:
                Adjustment = new ParamAdjusterWithCondition();
                break;

            case AdjustmentType.卡尔曼滤波:
                Adjustment = new SimpleKalmanFilter();
                // Adjustment = new KalmanFilter();
                break;

            case AdjustmentType.均方根滤波:
                Adjustment = new SquareRootInformationFilter();
                break;

            case AdjustmentType.序贯平差:
                Adjustment = new SequentialAdjuster();
                break;

            case AdjustmentType.参数加权平差:
                Adjustment = new WeightedParamAdjuster();
                break;

            case AdjustmentType.递归最小二乘:
                Adjustment = new RecursiveAdjuster();
                break;

            case AdjustmentType.单期递归最小二乘:
                Adjustment = new SingleRecursiveAdjuster();
                break;

            default:
                //Adjustment = new ParamAdjuster();
                break;
            }
            if (Adjustment == null)
            {
                throw new Exception("尚未实现 " + type);
            }

            return(Adjustment);
        }
        private void UpdateItemHistory(ItemHistory itemHistory, int quantity, AdjustmentType adjustmentType, string remarks)
        {
            itemHistory.Date     = DateTime.Now;
            itemHistory.Quantity = adjustmentType == AdjustmentType.Add ?
                                   quantity : quantity * -1;
            itemHistory.Remarks = remarks;

            context.Entry(itemHistory).State = EntityState.Modified;
        }
 private ItemHistory CreateItemHistory(long itemId, AdjustmentType adjustmentType, int quantity, string remarks)
 {
     return(new ItemHistory
     {
         ItemId = itemId,
         Quantity = adjustmentType == AdjustmentType.Add ? quantity : quantity * -1,
         Date = DateTime.Now,
         Remarks = remarks
     });
 }
        private bool OffsetActivityStartTime(ITrip driverTrip,
                                             ITrip passengerTrip,
                                             ISharedMode sharedMode,
                                             bool pickUp,
                                             int driverWaitThreshold,
                                             int passengerWaitThreshold,
                                             AdjustmentType adjustmentType,
                                             out Time newDriverStartTime,
                                             out Time newPassengerStartTime)
        {
            newPassengerStartTime = Time.Zero;
            newDriverStartTime    = Time.Zero;

            if (adjustmentType == AdjustmentType.Driver)
            {
                Time startTime = passengerTrip.ActivityStartTime;
                newDriverStartTime    = startTime + driverTrip.Mode.TravelTime(passengerTrip.DestinationZone, driverTrip.DestinationZone, driverTrip.TripStartTime);
                newPassengerStartTime = startTime;

                return(WithinWaitThreshold(newDriverStartTime, driverTrip.ActivityStartTime, driverWaitThreshold));
            }
            else if (adjustmentType == AdjustmentType.Passenger)
            {
                Time toIntermediatefTime;
                Time toDestinationfTime;
                //determining travel times given whether its a pickup or drop-off trip
                if (pickUp)
                {
                    toIntermediatefTime = driverTrip.Mode.TravelTime(driverTrip.OriginalZone, passengerTrip.OriginalZone, passengerTrip.TripStartTime);
                    toDestinationfTime  = sharedMode.TravelTime(passengerTrip.OriginalZone, passengerTrip.DestinationZone, passengerTrip.TripStartTime);
                }
                else
                {
                    toIntermediatefTime = sharedMode.TravelTime(driverTrip.OriginalZone, passengerTrip.DestinationZone, passengerTrip.TripStartTime);
                    toDestinationfTime  = driverTrip.Mode.TravelTime(passengerTrip.DestinationZone, driverTrip.DestinationZone, driverTrip.TripStartTime);
                }
                Time toIntermediateTime = toIntermediatefTime;
                Time toDestinationTime  = toDestinationfTime;

                newPassengerStartTime = driverTrip.ActivityStartTime - toDestinationTime;
                newDriverStartTime    = driverTrip.ActivityStartTime;

                return(WithinWaitThreshold(newPassengerStartTime, passengerTrip.ActivityStartTime, passengerWaitThreshold));
            }
            else if (adjustmentType == AdjustmentType.Compromise)
            {
                throw new NotImplementedException("AdjustmentType.Compromise not implemented");
            }

            return(false);
        }
Beispiel #16
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="AdjustmentType"></param>
        /// <param name="OutDirectory"></param>
        /// <param name="ProgressNotifier"></param>
        public CommonFileAdjuster(AdjustmentType AdjustmentType = AdjustmentType.卡尔曼滤波, string OutDirectory = null, IProgressViewer ProgressNotifier = null)
        {
            if (String.IsNullOrWhiteSpace(OutDirectory))
            {
                OutDirectory = Setting.TempDirectory;
            }
            this.OutDirectory = OutDirectory;
            Geo.Utils.FileUtil.CheckOrCreateDirectory(OutDirectory);
            this.AdjustmentType = AdjustmentType;
            ResultTables        = new ObjectTableManager(OutDirectory);
            IsCancel            = false;
            this.ProgressViewer = ProgressNotifier;

            adjuster = AdjusterFactory.Create(AdjustmentType);
        }
        public async Task ProcessAdjustments(IEnumerable itemsToUpdate, AdjustmentType adjustmentType, string remarks, QuantityType quantityType)
        {
            foreach (var item in itemsToUpdate)
            {
                switch (item)
                {
                case OrderLineItem orderLineItem:
                    await ProcessItemAdjustmentAsync(orderLineItem.ItemId, orderLineItem.Quantity, adjustmentType, quantityType);
                    await UpdateOrderLineItemHistory(orderLineItem, adjustmentType, remarks);

                    break;

                case SaveOrderLineItemRequest orderDetailLineItemRequest:
                    await ProcessItemAdjustmentAsync(orderDetailLineItemRequest.ItemId, orderDetailLineItemRequest.Quantity, adjustmentType, quantityType);

                    var lineItem = mapper.Map <OrderLineItem>(orderDetailLineItemRequest);
                    await UpdateOrderLineItemHistory(lineItem, adjustmentType, remarks);

                    break;

                case Adjustment adjustment:
                    await ProcessItemAdjustmentAsync(adjustment.ItemId, adjustment.Quantity, adjustmentType, quantityType);

                    UpdateAdjustmentItemHistory(adjustment);
                    break;

                case CreditMemoLineItem creditMemoLineItem:
                    await ProcessItemAdjustmentAsync(creditMemoLineItem.ItemId, creditMemoLineItem.Quantity, adjustmentType, quantityType);
                    await UpdateCreditMemoItemHistory(creditMemoLineItem, adjustmentType, remarks);

                    break;

                case SaveCreditMemoLineItemRequest creditMemoLineItemRequest:
                    await ProcessItemAdjustmentAsync(creditMemoLineItemRequest.ItemId, creditMemoLineItemRequest.Quantity, adjustmentType, quantityType);

                    var cmLineItem = mapper.Map <CreditMemoLineItem>(creditMemoLineItemRequest);
                    await UpdateCreditMemoItemHistory(cmLineItem, adjustmentType, remarks);

                    break;

                case null:
                    break;
                }
            }
        }
Beispiel #18
0
        public override void Adjust(AdjustmentType method)
        {
            switch (method)
            {
            case AdjustmentType.Discount:
                WriteChar(0, PosKey.Discount); break;

            case AdjustmentType.Fee:
                WriteChar(0, PosKey.Fee); break;

            case AdjustmentType.PercentDiscount:
                WriteChar(0, PosKey.PercentDiscount); break;

            case AdjustmentType.PercentFee:
                WriteChar(0, PosKey.PercentFee); break;

            default: break;
            }
        }
Beispiel #19
0
        private void button_run_Click(object sender, EventArgs e)
        {
            var            filePath     = this.fileOpenControl_file.FilePath;
            AdjustmentType adjustType   = enumRadioControl1AdjustType.GetCurrent <AdjustmentType>();
            String         outDirectory = directorySelectionControl1.Path;

            adjuster = new CommonFileAdjuster(adjustType, outDirectory, progressBarComponent1);

            adjuster.Run(filePath);

            var result = adjuster.ResultTables.First;

            dataGridView_param.DataSource = result.GetDataTable();
            var resultRms = adjuster.ResultTables.Second;

            dataGridView_rms.DataSource = resultRms.GetDataTable();

            adjuster.OutputResult();
            Geo.Utils.FormUtil.ShowIfOpenDirMessageBox(outDirectory);
        }
Beispiel #20
0
        public IEnumerable <GLAdjustmentInfo> GetGLAdjustments(AdjustmentType adjustmentType, DateTime runDate)
        {
            using (BasicContext entityContext = new BasicContext())
            {
                var query = from a in entityContext.GLAdjustmentSet
                            join b in entityContext.GLMappingSet on a.GLCode equals b.GLCode
                            join c in entityContext.CurrencySet on a.Currency equals c.Symbol
                            join d in entityContext.BranchSet on a.CompanyCode equals d.Code
                            where a.AdjustmentType == adjustmentType //&& a.RunDate == runDate.
                            select new GLAdjustmentInfo()
                {
                    GLAdjustment = a,
                    GLMapping    = b,
                    Branch       = d,
                    Currency     = c
                };

                return(query.ToFullyLoaded());
            }
        }
Beispiel #21
0
        /// <summary>
        /// Adjust percent discount,discount,percent fee and fee transaction
        /// </summary>
        /// <param name="target">
        /// The target that will be adjusted.
        /// </param>
        /// <param name="type">
        /// Type of adjustment.
        /// </param>
        /// <param name="input">
        /// Adjustment amount.
        /// </param>
        public Adjustment(IAdjustable target, AdjustmentType type, Decimal input)
        {
            this.method         = type;
            input               = Math.Round(input, 2);
            this.requestValue   = input;
            this.adjustedObject = target;
            this.adjustedTotal  = target.TotalAmount;
            createdTime         = DateTime.Now;

            if (cr.CurrentCashier != null)
            {
                authorizingCashierId = cr.CurrentCashier.Id;
            }

            /*
             *  0.0001m added because of math.round bug
             *  for example: Math.Round(0.145, 2) = 0.14
             *           but Math.Round(0.1451,2) = 0.15
             */
            switch (type)
            {
            case AdjustmentType.Discount:
                netAmount = -1m * input;
                break;

            case AdjustmentType.PercentDiscount:
                requestValue = Math.Round(input, 0);
                netAmount    = (-1m) * Rounder.RoundDecimal((input / 100) * target.TotalAmount + 0.0001m, 2, true);
                break;

            case AdjustmentType.Fee:
                netAmount = input;
                break;

            case AdjustmentType.PercentFee:
                requestValue = Math.Round(input, 0);
                netAmount    = Rounder.RoundDecimal((input / 100) * target.TotalAmount + 0.0001m, 2, true);
                break;
            }
        }
        private async Task UpdateOrderLineItemHistory(OrderLineItem orderLineItem, AdjustmentType adjustmentType, string remarks)
        {
            var itemHistory = await context
                              .ItemHistories
                              .FirstOrDefaultAsync(a => a.OrderLineItemId == orderLineItem.Id);

            if (itemHistory == null)
            {
                orderLineItem.TransactionHistory = CreateItemHistory(
                    orderLineItem.ItemId,
                    adjustmentType,
                    orderLineItem.Quantity,
                    remarks);
            }
            else
            {
                UpdateItemHistory(itemHistory,
                                  orderLineItem.Quantity,
                                  adjustmentType,
                                  remarks);
            }
        }
Beispiel #23
0
        public async Task ProcessReturns(IEnumerable creditMemoLineItems, AdjustmentType adjustmentType)
        {
            foreach (var lineItem in creditMemoLineItems)
            {
                switch (lineItem)
                {
                case CreditMemoLineItem creditMemoLineItem:
                    await UpdateQuantityReturned(creditMemoLineItem, adjustmentType);

                    break;

                case SaveCreditMemoLineItemRequest request:
                    var cmLineItem = mapper.Map <CreditMemoLineItem>(request);
                    await UpdateQuantityReturned(cmLineItem, adjustmentType);

                    break;

                case null:
                    break;
                }
            }
        }
Beispiel #24
0
        public async Task ProcessDeliveries(IEnumerable deliveryLineItems, AdjustmentType adjustmentType)
        {
            foreach (var lineItem in deliveryLineItems)
            {
                switch (lineItem)
                {
                case DeliveryLineItem deliveryLineItem:
                    await UpdateQuantityDelivered(deliveryLineItem, adjustmentType);

                    break;

                case SaveDeliveryLineItemRequest request:
                    var delLineItem = mapper.Map <DeliveryLineItem>(request);
                    await UpdateQuantityDelivered(delLineItem, adjustmentType);

                    break;

                case null:
                    break;
                }
            }
        }
Beispiel #25
0
 public virtual void Adjust(AdjustmentType method)
 {
     cr.State = AlertCashier.Instance(cr.State.NotImplemented);
 }
//		private string[] _toolbarStrings = { "Translation", "Rotation" };
//		int toolbarInt = 0;


        void WindowContent(int windowID)
        {
            //GUI.skin = HighLogic.Skin;
            var lstyle = new GUIStyle(GUI.skin.label);

            //var errstyle = new GUIStyle (GUI.skin.label);
            //errstyle.normal.textColor = Color.red;
            if (fineAdjustActive && (DateTime.Now.Second % 2 == 0))
            {
                lstyle.normal.textColor = Color.yellow;
            }
            Part puc = null;

            if (fineAdjustActive)
            {
                puc = activePuc;
            }
            else
            {
                puc = EditorLogic.SelectedPart;                 //Utility.GetPartUnderCursor ();
            }
//			toolbarInt = GUILayout.Toolbar (toolbarInt, _toolbarStrings);
            //adjTypeStr = "None";
            if (GizmoEvents.offsetGizmoActive)
            {
                adjType    = AdjustmentType.translation;
                adjTypeStr = "Translation";
            }
            if (GizmoEvents.rotateGizmoActive)
            {
                adjType    = AdjustmentType.rotation;
                adjTypeStr = "Rotation";
            }

            GUILayout.BeginHorizontal();
            GUILayout.Label("Adjustment Type: ", lstyle);
            GUILayout.Label(adjTypeStr, lstyle);
            GUILayout.EndHorizontal();



            //		if (!GizmoEvents.offsetGizmoActive && !GizmoEvents.rotateGizmoActive)
            //			return;

            GUILayout.BeginHorizontal();
            GUILayout.Label("Current Part:", lstyle);
            GUILayout.Label(puc ? puc.name : "none", lstyle);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Symmetry Method: ", lstyle);
            if (puc != null)
            {
                GUILayout.Label(puc.symMethod.ToString());
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (adjType != AdjustmentType.translation || puc != EditorLogic.RootPart)
            {
                GUILayout.Label("Delta amount:", lstyle, GUILayout.MinWidth(150));
                if (GUILayout.Button("<", GUILayout.Width(20)))
                {
                    switch (adjType)
                    {
                    case AdjustmentType.rotation:
                        rotationdeltaIndex++;
                        if (rotationdeltaIndex > 3)
                        {
                            rotationdeltaIndex = 3;
                        }

                        break;

                    case AdjustmentType.translation:
                        offsetDeltaIndex++;
                        if (offsetDeltaIndex > 3)
                        {
                            offsetDeltaIndex = 3;
                        }
                        break;
                    }
                }
                switch (adjType)
                {
                case AdjustmentType.rotation:
                    GUILayout.Label(getDelta(rotationdeltaIndex).ToString(), "TextField");
                    break;

                case AdjustmentType.translation:
                    GUILayout.Label(getDelta(offsetDeltaIndex).ToString(), "TextField");
                    break;
                }

                if (GUILayout.Button(">", GUILayout.Width(20)))
                {
                    switch (adjType)
                    {
                    case AdjustmentType.rotation:
                        rotationdeltaIndex--;
                        if (rotationdeltaIndex < 0)
                        {
                            rotationdeltaIndex = 0;
                        }

                        break;

                    case AdjustmentType.translation:
                        offsetDeltaIndex--;
                        if (offsetDeltaIndex < 0)
                        {
                            offsetDeltaIndex = 0;
                        }
                        break;
                    }
                }
            }
            GUILayout.EndHorizontal();


            GUILayout.BeginHorizontal();
            if (adjType != AdjustmentType.translation || puc != EditorLogic.RootPart)
            {
                GUILayout.Label(adjTypeStr + " amount:", lstyle, GUILayout.MinWidth(150));
                if (GUILayout.Button("-", GUILayout.Width(20)))
                {
                    switch (adjType)
                    {
                    case AdjustmentType.rotation:
                        rotation -= getDelta(rotationdeltaIndex);
                        if (rotation <= 0.0f)
                        {
                            rotation = getDelta(rotationdeltaIndex);
                        }

                        break;

                    case AdjustmentType.translation:
                        offset -= getDelta(offsetDeltaIndex);
                        if (offset <= 0.0f)
                        {
                            offset = getDelta(offsetDeltaIndex);
                        }

                        break;
                    }
                }
                switch (adjType)
                {
                case AdjustmentType.rotation:
                    GUILayout.Label(rotation.ToString(), "TextField");
                    break;

                case AdjustmentType.translation:
                    GUILayout.Label(offset.ToString(), "TextField");
                    break;
                }

                if (GUILayout.Button("+", GUILayout.Width(20)))
                {
                    switch (adjType)
                    {
                    case AdjustmentType.rotation:
                        rotation += getDelta(rotationdeltaIndex);
                        break;

                    case AdjustmentType.translation:
                        offset += getDelta(offsetDeltaIndex);
                        break;
                    }
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Done"))
            {
                Log.Info("Done");
                fineAdjustActive = false;
                InputLockManager.RemoveControlLock("EEX_FA");
                CloseWindow();
            }
            GUILayout.EndHorizontal();
            GUI.DragWindow();
        }
Beispiel #27
0
 public GLAdjustmentData[] GetGLAdjustments(AdjustmentType adjustmentType)
 {
     return(Channel.GetGLAdjustments(adjustmentType));
 }
Beispiel #28
0
 public GLAdjustmentData[] GetGLAdjustmentByStatus(AdjustmentType adjustmentType, bool posted)
 {
     return(Channel.GetGLAdjustmentByStatus(adjustmentType, posted));
 }
Beispiel #29
0
 public void PurgeGLAdjustment(AdjustmentType adjustmentType)
 {
     Channel.PurgeGLAdjustment(adjustmentType);
 }
Beispiel #30
0
 public void ReverseGLAdjustmentByCode(AdjustmentType adjustmentType, string adjustmentCode)
 {
     Channel.ReverseGLAdjustmentByCode(adjustmentType, adjustmentCode);
 }
        private bool OffsetActivityStartTime(ITrip driverTrip,
                        ITrip passengerTrip,
                        ISharedMode sharedMode,
                        bool pickUp,
                        int driverWaitThreshold,
                        int passengerWaitThreshold,
                        AdjustmentType adjustmentType,
                        out Time newDriverStartTime,
                        out Time newPassengerStartTime)
        {
            newPassengerStartTime = Time.Zero;
            newDriverStartTime = Time.Zero;

            if ( adjustmentType == AdjustmentType.Driver )
            {
                Time startTime = passengerTrip.ActivityStartTime;
                newDriverStartTime = startTime + driverTrip.Mode.TravelTime( passengerTrip.DestinationZone, driverTrip.DestinationZone, driverTrip.TripStartTime );
                newPassengerStartTime = startTime;

                return WithinWaitThreshold( newDriverStartTime, driverTrip.ActivityStartTime, driverWaitThreshold );
            }
            else if ( adjustmentType == AdjustmentType.Passenger )
            {
                Time toIntermediatefTime;
                Time toDestinationfTime;
                //determining travel times given whether its a pickup or drop-off trip
                if ( pickUp )
                {
                    toIntermediatefTime = driverTrip.Mode.TravelTime( driverTrip.OriginalZone, passengerTrip.OriginalZone, passengerTrip.TripStartTime );
                    toDestinationfTime = sharedMode.TravelTime( passengerTrip.OriginalZone, passengerTrip.DestinationZone, passengerTrip.TripStartTime );
                }
                else
                {
                    toIntermediatefTime = sharedMode.TravelTime( driverTrip.OriginalZone, passengerTrip.DestinationZone, passengerTrip.TripStartTime );
                    toDestinationfTime = driverTrip.Mode.TravelTime( passengerTrip.DestinationZone, driverTrip.DestinationZone, driverTrip.TripStartTime );
                }
                Time toIntermediateTime = toIntermediatefTime;
                Time toDestinationTime = toDestinationfTime;

                newPassengerStartTime = driverTrip.ActivityStartTime - toDestinationTime;
                newDriverStartTime = driverTrip.ActivityStartTime;

                return WithinWaitThreshold( newPassengerStartTime, passengerTrip.ActivityStartTime, passengerWaitThreshold );
            }
            else if ( adjustmentType == AdjustmentType.Compromise )
            {
                throw new NotImplementedException( "AdjustmentType.Compromise not implemented" );
            }

            return false;
        }
        private static decimal CalculateDiscountedPrice(AdjustmentType adjustmentType, decimal basePrice, decimal adjustmentAmount)
        {
            switch (adjustmentType)
            {
                case AdjustmentType.Percent:
                    basePrice = basePrice - (basePrice * (adjustmentAmount / 100));

                    break;
                case AdjustmentType.Flat:
                    basePrice = basePrice - adjustmentAmount;
                    break;
            }
            basePrice = basePrice < 0 ? 0 : basePrice;
            return basePrice;
        }