Esempio n. 1
0
        private void buttonSave_Click(object sender, RoutedEventArgs e)
        {
            // Force revalidation
            idError = false; nameError = false; descriptionError = false; publicError = false;
            textBoxId.GetBindingExpression(TextBox.TextProperty).UpdateSource();
            textBoxName.GetBindingExpression(TextBox.TextProperty).UpdateSource();
            textBoxDescription.GetBindingExpression(TextBox.TextProperty).UpdateSource();


            // Type validation
            if (string.IsNullOrWhiteSpace(autoCompleteBoxTypes.Text) ||
                tw.database.GetType(autoCompleteBoxTypes.Text) == null)
            {
                textBoxTypeError.Visibility = System.Windows.Visibility.Visible;
                autoCompleteBoxTypes.Focus();
                return;
            }

            if (idError == false &&
                nameError == false &&
                descriptionError == false &&
                publicError == false && priceError == false)
            {
                resource.Type = tw.database.GetType(autoCompleteBoxTypes.Text);


                // Set the default type icon
                if (string.IsNullOrEmpty(textBoxIconPath.Text) || string.IsNullOrWhiteSpace(textBoxIconPath.Text))
                {
                    resource.IconPath = resource.Type.IconPath;
                }
                Console.WriteLine("duzina liste tagova");
                Console.WriteLine(SelectedTags.Count());


                // Resource.Tags = new ObservableCollection<ResourceTag>(SelectedTags);
                tw.database.AddResource(resource);
                String ids = "";
                foreach (ResourceTag rt in Resource.Tags)
                {
                }

                Close();
                tw.addToResourcesToShow();
            }
        }