Beispiel #1
0
        private void _buttonAddAttribute_Click(object sender, RoutedEventArgs e)
        {
            MycoKeyCreator.Application.ViewModel.KeyViewModel keyViewModel = DataContext as MycoKeyCreator.Application.ViewModel.KeyViewModel;

            View.AttributeTypeView           attributeTypeView      = new AttributeTypeView();
            ViewModel.AttributeTypeViewModel attributeTypeViewModel = new ViewModel.AttributeTypeViewModel();
            attributeTypeView.DataContext           = attributeTypeViewModel;
            attributeTypeView.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            attributeTypeView.Owner = this;
            if (attributeTypeView.ShowDialog() != true)
            {
                return;
            }
            if (attributeTypeViewModel.SelectedAttributeType.Value == Library.Database.AttributeType.Choice)
            {
                Library.DBObject.Attribute attribute = new Library.DBObject.Attribute();
                attribute.type     = (Int16)Library.Database.AttributeType.Choice;
                attribute.position = (short)keyViewModel.Attributes.Count();
                EditChoiceAttribute(attribute);
            }
            else
            {
                string description = "";
                if (OpenControls.Wpf.Utilities.View.InputTextView.ShowDialog(this, "New Attribute", "Description", ref description))
                {
                    Library.DBObject.Attribute attribute = new Library.DBObject.Attribute();
                    attribute.type        = (Int16)attributeTypeViewModel.SelectedAttributeType.Value;
                    attribute.position    = (short)keyViewModel.Attributes.Count();
                    attribute.description = description;
                    keyViewModel.AddAttribute(attribute);
                    keyViewModel.ReloadAttributes();
                }
            }
        }
Beispiel #2
0
 private void ShowKeyView(MycoKeyCreator.Library.Database.IKeyManager iKeyManager, MycoKeyCreator.Library.DBObject.Key key)
 {
     MycoKeyCreator.Application.View.KeyView keyView = new MycoKeyCreator.Application.View.KeyView();
     keyView.WindowStartupLocation = WindowStartupLocation.CenterOwner;
     keyView.Owner = this;
     MycoKeyCreator.Application.ViewModel.KeyViewModel keyViewModel = new MycoKeyCreator.Application.ViewModel.KeyViewModel(iKeyManager, key);
     keyView.DataContext = keyViewModel;
     keyView.ShowDialog();
 }
Beispiel #3
0
        private void _buttonEditDescription_Click(object sender, RoutedEventArgs e)
        {
            MycoKeyCreator.Application.ViewModel.KeyViewModel keyViewModel = DataContext as MycoKeyCreator.Application.ViewModel.KeyViewModel;
            string text = keyViewModel.Description;

            if (EditText("Description", ref text))
            {
                keyViewModel.Description = text;
                keyViewModel.Save();
            }
        }
Beispiel #4
0
        private void _buttonEditCopyright_Click(object sender, RoutedEventArgs e)
        {
            MycoKeyCreator.Application.ViewModel.KeyViewModel keyViewModel = DataContext as MycoKeyCreator.Application.ViewModel.KeyViewModel;
            string text = keyViewModel.Copyright;

            if (EditText("Copyright", ref text))
            {
                keyViewModel.Copyright = text;
                keyViewModel.Save();
            }
        }
Beispiel #5
0
        private void _buttonEditHeader_Click(object sender, RoutedEventArgs e)
        {
            MycoKeyCreator.Application.ViewModel.KeyViewModel keyViewModel = DataContext as MycoKeyCreator.Application.ViewModel.KeyViewModel;

            View.KeyHeaderView           keyHeaderView      = new KeyHeaderView();
            ViewModel.KeyHeaderViewModel keyHeaderViewModel = new ViewModel.KeyHeaderViewModel(keyViewModel.IKeyManager, keyViewModel.Key);
            keyHeaderView.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            keyHeaderView.Owner       = this;
            keyHeaderView.DataContext = keyHeaderViewModel;
            if (keyHeaderView.ShowDialog() == true)
            {
                keyViewModel.LoadHeader();
            }
        }
Beispiel #6
0
        private void EditSpeciesAttributes()
        {
            MycoKeyCreator.Application.ViewModel.KeyViewModel keyViewModel = DataContext as MycoKeyCreator.Application.ViewModel.KeyViewModel;

            if (keyViewModel.SelectedSpecies == null)
            {
                return;
            }

            ViewModel.SpeciesAttributesViewModel speciesAttributesViewModel =
                new ViewModel.SpeciesAttributesViewModel(keyViewModel.IKeyManager, keyViewModel.Key, keyViewModel.SelectedSpecies);
            View.SpeciesAttributesView speciesAttributesView = new SpeciesAttributesView();
            speciesAttributesView.DataContext           = speciesAttributesViewModel;
            speciesAttributesView.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            speciesAttributesView.Owner = this;
            speciesAttributesView.ShowDialog();
        }
Beispiel #7
0
        private void EditChoiceAttribute(MycoKeyCreator.Library.DBObject.Attribute attribute)
        {
            if (attribute == null)
            {
                return;
            }

            MycoKeyCreator.Application.ViewModel.KeyViewModel keyViewModel = DataContext as MycoKeyCreator.Application.ViewModel.KeyViewModel;
            ViewModel.AttributeViewModel attributeViewModel = new ViewModel.AttributeViewModel(keyViewModel.IKeyManager, keyViewModel.Key, attribute);
            View.AttributeView           attributeView      = new AttributeView();
            attributeView.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            attributeView.Owner       = this;
            attributeView.DataContext = attributeViewModel;
            if (attributeView.ShowDialog() == true)
            {
                keyViewModel.ReloadAttributes();
            }
        }
Beispiel #8
0
        private void EditSpecies(Library.DBObject.Species species)
        {
            if (species == null)
            {
                return;
            }

            MycoKeyCreator.Application.ViewModel.KeyViewModel keyViewModel = DataContext as MycoKeyCreator.Application.ViewModel.KeyViewModel;
            ViewModel.SpeciesViewModel speciesViewModel = new ViewModel.SpeciesViewModel(keyViewModel.IKeyManager, keyViewModel.Key, species);
            View.SpeciesView           speciesView      = new SpeciesView();
            speciesView.DataContext           = speciesViewModel;
            speciesView.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            speciesView.Owner = this;
            if (speciesView.ShowDialog() == true)
            {
                keyViewModel.LoadSpecies();
            }
        }
Beispiel #9
0
        private bool EditText(string label, ref string text)
        {
            MycoKeyCreator.Application.ViewModel.KeyViewModel keyViewModel = DataContext as MycoKeyCreator.Application.ViewModel.KeyViewModel;

            ViewModel.InputTextViewModel inputTextViewModel = new ViewModel.InputTextViewModel();
            inputTextViewModel.Title = "MycoKeyCreator.Application";
            inputTextViewModel.Text  = text;

            InputTextView inputTextView = new InputTextView();

            inputTextView.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            inputTextView.Owner       = this;
            inputTextView.DataContext = inputTextViewModel;

            bool success = (inputTextView.ShowDialog() == true);

            if (success)
            {
                text = inputTextViewModel.Text;
            }
            return(success);
        }
Beispiel #10
0
        private void EditAttribute()
        {
            MycoKeyCreator.Application.ViewModel.KeyViewModel keyViewModel = DataContext as MycoKeyCreator.Application.ViewModel.KeyViewModel;

            Library.DBObject.Attribute attribute = keyViewModel.SelectedAttribute;
            if (attribute.type == (Int16)Library.Database.AttributeType.Choice)
            {
                EditChoiceAttribute(attribute);
            }
            else if (
                (attribute.type == (Int16)Library.Database.AttributeType.MaximumSize) ||
                (attribute.type == (Int16)Library.Database.AttributeType.MinimumSize)
                )
            {
                string title       = (attribute.type == (Int16)Library.Database.AttributeType.MaximumSize) ? "Maximum Size Attribute" : "Minimum Size Attribute";
                string description = attribute.description;
                if (OpenControls.Wpf.Utilities.View.InputTextView.ShowDialog(this, title, "Description", ref description))
                {
                    attribute.description = description;
                    keyViewModel.UpdateAttribute(attribute);
                    keyViewModel.ReloadAttributes();
                }
            }
        }
Beispiel #11
0
 private void _buttonAddSpecies_Click(object sender, RoutedEventArgs e)
 {
     MycoKeyCreator.Application.ViewModel.KeyViewModel keyViewModel = DataContext as MycoKeyCreator.Application.ViewModel.KeyViewModel;
     Library.DBObject.Species species = new Library.DBObject.Species();
     EditSpecies(species);
 }