Пример #1
0
 bool SerializeValue(object value, StringBuilder builder)
 {
     if (value == null)
     {
         builder.Append("null");
     }
     else if (value.GetType().IsArray)
     {
         SerializeArray(new ArrayList((ICollection)value), builder);
     }
     else if (value is string)
     {
         SerializeString((string)value, builder);
     }
     else if (value is Char)
     {
         SerializeString(Convert.ToString((char)value), builder);
     }
     else if (value is Hashtable)
     {
         SerializeObject((Hashtable)value, builder);
     }
     else if (value is ArrayList)
     {
         SerializeArray((ArrayList)value, builder);
     }
     else if ((value is bool) && ((bool)value == true))
     {
         builder.Append("true");
     }
     else if ((value is bool) && ((bool)value == false))
     {
         builder.Append("false");
     }
     else if (value.GetType().IsPrimitive)
     {
         SerializeNumber(Convert.ToDouble(value), builder);
     }
     else
     {
         return(false);
     }
     return(true);
 }
Пример #2
0
        private void LoadVariables()
        {
            /*Prefix = Convert.ToString(GetConfig("Chat Settings", "Prefix", "[NightPVP] "));                       // CHAT PLUGIN PREFIX
             * PrefixColor = Convert.ToString(GetConfig("Chat Settings", "PrefixColor", "#bf0000"));                // CHAT PLUGIN PREFIX COLOR
             * ChatColor = Convert.ToString(GetConfig("Chat Settings", "ChatColor", "#dd8e8e"));                    // CHAT MESSAGE COLOR
             * SteamIDIcon = Convert.ToUInt64(GetConfig("Chat Settings", "SteamIDIcon", "76561198079320022")); */// SteamID FOR PLUGIN ICON - STEAM PROFILE CREATED FOR THIS PLUGIN / NONE YET /
            pvpcolor        = Convert.ToString(GetConfig("HUD COLOR", "for PVP", "0.6 0.2 0.2"));
            pvecolor        = Convert.ToString(GetConfig("HUD COLOR", "for PVE", "0.5 1.0 0.0"));
            pvpcoloropacity = Convert.ToString(GetConfig("HUD OPACITY", "for PVP", "0.5"));
            pvecoloropacity = Convert.ToString(GetConfig("HUD OPACITY", "for PVE", "0.4"));
            textsize        = Convert.ToInt32(GetConfig("HUD TEXT", "size", "12"));
            pvptextcolor    = Convert.ToString(GetConfig("HUD TEXT", "color for PVP", "1.0 1.0 1.0"));
            pvetextcolor    = Convert.ToString(GetConfig("HUD TEXT", "color for PVE", "1.0 1.0 1.0"));
            HUDleft         = Convert.ToDouble(GetConfig("HUD POSITION", "left", "0.65"));
            HUDbottom       = Convert.ToDouble(GetConfig("HUD COLOR", "bottom", "0.04"));

            if (!ConfigChanged)
            {
                return;
            }
            SaveConfig();
            ConfigChanged = false;
        }
Пример #3
0
 private static decimal Apply(SysFun2 func, decimal value1, decimal value2) =>
 Convert.ToDecimal(func(Convert.ToDouble(value1), Convert.ToDouble(value2)));
Пример #4
0
        // Helper functions to apply functions of double arguments to the decimal parameters

        private static decimal Apply(SysFun func, decimal value) =>
        Convert.ToDecimal(func(Convert.ToDouble(value)));
Пример #5
0
        public static void InputBox(SerializedProperty property)
        {
            var action = (Action)property.Object;
            var panel  = new DockPanel {
                VerticalAlignment = VerticalAlignment.Center,
                // Margin = new Thickness(5, 5, 5, 0)
                Margin = actionPropertyIndex == 0 ? new Thickness(5, 0, 5, 0) : new Thickness(5, 5, 5, 0)
            };

            actionPropertyIndex++;

            var data = new BindingData();

            var label = property.Property.GetCustomAttribute <LabelAttribute>()?.text ?? property.Property.Name.ToDisplayName();

            var textBlock = new TextBlock {
                Text              = label,
                Width             = 100,
                MinWidth          = 50,
                VerticalAlignment = VerticalAlignment.Center,
                // Cursor = Cursors.SizeWE,
                DataContext = data
            };

            var tooltip = property.Property.GetCustomAttribute <TooltipAttribute>();

            if (tooltip is TooltipAttribute attr)
            {
                textBlock.ToolTip = attr.toolTip;
                ToolTipService.SetShowDuration(textBlock, int.MaxValue);
            }

            var textBox = new TextBox {
                Text        = property.Property.GetValue(action).ToString(),
                Margin      = new Thickness(5, 0, 0, 0),
                DataContext = data,
                MinWidth    = 50
            };

            data.Action   = action;
            data.Property = property.Property;
            data.Label    = textBlock;
            data.Controls.Add(textBox);

            textBlock.MouseDown += OnSetDrag;

            textBox.GotFocus       += OnInputGotFocus;
            textBox.LostFocus      += OnInputLostFocus;
            textBox.KeyUp          += OnInputChanged;
            textBox.PreviewKeyDown += OnPreviewKeyDown;

            DockPanel.SetDock(textBlock, Dock.Left);
            DockPanel.SetDock(textBox, Dock.Right);

            var range  = property.Property.GetCustomAttribute <RangeAttribute>();
            var slider = new Slider();

            if (range != null)
            {
                data.Controls.Add(slider);
                if (property.Property.GetValue(action).GetType() == typeof(int))
                {
                    slider.Value = Convert.ToDouble(property.Property.GetValue(action));
                }
                else
                {
                    slider.Value = (double)property.Property.GetValue(action);
                }
                slider.Minimum       = range.min;
                slider.Maximum       = range.max;
                slider.TickFrequency = 1;
                slider.DataContext   = data;
                slider.IsTabStop     = false;
                // if (property.Property.GetValue(action).GetType() == typeof(int))
                slider.TickFrequency = 1;
                // else
                //   slider.TickFrequency = 0.01;
                // slider.LargeChange = 1;
                slider.IsSnapToTickEnabled = true;
                // slider.LargeChange = 5;
                // var collection = new DoubleCollection { range.initial };
                // slider.Ticks = collection;
                // slider.TickPlacement = TickPlacement.BottomRight;
                slider.ValueChanged += OnUpdateSliderValue;
            }
            var dockPanel = new DockPanel {
                Margin = new Thickness(0, 0, 0, 0)
            };


            dockPanel.Children.Add(textBox);
            if (range != null)
            {
                DockPanel.SetDock(slider, Dock.Left);
                dockPanel.Children.Add(slider);
            }

            panel.Children.Add(textBlock);
            panel.Children.Add(dockPanel);

            AddAction(panel, property);
        }