/*
  * 移动层次
  */
 public void moveUpIdx(DControl dControl, DControl eleDControl)
 {
     update(dControl);
     update(eleDControl);
 }
Ejemplo n.º 2
0
        //
        private void Submit_Button_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(width.Text))
            {
                MessageBox.Show("请填写宽度;"); return;
            }
            else if (!DataUtil.isInt(width.Text.ToString()))
            {
                MessageBox.Show("宽度必须是整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(height.Text.ToString()))
            {
                MessageBox.Show("请填写高度;"); return;
            }
            else if (!DataUtil.isInt(height.Text.ToString()))
            {
                MessageBox.Show("高度必须是整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(left.Text.ToString()))
            {
                MessageBox.Show("请填写左边距;"); return;
            }
            else if (!DataUtil.isInt(left.Text.ToString()))
            {
                MessageBox.Show("左边距请填写整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(top.Text.ToString()))
            {
                MessageBox.Show("请填写上边距;"); return;
            }
            else if (!DataUtil.isInt(top.Text.ToString()))
            {
                MessageBox.Show("上边距请填写整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(opacity.Text.ToString()))
            {
                MessageBox.Show("请填写透明度;"); return;
            }
            else if (!DataUtil.isInt(opacity.Text.ToString()))
            {
                MessageBox.Show("透明度请填写整数;"); return;
            }
            else
            {
                Int32 opacityVal = Convert.ToInt32(opacity.Text.ToString());
                if (opacityVal < 0 || opacityVal > 100)
                {
                    MessageBox.Show("透明度为0-100内的整数;"); return;
                }
            }


            //更新到数据库
            DControl dControl = dControlBll.get(currDControl.id);

            dControl.width   = int.Parse(width.Text);
            dControl.height  = int.Parse(height.Text);
            dControl.left    = int.Parse(left.Text);
            dControl.top     = int.Parse(top.Text);
            dControl.opacity = int.Parse(opacity.Text);
            dControlBll.update(dControl);
            currDControl    = dControl;
            currElement.Tag = currDControl;

            //更新页面控件信息
            TextBox textBox = (TextBox)currElement;

            textBox.Width   = currDControl.width;
            textBox.Height  = currDControl.height;
            textBox.Margin  = new Thickness(currDControl.left, currDControl.top, 0, 0);
            textBox.Opacity = currDControl.opacity / 100.0;

            editing.updateEditingBorder(dControl);
            Close();
        }
        //
        private void Submit_Button_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(width.Text))
            {
                MessageBox.Show("请填写宽度;"); return;
            }
            else if (!DataUtil.isInt(width.Text.ToString()))
            {
                MessageBox.Show("宽度必须是整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(height.Text.ToString()))
            {
                MessageBox.Show("请填写高度;"); return;
            }
            else if (!DataUtil.isInt(height.Text.ToString()))
            {
                MessageBox.Show("高度必须是整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(left.Text.ToString()))
            {
                MessageBox.Show("请填写左边距;"); return;
            }
            else if (!DataUtil.isInt(left.Text.ToString()))
            {
                MessageBox.Show("左边距请填写整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(top.Text.ToString()))
            {
                MessageBox.Show("请填写上边距;"); return;
            }
            else if (!DataUtil.isInt(top.Text.ToString()))
            {
                MessageBox.Show("上边距请填写整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(opacity.Text.ToString()))
            {
                MessageBox.Show("请填写透明度;"); return;
            }
            else if (!DataUtil.isInt(opacity.Text.ToString()))
            {
                MessageBox.Show("透明度请填写整数;"); return;
            }
            else
            {
                Int32 opacityVal = Convert.ToInt32(opacity.Text.ToString());
                if (opacityVal < 0 || opacityVal > 100)
                {
                    MessageBox.Show("透明度为0-100内的整数;"); return;
                }
            }
            StorageImage storageImage = null;
            object       tag          = storageIdOfCover.Tag;

            if (tag != null)
            {
                storageImage = (StorageImage)tag;
            }

            //更新到数据库
            DControl dControl = dControlBll.get(currDControl.id);

            //  dControl.url = url.Text;
            dControl.width            = int.Parse(width.Text);
            dControl.height           = int.Parse(height.Text);
            dControl.left             = int.Parse(left.Text);
            dControl.top              = int.Parse(top.Text);
            dControl.opacity          = int.Parse(opacity.Text);
            dControl.autoplay         = (Boolean)autoplay.IsChecked;
            dControl.loop             = (Boolean)loop.IsChecked;
            dControl.storageIdOfCover = (storageImage == null ? 0 : storageImage.id);
            dControlBll.update(dControl);
            currDControl    = dControl;
            currElement.Tag = currDControl;


            //更新页面控件信息
            string audioCoverUrl = Params.CAudioImageNotExists;

            if (currDControl.storageIdOfCover > 0)
            {
                StorageImage storageImage1 = storageImageBll.get(currDControl.storageIdOfCover);
                audioCoverUrl = storageImage1?.url;
            }
            CAudio cAudio = (CAudio)currElement;

            cAudio.updateElementAttr(dControl, audioCoverUrl, true);

            //2.修改8个点的位置 及宽高
            editing.updateEditingBorder(currDControl);

            Close();
        }
        //
        private void Submit_Button_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(width.Text))
            {
                MessageBox.Show("请填写宽度;"); return;
            }
            else if (!DataUtil.isInt(width.Text.ToString()))
            {
                MessageBox.Show("宽度必须是整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(height.Text.ToString()))
            {
                MessageBox.Show("请填写高度;"); return;
            }
            else if (!DataUtil.isInt(height.Text.ToString()))
            {
                MessageBox.Show("高度必须是整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(left.Text.ToString()))
            {
                MessageBox.Show("请填写左边距;"); return;
            }
            else if (!DataUtil.isInt(left.Text.ToString()))
            {
                MessageBox.Show("左边距请填写整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(top.Text.ToString()))
            {
                MessageBox.Show("请填写上边距;"); return;
            }
            else if (!DataUtil.isInt(top.Text.ToString()))
            {
                MessageBox.Show("上边距请填写整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(opacity.Text.ToString()))
            {
                MessageBox.Show("请填写透明度;"); return;
            }
            else if (!DataUtil.isInt(opacity.Text.ToString()))
            {
                MessageBox.Show("透明度请填写整数;"); return;
            }
            else
            {
                Int32 opacityVal = Convert.ToInt32(opacity.Text.ToString());
                if (opacityVal < 0 || opacityVal > 100)
                {
                    MessageBox.Show("透明度为0-100内的整数;"); return;
                }
            }


            //更新到数据库
            DControl dControl = dControlBll.get(currDControl.id);

            //  dControl.url = url.Text;
            dControl.width   = int.Parse(width.Text);
            dControl.height  = int.Parse(height.Text);
            dControl.left    = int.Parse(left.Text);
            dControl.top     = int.Parse(top.Text);
            dControl.opacity = int.Parse(opacity.Text);
            dControlBll.update(dControl);
            currDControl    = dControl;
            currElement.Tag = currDControl;


            //更新页面控件信息,更新isClickShow
            //CWord cWord = (CWord)currElement;
            //cWord.Width = currDControl.width;
            //cWord.Height = currDControl.height;
            //cWord.Margin = new Thickness(currDControl.left,currDControl.top,0,0);
            //cWord.fitToWidth();

            DocumentViewer docViewer = (DocumentViewer)currElement;

            docViewer.Width   = dControl.width;
            docViewer.Height  = dControl.height;
            docViewer.Margin  = new Thickness(dControl.left, dControl.top, 0, 0);
            docViewer.Opacity = dControl.opacity / 100.0;
            docViewer.FitToWidth();

            //2.修改8个点的位置 及宽高
            editing.updateEditingBorder(currDControl);


            Close();
        }
Ejemplo n.º 5
0
        /*
         * 添加一个控件
         */
        public DControl insert(DControl entity)
        {
            String sql = "insert into dControl(pageId,name,content,width,height,left,top,type,idx,linkToPageId,isClickShow,linkToVideoId,autoplay,loop,turnPictureSpeed,linkToWeb,storageId,isShowTurnPictureArrow,opacity,parentId,contentWidth,contentHeight,backgroundImageId,isTab,rowNum,spacing,rotateAngle,isDialogLink,showInWhichCFrame,isTransparentDialog,fontFamily,fontSize,fontLineHeight,fontColor,fontWeight,fontTextAlignment,storageIdOfCover,screenCfgId,isHideVideoConsoleOfFirstLoad) ";

            sql = sql + " values(@pageId,@name,@content,@width,@height,@left,@top,@type,@idx,@linkToPageId,@isClickShow,@linkToVideoId,@autoplay,@loop,@turnPictureSpeed,@linkToWeb,@storageId,@isShowTurnPictureArrow,@opacity,@parentId,@contentWidth,@contentHeight,@backgroundImageId,@isTab,@rowNum,@spacing,@rotateAngle,@isDialogLink,@showInWhichCFrame,@isTransparentDialog,@fontFamily,@fontSize,@fontLineHeight,@fontColor,@fontWeight,@fontTextAlignment,@storageIdOfCover,@screenCfgId,@isHideVideoConsoleOfFirstLoad);select last_insert_rowid();";
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@pageId",                        DbType.Int32,     4),
                new SQLiteParameter("@name",                          DbType.String,   30),
                new SQLiteParameter("@content",                       DbType.String, 4000),
                new SQLiteParameter("@width",                         DbType.Int32,     4),
                new SQLiteParameter("@height",                        DbType.Int32,     4),
                new SQLiteParameter("@left",                          DbType.Int32,     4),
                new SQLiteParameter("@top",                           DbType.Int32,     4),
                new SQLiteParameter("@type",                          DbType.String,   30),
                //new SQLiteParameter("@url", DbType.String,255),
                //new SQLiteParameter("@imgs", DbType.String,4000),
                new SQLiteParameter("@idx",                           DbType.Int32,     4),
                new SQLiteParameter("@linkToPageId",                  DbType.Int32,     4),
                new SQLiteParameter("@isClickShow",                   DbType.Int32,     4),
                new SQLiteParameter("@linkToVideoId",                 DbType.Int32,     4),
                new SQLiteParameter("@autoplay",                      DbType.Int32,     4),
                new SQLiteParameter("@loop",                          DbType.Int32,     4),
                new SQLiteParameter("@turnPictureSpeed",              DbType.Int32,     4),
                new SQLiteParameter("@linkToWeb",                     DbType.String,  255),
                new SQLiteParameter("@storageId",                     DbType.Int32,     4),
                new SQLiteParameter("@isShowTurnPictureArrow",        DbType.Int32,     4),
                new SQLiteParameter("@opacity",                       DbType.Int32,     4),
                new SQLiteParameter("@parentId",                      DbType.Int32,     4),
                new SQLiteParameter("@contentWidth",                  DbType.Int32,     4),
                new SQLiteParameter("@contentHeight",                 DbType.Int32,     4),
                new SQLiteParameter("@backgroundImageId",             DbType.Int32,     4),
                new SQLiteParameter("@isTab",                         DbType.Int32,     4),
                new SQLiteParameter("@rowNum",                        DbType.Int32,     4),
                new SQLiteParameter("@spacing",                       DbType.Int32,     4),
                new SQLiteParameter("@rotateAngle",                   DbType.Int32,     4),
                new SQLiteParameter("@isDialogLink",                  DbType.Int32,     4),
                new SQLiteParameter("@showInWhichCFrame",             DbType.Int32,     4),
                new SQLiteParameter("@isTransparentDialog",           DbType.Int32,     4),
                new SQLiteParameter("@fontFamily",                    DbType.String,   30),
                new SQLiteParameter("@fontSize",                      DbType.Int32,     4),
                new SQLiteParameter("@fontLineHeight",                DbType.Int32,     4),
                new SQLiteParameter("@fontColor",                     DbType.String,   30),
                new SQLiteParameter("@fontWeight",                    DbType.String,   30),
                new SQLiteParameter("@fontTextAlignment",             DbType.Int32,     4),
                new SQLiteParameter("@storageIdOfCover",              DbType.Int32,     4),
                new SQLiteParameter("@screenCfgId",                   DbType.Int32,     4),
                new SQLiteParameter("@isHideVideoConsoleOfFirstLoad", DbType.Int32, 4)
            };
            parameters[0].Value  = entity.pageId;
            parameters[1].Value  = entity.name;
            parameters[2].Value  = entity.content;
            parameters[3].Value  = entity.width;
            parameters[4].Value  = entity.height;
            parameters[5].Value  = entity.left;
            parameters[6].Value  = entity.top;
            parameters[7].Value  = entity.type;
            parameters[8].Value  = entity.idx;
            parameters[9].Value  = entity.linkToPageId;
            parameters[10].Value = entity.isClickShow;
            parameters[11].Value = entity.linkToVideoId;
            parameters[12].Value = entity.autoplay;
            parameters[13].Value = entity.loop;
            parameters[14].Value = entity.turnPictureSpeed;
            parameters[15].Value = entity.linkToWeb;
            parameters[16].Value = entity.storageId;
            parameters[17].Value = entity.isShowTurnPictureArrow;
            parameters[18].Value = entity.opacity;

            parameters[19].Value = entity.parentId;
            parameters[20].Value = entity.contentWidth;
            parameters[21].Value = entity.contentHeight;
            parameters[22].Value = entity.backgroundImageId;
            parameters[23].Value = entity.isTab;
            parameters[24].Value = entity.rowNum;
            parameters[25].Value = entity.spacing;
            parameters[26].Value = entity.rotateAngle;
            parameters[27].Value = entity.isDialogLink;
            parameters[28].Value = entity.showInWhichCFrame;
            parameters[29].Value = entity.isTransparentDialog;

            parameters[30].Value = entity.fontFamily;
            parameters[31].Value = entity.fontSize;
            parameters[32].Value = entity.fontLineHeight;
            parameters[33].Value = entity.fontColor;
            parameters[34].Value = entity.fontWeight;
            parameters[35].Value = entity.fontTextAlignment;
            parameters[36].Value = entity.storageIdOfCover;
            parameters[37].Value = entity.screenCfgId;
            parameters[38].Value = entity.isHideVideoConsoleOfFirstLoad;

            DataTable dt = Common.SQLiteHelper.ExecuteQuery(sql, parameters);
            int       id = DataType.ToInt32(dt.Rows[0]["last_insert_rowid()"].ToString());

            entity.id = id;
            return(entity);
        }
        //
        private void Submit_Button_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(width.Text))
            {
                MessageBox.Show("请填写宽度;"); return;
            }
            else if (!DataUtil.isInt(width.Text.ToString()))
            {
                MessageBox.Show("宽度必须是整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(height.Text.ToString()))
            {
                MessageBox.Show("请填写高度;"); return;
            }
            else if (!DataUtil.isInt(height.Text.ToString()))
            {
                MessageBox.Show("高度必须是整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(left.Text.ToString()))
            {
                MessageBox.Show("请填写左边距;"); return;
            }
            else if (!DataUtil.isInt(left.Text.ToString()))
            {
                MessageBox.Show("左边距请填写整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(top.Text.ToString()))
            {
                MessageBox.Show("请填写上边距;"); return;
            }
            else if (!DataUtil.isInt(top.Text.ToString()))
            {
                MessageBox.Show("上边距请填写整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(turnPictureSpeed.Text.ToString()))
            {
                MessageBox.Show("请填写自动切换速度;"); return;
            }
            else if (!DataUtil.isInt(turnPictureSpeed.Text.ToString()))
            {
                MessageBox.Show("自动切换速度请填写整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(opacity.Text.ToString()))
            {
                MessageBox.Show("请填写透明度;"); return;
            }
            else if (!DataUtil.isInt(opacity.Text.ToString()))
            {
                MessageBox.Show("透明度请填写整数;"); return;
            }
            else
            {
                Int32 opacityVal = Convert.ToInt32(opacity.Text.ToString());
                if (opacityVal < 0 || opacityVal > 100)
                {
                    MessageBox.Show("透明度为0-100内的整数;"); return;
                }
            }

            int turnPictureSpeed1 = int.Parse(turnPictureSpeed.Text.ToString());

            if (turnPictureSpeed1 <= 0)
            {
                turnPictureSpeed1 = 8;
            }



            //更新到数据库
            DControl dControl = dControlBll.get(currDControl.id);

            dControl.width                  = int.Parse(width.Text);
            dControl.height                 = int.Parse(height.Text);
            dControl.left                   = int.Parse(left.Text);
            dControl.top                    = int.Parse(top.Text);
            dControl.autoplay               = (Boolean)autoplay.IsChecked;
            dControl.loop                   = (Boolean)loop.IsChecked;
            dControl.turnPictureSpeed       = turnPictureSpeed1;
            dControl.isShowTurnPictureArrow = (Boolean)isShowTurnPictureArrow.IsChecked;
            dControl.isClickShow            = (Boolean)isClickShow.IsChecked;
            dControl.opacity                = int.Parse(opacity.Text);
            dControlBll.update(dControl);
            currDControl    = dControl;
            currElement.Tag = currDControl;

            //更新页面控件信息
            TurnPicture turnPicture = (TurnPicture)currElement;

            turnPicture.updateElementAttr(dControl, true);
            editing.updateEditingBorder(dControl);
            Close();
        }
        //
        private void Submit_Button_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(width.Text))
            {
                MessageBox.Show("请填写宽度;"); return;
            }
            else if (!DataUtil.isInt(width.Text.ToString()))
            {
                MessageBox.Show("宽度必须是整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(height.Text.ToString()))
            {
                MessageBox.Show("请填写高度;"); return;
            }
            else if (!DataUtil.isInt(height.Text.ToString()))
            {
                MessageBox.Show("高度必须是整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(left.Text.ToString()))
            {
                MessageBox.Show("请填写左边距;"); return;
            }
            else if (!DataUtil.isInt(left.Text.ToString()))
            {
                MessageBox.Show("左边距请填写整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(top.Text.ToString()))
            {
                MessageBox.Show("请填写上边距;"); return;
            }
            else if (!DataUtil.isInt(top.Text.ToString()))
            {
                MessageBox.Show("上边距请填写整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(turnPictureSpeed.Text.ToString()))
            {
                MessageBox.Show("请填写自动切换速度;"); return;
            }
            else if (!DataUtil.IsDouble(turnPictureSpeed.Text.ToString()))
            {
                MessageBox.Show("自动切换速度请填写数字;"); return;
            }
            if (string.IsNullOrWhiteSpace(opacity.Text.ToString()))
            {
                MessageBox.Show("请填写透明度;"); return;
            }
            else if (!DataUtil.isInt(opacity.Text.ToString()))
            {
                MessageBox.Show("透明度请填写整数;"); return;
            }
            else
            {
                Int32 opacityVal = Convert.ToInt32(opacity.Text.ToString());
                if (opacityVal < 0 || opacityVal > 100)
                {
                    MessageBox.Show("透明度为0-100内的整数;"); return;
                }
            }

            if (string.IsNullOrWhiteSpace(rowNum.Text.ToString()))
            {
                MessageBox.Show("请填写可见图片数量;"); return;
            }
            else if (!DataUtil.isInt(top.Text.ToString()))
            {
                MessageBox.Show("可见图片数量请填写整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(spacing.Text.ToString()))
            {
                MessageBox.Show("请填写间距;"); return;
            }
            else if (!DataUtil.isInt(spacing.Text.ToString()))
            {
                MessageBox.Show("间距请填写整数;"); return;
            }

            int turnPictureSpeed1 = (int)Math.Floor(Double.Parse(turnPictureSpeed.Text.ToString()) * 1000);

            if (turnPictureSpeed1 <= 0)
            {
                turnPictureSpeed1 = 1000;
            }



            //更新到数据库
            DControl dControl = dControlBll.get(currDControl.id);

            dControl.width            = int.Parse(width.Text);
            dControl.height           = int.Parse(height.Text);
            dControl.left             = int.Parse(left.Text);
            dControl.top              = int.Parse(top.Text);
            dControl.turnPictureSpeed = turnPictureSpeed1;
            dControl.opacity          = int.Parse(opacity.Text);

            dControl.rowNum  = int.Parse(rowNum.Text);
            dControl.spacing = int.Parse(spacing.Text);

            dControl.autoplay = (Boolean)autoplay.IsChecked;
            dControl.loop     = (Boolean)loop.IsChecked;

            dControlBll.update(dControl);
            currDControl    = dControl;
            currElement.Tag = currDControl;

            //更新页面控件信息
            MarqueLayer marqueLayer = (MarqueLayer)currElement;

            marqueLayer.updateElementAttr(dControl, true);
            editing.updateEditingBorder(dControl);
            Close();
        }
Ejemplo n.º 8
0
 public CVideo(DControl ctl, Boolean isDesign, Cfg cfg, StorageVideoDto storageVideoDto, MqServer mqServer, Boolean isLinkToFullVideo)
     : this(ctl, isDesign, cfg, storageVideoDto, mqServer)
 {
     this.isLinkToFullVideo = isLinkToFullVideo;
 }
Ejemplo n.º 9
0
        /*
         * 1 右击-插入图片到页面
         */
        public void insertImageClick(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog ofld = new System.Windows.Forms.OpenFileDialog();
            ofld.Filter = "图片|*.jpg;*.jpeg;*.png;*.gif;*.bmp";
            if (ofld.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string text = ofld.FileName;
                if (text != "" || text != null)
                {
                    System.Drawing.Image sourceImage = System.Drawing.Image.FromFile(text);
                    DControl             dControl    = new DControl();
                    dControl.pageId  = App.localStorage.currPageId; /////////
                    dControl.name    = "Image";
                    dControl.content = "";
                    dControl.width   = sourceImage.Width;
                    dControl.height  = sourceImage.Height;
                    dControl.left    = (int)rightClickLocation.X; /////////
                    dControl.top     = (int)rightClickLocation.Y; /////////
                    dControl.type    = "Image";
                    // dControl.idx = 1;////////


                    //1、复制文件
                    String url        = uploadImage(text);
                    double showWidth  = sourceImage.Width;
                    double showHeight = sourceImage.Height;
                    double w          = sourceImage.Width / App.localStorage.cfg.screenWidth;
                    double h          = sourceImage.Height / App.localStorage.cfg.screenHeight;
                    if (w > 1 && h > 1)
                    {
                        if (w > h)
                        {
                            showWidth  = App.localStorage.cfg.screenWidth;
                            showHeight = sourceImage.Height / w;
                        }
                        else
                        {
                            showHeight = App.localStorage.cfg.screenHeight;
                            showWidth  = sourceImage.Width / h;
                        }
                    }
                    else if (w > 1)
                    {
                        showWidth  = App.localStorage.cfg.screenWidth;
                        showHeight = sourceImage.Height / w;
                    }
                    else if (h > 1)
                    {
                        showHeight = App.localStorage.cfg.screenHeight;
                        showWidth  = sourceImage.Width / h;
                    }
                    dControl.width  = (int)showWidth;
                    dControl.height = (int)showHeight;


                    //2、插入文件库
                    StorageImage storageImage = storageImageBll.insert(text, url, sourceImage.Width, sourceImage.Height, 1);
                    //3、插入控件库
                    dControl.storageId = storageImage.id;
                    dControl           = dControlBll.insert(dControl);
                    //4、插入页面
                    insertImageToPage(dControl);
                }
            }
        }
        /*
         * 加载所有动画效果
         */
        public void loadAllAnimation(FrameworkElement currElement, DControl currDControl)
        {
            List <DControlAnimation> list = dControlAnimationBll.getByDControlId(currDControl.id);

            AnimationUtil.loadAllAnimation(currElement, currDControl, list, App.localStorage.cfg);
        }
        /*
         * 让当前控件获得焦点
         */
        private Border control_GetFocus(object sender, MouseButtonEventArgs e)
        {
            pageTemplate.container.Children.Remove(editingBorder);
            FrameworkElement control     = (FrameworkElement)sender;
            DControl         dControl    = (DControl)control.Tag;
            SolidColorBrush  borderColor = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF109CEC"));


            //point宽度的一般
            double bhalf = Math.Floor(pointWidth / 2);
            //point水平居中坐标
            double centerX = (control.Width - pointWidth) / 2;
            //point垂直居中坐标
            double centerY = (control.Height - pointWidth) / 2;


            //1左上角
            Border border1 = new Border();

            border1.Name   = "leftTopBorder";
            border1.Width  = pointWidth;
            border1.Height = pointWidth;
            // border1.Margin = new Thickness(-bhalf,-bhalf,0,0);
            border1.BorderThickness = new Thickness(1);
            border1.BorderBrush     = borderColor;
            border1.Background      = Brushes.White;
            border1.SetValue(Canvas.LeftProperty, -bhalf);
            border1.SetValue(Canvas.TopProperty, -bhalf);
            //2右上角
            Border border2 = new Border();

            border2.Name   = "rightTopBorder";
            border2.Width  = pointWidth;
            border2.Height = pointWidth;
            // border2.Margin = new Thickness(0, -bhalf, -bhalf, 0);
            border2.BorderThickness = new Thickness(1);
            border2.BorderBrush     = borderColor;
            border2.Background      = Brushes.White;
            border2.SetValue(Canvas.TopProperty, -bhalf);
            border2.SetValue(Canvas.RightProperty, -bhalf);

            //3右下角
            Border border3 = new Border();

            border3.Name   = "rightBottomBorder";
            border3.Width  = pointWidth;
            border3.Height = pointWidth;
            // border3.Margin = new Thickness(0, 0, -bhalf, -bhalf);
            border3.BorderThickness = new Thickness(1);
            border3.BorderBrush     = borderColor;
            border3.Background      = Brushes.White;
            border3.SetValue(Canvas.RightProperty, -bhalf);
            border3.SetValue(Canvas.BottomProperty, -bhalf);
            border3.MouseEnter       += border3_MouseEnter;
            border3.MouseLeave       += border3_MouseLeave;
            border3.PreviewMouseDown += border3_MouseDown;
            border3.PreviewMouseMove += border3_MouseMove;
            border3.PreviewMouseUp   += border3_MouseUp;

            //4左下角
            Border border4 = new Border();

            border4.Name   = "leftBottomBorder";
            border4.Width  = pointWidth;
            border4.Height = pointWidth;
            // border4.Margin = new Thickness(-bhalf, 0, 0, -bhalf);
            border4.BorderThickness = new Thickness(1);
            border4.BorderBrush     = borderColor;
            border4.Background      = Brushes.White;
            border4.SetValue(Canvas.LeftProperty, -bhalf);
            border4.SetValue(Canvas.BottomProperty, -bhalf);

            //5左中角
            Border border5 = new Border();

            border5.Name   = "leftCenterBorder";
            border5.Width  = pointWidth;
            border5.Height = pointWidth;
            // border5.Margin = new Thickness(-bhalf, centerY, 0, 0);
            border5.BorderThickness = new Thickness(1);
            border5.BorderBrush     = borderColor;
            border5.Background      = Brushes.White;
            border5.SetValue(Canvas.LeftProperty, -bhalf);
            border5.SetValue(Canvas.TopProperty, centerY);

            //6上中角
            Border border6 = new Border();

            border6.Name   = "topCenterBorder";
            border6.Width  = pointWidth;
            border6.Height = pointWidth;
            // border6.Margin = new Thickness(centerX, -bhalf, 0, 0);
            border6.BorderThickness = new Thickness(1);
            border6.BorderBrush     = borderColor;
            border6.Background      = Brushes.White;
            border6.SetValue(Canvas.LeftProperty, centerX);
            border6.SetValue(Canvas.TopProperty, -bhalf);

            //7右中角
            Border border7 = new Border();

            border7.Name   = "rightCenterBorder";
            border7.Width  = pointWidth;
            border7.Height = pointWidth;
            //   border7.Margin = new Thickness(0, centerY, -bhalf, 0);
            border7.BorderThickness = new Thickness(1);
            border7.BorderBrush     = borderColor;
            border7.Background      = Brushes.White;
            border7.SetValue(Canvas.RightProperty, -bhalf);
            border7.SetValue(Canvas.TopProperty, centerY);

            //8下中角
            Border border8 = new Border();

            border8.Name   = "bottomCenterBorder";
            border8.Width  = pointWidth;
            border8.Height = pointWidth;
            //  border8.Margin = new Thickness(centerX, 0, 0, -bhalf);
            border8.BorderThickness = new Thickness(1);
            border8.BorderBrush     = borderColor;
            border8.Background      = Brushes.White;
            border8.SetValue(Canvas.LeftProperty, centerX);
            border8.SetValue(Canvas.BottomProperty, -bhalf);


            Canvas editingCanvas = new Canvas();

            editingCanvas.Name                = "editingCanvas";
            editingCanvas.Width               = control.Width;
            editingCanvas.Height              = control.Height;
            editingCanvas.VerticalAlignment   = VerticalAlignment.Top;
            editingCanvas.HorizontalAlignment = HorizontalAlignment.Left;
            editingCanvas.Margin              = new Thickness(-1, -1, 0, 0);
            editingCanvas.Children.Add(border1);
            editingCanvas.Children.Add(border2);
            editingCanvas.Children.Add(border3);
            editingCanvas.Children.Add(border4);
            editingCanvas.Children.Add(border5);
            editingCanvas.Children.Add(border6);
            editingCanvas.Children.Add(border7);
            editingCanvas.Children.Add(border8);


            editingBorder                     = new Border();
            editingBorder.Name                = "editingBorder";
            editingBorder.Width               = control.Width;
            editingBorder.Height              = control.Height;
            editingBorder.Margin              = control.Margin;
            editingBorder.BorderThickness     = new Thickness(1);
            editingBorder.BorderBrush         = borderColor;
            editingBorder.Background          = Brushes.Transparent;
            editingBorder.VerticalAlignment   = VerticalAlignment.Top;
            editingBorder.HorizontalAlignment = HorizontalAlignment.Left;
            Grid.SetZIndex(editingBorder, 10001);
            editingBorder.Child = editingCanvas;
            editingBorder.Tag   = control;
            // control.Tag = editingBorder;
            TransformGroup  group           = new TransformGroup();
            RotateTransform rotateTransform = TransformGroupUtil.GetRotateTransform(group);

            rotateTransform.Angle               = dControl.rotateAngle;
            editingBorder.RenderTransform       = group;
            editingBorder.RenderTransformOrigin = new Point(0.5, 0.5);


            editingBorder.MouseLeftButtonDown += editingBorder_MouseDown;
            editingBorder.MouseMove           += editingBorder_MouseMove;
            editingBorder.MouseLeftButtonUp   += editingBorder_MouseUp;
            //editingBorder.PreviewTouchDown += editingBorder_PreviewTouchDown;
            //editingBorder.TouchMove += editingBorder_TouchMove;
            //editingBorder.PreviewTouchUp += editingBorder_PreviewTouchUp;
            //右击控件
            editingBorder.MouseRightButtonUp += control_MouseRightButtonUp;


            pageTemplate.container.Children.Add(editingBorder);
            return(editingBorder);
        }
        /*
         * 关闭大图
         *
         * 动画,回到原位,移除大图
         */
        public static void closeAnimation(Canvas frameDialogCanvas, Border borderBg, Canvas innerCanvas, DControl dControlDto, Grid mainContainer)
        {
            double scaleX = dControlDto.width / innerCanvas.Width;
            double scaleY = dControlDto.height / innerCanvas.Height;

            if (scaleX / scaleY > 2 || scaleY / scaleX > 2)
            {
                scaleX = 0.1;
                scaleY = 0.1;
            }


            //1.淡出
            borderBg.RenderTransformOrigin = new Point(0.5, 0.5);
            DoubleAnimation da = new DoubleAnimation(borderBg.Opacity, 0, new Duration(TimeSpan.FromMilliseconds(300)));

            borderBg.BeginAnimation(UIElement.OpacityProperty, da);

            //2.缩放
            TransformGroup group = (TransformGroup)innerCanvas.RenderTransform;
            //  innerCanvas.RenderTransformOrigin = new Point(0.5, 0.5);
            ScaleTransform  scaleTransform = TransformGroupUtil.GetScaleTransform(group);
            DoubleAnimation da2            = new DoubleAnimation(scaleTransform.ScaleY, scaleY, new Duration(TimeSpan.FromMilliseconds(300)));

            da2.Completed += (sender, e) => closeAnimation_Completed(frameDialogCanvas, innerCanvas, mainContainer);
            scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, da2);
            DoubleAnimation da22 = new DoubleAnimation(scaleTransform.ScaleX, scaleX, new Duration(TimeSpan.FromMilliseconds(300)));

            scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, da22);

            // 平移
            TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
            DoubleAnimation    da31 = new DoubleAnimation(translateTransform.X, 0, new Duration(TimeSpan.FromMilliseconds(300)));

            translateTransform.BeginAnimation(TranslateTransform.XProperty, da31);
            DoubleAnimation da32 = new DoubleAnimation(translateTransform.Y, 0, new Duration(TimeSpan.FromMilliseconds(300)));

            translateTransform.BeginAnimation(TranslateTransform.YProperty, da32);


            // 淡出模式
            DoubleAnimation da4 = new DoubleAnimation(innerCanvas.Opacity, 0, new Duration(TimeSpan.FromMilliseconds(300)));

            da4.Completed += (sender, e) => closeAnimation_Completed(frameDialogCanvas, innerCanvas, mainContainer);
            innerCanvas.BeginAnimation(UIElement.OpacityProperty, da4);
        }
Ejemplo n.º 13
0
        /*
         * 填充轮播图中的图片,设置宽度,并绑定点按钮事件
         */
        private void fillImage(DControl ctl, List <TurnPictureImagesDto> list)
        {
            marque_scrollViewer.Width = ctl.width;

            if (list == null || list.Count == 0)
            {
                //return;
            }

            System.Windows.Style itemStyle = (System.Windows.Style)FindResource("ListBoxItemStyle1");
            System.Windows.Style turnPicturePageButtonStyle = (System.Windows.Style)FindResource("TurnPicturePageButtonStyle");


            int i = 0;

            foreach (TurnPictureImagesDto dto in list)
            {
                i = i + 1;
                Button item = new Button();
                item.Name            = "item" + i;
                item.Width           = itemWidth;
                item.Height          = ctl.height;
                item.BorderThickness = new Thickness(0);
                item.AllowDrop       = true;
                //   item.Style = itemStyle;
                item.Background = System.Windows.Media.Brushes.Transparent;
                FileUtil.readImage2Button(item, AppDomain.CurrentDomain.BaseDirectory + dto.url, ctl.width / 3, Stretch.Fill);

                if (i > 1)
                {
                    item.Margin = new Thickness(ctl.spacing, 0, 0, 0);
                }
                item.Tag = dto;
                item.PreviewMouseDown += item_Click;
                item.PreviewTouchDown += item_Click;
                marque_stackPanel.Children.Add(item);


                ////添加point
                Button btn = new Button();
                btn.Width           = 8;
                btn.Height          = 8;
                btn.Margin          = new Thickness(3, 0, 3, 0);
                btn.Padding         = new Thickness(0);
                btn.BorderThickness = new Thickness(0);
                btn.Style           = turnPicturePageButtonStyle;
                pagePanel.Children.Add(btn);
            }


            if (list.Count > ctl.rowNum)
            {
                for (int a = 0; a < ctl.rowNum; a++)
                {
                    TurnPictureImagesDto dto = list[a];
                    Button item = new Button();
                    item.Name            = "itema" + a;
                    item.Width           = itemWidth;
                    item.Height          = ctl.height;
                    item.BorderThickness = new Thickness(0);
                    item.AllowDrop       = true;
                    //   item.Style = itemStyle;
                    item.Background = System.Windows.Media.Brushes.Transparent;
                    FileUtil.readImage2Button(item, AppDomain.CurrentDomain.BaseDirectory + dto.url, ctl.width / 3, Stretch.Fill);
                    item.Margin            = new Thickness(ctl.spacing, 0, 0, 0);
                    item.Tag               = dto;
                    item.PreviewMouseDown += item_Click;
                    item.PreviewTouchDown += item_Click;

                    marque_stackPanel.Children.Add(item);
                }
            }
        }
Ejemplo n.º 14
0
        //
        private void Submit_Button_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(width.Text))
            {
                MessageBox.Show("请填写宽度;"); return;
            }
            else if (!DataUtil.isInt(width.Text.ToString()))
            {
                MessageBox.Show("宽度必须是整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(height.Text.ToString()))
            {
                MessageBox.Show("请填写高度;"); return;
            }
            else if (!DataUtil.isInt(height.Text.ToString()))
            {
                MessageBox.Show("高度必须是整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(left.Text.ToString()))
            {
                MessageBox.Show("请填写左边距;"); return;
            }
            else if (!DataUtil.isInt(left.Text.ToString()))
            {
                MessageBox.Show("左边距请填写整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(top.Text.ToString()))
            {
                MessageBox.Show("请填写上边距;"); return;
            }
            else if (!DataUtil.isInt(top.Text.ToString()))
            {
                MessageBox.Show("上边距请填写整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(opacity.Text.ToString()))
            {
                MessageBox.Show("请填写透明度;"); return;
            }
            else if (!DataUtil.isInt(opacity.Text.ToString()))
            {
                MessageBox.Show("透明度请填写整数;"); return;
            }
            else
            {
                Int32 opacityVal = Convert.ToInt32(opacity.Text.ToString());
                if (opacityVal < 0 || opacityVal > 100)
                {
                    MessageBox.Show("透明度为0-100内的整数;"); return;
                }
            }


            //更新到数据库
            DControl dControl = dControlBll.get(currDControl.id);

            dControl.width    = int.Parse(width.Text);
            dControl.height   = int.Parse(height.Text);
            dControl.left     = int.Parse(left.Text);
            dControl.top      = int.Parse(top.Text);
            dControl.autoplay = (Boolean)autoplay.IsChecked;
            dControl.loop     = (Boolean)loop.IsChecked;
            dControl.opacity  = int.Parse(opacity.Text);
            dControl.isHideVideoConsoleOfFirstLoad = (Boolean)isHideVideoConsoleOfFirstLoad.IsChecked;
            dControlBll.update(dControl);
            currDControl    = dControl;
            currElement.Tag = currDControl;

            //更新页面控件信息
            CVideo cVideo = (CVideo)currElement;

            cVideo.updateElementAttr(dControl, true);

            editing.updateEditingBorder(dControl);
            Close();
        }
        /*
         *  1.2 弹窗显示页面
         */
        public void insertFrameDialog(DControl dControl)
        {
            //1.获取指定的显示位置,CFrame的宽高
            CFrameTag cFrameTag        = getCFrameTag(dControl.showInWhichCFrame);
            Grid      mainContainerTmp = mainContainer;
            Frame     mainFrameTmp     = mainFrame;

            if (cFrameTag != null)
            {
                //获取框架中的页面大小,及container
                PageTemplate pt = (PageTemplate)cFrameTag.currCFrame.Content;
                mainContainerTmp = pt.container;
                mainFrameTmp     = cFrameTag.currCFrame;
            }
            this.realeaseOtherFrameDialog(mainContainerTmp);

            Int32 linkToPageId = dControl.linkToPageId;

            if (linkToPageId <= 0)
            {
                return;
            }
            DPage linkToDPage = dPageBll.get(linkToPageId);

            if (linkToDPage == null)
            {
                return;
            }
            //窗口所在父页面
            //if (dControlDto.pageId <= 0) return;
            //DPage dPage = dPageBll.get(dControlDto.pageId);
            //if (dPage == null) return;

            //父页面宽高
            int dPageWidth  = Convert.ToInt32(mainContainerTmp.ActualWidth);
            int dPageHeight = Convert.ToInt32(mainContainerTmp.ActualHeight);



            //弹窗
            int frameWidth  = Convert.ToInt32(dPageWidth);
            int frameHeight = Convert.ToInt32(dPageHeight);

            if (linkToDPage.width > 0)
            {
                frameWidth = linkToDPage.width;
            }
            if (linkToDPage.height > 0)
            {
                frameHeight = linkToDPage.height;
            }
            Cfg cfg = new Cfg();

            cfg.screenWidth  = frameWidth;
            cfg.screenHeight = frameHeight;



            Canvas frameDialogCanvas = new Canvas();

            frameDialogCanvas.Name = "frameDialogCanvas";
            frameDialogCanvas.HorizontalAlignment = HorizontalAlignment.Left;
            frameDialogCanvas.VerticalAlignment   = VerticalAlignment.Top;
            frameDialogCanvas.Width      = dPageWidth;
            frameDialogCanvas.Height     = dPageHeight;
            frameDialogCanvas.Background = Brushes.Transparent;
            Panel.SetZIndex(frameDialogCanvas, 10004);

            //1.透明底层
            Border frameDialogBorder = new Border();

            frameDialogBorder.Name       = "frameDialogBorder";
            frameDialogBorder.Width      = dPageWidth;
            frameDialogBorder.Height     = dPageHeight;
            frameDialogBorder.Background = Brushes.Black;
            frameDialogBorder.Opacity    = 0.5;
            Panel.SetZIndex(frameDialogBorder, 1);
            frameDialogCanvas.Children.Add(frameDialogBorder);


            //2.弹窗
            Canvas innerCanvas = new Canvas();

            innerCanvas.Name                = "innerCanvas";
            innerCanvas.Width               = cfg.screenWidth;
            innerCanvas.Height              = cfg.screenHeight;
            innerCanvas.Background          = Brushes.Transparent;
            innerCanvas.HorizontalAlignment = HorizontalAlignment.Left;
            innerCanvas.VerticalAlignment   = VerticalAlignment.Top;
            double left = dControl.left;
            double top  = dControl.top;

            innerCanvas.SetValue(Canvas.LeftProperty, left);
            innerCanvas.SetValue(Canvas.TopProperty, top);
            Panel.SetZIndex(innerCanvas, 2);



            CFrame cFrame = new CFrame(mainFrameTmp, dControl, cfg, pageTemplate1.screen, pageTemplate1.mqServer);

            cFrame.BorderThickness     = new Thickness(0);
            cFrame.Margin              = new Thickness(0, 0, 0, 0);
            cFrame.Width               = cfg.screenWidth;
            cFrame.Height              = cfg.screenHeight;
            cFrame.HorizontalAlignment = HorizontalAlignment.Left;
            cFrame.VerticalAlignment   = VerticalAlignment.Top;
            cFrame.Opacity             = 100.0;
            Panel.SetZIndex(cFrame, 1);
            cFrame.Focusable = false;
            innerCanvas.Children.Add(cFrame);

            //4.关闭按钮
            double posR = -25.0;
            double posT = -25.0;

            if (dPageWidth == frameWidth && dPageHeight == frameHeight)
            {
                posR = 0;
                posT = 0;
            }
            Button closebtn = new Button();

            closebtn.Background = new ImageBrush
            {
                ImageSource = FileUtil.readImage(AppDomain.CurrentDomain.BaseDirectory + "/myfile/sysimg/ico-image-close.png")
                ,
                Stretch = Stretch.Fill
            };
            closebtn.Width               = 50;
            closebtn.Height              = 50;
            closebtn.BorderThickness     = new Thickness(0);
            closebtn.HorizontalAlignment = HorizontalAlignment.Left;
            closebtn.VerticalAlignment   = VerticalAlignment.Top;
            closebtn.SetValue(Canvas.RightProperty, posR);
            closebtn.SetValue(Canvas.TopProperty, posT);
            Panel.SetZIndex(closebtn, 2);
            innerCanvas.Children.Add(closebtn);


            TransformGroup group  = new TransformGroup();
            double         scaleX = dControl.width / innerCanvas.Width;
            double         scaleY = dControl.height / innerCanvas.Height;

            if (scaleX / scaleY > 2 || scaleY / scaleX > 2)
            {
                scaleX = 0.1;
                scaleY = 0.1;
                left   = left + dControl.width * (1 - 0.1) / 2; //默认比例0.1
                top    = top + dControl.height * (1 - 0.1) / 2;
                innerCanvas.SetValue(Canvas.LeftProperty, left);
                innerCanvas.SetValue(Canvas.TopProperty, top);
            }
            ScaleTransform scaleTransform = new ScaleTransform();

            scaleTransform.ScaleX = scaleX;
            scaleTransform.ScaleY = scaleY;
            group.Children.Add(scaleTransform);
            innerCanvas.RenderTransform = group;

            frameDialogCanvas.Children.Add(innerCanvas);

            closebtn.Click += (object sender1, RoutedEventArgs e1) => ShowFrameDialogUtil.closeAnimation(frameDialogCanvas, frameDialogBorder, innerCanvas, dControl, mainContainerTmp);
            frameDialogBorder.PreviewMouseLeftButtonDown += (object sender1, MouseButtonEventArgs e1) => ShowFrameDialogUtil.closeAnimation(frameDialogCanvas, frameDialogBorder, innerCanvas, dControl, mainContainerTmp);
            frameDialogBorder.PreviewTouchDown           += (object sender1, TouchEventArgs e1) => ShowFrameDialogUtil.closeAnimation(frameDialogCanvas, frameDialogBorder, innerCanvas, dControl, mainContainerTmp);

            //动画,平移到指定位置
            double toLeft = (dPageWidth - innerCanvas.Width) / 2;
            double toTop  = (dPageHeight - innerCanvas.Height) / 2;
            double toTranslateTransformX = toLeft - left;
            double toTranslateTransformY = toTop - top;


            ShowFrameDialogUtil.showAnimation(frameDialogBorder, innerCanvas, dControl, toTranslateTransformX, toTranslateTransformY);
            mainContainerTmp.Children.Add(frameDialogCanvas);
        }
        //
        private void Submit_Button_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(width.Text))
            {
                MessageBox.Show("请填写宽度;"); return;
            }
            else if (!DataUtil.isInt(width.Text.ToString()))
            {
                MessageBox.Show("宽度必须是整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(height.Text.ToString()))
            {
                MessageBox.Show("请填写高度;"); return;
            }
            else if (!DataUtil.isInt(height.Text.ToString()))
            {
                MessageBox.Show("高度必须是整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(left.Text.ToString()))
            {
                MessageBox.Show("请填写左边距;"); return;
            }
            else if (!DataUtil.isInt(left.Text.ToString()))
            {
                MessageBox.Show("左边距请填写整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(top.Text.ToString()))
            {
                MessageBox.Show("请填写上边距;"); return;
            }
            else if (!DataUtil.isInt(top.Text.ToString()))
            {
                MessageBox.Show("上边距请填写整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(opacity.Text.ToString()))
            {
                MessageBox.Show("请填写透明度;"); return;
            }
            else if (!DataUtil.isInt(opacity.Text.ToString()))
            {
                MessageBox.Show("透明度请填写整数;"); return;
            }
            else
            {
                Int32 opacityVal = Convert.ToInt32(opacity.Text.ToString());
                if (opacityVal < 0 || opacityVal > 100)
                {
                    MessageBox.Show("透明度为0-100内的整数;"); return;
                }
            }

            if (string.IsNullOrWhiteSpace(rotateAngle.Text))
            {
                MessageBox.Show("请填写旋转角度;"); return;
            }
            else if (!DataUtil.isInt(rotateAngle.Text.ToString()))
            {
                MessageBox.Show("旋转角度必须是整数;"); return;
            }
            else
            {
                Int32 rotateAngleVal = Convert.ToInt32(rotateAngle.Text.ToString());
                if (rotateAngleVal < 0 || rotateAngleVal > 360)
                {
                    MessageBox.Show("旋转角度为0-360内的整数;"); return;
                }
            }


            //更新到数据库
            DControl dControl = dControlBll.get(currDControl.id);

            dControl.width       = int.Parse(width.Text);
            dControl.height      = int.Parse(height.Text);
            dControl.left        = int.Parse(left.Text);
            dControl.top         = int.Parse(top.Text);
            dControl.isClickShow = (Boolean)isClickShow.IsChecked;
            dControl.opacity     = int.Parse(opacity.Text);
            dControl.isTab       = (Boolean)isTab.IsChecked;
            dControl.rotateAngle = int.Parse(rotateAngle.Text);
            dControlBll.update(dControl);



            //更新页面控件信息,更新isClickShow
            currDControl    = dControl;
            currElement.Tag = currDControl;
            Gif button = (Gif)currElement;

            button.updateElementAttr(currDControl, true);

            //button.Width = currDControl.width;
            //button.Height = currDControl.height;
            //button.Margin = new Thickness(currDControl.left,currDControl.top,0,0);
            //button.Opacity = currDControl.opacity / 100.0;
            //TransformGroup group = (TransformGroup) button.RenderTransform;
            //RotateTransform rotateTransform = TransformGroupUtil.GetRotateTransform(group);
            //rotateTransform.Angle = currDControl.rotateAngle;

            //2.修改8个点的位置 及宽高
            editing.updateEditingBorder(currDControl);


            Close();
        }
        /*
         * 1.3 跳转到指定的页面,并伴随页面切换效果
         */
        private void linkToPageWithPageSwitchType(DControl ctl)
        {
            //1.如果显示位置不是 最顶层,则直接显示(无页面切换效果)
            CFrameTag cFrameTag = getCFrameTag(ctl.showInWhichCFrame);
            //2.如果是当前页面
            DPage linkToDPage = dPageBll.get(ctl.linkToPageId);

            if (linkToDPage == null)
            {
                return;
            }
            if (linkToDPage.pageSwitchType <= 0)
            {
                linkToDPage.pageSwitchType = 1;
            }

            //滚动条回到开始
            if (cFrameTag.parentFrame != null)
            {
                object parent = cFrameTag.currCFrame.Parent;
                if (parent is ScrollViewer)
                {
                    ScrollViewer sv = (ScrollViewer)parent;
                    sv.ScrollToVerticalOffset(0);
                    sv.ScrollToHorizontalOffset(0);
                }
            }

            //1.直接进入
            if (linkToDPage.pageSwitchType == 1)
            {
                //  cFrameTag.currCFrame.Background = Brushes.White;
                PageTemplate page1 = new PageTemplate(cFrameTag.currCFrame, ctl.linkToPageId, false, pageTemplate1.screen, pageTemplate1.mqServer);
                cFrameTag.currCFrame.NavigationService.Navigate(page1);
                return;
            }
            //2.淡出淡入
            if (linkToDPage.pageSwitchType == 2)
            {
                PageTemplate pt = (PageTemplate)cFrameTag.currCFrame.Content;
                cFrameTag.currCFrame.Background = Brushes.White;
                pt.RenderTransformOrigin        = new System.Windows.Point(0.5, 0.5);
                TransformGroup group = new TransformGroup();
                pt.RenderTransform = group;

                DoubleAnimation da = new DoubleAnimation(1.0, 0, new Duration(TimeSpan.FromMilliseconds(400)));
                da.BeginTime = TimeSpan.FromMilliseconds(0);
                IEasingFunction easingFunction = new CubicEase()
                {
                    EasingMode = EasingMode.EaseIn
                };
                da.EasingFunction = easingFunction;
                da.Completed     += (sender1, e1) => fadeOut_Completed(ctl, cFrameTag);
                pt.BeginAnimation(UIElement.OpacityProperty, da);

                return;
            }

            //3.右侧移入
            if (linkToDPage.pageSwitchType == 3)
            {
                PageTemplate pt        = (PageTemplate)cFrameTag.currCFrame.Content;
                string       shotImage = ShotUtil.shot(pt);
                cFrameTag.currCFrame.Background = new ImageBrush
                {
                    ImageSource = FileUtil.readImage(AppDomain.CurrentDomain.BaseDirectory + shotImage)
                };
                PageTemplate page = new PageTemplate(cFrameTag.currCFrame, ctl.linkToPageId, true, pageTemplate1.screen, pageTemplate1.mqServer);
                cFrameTag.currCFrame.NavigationService.Navigate(page);
                FrameUtil.RemoveBackEntry(cFrameTag.currCFrame);
                return;
            }

            //4.右侧拉伸
            if (linkToDPage.pageSwitchType == 4)
            {
                PageTemplate pt        = (PageTemplate)cFrameTag.currCFrame.Content;
                string       shotImage = ShotUtil.shot(pt);
                cFrameTag.currCFrame.Background = new ImageBrush
                {
                    ImageSource = FileUtil.readImage(AppDomain.CurrentDomain.BaseDirectory + shotImage)
                };
                PageTemplate page = new PageTemplate(cFrameTag.currCFrame, ctl.linkToPageId, true, pageTemplate1.screen, pageTemplate1.mqServer);
                cFrameTag.currCFrame.NavigationService.Navigate(page);
                FrameUtil.RemoveBackEntry(cFrameTag.currCFrame);
                return;
            }

            //5.中心放大
            if (linkToDPage.pageSwitchType == 5)
            {
                PageTemplate pt        = (PageTemplate)cFrameTag.currCFrame.Content;
                string       shotImage = ShotUtil.shot(pt);
                cFrameTag.currCFrame.Background = new ImageBrush
                {
                    ImageSource = FileUtil.readImage(AppDomain.CurrentDomain.BaseDirectory + shotImage)
                };
                PageTemplate page = new PageTemplate(cFrameTag.currCFrame, ctl.linkToPageId, true, pageTemplate1.screen, pageTemplate1.mqServer);
                cFrameTag.currCFrame.NavigationService.Navigate(page);
                FrameUtil.RemoveBackEntry(cFrameTag.currCFrame);
                return;
            }
        }
Ejemplo n.º 18
0
        /*
         * 更新
         */
        public Int32 update(DControl entity)
        {
            string sql = "update dControl set pageId=@pageId,name=@name,content=@content"
                         + ",width=@width,height=@height"
                         + ",left=@left,top=@top"
                         + ",idx=@idx,linkToPageId=@linkToPageId"
                         + ",isClickShow=@isClickShow,linkToVideoId=@linkToVideoId"
                         + ",autoplay=@autoplay,loop=@loop,turnPictureSpeed=@turnPictureSpeed"
                         + ",linkToWeb=@linkToWeb,storageId=@storageId,isShowTurnPictureArrow=@isShowTurnPictureArrow"
                         + ",opacity=@opacity"
                         + ",parentId=@parentId,contentWidth=@contentWidth,contentHeight=@contentHeight"
                         + ",backgroundImageId=@backgroundImageId,isTab=@isTab"
                         + ",rowNum=@rowNum,spacing=@spacing,rotateAngle=@rotateAngle,isDialogLink=@isDialogLink"
                         + ",showInWhichCFrame=@showInWhichCFrame,isTransparentDialog=@isTransparentDialog"
                         + ",fontFamily=@fontFamily,fontSize=@fontSize,fontLineHeight=@fontLineHeight"
                         + ",fontColor=@fontColor,fontWeight=@fontWeight,fontTextAlignment=@fontTextAlignment"
                         + ",storageIdOfCover=@storageIdOfCover,screenCfgId=@screenCfgId,isHideVideoConsoleOfFirstLoad=@isHideVideoConsoleOfFirstLoad"

                         + "  where id=@id";

            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@pageId",                        DbType.Int32,     4),
                new SQLiteParameter("@name",                          DbType.String,   30),
                new SQLiteParameter("@content",                       DbType.String, 4000),

                new SQLiteParameter("@width",                         DbType.Int32,     4),
                new SQLiteParameter("@height",                        DbType.Int32,     4),
                new SQLiteParameter("@left",                          DbType.Int32,     4),
                new SQLiteParameter("@top",                           DbType.Int32,     4),
                new SQLiteParameter("@type",                          DbType.String,   30),

                new SQLiteParameter("@idx",                           DbType.Int32,     4),
                new SQLiteParameter("@linkToPageId",                  DbType.Int32,     4),
                new SQLiteParameter("@isClickShow",                   DbType.Int32,     4),
                new SQLiteParameter("@linkToVideoId",                 DbType.Int32,     4),
                new SQLiteParameter("@autoplay",                      DbType.Int32,     4),
                new SQLiteParameter("@loop",                          DbType.Int32,     4),
                new SQLiteParameter("@turnPictureSpeed",              DbType.Int32,     4),
                new SQLiteParameter("@linkToWeb",                     DbType.String,  255),
                new SQLiteParameter("@storageId",                     DbType.Int32,     4),
                new SQLiteParameter("@isShowTurnPictureArrow",        DbType.Int32,     4),
                new SQLiteParameter("@opacity",                       DbType.Int32,     4),
                new SQLiteParameter("@parentId",                      DbType.Int32,     4),
                new SQLiteParameter("@contentWidth",                  DbType.Int32,     4),
                new SQLiteParameter("@contentHeight",                 DbType.Int32,     4),
                new SQLiteParameter("@backgroundImageId",             DbType.Int32,     4),
                new SQLiteParameter("@isTab",                         DbType.Int32,     4),
                new SQLiteParameter("@rowNum",                        DbType.Int32,     4),
                new SQLiteParameter("@spacing",                       DbType.Int32,     4),
                new SQLiteParameter("@rotateAngle",                   DbType.Int32,     4),
                new SQLiteParameter("@isDialogLink",                  DbType.Int32,     4),
                new SQLiteParameter("@showInWhichCFrame",             DbType.Int32,     4),
                new SQLiteParameter("@isTransparentDialog",           DbType.Int32,     4),
                new SQLiteParameter("@fontFamily",                    DbType.String,   30),
                new SQLiteParameter("@fontSize",                      DbType.Int32,     4),
                new SQLiteParameter("@fontLineHeight",                DbType.Int32,     4),
                new SQLiteParameter("@fontColor",                     DbType.String,   30),
                new SQLiteParameter("@fontWeight",                    DbType.String,   30),
                new SQLiteParameter("@fontTextAlignment",             DbType.Int32,     4),
                new SQLiteParameter("@storageIdOfCover",              DbType.Int32,     4),
                new SQLiteParameter("@screenCfgId",                   DbType.Int32,     4),
                new SQLiteParameter("@isHideVideoConsoleOfFirstLoad", DbType.Int32,     4),
                new SQLiteParameter("@id",                            DbType.Int32, 4)
            };
            parameters[0].Value = entity.pageId;
            parameters[1].Value = entity.name;
            parameters[2].Value = entity.content;

            parameters[3].Value = entity.width;
            parameters[4].Value = entity.height;
            parameters[5].Value = entity.left;
            parameters[6].Value = entity.top;
            parameters[7].Value = entity.type;

            parameters[8].Value  = entity.idx;
            parameters[9].Value  = entity.linkToPageId;
            parameters[10].Value = entity.isClickShow;
            parameters[11].Value = entity.linkToVideoId;
            parameters[12].Value = entity.autoplay;
            parameters[13].Value = entity.loop;
            parameters[14].Value = entity.turnPictureSpeed;
            parameters[15].Value = entity.linkToWeb;
            parameters[16].Value = entity.storageId;
            parameters[17].Value = entity.isShowTurnPictureArrow;
            parameters[18].Value = entity.opacity;
            parameters[19].Value = entity.parentId;
            parameters[20].Value = entity.contentWidth;
            parameters[21].Value = entity.contentHeight;
            parameters[22].Value = entity.backgroundImageId;
            parameters[23].Value = entity.isTab;
            parameters[24].Value = entity.rowNum;
            parameters[25].Value = entity.spacing;
            parameters[26].Value = entity.rotateAngle;
            parameters[27].Value = entity.isDialogLink;
            parameters[28].Value = entity.showInWhichCFrame;
            parameters[29].Value = entity.isTransparentDialog;

            parameters[30].Value = entity.fontFamily;
            parameters[31].Value = entity.fontSize;
            parameters[32].Value = entity.fontLineHeight;
            parameters[33].Value = entity.fontColor;
            parameters[34].Value = entity.fontWeight;
            parameters[35].Value = entity.fontTextAlignment;
            parameters[36].Value = entity.storageIdOfCover;
            parameters[37].Value = entity.screenCfgId;
            parameters[38].Value = entity.isHideVideoConsoleOfFirstLoad;
            parameters[39].Value = entity.id;
            int result = Common.SQLiteHelper.ExecuteNonQuery(sql, parameters);

            return(result);
        }
        /*
         *  1.4 链接到全屏视频
         */
        public void insertFullVideoToPage(DControlDto dControlDto)
        {
            StorageVideo storageVideo = storageVideoBll.get(dControlDto.linkToVideoId);


            int frameWidth  = App.localStorage.cfg.screenWidth;
            int frameHeight = App.localStorage.cfg.screenHeight;

            if (dPage.width > 0)
            {
                frameWidth = dPage.width;
            }
            if (dPage.height > 0)
            {
                frameHeight = dPage.height;
            }
            Cfg cfg = new Cfg();

            cfg.screenWidth  = frameWidth;
            cfg.screenHeight = frameHeight;


            if (storageVideo == null)
            {
                storageVideo              = new StorageVideo();
                storageVideo.url          = "/myfile/sysimg/notExists/video.mp4";
                storageVideo.origFilename = "演示视频.mp4";
            }
            StorageVideoDto dto          = StorageVideoUtil.convert(storageVideo);
            StorageImage    storageImage = storageImageBll.get(dto.storageImageId);

            dto.storageImageUrl = storageImage?.url;

            DControl ctl = new DControl();

            ctl.id               = 10003;
            ctl.pageId           = 0;
            ctl.name             = "cVideo";
            ctl.width            = cfg.screenWidth;
            ctl.height           = cfg.screenHeight;
            ctl.left             = 0;
            ctl.top              = 0;
            ctl.type             = "Video";
            ctl.content          = FileUtil.getFilenameTitle(storageVideo?.origFilename);
            ctl.idx              = 0; /////
            ctl.linkToPageId     = 0;
            ctl.isClickShow      = false;
            ctl.linkToVideoId    = 0;
            ctl.autoplay         = true;
            ctl.loop             = false;
            ctl.turnPictureSpeed = 0;
            ctl.storageId        = storageVideo.id;


            Canvas fullVideoCanvas = new Canvas();

            fullVideoCanvas.Name   = "fullVideoCanvas";
            fullVideoCanvas.Width  = ctl.width;
            fullVideoCanvas.Height = ctl.height;
            fullVideoCanvas.HorizontalAlignment = HorizontalAlignment.Left;
            fullVideoCanvas.VerticalAlignment   = VerticalAlignment.Top;
            TransformGroup group          = new TransformGroup();
            double         scaleX         = dControlDto.width / Convert.ToDouble(ctl.width);
            double         scaleY         = dControlDto.height / Convert.ToDouble(ctl.height);
            ScaleTransform scaleTransform = new ScaleTransform();

            scaleTransform.ScaleX = scaleX;
            scaleTransform.ScaleY = scaleY;
            group.Children.Add(scaleTransform);
            fullVideoCanvas.RenderTransform = group;
            double left = dControlDto.left;
            double top  = dControlDto.top;

            fullVideoCanvas.Margin = new Thickness(left, top, 0, 0);
            Panel.SetZIndex(fullVideoCanvas, 10003);

            CVideo cVideo = new CVideo(ctl, true, cfg, dto, pageTemplate1.mqServer, true);

            cVideo.Name = "cVideo";
            cVideo.HorizontalAlignment = HorizontalAlignment.Left;
            cVideo.VerticalAlignment   = VerticalAlignment.Top;
            cVideo.Width      = ctl.width;
            cVideo.Height     = ctl.height;
            cVideo.Background = null;
            cVideo.Tag        = ctl;


            //动画,平移到指定位置
            double toTranslateTransformX = 0 - dControlDto.left;
            double toTranslateTransformY = 0 - dControlDto.top;

            fullVideoCanvas.Children.Add(cVideo);
            AnimationUtil.loadFullVideo(fullVideoCanvas, toTranslateTransformX, toTranslateTransformY);


            pageTemplate1.container.Children.Add(fullVideoCanvas);

            //是否显示关闭按钮
            Button closebtn = cVideo.GetClosebtn();

            closebtn.Visibility = Visibility.Visible;
            closebtn.Tag        = true;
            closebtn.Click     += (object sender, RoutedEventArgs e) => closeVideoAnimation(fullVideoCanvas, dControlDto, cVideo);
        }
        /*
         * 1.1 右击图片或编辑框
         */
        internal void control_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            FrameworkElement ele = (FrameworkElement)sender;

            if (ele.GetType().Name == "Border")
            {
                ele = (FrameworkElement)ele.Tag;
            }
            else
            {
                Border editingBorder = control_GetFocus(sender, e);
            }
            DControl dControl = (DControl)ele.Tag;

            //this.rightClickDControl = dControl;
            rightClickEle = ele;



            //目标
            // ele.ContextMenu.PlacementTarget = this.btnMenu;
            //位置
            // ele.ContextMenu.Placement = PlacementMode.Top;
            //显示菜单

            if (dControl.type == "Image")
            {
                Grid xContextMenu = FrameworkElementUtil.GetChildObject <Grid>(pageTemplate.container, "ImageContextMenu");
                xContextMenu.ContextMenu.IsOpen = true;
            }
            else if (dControl.type == "TurnPicture")
            {
                Grid xContextMenu = FrameworkElementUtil.GetChildObject <Grid>(pageTemplate.container, "TurnPictureContextMenu");
                xContextMenu.ContextMenu.IsOpen = true;
            }
            else if (dControl.type == "Marque")
            {
                Grid xContextMenu = FrameworkElementUtil.GetChildObject <Grid>(pageTemplate.container, "MarqueContextMenu");
                xContextMenu.ContextMenu.IsOpen = true;
            }
            else if (dControl.type == "MarqueLayer")
            {
                Grid xContextMenu = FrameworkElementUtil.GetChildObject <Grid>(pageTemplate.container, "MarqueLayerContextMenu");
                xContextMenu.ContextMenu.IsOpen = true;
            }
            else if (dControl.type == "Word")
            {
                Grid xContextMenu = FrameworkElementUtil.GetChildObject <Grid>(pageTemplate.container, "WordContextMenu");
                xContextMenu.ContextMenu.IsOpen = true;
            }
            else if (dControl.type == "Video")
            {
                Grid xContextMenu = FrameworkElementUtil.GetChildObject <Grid>(pageTemplate.container, "VideoContextMenu");
                xContextMenu.ContextMenu.IsOpen = true;
            }
            else if (dControl.type == "BackButton")
            {
                Grid xContextMenu = FrameworkElementUtil.GetChildObject <Grid>(pageTemplate.container, "BackButtonContextMenu");
                xContextMenu.ContextMenu.IsOpen = true;
            }
            else if (dControl.type == "HomeButton")
            {
                Grid xContextMenu = FrameworkElementUtil.GetChildObject <Grid>(pageTemplate.container, "HomeButtonContextMenu");
                xContextMenu.ContextMenu.IsOpen = true;
            }
            else if (dControl.type == "CFrame")
            {
                Grid xContextMenu = FrameworkElementUtil.GetChildObject <Grid>(pageTemplate.container, "CFrameContextMenu");
                xContextMenu.ContextMenu.IsOpen = true;
            }
            else if (dControl.type == "TextBlock")
            {
                Grid xContextMenu = FrameworkElementUtil.GetChildObject <Grid>(pageTemplate.container, "TextBlockContextMenu");
                xContextMenu.ContextMenu.IsOpen = true;
            }
            else if (dControl.type == "Gif")
            {
                Grid xContextMenu = FrameworkElementUtil.GetChildObject <Grid>(pageTemplate.container, "GifContextMenu");
                xContextMenu.ContextMenu.IsOpen = true;
            }
            else if (dControl.type == "CCalendar")
            {
                Grid xContextMenu = FrameworkElementUtil.GetChildObject <Grid>(pageTemplate.container, "CCalendarContextMenu");
                xContextMenu.ContextMenu.IsOpen = true;
            }
            else if (dControl.type == "CAudio")
            {
                Grid xContextMenu = FrameworkElementUtil.GetChildObject <Grid>(pageTemplate.container, "CAudioContextMenu");
                xContextMenu.ContextMenu.IsOpen = true;
            }
            e.Handled = true;
        }
        /*
         * 4.1 返回按钮单击
         */
        public void backButtonClick(object sender, RoutedEventArgs e)
        {
            Button   backButton = (Button)sender;
            DControl dControl   = (DControl)backButton.Tag;

            DPage dPage = dPageBll.get(dControl.pageId);

            if (dPage.parentId <= 0)
            {
                return;
            }

            //设置返回哪一个页面
            dControl.linkToPageId = dPage.parentId;

            int pageSwitchType = dPage.pageSwitchType;

            if (pageSwitchType <= 0)
            {
                pageSwitchType = 1;
            }

            //1.默认
            if (pageSwitchType == 1)
            {
                PageTemplate page = new PageTemplate(pageTemplate1.mainFrame, dPage.parentId, true, true, pageSwitchType, pageTemplate1.screen, pageTemplate1.mqServer);
                pageTemplate1.NavigationService.Navigate(page);
                return;
            }
            //2.淡出
            if (pageSwitchType == 2)
            {
                TransformGroup group = new TransformGroup();
                pageTemplate1.RenderTransform = group;

                DoubleAnimation da = new DoubleAnimation(1.0, 0, new Duration(TimeSpan.FromMilliseconds(500)));
                da.BeginTime = TimeSpan.FromMilliseconds(0);
                IEasingFunction easingFunction = new SineEase()
                {
                    EasingMode = EasingMode.EaseIn
                };
                da.EasingFunction = easingFunction;
                da.Completed     += (sender1, e1) => fadeOut_Completed(dControl, true, pageSwitchType);
                pageTemplate1.BeginAnimation(UIElement.OpacityProperty, da);
                return;
            }

            //3.右侧移入 -> 左侧移出
            if (pageSwitchType == 3)
            {
                Border    CoverBorder = null;
                CFrameTag tag         = (CFrameTag)pageTemplate1.mainFrame.Tag;
                CoverBorder = tag.currCoverBorder;


                //截图
                string shotImage = ShotUtil.shot(pageTemplate1);
                //显示上一页
                BitmapImage bitmapImage = FileUtil.readImage(AppDomain.CurrentDomain.BaseDirectory + shotImage);
                CoverBorder.Background = new ImageBrush
                {
                    ImageSource = bitmapImage
                    ,
                    Stretch = Stretch.Fill
                };
                CoverBorder.Visibility = Visibility.Visible;
                CoverBorder.UpdateLayout();


                PageTemplate page = new PageTemplate(pageTemplate1.mainFrame, dPage.parentId, true, true, pageSwitchType, pageTemplate1.screen, pageTemplate1.mqServer);
                pageTemplate1.NavigationService.Navigate(page);


                //移出当前封面
                int pageWidth = PageWidthUtil.getPageWidth(dPage.width, App.localStorage.cfg.screenWidth);
                CoverBorderUtil.TranslateXMoveOut(CoverBorder, pageWidth);

                return;
            }


            //4.右侧拉伸 -> 左侧收缩
            if (pageSwitchType == 4)
            {
                pageTemplate1.mainFrame.Background = Brushes.White;
                Border    CoverBorder = null;
                CFrameTag tag         = (CFrameTag)pageTemplate1.mainFrame.Tag;
                CoverBorder = tag.currCoverBorder;
                //截图
                string shotImage = ShotUtil.shot(pageTemplate1);
                CoverBorder.Background = new ImageBrush
                {
                    ImageSource = FileUtil.readImage(AppDomain.CurrentDomain.BaseDirectory + shotImage)
                    ,
                    Stretch = Stretch.Fill
                };
                CoverBorder.Visibility = Visibility.Visible;

                //显示上一页
                PageTemplate page = new PageTemplate(pageTemplate1.mainFrame, dPage.parentId, true, true, pageSwitchType, pageTemplate1.screen, pageTemplate1.mqServer);
                pageTemplate1.NavigationService.Navigate(page);

                //移出当前封面
                CoverBorderUtil.ScaleXMoveOut(CoverBorder);
                return;
            }


            //5.中心放大 -> 中心收缩
            if (pageSwitchType == 5)
            {
                pageTemplate1.mainFrame.Background = Brushes.White;
                Border    CoverBorder = null;
                CFrameTag tag         = (CFrameTag)pageTemplate1.mainFrame.Tag;
                CoverBorder = tag.currCoverBorder;
                //截图
                string shotImage = ShotUtil.shot(pageTemplate1);
                CoverBorder.Background = new ImageBrush
                {
                    ImageSource = FileUtil.readImage(AppDomain.CurrentDomain.BaseDirectory + shotImage)
                    ,
                    Stretch = Stretch.Fill
                };
                CoverBorder.Visibility = Visibility.Visible;

                //显示上一页
                PageTemplate page = new PageTemplate(pageTemplate1.mainFrame, dPage.parentId, true, true, pageSwitchType, pageTemplate1.screen, pageTemplate1.mqServer);
                pageTemplate1.NavigationService.Navigate(page);

                //移出当前封面
                CoverBorderUtil.CenterMoveOut(CoverBorder);
                return;
            }
        }
Ejemplo n.º 22
0
        /*
         * 加载所有动画效果
         *
         * @param currElement 当前控件
         *
         * @param currDControl  当前控件数据
         *
         * @param  list 动画列表
         */
        public static void loadAllAnimation(FrameworkElement currElement, DControl currDControl, List <DControlAnimation> list, Cfg cfg)
        {
            double         currOpacity = currDControl.opacity / 100.0;
            TransformGroup group       = (TransformGroup)currElement.RenderTransform;


            // group.Children.Clear();   多次加载动画需要归零
            foreach (DControlAnimation animation in list)
            {
                if (animation.type == 1001)
                {
                    //淡入
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);
                    currElement.Opacity = 0;
                    IEasingFunction easingFunction = new CubicEase()
                    {
                        EasingMode = EasingMode.EaseIn
                    };
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, 0, currOpacity, easingFunction);
                    currElement.BeginAnimation(UIElement.OpacityProperty, da);
                }
                else if (animation.type == 1002)
                {
                    //从左移入
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);


                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    DoubleAnimation    da = DoubleAnimationUtil.initDoubleAnimation(animation, -currDControl.left - currDControl.width, 0);
                    translateTransform.BeginAnimation(TranslateTransform.XProperty, da);

                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1003)
                {
                    //从右移入
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    DoubleAnimation    da = DoubleAnimationUtil.initDoubleAnimation(animation, cfg.screenWidth - currDControl.left, 0);
                    translateTransform.BeginAnimation(TranslateTransform.XProperty, da);

                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1004)
                {
                    //从上移入
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    DoubleAnimation    da = DoubleAnimationUtil.initDoubleAnimation(animation, -currDControl.top - currDControl.height, 0);

                    translateTransform.BeginAnimation(TranslateTransform.YProperty, da);

                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1005)
                {
                    //从下移入
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    DoubleAnimation    da = DoubleAnimationUtil.initDoubleAnimation(animation, cfg.screenHeight - currDControl.top, 0);

                    translateTransform.BeginAnimation(TranslateTransform.YProperty, da);

                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }

                else if (animation.type == 1006)
                {
                    //放大
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    ScaleTransform  scaleTransform = TransformGroupUtil.GetScaleTransform(group);
                    DoubleAnimation da             = DoubleAnimationUtil.initDoubleAnimation(animation, 0.5, 1.0);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, da);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, da);


                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1007)
                {
                    //缩小
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    ScaleTransform  scaleTransform = TransformGroupUtil.GetScaleTransform(group);
                    DoubleAnimation da             = DoubleAnimationUtil.initDoubleAnimation(animation, 1.5, 1.0);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, da);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, da);

                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1101)
                {
                    //从左旋转
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    RotateTransform rotateTransform = TransformGroupUtil.GetRotateTransform(group);
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, 180 + currDControl.rotateAngle, 360 + currDControl.rotateAngle);
                    rotateTransform.BeginAnimation(RotateTransform.AngleProperty, da);


                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    DoubleAnimation    da2 = DoubleAnimationUtil.initDoubleAnimation(animation, -currDControl.width * 1, 0);
                    translateTransform.BeginAnimation(TranslateTransform.XProperty, da2);


                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1102)
                {
                    //从右旋转
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    RotateTransform rotateTransform = TransformGroupUtil.GetRotateTransform(group);
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, 180 + currDControl.rotateAngle, 360 + currDControl.rotateAngle);

                    rotateTransform.BeginAnimation(RotateTransform.AngleProperty, da);


                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    DoubleAnimation    da2 = DoubleAnimationUtil.initDoubleAnimation(animation, currDControl.width * 1, 0);
                    translateTransform.BeginAnimation(TranslateTransform.XProperty, da2);


                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1103)
                {
                    //从上旋转
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    RotateTransform rotateTransform = TransformGroupUtil.GetRotateTransform(group);
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, 180 + currDControl.rotateAngle, 360 + currDControl.rotateAngle);
                    rotateTransform.BeginAnimation(RotateTransform.AngleProperty, da);


                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    DoubleAnimation    da2 = DoubleAnimationUtil.initDoubleAnimation(animation, -currDControl.height * 1, 0);
                    translateTransform.BeginAnimation(TranslateTransform.YProperty, da2);


                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1104)
                {
                    //从下旋转
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    RotateTransform rotateTransform = TransformGroupUtil.GetRotateTransform(group);
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, 180 + currDControl.rotateAngle, 360 + currDControl.rotateAngle);
                    rotateTransform.BeginAnimation(RotateTransform.AngleProperty, da);


                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    DoubleAnimation    da2 = DoubleAnimationUtil.initDoubleAnimation(animation, currDControl.height * 1, 0);
                    translateTransform.BeginAnimation(TranslateTransform.YProperty, da2);


                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1201)
                {
                    //从左弹入
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    TranslateTransform translateTransform12 = TransformGroupUtil.GetTranslateTransform(group);
                    IEasingFunction    easingFunction       = new BackEase()
                    {
                        EasingMode = EasingMode.EaseInOut
                    };
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, -currDControl.left - currDControl.width, 0, easingFunction);
                    translateTransform12.BeginAnimation(TranslateTransform.XProperty, da);


                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1202)
                {
                    //从右弹入
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    IEasingFunction    easingFunction     = new BackEase()
                    {
                        EasingMode = EasingMode.EaseInOut
                    };
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, cfg.screenWidth - currDControl.left, 0, easingFunction);
                    translateTransform.BeginAnimation(TranslateTransform.XProperty, da);

                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1203)
                {
                    //从上弹入
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    IEasingFunction    easingFunction     = new BackEase()
                    {
                        EasingMode = EasingMode.EaseInOut
                    };
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, -currDControl.top - currDControl.height, 0, easingFunction);

                    translateTransform.BeginAnimation(TranslateTransform.YProperty, da);


                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1204)
                {
                    //从下弹入
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    IEasingFunction    easingFunction     = new BackEase()
                    {
                        EasingMode = EasingMode.EaseInOut
                    };
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, cfg.screenHeight - currDControl.top, 0, easingFunction);

                    translateTransform.BeginAnimation(TranslateTransform.YProperty, da);

                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1205)
                {
                    //中心弹入
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    ScaleTransform  scaleTransform = TransformGroupUtil.GetScaleTransform(group);
                    IEasingFunction easingFunction = new BackEase()
                    {
                        EasingMode = EasingMode.EaseInOut
                    };
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, 0.5, 1.0, easingFunction);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, da);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, da);


                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1301)
                {
                    //从左斜入
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    SkewTransform   skewTransform  = TransformGroupUtil.GetSkewTransform(group);
                    IEasingFunction easingFunction = new BackEase()
                    {
                        EasingMode = EasingMode.EaseInOut
                    };
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, 140, 180, easingFunction);
                    skewTransform.BeginAnimation(SkewTransform.AngleXProperty, da);


                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    DoubleAnimation    da1 = DoubleAnimationUtil.initDoubleAnimation(animation, -currDControl.width * 1, 0, easingFunction);
                    translateTransform.BeginAnimation(TranslateTransform.XProperty, da1);


                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1302)
                {
                    //从右斜入
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    SkewTransform   skewTransform  = TransformGroupUtil.GetSkewTransform(group);
                    IEasingFunction easingFunction = new BackEase()
                    {
                        EasingMode = EasingMode.EaseInOut
                    };
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, 40, 0, easingFunction);
                    skewTransform.BeginAnimation(SkewTransform.AngleXProperty, da);


                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    DoubleAnimation    da1 = DoubleAnimationUtil.initDoubleAnimation(animation, currDControl.width, 0, easingFunction);
                    translateTransform.BeginAnimation(TranslateTransform.XProperty, da1);


                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1303)
                {
                    //从上斜入
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    ScaleTransform  scaleTransform = TransformGroupUtil.GetScaleTransform(group);
                    DoubleAnimation da             = DoubleAnimationUtil.initDoubleAnimation(animation, 0.1, 1.0);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, da);



                    SkewTransform   skewTransform  = TransformGroupUtil.GetSkewTransform(group);
                    IEasingFunction easingFunction = new BackEase()
                    {
                        EasingMode = EasingMode.EaseInOut
                    };
                    DoubleAnimation da1 = DoubleAnimationUtil.initDoubleAnimation(animation, 60, 0, easingFunction);
                    skewTransform.BeginAnimation(SkewTransform.AngleXProperty, da1);


                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    DoubleAnimation    da2 = DoubleAnimationUtil.initDoubleAnimation(animation, -currDControl.height, 0);
                    translateTransform.BeginAnimation(TranslateTransform.YProperty, da2);

                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1304)
                {
                    //从下斜入
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    ScaleTransform  scaleTransform = TransformGroupUtil.GetScaleTransform(group);
                    DoubleAnimation da             = DoubleAnimationUtil.initDoubleAnimation(animation, 0.1, 1.0);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, da);

                    SkewTransform   skewTransform  = TransformGroupUtil.GetSkewTransform(group);
                    IEasingFunction easingFunction = new BackEase()
                    {
                        EasingMode = EasingMode.EaseInOut
                    };
                    DoubleAnimation da1 = DoubleAnimationUtil.initDoubleAnimation(animation, 60, 0, easingFunction);
                    skewTransform.BeginAnimation(SkewTransform.AngleXProperty, da1);


                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    DoubleAnimation    da2 = DoubleAnimationUtil.initDoubleAnimation(animation, currDControl.height, 0);
                    translateTransform.BeginAnimation(TranslateTransform.YProperty, da2);


                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1401)
                {
                    //从左绕入

                    currElement.RenderTransformOrigin = new Point(0, 0);
                    RotateTransform rotateTransform = TransformGroupUtil.GetRotateTransform(group);
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, 360 + currDControl.rotateAngle, 0 + currDControl.rotateAngle);
                    rotateTransform.BeginAnimation(RotateTransform.AngleProperty, da);


                    ScaleTransform  scaleTransform = TransformGroupUtil.GetScaleTransform(group);
                    DoubleAnimation da1            = DoubleAnimationUtil.initDoubleAnimation(animation, 0, 1.0);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, da1);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, da1);

                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1402)
                {
                    //从右绕入

                    currElement.RenderTransformOrigin = new Point(1, 1);
                    RotateTransform rotateTransform = TransformGroupUtil.GetRotateTransform(group);
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, 360 + currDControl.rotateAngle, 0 + currDControl.rotateAngle);
                    rotateTransform.BeginAnimation(RotateTransform.AngleProperty, da);


                    ScaleTransform  scaleTransform = TransformGroupUtil.GetScaleTransform(group);
                    DoubleAnimation da1            = DoubleAnimationUtil.initDoubleAnimation(animation, 0, 1.0);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, da1);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, da1);


                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1403)
                {
                    //从上绕入


                    currElement.RenderTransformOrigin = new Point(1, 0);
                    RotateTransform rotateTransform = TransformGroupUtil.GetRotateTransform(group);
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, 360 + currDControl.rotateAngle, 0 + currDControl.rotateAngle);
                    rotateTransform.BeginAnimation(RotateTransform.AngleProperty, da);

                    ScaleTransform  scaleTransform = TransformGroupUtil.GetScaleTransform(group);
                    DoubleAnimation da1            = DoubleAnimationUtil.initDoubleAnimation(animation, 0, 1.0);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, da1);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, da1);

                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1404)
                {
                    //从下绕入

                    currElement.RenderTransformOrigin = new Point(0, 1);
                    RotateTransform rotateTransform = TransformGroupUtil.GetRotateTransform(group);
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, 0 + currDControl.rotateAngle, 360 + currDControl.rotateAngle);
                    rotateTransform.BeginAnimation(RotateTransform.AngleProperty, da);


                    ScaleTransform  scaleTransform = TransformGroupUtil.GetScaleTransform(group);
                    DoubleAnimation da1            = DoubleAnimationUtil.initDoubleAnimation(animation, 0, 1.0);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, da1);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, da1);


                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1501)
                {
                    //翻开
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    SkewTransform   skewTransform  = TransformGroupUtil.GetSkewTransform(group);
                    IEasingFunction easingFunction = new BackEase()
                    {
                        EasingMode = EasingMode.EaseInOut, Amplitude = 0.1
                    };
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, 10, 0, easingFunction);
                    skewTransform.BeginAnimation(SkewTransform.AngleXProperty, da);


                    ScaleTransform  scaleTransform  = TransformGroupUtil.GetScaleTransform(group);
                    IEasingFunction easingFunction1 = new BackEase()
                    {
                        EasingMode = EasingMode.EaseInOut
                    };
                    DoubleAnimation da1 = DoubleAnimationUtil.initDoubleAnimation(animation, 0.4, 1.0, easingFunction1);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, da1);


                    IEasingFunction easingFunction2 = new CubicEase()
                    {
                        EasingMode = EasingMode.EaseIn
                    };
                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity, easingFunction2);
                }
                else if (animation.type == 1502)
                {
                    //旋转
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    RotateTransform rotateTransform = TransformGroupUtil.GetRotateTransform(group);
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, 0 + currDControl.rotateAngle, 360 + currDControl.rotateAngle);
                    rotateTransform.BeginAnimation(RotateTransform.AngleProperty, da);

                    IEasingFunction easingFunction2 = new CubicEase()
                    {
                        EasingMode = EasingMode.EaseIn
                    };
                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity, easingFunction2);
                }
                else if (animation.type == 1601)
                {
                    //光晕 来回缩放
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    double halfSeconds = animation.durationSeconds / 2.0;
                    DoubleAnimationUsingKeyFrames da = new DoubleAnimationUsingKeyFrames();
                    if (animation.playTimes <= 0)
                    {
                        da.RepeatBehavior = RepeatBehavior.Forever;
                    }
                    else
                    {
                        da.RepeatBehavior = new RepeatBehavior(animation.playTimes);
                    }
                    ScaleTransform  scaleTransform = TransformGroupUtil.GetScaleTransform(group);
                    var             keyFrames      = da.KeyFrames;
                    IEasingFunction easingFunction = new CubicEase()
                    {
                        EasingMode = EasingMode.EaseIn
                    };
                    keyFrames.Add(new LinearDoubleKeyFrame(1.0, TimeSpan.FromMilliseconds(0)));
                    keyFrames.Add(new LinearDoubleKeyFrame(0.78, TimeSpan.FromMilliseconds(halfSeconds)));
                    keyFrames.Add(new LinearDoubleKeyFrame(1.0, TimeSpan.FromMilliseconds(animation.durationSeconds)));
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, da);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, da);
                }
            }
        }
        /*
         * 更新控件数据
         */
        public DControl update(DControl entity)
        {
            int rows = dControlDal.update(entity);

            return(entity);
        }
Ejemplo n.º 24
0
        private void Submit_Button_Click(object sender, RoutedEventArgs e)
        {
            string fontSizeText = fontSize.Text;
            int    fontSizeVal  = 24;

            if (fontSizeText != null && fontSizeText.EndsWith("像素"))
            {
                fontSizeText = fontSizeText.Replace("像素", "");
                try
                {
                    fontSizeVal = int.Parse(fontSizeText);
                }
                catch (Exception) { }
            }

            string fontLineHeightText = fontLineHeight.Text;
            int    fontLineHeightVal  = 24;

            if (fontLineHeightText != null && fontLineHeightText.EndsWith("像素"))
            {
                fontLineHeightText = fontLineHeightText.Replace("像素", "");
                try
                {
                    fontLineHeightVal = int.Parse(fontLineHeightText);
                }
                catch (Exception) { }
            }

            string fontFamilyVal = fontFamily.Text;
            string fontWeightVal = "Normal";

            if ((Boolean)fontWeight.IsChecked)
            {
                fontWeightVal = "Bold";
            }

            object tag          = fontColor.Tag;
            string fontColorVal = "ff000000";

            if (tag != null)
            {
                string fontColorText = tag.ToString();
                if (!string.IsNullOrWhiteSpace(fontColorText))
                {
                    fontColorVal = fontColorText;
                }
            }

            int          fontTextAlignmentVal = 0;
            ComboBoxItem item = (ComboBoxItem)fontTextAlignment.SelectedItem;

            if (item != null)
            {
                if (item.Tag != null)
                {
                    fontTextAlignmentVal = Convert.ToInt32(item.Tag);
                }
            }

            //更新到数据库
            DControl dControl = dControlBll.get(currDControl.id);

            dControl.content           = content.Text;
            dControl.fontFamily        = fontFamilyVal;
            dControl.fontSize          = fontSizeVal;
            dControl.fontLineHeight    = fontLineHeightVal;
            dControl.fontColor         = fontColorVal;
            dControl.fontWeight        = fontWeightVal;
            dControl.fontTextAlignment = fontTextAlignmentVal;
            dControlBll.update(dControl);
            //同步到页面
            currDControl = dControl;


            Close();
        }
        //
        private void Submit_Button_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(content.Text.ToString()))
            {
                MessageBox.Show("请填写名称;"); return;
            }

            if (string.IsNullOrWhiteSpace(width.Text))
            {
                MessageBox.Show("请填写宽度;"); return;
            }
            else if (!DataUtil.isInt(width.Text.ToString()))
            {
                MessageBox.Show("宽度必须是整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(height.Text.ToString()))
            {
                MessageBox.Show("请填写高度;"); return;
            }
            else if (!DataUtil.isInt(height.Text.ToString()))
            {
                MessageBox.Show("高度必须是整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(left.Text.ToString()))
            {
                MessageBox.Show("请填写左边距;"); return;
            }
            else if (!DataUtil.isInt(left.Text.ToString()))
            {
                MessageBox.Show("左边距请填写整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(top.Text.ToString()))
            {
                MessageBox.Show("请填写上边距;"); return;
            }
            else if (!DataUtil.isInt(top.Text.ToString()))
            {
                MessageBox.Show("上边距请填写整数;"); return;
            }

            if (string.IsNullOrWhiteSpace(opacity.Text.ToString()))
            {
                MessageBox.Show("请填写透明度;"); return;
            }
            else if (!DataUtil.isInt(opacity.Text.ToString()))
            {
                MessageBox.Show("透明度请填写整数;"); return;
            }
            else
            {
                Int32 opacityVal = Convert.ToInt32(opacity.Text.ToString());
                if (opacityVal < 0 || opacityVal > 100)
                {
                    MessageBox.Show("透明度为0-100内的整数;"); return;
                }
            }



            //更新到数据库
            DControl dControl = dControlBll.get(currDControl.id);

            dControl.width   = int.Parse(width.Text);
            dControl.height  = int.Parse(height.Text);
            dControl.left    = int.Parse(left.Text);
            dControl.top     = int.Parse(top.Text);
            dControl.opacity = int.Parse(opacity.Text);
            dControl.content = content.Text;
            dControlBll.update(dControl);
            currDControl    = dControl;
            currElement.Tag = currDControl;

            //更新页面控件信息
            CFrame cFrame = (CFrame)currElement;

            cFrame.updateElementAttr(dControl, true);
            editing.updateEditingBorder(dControl);
            Close();
        }