Exemple #1
0
        public override Func <long> ToLong(FlagTypeData settings)
        {
            if (_comparison >= RelationalComparison.BinaryAnd)
            {
                var predicateLeft  = _leftCondition.ToLong(settings);
                var predicateRight = _rightCondition.ToLong(settings);

                switch (_comparison)
                {
                case RelationalComparison.BinaryAnd:
                    return(new Func <long>(() => predicateLeft() & predicateRight()));

                case RelationalComparison.BinaryOr:
                    return(new Func <long>(() => predicateLeft() | predicateRight()));

                case RelationalComparison.BinaryRightShift:
                    return(new Func <long>(() => predicateLeft() >> (int)predicateRight()));

                case RelationalComparison.BinaryLeftShift:
                    return(new Func <long>(() => predicateLeft() << (int)predicateRight()));

                case RelationalComparison.Add:
                    return(new Func <long>(() => predicateLeft() + predicateRight()));

                case RelationalComparison.Minus:
                    return(new Func <long>(() => predicateLeft() - predicateRight()));

                case RelationalComparison.Mult:
                    return(new Func <long>(() => predicateLeft() * predicateRight()));

                case RelationalComparison.Div:
                    return(new Func <long>(() => predicateLeft() / predicateRight()));

                case RelationalComparison.Mod:
                    return(new Func <long>(() => predicateLeft() % predicateRight()));
                }
            }

            return(new Func <long>(() => 0));
        }
Exemple #2
0
        public GenericFlagDialog(DbAttribute attribute, string text, Type enumType, FlagTypeData flagTypeData, string description) : base(description, "cde.ico", SizeToContent.WidthAndHeight, ResizeMode.CanResize)
        {
            InitializeComponent();

            _value = text.ToLong();

            if (flagTypeData != null)
            {
                List <long> valuesEnum = flagTypeData.Values.Where(p => (p.DataFlag & FlagDataProperty.Hide) == 0).Select(p => p.Value).ToList();
                var         values     = flagTypeData.Values.Where(p => (p.DataFlag & FlagDataProperty.Hide) == 0).ToList();

                GridIndexProvider provider = _findGrid(values);

                var toolTips = new string[values.Count];

                for (int i = 0; i < values.Count; i++)
                {
                    toolTips[i] = _getTooltip(values[i].Description);
                }

                AbstractProvider iProvider = new DefaultIndexProvider(0, values.Count);
                ToolTipsBuilder.Initialize(toolTips, this);

                int row;
                int col;

                for (int i = 0; i < values.Count; i++)
                {
                    provider.Next(out row, out col);

                    int      index = (int)iProvider.Next();
                    CheckBox box   = new CheckBox {
                        Content = values[index].Name, Margin = new Thickness(3, 6, 3, 6), VerticalAlignment = VerticalAlignment.Center
                    };

                    var      menu = new ContextMenu();
                    MenuItem item = new MenuItem();
                    item.Header     = "Restrict search to [" + values[index].Name + "]";
                    box.ContextMenu = menu;
                    menu.Items.Add(item);
                    item.Click += delegate {
                        var selected = SdeEditor.Instance.Tabs.FirstOrDefault(p => p.IsSelected);

                        if (selected != null)
                        {
                            selected._dbSearchPanel._searchTextBox.Text = "([" + attribute.AttributeName + "] & " + "Flags." + values[index].Name + ") != 0";
                        }
                    };

                    box.Tag = valuesEnum[index];
                    WpfUtils.AddMouseInOutEffectsBox(box);
                    _boxes.Add(box);
                    _upperGrid.Children.Add(box);
                    WpfUtilities.SetGridPosition(box, row, 2 * col);
                }

                _boxes.ForEach(_addEvents);
            }
            else
            {
                if (enumType.BaseType != typeof(Enum))
                {
                    throw new Exception("Invalid argument type, excepted an enum.");
                }

                if (enumType == typeof(MobModeType))
                {
                    if (DbPathLocator.GetServerType() == ServerType.RAthena && !ProjectConfiguration.UseOldRAthenaMode)
                    {
                        enumType = typeof(MobModeTypeNew);
                    }
                }

                List <long> valuesEnum = Enum.GetValues(enumType).Cast <int>().Select(p => (long)p).ToList();
                var         values     = Enum.GetValues(enumType).Cast <Enum>().ToList();

                string[] commands = Description.GetAnyDescription(enumType).Split('#');

                if (commands.Any(p => p.StartsWith("max_col_width:")))
                {
                    _maxColWidth = Int32.Parse(commands.First(p => p.StartsWith("max_col_width")).Split(':')[1]);
                }

                GridIndexProvider provider = _findGrid(values);

                var toolTips = new string[values.Count];

                if (!commands.Contains("disable_tooltips"))
                {
                    for (int i = 0; i < values.Count; i++)
                    {
                        toolTips[i] = _getTooltip(Description.GetDescription(values[i]));
                    }
                }

                AbstractProvider iProvider = new DefaultIndexProvider(0, values.Count);

                if (commands.Any(p => p.StartsWith("order:")))
                {
                    List <int> order = commands.First(p => p.StartsWith("order:")).Split(':')[1].Split(',').Select(Int32.Parse).ToList();

                    for (int i = 0; i < values.Count; i++)
                    {
                        if (!order.Contains(i))
                        {
                            order.Add(i);
                        }
                    }

                    iProvider = new SpecifiedIndexProvider(order);
                }

                ToolTipsBuilder.Initialize(toolTips, this);

                int        row;
                int        col;
                ServerType currentType = DbPathLocator.GetServerType();

                for (int i = 0; i < values.Count; i++)
                {
                    provider.Next(out row, out col);

                    int      index = (int)iProvider.Next();
                    CheckBox box   = new CheckBox {
                        Content = _getDisplay(Description.GetDescription(values[index])), Margin = new Thickness(3, 6, 3, 6), VerticalAlignment = VerticalAlignment.Center
                    };
                    ServerType type = _getEmuRestrition(Description.GetDescription(values[index]));

                    if ((type & currentType) != currentType)
                    {
                        box.IsEnabled = false;
                    }

                    var      menu = new ContextMenu();
                    MenuItem item = new MenuItem();
                    item.Header     = "Restrict search to [" + _getDisplay(Description.GetDescription(values[index])) + "]";
                    box.ContextMenu = menu;
                    menu.Items.Add(item);
                    item.Click += delegate {
                        var selected = SdeEditor.Instance.Tabs.FirstOrDefault(p => p.IsSelected);

                        if (selected != null)
                        {
                            selected._dbSearchPanel._searchTextBox.Text = "([" + attribute.AttributeName + "] & " + valuesEnum[index] + ") != 0";
                        }
                    };

                    box.Tag = valuesEnum[index];
                    WpfUtils.AddMouseInOutEffectsBox(box);
                    _boxes.Add(box);
                    _upperGrid.Children.Add(box);
                    WpfUtilities.SetGridPosition(box, row, 2 * col);
                }

                _boxes.ForEach(_addEvents);
            }
        }
Exemple #3
0
 public GenericFlagDialog(DbAttribute attribute, string text, Type enumType, FlagTypeData flagTypeData) : this(attribute, text, enumType, flagTypeData, enumType == null ? "Flag edit" : _getDisplay(Description.GetAnyDescription(enumType)))
 {
 }
Exemple #4
0
 public override Func <long> ToLong(FlagTypeData settings)
 {
     return(new Func <long>(() => settings.Name2Value[Value]));
 }
Exemple #5
0
 public virtual Func <long> ToLong(FlagTypeData settings)
 {
     return(new Func <long>(() => 0));
 }
Exemple #6
0
        public override Func <long> ToLong(FlagTypeData settings)
        {
            var predicate = Condition.ToLong(settings);

            return(new Func <long>(() => IsReversed ? predicate() : ~predicate()));
        }