void CategoryListViewItemChanged(object sender, EventArgs e) { CodeGeneratorBase codeGenerator = SelectedCodeGenerator; if (codeGenerator == null) { return; } statusLabel.Text = StringParser.Parse(codeGenerator.Hint); selectionListBox.BeginUpdate(); selectionListBox.Items.Clear(); if (codeGenerator.Content.Count > 0) { Hashtable objs = new Hashtable(); // selectionListBox.Sorted = codeGenerator.Content.Count > 1; foreach (object o in codeGenerator.Content) { if (!objs.Contains(o.ToString())) { selectionListBox.Items.Add(o); objs.Add(o.ToString(), ""); } } selectionListBox.SelectedIndex = 0; } selectionListBox.EndUpdate(); selectionListBox.Refresh(); }
public CodeGenerationForm(TextEditorControl textEditorControl, CodeGeneratorBase[] codeGenerators, IClass currentClass) { this.textEditorControl = textEditorControl; foreach (CodeGeneratorBase generator in codeGenerators) { generator.Initialize(currentClass); } // Must be called for initialization this.InitializeComponents(); okButton.Text = ResourceService.GetString("Global.OKButtonText"); cancelButton.Text = ResourceService.GetString("Global.CancelButtonText"); // selectionListBox.Sorted = true; TextLocation caretPos = textEditorControl.ActiveTextAreaControl.Caret.Position; TextArea textArea = textEditorControl.ActiveTextAreaControl.TextArea; TextView textView = textArea.TextView; Point visualPos; int physicalline = textView.Document.GetVisibleLine(caretPos.Y); visualPos = new Point(textView.GetDrawingXPos(caretPos.Y, caretPos.X) + textView.DrawingPosition.X, (int)((1 + physicalline) * textView.FontHeight) - textArea.VirtualTop.Y - 1 + textView.DrawingPosition.Y); Point tempLocation = textEditorControl.ActiveTextAreaControl.TextArea.PointToScreen(visualPos); tempLocation.Y = (tempLocation.Y + Height) > Screen.FromPoint(tempLocation).WorkingArea.Bottom ? Screen.FromPoint(tempLocation).WorkingArea.Bottom - Height : tempLocation.Y; tempLocation.X = (tempLocation.X + Width) > Screen.FromPoint(tempLocation).WorkingArea.Right ? Screen.FromPoint(tempLocation).WorkingArea.Right - Width : tempLocation.X; Location = tempLocation; StartPosition = FormStartPosition.Manual; categoryListView.SmallImageList = categoryListView.LargeImageList = ClassBrowserIconService.ImageList; foreach (CodeGeneratorBase codeGenerator in codeGenerators) { if (codeGenerator.IsActive) { ListViewItem newItem = new ListViewItem(StringParser.Parse(codeGenerator.CategoryName)); newItem.ImageIndex = codeGenerator.ImageIndex; newItem.Tag = codeGenerator; categoryListView.Items.Add(newItem); } } categoryListView.SelectedIndexChanged += new EventHandler(CategoryListViewItemChanged); }