Ejemplo n.º 1
0
        /*
         * 3.3插入层叠相册
         */
        public void insertMarqueLayerToPage(DControl ctl)
        {
            List <TurnPictureImagesDto> list = turnPictureImagesBll.getByDControlId(ctl.id);

            //如果storageImageId=0,则显示替代的Params.TurnPictureNotExists[i]
            for (int i = 0; i < list.Count; i++)
            {
                TurnPictureImagesDto dto = list[i];
                if (dto == null)
                {
                    list.Remove(dto);
                }
                string imgNotExists = Params.ImageNotExists;
                if (i < 6 && dto.storageImageId == 0)
                {
                    imgNotExists = Params.TurnPictureNotExists[i];
                }
                string imgFullPath = FileUtil.notExistsShowDefault(dto.url, imgNotExists);
                dto.url = imgFullPath;
            }
            MarqueLayer marqueLayer = NewControlUtil.newMarqueLayer(ctl, list, true);

            System.Windows.Style myStyle = (System.Windows.Style)pageTemplate.container.FindResource("DefaultMarqueLayerStyle");
            marqueLayer.Style = myStyle;

            marqueLayer.PreviewMouseLeftButtonDown += control_MouseDown;
            marqueLayer.PreviewMouseMove           += control_MouseMove;
            marqueLayer.PreviewMouseLeftButtonUp   += control_MouseUp;
            //控件上右击显示菜单
            marqueLayer.MouseRightButtonUp += control_MouseRightButtonUp;
            pageTemplate.container.Children.Add(marqueLayer);
        }
Ejemplo n.º 2
0
        /*
         * 保存数据
         */
        private void Submit_Button_Click(object sender, RoutedEventArgs e)
        {
            //过滤掉空图片
            List <TurnPictureImagesDto> list = new List <TurnPictureImagesDto>();

            foreach (Canvas imgCanvas in imgList.Children)
            {
                object tag = imgCanvas.Tag;
                if (tag == null)
                {
                    continue;
                }
                TurnPictureImagesDto dto = (TurnPictureImagesDto)tag;
                if (dto.storageImageId == 0 && dto.url == "")
                {
                    turnPictureImagesBll.delete(dto.id);
                    continue;
                }
                list.Add(dto);
            }
            //更新到数据库
            turnPictureImagesBll.updateByDControlId(currDControl, list);


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

            marqueLayer.updateElement(currDControl, true, list);

            Close();
        }
        /*
         * 3.3插入层叠相册
         */
        public void insertMarqueLayerToPage(DControl ctl)
        {
            List <TurnPictureImagesDto> list = turnPictureImagesBll.getByDControlId(ctl.id);

            for (int i = 0; i < list.Count; i++)
            {
                TurnPictureImagesDto dto = list[i];
                if (dto == null)
                {
                    list.Remove(dto);
                }
                string imgNotExists = Params.ImageNotExists;
                if (i < 6 && dto.storageImageId == 0)
                {
                    imgNotExists = Params.TurnPictureNotExists[i];
                }
                string imgFullPath = FileUtil.notExistsShowDefault(dto.url, imgNotExists);
                dto.url = imgFullPath;
            }

            MarqueLayer marqueLayer = NewControlUtil.newMarqueLayer(ctl, list, false);

            loadAllAnimation(marqueLayer, ctl);
            mainContainer.Children.Add(marqueLayer);
            marqueLayer.MarqueLayerItemEvent += new MarqueLayerItemHandler(TurnPictureItemFun);
        }
        /*
         * 5 层叠相册
         */
        public static MarqueLayer newMarqueLayer(DControl ctl, List <TurnPictureImagesDto> list, Boolean isDesign)
        {
            MarqueLayer marqueLayer = new MarqueLayer(ctl, isDesign, list);

            marqueLayer.HorizontalAlignment = HorizontalAlignment.Left;
            marqueLayer.VerticalAlignment   = VerticalAlignment.Top;
            marqueLayer.Margin = new Thickness(ctl.left, ctl.top, 0, 0);
            marqueLayer.Width  = ctl.width;
            marqueLayer.Height = ctl.height;

            marqueLayer.Background = null;
            marqueLayer.Opacity    = ctl.opacity / 100.0;
            Panel.SetZIndex(marqueLayer, ctl.idx);
            marqueLayer.Focusable = false;
            marqueLayer.Tag       = ctl;
            TransformGroup group = new TransformGroup();

            marqueLayer.RenderTransform       = group;
            marqueLayer.RenderTransformOrigin = new Point(0.5, 0.5);
            return(marqueLayer);
        }
        public void PageTemplate_UnLoaded(object sender, RoutedEventArgs e)
        {
            Unloaded -= PageTemplate_UnLoaded;
            foreach (FrameworkElement element in container.Children)
            {
                if (element is Button)
                {
                    Button btn = element as Button;
                    if (btn.Name == "Image")
                    {
                        btn.Click -= insertToPage.imageButtonClick;
                    }
                    else if (btn.Name == "BackButton")
                    {
                        btn.Click -= insertToPage.backButtonClick;
                    }
                    else if (btn.Name == "HomeButton")
                    {
                        btn.Click -= insertToPage.homeButtonClick;
                    }
                    btn.Background = null;
                    btn            = null;
                }
                else if (element is DocumentViewer)
                {
                    DocumentViewer documentViewer = element as DocumentViewer;
                    documentViewer.Document = null;
                    documentViewer          = null;
                }
                else if (element is TurnPicture)
                {
                    TurnPicture turnPicture = element as TurnPicture;
                    turnPicture = null;
                }
                else if (element is Marque)
                {
                    Marque marque = element as Marque;
                    marque = null;
                }
                else if (element is MarqueLayer)
                {
                    MarqueLayer marqueLayer = element as MarqueLayer;
                    marqueLayer = null;
                }
                else if (element is CVideo)
                {
                    CVideo cVideo = element as CVideo;
                    cVideo = null;
                }

                else if (element is CFrame)
                {
                    CFrame cFrame = element as CFrame;
                    cFrame.Content = null;
                    cFrame         = null;
                }
                else if (element is TextBlock)
                {
                    TextBlock textBlock = element as TextBlock;
                    textBlock.PreviewMouseUp -= insertToPage.textBlock_PreviewMouseUp;
                    textBlock.PreviewTouchUp -= insertToPage.textBlock_PreviewTouchUp;
                    textBlock = null;
                }
                else if (element is Gif)
                {
                    Gif gif = element as Gif;
                    gif.PreviewMouseUp -= insertToPage.gif_PreviewMouseUp;
                    gif.PreviewTouchUp -= insertToPage.gif_PreviewTouchUp;
                    gif = null;
                }
                else if (element is CAudio)
                {
                    CAudio cAudio = element as CAudio;
                    cAudio.PreviewMouseUp += insertToPage.cAudio_PreviewMouseUp;
                    cAudio.PreviewTouchUp += insertToPage.cAudio_PreviewTouchUp;
                    cAudio = null;
                }

                else if (element is CCalendar)
                {
                    CCalendar cCalendar = element as CCalendar;
                    cCalendar = null;
                }
                else if (element is Canvas && element.Name == "frameDialogCanvas")
                {
                    releaseFrameDialogCanvas(element);
                }
                else
                {
                    FrameworkElement fe = element as FrameworkElement;
                    fe = null;
                }
            }

            //释放视频背景
            foreach (FrameworkElement ele in backgroundVideo.Children)
            {
                if (ele.Name == "CVideoBackground")
                {
                    CVideoBackground cVideoBackground = (CVideoBackground)ele;
                    cVideoBackground = null;
                }
            }
            backgroundVideo.Children.Clear();
            Background   = null;
            insertToPage = null;
            Content      = null;
            container.Children.Clear();

            GC.Collect();
        }
        //
        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();
        }