/// <summary>
        /// Instantiates a EntrySelectorDialog WPF dialog
        /// </summary>
        /// <param name="owner">WPF owning window. Used for centering. Set to null if the calling window is not WPF based</param>
        /// <param name="pcc">Package file to load entries from</param>
        /// <param name="supportedInputTypes">Supported selection types</param>
        /// <param name="entryPredicate">A predicate to narrow the displayed entries</param>
        private EntrySelector(Window owner, IMEPackage pcc, SupportedTypes supportedInputTypes, string directionsText = null, Predicate <IEntry> entryPredicate = null)
        {
            this.Pcc = pcc;
            this.SupportedInputTypes    = supportedInputTypes;
            this.DirectionsTextOverride = directionsText;

            var allEntriesBuilding = new List <object>();

            if (SupportedInputTypes.HasFlag(SupportedTypes.Imports))
            {
                for (int i = Pcc.Imports.Count - 1; i >= 0; i--)
                {
                    if (entryPredicate?.Invoke(Pcc.Imports[i]) ?? true)
                    {
                        allEntriesBuilding.Add(Pcc.Imports[i]);
                    }
                }
            }
            if (SupportedInputTypes.HasFlag(SupportedTypes.Exports))
            {
                foreach (ExportEntry exp in Pcc.Exports)
                {
                    if (entryPredicate?.Invoke(exp) ?? true)
                    {
                        allEntriesBuilding.Add(exp);
                    }
                }
            }
            AllEntriesList.ReplaceAll(allEntriesBuilding);
            Owner       = owner;
            DataContext = this;
            LoadCommands();
            InitializeComponent();
            EntrySelector_ComboBox.Focus();
        }
Exemple #2
0
 private InputComboBoxWPF(Window owner, string promptText, IEnumerable <string> items, string defaultValue = "", bool topMost = false)
 {
     DirectionsText = promptText;
     Topmost        = topMost;
     Owner          = owner;
     DataContext    = this;
     LoadCommands();
     InitializeComponent();
     if (owner == null)
     {
         WindowStartupLocation = WindowStartupLocation.CenterScreen;
     }
     EntrySelector_ComboBox.ItemsSource  = items;
     EntrySelector_ComboBox.SelectedItem = defaultValue;
     EntrySelector_ComboBox.Focus();
 }
Exemple #3
0
 private InputComboBoxWPF(Control owner, string promptText, string titleText, IEnumerable <object> items, string defaultValue = "", bool topMost = false)
 {
     DirectionsText = promptText;
     Topmost        = topMost;
     Title          = titleText;
     DataContext    = this;
     LoadCommands();
     InitializeComponent();
     if (owner != null)
     {
         Owner = owner as Window ?? GetWindow(owner);
         WindowStartupLocation = WindowStartupLocation.CenterOwner;
     }
     else
     {
         WindowStartupLocation = WindowStartupLocation.CenterScreen;
     }
     EntrySelector_ComboBox.ItemsSource  = items;
     EntrySelector_ComboBox.SelectedItem = defaultValue;
     EntrySelector_ComboBox.Focus();
 }