示例#1
0
        public static EnumWindow Create(ICbValueEnumClass <Enum> enumClass, Point?pos = null)
        {
            EnumWindow enumWindow = new EnumWindow();

            enumWindow.EnumItem = enumClass;
            enumWindow.Caption  = enumWindow.EnumItem.TypeName;
            enumWindow.Owner    = CommandCanvasList.OwnerWindow;
            ControlTools.SetWindowPos(enumWindow, pos);
            return(enumWindow);
        }
        public static StackNode Create(
            CommandCanvas OwnerCommandCanvas,
            string caption,
            ObservableCollection <StackGroup> stackList,
            bool forcedListTypeSelect,
            Point?pos = null)
        {
            ListSelectWindow selectWindow = new ListSelectWindow();

            selectWindow.Caption = caption;
            selectWindow.Owner   = CommandCanvasList.OwnerWindow;
            ControlTools.SetWindowPos(selectWindow, pos);

            if (DefaultValue != null)
            {
                selectWindow.Add("[ New ]");
            }
            List <string> teble = new List <string>();

            foreach (var node in stackList)
            {
                teble.Add(node.stackNode.ValueData.Name);

                if (DefaultValue != null)
                {
                    if (DefaultValue.TypeName != node.stackNode.ValueData.TypeName)
                    {
                        continue;
                    }
                }

                if (forcedListTypeSelect)
                {
                    if (!node.stackNode.ValueData.IsList)
                    {
                        continue;
                    }
                }

                selectWindow.Add(node.stackNode.ValueData.Name);
            }
            selectWindow.ShowDialog();
            if (selectWindow.SelectedIndex == -1)
            {
                return(null);
            }

            if (selectWindow.SelectedName == "[ New ]")
            {
                if (DefaultValue is null)
                {
                    return(null);
                }

                // 新規作成する
                DefaultValue.Name = "variable" + (OwnerCommandCanvas.ScriptWorkStack.StackData.Count + 1);
                var ret = OwnerCommandCanvas.ScriptWorkStack.Append(DefaultValue).stackNode;
                DefaultValue = null;
                return(ret);
            }
            DefaultValue = null;

            // 選ばれたアイテムの名前からインデックスを求める
            int index = teble.FindIndex((x) => x == selectWindow.SelectedName);

            return(stackList[index].stackNode);
        }