public static bool MoveNode(Data.Node movedNode, Data.NodeBase targetParent, int targetIndex) { // Check if (movedNode.Parent == targetParent && targetIndex != int.MaxValue) { var index = targetParent.Children.Internal.Select((i, n) => Tuple35.Create(i, n)).FirstOrDefault(_ => _.Item1 == movedNode).Item2; // Not changed. if (index == targetIndex || index + 1 == targetIndex) { return(false); } } if (movedNode == targetParent) { return(false); } Func <Data.Node, bool> isFound = null; isFound = (Data.Node n) => { if (n.Children.Internal.Any(_ => _ == targetParent)) { return(true); } foreach (var n_ in n.Children.Internal) { if (isFound(n_)) { return(true); } } return(false); }; if (isFound(movedNode)) { return(false); } // if (targetParent == movedNode.Parent && targetIndex != int.MaxValue) { var index = targetParent.Children.Internal.Select((i, n) => Tuple35.Create(i, n)).FirstOrDefault(_ => _.Item1 == movedNode).Item2; if (index < targetIndex) { targetIndex -= 1; } } Command.CommandManager.StartCollection(); movedNode.Parent.RemoveChild(movedNode); targetParent.AddChild(movedNode, targetIndex); Command.CommandManager.EndCollection(); return(true); }
/// <summary> /// 現在有効なFカーブを含めたノード情報を取得する。 /// </summary> /// <returns></returns> public static Utl.ParameterTreeNode GetFCurveParameterNode() { // 実行速度を上げるために、全て力技で対応 // 値を取得する Func <Data.Node, Tuple35 <string, object>[]> getParameters = (node) => { var list = new List <Tuple35 <string, object> >(); if (node.LocationValues.Type.Value == Data.LocationValues.ParamaterType.LocationFCurve) { var name = "Location"; if (Language == Language.Japanese) { name = "位置"; } list.Add(Tuple35.Create(name, (object)node.LocationValues.LocationFCurve.FCurve)); } if (node.RotationValues.Type.Value == Data.RotationValues.ParamaterType.RotationFCurve) { var name = "Angle"; if (Language == Language.Japanese) { name = "角度"; } list.Add(Tuple35.Create(name, (object)node.RotationValues.RotationFCurve.FCurve)); } if (node.ScalingValues.Type.Value == Data.ScaleValues.ParamaterType.FCurve) { var name = "Scaling Factor"; if (Language == Language.Japanese) { name = "拡大率"; } list.Add(Tuple35.Create(name, (object)node.ScalingValues.FCurve.FCurve)); } if (node.RendererCommonValues.UV.Value == Data.RendererCommonValues.UVType.FCurve) { var name = "UV(Start)"; if (Language == Language.Japanese) { name = "UV(始点)"; } list.Add(Tuple35.Create(name, (object)node.RendererCommonValues.UVFCurve.Start)); } if (node.RendererCommonValues.UV.Value == Data.RendererCommonValues.UVType.FCurve) { var name = "UV(Size)"; if (Language == Language.Japanese) { name = "UV(大きさ)"; } list.Add(Tuple35.Create(name, (object)node.RendererCommonValues.UVFCurve.Size)); } if (node.DrawingValues.Type.Value == Data.RendererValues.ParamaterType.Sprite && node.DrawingValues.Sprite.ColorAll.Value == Data.StandardColorType.FCurve) { var name = "Sprite-Color all(RGBA)"; if (Language == Language.Japanese) { name = "スプライト・全体色(RGBA)"; } list.Add(Tuple35.Create(name, (object)node.DrawingValues.Sprite.ColorAll_FCurve.FCurve)); } if (node.DrawingValues.Type.Value == Data.RendererValues.ParamaterType.Model && node.DrawingValues.Model.Color.Value == Data.StandardColorType.FCurve) { var name = "Model-Color(RGBA)"; if (Language == Language.Japanese) { name = "モデル・色(RGBA)"; } list.Add(Tuple35.Create(name, (object)node.DrawingValues.Model.Color_FCurve.FCurve)); } if (node.DrawingValues.Type.Value == Data.RendererValues.ParamaterType.Track) { if (node.DrawingValues.Track.ColorLeft.Value == Data.StandardColorType.FCurve) { var name = "Track-Color,Left(RGBA)"; if (Language == Language.Japanese) { name = "軌跡・左(RGBA)"; } list.Add(Tuple35.Create(name, (object)node.DrawingValues.Track.ColorLeft_FCurve.FCurve)); } if (node.DrawingValues.Track.ColorLeftMiddle.Value == Data.StandardColorType.FCurve) { var name = "Track-Color,Left-Center(RGBA)"; if (Language == Language.Japanese) { name = "軌跡・左中間(RGBA)"; } list.Add(Tuple35.Create(name, (object)node.DrawingValues.Track.ColorLeftMiddle_FCurve.FCurve)); } if (node.DrawingValues.Track.ColorCenter.Value == Data.StandardColorType.FCurve) { var name = "Track-Color,Center(RGBA)"; if (Language == Language.Japanese) { name = "軌跡・中央(RGBA)"; } list.Add(Tuple35.Create(name, (object)node.DrawingValues.Track.ColorCenter_FCurve.FCurve)); } if (node.DrawingValues.Track.ColorCenterMiddle.Value == Data.StandardColorType.FCurve) { var name = "Track-Color,Center-Middle(RGBA)"; if (Language == Language.Japanese) { name = "軌跡・中央中間(RGBA)"; } list.Add(Tuple35.Create(name, (object)node.DrawingValues.Track.ColorCenterMiddle_FCurve.FCurve)); } if (node.DrawingValues.Track.ColorRight.Value == Data.StandardColorType.FCurve) { var name = "Track-Color,Right(RGBA)"; if (Language == Language.Japanese) { name = "軌跡・右(RGBA)"; } list.Add(Tuple35.Create(name, (object)node.DrawingValues.Track.ColorRight_FCurve.FCurve)); } if (node.DrawingValues.Track.ColorRightMiddle.Value == Data.StandardColorType.FCurve) { var name = "Track-Color,Right-Center(RGBA)"; if (Language == Language.Japanese) { name = "軌跡・右中間(RGBA)"; } list.Add(Tuple35.Create(name, (object)node.DrawingValues.Track.ColorRightMiddle_FCurve.FCurve)); } } return(list.ToArray()); }; // Generate tree Func <Data.NodeBase, Utl.ParameterTreeNode> getParameterTreeNodes = null; getParameterTreeNodes = (node) => { Tuple35 <string, object>[] parameters = null; var rootNode = node as Data.NodeRoot; var normalNode = node as Data.Node; if (rootNode != null) { parameters = new Tuple35 <string, object> [0]; } else if (normalNode != null) { parameters = getParameters(normalNode); } List <Utl.ParameterTreeNode> children = new List <ParameterTreeNode>(); for (int i = 0; i < node.Children.Count; i++) { children.Add(getParameterTreeNodes(node.Children[i])); } return(new ParameterTreeNode(node, parameters, children.ToArray())); }; return(getParameterTreeNodes(Root)); }