private void OpenPartyTargetsSelect_ButtonClick(object sender, RoutedEventArgs e) { if (((ViewModel)this.DataContext).SelectedBot?.Engine.PartyHealBuffHandler.SelectedRule == null) { return; } var unitsForm = new SurroundingUnits(); unitsForm.DataContext = this.DataContext; //xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" string listBoxString = @"<ListBox Height=""230"" xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" > <ListBox.ItemTemplate> <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width=""50""></ColumnDefinition> <ColumnDefinition></ColumnDefinition> </Grid.ColumnDefinitions> <CheckBox Grid.Column=""0"" IsChecked=""{Binding Enable, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"" HorizontalAlignment=""Center""/> <TextBlock HorizontalAlignment=""Center"" Grid.Column=""2"" Text=""{Binding Name}"" FontSize=""16"" FontStyle=""Italic""></TextBlock> </Grid> </DataTemplate> </ListBox.ItemTemplate> </ListBox>"; var mainStackPanel = new StackPanel(); ListBox listBox = (ListBox)XamlReader.Parse(listBoxString); mainStackPanel.Children.Add(listBox); listBox.ItemsSource = ((ViewModel)this.DataContext).SelectedBot?.Engine?.PartyHealBuffHandler?.SelectedRule?.PlayersToBuff; var stackPanel = new StackPanel() { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Center }; Button addButton = (Button) XamlReader.Parse( @"<Button xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" Content=""Save"" FontSize=""14""/>"); addButton.Click += (o, args) => { var curRule = MainWindow.ViewModel.SelectedBot.Engine.PartyHealBuffHandler.SelectedRule; curRule.PlayersFilter.Clear(); foreach (UIFormElement partyUnit in listBox.ItemsSource) { if (!partyUnit.Name.Contains("'s")) { if (partyUnit.Enable && !curRule.UseOnPlayer) { curRule.PlayersFilter.Add(partyUnit.Name, FilterType.Inclusive); } else if (!partyUnit.Enable && curRule.UseOnPlayer) { curRule.PlayersFilter.Add(partyUnit.Name, FilterType.Exclusive); } } else { if (partyUnit.Enable && !curRule.UseOnSummonPet) { curRule.PlayersFilter.Add(partyUnit.Name, FilterType.Inclusive); } else if (!partyUnit.Enable && curRule.UseOnSummonPet) { curRule.PlayersFilter.Add(partyUnit.Name, FilterType.Exclusive); } } } unitsForm.Close(); }; stackPanel.Children.Add(addButton); Button closeButton = (Button) XamlReader.Parse( @"<Button xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" Content=""Close"" FontSize=""14"" Margin=""20,0,0,0"" />"); closeButton.Click += (o, args) => { unitsForm.Close(); }; stackPanel.Children.Add(closeButton); mainStackPanel.Children.Add(stackPanel); unitsForm.grid.Children.Add(mainStackPanel); Dispatcher.BeginInvoke((Action)(() => unitsForm.ShowDialog())); }
private void SearchItemsPickupAdd_ButtonClick(object sender, RoutedEventArgs e) { if (((ViewModel)this.DataContext).SelectedBot?.Engine?.PickupHandler.Initialiased != true) { return; } var unitsForm = new SurroundingUnits(); unitsForm.DataContext = this.DataContext; //xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" string listBoxString = @"<ListBox Height=""230"" xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" > <ListBox.ItemTemplate> <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width=""50""></ColumnDefinition> <ColumnDefinition></ColumnDefinition> </Grid.ColumnDefinitions> <CheckBox Grid.Column=""0"" IsChecked=""{Binding Enable, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"" HorizontalAlignment=""Center""/> <TextBlock HorizontalAlignment=""Center"" Grid.Column=""2"" Text=""{Binding Name}"" FontSize=""16"" FontStyle=""Italic""></TextBlock> </Grid> </DataTemplate> </ListBox.ItemTemplate> </ListBox>"; var mainStackPanel = new StackPanel(); ListBox listBox = (ListBox)XamlReader.Parse(listBoxString); mainStackPanel.Children.Add(listBox); listBox.ItemsSource = ((ViewModel)this.DataContext).SelectedBot?.Engine?.PickupHandler?.FilteredItems; var stackPanel = new StackPanel() { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Center }; Button addButton = (Button) XamlReader.Parse( @"<Button xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" Content=""Save"" FontSize=""14""/>"); addButton.Click += (o, args) => { var pickupHandler = ((ViewModel)DataContext).SelectedBot.Engine.PickupHandler; foreach (UIItemAdd item in listBox.ItemsSource) { if (item.Enable) { pickupHandler.RulesInUse.Add(new PickupRule(item.Id)); } } unitsForm.Close(); }; stackPanel.Children.Add(addButton); Button closeButton = (Button) XamlReader.Parse( @"<Button xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" Content=""Close"" FontSize=""14"" Margin=""20,0,0,0"" />"); closeButton.Click += (o, args) => { unitsForm.Close(); }; stackPanel.Children.Add(closeButton); mainStackPanel.Children.Add(stackPanel); unitsForm.grid.Children.Add(mainStackPanel); Dispatcher.BeginInvoke((Action)(() => unitsForm.ShowDialog())); }
private void OpenSelectionForm(IEnumerable src, Action <string> setOutput) { var unitsForm = new SurroundingUnits(); unitsForm.DataContext = this.DataContext; string listBoxString = @"<ListBox Height=""230"" xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" > <ListBox.ItemTemplate> <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width=""50""></ColumnDefinition> <ColumnDefinition></ColumnDefinition> </Grid.ColumnDefinitions> <CheckBox Grid.Column=""0"" IsChecked=""{Binding Enable, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"" HorizontalAlignment=""Center""/> <TextBlock HorizontalAlignment=""Center"" Grid.Column=""2"" Text=""{Binding Name}"" FontSize=""16"" FontStyle=""Italic""></TextBlock> </Grid> </DataTemplate> </ListBox.ItemTemplate> </ListBox>"; var mainStackPanel = new StackPanel(); ListBox listBox = (ListBox)XamlReader.Parse(listBoxString); mainStackPanel.Children.Add(listBox); listBox.ItemsSource = src; var stackPanel = new StackPanel() { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Center }; Button addButton = (Button) XamlReader.Parse( @"<Button xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" Content=""Save"" FontSize=""14""/>"); addButton.Click += (o, args) => { StringBuilder sb = new StringBuilder(); foreach (UIFormElement buff in listBox.ItemsSource) { if (buff.Enable) { sb.Append(buff.Name + ";"); } } setOutput(sb.ToString()); unitsForm.Close(); }; stackPanel.Children.Add(addButton); Button closeButton = (Button) XamlReader.Parse( @"<Button xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" Content=""Close"" FontSize=""14"" Margin=""20,0,0,0"" />"); closeButton.Click += (o, args) => { unitsForm.Close(); }; stackPanel.Children.Add(closeButton); mainStackPanel.Children.Add(stackPanel); unitsForm.grid.Children.Add(mainStackPanel); Dispatcher.BeginInvoke((Action)(() => unitsForm.ShowDialog())); }