Exemplo n.º 1
0
        void MoveUp()
        {
            try
            {
                if (!CanMoveUp)
                {
                    return;
                }
                TreeNode node     = this.SelectedNode;
                TreeNode prevNode = node.PrevNode;
                GType    type     = (GType)node.Tag;
                GType    prevType = (GType)prevNode.Tag;

                node.Remove();
                prevNode.Parent.Nodes.Insert(prevNode.Index, node);
                this.tvTypes.SelectedNode = node;

                int priority = type.Priority;
                type.Priority     = prevType.Priority;
                prevType.Priority = priority;

                if (app.GetControlsAttr(ControlsAttr.AutoSave))
                {
                    using (Context context = Lib.GetContext())
                    {
                        type.Save(context);
                        prevType.Save(context);
                    }
                }

                if (OnTypeMoved != null)
                {
                    OnTypeMoved(this, new TypeEventArgs(type));
                }
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
            finally
            {
                app.UpdateControls();
            }
        }