BeginUpdate() публичный Метод

public BeginUpdate ( ) : void
Результат void
Пример #1
0
 private void btnSet_Click(object sender, EventArgs e)
 {
     try
     {
         string errMsg = GenericQbItem.ValidateText(typeof(string), typeof(string), txtItem.Text);
         if (errMsg.Length != 0)
         {
             err.SetError(txtItem, errMsg);
         }
         else
         {
             try
             {
                 lstItems.BeginUpdate();
                 int idx = getSelectedItem();
                 _preventUpdate      = true;
                 lstItems.Items[idx] = ""; //force item to update, if only case has changed it won't update
                 lstItems.Items[idx] = txtItem.Text;
             }
             finally
             {
                 _preventUpdate = false;
                 lstItems.EndUpdate();
             }
         }
     }
     catch (Exception ex)
     {
         base.ShowException("Script Set Item Error", ex);
     }
 }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            // Create an instance of the ListBox.
            ListBox listBox1 = new ListBox();
            // Set the size and location of the ListBox.
            listBox1.Size = new System.Drawing.Size(200, 100);
            listBox1.Location = new System.Drawing.Point(10, 10);
            // Add the ListBox to the form.
            this.Controls.Add(listBox1);
            // Set the ListBox to display items in multiple columns.
            listBox1.MultiColumn = true;
            // Set the selection mode to multiple and extended.
            listBox1.SelectionMode = SelectionMode.MultiExtended;

            // Shutdown the painting of the ListBox as items are added.
            listBox1.BeginUpdate();
            // Loop through and add 50 items to the ListBox.
            for (int x = 1; x <= 50; x++)
            {
                listBox1.Items.Add("Item " + x.ToString());
            }
            // Allow the ListBox to repaint and display the new items.
            listBox1.EndUpdate();

            // Select three items from the ListBox.
            listBox1.SetSelected(1, true);
            listBox1.SetSelected(3, true);
            listBox1.SetSelected(5, true);

            // Display the second selected item in the ListBox to the console.
            System.Diagnostics.Debug.WriteLine(listBox1.SelectedItems[1].ToString());
            // Display the index of the first selected item in the ListBox.
            System.Diagnostics.Debug.WriteLine(listBox1.SelectedIndices[0].ToString());
        }
Пример #3
0
        //js-Someone else added this. I don't know what it's for:

        /*private void FormLogOn_MinimumSizeChanged(object sender, EventArgs e){
         *      this.Parent.MinimumSize = this.MinimumSize;
         * }*/

        private void FillListBox()
        {
            listUser.BeginUpdate();
            listUser.Items.Clear();
            shortList = new List <Userod>();
            for (int i = 0; i < UserodC.Listt.Count; i++)
            {
                if (!UserodC.Listt[i].IsHidden)
                {
                    shortList.Add(UserodC.Listt[i]);
                }
            }
            for (int i = 0; i < shortList.Count; i++)
            {
                listUser.Items.Add(shortList[i]);
                if (Security.CurUser != null && shortList[i].UserNum == Security.CurUser.UserNum)
                {
                    listUser.SelectedIndex = i;
                }
            }
            if (listUser.SelectedIndex == -1)
            {
                listUser.SelectedIndex = 0;
            }
            listUser.EndUpdate();
        }
        private void tbEIName_TextChanged(object sender, System.EventArgs e)
        {
            int cur = lbImages.SelectedIndex;

            if (cur < 0)
            {
                return;
            }

            EmbeddedImageValues eiv = lbImages.Items[cur] as EmbeddedImageValues;

            if (eiv == null)
            {
                return;
            }

            if (eiv.Name == tbEIName.Text)
            {
                return;
            }

            eiv.Name = tbEIName.Text;
            // text doesn't change in listbox; force change by removing and re-adding item
            lbImages.BeginUpdate();
            lbImages.Items.RemoveAt(cur);
            lbImages.Items.Insert(cur, eiv);
            lbImages.SelectedIndex = cur;
            lbImages.EndUpdate();
        }
Пример #5
0
 private void FillListBox()
 {
     Userods.RefreshCache();
     UserGroups.RefreshCache();
     GroupPermissions.RefreshCache();
     listUser.BeginUpdate();
     listUser.Items.Clear();
     if (PrefC.GetBool(PrefName.UserNameManualEntry))
     {
         //Because _listUsers is used to verify the user name typed in, we need to include both non-hidden and CEMT users for offices that type in their credentials instead of picking.
         _listUsers = Userods.GetUsers(true);
     }
     else if (checkShowCEMTUsers.Checked)             //Only show list of CEMT users.
     {
         _listUsers = Userods.GetUsersForCEMT().Where(x => !x.IsHidden).ToList();
     }
     else              //This will be the most common way to fill the user list.  Only includes non-hidden, non-CEMT users.
     {
         _listUsers = Userods.GetUsers();
     }
     _listUsers.ForEach(x => listUser.Items.Add(x));
     if (UserNumPrompt > 0)
     {
         listUser.SelectedIndex = _listUsers.FindIndex(x => x.UserNum == UserNumPrompt);            //can be -1 if not found
     }
     else if (Security.CurUser != null)
     {
         listUser.SelectedIndex = _listUsers.FindIndex(x => x.UserNum == Security.CurUser.UserNum); //can be -1 if not found
     }
     if (listUser.SelectedIndex == -1 && listUser.Items.Count > 0)                                  //It is possible there are no users in the list if all users are CEMT users.
     {
         listUser.SelectedIndex = 0;
     }
     listUser.EndUpdate();
 }
Пример #6
0
        public static int ReadFile(string fileName, ListBox listbox)
        {
            if (File.Exists(fileName))
            {
                using (StreamReader sr = new StreamReader(new FileStream(fileName, FileMode.Open)))
                {
                    listbox.BeginUpdate();

                    while (!sr.EndOfStream)
                    {
                        string str = sr.ReadLine();

                        if(str.Length > 0)
                            listbox.Items.Add(str);
                    }

                    listbox.EndUpdate();

                    sr.Close();

                    return 0;
                }
            }

            return -1;
        }
Пример #7
0
 /// <summary>
 /// ¬озвращает измененное значение свойства
 /// </summary>
 /// <param name="value">»сходное значение</param>
 protected override Object OnEdit(Object value)
 {
     // создаем выпадающий список значений
     ListBox valuesList = new ListBox();
     valuesList.BorderStyle = BorderStyle.None;
     valuesList.BeginUpdate();
     try
     {
         // заполн¤ем список значени¤ми
         valuesList.Items.AddRange(Values);
     }
     finally
     {
         valuesList.EndUpdate();
     }
     // определ¤ем высоту списка
     Int32 heightMultiplier = valuesList.Items.Count > 7 ? 7 : valuesList.Items.Count;
     valuesList.Height = valuesList.ItemHeight * (heightMultiplier + 1);
     // выбираем строку в списке в зависимости от значени¤ свойства
     valuesList.SelectedIndex = ObjectToIndex(value);
     // добавл¤ем поддержку закрыти¤ по щелчку мыши
     valuesList.Click += new EventHandler(valuesList_Click);
     // открываем список значений
     EdSvc.DropDownControl(valuesList);
     // возвращаем выбранное значение свойства
     return IndexToObject(valuesList.SelectedIndex);
 }
Пример #8
0
        /// <summary>
        /// Compares the lists of articles in the 2 provided Lists
        /// Best to provide an already sorted list. List 1 should be the smallest list
        /// </summary>
        /// <param name="list1">First List (preferably the smallest)</param>
        /// <param name="list2">Second List</param>
        /// <param name="lb1">List Box where unique items from list1 should go</param>
        /// <param name="lb2">List Box where unique items from list2 should go</param>
        /// <param name="lb3">List Box where the duplicates should go</param>
        private static void CompareLists(IList<Article> list1, ICollection<Article> list2, ListBox lb1, ListBox lb2, ListBox lb3)
        {
            lb1.BeginUpdate();
            lb2.BeginUpdate();
            lb3.BeginUpdate();

            while (list1.Count > 0)
            {
                Article a = list1[0];
                if (list2.Contains(a))
                {
                    lb3.Items.Add(a.Name);
                    list2.Remove(a);
                }
                else
                    lb1.Items.Add(a.Name);

                list1.Remove(a);
            }

            foreach (Article article in list2)
            {
                lb2.Items.Add(article.Name);
            }

            lb1.EndUpdate();
            lb2.EndUpdate();
            lb3.EndUpdate();
        }
Пример #9
0
        private void FormConvertLang39_Load(object sender, System.EventArgs e)
        {
            textOldCode.Text = OldCulture.DisplayName;
            string suggestedName = string.Format("{0}-{0}", OldCulture.Name);

            ciList = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
            string suggestedItem = null;

            listCulture.BeginUpdate();
            for (int i = 0; i < ciList.Length; i++)
            {
                string item = ciList[i].DisplayName;
                listCulture.Items.Add(item);
                if (ciList[i].Name.ToLowerInvariant() == suggestedName)
                {
                    suggestedItem = item;
                }
            }
            listCulture.EndUpdate();

            if (suggestedItem != null)
            {
                listCulture.SelectedItem = suggestedItem;
            }
        }
Пример #10
0
        private void LoadAsstList()
        {
            ListCourse course = (ListCourse)lstCourses.SelectedItem;

            Assignment[] assts;
            try {
                assts = m_cds.GetAssignments(course.Course.ID);
            } catch (Exception er) {
                MessageBox.Show("Error: " + er.Message, "Error connecting to FrontDesk",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            lstAssts.BeginUpdate();
            lstAssts.Items.Clear();
            foreach (Assignment asst in assts)
            {
                lstAssts.Items.Add(new ListAsst(asst));
            }
            lstAssts.EndUpdate();

            if (lstAssts.Items.Count == 0)
            {
                Wizard.SetWizardButtons(WizardButton.Back);
            }
            else
            {
                Wizard.SetWizardButtons(WizardButton.Back | WizardButton.Next);
                lstAssts.SelectedIndex = 0;
            }
        }
Пример #11
0
 private void InsertTestResultItem(TestResultItem item)
 {
     detailList.BeginUpdate();
     detailList.Items.Insert(detailList.Items.Count, item);
     detailList.SelectedIndex = 0;
     detailList.EndUpdate();
 }
Пример #12
0
        private void tbDSName_TextChanged(object sender, System.EventArgs e)
        {
            int cur = lbDataSources.SelectedIndex;

            if (cur < 0)
            {
                return;
            }

            DataSourceValues dsv = lbDataSources.Items[cur] as DataSourceValues;

            if (dsv == null)
            {
                return;
            }

            if (dsv.Name == tbDSName.Text)
            {
                return;
            }

            dsv.Name = tbDSName.Text;
            // text doesn't change in listbox; force change by removing and re-adding item
            lbDataSources.BeginUpdate();
            lbDataSources.Items.RemoveAt(cur);
            lbDataSources.Items.Insert(cur, dsv);
            lbDataSources.SelectedIndex = cur;
            lbDataSources.EndUpdate();
        }
Пример #13
0
        private ChemtoolsGui()
        {
            this.Text = "ChemTools";
            this.Size = new Size(640, 640);

            input = new TextBox();
            input.Location = new Point(20, 20);
            input.Size = new Size(250, 20);
            input.TextChanged += new EventHandler(InputChanged);
            input.KeyDown += new KeyEventHandler(InputKeyDown);

            output = new RichTextBox();
            output.Location = new Point(50, 160);
            output.Size = new Size(250, 300);

            savedList = new ListBox();
            savedList.Location = new Point(300, 20);
            savedList.Size = new Size(300, 120);
            savedList.SelectedIndexChanged += new EventHandler(ListSelectChange);
            savedList.KeyDown += new KeyEventHandler(ListKeyDown);
            savedList.BeginUpdate();
            savedList.Items.Add("H2O");
            savedList.Items.Add("CO2");
            savedList.Items.Add("C4H10+O2=CO2+H2O");
            savedList.Items.Add("44.0095gCO2");
            savedList.EndUpdate();

            savedOutput = new RichTextBox();
            savedOutput.Location = new Point(300, 160);
            savedOutput.Size = new Size(250, 300);

            btnAdd = new Button();
            btnAdd.Location = new Point(180, 50);
            btnAdd.Text = "Save";
            btnAdd.Click += new EventHandler(AddClick);

            btnDelete = new Button();
            btnDelete.Location = new Point(180, 100);
            btnDelete.Text = "Delete";
            btnDelete.Click += new EventHandler(DeleteClick);

            btnClear = new Button();
            btnClear.Location = new Point(20, 50);
            btnClear.Text = "Clear";
            btnClear.Click += new EventHandler(ClearClick);

            btnReset = new Button();
            btnReset.Location = new Point(20, 100);
            btnReset.Text = "Reset All";
            btnReset.Click += new EventHandler(ResetClick);

            this.Controls.Add(input);
            this.Controls.Add(output);
            this.Controls.Add(savedList);
            this.Controls.Add(savedOutput);
            this.Controls.Add(btnAdd);
            this.Controls.Add(btnDelete);
            this.Controls.Add(btnClear);
            this.Controls.Add(btnReset);
        }
        private void listBox1_Click(object sender, System.EventArgs e)
        {
            if (box1.SelectedIndices.Count > 0)
            {
                if (b_MultiSel)
                {
                    box1.BeginUpdate();

                    this.strCols.Clear();
                    if (box1.SelectedIndices.Contains(0))
                    {
                        for (int i = 0; i < box1.Items.Count; i++)
                        {
                            box1.SetSelected(i, false);
                        }
                    }
                    else
                    {
                        foreach (int index in box1.SelectedIndices)
                        {
                            this.strCols.Add(box1.Items[index].ToString());
                        }
                    }

                    box1.EndUpdate();
                }
                else
                {
                    this.strResult = (string)box1.SelectedItem;

                    edSvc.CloseDropDown();
                }
            }
        }
Пример #15
0
 private void m_mthSetItem(clsCaseGradeValue p_objGradeValue)
 {
     m_lstDetail.BeginUpdate();
     m_lsvDitail.Visible = false;
     m_lstDetail.Visible = true;
     m_lstDetail.Items.Clear();
     for (int j2 = 0; j2 < p_objGradeValue.m_objItemValueArr.Length; j2++)
     {
         if (p_objGradeValue.m_objItemValueArr[j2].m_strDescription != null)
         {
             if (p_objGradeValue.m_objItemValueArr[j2].m_strDescription != "")
             {
                 string str = p_objGradeValue.m_objItemValueArr[j2].m_strDescription + "(";
                 try
                 {
                     float.Parse(p_objGradeValue.m_objItemValueArr[j2].m_strItemContent);
                     str += "扣分:" + p_objGradeValue.m_objItemValueArr[j2].m_strItemContent + "分)";
                 }
                 catch
                 {
                     str += p_objGradeValue.m_objItemValueArr[j2].m_strItemContent + ")";
                 }
                 m_lstDetail.Items.Add(str);
             }
         }
     }
     m_lstDetail.EndUpdate();
 }
Пример #16
0
        private void InitOtherColors()
        {
            listWeb.BeginUpdate();
            listWeb.Items.Clear();
            Type type = typeof(Color);

            System.Reflection.PropertyInfo[] fields = type.GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
            Color clr = new Color();

            foreach (System.Reflection.PropertyInfo pi in fields)
            {
                listWeb.Items.Add(pi.GetValue(clr, null));
            }
            listWeb.EndUpdate();

            listSystem.BeginUpdate();
            listSystem.Items.Clear();
            type   = typeof(SystemColors);
            fields = type.GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
            foreach (System.Reflection.PropertyInfo pi in fields)
            {
                listSystem.Items.Add(pi.GetValue(clr, null));
            }
            listSystem.EndUpdate();
        }
Пример #17
0
 private void lstMultiSelect_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     // Display a list of selected indices.
     // The SelectedIndices property returns a SelectedIndexCollection
     // object. Use its CopyTo method to copy the items to
     // an array, so you can bind the list to a ListBox control.
     try {
         int[] aIndices = new int[lstMultiSelect.SelectedIndices.Count];
         lstMultiSelect.SelectedIndices.CopyTo(aIndices, 0);
         lstSelected.DataSource = aIndices;
         // Demonstrate how to "walk" the selected items list.
         lstSelectedItems.Items.Clear();
         // Begin/EndUpdate turn off/on display of the control
         // you're adding items. Just makes the update "cleaner".
         lstSelectedItems.BeginUpdate();
         foreach (FileInfo fi in lstMultiSelect.SelectedItems)
         {
             lstSelectedItems.Items.Add(fi.Name);
         }
         lstSelectedItems.EndUpdate();
     } catch
     {
         lstSelected.DataSource = null;
     }
 }
Пример #18
0
 public static int FillListBox(ListBox lb, List<string> list)
 {
     lb.BeginUpdate();
     foreach(var s in list)
     lb.Items.Add(s);
     lb.EndUpdate();
     return lb.Items.Count;
 }
Пример #19
0
 private void Form1_Click(object sender, System.EventArgs e)
 {
     ListBox1.BeginUpdate();
     for (int i = 0; i < 10000; i++)
     {
         ListBox1.Items.Add("Line " + i.ToString());
     }
     ListBox1.EndUpdate();
 }
Пример #20
0
        private void menuDel_Click(object sender, System.EventArgs e)
        {
            int idx = listBox.SelectedIndex;

            if (idx != -1)
            {
                if (MessageBox.Show("Do you want delete data?", "Question?",
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    // smazat data
                    listBox.BeginUpdate();
                    DataList.RemoveAt(idx);
                    this.SetDataList(DataList);
                    listBox.EndUpdate();
                    listBox.Invalidate();
                }
            }
        }
Пример #21
0
        /// <summary>
        /// Event signals a new event and to update the event log display
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        private void Logger_Changed(object sender, EventArgs e)
        {
            lbEvents.BeginUpdate();
            CurrencyManager cManager = this.BindingContext[Logger.Log] as CurrencyManager;

            cManager.Refresh();
            lbEvents.SelectedIndex = lbEvents.Items.Count - 1;
            lbEvents.EndUpdate();
        }
Пример #22
0
 private void _lstFiles_SizeChanged(object sender, EventArgs e)
 {
     object[] tmp = new object[_lstFiles.Items.Count];
     _lstFiles.BeginUpdate();
     _lstFiles.Items.CopyTo(tmp, 0);
     _lstFiles.Items.Clear();
     _lstFiles.Items.AddRange(tmp);
     _lstFiles.EndUpdate();
 }
Пример #23
0
 /// <summary>
 /// Fills lisbox with unsaved documents preceeded with corresponding
 /// projects and parent solution names.
 /// </summary>
 /// <param name="unsavedDocuments"></param>
 private void FillListBox(IList unsavedDocuments)
 {
     m_listBoxUnsavedDocuments.BeginUpdate();
     foreach (Document document in unsavedDocuments)
     {
         AddDocumentItem(document);
     }
     m_listBoxUnsavedDocuments.EndUpdate();
 }
Пример #24
0
 private void addImage(string imageToLoad)
 {
     if (imageToLoad != "")
     {
         imageList1.Images.Add(Image.FromFile(imageToLoad));
         listBox1.BeginUpdate();
         listBox1.Items.Add(imageToLoad);
         listBox1.EndUpdate();
     }
 }
Пример #25
0
 /// <summary>
 /// Clears and fills the control with the given data. 
 /// </summary>
 /// <param name="ctrl">Listbox control to fill</param>
 /// <param name="data">List of data</param>
 /// <param name="none">Flag to fill the first position with "None"</param>
 /// <remarks>Painting is suspended until after items have been added</remarks>
 public static void Populate(ListBox ctrl, IList<dynamic> data, bool none)
 {
     ctrl.BeginUpdate();
     ctrl.Items.Clear();
     if (none)
         ctrl.Items.Add("<None>");
     for (int i = 1; i < data.Count; i++)
         ctrl.Items.Add(data[i].ToString());
     ctrl.EndUpdate();
 }
Пример #26
0
 protected void UpdateList()
 {
     lstPhotos.BeginUpdate();
     lstPhotos.Items.Clear();
     foreach (Photograph photo in _album)
     {
         lstPhotos.Items.Add(photo);
     }
     lstPhotos.EndUpdate();
 }
Пример #27
0
 private void UpdateCurrentListItem()
 {
     optionListBox.BeginUpdate();
     optionListBox.Items.Clear();
     foreach (string tag in currentOpt.List)
     {
         optionListBox.Items.Add(tag);
     }
     optionListBox.EndUpdate();
 }
Пример #28
0
        public static void SetListItems(ListBox listBox, ListItemWithId[] items)
        {
            listBox.Text = "";
            listBox.Items.Clear();

            listBox.BeginUpdate();

            for (int i = 0; i < items.Length; i++)
                listBox.Items.Add(items[i]);

            listBox.EndUpdate();
        }
Пример #29
0
        private void listBox1_Refresh()
        {
            TreeNodeCollection nodes = TreeView1.Nodes;

            listBox1.BeginUpdate();
            listBox1.Items.Clear();
            foreach (TreeNode n in nodes)
            {
                CallRecursive(n);
            }
            listBox1.EndUpdate();
        }
Пример #30
0
        public void DisplayResource(IResource resource)
        {
            _changeSet     = resource;
            _changeSetList = resource.ToResourceListLive();
            _changeSetList.ResourceChanged += HandleChangesetChanged;
            _edtDescription.Text            = resource.GetPropText(Core.Props.LongBody);
            HighlightDescriptionLinks();

            IResource      repository = _changeSet.GetProp(Props.ChangeSetRepository);
            RepositoryType repType    = SccPlugin.GetRepositoryType(repository);

            repType.OnChangesetSelected(repository, _changeSet);

            _changedFilesList.BeginUpdate();
            try
            {
                _changedFilesList.Items.Clear();
                foreach (FileChange fileChange in resource.GetLinksOfType(FileChange.ResourceType,
                                                                          Props.Change))
                {
                    if (Settings.HideUnchangedFiles)
                    {
                        if (!fileChange.Binary &&
                            fileChange.ChangeType == "edit" &&
                            String.IsNullOrEmpty(fileChange.Diff))
                        {
                            continue;
                        }
                    }

                    _changedFilesList.Items.Add(fileChange);
                }
            }
            finally
            {
                _changedFilesList.EndUpdate();
            }

            if (_changedFilesList.Items.Count == 0)
            {
                ClearSelectedChange();
                _lnkFileName.Links.Clear();
            }
            else
            {
                FileChange fileChange = (FileChange)_changedFilesList.Items [0];
                _changedFilesList.SelectedItem = fileChange;
                if (repType.BuildLinkToFile(repository, fileChange) == null)
                {
                    _lnkFileName.Links.Clear();
                }
            }
        }
Пример #31
0
        private void move(int offset)
        {
            object cur = selectedList.SelectedItem;
            int    idx = selectedList.SelectedIndex;

            selectedList.BeginUpdate();
            selectedList.Items.RemoveAt(idx);
            selectedList.Items.Insert(idx + offset, cur);
            selectedList.SelectedIndex = idx + offset;
            selectedList.EndUpdate();

            updateButtons();
        }
Пример #32
0
 private void updateMembers()
 {
     // Shutdown the painting of the ListBox as items are added.
     lstMembers.BeginUpdate();
     lstMembers.Items.Clear();
     // Loop through and add 50 items to the ListBox.
     foreach (String userHandler in members.Values)
     {
         lstMembers.Items.Add(userHandler);
     }
     // Allow the ListBox to repaint and display the new items.
     lstMembers.EndUpdate();
 }
Пример #33
0
        private void LoadTermos(bool excludeAutorizados, long excludeAutorizadosTipoNoticiaAut, ArrayList includeOthers, long caID)
        {
            long start = 0;

            start = DateTime.Now.Ticks;

            ArrayList termosID = new ArrayList();
            // carregar para memória o conjunto de termos pretendidos
            IDbConnection conn = GisaDataSetHelper.GetConnection();

            try
            {
                conn.Open();
                bool constraints = GisaDataSetHelper.GetInstance().EnforceConstraints;
                GisaDataSetHelper.ManageDatasetConstraints(false);
                termosID = ControloAutRule.Current.LoadTermosData(GisaDataSetHelper.GetInstance(), excludeAutorizados, excludeAutorizadosTipoNoticiaAut, includeOthers, caID, conn);
                GisaDataSetHelper.ManageDatasetConstraints(constraints);
            }
            catch (System.Data.ConstraintException ex)
            {
                Trace.WriteLine(ex);
                Debug.Assert(false, ex.ToString());
                GisaDataSetHelper.FixDataSet(GisaDataSetHelper.GetInstance(), conn);
            }
            finally
            {
                conn.Close();
            }

            Debug.WriteLine("<<Load Termos>>: " + new TimeSpan(DateTime.Now.Ticks - start).ToString());

            start = DateTime.Now.Ticks;

            // popular a lista
            lstEscolher.BeginUpdate();
            lstEscolher.Items.Clear();
            lstEscolher.Items.AddRange(termosID.ToArray());
            lstEscolher.EndUpdate();

            Debug.WriteLine("<<Populate Termos>>: " + new TimeSpan(DateTime.Now.Ticks - start).ToString());

            if (lstEscolher.Items.Count > 0)
            {
                lstEscolher.SelectedIndex = 0;
            }
            else
            {
                gbEscolher.Enabled = false;
                rbEscolher.Enabled = false;
            }
        }
Пример #34
0
        private void cmbList_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            m_Set = cmbList.SelectedItem as TileSet;

            lst.BeginUpdate();
            lst.Items.Clear();

            foreach (TileMask mask in m_Set.Tiles)
            {
                lst.Items.Add(mask);
            }

            lst.EndUpdate();
        }
Пример #35
0
        private void lbParameters_MoveItem(int curloc, int newloc)
        {
            ReportParm rp = lbParameters.Items[curloc] as ReportParm;

            if (rp == null)
            {
                return;
            }

            lbParameters.BeginUpdate();
            lbParameters.Items.RemoveAt(curloc);
            lbParameters.Items.Insert(newloc, rp);
            lbParameters.SelectedIndex = newloc;
            lbParameters.EndUpdate();
        }
Пример #36
0
 void RefreshValList()
 {
     lstVals.BeginUpdate();
     lstVals.Items.Clear();
     foreach (RcVal v in vallist.List)
     {
         lstVals.Items.Add(v.ToString());
     }
     lstVals.Items.Add("(新規)");
     if (0 <= idx && idx < lstVals.Items.Count)
     {
         lstVals.SelectedIndex = idx;
     }
     lstVals.EndUpdate();
 }
Пример #37
0
        private void UpdateTileset()
        {
            lst.BeginUpdate();
            lst.Items.Clear();

            foreach (RandomTile tile in m_TileSet.Tiles)
            {
                lst.Items.Add(tile);
            }

            lst.EndUpdate();

            grpGroup.Text    = m_TileSet.Name;
            bDelItem.Enabled = false;
        }
Пример #38
0
        public void Write_to_log(ref string outstring)
        {
            //write log to log file
            if (outfile.Length > 0)
            {
                StreamWriter log_out_file;
                try
                {
                    log_out_file = File.AppendText(outfile);
                    if (cache.Count > 0)
                    {
                        foreach (string line in cache)
                        {
                            log_out_file.WriteLine(line);
                        }
                        cache.Clear();
                    }
                    log_out_file.WriteLine(outstring);
                    log_out_file.Flush();
                    log_out_file.Close();
                }
                catch (Exception)
                {
                    if (!msgbox)
                    {
                        string msg = string.Format(LocRM.GetString("String9"), outfile);
                        //string msg = "Datei  " + outfile + " kann nicht geöffnet werden";
                        MessageBox.Show(msg, "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        msgbox = true;
                    }
                }
            }
            else
            {
                cache.Add(outstring);
            }

            //write log to log window
            log_output.BeginUpdate();
            if (log_output.Items.Count > maxlines)
            {
                log_output.Items.RemoveAt(0);
            }
            log_output.Items.Add(outstring);
            log_output.TopIndex = log_output.Items.Count - 1;
            log_output.EndUpdate();
            log_output.Refresh();
        }
Пример #39
0
        private void ShowInfoProc(string strMsg, ListBox lstBox, int nMax)
        {
            lstBox.BeginInvoke((Action)delegate ()
            {
                lstBox.BeginUpdate();
                lstBox.Items.Add(strMsg);
                if (nMax > 0)
                {
                    while (lstBox.Items.Count > nMax)
                        lstBox.Items.RemoveAt(0);
                }

                // Scroll to end
                //
                lstBox.SelectedIndex = lstBox.Items.Count - 1;
                lstBox.EndUpdate();
            });
        }        
Пример #40
0
        private void MoveComponent(ListBox source, ListBox dest, IEnumerable<DeckManager.Components.BaseComponent> items)
        {
            source.BeginUpdate();
            dest.BeginUpdate();

            source.Items.Remove(items);
            dest.Items.AddRange(items.ToArray());

            // probably a better way to get the nodenames but whatever
            DeckManager.Boards.Dradis.DradisNodeName SourceNode;
            _sectors.TryGetValue(source, out SourceNode);
            DeckManager.Boards.Dradis.DradisNodeName DestNode;
            _sectors.TryGetValue(dest, out DestNode);
            Program.GManager.MoveComponents(SourceNode, DestNode, items);

            source.EndUpdate();
            dest.EndUpdate();
            // todo add rollback on error checking?
        }
Пример #41
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            ListBox listBox = new ListBox();
            listBox.SelectionMode = SelectionMode.One;
            listBox.SelectedValueChanged += OnListBoxSelectedValueChanged;
            listBox.DisplayMember = nameof(AbstractSkin.Name);
            listBox.BeginUpdate();
            foreach (var skinType in WinFwkHelper.GetDerivedTypes(typeof(AbstractSkin)))
            {
                var skin = Activator.CreateInstance(skinType);
                listBox.Items.Add(skin);
            }
            listBox.EndUpdate();
            listBox.Sorted = true;
            editorService.DropDownControl(listBox);
            if (listBox.SelectedItem == null) // no selection, return the passed-in value as is
                return value;

            return listBox.SelectedItem;
        }
Пример #42
0
        public ListBox NewDecisionListBox(List<DecisionTree> dtChildren)
        {
            ListBox retVal = new ListBox();
            retVal.Font = new Font("Courier New", 8);
            retVal.ScrollAlwaysVisible = true;
            retVal.Width = 223;
            retVal.BeginUpdate();

            foreach (DecisionTree curDecision in dtChildren)
            {
                if (curDecision.Move != null)
                {
                    if ((curDecision.Parent != null) &&
                        (curDecision.Parent.BestChildMove != null) &&
                        (curDecision.Parent.BestChildMove == curDecision.Move))
                    {
                        curDecision.Move.ToStringPrefix = "-> ";
                    }
                    else
                    {
                        curDecision.Move.ToStringPrefix = "   ";
                    }
                }
                else
                {
                    retVal.Width = 140;
                }

                retVal.Items.Add(curDecision);
            }

            retVal.EndUpdate();

            retVal.Height = this.splitContainer1.Panel2.Height - this.hScrollBar1.Height;
            retVal.SelectedIndexChanged += this.OnSelectedIndexChanged;

            return retVal;
        }
Пример #43
0
		private void populateListBox(ListBox listBox, int maxID, string listName) {
			List<String> strings = LanguageManager.GetList(listName);

			listBox.BeginUpdate();
			listBox.Items.Clear();
			for (int i = 0; i < maxID; i++)
				listBox.Items.Add(string.Format(LanguageManager.Get("BehaviorEditor", "unknown"), i));

			foreach (string item in strings) {
				int where = item.IndexOf('=');

				int idx;
				if (item.StartsWith("0x"))
					idx = int.Parse(item.Substring(2, where-2), System.Globalization.NumberStyles.AllowHexSpecifier);
				else
					idx = int.Parse(item.Substring(0, where));

				string text = item.Substring(where+1);

				listBox.Items[idx] = text;
			}
			listBox.EndUpdate();
		}
Пример #44
0
		public static void UpdateList(ListBox listView, SelectableListNodeList items)
		{
			listView.SelectedIndexChanged -= EhListBoxSelectedIndexChanged;
			listView.BeginUpdate();
			listView.Items.Clear();
			for (int i = 0; i < items.Count; i++)
			{
				listView.Items.Add(items[i]);
				if (items[i].Selected)
					listView.SelectedIndex = i;
			}

			listView.EndUpdate();
			listView.SelectedIndexChanged += EhListBoxSelectedIndexChanged;
		}
Пример #45
0
        private static void CompareListsNew(IList<Article> list1, List<Article> list2, ListBox lb1, ListBox lb2, ListBox lb3)
        {
            // hashset by definition does not allow duplicates, discards any on creation
            HashSet<Article> UniqueIn1 = new HashSet<Article>(list1);
            HashSet<Article> Duplicates = new HashSet<Article>(list1);
            HashSet<Article> UniqueIn2 = new HashSet<Article>(list2);

            HashSet<Article> L1HS = new HashSet<Article>(list1);
            HashSet<Article> L2HS = new HashSet<Article>(list2);

            Duplicates.IntersectWith(L2HS);
            UniqueIn1.ExceptWith(L2HS);
            UniqueIn2.ExceptWith(L1HS);

            lb1.BeginUpdate();
            lb2.BeginUpdate();
            lb3.BeginUpdate();

            lb1.Items.AddRange(new List<Article>(UniqueIn1).ToArray());
            lb2.Items.AddRange(new List<Article>(UniqueIn2).ToArray());
            lb3.Items.AddRange(new List<Article>(Duplicates).ToArray());

            lb1.EndUpdate();
            lb2.EndUpdate();
            lb3.EndUpdate();
        }
Пример #46
0
        public static void UpdateExplanation(ListBox box, object item)
        {
            List<string> lines = new List<string>();
            box.BeginUpdate();
            box.Items.Clear();
            if (item.GetType().Equals(typeof(SQLStatement)))
            {
                // explain SQL statement
                var sql = (SQLStatement)item;
                lines.Add("Line #" + sql.LineNumber);
                lines.Add("Statement: " + sql.Statement);
                lines.Add(String.Format("Duration: {0}, Execute: {1}, Fetch: {2}.", sql.Duration, sql.ExecTime, sql.FetchTime));
                lines.Add("Fetched " + sql.FetchCount + " rows.");
                lines.Add("Bind count: " + sql.BindValues.Count);
                for (var x = 0; x < sql.BindValues.Count; x++)
                {
                    var index = sql.BindValues[x].Index;
                    var value = sql.BindValues[x].Value;
                    var typ = sql.BindValues[x].Type;
                    var length = sql.BindValues[x].Length;

                    lines.Add(String.Format("Bind #{0} - {1} ({2}) - {3}", index, typ, length, value));
                }
                lines.Add("Caller: " + (sql.ParentCall == null ? "None" : ("Line #" + sql.ParentCall.StartLine) + " " + sql.ParentCall.Function));

                /* handle error */
                if (sql.IsError)
                {
                    lines.Add("SQL Error:");
                    lines.Add("    Error Position: " + sql.ErrorInfo.ErrorPosition);
                    lines.Add("    Return Code: " + sql.ErrorInfo.ReturnCode);
                    lines.Add("    Message: " + sql.ErrorInfo.Message);
                }
            }
            else if (item.GetType().Equals(typeof(SQLByWhere)))
            {
                var sql = (SQLByWhere)item;
                lines.Add("Where: " + sql.WhereClause);
                // explain SQL Where
            }
            else if (item.GetType().Equals(typeof(SQLByFrom)))
            {
                var sql = (SQLByFrom)item;
                lines.Add("From: " + sql.FromClause);
                // explain SQL From
            }
            else if (item.GetType().Equals(typeof(ExecutionCall)))
            {
                // explain Execution Call
                var exec = (ExecutionCall)item;

                if (exec.Type == ExecutionCallType.SQL)
                {
                    // explain SQL statement
                    var sql = (SQLStatement)exec.SQLStatement;
                    lines.Add("Line #" + sql.LineNumber);
                    lines.Add("Statement: " + sql.Statement);
                    lines.Add(String.Format("Duration: {0}, Execute: {1}, Fetch: {2}.", sql.Duration, sql.ExecTime, sql.FetchTime));
                    lines.Add("Fetched " + sql.FetchCount + " rows.");
                    lines.Add("Bind count: " + sql.BindValues.Count);
                    for (var x = 0; x < sql.BindValues.Count; x++)
                    {
                        var index = sql.BindValues[x].Index;
                        var value = sql.BindValues[x].Value;
                        var typ = sql.BindValues[x].Type;
                        var length = sql.BindValues[x].Length;

                        lines.Add(String.Format("Bind #{0} - {1} ({2}) - {3}", index, typ, length, value));
                    }
                    lines.Add("Caller: " + (sql.ParentCall == null ? "None" : ("Line #" + sql.ParentCall.StartLine) + " " + sql.ParentCall.Function));

                    /* handle error */
                    if (sql.IsError)
                    {
                        lines.Add("SQL Error:");
                        lines.Add("    Error Position: " + sql.ErrorInfo.ErrorPosition);
                        lines.Add("    Return Code: " + sql.ErrorInfo.ReturnCode);
                        lines.Add("    Message: " + sql.ErrorInfo.Message);
                    }
                } else
                {
                    lines.Add(exec.Function);
                }
                
                if (exec.HasError)
                {
                    // alert that somewhere below has an error
                    lines.Add("A call underneath this one experienced an error.");
                }

                if (exec.IsError)
                {
                    // this threw an error, explain the error.
                    if (exec.StackTrace != null)
                    {
                        lines.Add("Exception occured:");
                        lines.Add("    Line #" + exec.StackTrace.LineNumber);
                        lines.Add("    Message: " + exec.StackTrace.Message);
                        lines.Add("    Offender: " + exec.StackTrace.Offender);
                        for (var x = 1; x < exec.StackTrace.StackTrace.Count; x++)
                        {
                            lines.Add(new string(' ', (x + 4) * 2) + exec.StackTrace.StackTrace[x]);
                        }
                    }
                }

            } else if (item.GetType().Equals(typeof(StackTraceEntry))) {
                var st = (StackTraceEntry)item;
                lines.Add("Line #" + st.LineNumber);
                lines.Add("Message: " + st.Message);
                lines.Add("Offender: " + st.Offender);
                for (var x = 1; x < st.StackTrace.Count; x++)
                {
                    lines.Add(new string(' ', x * 2) + st.StackTrace[x]);
                }

            } else
            {
                lines.Add(item.ToString());
            }

            foreach (string s in lines)
            {
                box.Items.Add(s);
            }
            box.EndUpdate();
        }
Пример #47
0
        /// <summary>
        /// Compares the lists of articles in the 2 provided Lists
        /// Best to provide an already sorted list. List 1 should be the smallest list
        /// </summary>
        /// <param name="list1">First List (preferably the smallest)</param>
        /// <param name="list2">Second List</param>
        /// <param name="lb1">List Box where unique items from list1 should go</param>
        /// <param name="lb2">List Box where unique items from list2 should go</param>
        /// <param name="lb3">List Box where the duplicates should go</param>
        private static void CompareLists(IList<Article> list1, List<Article> list2, ListBox lb1, ListBox lb2, ListBox lb3)
        {
            lb1.BeginUpdate();
            lb2.BeginUpdate();
            lb3.BeginUpdate();

            while (list1.Count > 0)
            {
                Article a = list1[0];
                if (list2.Contains(a))
                {
                    lb3.Items.Add(a.Name);
                    if (list2.IndexOf(a) > 0)
                    {
                    	foreach (Article a2 in list2.GetRange(0, list2.IndexOf(a) - 1))
                    	{
                    	  lb2.Items.Add(a2.Name);
                          list2.Remove(a2);
                    	}
                    }

                    list2.Remove(a);
                }
                else
                    lb1.Items.Add(a.Name);

                list1.Remove(a);
            }

            foreach (Article article in list2)
            {
                lb2.Items.Add(article.Name);
            }

            lb1.EndUpdate();
            lb2.EndUpdate();
            lb3.EndUpdate();
        }
Пример #48
0
 public static void AddLog2List(ListBox lstAct, string content)
 {
     try
     {
         if (lstAct.InvokeRequired)
         {
             lstAct.Invoke(new AddLog(AddLog2List), new object[] { lstAct, content });
         }
         else
         {
             lstAct.BeginUpdate();
             lstAct.Items.Add(content);
             lstAct.EndUpdate();
         }
     }
     catch
     {
     }
 }
Пример #49
0
        public override void OnSelected( ListBox subList, params Button[] buttons )
        {
            m_SubList = subList;
            buttons[0].Text = Language.GetString( LocString.AddTarg );
            buttons[0].Visible = true;
            m_BagBTN = buttons[1];
            m_ArrBTN = buttons[2];
            if ( m_Cont != 0 )
                buttons[1].Text = Language.GetString( LocString.ClearHB );
            else
                buttons[1].Text = Language.GetString( LocString.SetHB );
            buttons[1].Visible = true;
            buttons[2].Text = Language.GetString( LocString.OrganizeNow );
            buttons[2].Visible = true;
            buttons[3].Text = Language.GetString( LocString.Remove );
            buttons[3].Visible = true;
            buttons[4].Text = Language.GetString( LocString.Clear );
            buttons[4].Visible = true;
            buttons[5].Text = Language.GetString( LocString.StopNow );
            buttons[5].Visible = true;

            m_SubList.BeginUpdate();
            m_SubList.Items.Clear();
            for (int i=0;i<m_Items.Count;i++)
                m_SubList.Items.Add( (ItemID)((ushort)m_Items[i]) );
            m_SubList.EndUpdate();
        }
Пример #50
0
        public override void OnSelected( ListBox subList, params Button[] buttons )
        {
            buttons[0].Text = Language.GetString( LocString.AddTarg );
            buttons[0].Visible = true;
            buttons[1].Text = Language.GetString( LocString.Remove );
            buttons[1].Visible = true;
            buttons[2].Text = Language.GetString( LocString.SetHB );
            buttons[2].Visible = true;
            buttons[3].Text = Language.GetString( LocString.ClearList );
            buttons[3].Visible = true;
            buttons[4].Text = Language.GetString( LocString.ClearScavCache );
            buttons[4].Visible = true;
            m_EnButton = buttons[5];
            m_EnButton.Visible = true;
            UpdateEnableButton();

            m_SubList = subList;
            subList.BeginUpdate();
            subList.Items.Clear();

            for(int i=0;i<m_Items.Count;i++)
                subList.Items.Add( m_Items[i] );
            subList.EndUpdate();
        }
Пример #51
0
        public override void OnSelected( ListBox subList, params Button[] buttons )
        {
            m_EnableBTN = buttons[4];

            buttons[0].Text = Language.GetString( LocString.AddTarg );
            buttons[0].Visible = true;
            buttons[1].Text = Language.GetString( LocString.Remove );
            buttons[1].Visible = true;
            buttons[2].Text = Language.GetString( LocString.RemoveTarg );
            buttons[2].Visible = true;
            buttons[3].Text = Language.GetString( LocString.ClearList );
            buttons[3].Visible = true;
            buttons[4].Text = Language.GetString( m_Enabled ? LocString.PushDisable : LocString.PushEnable );
            buttons[4].Visible = true;

            m_SubList = subList;
            subList.BeginUpdate();
            subList.Items.Clear();
            for(int i=0;i<m_Chars.Count;i++)
                Add2List( (Serial)m_Chars[i] );
            subList.EndUpdate();
        }
Пример #52
0
        public override void OnSelected( ListBox subList, params Button[] buttons )
        {
            m_SubList = subList;
            m_EnableBTN = buttons[5];
            m_HotBTN = buttons[2];
            m_AmountButton = buttons[4];

            buttons[0].Text = Language.GetString( LocString.AddTarg );
            buttons[0].Visible = true;
            buttons[1].Text = Language.GetString( LocString.Remove );
            buttons[1].Visible = true;
            //button[2] = hotbutton
            buttons[2].Visible = true;
            buttons[3].Text = Language.GetString( LocString.Clear );
            buttons[3].Visible = true;
            m_AmountButton.Text = Language.Format( LocString.SellAmount, Config.GetInt( "SellAgentMax" ) );
            buttons[4].Visible = true;
            buttons[5].Text = Language.GetString( m_Enabled ? LocString.PushDisable : LocString.PushEnable );
            buttons[5].Visible = true;

            SetHBText();
            m_SubList.BeginUpdate();
            m_SubList.Items.Clear();
            for (int i=0;i<m_Items.Count;i++)
                m_SubList.Items.Add( (ItemID)((ushort)m_Items[i]) );
            m_SubList.EndUpdate();

            if ( !ClientCommunication.AllowBit( FeatureBit.SellAgent ) && Engine.MainWindow != null )
            {
                for (int i=0;i<buttons.Length;i++)
                    Engine.MainWindow.LockControl( buttons[i] );
                Engine.MainWindow.LockControl( subList );
            }
        }
Пример #53
0
        public override void OnSelected( ListBox subList, params Button[] buttons )
        {
            m_SubList = subList;

            buttons[0].Text = Language.GetString( LocString.AddTarg );
            buttons[0].Visible = true;
            buttons[1].Text = Language.GetString( LocString.AddTargType );
            buttons[1].Visible = true;
            buttons[2].Text = Language.GetString( LocString.Remove );
            buttons[2].Visible = true;
            buttons[3].Text = Language.GetString( LocString.RemoveTarg );
            buttons[3].Visible = true;
            buttons[4].Text = Language.GetString( LocString.ClearList );
            buttons[4].Visible = true;

            m_SubList.BeginUpdate();
            m_SubList.Items.Clear();

            for(int i=0;i<m_Items.Count;i++)
            {
                Item item = null;
                if ( m_Items[i] is Serial )
                    item = World.FindItem( (Serial)m_Items[i] );
                if ( item != null )
                    m_SubList.Items.Add( item.ToString() );
                else
                    m_SubList.Items.Add( m_Items[i].ToString() );
            }
            m_SubList.EndUpdate();
        }
Пример #54
0
        private static void CompareListsNew(IList<Article> list1, List<Article> list2, ListBox lb1, ListBox lb2, ListBox lb3)
        {
            lb1.BeginUpdate();
            lb2.BeginUpdate();
            lb3.BeginUpdate();

            lb1.Items.AddRange(list1.Except(list2).ToArray());
            lb2.Items.AddRange(list2.Except(list1).ToArray());
            lb3.Items.AddRange(list1.Intersect(list2).ToArray());

            lb1.EndUpdate();
            lb2.EndUpdate();
            lb3.EndUpdate();
        }
Пример #55
0
 /// <summary>
 /// adds item to list box
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="text"></param>
 private void AddListBox(ListBox obj, string text)
 {
     if (obj.InvokeRequired)
     {
         AddListBoxCallback tcb = new AddListBoxCallback(AddListBox);
         this.Invoke(tcb, new Object[] { obj, text });
     }
     else
     {
         if (obj.Items.Contains(text)) return;
         obj.BeginUpdate();
         obj.Items.Add(text);
         obj.EndUpdate();
     }
 }
Пример #56
0
        public override void OnSelected( ListBox subList, params Button[] buttons )
        {
            m_SubList = subList;
            buttons[0].Text = Language.GetString( LocString.AddTarg );
            buttons[0].Visible = true;
            buttons[1].Text = Language.GetString( LocString.AddContTarg );
            buttons[1].Visible = true;
            buttons[2].Text = Language.GetString( LocString.RemoveTarg );
            buttons[2].Visible = true;
            buttons[3].Text = Language.GetString( LocString.ClearList );
            buttons[3].Visible = true;

            m_SubList.BeginUpdate();
            m_SubList.Items.Clear();

            for(int i=0;i<m_Items.Count;i++)
            {
                if ( m_Items[i] is Serial )
                {
                    Item item = World.FindItem( (Serial)m_Items[i] );
                    if ( item != null )
                        m_Items[i] = item;
                }
                m_SubList.Items.Add( m_Items[i] );
            }
            m_SubList.EndUpdate();

            if ( !ClientCommunication.AllowBit( FeatureBit.UseOnceAgent ) && Engine.MainWindow != null )
            {
                for (int i=0;i<buttons.Length;i++)
                    Engine.MainWindow.LockControl( buttons[i] );
                Engine.MainWindow.LockControl( subList );
            }
        }
        /// <summary>
        /// Overrides the method used to provide basic behaviour for selecting editor.
        /// Shows our custom control for editing the value.
        /// </summary>
        /// <param name="context">The context of the editing control</param>
        /// <param name="provider">A valid service provider</param>
        /// <param name="value">The current value of the object to edit</param>
        /// <returns>The new value of the object</returns>
        public override object EditValue( ITypeDescriptorContext context, 
      IServiceProvider provider, object value)
        {
            if( context != null && context.Instance != null && provider != null )
              {
            edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if( edSvc != null )
            {
              // Create a ListBox and populate it with all the enum values
              clb = new ListBox();
              clb.BorderStyle = BorderStyle.FixedSingle;
              clb.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
              clb.MeasureItem += new MeasureItemEventHandler( this.OnMeasureItem );
              clb.DrawItem  += new DrawItemEventHandler( this.OnDrawItem );
              clb.MouseDown += new MouseEventHandler( this.OnMouseDown );
              clb.MouseMove += new MouseEventHandler( this.OnMouseMoved );
              clb.DoubleClick += new EventHandler( this.OnDoubleClick );

              tooltipControl = new ToolTip();
              tooltipControl.ShowAlways = true;

              clb.BeginUpdate();
              int iSelected = 0; // by default will be selected first item

              foreach( string name in Enum.GetNames( context.PropertyDescriptor.PropertyType ) )
              {
            // Get the enum value
            object enumVal = Enum.Parse( context.PropertyDescriptor.PropertyType, name );

            // Get the int value
            int intVal = (int)Convert.ChangeType( enumVal, typeof( int ) );

            // Get the description attribute for this field
            System.Reflection.FieldInfo fi = context.PropertyDescriptor.PropertyType.GetField(name);
            DescriptionAttribute[] attrs = ( DescriptionAttribute[] )
              fi.GetCustomAttributes( typeof( DescriptionAttribute ), false );

            // Store the the description
            string tooltip = attrs.Length > 0 ? attrs[0].Description : string.Empty;

            // Creates a clbItem that stores the name, the int value and the tooltip
            clbItem item = new clbItem( enumVal.ToString(), intVal, tooltip );

            // Add the item with the right check state
            int index = clb.Items.Add( item );

            // set selected item
            if( intVal == (int)value )
            {
              iSelected = index;
            }
              }

              clb.EndUpdate();
              clb.SelectedIndex = iSelected;

              // Show our CheckedListbox as a DropDownControl.
              // This methods returns only when the dropdowncontrol is closed
              edSvc.DropDownControl( clb );

              // Get the sum of all checked flags
              int result = ((clbItem)clb.SelectedItem).Value;

              // return the right enum value corresponding to the result
              return Enum.ToObject( context.PropertyDescriptor.PropertyType, result );
            }
              }

              return value;
        }
Пример #58
0
        public override void OnSelected( ListBox subList, params Button[] buttons )
        {
            buttons[0].Text = Language.GetString( LocString.AddTarg );
            buttons[0].Visible = true;
            buttons[1].Text = Language.GetString( LocString.Remove );
            buttons[1].Visible = true;
            buttons[2].Text = Language.GetString( LocString.SetAmt );
            buttons[2].Visible = true;
            buttons[3].Text = Language.GetString( LocString.ClearList );
            buttons[3].Visible = true;
            m_HotBTN = buttons[4];
            SetHBText();
            buttons[4].Visible = true;
            buttons[5].Text = Language.GetString( LocString.RestockNow );
            buttons[5].Visible = true;

            m_SubList = subList;
            subList.BeginUpdate();
            subList.Items.Clear();
            for(int i=0;i<m_Items.Count;i++)
                subList.Items.Add( m_Items[i] );
            subList.EndUpdate();

            if ( !ClientCommunication.AllowBit( FeatureBit.RestockAgent ) && Engine.MainWindow != null )
            {
                for (int i=0;i<buttons.Length;i++)
                    Engine.MainWindow.LockControl( buttons[i] );
                Engine.MainWindow.LockControl( subList );
            }
        }
Пример #59
0
		}; // class FontInfo

		// Constructor.
		public FontDialogForm(FontDialog dialog)
				{
					// Record the parent for later access.
					this.dialog = dialog;

					// Create the initial font cache.
					fonts = new Hashtable();
					FontInfo info = new FontInfo(dialog.Font, false);
					fonts.Add(info, info);

					// Set the title.
					Text = S._("SWF_FontDialog_Title", "Font");

					// Construct the layout boxes for the font dialog.
					hbox = new HBoxLayout();
					hbox.Dock = DockStyle.Fill;
					vbox1 = new VBoxLayout();
					vbox2 = new VBoxLayout();
					vbox3 = new VBoxLayout();
					hbox2 = new HBoxLayout();
					grid = new GridLayout(2, 3);
					grid.StretchColumn = 0;
					effects = new GroupBox();
					effects.Text = S._("SWF_FontDialog_Effects", "Effects");
					effects.Width = 80;
					hbox.Controls.Add(vbox1);
					hbox.Controls.Add(vbox2);
					hbox.StretchControl = vbox1;
					hbox2.Controls.Add(grid);
					hbox2.Controls.Add(effects);
					hbox2.StretchControl = grid;
					vbox1.Controls.Add(hbox2);
					vbox1.StretchControl = hbox2;
					effects.Controls.Add(vbox3);
					vbox3.Dock = DockStyle.Fill;

					// Create the main display area.
					Label label;
					label = new Label();
					label.Text = S._("SWF_FontDialog_Name", "Font:");
					name = new TextBox();
					name.ReadOnly = true;
					nameList = new ListBox();
					grid.SetControl(0, 0, label);
					grid.SetControl(0, 1, name);
					grid.SetControl(0, 2, nameList);
					label = new Label();
					label.Text = S._("SWF_FontDialog_Size", "Size:");
					size = new TextBox();
					size.Width = 40;
					size.ReadOnly = true;
					sizeList = new ListBox();
					sizeList.Width = 40;
					grid.SetControl(1, 0, label);
					grid.SetControl(1, 1, size);
					grid.SetControl(1, 2, sizeList);

					// Create the buttons.
					okButton = new Button();
					okButton.Text = S._("SWF_MessageBox_OK", "OK");
					cancelButton = new Button();
					cancelButton.Text = S._("SWF_MessageBox_Cancel", "Cancel");
					applyButton = new Button();
					applyButton.Text = S._("SWF_MessageBox_Apply", "Apply");
					helpButton = new Button();
					helpButton.Text = S._("SWF_MessageBox_Help", "Help");
					vbox2.Controls.Add(okButton);
					vbox2.Controls.Add(cancelButton);
					vbox2.Controls.Add(applyButton);
					vbox2.Controls.Add(helpButton);
					vbox2.Controls.Add(new EmptyControl());
					AcceptButton = okButton;
					CancelButton = cancelButton;

					// Create the effects controls.
					bold = new CheckBox();
					bold.Text = S._("SWF_FontDialog_Bold", "Bold");
					italic = new CheckBox();
					italic.Text = S._("SWF_FontDialog_Italic", "Italic");
					underline = new CheckBox();
					underline.Text =
						S._("SWF_FontDialog_Underline", "Underline");
					strikeout = new CheckBox();
					strikeout.Text =
						S._("SWF_FontDialog_Strikeout", "Strikeout");
					Control spacing = new Control();
					vbox3.Spacing = 0;
					vbox3.Controls.Add(bold);
					vbox3.Controls.Add(italic);
					vbox3.Controls.Add(underline);
					vbox3.Controls.Add(strikeout);
					vbox3.Controls.Add(spacing);

					// Create the sample box.
					sample = new Control();
					sample.ForeColor = SystemColors.WindowText;
					sample.BackColor = SystemColors.Window;
					sample.BorderStyleInternal = BorderStyle.Fixed3D;
					sample.Height = 60;
					vbox1.Controls.Add(sample);

					// Add the top-level hbox to the dialog and set the size.
					Controls.Add(hbox);
					Size drawsize = hbox.RecommendedSize;
					if(drawsize.Width < 450)
					{
						drawsize.Width = 450;
					}
					if(drawsize.Height < 280)
					{
						drawsize.Height = 280;
					}
					ClientSize = drawsize;
					MinimumSize = drawsize;
					MinimizeBox = false;
					ShowInTaskbar = false;

					// Fill in the font names and sizes.
					nameList.BeginUpdate();
					foreach(FontFamily family in FontFamily.Families)
					{
						nameList.Items.Add(family.Name);
					}
					nameList.EndUpdate();
					sizeList.BeginUpdate();
					foreach(int value in sizes)
					{
						sizeList.Items.Add(value);
					}
					sizeList.EndUpdate();

					// Hook up interesting events.
					okButton.Click += new EventHandler(AcceptDialog);
					cancelButton.Click += new EventHandler(CancelDialog);
					applyButton.Click += new EventHandler(ApplyButtonClicked);
					helpButton.Click += new EventHandler(HelpButtonClicked);
					nameList.SelectedIndexChanged
						+= new EventHandler(NameIndexChanged);
					sizeList.SelectedIndexChanged
						+= new EventHandler(SizeIndexChanged);
					bold.CheckedChanged
						+= new EventHandler(FontStyleChanged);
					italic.CheckedChanged
						+= new EventHandler(FontStyleChanged);
					underline.CheckedChanged
						+= new EventHandler(FontStyleChanged);
					strikeout.CheckedChanged
						+= new EventHandler(FontStyleChanged);
					sample.Paint += new PaintEventHandler(PaintSample);

					// Match the requested settings from the dialog parent.
					UpdateDialog();
				}
Пример #60
0
        public override void OnSelected( ListBox subList, params Button[] buttons )
        {
            m_SubList = subList;
            m_EnableBTN = buttons[4];

            buttons[0].Text = Language.GetString( LocString.AddTarg );
            buttons[0].Visible = true;
            buttons[1].Text = Language.GetString( LocString.Edit );
            buttons[1].Visible = true;
            buttons[2].Text = Language.GetString( LocString.Remove );
            buttons[2].Visible = true;
            buttons[3].Text = Language.GetString( LocString.ClearList );
            buttons[3].Visible = true;
            buttons[4].Text = Language.GetString( m_Enabled ? LocString.PushDisable : LocString.PushEnable );
            buttons[4].Visible = true;

            m_SubList.BeginUpdate();
            m_SubList.Items.Clear();
            for (int i=0;i<m_Items.Count;i++)
                m_SubList.Items.Add( m_Items[i] );
            m_SubList.EndUpdate();

            if ( !ClientCommunication.AllowBit( FeatureBit.BuyAgent ) && Engine.MainWindow != null )
            {
                for (int i=0;i<buttons.Length;i++)
                    Engine.MainWindow.LockControl( buttons[i] );
                Engine.MainWindow.LockControl( subList );
            }
        }