コード例 #1
0
ファイル: CbFunc.cs プロジェクト: katsumiar/CapyCSS
        /// <summary>
        /// Func<object, type> 型の CbFunc<type> 型の変数を返します。
        /// </summary>
        /// <param name="type">オリジナルの元々の型</param>
        /// <param name="retType">オリジナルの返し値の型</param>
        /// <param name="name">変数名</param>
        /// <returns>CbFunc<type> 型の変数</returns>
        public static ICbValue FuncValue(Type type, Type retType, string name)
        {
            if (type is null)
            {
                return(null);
            }
            string typeName = type.FullName;

            if (type.IsByRef)
            {
                // リファレンス(スクリプト変数接続)

                typeName = typeName.Replace("&", "");
                type     = CbST.GetTypeEx(typeName);
            }

            foreach (var arg in type.GenericTypeArguments)
            {
                Type cbType = CbST.ConvertCbType(arg);
                if (cbType is null)
                {
                    return(null);
                }
            }

            return(CbFunc.CreateFuncFromOriginalType(type, retType, name));
        }
コード例 #2
0
            public _AssetXML()
            {
                ReadAction = (self) =>
                {
                    if (DataVersion != DATA_VERSION)
                    {
                        ControlTools.ShowErrorMessage(CapyCSS.Language.Instance["Help:DataVersionError"]);
                        return;
                    }

                    self.attachVariableIds = RootFunc.AttachVariableIds;

                    if (RootFunc.AttachFileName != null)
                    {
                        self.AttachParam = new AttachText(RootFunc.AttachFileName);
                    }
                    if (RootFunc.AttachVariableId != 0)
                    {
                        self.AttachParam = new AttachVariableId(RootFunc.AttachVariableId);
                    }

                    if (RootFunc.AssetValueType != null)
                    {
                        Type type = CbST.GetTypeEx(RootFunc.AssetValueType);
                        self.SelectedVariableType[0]     = type;
                        self.SelectedVariableTypeName[0] = RootFunc.AssetValueType;
                    }
                    else
                    {
                        self.SelectedVariableTypes = RootFunc.AssetValueTypes.ToArray();
                    }

                    self.IsReBuildMode = true;
                    self.AssetFuncType = RootFunc.AssetFuncType;
                    self.AssetType     = RootFunc.AssetType;

                    self.LinkConnectorControl.AssetXML = RootFunc.RootConnector;
                    self.LinkConnectorControl.AssetXML.ReadAction?.Invoke(self.LinkConnectorControl);

                    // 次回の為の初期化
                    self.AssetXML = new _AssetXML <MultiRootConnector>(self);
                };
            }
コード例 #3
0
ファイル: CbScript.cs プロジェクト: katsumiar/CapyCSS
        /// <summary>
        /// 指定されたアセットコードに対してウインドウを表示して変数の型を選択しノードを作成します。
        /// </summary>
        /// <param name="assetCode">アセットコード</param>
        /// <param name="multiRootConnector">対象のMultiRootConnector</param>
        /// <param name="stackNode">変数の登録領域</param>
        /// <param name="forcedListTypeSelect">リスト型を選択するか?</param>
        /// <returns>ノード</returns>
        private static MultiRootConnector _CreateFreeTypeVariableFunction(
            CommandCanvas OwnerCommandCanvas,
            string assetCode,
            List <TypeRequest> typeRequests,
            MultiRootConnector multiRootConnector,
            StackNode stackNode,
            bool forcedListTypeSelect)
        {
            if (multiRootConnector is null)
            {
                List <string> typeNames;
                if (typeRequests == null)
                {
                    if (OwnerCommandCanvas.ScriptWorkStack.StackData.Count != 0)
                    {
                        // 既存の変数から選択する

                        stackNode = ListSelectWindow.Create(
                            OwnerCommandCanvas,
                            "Variable",
                            OwnerCommandCanvas.ScriptWorkStack.StackData,
                            forcedListTypeSelect,
                            new Point(Mouse.GetPosition(null).X, Mouse.GetPosition(null).Y));

                        if (stackNode is null)
                        {
                            return(null);
                        }

                        typeNames = new List <string>();
                        typeNames.Add(stackNode.ValueData.OriginalType.FullName);
                    }
                    else
                    {
                        // 既存の変数が存在しない

                        return(null);
                    }
                }
                else
                {
                    // 変数を新規作成する

                    typeNames = OwnerCommandCanvas.RequestTypeName(typeRequests);

                    if (typeNames is null)
                    {
                        return(null);
                    }

                    int    nameIndex = 1;
                    string name;
                    do
                    {
                        name = "variable" + nameIndex++;
                    }while (OwnerCommandCanvas.ScriptWorkStack.NameContains(name));

                    ListSelectWindow.DefaultValue = CbST.CbCreate(CbST.GetTypeEx(typeNames[0]), name);
                    stackNode = OwnerCommandCanvas.ScriptWorkStack.Append(ListSelectWindow.DefaultValue).stackNode;
                    ListSelectWindow.DefaultValue = null;
                }

                multiRootConnector = new MultiRootConnector(nameof(CbScript));
                multiRootConnector.OwnerCommandCanvas    = OwnerCommandCanvas;
                multiRootConnector.SelectedVariableTypes = typeNames.ToArray();

                multiRootConnector.AssetFuncType = assetCode;
            }

            multiRootConnector.AttachParam = new MultiRootConnector.AttachVariableId(stackNode.Id);
            multiRootConnector.AssetType   = FunctionType.FuncType;

            return(multiRootConnector);
        }