Пример #1
0
        /// <summary>
        /// Loads entry from stream.
        /// </summary>
        /// <param name="reeader">Reader to read from.</param>
        public void Load(BinaryReader reader)
        {
            IsVisible = reader.ReadBoolean();
            IsChecked = reader.ReadBoolean();

            int propertyCount = reader.ReadInt32();

            if (propertyCount > 0)
            {
                List <UltimaPacketFilterProperty> properties = new List <UltimaPacketFilterProperty>();

                for (int i = 0; i < propertyCount; i++)
                {
                    UltimaPacketFilterProperty property = new UltimaPacketFilterProperty(this);

                    if (property.Load(reader))
                    {
                        properties.Add(property);
                    }
                }

                Properties = properties;
            }

            bool definition = reader.ReadBoolean();

            if (!definition && _Definition != null)
            {
                IsVisible = true;
                IsChecked = true;
            }
        }
Пример #2
0
        private static void Value_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            UltimaPacketFilterProperty property = d as UltimaPacketFilterProperty;

            if (property != null)
            {
                property.Validate();
            }
        }
Пример #3
0
        private static void IsChecked_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            UltimaPacketFilterProperty property = d as UltimaPacketFilterProperty;

            if (property != null && property.Parent != null && property.Parent.Owner != null)
            {
                property.Parent.Owner.OnChange();
            }
        }
Пример #4
0
        private void AddButton_Click( object sender, RoutedEventArgs e )
        {
            if ( Properties == null || Entry == null )
                return;

            UltimaPacketFilterProperty filter = new UltimaPacketFilterProperty( Entry );
            filter.IsChecked = true;
            filter.Text = filter.ToString();
            Properties.Add( filter );
            Filters.ItemsSource = null;
            Filters.ItemsSource = Properties;
        }
        private void UpdateSample()
        {
            UltimaPacketFilterProperty      filter    = Filters.SelectedValue as UltimaPacketFilterProperty;
            UltimaPacketPropertyDefinition  property  = Definition.SelectedValue as UltimaPacketPropertyDefinition;
            UltimaPacketFilterTypeOperation?operation = Operation.SelectedValue as UltimaPacketFilterTypeOperation?;

            if (filter != null && property != null && operation != null)
            {
                SampleValue.Text = UltimaPacketFilterParser.GetSample(property, (UltimaPacketFilterTypeOperation)operation, false);
                Sample.Text      = UltimaPacketFilterParser.GetComposedSample(property, (UltimaPacketFilterTypeOperation)operation, false, false);
            }
        }
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            if (Properties == null || Entry == null)
            {
                return;
            }

            UltimaPacketFilterProperty filter = new UltimaPacketFilterProperty(Entry);

            filter.IsChecked = true;
            filter.Text      = filter.ToString();
            Properties.Add(filter);
            Filters.ItemsSource = null;
            Filters.ItemsSource = Properties;
        }
        private void Definition_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            UltimaPacketFilterProperty     filter   = Filters.SelectedValue as UltimaPacketFilterProperty;
            UltimaPacketPropertyDefinition property = Definition.SelectedValue as UltimaPacketPropertyDefinition;

            if (property != null)
            {
                Operation.ItemsSource = UltimaPacketFilterParser.GetTypeOperations(property);
            }

            if (filter != null)
            {
                Operation.SelectedValue = null;
                Operation.SelectedValue = filter.Operation;
            }

            UpdateSample();
        }
        private void Filters_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            UltimaPacketFilterProperty filter = Filters.SelectedValue as UltimaPacketFilterProperty;
            bool isValid = filter != null;

            Definition.IsEnabled = isValid;
            Operation.IsEnabled  = isValid;
            Value.IsEnabled      = isValid;

            if (isValid)
            {
                Sample.Visibility      = Visibility.Visible;
                SampleValue.Visibility = Visibility.Visible;
            }
            else
            {
                Sample.Visibility      = Visibility.Collapsed;
                SampleValue.Visibility = Visibility.Collapsed;
            }

            UpdateSample();
        }
Пример #9
0
        private static void Definition_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            UltimaPacketFilterProperty property = d as UltimaPacketFilterProperty;

            if (property != null)
            {
                property._Code = Type.GetTypeCode(property.Definition.Info.PropertyType);

                // Check operation
                if (property.Definition != null)
                {
                    UltimaPacketFilterTypeOperation operation = UltimaPacketFilterTypeOperation.Greater;

                    if (!UltimaPacketFilterParser.IsValidOperation(property.Definition, property.Operation, ref operation))
                    {
                        property.Operation = operation;
                    }
                }

                property.Validate();
            }
        }
Пример #10
0
        private void RemoveFilter()
        {
            if (Properties == null)
            {
                return;
            }

            UltimaPacketFilterProperty filter = Filters.SelectedValue as UltimaPacketFilterProperty;
            int index = Filters.SelectedIndex;

            if (filter != null)
            {
                Properties.Remove(filter);

                if (index >= Properties.Count)
                {
                    index--;
                }

                Filters.ItemsSource   = null;
                Filters.ItemsSource   = Properties;
                Filters.SelectedIndex = index;
            }
        }