示例#1
0
        /// <summary>
        /// 验证短信
        /// </summary>
        /// <param name="code"></param>
        public void SetA2(string text)
        {
            ControlDetailForPage ctobj = this.Tag as ControlDetailForPage;

            if (string.IsNullOrEmpty(_currentType))
            {
                string typecode = ctobj.d5;
                _currentType = typecode.Equals("1") ? smsType.phone.ToString() : smsType.email.ToString();
            }
            var result = _smsController.DealWithSMS(_currentType, _currentPhoneNumber, _currentCode, true);

            if (result.Result)
            {
            }
            else
            {
            }
            //if (cn.DealWithSMS(_currentType, _currentPhoneNumber, _currentCode, true))
            //{
            //    DecoderAssistant.CallEventDerectly(ctobj.p9, this);
            //}
            //else
            //{
            //    DecoderAssistant.CallEventDerectly(ctobj.p12, this);
            //}
            //cn = null;
        }
        public static List <ControlDetailForPage> CastArrayToControl(object[][] objArray)
        {
            List <ControlDetailForPage> controlst = new List <ControlDetailForPage>();

            for (int i = 0; i < objArray.Length; i++)
            {
                ControlDetailForPage obj = new ControlDetailForPage();
                int propertyIndex        = 0;
                //这里使用反射进行转换,但是需要注意的是顺序改变的话可能会出错
                foreach (var prop in obj.GetType().GetFields())
                {
                    if ("Int32".Equals(prop.FieldType.Name))
                    {
                        int value = SetInt(objArray[i][propertyIndex]);
                        prop.SetValue(obj, value);
                    }
                    else
                    {
                        string value = setString(objArray[i][propertyIndex]);
                        prop.SetValue(obj, value);
                    }
                    propertyIndex++;
                }
                controlst.Add(obj);
            }
            return(controlst);
        }
示例#3
0
        /// <summary>
        /// 设置控件的值
        /// 这个是父类的方法,如果是图片控件什么的,需要自己重新重写一下这个方法
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="inControl"></param>
        /// <param name="text"></param>
        public static void SetD0 <T>(this T inControl, object value) where T : IControl
        {
            //更新一下d0的值
            if (value is string)
            {
                ControlDetailForPage obj = (inControl as FrameworkElement).Tag as ControlDetailForPage;
                obj.d0 = value.ToString();
                (inControl as FrameworkElement).Tag = obj;
            }

            if (ExcuteClassMethodByname(inControl, "SetD0", value) == ReturnConst.CancleReturn)
            {
                //if (!object.Equals(value, null))
                //{
                //    //(inControl as FrameworkElement) = value.ToString();
                //}
            }

            //数据获取后执行的事件
            if (!object.Equals(value, null) && !string.IsNullOrEmpty(value.ToString()))
            {
                if (!string.IsNullOrEmpty(((inControl as FrameworkElement).Tag as ControlDetailForPage).p4))
                {
                    EventAssitant.CallEventDerectly(((inControl as FrameworkElement).Tag as ControlDetailForPage).p4, inControl);
                }
            }
        }
        /// <summary>
        /// 初始化控件,由于比较复杂,所以这种情况由控件自身进行初始化
        /// </summary>
        /// <param name="controlObj"></param>
        /// <param name="listControlObj"></param>
        /// <param name="listControl"></param>
        public void InitControl(ControlDetailForPage controlObj, List <ControlDetailForPage> listControlObj, List <IControl> listControl)
        {
            this.Items.Clear();

            List <ControlDetailForPage> listgroups = this.GetParentGroups(listControlObj, controlObj.d17);

            //开始生成控件
            foreach (ControlDetailForPage groupobj in listgroups)
            {
                //生成树节点
                TreeViewItem itemGroup = new TreeViewItem();
                itemGroup.Header = ProduceTreeviewItem(listControlObj, listControl, groupobj);

                //获取该目录下的子节点
                List <ControlDetailForPage> listItems = listControlObj.Where(p => groupobj.ctrl_id.ToString().Equals(p.d13) &&
                                                                             xinLongyuControlType.pcnavigationBarItemType.Equals(p.ctrl_type)).ToList();
                if (object.Equals(listItems, null) || listItems.Count < 1)
                {
                    continue;
                }
                //排序
                listItems = listItems.OrderBy(p => CommonConverter.StringToInt(p.d21)).ToList();

                foreach (ControlDetailForPage itemObj in listItems)
                {
                    TreeViewItem childItem = new TreeViewItem();
                    childItem.Header            = ProduceTreeviewItem(listControlObj, listControl, itemObj);
                    childItem.Tag               = itemObj;
                    childItem.MouseDoubleClick += ChildItem_MouseDoubleClick;
                    itemGroup.Items.Add(childItem);
                }

                this.Items.Add(itemGroup);
            }
        }
        /// <summary>
        /// 获取控件基本信息
        /// </summary>
        /// <param name="pageid"></param>
        /// <returns></returns>
        private List <ControlDetailForPage> GetControlBaseInfo(int pageid)
        {
            string sql = @"select * from hs_new_page_ctrls t where t.page_id = '{0}'";

            sql = string.Format(sql, pageid);
            SQLiteDataReader            reader      = this.ExcuteReader(sql);
            List <ControlDetailForPage> listControl = new List <ControlDetailForPage>();

            while (reader.Read())
            {
                //int index = 0;
                ControlDetailForPage obj = new ControlDetailForPage();
                foreach (var prop in obj.GetType().GetFields())
                {
                    string value = reader[prop.Name].ToString();
                    //这里判断一下类型
                    if ("Boolean".Equals(prop.FieldType.Name))
                    {
                        prop.SetValue(obj, CommonConverter.StringToBool(value));
                    }
                    else if ("Int32".Equals(prop.FieldType.Name))
                    {
                        prop.SetValue(obj, CommonConverter.StringToInt(value));
                    }
                    else
                    {
                        prop.SetValue(obj, value);
                    }
                }
                listControl.Add(obj);
            }
            reader.Close();
            this._connection.Close();
            return(listControl);
        }
        /// <summary>
        /// 上传文件
        /// 将返回路径存储到d0字段中
        /// </summary>
        /// <param name="value"></param>
        public void SetA1(object value)
        {
            ControlDetailForPage obj = (this.Tag as ControlDetailForPage);
            //上传文件
            var values = new[]
            {
                new KeyValuePair <string, string>("api_type", "upload"),
                new KeyValuePair <string, string>("sql", /*obj.d5*/ string.Empty),
                //other values
            };
            OpenFileDialog opf    = new OpenFileDialog();
            string         filter = this.GetFilterType();

            if (!string.IsNullOrEmpty(filter))
            {
                opf.Filter = filter;
            }
            if (opf.ShowDialog() == DialogResult.OK)
            {
                if (IsValidImage(opf.FileName))
                {
                    long  length = new System.IO.FileInfo(opf.FileName).Length;
                    float lef    = length / (1024 * 1024);
                    if (lef > 2.0)
                    {
                        MessageBox.Show("图片大小超过2m!");
                        return;
                    }
                }
                try
                {
                    bool resultbol = false;
                    //if (CommonFunction.IsFinishLoading)
                    //{
                    //    resultbol = true;
                    //    CommonFunction.IsFinishLoading = false;
                    //    CommonFunction.ShowWaitingForm();
                    //}

                    BaseConnection   bcc          = new BaseConnection();
                    var              result       = bcc.PostFile(opf.FileName, values);
                    BaseReturn       brj          = JsonController.DeSerializeToClass <BaseReturn>(result.Result);
                    FileUploadReturn returnResult = JsonController.DeSerializeToClass <FileUploadReturn>(brj.data.ToString());
                    obj.d0   = returnResult.data.path;
                    this.Tag = obj;
                    this.SetP9(obj.p9);
                    //if (resultbol)
                    //{
                    //    CommonFunction.IsFinishLoading = true;
                    //}
                }
                catch
                {
                    //调用失败后走这里
                    this.SetP12(obj.p12);
                }
            }
        }
 /// <summary>
 /// 加载数据
 /// </summary>
 /// <param name="listControlObj"></param>
 /// <param name="gridObj"></param>
 public void LoadData(List <ControlDetailForPage> listControlObj, ControlDetailForPage gridObj, IControl icontrol)
 {
     _CurrentCtObj    = gridObj;
     _currentIControl = icontrol;
     SetDataGridColumns(listControlObj, _CurrentCtObj);
     DealWithPageIndex();
     PageTurning();
     //SetDataSource(gridObj.d0);
 }
 public void SetD0(object value)
 {
     if (!string.IsNullOrEmpty(value.ToString()))
     {
         ControlDetailForPage tag = this.Tag as ControlDetailForPage;
         tag.d0   = value.ToString();
         this.Tag = tag;
     }
 }
示例#9
0
 /// <summary>
 /// 设置D5属性,一般是行高属性
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="inControl"></param>
 /// <param name="text"></param>
 public static void SetD5 <T>(this T inControl, string text) where T : IControl
 {
     if (!object.Equals(text, null))
     {
         ControlDetailForPage ctobj = (inControl as FrameworkElement).Tag as ControlDetailForPage;
         ctobj.d5 = text;
     }
     ExcuteClassMethodByname(inControl, "SetD5", text);
 }
示例#10
0
        /// <summary>
        /// 设置D16属性
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="inControl"></param>
        /// <param name="text"></param>
        public static void SetD16 <T>(this T inControl, string text) where T : IControl
        {
            ControlDetailForPage ctObj = (inControl as FrameworkElement).Tag as ControlDetailForPage;

            ctObj.d16 = text;
            (inControl as FrameworkElement).Tag = ctObj;

            ExcuteClassMethodByname(inControl, "SetD16", text);
        }
示例#11
0
 /// <summary>
 /// 设置控件的事件
 /// </summary>
 public void SetControlEvent(IControl control, ControlDetailForPage controlObj)
 {
     //这里也可以设置成通用的,不过需要对语法进行解析
     //单击事件
     control.SetP0(controlObj.p0);
     //双击事件
     //control.SetP1(controlObj.p1);
     ////设置长按
     //control.SetP2(controlObj.p2);
 }
示例#12
0
        /// <summary>
        /// 生成父控件
        /// </summary>
        public void ProduceFatherControl(ControlDetailForPage controlObj, List <ControlDetailForPage> listControlObj, List <IControl> listControl, UIElement fatherControl, bool isNeedSetRow = false)
        {
            if (controlObj.ctrl_type.Equals(xinLongyuControlType.PCGrid))
            {
                string teset = string.Empty;
            }
            IControl newfatherControl = this.ProductChildControl(controlObj, listControl, fatherControl);

            if (isNeedSetRow)
            {
                (newfatherControl as FrameworkElement).SetValue(Grid.RowProperty, 1);
            }

            //导航栏控件由自身进行初始化
            if (xinLongyuControlType.pcnavigationBarType.Equals(controlObj.ctrl_type))
            {
                //(newfatherControl as xinlongyuNavigationControl).InitControl(controlObj, listControlObj, listControl);
                return;
            }
            //表格控件也由自身进行初始化
            if (xinLongyuControlType.PCGrid.Equals(controlObj.ctrl_type))
            {
                //(newfatherControl as xinlongyuDataGird).LoadMyData(listControlObj, controlObj);
                return;
            }

            //获取子控件列表
            string controlList = _D0FatherControlList.Contains(controlObj.ctrl_type) ? controlObj.d0 : controlObj.d17;

            if (string.IsNullOrEmpty(controlList))
            {
                return;
            }
            List <int> controlIdList = JsonController.DeSerializeToClass <List <int> >(controlList);

            if (object.Equals(controlIdList, null) || controlIdList.Count < 1)
            {
                return;
            }
            //这里对层级进行排序
            List <ControlDetailForPage> childrenList = listControlObj.Where(p => controlIdList.Contains(p.ctrl_id)).OrderBy(p => p.ctrl_level).ToList();

            foreach (ControlDetailForPage ctObj in childrenList)
            {
                //这里使用递归循环生成控件
                if (_fatherControlList.Contains(ctObj.ctrl_type))
                {
                    ProduceFatherControl(ctObj, listControlObj, listControl, newfatherControl as UIElement);
                }
                else
                {
                    this.ProductChildControl(ctObj, listControl, newfatherControl as UIElement);
                }
            }
        }
示例#13
0
        /// <summary>
        /// 设置字体颜色
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="inControl"></param>
        /// <param name="text"></param>
        public static void SetD7 <T>(this T inControl, string text) where T : IControl
        {
            if (!object.Equals(text, null))
            {
                ControlDetailForPage ctobj = (inControl as FrameworkElement).Tag as ControlDetailForPage;
                ctobj.d7 = text;
                ExcuteClassMethodByname(inControl, "SetD7", text);
            }

            //(inControl as UIElement).Foreground = new SolidColorBrush(CommonConverter.ConvertStringToColor(text));
        }
        /// <summary>
        /// 生成节点内容
        /// </summary>
        /// <param name="listControlObj"></param>
        /// <param name="listControl"></param>
        /// <param name="treeviewItemObj"></param>
        /// <returns></returns>
        private UIElement ProduceTreeviewItem(List <ControlDetailForPage> listControlObj, List <IControl> listControl, ControlDetailForPage treeviewItemObj)
        {
            List <int>             listChild      = JsonController.DeSerializeToClass <List <int> >(treeviewItemObj.d17);
            ControlDetailForPage   gridObj        = listControlObj.Where(p => listChild.Contains(p.ctrl_id)).ToList()[0];
            ControlDecoder         controlDecoder = new ControlDecoder();
            xinlongyuParentControl parentControl  = new xinlongyuParentControl();

            controlDecoder.ProduceFatherControl(gridObj, listControlObj, listControl, parentControl);
            parentControl.Width  = 200;
            parentControl.Height = 50;
            return(parentControl);
        }
示例#15
0
        /// <summary>
        /// 获取主值
        /// </summary>
        /// <returns></returns>
        public string GetD0(string text)
        {
            ControlDetailForPage ctObj = this.Tag as ControlDetailForPage;

            if (!string.IsNullOrEmpty(ctObj.d0))
            {
                return(ctObj.d0);
            }
            else
            {
                return(string.Empty);
            }
        }
示例#16
0
        /// <summary>
        /// 显示页面
        /// </summary>
        /// <param name="window"></param>
        /// <param name="pageId"></param>
        /// <param name="listPage"></param>
        /// <param name="parameter">传入的参数字典</param>
        /// <returns></returns>
        public async Task ShowPage(ContentControl window, int pageId, List <Page> listPage, Dictionary <string, string> parameter = null)
        {
            //window.Content = null;
            try
            {
                var page = await ProducePage(pageId);

                if (object.Equals(page, null))
                {
                    page = await GetDefaultPage();
                }
                window.Content = null;
                if (!object.Equals(parameter, null))
                {
                    page.SetParameters(parameter);
                }
                window.Content = page;
                //listPage.Add(page);
                window.Width  = page.Width;
                window.Height = page.Height + ConfigManagerSection.TitleBarHeight;

                //设置页面控件基本属性
                foreach (IControl control in page._currentControlList)
                {
                    ControlDetailForPage controlObj = (control as FrameworkElement).Tag as ControlDetailForPage;
                    _controlDecode.SetControlProperty(control, controlObj);
                }

                //设置控件基本事件
                foreach (IControl control in page._currentControlList)
                {
                    _controlDecode.SetControlEvent(control, (control as FrameworkElement).Tag as ControlDetailForPage);
                }

                //页面初始化事件
                IControl mypageControl = page._currentControlList.First(p => xinLongyuControlType.pageType.Equals(((p as FrameworkElement).Tag as Models.ControlInfo.ControlDetailForPage).ctrl_type));
                var      pageObj       = page._currentControlObjList.First(p => xinLongyuControlType.pageType.Equals(p.ctrl_type));
                mypageControl.SetP7(pageObj.p7);
                //

                if (window.GetType() == typeof(Window))
                {
                    listPage.Add(page);
                    (window as Window).Title = page.Title;
                    (window as Window).Show();
                }
            }
            catch
            {
            }
        }
示例#17
0
        /// <summary>
        /// 设置控件的属性
        /// </summary>
        /// <param name="control"></param>
        /// <param name="controlObj"></param>
        public void SetControlProperty(IControl control, ControlDetailForPage controlObj)
        {
            //宽度
            control.SetD1(controlObj.d1);
            //高度
            control.SetD2(controlObj.d2);
            //坐标
            control.SetD3D4(controlObj.d3, controlObj.d4);
            //主值
            control.SetD0(controlObj.d0);

            //行高属性
            control.SetD5(controlObj.d5);
            //字体大小
            control.SetD6(controlObj.d6);
            //字体颜色
            control.SetD7(controlObj.d7);
            //背景颜色
            control.SetD8(controlObj.d8);
            //字体对齐方式
            control.SetD9(controlObj.d9);
            //
            control.SetD10(controlObj.d10);
            //设置选中时颜色
            control.SetD10(controlObj.d10, controlObj.d11);
            //设置限制长度
            control.SetD11(controlObj.d11);
            //是否自适应高度
            control.SetD12(controlObj.d12);
            //
            control.SetD13(controlObj.d13);
            //
            control.SetD14(controlObj.d14);
            //设置边框颜色
            control.SetD15(controlObj.d15);
            //设置是否密码输入框
            control.SetD16(controlObj.d16);
            //设置可见性
            control.SetD18(controlObj.d18);
            //
            control.SetD19(controlObj.d19);
            //
            control.SetD20(controlObj.d20);
            //
            control.SetD21(controlObj.d21);
            //
            control.SetD25(controlObj.d25);
            //设置是否可以编辑
            control.SetD30(controlObj.d30);
        }
示例#18
0
        /// <summary>
        /// 加载完成事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void XinlongyuVideoUploader_DocumentCompleted(object sender, NavigationEventArgs e)
        {
            string api = "https://icityservice.cn/uploadVideo.html";

            if (_currentBrowserMode == browserMode.result && !MyWebBrowse.Source.AbsoluteUri.Equals(api))
            {
                //CommonFunction.IsFinishLoading = true;
                string success             = "icity://uploadvideo/?code=1";
                string failure             = "icity://uploadVidel/?code=0";
                ControlDetailForPage ctObj = this.Tag as ControlDetailForPage;
                if ((MyWebBrowse.Source.AbsoluteUri.ToString().StartsWith(success)))
                {
                    ctObj.d0 = MyWebBrowse.Source.AbsoluteUri.ToString().Replace("icity://uploadvideo/?code=1&id=", string.Empty); //保存视频ID
                    this.Tag = ctObj;
                    //DecoderAssistant.CallEventDerectly(ctObj.p9, this);
                }
                else if (MyWebBrowse.Source.AbsoluteUri.ToString().StartsWith(failure))
                {
                    //DecoderAssistant.CallEventDerectly(ctObj.p12, this);
                }
                MyWebBrowse.Navigate(api);
                _currentBrowserMode = browserMode.normal;
            }
            else if (_currentBrowserMode == browserMode.start)
            {
                try
                {
                    //使用的mshtml空间下的控件,不知道有没有效果
                    var document = MyWebBrowse.Document as mshtml.HTMLDocument;
                    var script   = document.createElement("script");
                    script.setAttribute("type", "text/javascript");
                    _isAppended = true;
                    script.setAttribute("text", "function _func(){$('#uploadVideoNow-file').click();}");
                    var head = document.body.children(script);
                    MyWebBrowse.InvokeScript("_func");
                    this._currentBrowserMode = browserMode.result;

                    //if (CommonFunction.IsFinishLoading)
                    //{
                    //    CommonFunction.IsFinishLoading = false;
                    //    CommonFunction.ShowWaitingForm();
                    //}
                }
                catch (System.Exception ex)
                {
                    string error = ex.Message;
                }
            }
        }
        /// <summary>
        /// 获取对应控件的模板
        /// </summary>
        /// <param name="ctrlType"></param>
        /// <param name="propertyName"></param>
        /// <returns></returns>
        private FrameworkElementFactory GetFrameworkElement(string propertyName, ControlDetailForPage ctObj)
        {
            FrameworkElementFactory fac;

            if (xinLongyuControlType.textType.Equals(ctObj.ctrl_type))
            {
                fac = new FrameworkElementFactory(typeof(TextBlock));
                fac.SetValue(TextBlock.TextWrappingProperty, TextWrapping.Wrap);
                fac.SetBinding(TextBlock.TextProperty, new Binding(propertyName));
            }
            else if (xinLongyuControlType.buttonType.Equals(ctObj.ctrl_type))
            {
                fac = new FrameworkElementFactory(typeof(Button));
                fac.SetValue(Button.ContentProperty, ctObj.d0);
                fac.SetValue(FrameworkElement.StyleProperty, (Style)FindResource("ButtonWithRoundedCorner"));
                //之后还要设置一下事件
                //fac.AddHandler(Button.ClickEvent, new EventHandler(fac, SomeHandler));
            }
            else if (xinLongyuControlType.imgType.Equals(ctObj.ctrl_type))
            {
                fac = new FrameworkElementFactory(typeof(Image));
                fac.SetBinding(Image.SourceProperty, new Binding(propertyName)
                {
                    Converter = new StringToBitmapImageConverter(), UpdateSourceTrigger = UpdateSourceTrigger.Explicit
                });
            }
            //默认使用textblock
            else
            {
                fac = new FrameworkElementFactory(typeof(TextBlock));
                fac.SetBinding(TextBlock.TextProperty, new Binding(propertyName));
            }
            fac.SetValue(VerticalAlignmentProperty, VerticalAlignment.Top);
            fac.SetValue(HorizontalAlignmentProperty, HorizontalAlignment.Left);
            fac.SetValue(MarginProperty, new Thickness(ctObj.d3, ctObj.d4, 0, 0));
            fac.SetValue(WidthProperty, (double)ctObj.d1);
            fac.SetValue(HeightProperty, (double)ctObj.d2);
            if (!string.IsNullOrEmpty(ctObj.d8))
            {
                fac.SetValue(BackgroundProperty, (System.Windows.Media.Brush)(new System.Windows.Media.BrushConverter().ConvertFromString(ctObj.d8)));
            }
            if (!string.IsNullOrEmpty(ctObj.d7))
            {
                fac.SetValue(ForegroundProperty, (System.Windows.Media.Brush)(new System.Windows.Media.BrushConverter().ConvertFromString(ctObj.d7)));
            }


            return(fac);
        }
示例#20
0
 /// <summary>
 /// 启动控件
 /// </summary>
 /// <param name="text"></param>
 public void SetA1(string text)
 {
     if (!object.Equals(_allFiles, null) && _allFiles.Count > 0)
     {
         try
         {
             ControlDetailForPage obj = (this.Tag as ControlDetailForPage);
             //上传文件
             var values = new[]
             {
                 new KeyValuePair <string, string>("api_type", "upload"),
                 new KeyValuePair <string, string>("sql", string.Empty),
             };
             SqlController slcontroller = new SqlController();
             string        sqlInsert    = obj.d5;
             //sqlInsert = DecoderAssistant.FormatSql(sqlInsert, this);
             //bool resultbol = false;
             //if (CommonFunction.IsFinishLoading)
             //{
             //    resultbol = true;
             //    CommonFunction.IsFinishLoading = false;
             //    CommonFunction.ShowWaitingForm();
             //}
             //改为传相对路径
             foreach (string file in _allFiles)
             {
                 var              result       = slcontroller.PostFile(file, values);
                 BaseReturn       brj          = JsonController.DeSerializeToClass <BaseReturn>(result.Result);
                 FileUploadReturn returnResult = JsonController.DeSerializeToClass <FileUploadReturn>(brj.data.ToString());
                 string           fileUrl      = returnResult.data.path;
                 string           filename     = this.GetRelativePath(file, _folderPath);;
                 string           fileName     = @"\" + @filename;
                 fileName = fileName.Replace("\\", "\\\\");
                 slcontroller.ExcuteSqlWithReturn(string.Format(sqlInsert, fileUrl, fileName));
             }
             //if (resultbol)
             //{
             //    CommonFunction.IsFinishLoading = true;
             //}
             this.SetP9(obj.p9);
         }
         catch
         {
             this.SetP9((this.Tag as ControlDetailForPage).p12);
         }
     }
 }
示例#21
0
        /// <summary>
        /// 设置控件是否接收事件
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="inControl"></param>
        /// <param name="text"></param>
        public static void SetD30 <T>(this T inControl, string text) where T : IControl
        {
            ControlDetailForPage ctObj = (inControl as FrameworkElement).Tag as ControlDetailForPage;

            ctObj.d30 = text;
            (inControl as FrameworkElement).Tag = ctObj;

            if ("0".Equals(text.Trim()))
            {
                (inControl as FrameworkElement).IsEnabled = false;
            }
            else
            {
                (inControl as FrameworkElement).IsEnabled = true;
            }
            ExcuteClassMethodByname(inControl, "SetD30", text);
        }
        /// <summary>
        /// 设置主值
        /// </summary>
        /// <param name="value"></param>
        public void SetD0(object value)
        {
            listItems.Clear();
            if (object.Equals(value, null) || string.IsNullOrEmpty(value.ToString()))
            {
                return;
            }
            ControlDetailForPage currentObj = this.Tag as ControlDetailForPage;
            //获取页面ID数组,默认全都要设置所以这里不进行判断
            List <int> listPageId = JsonController.DeSerializeToClass <List <int> >(currentObj.d11);

            //判断是数组还是sql
            if (System.Text.RegularExpressions.Regex.IsMatch(value.ToString().Replace("\r\n", string.Empty), @".*\[.*\].*"))
            {
                List <string> listImage = JsonController.DeSerializeToClass <List <string> >(value.ToString());
                for (int i = 0; i < listPageId.Count; i++)
                {
                    listItems.Add(new FlipViewItem()
                    {
                        ImageUrl = listImage[i], pageId = listPageId[i]
                    });
                }
            }
            else
            {
                //sql处理
                SqlController cn = new SqlController();
                value = EventAssitant.FormatSql(value.ToString(), this);
                var returnDic = cn.ExcuteSqlWithReturn(value.ToString().Trim());
                var result    = returnDic.data;
                if (!object.Equals(result, null) && result.Length > 0)
                {
                    int index = 0;
                    foreach (Dictionary <string, string> dic in result)
                    {
                        listItems.Add(new FlipViewItem()
                        {
                            ImageUrl = dic[currentObj.d19], pageId = listPageId[index]
                        });
                        index++;
                    }
                }
            }
            MyFlipView.ItemsSource = null;
            MyFlipView.ItemsSource = listItems;
        }
示例#23
0
        /// <summary>
        /// 生成子控件
        /// </summary>
        private IControl ProductChildControl(ControlDetailForPage controlObj, List <IControl> listControl, UIElement fatherControl)
        {
            IControl control = this.GetIControl(controlObj);

            if (object.Equals(control, null))
            {
                return(null);
            }
            listControl.Add(control);

            #region 判断类型
            if (fatherControl.GetType() == typeof(Page))
            {
                (fatherControl as Page).Content = control as UIElement;
            }
            else if (fatherControl.GetType() == typeof(xinlongyuParentControl))
            {
                (fatherControl as Grid).Children.Add(control as UIElement);
            }
            else if (fatherControl.GetType() == typeof(ScrollViewer))
            {
                (fatherControl as ScrollViewer).Content = control as UIElement;
            }
            else if (fatherControl.GetType() == typeof(xinlongyuNavigationControl))
            {
                (fatherControl as TreeView).Items.Add(control as UIElement);
            }
            else if (fatherControl.GetType() == typeof(xinlongyuNavigationItem))
            {
                (fatherControl as TreeViewItem).Header = control as UIElement;
            }
            //else if (fatherControl.GetType() == typeof(StackPanel))
            //{
            //    (fatherControl as StackPanel).Children.Add(control as UIElement);
            //}
            else
            {
                (fatherControl as Grid).Children.Add(control as UIElement);
            }
            #endregion

            return(control);
        }
        /// <summary>
        /// 设置表格的列
        /// </summary>
        /// <param name="listControlObj"></param>
        /// <param name="gridObj"></param>
        private void SetDataGridColumns(List <ControlDetailForPage> listControlObj, ControlDetailForPage gridObj)
        {
            mydatagridview.Columns.Clear();
            //获取所有的列
            List <int> listChildId = JsonController.DeSerializeToClass <List <int> >(gridObj.d17);
            List <ControlDetailForPage> listAllColumns = listControlObj.Where(p => listChildId.Contains(p.ctrl_id) &&
                                                                              xinLongyuControlType.GridColumnName.Equals(p.ctrl_type))
                                                         .OrderBy(p => CommonConverter.StringToInt(p.d21)).ToList();
            //获取键值对应字典
            Dictionary <int, string> ctrlIdToColumnName = this.GetDicCtrlToColumn(gridObj.d22);

            //生成列类型
            foreach (ControlDetailForPage ctObj in listAllColumns)
            {
                DataGridColumn column = GetDataGridColumn(ctObj, ctrlIdToColumnName, listControlObj);
                column.Header = ctObj.d0;
                mydatagridview.Columns.Add(column);
            }
            //设置行高
            mydatagridview.RowHeight = CommonConverter.StringToInt(gridObj.d19);
        }
        /// <summary>
        /// 获取对应的列
        /// </summary>
        /// <returns></returns>
        private DataGridColumn GetDataGridColumn(ControlDetailForPage ctObj, Dictionary <int, string> ctrlIdToColumnName, List <ControlDetailForPage> listControlObj)
        {
            List <int> listChild = JsonController.DeSerializeToClass <List <int> >(ctObj.d17);
            List <ControlDetailForPage> listAllChild = listControlObj.Where(p => listChild.Contains(p.ctrl_id)).ToList();
            DataGridTemplateColumn      tcolumn      = new DataGridTemplateColumn();
            DataTemplate template = new DataTemplate();

            template.DataType = typeof(ObjectHelperForDataGrid);

            if (listAllChild.Count > 1)
            {
                FrameworkElementFactory factory = new FrameworkElementFactory(typeof(Grid));
                factory.SetValue(VerticalAlignmentProperty, VerticalAlignment.Stretch);
                factory.SetValue(HorizontalAlignmentProperty, HorizontalAlignment.Stretch);
                foreach (ControlDetailForPage obj in listAllChild)
                {
                    if (ctrlIdToColumnName.ContainsKey(obj.ctrl_id))
                    {
                        factory.AppendChild(GetFrameworkElement(_propertyNameToColumnName[ctrlIdToColumnName[obj.ctrl_id]], obj));
                    }
                    else
                    {
                        factory.AppendChild(GetFrameworkElement(string.Empty, obj));
                    }
                }
                template.VisualTree = factory;
            }
            else
            {
                string propertyName                  = ctrlIdToColumnName.ContainsKey(listAllChild[0].ctrl_id)? _propertyNameToColumnName[ctrlIdToColumnName[listAllChild[0].ctrl_id]] : string.Empty;
                FrameworkElementFactory factory      = new FrameworkElementFactory(typeof(Grid));
                FrameworkElementFactory factorychild = GetFrameworkElement(propertyName, listAllChild[0]);
                factorychild.SetValue(VerticalAlignmentProperty, VerticalAlignment.Stretch);
                factorychild.SetValue(HorizontalAlignmentProperty, HorizontalAlignment.Stretch);
                factory.AppendChild(factorychild);
                template.VisualTree = factory;
            }
            tcolumn.CellTemplate = template;
            return(tcolumn);
        }
示例#26
0
 /// <summary>
 /// 设置字体大小
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="inControl"></param>
 /// <param name="text"></param>
 public static void SetD6 <T>(this T inControl, string text) where T : IControl
 {
     if (!object.Equals(text, null))
     {
         ControlDetailForPage ctobj = (inControl as FrameworkElement).Tag as ControlDetailForPage;
         ctobj.d6 = text;
     }
     //这里增加一个判断流程是为了兼容字体样式之前的版本,防止需要全部回去修改配置
     if (!string.IsNullOrEmpty(text))
     {
         try
         {
             if (!string.IsNullOrEmpty(text) && CommonConverter.StringToInt(text) == -1)
             {
                 ExcuteClassMethodByname(inControl, "SetD6", text);
             }
         }
         catch
         { }
         //if (ExcuteClassMethodByname(inControl, "SetD6", text) == ReturnConst.CancleReturn)
         //{
         //}
     }
 }
示例#27
0
        /// <summary>
        /// 解析控件为界面控件
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public xinlongyuForm ProduceControl(ControlDetailForPage pageobj, List <IControl> listControl, List <ControlDetailForPage> listControlObj, bool isNavigationWindow)
        {
            xinlongyuParentControl _currentForm = new xinlongyuParentControl();

            AddTitleBar(_currentForm, pageobj, isNavigationWindow);
            if (_fatherControlList.Contains(pageobj.ctrl_type))
            {
                this.ProduceFatherControl(pageobj, listControlObj, listControl, _currentForm, true);
            }
            else
            {
                return(null);
            }


            _currentForm.HorizontalAlignment = HorizontalAlignment.Stretch;
            _currentForm.VerticalAlignment   = VerticalAlignment.Stretch;
            //_currentForm.Margin = new Thickness(10);


            //实现窗体的滚动条
            //ScrollViewer scrollView = new ScrollViewer();
            ////scrollView.HorizontalAlignment = HorizontalAlignment.Stretch;
            ////scrollView.VerticalAlignment = VerticalAlignment.Stretch;
            //scrollView.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            //scrollView.Content = _currentForm;

            xinlongyuForm page = new xinlongyuForm(pageobj.page_id);

            page.Content = _currentForm;
            page.Width   = pageobj.d1;
            page.Height  = pageobj.d2;

            //返回page
            return(page);
        }
示例#28
0
        /// <summary>
        /// 解析页面控件
        /// </summary>
        /// <param name="frm"></param>
        /// <param name="listControlObject"></param>
        private xinlongyuForm DecodeListControlObj(List <ControlDetailForPage> listControlObject, bool isNavigationWindow)
        {
            int pageIndex = listControlObject.FindIndex(p => xinLongyuControlType.pageType.Equals(p.ctrl_type));

            if (pageIndex == -1)
            {
                throw new Exception("页面缺少主要控件");
            }
            listControlObject[pageIndex].d18 = "1";//这里是防止页面控件为隐性
            ControlDetailForPage pageControl = listControlObject[pageIndex];

            if (string.IsNullOrEmpty(pageControl.d0))
            {
                //一个控件都没有就退出解析过程
                return(null);
            }
            //界面控件数组
            List <IControl> listControl = new List <IControl>();
            var             page        = _controlDecode.ProduceControl(pageControl, listControl, listControlObject, isNavigationWindow);

            page._currentControlList    = listControl;
            page._currentControlObjList = listControlObject;
            return(page);
        }
        /// <summary>
        /// 设置显示
        /// </summary>
        /// <param name="value"></param>
        public void SetD0(object value)
        {
            this.Items.Clear();
            _listValue.Clear();

            if (!object.Equals(value, null))
            {
                if (value is string)
                {
                    if (!string.IsNullOrEmpty(value.ToString()))
                    {
                        ControlDetailForPage currentObj = this.Tag as ControlDetailForPage;
                        //数组处理

                        if (System.Text.RegularExpressions.Regex.IsMatch(value.ToString().Replace("\r\n", string.Empty), @".*\[.*\].*"))
                        {
                            string[] array = new string[1];
                            try
                            {
                                array = JsonController.DeSerializeToClass <string[]>(value.ToString().Replace("\r\n", string.Empty));
                            }
                            catch
                            {
                                array = JsonController.DeSerializeToClass <string[]>(value.ToString());
                            }
                            this.ItemsSource = array;
                            if (System.Text.RegularExpressions.Regex.IsMatch(currentObj.d5.Trim().Replace("\r\n", string.Empty), @".*\[.*\].*"))
                            {
                                _listValue.AddRange(JsonController.DeSerializeToClass <string[]>(currentObj.d5.Trim()));
                            }
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(currentObj.d19) || string.IsNullOrEmpty(currentObj.d20))
                            {
                                return;
                            }
                            //sql处理
                            SqlController cn = new SqlController();
                            value = EventAssitant.FormatSql(value.ToString(), this);
                            var returnDic = cn.ExcuteSqlWithReturn(value.ToString().Trim());
                            var result    = returnDic.data;
                            if (!object.Equals(result, null) && result.Length > 0)
                            {
                                foreach (Dictionary <string, string> dic in result)
                                {
                                    this.Items.Add(dic[currentObj.d20]);
                                    _listValue.Add(dic[currentObj.d19]);
                                }
                            }
                        }
                        if (this.Items.Count > 0)
                        {
                            this.SelectedIndex = 0;
                        }
                    }
                }
                else
                {
                    //这里应该是用于.语法调用处理的时候进行处理,就是传进来的
                }
            }
        }
示例#30
0
        /// <summary>
        /// 主值
        /// </summary>
        /// <param name="text"></param>
        public void SetD0(object value)
        {
            checkListItems.Clear();
            MyListBox.ItemsSource = null;

            if (!object.Equals(value, null))
            {
                if (value is string)
                {
                    if (!string.IsNullOrEmpty(value.ToString()))
                    {
                        ControlDetailForPage currentObj = this.Tag as ControlDetailForPage;
                        //数组处理

                        if (System.Text.RegularExpressions.Regex.IsMatch(value.ToString().Replace("\r\n", string.Empty), @".*\[.*\].*"))
                        {
                            List <string> listArray = JsonController.DeSerializeToClass <List <string> >(value.ToString().Replace("\r\n", string.Empty));
                            //判断是否需要显示与值分开
                            if (!string.IsNullOrEmpty(currentObj.d11))
                            {
                                List <string> listValue = JsonController.DeSerializeToClass <List <string> >(currentObj.d11);
                                for (int i = 0; i < listArray.Count; i++)
                                {
                                    checkListItems.Add(new CheckBoxListItem()
                                    {
                                        DisPlayValue = listArray[i], ActualValue = listValue [i]
                                    });
                                }
                            }
                            else
                            {
                                listArray.AsParallel().ForAll(p => checkListItems.Add(new CheckBoxListItem()
                                {
                                    ActualValue = p, DisPlayValue = p
                                }));
                            }
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(currentObj.d19) || string.IsNullOrEmpty(currentObj.d20))
                            {
                                return;
                            }
                            //sql处理
                            SqlController cn = new SqlController();
                            value = EventAssitant.FormatSql(value.ToString(), this);
                            var returnDic = cn.ExcuteSqlWithReturn(value.ToString().Trim());
                            var result    = returnDic.data;
                            if (!object.Equals(result, null) && result.Length > 0)
                            {
                                foreach (Dictionary <string, string> dic in result)
                                {
                                    checkListItems.Add(new CheckBoxListItem()
                                    {
                                        ActualValue = dic[currentObj.d19], DisPlayValue = dic[currentObj.d20]
                                    });
                                }
                            }
                        }
                    }
                    if (!object.Equals(checkListItems, null))
                    {
                        MyListBox.ItemsSource = checkListItems;
                    }
                }
            }
        }