public ConfigurationWindow(object dataContext)
        {
            DataContext = dataContext;
            Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;

            Application.Current.DispatcherUnhandledException += (o, args) =>
            {
                Exception ex = (Exception)args.Exception;
                log.Debug("UI exception: ");
                log.Debug(ex);
                throw ex;
            };

            InitializeComponent();

            Style itemContainerStyle = new Style(typeof(ListBoxItem));

            itemContainerStyle.Setters.Add(new Setter(ListBoxItem.AllowDropProperty, true));
            itemContainerStyle.Setters.Add(new EventSetter(ListBoxItem.MouseMoveEvent,
                                                           new MouseEventHandler(NukeRulesListBox_PreviewMouseMove)));
            itemContainerStyle.Setters.Add(new EventSetter(ListBoxItem.DropEvent,
                                                           new DragEventHandler(NukeRulesListBox_Drop)));
            NukeRulesListBox.ItemContainerStyle = itemContainerStyle;

            itemContainerStyle = new Style(typeof(ListBoxItem));
            itemContainerStyle.Setters.Add(new Setter(ListBoxItem.AllowDropProperty, true));
            itemContainerStyle.Setters.Add(new EventSetter(ListBoxItem.MouseMoveEvent,
                                                           new MouseEventHandler(NukeRulesListBox_PreviewMouseMove)));
            itemContainerStyle.Setters.Add(new EventSetter(ListBoxItem.DropEvent,
                                                           new DragEventHandler(SelfHealBuffRulesListBox_Drop)));
            SelfHealRulesListBox.ItemContainerStyle = itemContainerStyle;

            itemContainerStyle = new Style(typeof(ListBoxItem));
            itemContainerStyle.Setters.Add(new Setter(ListBoxItem.AllowDropProperty, true));
            itemContainerStyle.Setters.Add(new EventSetter(ListBoxItem.MouseMoveEvent,
                                                           new MouseEventHandler(NukeRulesListBox_PreviewMouseMove)));
            itemContainerStyle.Setters.Add(new EventSetter(ListBoxItem.DropEvent,
                                                           new DragEventHandler(PartyHealBuffRulesListBox_Drop)));
            PartyHealRulesListBox.ItemContainerStyle = itemContainerStyle;

            Opened   = true;
            Instance = this;
        }
Ejemplo n.º 2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (!ConfigurationWindow.Opened)
            {
                var cfgwdw = new ConfigurationWindow(this.DataContext);
                if (ViewModel.SelectedBot?.PlayerData?.MainHero?.Name != null)
                {
                    cfgwdw.Title = ViewModel.SelectedBot?.PlayerData?.MainHero?.Name;
                }

                Dispatcher.BeginInvoke((Action)(() => cfgwdw.Show()));
            }
            else
            {
                if (ConfigurationWindow.Instance.WindowState == WindowState.Minimized)
                {
                    ConfigurationWindow.Instance.WindowState = WindowState.Normal;
                }

                ConfigurationWindow.Instance.Activate();
            }
        }