예제 #1
0
        private void menuAddInterest_Click(object sender, EventArgs e)
        {
            DialogResult ret = DialogResult.None;

            try
            {
                ret = ps.addInterestWindow.ShowDialog();
            }
            catch (Exception)
            {
                Debug.WriteLine("Could not show addInterest dialog");
            }

            if (ret == DialogResult.OK)
            {
                int retval = 0;

                Haggle.Attribute.AttributeList al = ps.addInterestWindow.getAddInterests();

                foreach (Haggle.Attribute a in al.AsArray())
                {
                    Debug.WriteLine("Add interest: " + a.ToString());
                }

                if (al.Size() > 0)
                {
                    retval = ps.hh.AddInterests(al);

                    Debug.WriteLine("Add interests returned: " + retval);
                }
                al = ps.addInterestWindow.getDelInterests();

                foreach (Haggle.Attribute a in al.AsArray())
                {
                    Debug.WriteLine("Delete interest: " + a.ToString());
                }

                if (al.Size() > 0)
                {
                    retval = ps.hh.DeleteInterests(al);

                    Debug.WriteLine("Delete interests returned: " + retval);

                    photoListView.Clear();
                    ps.dataObjects.Clear();
                    ps.addInterestWindow.interestListView.Clear();
                    ps.hh.RequestInterests();
                    ps.hh.RequestDataObjects();
                }
            }
        }
예제 #2
0
        public long interestListUpdate(Haggle.Attribute.AttributeList al)
        {
            long numberOfAttributesAdded = 0;

            Haggle.Attribute[] attrs = al.AsArray();

            interestListView.BeginUpdate();

            foreach (Haggle.Attribute a in attrs)
            {
                bool canAdd = true;

                if (a.GetName() != "Picture")
                {
                    continue;
                }

                string str = a.GetValue();

                // Check that this attribute doesn't already exist:
                for (int i = 0; i < interestListView.Items.Count && canAdd; i++)
                {
                    string   attrvalue = interestListView.Items[i].Text;
                    string[] avw       = attrvalue.Split(':');

                    if (Equals(avw[0], str))
                    {
                        canAdd = false;
                    }
                }

                if (canAdd)
                {
                    // Add weight to string
                    str += ":" + a.GetWeight();

                    ListViewItem lvi = new ListViewItem(str);
                    interestListView.Items.Add(lvi);
                    numberOfAttributesAdded++;
                }
            }

            interestListView.EndUpdate();

            return(numberOfAttributesAdded);
        }