public WizardForm(PackForm parent) { InitializeComponent(); _parent = parent; gdItems.DataSource = _items; PopulateCombos(); foreach (string type in Pack.SpawnItemConfig.AttachmentTypes.Keys) { for (int i = 0; i < PackForm.MaxAttachmentsForType; i++) { var gc = gvItems.Columns.Add(); gc.Name = String.Format("{0}{1}{2}", PackForm.AttachmentColNamePrefix, type, i); gc.FieldName = gc.Name; gc.Caption = type; gc.UnboundType = UnboundColumnType.String; gc.Width = 30; gc.Visible = true; _attachTypeColMap.Add(gc, type); } } // instant commit (will be detached automatically when form closes) foreach (var cmb in _parent.AttachmentEditorsByType.Values) { GridUtility.ConfigureInstantCommit(gvItems, cmb); } }
private void PopulateAttachmentNames(RepositoryItemImageComboBox cmb, string singleType = null) { cmb.SmallImages = ilAttachmentNames; cmb.GlyphAlignment = HorzAlignment.Center; cmb.Buttons[0].Visible = false; GridUtility.ConfigureInstantCommit(gvAttachmentTypes, cmb); var attachmentTypes = cmb.Items; // добавляем пустой элемент, чтобы можно было сбросить значение attachmentTypes.Add(new ImageComboBoxItem(null)); IEnumerable <string> types; if (singleType == null) { types = Pack.SpawnItemConfig.AttachmentTypes.Keys; } else { types = new string[] { singleType } }; foreach (string type in types) { // добавляем пустой элемент типа, если это комбик со множеством типов if (singleType == null) { attachmentTypes.Add(new ImageComboBoxItem(type, null)); } foreach (KeyValuePair <string, string> attachName in Pack.SpawnItemConfig.AttachmentTypes[type]) { string imgFileName = attachName.Value; string name = attachName.Key; int imgIndex = GetImageIndex(ilAttachmentNames, imgFileName, true); attachmentTypes.Add(new ImageComboBoxItem(name, name, imgIndex)); } } }
private void PopulateCombos() { _parent.PopulateSpawnItemTypes(repCmbItemType, true, true); GridUtility.ConfigureInstantCommit(gvItems, repCmbItemType); }
public PackForm(string levelTemplatePath, string packPath = null) { InitializeComponent(); cmLinePanel.MenuItems.Add(new MenuItem("Add", cmLinePanel_ClickAdd)); cmLinePanel.MenuItems.Add(new MenuItem("Add wizard...", cmLinePanel_ClickAddWizard)); cmLinePanel.MenuItems.Add(new MenuItem("Delete all", cmLinePanel_ClickDeleteAll)); cmButton.MenuItems.Add(new MenuItem("Insert", cmButton_ClickInsert)); cmButton.MenuItems.Add(new MenuItem("Insert wizard...", cmButton_ClickInsertWizard)); cmButton.MenuItems.Add(new MenuItem("Delete", cmButton_ClickDelete)); cmButton.MenuItems.Add(new MenuItem("Delete all", cmButton_ClickDeleteAll)); decimal zoomOut = (decimal)23 / Math.Max(ilSpawnItemTypesLarge.ImageSize.Width, ilSpawnItemTypesLarge.ImageSize.Height); ilSpawnItemTypesSmall.ImageSize = new Size((int)(ilSpawnItemTypesLarge.ImageSize.Width * zoomOut), (int)(ilSpawnItemTypesLarge.ImageSize.Height * zoomOut)); ilSpawnItemTypesSmall.Images.Clear(); foreach (string key in ilSpawnItemTypesLarge.Images.Keys) { ilSpawnItemTypesSmall.Images.Add(key, ilSpawnItemTypesLarge.Images[key]); } BeginBinding(); try { for (int i = 0; i < MaxAttachmentsForType; i++) { var gc = gvAttachmentTypes.Columns.Add(); gc.Name = AttachmentColNamePrefix + i.ToString(); gc.FieldName = gc.Name; gc.UnboundType = UnboundColumnType.String; gc.Visible = true; gc.Width = 30; } txtTime.Properties.Increment = (decimal)SpawnLine.DefaultDelay; txtSpawnItemDelay.Properties.Increment = (decimal)SpawnLine.DefaultDelay; for (int i = 0; ; i++) { string panelName = String.Format("pnlLine{0}", i + 1); if (!pnlLines.Controls.ContainsKey(panelName)) { break; } var pnlLine = (Panel)pnlLines.Controls[panelName]; _linePanels.Add(pnlLine); pnlLine.AllowDrop = true; pnlLine.ContextMenu = cmLinePanel; pnlLine.MouseDown += pnlLine_MouseDown; pnlLine.Paint += pnlLine_Paint; pnlLine.DragEnter += pnlLine_DragEnter; pnlLine.DragDrop += pnlLine_DragDrop; } InitTaskParamMap(); BindSpawnItem(null); Text = packPath; string packXml = packPath.IsNullOrWhiteSpace() ? null : File.ReadAllText(packPath); _pack = new Pack(File.ReadAllText(levelTemplatePath), packXml, this); LookupUtility.Configure(repCmbTaskCategory, Pack.TaskConfig.Categories); LookupUtility.Configure(repCmbTaskType, Pack.TaskConfig.Types); GridUtility.ConfigureInstantCommit(gvTasks, repCmbTaskCategory); GridUtility.ConfigureInstantCommit(gvTasks, repCmbTaskType); ConfigureSpawnItems(); gvAttachmentTypes.CellValueChanged += view_CellValueChanged; gvTasks.CellValueChanged += view_CellValueChanged; gvLevelItems.CellValueChanged += view_CellValueChanged; LoadLevel(true); // сбрасываем флаги в последнюю очередь, т.к. биндинг может привести к изменению значений bool isNew = packPath == null; IsNeedSave = isNew; IsNew = isNew; } finally { EndBinding(); } }