private bool ValidateSave()
 {
     if (!StatusString.Equals("Cautation Saved Successfully"))
     {
         StatusString    = "Please Send Cautation again";
         ForegroundColor = System.Windows.Media.Brushes.Red;
         return(false);
     }
     else if (ListofSelectedClients.Count <= 0)
     {
         StatusString    = "Please Select Clients";
         ForegroundColor = System.Windows.Media.Brushes.Red;
         this.parent.To.Focus();
         return(false);
     }
     else if (CustomValidation.validateString(_subject))
     {
         StatusString    = "Please Enter Subject";
         ForegroundColor = System.Windows.Media.Brushes.Red;
         this.parent.Subject.Focus();
         return(false);
     }
     else if (CustomValidation.validateString(_body))
     {
         StatusString    = "Please Enter Body";
         ForegroundColor = System.Windows.Media.Brushes.Red;
         this.parent.Body.Focus();
         return(false);
     }
     return(true);
 }
        /// <summary>
        /// Проверить ответ, Присвоить выходные данные.
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool SetDataByte(byte[] data)
        {
            var format = _currentRequest.ResponseOption.Format;

            if (data == null)
            {
                IsOutDataValid = false;
                OutputData     = new ResponseDataItem <AdInputType>
                {
                    ResponseData   = null,
                    Encoding       = format,
                    IsOutDataValid = IsOutDataValid
                };
                return(false);
            }
            var stringResponse = data.ArrayByteToString(format);

            IsOutDataValid = (stringResponse == _currentRequest.ResponseOption.Body);
            OutputData     = new ResponseDataItem <AdInputType>
            {
                ResponseData   = stringResponse,
                Encoding       = format,
                IsOutDataValid = IsOutDataValid
            };
            StatusString.AppendLine($"SetDataByte.StringResponse= \"{stringResponse}\" Length= \"{data.Length}\"");
            return(IsOutDataValid);
        }
        private void Ok()
        {
            if (StatusString.Equals("Order Cancelled Successfully") || StatusString.Equals("Order Modified Successfully") || StatusString.Equals("Order Placed Successfully"))
            {
                parent.Close();
            }

            StatusStringFlag = Visibility.Collapsed;
            StatusString     = "";
        }
Ejemplo n.º 4
0
        private void Ok()
        {
            if (StatusString.Equals("Client Added Successfully") || StatusString.Equals("Client Modified Successfully"))
            {
                parent.Close();
            }

            StatusStringFlag = Visibility.Collapsed;
            StatusString     = "";
        }
        private void Ok()
        {
            if (StatusString.Equals("Cautation Send Successfully"))
            {
                parent.Close();
            }

            StatusStringFlag = Visibility.Collapsed;
            StatusString     = "";
        }
        private IProgress <int> UpdateProgress()
        {
            return(new Progress <int>(x =>
            {
                StatusInPercent = x;

                StatusString = StatusString.Substring(0, StatusString.LastIndexOf("."));

                StatusString += $".{StatusInPercent} % ";
            }));
        }
        public byte[] GetDataByte()
        {
            var stringRequset = _currentRequest.StringRequest;
            var format        = _currentRequest.RequestOption.Format;

            StatusString.AppendLine($"GetDataByte.StringRequest= \"{stringRequset}\". Lenght= \"{stringRequset.Length}\"");
            //Преобразовываем КОНЕЧНУЮ строку в массив байт
            var resultBuffer = stringRequset.ConvertString2ByteArray(format);

            StatusString.AppendLine($"GetDataByte.ByteRequest= \"{ resultBuffer.ArrayByteToString("X2")}\" Lenght= \"{resultBuffer.Length}\"");
            return(resultBuffer);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Try get string that implements <see cref="IString"/>.
 /// </summary>
 /// <param name="line"></param>
 /// <param name="result"></param>
 /// <param name="resolver">(optional) type resolver that resolves "StringFormat" parameter into type. Returns null, if could not resolve, exception if resolve fails</param>
 /// <returns>true if part was found</returns>
 public static bool TryGetString(this ILine line, out IString result, IResolver resolver = null)
 {
     try
     {
         for (ILine part = line; part != null; part = part.GetPreviousPart())
         {
             if (part is ILineString valuePart && valuePart.String != null)
             {
                 result = valuePart.String; return(true);
             }
             if (resolver != null && part is ILineParameterEnumerable lineParameters)
             {
                 foreach (ILineParameter parameter in lineParameters)
                 {
                     if (parameter.ParameterName == "String" && parameter.ParameterValue != null)
                     {
                         IStringFormat stringFormat = line.FindStringFormat(resolver);
                         result = stringFormat.Parse(parameter.ParameterValue);
                         return(true);
                     }
                 }
             }
             if (resolver != null && part is ILineParameter lineParameter && lineParameter.ParameterName == "String" && lineParameter.ParameterValue != null)
             {
                 IStringFormat stringFormat = line.FindStringFormat(resolver);
                 result = stringFormat.Parse(lineParameter.ParameterValue);
                 return(true);
             }
         }
         result = new StatusString(null, LineStatus.StringFormatFailedNull);
         return(false);
     } catch (Exception)
     {
         result = new StatusString(null, LineStatus.FailedUnknownReason);
         return(false);
     }
 }
        // unfortunate how it is not virtual in base class
        // TODO: create TexButton icons (RW UI textures are internal)
        public new Rect DoInterface(float x, float y, float width, int index)
        {
            Rect  rect = new Rect(x, y, width, 53f);
            float num  = 0f;

            if (!StatusString.NullOrEmpty())
            {
                num = Mathf.Max(17f, StatusLineMinHeight);
            }
            rect.height += num;
            Color color = Color.white;

            GUI.color = color;
            Text.Font = GameFont.Small;
            if (index % 2 == 0)
            {
                Widgets.DrawAltRect(rect);
            }
            GUI.BeginGroup(rect);
            Rect rect2 = new Rect(0f, 0f, 24f, 24f);

            if (expStack.IndexOf(this) > 0)
            {
                if (Widgets.ButtonText(rect2, "U"))
                {
                    expStack.Reorder(this, -1);
                    SoundDefOf.Tick_High.PlayOneShotOnCamera();
                }
                TooltipHandler.TipRegion(rect2, "ReorderBillUpTip".Translate());
            }
            if (expStack.IndexOf(this) < expStack.ListCount - 1)
            {
                Rect rect3 = new Rect(0f, 24f, 24f, 24f);
                if (Widgets.ButtonText(rect3, "D"))
                {
                    expStack.Reorder(this, 1);
                    SoundDefOf.Tick_Low.PlayOneShotOnCamera();
                }
                TooltipHandler.TipRegion(rect3, "ReorderBillDownTip".Translate());
            }
            Rect rect4 = new Rect(28f, 0f, rect.width - 48f - 20f, 24f);

            Widgets.Label(rect4, LabelCap);

            if (uniquePawnDoer != null)
            {
                Rect pawnBillDoerRect = new Rect(28f, 20f, rect.width - 48f - 20f, 24f);
                Widgets.Label(pawnBillDoerRect, "Reserved for: " + uniquePawnDoer.Name.ToString());
            }



            Rect rect5 = new Rect(300f, 0f, 70f, 24f);

            if (Widgets.ButtonText(rect5, "Delete"))
            {
                expStack.Delete(this);
                SoundDefOf.Click.PlayOneShotOnCamera();
            }
            TooltipHandler.TipRegion(rect5, "DeleteBillTip".Translate());

            Rect rect6 = new Rect(300f, 26f, 70f, 24f);

            //rect6.x -= rect6.width + 4f;
            if (Widgets.ButtonText(rect6, "Suspend"))
            {
                // in RW, setting a bill as suspended will only take effect if you stop the pawn from doing the bill job,
                // for example, if a pawn is doing a bill and you suspend it, it will keep doing the bill until you manually stop them or they stop themselves.
                suspended = !suspended;
                expStack.SetSuspended(this, suspended);
            }
            TooltipHandler.TipRegion(rect6, "SuspendBillTip".Translate());


            /* if (!StatusString.NullOrEmpty())
             * {
             *   Text.Font = GameFont.Tiny;
             *   Rect rect8 = new Rect(24f, rect.height - num, rect.width - 24f, num);
             *   Widgets.Label(rect8, StatusString);
             *   //DoStatusLineInterface(rect8);
             * }*/
            GUI.EndGroup();
            if (suspended)
            {
                Text.Font   = GameFont.Medium;
                Text.Anchor = TextAnchor.MiddleCenter;
                Rect rect9 = new Rect(rect.x + rect.width / 2f - 70f, rect.y + rect.height / 2f - 20f, 140f, 40f);
                GUI.DrawTexture(rect9, TexUI.GrayTextBG);
                Widgets.Label(rect9, "SuspendedCaps".Translate());
                Text.Anchor = TextAnchor.UpperLeft;
                Text.Font   = GameFont.Small;
            }
            Text.Font = GameFont.Small;
            GUI.color = Color.white;
            return(rect);
        }
Ejemplo n.º 10
0
        public RirIpRecord(Alpha2.IsoAlpha2CountryCodes ccResolver, string countryIsoCode, string startAddress, long addressCount, DateTime assignDate, string statusString, string city = null)
        {
            CountryIsoCode      = countryIsoCode;
            StartAddress        = startAddress ?? throw new ArgumentNullException(nameof(startAddress));
            AddressCount        = addressCount;
            AssignDate          = assignDate;
            StatusString        = statusString ?? throw new ArgumentNullException(nameof(statusString));
            CountryCodeResolver = ccResolver ?? throw new ArgumentNullException(nameof(ccResolver));
            City = city;

            RirIpRecordStatus status;

            if (Enum.TryParse <RirIpRecordStatus>(StatusString.Trim(), true, out status))
            {
                Status = status;
            }
            else
            {
                Status = RirIpRecordStatus.Unknown;
            }

            if (StartAddress.Contains('/'))
            {
                string[] segments = StartAddress.Split('/', StringSplitOptions.None);
                StartAddress = segments[0].Trim();
                MaskLength   = int.Parse(segments[1].Trim());
            }
            else
            {
                if (addressCount < 1)
                {
                    MaskLength = 32;
                }
                else
                {
                    double mask = Math.Log2(addressCount);
                    if ((int)mask < mask)
                    {
                        MaskLength = 32 - (int)mask + 1;
                    }
                    else
                    {
                        MaskLength = 32 - (int)mask;
                    }
                }
            }

            string[] ipvalues = StartAddress.Split('.', StringSplitOptions.None);
            if (ipvalues.Length != 4)
            {
                throw new ArgumentException("The provided IP Address is invalid.", nameof(StartAddress));
            }

            uint ipdec = 0;

            ipdec  += byte.Parse(ipvalues[0]);
            ipdec <<= 8;
            ipdec  += byte.Parse(ipvalues[1]);
            ipdec <<= 8;
            ipdec  += byte.Parse(ipvalues[2]);
            ipdec <<= 8;
            ipdec  += byte.Parse(ipvalues[3]);

            AddressDec = ipdec;


            uint maskOverlay = 0xFFFFFFFF;

            maskOverlay  <<= 32 - MaskLength;
            IsNetworkValid = (AddressDec & maskOverlay) == AddressDec;
        }
        public async Task <int> StartExchangePipeline(InDataWrapper <AdInputType> inData)
        {
            //DEBUG
            //TODO: тут можно не дополнять,
            if (inData == null)
            {
                inData = new InDataWrapper <AdInputType>
                {
                    Datas = new List <AdInputType>()
                };
            }

            var countTryingSendData = 0; //Счетчик попыток отправит подготовленные данные.

            foreach (var rule in _rules)
            {
                StatusString.Clear();
                StatusString.AppendLine($"RuleName= \"{rule.Option.Name}\"");
                //КОМАНДА-------------------------------------------------------------
                if (IsCommandHandler(inData.Command, rule.Option.Name))
                {
                    StatusString.AppendLine($"Command= \"{inData.Command}\"");
                    var commandViewRule = rule.ViewRules.FirstOrDefault();
                    _currentRequest = commandViewRule?.GetCommandRequestString();
                    InputData       = new InDataWrapper <AdInputType> {
                        Command = inData.Command
                    };
                    RaiseSendDataRx.OnNext(this);
                    countTryingSendData++;
                    continue;
                }
                //ДАННЫЕ--------------------------------------------------------------
                var takesItems = FilteredAndOrderedAndTakesItems(inData.Datas, rule.Option.WhereFilter, rule.Option.OrderBy, rule.Option.TakeItems, rule.Option.DefaultItemJson)?.ToList();
                if (IsDataHandler(inData.Command, takesItems))
                {
                    foreach (var viewRule in rule.ViewRules)
                    {
                        foreach (var request in viewRule.GetDataRequestString(takesItems))
                        {
                            if (request == null) //правило отображения не подходит под ДАННЫЕ
                            {
                                continue;
                            }

                            _currentRequest = request;
                            InputData       = new InDataWrapper <AdInputType> {
                                Datas = _currentRequest.BatchedData.ToList()
                            };
                            StatusString.AppendLine($"viewRule.Id = \"{viewRule.Option.Id}\".  CountItem4Sending = \"{InputData.Datas.Count}\"");
                            RaiseSendDataRx.OnNext(this);
                            countTryingSendData++;
                        }
                    }
                }
            }
            //Конвеер обработки входных данных завершен
            StatusString.Clear();
            await Task.CompletedTask;

            return(countTryingSendData);
        }
Ejemplo n.º 12
0
        public Rect DoInterface(float x, float y, float width, int index)
        {
            Rect  rect = new Rect(x, y, width, 53f);
            float num  = 0f;

            if (!StatusString.NullOrEmpty())
            {
                num = Mathf.Max(17f, StatusLineMinHeight);
            }
            rect.height += num;
            Color color = Color.white;

            if (!ShouldDoNow())
            {
                color = new Color(1f, 0.7f, 0.7f, 0.7f);
            }
            GUI.color = color;
            Text.Font = GameFont.Small;
            if (index % 2 == 0)
            {
                Widgets.DrawAltRect(rect);
            }
            GUI.BeginGroup(rect);
            Rect rect2 = new Rect(0f, 0f, 24f, 24f);

            if (billStack.IndexOf(this) > 0)
            {
                if (Widgets.ButtonImage(rect2, TexButton.ReorderUp, color))
                {
                    billStack.Reorder(this, -1);
                    SoundDefOf.Tick_High.PlayOneShotOnCamera();
                }
                TooltipHandler.TipRegionByKey(rect2, "ReorderBillUpTip");
            }
            if (billStack.IndexOf(this) < billStack.Count - 1)
            {
                Rect rect3 = new Rect(0f, 24f, 24f, 24f);
                if (Widgets.ButtonImage(rect3, TexButton.ReorderDown, color))
                {
                    billStack.Reorder(this, 1);
                    SoundDefOf.Tick_Low.PlayOneShotOnCamera();
                }
                TooltipHandler.TipRegionByKey(rect3, "ReorderBillDownTip");
            }
            Widgets.Label(new Rect(28f, 0f, rect.width - 48f - 20f, rect.height + 5f), LabelCap);
            DoConfigInterface(rect.AtZero(), color);
            Rect rect4 = new Rect(rect.width - 24f, 0f, 24f, 24f);

            if (Widgets.ButtonImage(rect4, TexButton.DeleteX, color, color * GenUI.SubtleMouseoverColor))
            {
                billStack.Delete(this);
                SoundDefOf.Click.PlayOneShotOnCamera();
            }
            TooltipHandler.TipRegionByKey(rect4, "DeleteBillTip");
            Rect rect5;

            if (!CanCopy)
            {
                rect5 = new Rect(rect4);
            }
            else
            {
                Rect rect6 = new Rect(rect4);
                rect6.x -= rect6.width + 4f;
                if (Widgets.ButtonImageFitted(rect6, TexButton.Copy, color))
                {
                    BillUtility.Clipboard = Clone();
                    SoundDefOf.Tick_High.PlayOneShotOnCamera();
                }
                TooltipHandler.TipRegionByKey(rect6, "CopyBillTip");
                rect5 = new Rect(rect6);
            }
            rect5.x -= rect5.width + 4f;
            if (Widgets.ButtonImage(rect5, TexButton.Suspend, color))
            {
                suspended = !suspended;
                SoundDefOf.Click.PlayOneShotOnCamera();
            }
            TooltipHandler.TipRegionByKey(rect5, "SuspendBillTip");
            if (!StatusString.NullOrEmpty())
            {
                Text.Font = GameFont.Tiny;
                Rect rect7 = new Rect(24f, rect.height - num, rect.width - 24f, num);
                Widgets.Label(rect7, StatusString);
                DoStatusLineInterface(rect7);
            }
            GUI.EndGroup();
            if (suspended)
            {
                Text.Font   = GameFont.Medium;
                Text.Anchor = TextAnchor.MiddleCenter;
                Rect rect8 = new Rect(rect.x + rect.width / 2f - 70f, rect.y + rect.height / 2f - 20f, 140f, 40f);
                GUI.DrawTexture(rect8, TexUI.GrayTextBG);
                Widgets.Label(rect8, "SuspendedCaps".Translate());
                Text.Anchor = TextAnchor.UpperLeft;
                Text.Font   = GameFont.Small;
            }
            Text.Font = GameFont.Small;
            GUI.color = Color.white;
            return(rect);
        }
Ejemplo n.º 13
0
        public Rect DoInterface(float x, float y, float width, int index)
        {
            Rect  rect = new Rect(x, y, width, 53f);
            float num  = 0f;

            if (!StatusString.NullOrEmpty())
            {
                num = Mathf.Max(17f, StatusLineMinHeight);
            }

            rect.height += num;
            Color white = Color.white;

            if (!ShouldDoNow())
            {
                white = new Color(1f, 0.7f, 0.7f, 0.7f);
            }

            GUI.color = white;
            Text.Font = GameFont.Small;
            if (index % 2 == 0)
            {
                Widgets.DrawAltRect(rect);
            }

            GUI.BeginGroup(rect);
            Rect butRect = new Rect(0f, 0f, 24f, 24f);

            if (billStack.IndexOf(this) > 0 && Widgets.ButtonImage(butRect, Widgets_Extensions.reorderUpTex, white))
            {
                billStack.Reorder(this, -1);
                SoundDefOf.TickHigh.PlayOneShotOnCamera(null);
            }
            if (billStack.IndexOf(this) < billStack.Count - 1)
            {
                Rect butRect2 = new Rect(0f, 24f, 24f, 24f);
                if (Widgets.ButtonImage(butRect2, Widgets_Extensions.reorderDownTex, white))
                {
                    billStack.Reorder(this, 1);
                    SoundDefOf.TickLow.PlayOneShotOnCamera(null);
                }
            }

            Rect rect2 = new Rect(28f, 0f, rect.width - 48f - 20f, rect.height + 5f);

            Widgets.Label(rect2, LabelCap);
            DoConfigInterface(rect.AtZero(), white);

            Rect rect3 = new Rect(rect.width - 24f, 0f, 24f, 24f);

            if (Widgets.ButtonImage(rect3, Widgets_Extensions.deleteXTex, white))
            {
                billStack.Delete(this);
            }

            Rect butRect3 = new Rect(rect3);

            butRect3.x -= butRect3.width + 4f;
            if (Widgets.ButtonImage(butRect3, Widgets_Extensions.suspendTex, white))
            {
                suspended = !suspended;
            }

            if (!StatusString.NullOrEmpty())
            {
                Text.Font = GameFont.Tiny;
                Rect rect4 = new Rect(24f, rect.height - num, rect.width - 24f, num);
                Widgets.Label(rect4, StatusString);
                DoStatusLineInterface(rect4);
            }
            GUI.EndGroup();

            if (suspended)
            {
                Text.Font   = GameFont.Medium;
                Text.Anchor = TextAnchor.MiddleCenter;
                Rect rect5 = new Rect(rect.x + rect.width / 2f - 70f, rect.y + rect.height / 2f - 20f, 140f, 40f);
                GUI.DrawTexture(rect5, TexUI.GrayTextBG);
                Widgets.Label(rect5, "SuspendedCaps".Translate());
                Text.Anchor = TextAnchor.UpperLeft;
                Text.Font   = GameFont.Small;
            }

            Text.Font = GameFont.Small;
            GUI.color = Color.white;
            return(rect);
        }
Ejemplo n.º 14
0
        public new Rect DoInterface(float x, float y, float width, int index)
        {
            var rect = new Rect(x, y, width, 53f);

            if (!StatusString.NullOrEmpty())
            {
                rect.height += 17f;
            }
            var white = Color.white;

            if (!ShouldDoNow())
            {
                white = new Color(1f, 0.7f, 0.7f, 0.7f);
            }
            GUI.color = white;
            Text.Font = GameFont.Small;
            if (index % 2 == 0)
            {
                Widgets.DrawAltRect(rect);
            }
            GUI.BeginGroup(rect);
            var butRect = new Rect(0f, 0f, 24f, 24f);

            if ((billStack.IndexOf(this) > 0) && Widgets.ButtonImage(butRect, TexButton.ReorderUp, white))
            {
                billStack.Reorder(this, -1);
                SoundDefOf.TickHigh.PlayOneShotOnCamera();
            }
            if (billStack.IndexOf(this) < billStack.Count - 1)
            {
                var butRect2 = new Rect(0f, 24f, 24f, 24f);
                if (Widgets.ButtonImage(butRect2, TexButton.ReorderDown, white))
                {
                    billStack.Reorder(this, 1);
                    SoundDefOf.TickLow.PlayOneShotOnCamera();
                }
            }
            var rect2 = new Rect(28f, 0f, rect.width - 48f - 20f, 48f);

            // change bill name
            var iBill = this as IExtendable;

            Widgets.Label(rect2, iBill != null ? iBill.Name.Truncate(rect.width - 180f) : LabelCap);

            DoConfigInterface(rect.AtZero(), white);
            var rect3 = new Rect(rect.width - 24f, 0f, 24f, 24f);

            if (Widgets.ButtonImage(rect3, TexButton.DeleteX, white))
            {
                billStack.Delete(this);
            }
            var butRect3 = new Rect(rect3);

            butRect3.x -= butRect3.width + 4f;
            if (Widgets.ButtonImage(butRect3, TexButton.Suspend, white))
            {
                suspended = !suspended;
            }
            if (!StatusString.NullOrEmpty())
            {
                Text.Font = GameFont.Tiny;
                var rect4 = new Rect(24f, rect.height - 17f, rect.width - 24f, 17f);
                Widgets.Label(rect4, StatusString);
            }
            GUI.EndGroup();
            if (suspended)
            {
                Text.Font   = GameFont.Medium;
                Text.Anchor = TextAnchor.MiddleCenter;
                var rect5 = new Rect(rect.x + rect.width / 2f - 70f, rect.y + rect.height / 2f - 20f, 140f, 40f);
                GUI.DrawTexture(rect5, TexUI.GrayTextBG);
                Widgets.Label(rect5, "SuspendedCaps".Translate());
                Text.Anchor = TextAnchor.UpperLeft;
                Text.Font   = GameFont.Small;
            }
            Text.Font = GameFont.Small;
            GUI.color = Color.white;
            return(rect);
        }