public void AutoTile_Edit(AutoTile element, TileBoxViewModel.EditElementOp op)
        {
            TileEditForm      frmData = new TileEditForm();
            TileEditViewModel tmv     = new TileEditViewModel();

            frmData.DataContext = tmv;
            tmv.Name            = element.ToString();

            //load as if eyedropping
            tmv.TileBrowser.TileSize     = ZoneManager.Instance.CurrentGround.TileSize;
            tmv.AutotileBrowser.TileSize = ZoneManager.Instance.CurrentGround.TileSize;
            tmv.LoadTile(element);

            tmv.SelectedOKEvent += () =>
            {
                element = tmv.GetTile();
                op(element);
                frmData.Close();
            };
            tmv.SelectedCancelEvent += () =>
            {
                frmData.Close();
            };

            DevForm form = (DevForm)DiagManager.Instance.DevEditor;

            form.GroundEditForm.RegisterChild(frmData);
            frmData.Show();
        }
        public override void LoadWindowControls(StackPanel control, string parent, string name, Type type, object[] attributes, AutoTile member)
        {
            LoadLabelControl(control, name);

            TileBox          cbxValue = new TileBox();
            TileBoxViewModel mv       = new TileBoxViewModel();

            cbxValue.DataContext = mv;

            //add lambda expression for editing a single element
            mv.OnEditItem += (AutoTile element, TileBoxViewModel.EditElementOp op) =>
            {
                TileEditForm      frmData = new TileEditForm();
                TileEditViewModel tmv     = new TileEditViewModel();
                frmData.DataContext = tmv;
                tmv.Name            = name + "/" + type.Name;

                //load as if eyedropping
                tmv.TileBrowser.TileSize = GraphicsManager.TileSize;
                tmv.LoadTile(element);

                tmv.SelectedOKEvent += () =>
                {
                    element = tmv.GetTile();
                    op(element);
                    frmData.Close();
                };
                tmv.SelectedCancelEvent += () =>
                {
                    frmData.Close();
                };

                control.GetOwningForm().RegisterChild(frmData);
                frmData.Show();
            };
            mv.LoadFromSource(member);
            control.Children.Add(cbxValue);
        }