private void Form1_Load(object sender, EventArgs e) { // Remember: TreeListViews must have a small image list assigned to them. // If they do not, the hit testing will be wildly off // Allow all models to be expanded and each model will show Children as its sub-branches treeListView1.CanExpandGetter = delegate(object x) { return(true); }; treeListView1.ChildrenGetter = delegate(object x) { return(((ModelWithChildren)x).Children); }; treeListView2.CanExpandGetter = delegate(object x) { return(true); }; treeListView2.ChildrenGetter = delegate(object x) { return(((ModelWithChildren)x).Children); }; // In the Designer, set IsSimpleDropSink to true for both tree list views. // That creates an appropriately configured SimpleDropSink. // Here, we are just configuring it a little more SimpleDropSink sink1 = (SimpleDropSink)treeListView1.DropSink; sink1.AcceptExternal = true; sink1.CanDropBetween = true; sink1.CanDropOnBackground = true; SimpleDropSink sink2 = (SimpleDropSink)treeListView2.DropSink; sink2.AcceptExternal = true; sink2.CanDropBetween = true; sink2.CanDropOnBackground = true; // Give each tree its top level objects to get things going treeListView1.Roots = ModelWithChildren.CreateModels(null, new ArrayList { 0, 1, 2, 3, 4, 5 }); treeListView2.Roots = ModelWithChildren.CreateModels(null, new ArrayList { "A", "B ", "C", "D", "E" }); }
private void SetupDropSink() { DropSink = new SimpleDropSink { CanDropBetween = true }; }
public TLVBase(TreeListView tlv, OLVColumn olvColumn, bool dragAndDrop) { TLV = tlv; MasterList = new List <object>(); FolderMasterList = new List <FolderModel>(); AbilityMasterList = new List <AbilityModel>(); TLV.SmallImageList.Images.Add("Folder", Properties.Resources.folderIcon); TLV.SmallImageList.Images.Add("DefaultIcon", Properties.Resources.BTN_unknown); // image getter olvColumn.ImageGetter = delegate(object rowObject) { if (rowObject is FolderModel) { return("Folder"); } else if (rowObject is AbilityModel _item) { if (null != _item.ImageKey) { return(_item.ImageKey); } else { return("DefaultIcon"); } } return(""); }; // when the node can be expanded TLV.CanExpandGetter = delegate(object x) { return(x is FolderModel && ((FolderModel)x).List.Count > 0); }; TLV.ChildrenGetter = delegate(object x) { if (x is FolderModel && ((FolderModel)x).List.Count > 0) { return(((FolderModel)x).List); } else { return(null); } }; if (dragAndDrop) { SimpleDropSink sink1 = (SimpleDropSink)TLV.DropSink; sink1.AcceptExternal = false; sink1.CanDropBetween = true; sink1.CanDropOnBackground = true; } }
//constructor public ConfigureDatasetUI() { InitializeComponent(); olvAvailableColumnName.ImageGetter += ImageGetter; olvSelectedColumnName.ImageGetter += ImageGetter; olvSelected.ItemActivate += OlvSelected_ItemActivate; olvAvailableColumnCategory.AspectGetter += AvailableColumnCategoryAspectGetter; olvAvailable.AlwaysGroupByColumn = olvAvailableColumnCategory; olvSelectedCatalogue.AspectGetter += SelectedCatalogue_AspectGetter; olvSelectedCategory.AspectGetter += SelectedCategory_AspectGetter; SimpleDropSink dropSink = (SimpleDropSink)olvSelected.DropSink; dropSink.CanDropOnItem = false; dropSink.CanDropBetween = true; AssociatedCollection = RDMPCollection.DataExport; var tableInfoIcon = CatalogueIcons.TableInfo; olvJoinTableName.ImageGetter += o => tableInfoIcon; olvJoin.CheckStateGetter += ForceJoinCheckStateGetter; olvJoin.CheckStatePutter += ForceJoinCheckStatePutter; olvJoinColumn.AspectGetter += JoinColumn_AspectGetter; olvJoin.ButtonClick += olvJoin_ButtonClick; olvJoinColumn.EnableButtonWhenItemIsDisabled = true; olvIssues.AspectGetter += Issues_AspectGetter; olvSelected.UseCellFormatEvents = true; olvSelected.FormatCell += olvSelected_FormatCell; olvSelected.CellRightClick += olvSelected_CellRightClick; helpIconJoin.SetHelpText("Configure JoinInfos", "Your query involves more than 1 table and RDMP does not yet know which columns to use to join the tables on. Click the 'Configure' button below on any ticked tables for which no joins are shown"); RDMPCollectionCommonFunctionality.SetupColumnTracking(olvAvailable, olvAvailableColumnCategory, new Guid("e515dd51-6ab4-4e62-8d58-0081dde77646")); RDMPCollectionCommonFunctionality.SetupColumnTracking(olvAvailable, olvAvailableColumnName, new Guid("f40a31b5-4a64-44b5-9d21-54595f8671b1")); RDMPCollectionCommonFunctionality.SetupColumnTracking(olvAvailable, olvAvailableIsExtractionIdentifier, new Guid("6741ea5c-5a1e-482a-943e-5d9bcfde4a1f")); RDMPCollectionCommonFunctionality.SetupColumnTracking(olvJoin, olvJoinColumn, new Guid("7e034241-9d7a-48a6-869c-a0831303839a")); RDMPCollectionCommonFunctionality.SetupColumnTracking(olvJoin, olvJoinTableName, new Guid("7b0b0c8f-b648-47cc-a14f-6dce54333d0b")); RDMPCollectionCommonFunctionality.SetupColumnTracking(olvSelected, olvSelectedCatalogue, new Guid("7ec2a0b8-cc84-4759-8f78-0f2c492ae408")); RDMPCollectionCommonFunctionality.SetupColumnTracking(olvSelected, olvSelectedCategory, new Guid("e0cc6915-15ad-4148-adf1-978489e36940")); RDMPCollectionCommonFunctionality.SetupColumnTracking(olvSelected, olvSelectedColumnName, new Guid("061b5ef1-d0bd-4be6-9e9a-1a6a9c13a01c")); RDMPCollectionCommonFunctionality.SetupColumnTracking(olvSelected, olvSelectedColumnOrder, new Guid("2b4db0ee-3768-4e0e-a62b-e5a9b19e91a7")); RDMPCollectionCommonFunctionality.SetupColumnTracking(olvSelected, olvIssues, new Guid("741f0cff-1d2e-46a7-a5da-9ce13e0960cf")); }
public EditPlotOrder(List <PlotOrderElement> plotOrder) { InitializeComponent(); plotOrder.Reverse(); PlotOrder = plotOrder; SimpleDropSink sink = (SimpleDropSink)olv.DropSink; sink.AcceptExternal = false; sink.CanDropBetween = true; sink.CanDropOnBackground = false; sink.AcceptableLocations = DropTargetLocation.BetweenItems | DropTargetLocation.AboveItem | DropTargetLocation.BelowItem; olv.ModelCanDrop += Olv_ModelCanDrop; olv.ModelDropped += Olv_ModelDropped; olv.AddObjects(PlotOrder); }
public FrmTableEditor(int templateIndex, string file) { FrmTableEditor.Instance = this; this.InitializeComponent(); this.LoadIcons(); this.undoManager.DataChanged += this.UndoManagerDataChanged; Helper.Settings.LoadTemplates(); if (file != null) { FileManager fileManager = new FileManager(file) { ReadWriteComments = true, // always read comments }; EditorIniData iniContent = fileManager.Read(FileEncoding.Automatic, templateIndex); this.Data = new TableData(iniContent); this.isBini = fileManager.IsBini; this.SetFile(file); } else { this.Data = new TableData { TemplateIndex = templateIndex }; this.SetFile(string.Empty); } this.SetTheme(); SimpleDropSink dropSink = this.objectListView1.DropSink as SimpleDropSink; if (dropSink != null) { dropSink.CanDropBetween = true; dropSink.CanDropOnItem = false; } this.RefreshSettings(); }
public frmTableEditor(int templateIndex, string file) { InitializeComponent(); LoadIcons(); _undoManager.DataChanged += UndoManager_DataChanged; if (file != null) { FileManager fileManager = new FileManager(file) { ReadWriteComments = true, // always read comments }; EditorINIData iniContent = fileManager.Read(FileEncoding.Automatic, templateIndex); Data = new TableData(iniContent); _isBINI = fileManager.IsBINI; SetFile(file); } else { Data = new TableData { TemplateIndex = templateIndex }; SetFile(string.Empty); } objectListView1.CellToolTip.InitialDelay = 1000; objectListView1.UnfocusedHighlightBackgroundColor = objectListView1.HighlightBackgroundColorOrDefault; objectListView1.UnfocusedHighlightForegroundColor = objectListView1.HighlightForegroundColorOrDefault; SimpleDropSink dropSink = objectListView1.DropSink as SimpleDropSink; if (dropSink != null) { dropSink.CanDropBetween = true; dropSink.CanDropOnItem = false; } RefreshSettings(); }
//constructor public ConfigureDatasetUI() { InitializeComponent(); olvAvailableColumnName.ImageGetter += ImageGetter; olvSelectedColumnName.ImageGetter += ImageGetter; olvSelected.ItemActivate += OlvSelected_ItemActivate; olvAvailableColumnCategory.AspectGetter += AvailableColumnCategoryAspectGetter; olvAvailable.AlwaysGroupByColumn = olvAvailableColumnCategory; olvSelectedCatalogue.AspectGetter += SelectedCatalogue_AspectGetter; olvSelectedCategory.AspectGetter += SelectedCategory_AspectGetter; SimpleDropSink dropSink = (SimpleDropSink)olvSelected.DropSink; dropSink.CanDropOnItem = false; dropSink.CanDropBetween = true; AssociatedCollection = RDMPCollection.DataExport; var tableInfoIcon = CatalogueIcons.TableInfo; olvJoinTableName.ImageGetter += o => tableInfoIcon; olvJoin.CheckStateGetter += ForceJoinCheckStateGetter; olvJoin.CheckStatePutter += ForceJoinCheckStatePutter; olvJoinColumn.AspectGetter += JoinColumn_AspectGetter; olvJoin.ButtonClick += olvJoin_ButtonClick; olvJoinColumn.EnableButtonWhenItemIsDisabled = true; olvIssues.AspectGetter += Issues_AspectGetter; olvSelected.UseCellFormatEvents = true; olvSelected.FormatCell += olvSelected_FormatCell; olvSelected.CellRightClick += olvSelected_CellRightClick; helpIconJoin.SetHelpText("Configure JoinInfos", "Your query involves more than 1 table and RDMP does not yet know which columns to use to join the tables on. Click the 'Configure' button below on any ticked tables for which no joins are shown"); }
public static void SetupDragAndDrop(ObjectListView listView, EventHandler <OlvDropEventArgs> onDropped, EventHandler <OlvDropEventArgs> canDrop, EventHandler afterDrag) { var simpleDropSink = new SimpleDropSink { AcceptExternal = true, EnableFeedback = false, UseDefaultCursors = true }; simpleDropSink.Dropped += onDropped; simpleDropSink.CanDrop += canDrop; var target = listView; target.DropSink = simpleDropSink; target.AllowDrop = true; var fileDragSource = new UniversalDragAndDrop(); fileDragSource.AfterDrag += afterDrag; target.DragSource = fileDragSource; }
protected void SkillListView_OnModelCanDrop(object sender, ModelDropEventArgs e) { SimpleDropSink sink1 = (SimpleDropSink)DropSink; sink1.CanDropOnItem = false; // idk why something is changing it back to default (shit class, shit designer, who cares) sink1.CanDropOnBackground = true; if (e.SourceListView == this || !ModelDropCheck(e.SourceModels[0] as Skill)) { // cant drop this here e.Effect = System.Windows.Forms.DragDropEffects.None; sink1.FeedbackColor = UITools.Red; } else { // can e.Effect = System.Windows.Forms.DragDropEffects.Link; sink1.FeedbackColor = UITools.Green; } e.Handled = true; }
private void SetupDragAndDrop() { // Drag and drop support // Indicate that the OLV can be used to drag items out. // You can write this code, or you can set IsSimpleDropSource to true (in the Designer). this.olvComplex.DragSource = new SimpleDragSource(); // Indicate that the OLV can be accept items being dropped on it. // These items could come from an ObjectListView or from some other control (or even // from another application). // If the drag source is an ObjectListView, you can listen for ModelCanDrop and // ModelDropped events, which have some extra properties to make your life easier. // If the drag source is not an ObjectListView, you have to listen for CanDrop and // Dropped events, and figure out everything for yourself. SimpleDropSink dropSink = new SimpleDropSink(); dropSink.CanDropOnItem = true; //dropSink.CanDropOnSubItem = true; dropSink.FeedbackColor = Color.IndianRed; // just to be different this.olvComplex.DropSink = dropSink; // For our purpose here, we will make it that if you drop one or more person // onto someone, they all become married. dropSink.ModelCanDrop += delegate(object sender, ModelDropEventArgs e) { Person person = e.TargetModel as Person; if (person == null) { e.Effect = DragDropEffects.None; } else { if (person.MaritalStatus == MaritalStatus.Married) { e.Effect = DragDropEffects.None; e.InfoMessage = "Can't drop on someone who is already married"; } else { e.Effect = DragDropEffects.Move; } } }; dropSink.ModelDropped += delegate(object sender, ModelDropEventArgs e) { if (e.TargetModel == null) { return; } // Change the dropped people plus the target person to be married ((Person)e.TargetModel).MaritalStatus = MaritalStatus.Married; foreach (Person p in e.SourceModels) { p.MaritalStatus = MaritalStatus.Married; } // Force them to refresh e.RefreshObjects(); }; }
public SkillListView() { // forms settings Dock = System.Windows.Forms.DockStyle.Fill; // my settings m_ToolTip = new SkillToolTip(this); Options.RegisterEvent(Options.EVENT.OPTIONS_SHOWLISTGROUPS.ToString(), delegate(object x) { this.ShowGroups = Options.ShowListGroups; }); Options.RegisterEvent(Data.EVENT.DATA_LEARNSKILL.ToString(), delegate(object x) { if (this.SelectedItem != null) { List <Skill> list = x as List <Skill>; foreach (var sk in list) { if (this.SelectedItem.RowObject == sk) { // unselect this.SelectedItem = null; break; // done obv only 1 thing can be selected (by our settings on the OLV) } } } UpdateFilter(); }); m_decorRowRed.BorderPen = UITools.Pen_Red; m_decorRowRed.BoundsPadding = new Size(1, 1); m_decorRowRed.CornerRounding = 4.0f; m_decorRowRed.FillBrush = new SolidBrush(Color.FromArgb(32, UITools.Red)); Constant = false; // can change skills by default thru this listview // olv settings this.AutoGenerateColumns = false; this.ShowGroups = true; this.SortGroupItemsByPrimaryColumn = false; this.ModelFilter = new ModelFilter(Delegate_Filter); this.UseFiltering = true; this.ShowGroups = Options.ShowListGroups; this.GroupingStrategy = new SkillListGroupingStrategy(m_pSortProperties); this.ModelCanDrop += SkillListView_OnModelCanDrop; SimpleDropSink sink1 = (SimpleDropSink)DropSink; sink1.CanDropOnItem = false; sink1.CanDropOnBackground = true; SmallImageList = UITools.SmallIconImageList; GroupImageList = UITools.ClasstagsImageList; ShowFilterMenuOnRightClick = false; FullRowSelect = true; SelectColumnsOnRightClickBehaviour = ColumnSelectBehaviour.None; MultiSelect = false; // hot item selection RowBorderDecoration rbd = new RowBorderDecoration(); rbd.BorderPen = new Pen(Color.Black, 2); rbd.BoundsPadding = new Size(1, 1); rbd.CornerRounding = 4.0f; rbd.FillBrush = new SolidBrush(Color.FromArgb(64, 128, 128, 128)); // Put the decoration onto the hot item HotItemStyle = new HotItemStyle(); HotItemStyle.Decoration = rbd; this.UseHotItem = true; this.ClearHotItem(); // cuz it defaults to the first item for some reason without any mouse doing this.HideSelection = false; this.MouseMove += SkillListView_OnMouseMove; this.MouseLeave += SkillListView_OnMouseLeave; FormatRow += SkillListView_OnFormatRow; BeforeCreatingGroups += SkillListView_OnBeforeCreatingGroups; AboutToCreateGroups += SkillListView_OnAboutToCreateGroups; this.MouseClick += SkillListView_OnMouseClick; this.MouseDoubleClick += SkillListView_OnMouseDoubleClick; // columns List <ColumnSetting> vColumns = new List <ColumnSetting>(); vColumns.Add(new ColumnSetting("Name", "Name", 200)); vColumns.Add(new ColumnSetting("Class", "Class", 80)); vColumns.Add(new ColumnSetting("Spec", "Spec", 100)); vColumns.Add(new ColumnSetting("RequiredLevel", "Req. Level", 90)); vColumns.Add(new ColumnSetting("AECost", "AE", 50)); vColumns.Add(new ColumnSetting("TECost", "TE", 50)); foreach (var col in vColumns) { OLVColumn olvCol = GenerateColumn(); //olvCol.AspectName = col.m_szAspectName; // aspectgetter way faster (doesnt use reflection for property names) switch (col.m_szAspectName) { case "Name": // do our sortprops copy m_pSortProperties.SortColumn = olvCol; // init the real one to sync it this.PrimarySortColumn = olvCol; this.PrimarySortOrder = SortOrder.Ascending; this.SecondarySortColumn = olvCol; this.SecondarySortOrder = SortOrder.Ascending; olvCol.HeaderImageKey = "letter"; olvCol.AspectGetter = delegate(object sk) { return((sk as Skill).Name); }; olvCol.ImageGetter = delegate(object sk) { return((sk as Skill).IconAsString); }; break; case "Class": olvCol.HeaderImageKey = "warrior"; olvCol.AspectGetter = delegate(object sk) { return((sk as Skill).Class); }; olvCol.ImageGetter = delegate(object sk) { return((sk as Skill).Class); }; break; case "Spec": olvCol.HeaderImageKey = "ability_marksmanship"; olvCol.AspectGetter = delegate(object sk) { return(UITools.FixSpec((sk as Skill).Spec)); }; olvCol.ImageGetter = delegate(object sk) { Skill skill = sk as Skill; switch (skill.Spec) { case "Balance": return("spell_nature_starfall"); case "Feral": return("ability_racial_bearform"); case "Restoration": if (skill.Class == "Druid") { return("spell_nature_healingtouch"); } else // shaman { return("spell_nature_magicimmunity"); } case "BeastMastery": return("ability_hunter_beasttaming"); case "Marksmanship": return("ability_marksmanship"); case "Survival": return("ability_hunter_swiftstrike"); case "Arcane": return("spell_holy_magicalsentry"); case "Fire": return("spell_fire_flamebolt"); case "Frost": return("spell_frost_frostbolt02"); case "Holy": return("spell_holy_holybolt"); // they both use this (pal/priest) case "Protection": if (skill.Class == "Paladin") { return("spell_holy_devotionaura"); } else // warrior { return("ability_warrior_defensivestance"); } case "Retribution": return("spell_holy_auraoflight"); case "Discipline": return("spell_holy_wordfortitude"); case "Shadow": return("spell_shadow_shadowwordpain"); case "Assassination": return("ability_rogue_eviscerate"); case "Combat": return("ability_backstab"); case "Subtlety": return("ability_stealth"); case "Elemental": return("spell_nature_lightning"); case "Enhancement": return("spell_nature_lightningshield"); case "Affliction": return("spell_shadow_deathcoil"); case "Demonology": return("spell_shadow_metamorphosis"); case "Destruction": return("spell_shadow_rainoffire"); case "Arms": return("ability_rogue_eviscerate"); case "Fury": return("ability_warrior_innerrage"); case "General": return("ability_dualwield"); default: return(""); } }; break; case "RequiredLevel": olvCol.HeaderImageKey = "level"; olvCol.AspectGetter = delegate(object sk) { return((sk as Skill).RequiredLevel); }; break; case "AECost": olvCol.HeaderImageKey = "ae"; olvCol.AspectGetter = delegate(object sk) { return((sk as Skill).AECost); }; break; case "TECost": olvCol.HeaderImageKey = "te"; olvCol.AspectGetter = delegate(object sk) { return((sk as Skill).TECost); }; break; } olvCol.Text = col.m_szText; olvCol.Width = col.m_nWidth; } SetObjects(new List <Skill>(Data.AvailableList)); }
private void InitDragDrop(ObjectListView listView) { listView.IsSimpleDragSource = true; listView.IsSimpleDropSink = true; SimpleDropSink dropSink = (SimpleDropSink)listView.DropSink; dropSink.AcceptExternal = true; dropSink.CanDropBetween = true; dropSink.CanDropOnBackground = true; listView.ModelCanDrop += delegate(object sender, ModelDropEventArgs e) { bool isNavigator = this.IsNavigator(e.ListView); e.Handled = true; e.Effect = DragDropEffects.None; if (e.SourceModels.Contains(e.TargetModel)) { e.InfoMessage = "Cannot drop on self"; return; } else if (e.TargetModel is MyFileSystemInfo info) { string targetFolder = info.AsDirectory.FullName; if (info.IsDirectory) { if (e.SourceModels.OfType <MyFileSystemInfo>().Any(item => item.IsDirectory && targetFolder.StartsWith(item.AsDirectory.FullName))) { e.InfoMessage = "Cannot drop on descendant"; return; } } } else { if (e.SourceModels.OfType <MyFileSystemInfo>().Any(item => item.IsDrive)) { return; } if (isNavigator) { if (e.TargetModel == null) { return; } } else { if (e.ListView.Tag == null) { return; } } } e.Effect = DragDropEffects.Move; }; listView.ModelDropped += delegate(object sender, ModelDropEventArgs e) { bool isNavigator = this.IsNavigator(e.ListView); MyFileSystemInfo targetModel = null; if (isNavigator) { targetModel = e.TargetModel as MyFileSystemInfo; } else { targetModel = e.ListView.Tag as MyFileSystemInfo; } if (targetModel == null) { return; } this.MoveFiles(e.SourceListView, e.ListView, e.SourceModels.OfType <MyFileSystemInfo>(), targetModel, FileMoveMode.Drag); e.RefreshObjects(); e.Effect = DragDropEffects.None; }; }