Exemplo n.º 1
0
        void clear()
        {
            Filename        = "";
            ReplaceFilename = "";
            Location        = "";

            Rating      = 0;
            Title       = "";
            Description = "";
            Author      = "";
            Copyright   = "";
            Creation    = null;
            IsImported  = false;
            Geotag      = new GeoTagCoordinatePair();

            lock (itemsLock)
            {
                DynamicProperties.Clear();
            }

            SelectedMetaDataPreset = noPresetMetaData;

            lock (tagsLock)
            {
                Tags.Clear();
            }
            lock (addTagsLock)
            {
                AddTags.Clear();
            }
            lock (removeTagsLock)
            {
                RemoveTags.Clear();
            }
        }
Exemplo n.º 2
0
        void clear()
        {
            Title        = null;
            Description  = null;
            Author       = null;
            CreationDate = null;
            Tags.Clear();
            DynamicProperties.Clear();
            Rating = null;

            IsBatchMode = false;
            IsEnabled   = false;

            IsTitleEnabled        = false;
            IsAuthorEnabled       = false;
            IsDescriptionEnabled  = false;
            IsCreationDateEnabled = false;
        }
Exemplo n.º 3
0
        private void ParseTemplate([NotNull] XElement templateElement)
        {
            Debug.ArgumentNotNull(templateElement, nameof(templateElement));

            var parameterValues = new UrlString(Parameters);

            DynamicProperties.Clear();

            foreach (var field in templateElement.Elements())
            {
                var n = field.GetAttributeValue("name");
                if (DynamicProperties.Any(p => p.Name == n))
                {
                    continue;
                }

                var displayName    = field.GetAttributeValue("displayname");
                var category       = field.GetAttributeValue("category");
                var typeName       = field.GetAttributeValue("type");
                var subType        = field.GetAttributeValue("subtype");
                var description    = field.GetAttributeValue("description");
                var bindModeString = field.GetAttributeValue("bindmode");
                var editor         = field.GetAttributeValue("editor");

                var value = HttpUtility.UrlDecode(parameterValues[n] ?? string.Empty);

                var bindMode = BindingMode.None;
                if (!string.IsNullOrEmpty(bindModeString))
                {
                    Enum.TryParse(bindModeString, out bindMode);
                }

                List <Tuple <string, string> > values = null;
                var valuesElement = field.Element("values");
                if (valuesElement != null)
                {
                    values = new List <Tuple <string, string> >();
                    foreach (var element in valuesElement.Elements())
                    {
                        values.Add(new Tuple <string, string>(element.GetAttributeValue("displayname", element.Value), element.Value));
                    }
                }

                parameterValues.Remove(n);

                object actualValue = null;
                Type   type;
                if (bindMode == BindingMode.ReadWrite || bindMode == BindingMode.Write || string.Compare(category, @"Data Bindings", StringComparison.InvariantCultureIgnoreCase) == 0)
                {
                    type = typeof(DataBinding);
                    var bindingValue = value;

                    if (string.Compare(typeName, @"checkbox", StringComparison.InvariantCultureIgnoreCase) == 0)
                    {
                        if (value == @"1" || string.Compare(value, @"true", StringComparison.InvariantCultureIgnoreCase) == 0)
                        {
                            bindingValue = "True";
                        }
                        else if (value == @"0" || string.Compare(value, @"false", StringComparison.InvariantCultureIgnoreCase) == 0)
                        {
                            bindingValue = "False";
                        }
                    }

                    if (values != null)
                    {
                        var item = values.FirstOrDefault(i => i.Item2 == bindingValue);
                        if (item != null)
                        {
                            bindingValue = item.Item1;
                        }
                    }

                    actualValue = new DataBinding(bindingValue);
                }
                else if (string.Compare(typeName, @"checkbox", StringComparison.InvariantCultureIgnoreCase) == 0)
                {
                    type = typeof(bool?);
                    if (value == @"1" || string.Compare(value, @"true", StringComparison.InvariantCultureIgnoreCase) == 0)
                    {
                        actualValue = true;
                    }
                    else if (value == @"0" || string.Compare(value, @"false", StringComparison.InvariantCultureIgnoreCase) == 0)
                    {
                        actualValue = false;
                    }
                }
                else if (string.Compare(typeName, @"tristate", StringComparison.InvariantCultureIgnoreCase) == 0)
                {
                    type = typeof(bool?);
                    if (value == @"1" || string.Compare(value, @"true", StringComparison.InvariantCultureIgnoreCase) == 0)
                    {
                        actualValue = true;
                    }
                    else if (value == @"0" || string.Compare(value, @"false", StringComparison.InvariantCultureIgnoreCase) == 0)
                    {
                        actualValue = false;
                    }
                    else if (value == @"-")
                    {
                        actualValue = null;
                    }
                }
                else if (string.Compare(typeName, @"datetime", StringComparison.InvariantCultureIgnoreCase) == 0 || string.Compare(typeName, @"date", StringComparison.InvariantCultureIgnoreCase) == 0)
                {
                    type        = typeof(DateTime);
                    actualValue = value != null?DateTimeExtensions.FromIso(value) : DateTime.MinValue;
                }
                else if (values != null)
                {
                    type = typeof(DropDownValue);

                    var item = values.FirstOrDefault(i => i.Item2 == value) ?? new Tuple <string, string>(value, value);
                    actualValue = new DropDownValue(item);
                }
                else
                {
                    type        = typeof(string);
                    actualValue = value;
                }

                var dynamicProperty = new DynamicProperty(GetType(), n, displayName, type, typeName, category, description, editor, actualValue, this);
                dynamicProperty.Modified        += RaiseModified;
                dynamicProperty.PropertyChanged += RaisePropertyChanged;

                if (type == typeof(DataBinding))
                {
                    dynamicProperty.Converter = new DataBindingConverter(values);
                }
                else if (type == typeof(DropDownValue) && values != null)
                {
                    dynamicProperty.Converter = new DropDownValueConverter(values);
                }

                if (bindMode == BindingMode.Read)
                {
                    dynamicProperty.IsReadOnly = true;
                }

                if (n == "Id")
                {
                    OldId = value;
                }

                dynamicProperty.Attributes["subtype"]  = subType;
                dynamicProperty.Attributes["bindmode"] = bindMode;

                DynamicProperties.Add(dynamicProperty);
            }

            ParameterDictionary.Parameters.Clear();
            foreach (string key in parameterValues.Parameters.Keys)
            {
                ParameterDictionary.Parameters[key] = parameterValues.Parameters[key];
            }
        }