private void _flipEditItemPanel(HeaderListItem item)
 {
     if (item.Editable && EditEvent != null)
     {
         EditEvent.Invoke(item);
     }
 }
        private HeaderListItem _createItem(TableExcelHeader header)
        {
            var item = new HeaderListItem();

            item.FieldName = header.FieldName;
            item.FieldType = header.FieldType;
            item.FieldDesc = header.FieldDesc;
            var binding = new Binding("ActualWidth")
            {
                Source = wp
            };

            item.SetBinding(FrameworkElement.WidthProperty, binding);
            item.MouseLeftButtonDown += (_s, _e) =>
            {
                _e.Handled = true;
                _selectItem(_s as HeaderListItem);
            };
            item.MouseRightButtonDown += (_s, _e) =>
            {
                _e.Handled = true;
                _selectItem(_s as HeaderListItem);
                _flipMenuWithItem(_s as HeaderListItem);
            };
            item.MouseDoubleClick += (_s, _e) =>
            {
                if (_e.ChangedButton == MouseButton.Left)
                {
                    _e.Handled = true;
                    _flipEditItemPanel(_s as HeaderListItem);
                }
            };
            return(item);
        }
 private void itemDeleteImpl(HeaderListItem item)
 {
     if (this.YesNoBox("确定要删除该条目吗?"))
     {
         lv.removeItem(item);
     }
 }
        private void itemAddCopyImpl(HeaderListItem item)
        {
            var panel = new HeaderFieldEdit();

            panel.IsFieldNameReadonly = false;
            panel.FieldName           = item.FieldName;
            panel.FieldType           = item.FieldType;
            panel.FieldDesc           = item.FieldDesc;

            var panel2 = new HeaderListView();

            var pw = new PopupWindow(panel);

            pw.Owner = Window.GetWindow(this);
            pw.Title = string.Format("复制添加字段");
            if (pw.ShowDialog() == true)
            {
                if (lv.isFieldNameExist(panel.FieldName))
                {
                    this.InfBox("该字段已存在!");
                    return;
                }

                lv.addItem(new TableExcelHeader()
                {
                    FieldName = panel.FieldName,
                    FieldType = panel.FieldType,
                    FieldDesc = panel.FieldDesc,
                }, true);
            }
        }
 public void removeItem(HeaderListItem item)
 {
     if (item == selectedItem_)
     {
         _selectItem(null);
     }
     items_.Remove(item);
     wp.Children.Remove(item);
     _refreshDisplayTip();
 }
        public void moveDown(HeaderListItem item)
        {
            int idx = items_.IndexOf(item);

            if (idx < 1 || idx == items_.Count - 1)
            {
                return;
            }

            var tmpItem = items_[idx + 1];

            items_[idx + 1] = item;
            items_[idx]     = tmpItem;
            wp.Children.RemoveAt(idx + 1);
            wp.Children.Insert(idx, tmpItem);
            sv.MakesureChildVisible(item);
        }
        private void itemEditImpl(HeaderListItem item)
        {
            var panel = new HeaderFieldEdit();

            panel.IsFieldNameReadonly = true;
            panel.FieldName           = item.FieldName;
            panel.FieldType           = item.FieldType;
            panel.FieldDesc           = item.FieldDesc;

            var pw = new PopupWindow(panel);

            pw.Owner = Window.GetWindow(this);
            pw.Title = string.Format("复制添加字段");
            if (pw.ShowDialog() == true)
            {
                item.FieldType = panel.FieldType;
                item.FieldDesc = panel.FieldDesc;
            }
        }
        private void _flipMenuWithItem(HeaderListItem item)
        {
            var menu = new ContextMenu();

            var miEdit = new MenuItem();

            miEdit.Header     = "编辑(_E)";
            miEdit.IsEnabled  = item.Editable;
            miEdit.FontWeight = FontWeights.Bold;
            miEdit.Click     += (_s, _e) => _flipEditItemPanel(item);
            menu.Items.Add(miEdit);

            var miAddCopy = new MenuItem();

            miAddCopy.IsEnabled = item.Editable;
            miAddCopy.Header    = "复制添加(_A)";
            miAddCopy.Click    += (_s, _e) =>
            {
                if (AddCopyEvent != null)
                {
                    AddCopyEvent.Invoke(item);
                }
            };
            menu.Items.Add(miAddCopy);

            var miDelete = new MenuItem();

            miDelete.IsEnabled = item.Editable;
            miDelete.Header    = "删除(_D)";
            miDelete.Click    += (_s, _e) =>
            {
                if (DeleteEvent != null)
                {
                    DeleteEvent.Invoke(item);
                }
            };
            menu.Items.Add(miDelete);

            menu.Placement = System.Windows.Controls.Primitives.PlacementMode.MousePoint;
            menu.IsOpen    = true;
        }
 private void _selectItem(HeaderListItem item)
 {
     if (selectedItem_ != item)
     {
         if (selectedItem_ != null)
         {
             selectedItem_.IsSelected = false;
         }
         selectedItem_ = item;
         if (selectedItem_ != null)
         {
             selectedItem_.IsSelected = true;
         }
         if (SelectedChangedEvent != null)
         {
             SelectedChangedEvent.Invoke(selectedItem_);
         }
     }
     if (selectedItem_ != null)
     {
         sv.MakesureChildVisible(selectedItem_);
     }
 }