public PreferenceListDetails(PreferenceList preferenceList, ListBox listBox, Button buttonUp, Button buttonDown)
 {
   _preferenceList = preferenceList;
   _list = listBox;
   _up = buttonUp;
   _down = buttonDown;
 }
 public PreferenceListDetails(PreferenceList preferenceList, ListBox listBox, Button buttonUp, Button buttonDown)
 {
     _preferenceList = preferenceList;
     _list           = listBox;
     _up             = buttonUp;
     _down           = buttonDown;
 }
示例#3
0
        public bool RemovePersonFromPrefList(IPerson person)
        {
            if (person == null)
            {
                Console.WriteLine("Null value for person being removed.");
                return(false);
            }

            if (person.GetType() == typeof(Woman))
            {
                Console.WriteLine($"Error: Removing Woman: {person.Name} from Men Preference List.");
                return(false);
            }

            if (PreferenceList.Contains(person))
            {
                PreferenceList.Remove(person);
                return(true);
            }
            else
            {
                Console.WriteLine("Person being removed does not exist.");
                return(false);
            }
        }
示例#4
0
        /// <summary>
        /// Creates a default PreferenceList.
        /// </summary>
        /// <param name="position"></param>
        /// <param name="tag"></param>
        /// <returns></returns>
        private Panel CreatePreferenceList(Position position, PreferenceList tag)
        {
            // List containing the items
            ListBox list = new ListBox();

            list.TabIndex = position.NextTabIndex;
            list.Name     = "preferenceList" + position.TabIndex.ToString();
            //list.Size = new Size(position.Width - position.Margin, position.LineHeight * 4);
            list.Size     = new Size(position.Width, position.LineHeight * 4);
            list.Location = new Point(0, 0);
            foreach (string item in tag.SortedItems)
            {
                list.Items.Add(item);
            }
            // Button to move items up
            Button up = new Button();

            up.TabIndex = position.NextTabIndex;
            up.Name     = "preferenceListUp" + position.TabIndex.ToString();
            up.Location = new Point(position.Margin, list.Height);
            up.Size     = new Size((int)(list.Width / 2 - position.Margin * 1.5), position.LineHeight);
            up.Text     = "+";
            up.Enabled  = false;
            // Button to move items down
            Button down = new Button();

            down.TabIndex = position.NextTabIndex;
            down.Name     = "preferenceListDown" + position.TabIndex.ToString();
            down.Location = new Point(up.Location.X + up.Size.Width + position.Margin, up.Location.Y);
            down.Size     = up.Size;
            down.Text     = "-";
            down.Enabled  = false;
            // Add events
            list.SelectedIndexChanged += _listboxSelectionChanged;
            up.Click   += _buttonClicked;
            down.Click += _buttonClicked;
            // Create PreferenceListDetails
            PreferenceListDetails details = new PreferenceListDetails(tag, list, up, down);

            // Set tags
            list.Tag = details;
            up.Tag   = details;
            down.Tag = details;
            // Create and return panel
            Panel panel = details.GetAsPanel(new Size(list.Width, position.LineHeight * 5), new Point(position.StartColumnOne, position.LinePosition));

            panel.TabIndex = position.NextTabIndex;
            panel.Name     = "preferenceListHolder" + position.TabIndex;
            return(panel);
        }
        public async Task <IActionResult> ReOrderPreferences([FromBody] PreferenceList preferences)
        {
            var query = _context.PersonHospitalRelationships as IQueryable <PersonHospitalRelationship>;
            var count = 0;

            foreach (var id in preferences.ChoiceIds)
            {
                count++;
                var item = query.Where(r => r.Id == id).FirstOrDefault();
                item.PreferenceNumber = count;
                _context.Update(item);
            }
            _context.SaveChanges();
            return(Json(new { success = true }));
        }
        private RegisterUpdateUC()
        {
            InitializeComponent();
            sc = new Service1Client();
            dc = new UserImageDC()
            {
                TheUser  = new User(),
                TheImage = "",
            };
            slist = sc.GetAllSexes();
            SexBox.ItemsSource = slist;
            plist = sc.GetAllPreferences();
            PreferenceBox.ItemsSource = plist;
            alist = sc.GetAllAreaCodes();
            AreaCodeBox.ItemsSource = alist;

            this.DataContext = dc;
            DateOfBirthPicker.DisplayDateStart = DateTime.Now.AddYears(-18);
            DateOfBirthPicker.DisplayDateEnd   = DateTime.Now.AddYears(-120);
        }
示例#7
0
        private static void Save()
        {
            using (StreamWriter writer = new StreamWriter(c_projectPreferencesPath, false))
            {
                PreferenceList preferenceList = new PreferenceList();
                preferenceList.m_elements = new List <PreferenceItem>();

                foreach (var preference in s_preferences)
                {
                    preferenceList.m_elements.Add(new PreferenceItem()
                    {
                        m_key   = preference.Key,
                        m_value = preference.Value
                    });
                }

                string text = JsonUtility.ToJson(preferenceList, true);
                writer.Write(text);
            }
        }
示例#8
0
        private static void Load()
        {
            s_preferences = new Dictionary <string, string>();

            using (FileStream fileStream = new FileStream(c_projectPreferencesPath, FileMode.OpenOrCreate))
            {
                using (StreamReader reader = new StreamReader(fileStream))
                {
                    string prefsString = reader.ReadToEnd();
                    if (string.IsNullOrEmpty(prefsString) == false)
                    {
                        PreferenceList preferences = JsonUtility.FromJson <PreferenceList>(prefsString);
                        foreach (var preference in preferences.m_elements)
                        {
                            s_preferences.Add(preference.m_key, preference.m_value);
                        }
                    }
                }
            }
        }
示例#9
0
        public bool AddPersonToPrefList(IPerson person)
        {
            if (person == null)
            {
                Console.WriteLine("Error: Non-existent person being added");
                return(false);
            }

            if (person.GetType() == typeof(Woman))
            {
                Console.WriteLine("Error: Adding Woman to Woman Preference List.");
                return(false);
            }

            if (PreferenceList.Contains(person))
            {
                Console.WriteLine($"Error: Person {person.Name} has already been added to the list.");
                return(false);
            }

            PreferenceList.Add(person);
            return(true);
        }
示例#10
0
        public RegisterPU(Admin father) : this()
        {
            admin = father;
            sr    = new Service1Client();
            xx    = new UserImageDC()
            {
                TheUser  = new User(),
                TheImage = "",
            };
            slist = sr.GetAllSexes();
            SexBox.ItemsSource = slist;
            plist = sr.GetAllPreferences();
            PreferenceBox.ItemsSource = plist;
            alist = sr.GetAllAreaCodes();
            AreaCodeBox.ItemsSource = alist;

            this.DataContext           = xx;
            SexBox.SelectedItem        = xx.TheUser.Sex;
            PreferenceBox.SelectedItem = xx.TheUser.Preference;
            dp.DisplayDateEnd          = DateTime.Now;
            dp.DisplayDateStart        = DateTime.Now.AddYears(-120);

            this.DataContext = xx;
        }
示例#11
0
 /// <summary>
 /// Creates a default PreferenceList.
 /// </summary>
 /// <param name="position"></param>
 /// <param name="tag"></param>
 /// <returns></returns>
 private Panel CreatePreferenceList(Position position, PreferenceList tag)
 {
   // List containing the items
   ListBox list = new ListBox();
   list.TabIndex = position.NextTabIndex;
   list.Name = "preferenceList" + position.TabIndex.ToString();
   //list.Size = new Size(position.Width - position.Margin, position.LineHeight * 4);
   list.Size = new Size(position.Width, position.LineHeight * 4);
   list.Location = new Point(0, 0);
   foreach (string item in tag.SortedItems)
     list.Items.Add(item);
   // Button to move items up
   Button up = new Button();
   up.TabIndex = position.NextTabIndex;
   up.Name = "preferenceListUp" + position.TabIndex.ToString();
   up.Location = new Point(position.Margin, list.Height);
   up.Size = new Size((int)(list.Width / 2 - position.Margin * 1.5), position.LineHeight);
   up.Text = "+";
   up.Enabled = false;
   // Button to move items down
   Button down = new Button();
   down.TabIndex = position.NextTabIndex;
   down.Name = "preferenceListDown" + position.TabIndex.ToString();
   down.Location = new Point(up.Location.X + up.Size.Width + position.Margin, up.Location.Y);
   down.Size = up.Size;
   down.Text = "-";
   down.Enabled = false;
   // Add events
   list.SelectedIndexChanged += _listboxSelectionChanged;
   up.Click += _buttonClicked;
   down.Click += _buttonClicked;
   // Create PreferenceListDetails
   PreferenceListDetails details = new PreferenceListDetails(tag, list, up, down);
   // Set tags
   list.Tag = details;
   up.Tag = details;
   down.Tag = details;
   // Create and return panel
   Panel panel = details.GetAsPanel(new Size(list.Width, position.LineHeight * 5), new Point(position.StartColumnOne, position.LinePosition));
   panel.TabIndex = position.NextTabIndex;
   panel.Name = "preferenceListHolder" + position.TabIndex;
   return panel;
 }
示例#12
0
 public bool Prefers(Person personObj)
 {
     return(PreferenceList.FindIndex(person => person == personObj) < PreferenceList.FindIndex(person => person == Match));
 }