Exemple #1
0
        public static void LoadSItemGroupVisualUpdate(GDbTabWrapper <int, ReadableTuple <int> > tab, GTabSettings <int, ReadableTuple <int> > settings, BaseDb gdb)
        {
            List <DbAttribute> attributes = ServerItemGroupSubAttributes.AttributeList.Attributes;
            List <int>         indexes    = new SpecifiedIndexProvider(new int[] { 2, 3, 4, 5, 6, 7 }).GetIndexes();
            Grid grid = tab._displayGrid.Children.Cast <UIElement>().FirstOrDefault(p => (int)p.GetValue(Grid.RowProperty) == 0 && (int)p.GetValue(Grid.ColumnProperty) == 2) as Grid;

            if (grid == null)
            {
                return;
            }

            int row    = 2;
            int column = 0;

            for (int i = 0; i < indexes.Count; i++)
            {
                if (indexes[i] > -1 && indexes[i] < attributes.Count)
                {
                    var attribute = attributes[indexes[i]];

                    if (attribute.IsSkippable)
                    {
                        var  attached = gdb.Attached[attribute.DisplayName];
                        bool isSet    = attached != null && (bool)gdb.Attached[attribute.DisplayName];

                        tab.Dispatch(delegate {
                            var label   = grid.Children.Cast <UIElement>().FirstOrDefault(p => (int)p.GetValue(Grid.RowProperty) == row && (int)p.GetValue(Grid.ColumnProperty) == column);
                            var content = grid.Children.Cast <UIElement>().FirstOrDefault(p => (int)p.GetValue(Grid.RowProperty) == row && (int)p.GetValue(Grid.ColumnProperty) == column + 1);

                            if (label != null)
                            {
                                label.Visibility = isSet ? Visibility.Visible : Visibility.Collapsed;
                                label.IsEnabled  = isSet;
                            }

                            if (content != null)
                            {
                                content.Visibility = isSet ? Visibility.Visible : Visibility.Collapsed;
                                content.IsEnabled  = isSet;
                            }
                        });
                    }
                }

                row += 2;
            }
        }
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);
            }
        }
        public GenericFlagDialog(string text, Type enumType) : base(_getDisplay(Description.GetAnyDescription(enumType)), "cde.ico", SizeToContent.WidthAndHeight, ResizeMode.CanResize)
        {
            InitializeComponent();

            _value = text.ToInt();

            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);
                }
            }

            var values     = Enum.GetValues(enumType).Cast <Enum>().ToList();
            var valuesEnum = Enum.GetValues(enumType).Cast <int>().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;
                }

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

            _boxes.ForEach(_addEvents);
        }