Ejemplo n.º 1
0
        private void ApplyContentToItem( )
        {
            if (lbItems.SelectedItems.Count == 0)
            {
                return;
            }

            CodeCompletionList selList = lbLists.SelectedItem as CodeCompletionList;

            if (selList == null)
            {
                return;
            }

            string key = lbItems.SelectedItem as string;

            if (String.IsNullOrEmpty(key))
            {
                return;
            }

            if (selList[key].Trim() != txtTemplateCode.Text.Trim())
            {
                selList[key] = txtTemplateCode.Text;
                _isModified  = true;
            }
        }
Ejemplo n.º 2
0
        private void AddNewItem( )
        {
            CodeCompletionList selList = lbLists.SelectedItem as CodeCompletionList;

            if (selList == null)
            {
                return;
            }

            string name = txtTemplateName.Text;

            if (String.IsNullOrEmpty(name))
            {
                return;
            }


            if (selList.Items.ContainsKey(name))
            {
                MessageBox.Show(String.Format("List content with key \"{0}\" already defined!", name)
                                , "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            selList.Items.Add(name, String.Empty);
            lbItems.ClearSelected();
            lbItems.SelectedIndex = lbItems.Items.Add(name);
            LoadItemContent();

            _isModified = true;
        }
Ejemplo n.º 3
0
        private void LoadListItems( )
        {
            if (_doNotLoad)
            {
                return;
            }

            lbItems.Items.Clear();
            if (_codeCompletionLists == null || lbLists.SelectedItem == null)
            {
                LoadItemContent();
                return;
            }

            CodeCompletionList selList = lbLists.SelectedItem as CodeCompletionList;

            foreach (string key in selList.Items.Keys)
            {
                lbItems.Items.Add(key);
            }

            if (lbItems.Items.Count > 0)
            {
                lbItems.SelectedIndex = 0;
            }
            LoadItemContent();
        }
Ejemplo n.º 4
0
        private static void PopulateTable(CodeCompletionList list, DataTable table)
        {
            if (table == null || list == null)
            {
                return;
            }

            string name = String.Empty;

            DataRow row;

            foreach (string key in list.Items.Keys)
            {
                row                = table.NewRow();
                row["Type"]        = "ccListItem";
                row["DisplayName"] = key;
                name               = String.IsNullOrEmpty(list[key]) ? key : list[key];
                row["Value"]       = name;

                name = name.Replace("\n", " ");
                name = name.Replace("\r", " ");
                name = name.Replace("\t", " ");
                row["DisplayValue"] = name;
                table.Rows.Add(row);
            }
        }
Ejemplo n.º 5
0
        private void DeleteSelectedItems( )
        {
            if (lbItems.SelectedItems.Count == 0)
            {
                return;
            }

            CodeCompletionList selList = lbLists.SelectedItem as CodeCompletionList;

            if (selList == null)
            {
                return;
            }
            DialogResult dlgRes = MessageBox.Show("Delete selected item(s)?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dlgRes == DialogResult.No)
            {
                return;
            }

            foreach (string key in lbItems.SelectedItems)
            {
                selList.Items.Remove(key);
            }

            try
            {
                _doNotLoad = true;
                while (lbItems.SelectedItems.Count > 0)
                {
                    lbItems.Items.Remove(lbItems.SelectedItems[0]);
                }
            }
            finally
            {
                _doNotLoad = false;
            }

            txtTemplateCode.Text = String.Empty;
            if (lbItems.SelectedItems.Count > 0)
            {
                lbItems.SelectedIndex = 0;
            }

            LoadItemContent();
        }
Ejemplo n.º 6
0
        private void AddList( )
        {
            string name = txtListName.Text;

            if (String.IsNullOrEmpty(name))
            {
                return;
            }
            CodeCompletionList newList = new CodeCompletionList();

            newList.Name = name;

            _codeCompletionLists.Add(newList);
            lbLists.ClearSelected();
            lbLists.SelectedIndex = lbLists.Items.Add(newList);
            _isModified           = true;
        }
Ejemplo n.º 7
0
        private void LoadItemContent( )
        {
            if (_doNotLoad)
            {
                return;
            }

            CodeCompletionList selList = lbLists.SelectedItem as CodeCompletionList;
            string             selKey  = lbItems.SelectedItem as string;

            if (selList == null || String.IsNullOrEmpty(selKey))
            {
                txtTemplateCode.Text = String.Empty;
                return;
            }
            txtTemplateCode.Text = selList[selKey];
        }
Ejemplo n.º 8
0
        private void RenameList( )
        {
            CodeCompletionList selList = lbLists.SelectedItem as CodeCompletionList;

            if (selList == null)
            {
                return;
            }

            string name = String.Empty;

            if (InputDialog.ShowDialog("Rename List", "Name", ref name) != DialogResult.OK)
            {
                return;
            }

            selList.Name = name;
            _isModified  = true;
        }