예제 #1
0
        protected override void OnInitialized()
        {
            base.OnInitialized();
            if (!typeof(GOAPAction).IsAssignableFrom(T_Model.GetType()))
            {
                return;
            }

            for (int i = 0; i < T_Model.Preconditions.Count; i++)
            {
                VisualElement v = CreateToggle(T_Model.Preconditions[i], (ele, state) =>
                {
                    T_Model.RemovePrecondition(state);
                    ele.RemoveFromHierarchy();
                });
                conditionFoldout.Add(v);
                ConditionElements[T_Model.Preconditions[i]] = v;
            }

            for (int i = 0; i < T_Model.Effects.Count; i++)
            {
                VisualElement v = CreateToggle(T_Model.Effects[i], (ele, state) =>
                {
                    T_Model.RemoveEffect(state);
                    ele.RemoveFromHierarchy();
                });
                effectFoldout.Add(v);
                EffectElements[T_Model.Effects[i]] = v;
            }
        }
        protected override void BindingProperties()
        {
            base.BindingProperties();
            T_Model.BindingProperty <string>(nameof(T_Model.Name), OnDataNameChanged);

            title = T_Model.Name;
        }
예제 #3
0
 /// <summary>
 /// 处理工程单位字段
 /// </summary>
 /// <param name="To_JavaXml">XML文档</param>
 /// <param name="item">XML属性对象</param>
 /// <param name="field">单位名称</param>
 public static void FieldMethod(System.Xml.XmlDocument To_JavaXml, T_Model item, string field, ref XmlElement X_temp, ProjectItemUnits projectFactory)
 {
     if (projectFactory != null)
     {
         if (projectFactory.ProjectDetail[field] is System.String[])
         {
             string Svalue = "";
             foreach (string values in (projectFactory.ProjectDetail[field] as System.String[]))
             {
                 if (!string.IsNullOrWhiteSpace(values))
                 {
                     Svalue += values + ",";
                 }
             }
             if (Svalue.EndsWith(","))
             {
                 Svalue = Svalue.Remove(Svalue.Length - 1);
             }
             X_temp = To_JavaXml.CreateElement(item.MappColumn);
             X_temp.SetAttribute("value", Svalue);
         }
         else
         {
             X_temp = To_JavaXml.CreateElement(item.MappColumn);
             X_temp.SetAttribute("value", projectFactory.ProjectDetail[field] == null ? "" : projectFactory.ProjectDetail[field].ToString());
         }
     }
 }
예제 #4
0
        void OnEffectAdded(GOAPState _newEffect)
        {
            VisualElement v = CreateToggle(_newEffect, (ele, state) =>
            {
                T_Model.RemoveEffect(state);
            });

            effectFoldout.Add(v);
            EffectElements[_newEffect] = v;
        }
예제 #5
0
        void OnPreconditionAdded(GOAPState _newCondition)
        {
            VisualElement v = CreateToggle(_newCondition, (ele, state) =>
            {
                T_Model.RemovePrecondition(state);
            });

            conditionFoldout.Add(v);
            ConditionElements[_newCondition] = v;
        }
예제 #6
0
        private void DataGrid1_LoadingRow(object sender, DataGridRowEventArgs e)
        {
            T_Model bindData = (T_Model)e.Row.DataContext;
            Button  btn      = DataGrid1.Columns[2].GetCellContent(e.Row).FindName("Button1") as Button;

            btn.Tag = bindData.id;

            btn     = DataGrid1.Columns[3].GetCellContent(e.Row).FindName("btn_Del") as Button;
            btn.Tag = bindData.id;
        }
예제 #7
0
        public override void UnBindingProperties()
        {
            base.UnBindingProperties();

            T_Model.UnBindingProperty <string>(nameof(T_Model.Name), OnNameChanged);
            T_Model.UnBindingProperty <float>(nameof(T_Model.Cost), OnCostChanged);

            T_Model.onPreconditionAdded   -= OnPreconditionAdded;
            T_Model.onPreconditionRemoved -= OnPreconditionRemoved;

            T_Model.onEffectAdded   -= OnEffectAdded;
            T_Model.onEffectRemoved -= OnEffectRemoved;
        }
예제 #8
0
        protected override void BindingProperties()
        {
            base.BindingProperties();
            rawTitle = T_Model.Title;

            nameField.SetValueWithoutNotify(T_Model.Name);
            costField.SetValueWithoutNotify(T_Model.Cost);
            Model.Title = T_Model.Name + $"({rawTitle})";

            nameField.RegisterValueChangedCallback(evt =>
            {
                T_Model.Name = evt.newValue;
            });

            costField.RegisterValueChangedCallback(evt =>
            {
                T_Model.Cost = evt.newValue;
            });

            btnAddCondition.clicked += () =>
            {
                T_Model.AddPrecondition(new GOAPState());
                Owner.SetDirty();
            };
            btnAddEffect.clicked += () =>
            {
                T_Model.AddEffect(new GOAPState());
                Owner.SetDirty();
            };

            T_Model.BindingProperty <string>(nameof(T_Model.Name), OnNameChanged);
            T_Model.BindingProperty <float>(nameof(T_Model.Cost), OnCostChanged);

            T_Model.onPreconditionAdded   += OnPreconditionAdded;
            T_Model.onPreconditionRemoved += OnPreconditionRemoved;

            T_Model.onEffectAdded   += OnEffectAdded;
            T_Model.onEffectRemoved += OnEffectRemoved;
        }
예제 #9
0
        //加载球赛信息 “场次,主场球队,客场球队等”,加载到datagrid(回调函数)
        void sc_GetModelByIDCompleted(object sender, GetModelByIDCompletedEventArgs e)
        {
            Model = new List<T_Model>(e.Result)[0];

            if (Model == null)
            {
                return;
            }

            Grid ModelGrid = new Grid();
            ModelGrid.Width = 325;
            ModelGrid.Height = 352;

            ColumnDefinition cd1 = new ColumnDefinition();
            cd1.Width = new GridLength(108);
            ColumnDefinition cd2 = new ColumnDefinition();
            cd2.Width = new GridLength(108);
            ColumnDefinition cd3 = new ColumnDefinition();
            cd3.Width = new GridLength(108);
            ColumnDefinition cd4 = new ColumnDefinition();
            cd4.Width = new GridLength(108);
            ModelGrid.ColumnDefinitions.Add(cd1);
            ModelGrid.ColumnDefinitions.Add(cd2);
            ModelGrid.ColumnDefinitions.Add(cd3);
            ModelGrid.ColumnDefinitions.Add(cd4);

            RowDefinition rda = new RowDefinition();
            rda.Height = new GridLength(20);
            ModelGrid.RowDefinitions.Add(rda);

            TextBlock lba = new TextBlock();
            lba.Text = "步骤";
            lba.Margin = new Thickness(2);
            lba.VerticalAlignment = VerticalAlignment.Center;
            lba.FontSize = 13;

            Grid.SetColumn(lba, 0);
            Grid.SetRow(lba, 0);
            ModelGrid.Children.Add(lba);

            RowDefinition rda1 = new RowDefinition();
            rda1.Height = new GridLength(20);
            ModelGrid.RowDefinitions.Add(rda1);

            TextBlock lba1 = new TextBlock();
            lba1.Text = "条件名称";
            lba1.Margin = new Thickness(2);
            lba1.VerticalAlignment = VerticalAlignment.Center;
            lba1.FontSize = 13;

            Grid.SetColumn(lba1, 1);
            Grid.SetRow(lba1, 0);
            ModelGrid.Children.Add(lba1);

            RowDefinition rda2 = new RowDefinition();
            rda2.Height = new GridLength(20);
            ModelGrid.RowDefinitions.Add(rda2);

            TextBlock lba2 = new TextBlock();
            lba2.Text = "条件设置";
            lba2.Margin = new Thickness(2);
            lba2.VerticalAlignment = VerticalAlignment.Center;
            lba2.FontSize = 13;

            Grid.SetColumn(lba2, 2);
            Grid.SetRow(lba2, 0);
            ModelGrid.Children.Add(lba2);

            ModleName.Content = Model.Name;
            ModleContent.Content = Model.Descption;

            string[] strContent = Model.Content.Split('b');
            int i = 1;

            foreach (string str in strContent)
            {
                if (string.IsNullOrEmpty(str))
                {
                    continue;
                }

                RowDefinition rd = new RowDefinition();
                rd.Height = new GridLength(20);
                ModelGrid.RowDefinitions.Add(rd);

                Label lb = new Label();
                lb.Content = "第 " + str.Substring(0, str.IndexOf('a')) + " 步";
                lb.BorderThickness = new Thickness(1, 0, 0, 0);
                lb.VerticalAlignment = VerticalAlignment.Center;
                lb.FontSize = 11;

                string tempstr = str.Substring(str.IndexOf('a') + 1);

                Grid.SetColumn(lb, 0);
                Grid.SetRow(lb, i);
                Grid.SetRowSpan(lb, tempstr.Split(']').Length);

                ModelGrid.Children.Add(lb);

                string[] strCondent = tempstr.Split(']');

                if (strCondent.Length < 1)
                {
                    continue;
                }

                Brush[] brushs = new Brush[] { new SolidColorBrush(Color.FromArgb(128, 242, 242, 242)), new SolidColorBrush(Color.FromArgb(255, 00, 00, 00)) };

                for (int j = 0; j < strCondent.Length; j++)
                {
                    if (string.IsNullOrEmpty(strCondent[j]))
                    {
                        continue;
                    }

                    RowDefinition rd1 = new RowDefinition();
                    rd1.Height = new GridLength(20);
                    ModelGrid.RowDefinitions.Add(rd1);

                    Label lb1 = new Label();
                    lb1.BorderThickness = new Thickness(1, 0, 0, 0);
                    lb1.VerticalAlignment = VerticalAlignment.Center;
                    lb1.FontSize = 11;
                    //lb1.Background = brushs[0];
                    //lb1.BorderBrush = brushs[1];
                    Grid.SetColumn(lb1, 1);
                    Grid.SetRow(lb1, i);

                    string[] strResult = strCondent[j].Split('@');

                    if (strResult.Length < 2)
                    {
                        continue;
                    }

                    lb1.Content = strResult[0].Replace("[", "");
                    ModelGrid.Children.Add(lb1);

                    Label lb2 = new Label();
                    lb2.BorderThickness = new Thickness(1, 0, 0, 0);
                    lb2.VerticalAlignment = VerticalAlignment.Center;
                    lb2.FontSize = 11;
                    //lb2.Background = brushs[0];
                    //lb2.BorderBrush = brushs[1];
                    Grid.SetColumn(lb2, 2);
                    Grid.SetRow(lb2, i);

                    if (strResult[1].IndexOf(";") >= 0)
                    {
                        lb2.Content = "共设置了 " + strResult[1].Split(';').Length + " 个条件";
                    }
                    else
                    {
                        lb2.Content = strResult[1];
                    }

                    ModelGrid.Children.Add(lb2);

                    i++;
                }
            }

            scorllTable.Content = ModelGrid;
        }
 public override void UnBindingProperties()
 {
     base.UnBindingProperties();
     T_Model.UnBindingProperty <string>(nameof(T_Model.Name), OnDataNameChanged);
 }
예제 #11
0
        /// <summary>
        /// 设置XML输出信息
        /// </summary>
        /// <param name="To_JavaXml">XML文档</param>
        /// <param name="project">工程对象</param>
        /// <param name="sqlID">SQL查询标识</param>
        /// <param name="xmlInfo">节点XML</param>
        /// <param name="template">模板名称</param>
        /// <param name="where">查询条件</param>
        /// <returns>自定义字段集合</returns>
        public static List <T_Model> setXmlInfo(XmlDocument To_JavaXml, T_Projects project, string sqlID, XmlElement xmlInfo, string template, string where = "")
        {
            XmlDoc         doc        = new XmlDoc(Application.StartupPath + @"\Common\XMLTemplate\" + template + ".xml");
            XmlNodeList    nodeList   = doc.GetNodeList("root");
            XmlNodeList    columList  = null;
            XmlNodeList    sqlList    = null;
            List <T_Model> modelList  = new List <T_Model>();
            List <T_Model> resultList = new List <T_Model>();
            string         sql        = string.Empty;

            #region XML节点
            for (int i = 0; i < nodeList.Count; i++)
            {
                switch (nodeList[i].Name.ToLower())
                {
                case "columns":
                    columList = nodeList[i].ChildNodes;
                    break;

                case "selects":
                    sqlList = nodeList[i].ChildNodes;
                    break;
                }
            }
            #endregion

            #region 模板字段
            if (columList != null)
            {
                modelList.Clear();
                resultList.Clear();

                T_Model model = null;

                for (int i = 0; i < columList.Count; i++)
                {
                    XmlNode node = columList[i];
                    XmlAttributeCollection attrCollection = node.Attributes;

                    if (attrCollection == null)
                    {
                        continue;
                    }
                    model = new T_Model();

                    for (int j = 0; j < attrCollection.Count; j++)
                    {
                        switch (attrCollection[j].Name)
                        {
                        case "column":
                            model.Column = attrCollection[j].Value;
                            break;

                        case "mappColumn":
                            model.MappColumn = attrCollection[j].Value;
                            break;

                        case "display":
                            model.Display = attrCollection[j].Value;
                            break;

                        case "description":
                            model.Description = attrCollection[j].Value;
                            break;

                        case "type":
                            model.Type = attrCollection[j].Value;
                            break;

                        case "default":
                            model.Default = attrCollection[j].Value;
                            break;
                        }
                    }

                    if (model.Display == "1")
                    {
                        modelList.Add(model);
                    }

                    if (model.Type == "1")
                    {
                        resultList.Add(model);
                    }
                }
            }
            #endregion

            #region  射字段
            if (sqlList.Count > 0)
            {
                for (int j = 0; j < sqlList.Count; j++)
                {
                    XmlAttributeCollection attrColl = sqlList[j].Attributes;
                    if (attrColl["id"].Value.ToString() == sqlID)
                    {
                        sql = sqlList[j].InnerText.Trim();

                        #region 参数处理
                        //switch (attrColl["parameterClass"].Value.ToLower())
                        //{
                        //    case "string":
                        //        sql = sql.Replace("#value#", "'" + project.ProjectNO + "'");
                        //        break;
                        //    case "int":
                        //        sql = sql.Replace("#value#", project.ProjectNO);
                        //        break;
                        //    default:
                        //        dynamic d = attrColl["parameterClass"].Value;

                        //        sql = sql.Replace("#value#", project.ProjectNO);
                        //        break;
                        //}
                        #endregion

                        #region 输出XML
                        try
                        {
                            DataSet ds = ERM.DAL.MyBatis.QueueyForSql(sql + "  " + where);
                            if (ds.Tables.Count > 0)
                            {
                                for (int m = 0; m < ds.Tables[0].Rows.Count; m++)
                                {
                                    for (int k = 0; k < modelList.Count; k++)
                                    {
                                        for (int n = 0; n < ds.Tables[0].Columns.Count; n++)
                                        {
                                            if (modelList[k].Column.ToString().ToLower() == ds.Tables[0].Columns[n].ColumnName.ToString().ToLower())
                                            {
                                                XmlElement X_temp = To_JavaXml.CreateElement(modelList[k].MappColumn);
                                                if (!string.IsNullOrEmpty(ds.Tables[0].Rows[m][n].ToString()))
                                                {
                                                    X_temp.SetAttribute("value", ds.Tables[0].Rows[m][n].ToString());
                                                }
                                                else
                                                {
                                                    X_temp.SetAttribute("value", modelList[k].Default);
                                                }
                                                xmlInfo.AppendChild(X_temp);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            TX.Framework.WindowUI.Forms.TXMessageBoxExtensions.Info(ex.Message.ToString());
                        }
                        break;
                        #endregion
                    }
                }
            }
            return(resultList);

            #endregion
        }
예제 #12
0
        /// <summary>
        /// 根据配置模板动态导出XML
        /// </summary>
        /// <param name="To_JavaXml">XML文档对象</param>
        /// <param name="project">工程对象</param>
        /// <param name="tableName">查询表名</param>
        /// <param name="xmlInfo">XML节点</param>
        /// <param name="template">XML模板名</param>
        /// <param name="outList">非数据库取值字段列表,在具体实现类处理</param>
        public static void setXmlInfo(XmlDocument To_JavaXml, T_Projects project, string tableName, XmlElement xmlInfo, string template, out List <T_Model> outList, string where)
        {
            XmlDoc      doc       = new XmlDoc(Application.StartupPath + @"\Common\XMLTemplate\" + template + ".xml");
            XmlNodeList nodeList  = doc.GetNodeList("root");
            XmlNodeList childList = null;

            outList = new List <T_Model>();

            for (int i = 0; i < nodeList.Count; i++)
            {
                if (nodeList[i].Name.ToLower() == "columns")
                {
                    childList = nodeList[i].ChildNodes;
                    break;
                }
            }

            if (childList != null)
            {
                T_Model        model      = null;
                string         sql        = string.Empty;
                List <T_Model> columnList = new List <T_Model>();

                for (int i = 0; i < childList.Count; i++)
                {
                    XmlNode node = childList[i];
                    XmlAttributeCollection attrCollection = node.Attributes;

                    if (attrCollection == null)
                    {
                        continue;
                    }
                    model = new T_Model();

                    for (int j = 0; j < attrCollection.Count; j++)
                    {
                        switch (attrCollection[j].Name)
                        {
                        case "column":
                            model.Column = attrCollection[j].Value;
                            break;

                        case "mappColumn":
                            model.MappColumn = attrCollection[j].Value;
                            break;

                        case "display":
                            model.Display = attrCollection[j].Value;
                            break;

                        case "description":
                            model.Description = attrCollection[j].Value;
                            break;

                        case "type":
                            model.Type = attrCollection[j].Value;
                            break;
                        }
                    }

                    if (model.Display == "1")
                    {
                        if (model.Type == "0")
                        {
                            sql += "[" + model.Column + "],";
                            columnList.Add(model);
                        }
                        else
                        {
                            outList.Add(model);
                        }
                    }
                }

                if (sql.Length > 0)
                {
                    sql = "select " + sql.TrimEnd(',') + " from " + tableName + " where " + where;
                    DataSet ds = ERM.DAL.MyBatis.QueueyForSql(sql);

                    if (ds.Tables.Count > 0)
                    {
                        DataTable dt = ds.Tables[0];
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            for (int j = 0; j < dt.Columns.Count; j++)
                            {
                                XmlElement X_temp = To_JavaXml.CreateElement(columnList[j].MappColumn);
                                X_temp.SetAttribute("value", dt.Rows[i][j].ToString());
                                X_temp.SetAttribute("description", columnList[j].Description);
                                xmlInfo.AppendChild(X_temp);
                            }
                        }
                    }
                }
            }
        }
예제 #13
0
        //加载球赛信息 “场次,主场球队,客场球队等”,加载到datagrid(回调函数)
        void sc_GetModelByIDCompleted(object sender, GetModelByIDCompletedEventArgs e)
        {
            Model = new List <T_Model>(e.Result)[0];

            if (Model == null)
            {
                return;
            }

            Grid ModelGrid = new Grid();

            ModelGrid.Width  = 325;
            ModelGrid.Height = 352;

            ColumnDefinition cd1 = new ColumnDefinition();

            cd1.Width = new GridLength(108);
            ColumnDefinition cd2 = new ColumnDefinition();

            cd2.Width = new GridLength(108);
            ColumnDefinition cd3 = new ColumnDefinition();

            cd3.Width = new GridLength(108);
            ColumnDefinition cd4 = new ColumnDefinition();

            cd4.Width = new GridLength(108);
            ModelGrid.ColumnDefinitions.Add(cd1);
            ModelGrid.ColumnDefinitions.Add(cd2);
            ModelGrid.ColumnDefinitions.Add(cd3);
            ModelGrid.ColumnDefinitions.Add(cd4);

            RowDefinition rda = new RowDefinition();

            rda.Height = new GridLength(20);
            ModelGrid.RowDefinitions.Add(rda);

            TextBlock lba = new TextBlock();

            lba.Text              = "步骤";
            lba.Margin            = new Thickness(2);
            lba.VerticalAlignment = VerticalAlignment.Center;
            lba.FontSize          = 13;

            Grid.SetColumn(lba, 0);
            Grid.SetRow(lba, 0);
            ModelGrid.Children.Add(lba);

            RowDefinition rda1 = new RowDefinition();

            rda1.Height = new GridLength(20);
            ModelGrid.RowDefinitions.Add(rda1);

            TextBlock lba1 = new TextBlock();

            lba1.Text              = "条件名称";
            lba1.Margin            = new Thickness(2);
            lba1.VerticalAlignment = VerticalAlignment.Center;
            lba1.FontSize          = 13;

            Grid.SetColumn(lba1, 1);
            Grid.SetRow(lba1, 0);
            ModelGrid.Children.Add(lba1);

            RowDefinition rda2 = new RowDefinition();

            rda2.Height = new GridLength(20);
            ModelGrid.RowDefinitions.Add(rda2);

            TextBlock lba2 = new TextBlock();

            lba2.Text              = "条件设置";
            lba2.Margin            = new Thickness(2);
            lba2.VerticalAlignment = VerticalAlignment.Center;
            lba2.FontSize          = 13;

            Grid.SetColumn(lba2, 2);
            Grid.SetRow(lba2, 0);
            ModelGrid.Children.Add(lba2);

            ModleName.Content    = Model.Name;
            ModleContent.Content = Model.Descption;

            string[] strContent = Model.Content.Split('b');
            int      i          = 1;

            foreach (string str in strContent)
            {
                if (string.IsNullOrEmpty(str))
                {
                    continue;
                }

                RowDefinition rd = new RowDefinition();
                rd.Height = new GridLength(20);
                ModelGrid.RowDefinitions.Add(rd);

                Label lb = new Label();
                lb.Content           = "第 " + str.Substring(0, str.IndexOf('a')) + " 步";
                lb.BorderThickness   = new Thickness(1, 0, 0, 0);
                lb.VerticalAlignment = VerticalAlignment.Center;
                lb.FontSize          = 11;

                string tempstr = str.Substring(str.IndexOf('a') + 1);

                Grid.SetColumn(lb, 0);
                Grid.SetRow(lb, i);
                Grid.SetRowSpan(lb, tempstr.Split(']').Length);

                ModelGrid.Children.Add(lb);

                string[] strCondent = tempstr.Split(']');

                if (strCondent.Length < 1)
                {
                    continue;
                }

                Brush[] brushs = new Brush[] { new SolidColorBrush(Color.FromArgb(128, 242, 242, 242)), new SolidColorBrush(Color.FromArgb(255, 00, 00, 00)) };

                for (int j = 0; j < strCondent.Length; j++)
                {
                    if (string.IsNullOrEmpty(strCondent[j]))
                    {
                        continue;
                    }

                    RowDefinition rd1 = new RowDefinition();
                    rd1.Height = new GridLength(20);
                    ModelGrid.RowDefinitions.Add(rd1);

                    Label lb1 = new Label();
                    lb1.BorderThickness   = new Thickness(1, 0, 0, 0);
                    lb1.VerticalAlignment = VerticalAlignment.Center;
                    lb1.FontSize          = 11;
                    //lb1.Background = brushs[0];
                    //lb1.BorderBrush = brushs[1];
                    Grid.SetColumn(lb1, 1);
                    Grid.SetRow(lb1, i);

                    string[] strResult = strCondent[j].Split('@');

                    if (strResult.Length < 2)
                    {
                        continue;
                    }

                    lb1.Content = strResult[0].Replace("[", "");
                    ModelGrid.Children.Add(lb1);

                    Label lb2 = new Label();
                    lb2.BorderThickness   = new Thickness(1, 0, 0, 0);
                    lb2.VerticalAlignment = VerticalAlignment.Center;
                    lb2.FontSize          = 11;
                    //lb2.Background = brushs[0];
                    //lb2.BorderBrush = brushs[1];
                    Grid.SetColumn(lb2, 2);
                    Grid.SetRow(lb2, i);

                    if (strResult[1].IndexOf(";") >= 0)
                    {
                        lb2.Content = "共设置了 " + strResult[1].Split(';').Length + " 个条件";
                    }
                    else
                    {
                        lb2.Content = strResult[1];
                    }

                    ModelGrid.Children.Add(lb2);

                    i++;
                }
            }

            scorllTable.Content = ModelGrid;
        }