/*
         * 清空控件中的图片
         */
        private void removeBtnClick(object sender, RoutedEventArgs e)
        {
            Button removeBtn = (Button)sender;
            Canvas bg        = (Canvas)VisualTreeHelper.GetParent(removeBtn);
            Canvas imgCanvas = (Canvas)VisualTreeHelper.GetParent(bg);
            object tag       = imgCanvas.Tag;

            if (tag == null)
            {
                return;
            }
            TurnPictureImagesDto dto = (TurnPictureImagesDto)tag;

            dto.url            = "";
            dto.storageImageId = 0;
            imgCanvas.Tag      = dto;
            Button imgBtn = (Button)FrameworkElementUtil.getByName(imgCanvas, "imgBtn");

            imgBtn.Background = new ImageBrush
            {
                ImageSource = FileUtil.readImage(AppDomain.CurrentDomain.BaseDirectory + defaultBg)
                ,
                Stretch = Stretch.Uniform
            };
        }
Exemplo n.º 2
0
        /*
         *右击树,显示菜单
         */
        private void StorageVideo_TreeView_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            // MessageBox.Show(e.Source.GetType().Name);
            if (e.Source.GetType().Name != "TreeViewItem")
            {
                e.Handled = true;
                return;
            }
            //  object or =   e.Source;
            try
            {
                TreeViewItem treeViewItem = (TreeViewItem)e.Source;
                rightClickTreeViewItem = treeViewItem;
                Object tag = treeViewItem.Tag;
                if (tag != null)
                {
                    Int32 folderId = Int32.Parse(tag.ToString());
                    rightClickFolderId = folderId;
                    treeViewItem.Focus();
                    folderTreeColumn.ContextMenu.IsOpen = true;


                    ItemCollection firstItems = folderTreeColumn.ContextMenu.Items;
                    FrameworkElementUtil.enableAllMenuItem(firstItems);
                    if (folderId == 1)
                    {
                        //   MenuItem NewAfterPage = FrameworkElementUtil.getByName(firstItems, "NewAfterPage");
                        MenuItem MoveUp       = FrameworkElementUtil.getByName(firstItems, "MoveUp");
                        MenuItem MoveDown     = FrameworkElementUtil.getByName(firstItems, "MoveDown");
                        MenuItem DeleteFolder = FrameworkElementUtil.getByName(firstItems, "DeleteFolder");
                        //    NewAfterPage.IsEnabled = false;
                        MoveUp.IsEnabled       = false;
                        MoveDown.IsEnabled     = false;
                        DeleteFolder.IsEnabled = false;
                    }
                }
                else
                {
                    MessageBox.Show("没有tag:" + treeViewItem.Header.ToString());
                }
            }
            catch (ArgumentNullException)
            {
                MessageBox.Show("页面不能为空");
            }
            catch (ArgumentException)
            {
                MessageBox.Show("页面地址异常");
            }
            catch (UriFormatException)
            {
                MessageBox.Show("页面地址格式化异常");
            }
            catch (Exception e4)
            {
                MessageBox.Show("找不到此页面" + e4.Message.ToString() + e4.StackTrace);
            }
        }
        /*
         * 上下左右,移动控件
         */
        public Boolean KeyDownMove(Key key)
        {
            Boolean result = false;

            FrameworkElement element = FrameworkElementUtil.getByName(container, "editingBorder");

            if (element == null)
            {
                return(result);
            }

            Border           editingBorder = (Border)element;
            FrameworkElement control       = (FrameworkElement)editingBorder.Tag;
            Thickness        margin        = control.Margin;


            if (key == Key.Up)
            {
                margin.Top           = margin.Top - 1;
                control.Margin       = margin;
                editingBorder.Margin = margin;
                result = true;
            }
            else if (key == Key.Down)
            {
                margin.Top           = margin.Top + 1;
                control.Margin       = margin;
                editingBorder.Margin = margin;
                result = true;
            }
            else if (key == Key.Left)
            {
                margin.Left          = margin.Left - 1;
                control.Margin       = margin;
                editingBorder.Margin = margin;
                result = true;
            }
            else if (key == Key.Right)
            {
                margin.Left          = margin.Left + 1;
                control.Margin       = margin;
                editingBorder.Margin = margin;
                result = true;
            }
            if (result)
            {
                DControl dc = (DControl)control.Tag;
                dc.left     = (Int32)control.Margin.Left;
                dc.top      = (Int32)control.Margin.Top;
                control.Tag = dc;
                dControlBll.update(dc);
            }

            return(result);
        }
        //鼠标移动到视频上
        private void imageCanvasMouseEnter(object sender, MouseEventArgs e)
        {
            Canvas      fileCanvas = (Canvas)sender;
            FileListTag tag        = (FileListTag)fileCanvas.Tag;

            if (fileCanvas != null && !tag.isSelected)
            {
                FrameworkElement selectButton = FrameworkElementUtil.getByName(fileCanvas, "selectButton");
                if (selectButton != null)
                {
                    selectButton.Visibility = Visibility.Visible;
                }
            }
        }
Exemplo n.º 5
0
        public Spinner()
        {
            _internalSpinner = new InternalSpinner();
            FrameworkElementUtil.BindingProperty(_internalSpinner, InternalSpinner.SpinnerStyleProperty, this, SpinnerStyleProperty);
            FrameworkElementUtil.BindingProperty(_internalSpinner, InternalSpinner.IsSpinningProperty, this, IsSpinningProperty);
            FrameworkElementUtil.BindingProperty(_internalSpinner, InternalSpinner.ForegroundProperty, this, GlyphBrushProperty);
            FrameworkElementUtil.BindingProperty(_internalSpinner, InternalSpinner.ThicknessProperty, this, GlyphSizeProperty);
            FrameworkElementUtil.BindingProperty(_internalSpinner, InternalSpinner.CornerRadiusProperty, this, GlyphCornerRadiusProperty);
            FrameworkElementUtil.BindingProperty(_internalSpinner, InternalSpinner.HeightProperty, this, ActualHeightProperty);
            FrameworkElementUtil.BindingProperty(_internalSpinner, InternalSpinner.WidthProperty, this, ActualWidthProperty);

            AddLogicalChild(_internalSpinner);
            AddVisualChild(_internalSpinner);
        }
        //鼠标离开视频
        private void videoCanvasMouseLeave(object sender, MouseEventArgs e)
        {
            Canvas       videoCanvas = (Canvas)sender;
            VideoListTag tag         = (VideoListTag)videoCanvas.Tag;

            if (videoCanvas != null && !tag.isSelected)
            {
                FrameworkElement selectButton = FrameworkElementUtil.getByName(videoCanvas, "selectButton");
                if (selectButton != null)
                {
                    selectButton.Visibility = Visibility.Hidden;
                }
            }
        }
        /*
         * 取消选中当前图片
         */
        private void unSelectThisImage(Canvas video)
        {
            VideoListTag tag          = (VideoListTag)video.Tag;
            Button       selectButton = (Button)FrameworkElementUtil.getByName(video, "selectButton");

            if (selectButton != null)
            {
                selectButton.Visibility = Visibility.Hidden;
                selectButton.Background = new ImageBrush
                {
                    ImageSource = new BitmapImage(new Uri(@"Resources/ico_media_select.png", UriKind.Relative)),
                    Stretch     = Stretch.UniformToFill
                };
            }
            tag.isSelected = false;
            video.Tag      = tag;
        }
        /*
         * 选中当前图片
         */
        private void selectThisImage(Canvas fileCanvas)
        {
            FileListTag tag          = (FileListTag)fileCanvas.Tag;
            Button      selectButton = (Button)FrameworkElementUtil.getByName(fileCanvas, "selectButton");

            if (selectButton != null)
            {
                selectButton.Visibility = Visibility.Visible;
                selectButton.Background = new ImageBrush
                {
                    ImageSource = new BitmapImage(new Uri(@"Resources/ico_media_select_active.png", UriKind.Relative)),
                    Stretch     = Stretch.UniformToFill
                };
            }
            tag.isSelected = true;
            fileCanvas.Tag = tag;
        }
Exemplo n.º 9
0
 private void UpdateBinding()
 {
     if (Source != null && IsInitialized)
     {
         FrameworkElementUtil.BindingPropertyIfUndefaultAndUninherited(this, HeightProperty, Source, IconHelper.HeightProperty);
         FrameworkElementUtil.BindingPropertyIfUndefaultAndUninherited(this, WidthProperty, Source, IconHelper.WidthProperty);
         FrameworkElementUtil.BindingPropertyIfUndefaultAndUninherited(this, VerticalContentAlignmentProperty, Source, IconHelper.VerticalAlignmentProperty);
         FrameworkElementUtil.BindingPropertyIfUndefaultAndUninherited(this, HorizontalContentAlignmentProperty, Source, IconHelper.HorizontalAlignmentProperty);
         FrameworkElementUtil.BindingPropertyIfUndefaultAndUninherited(this, MinWidthProperty, Source, IconHelper.MinWidthProperty);
         FrameworkElementUtil.BindingPropertyIfUndefaultAndUninherited(this, MinHeightProperty, Source, IconHelper.MinHeightProperty);
         FrameworkElementUtil.BindingPropertyIfUndefaultAndUninherited(this, MaxWidthProperty, Source, IconHelper.MaxWidthProperty);
         FrameworkElementUtil.BindingPropertyIfUndefaultAndUninherited(this, MaxHeightProperty, Source, IconHelper.MaxHeightProperty);
         FrameworkElementUtil.BindingPropertyIfUndefaultAndUninherited(this, MarginProperty, Source, IconHelper.MarginProperty);
         FrameworkElementUtil.BindingPropertyIfUndefaultAndUninherited(this, FontFamilyProperty, Source, IconHelper.FontFamilyProperty);
         FrameworkElementUtil.BindingPropertyIfUndefaultAndUninherited(this, ForegroundProperty, Source, IconHelper.ForegroundProperty);
         FrameworkElementUtil.BindingPropertyIfUndefaultAndUninherited(this, FontSizeProperty, Source, IconHelper.FontSizeProperty);
         FrameworkElementUtil.BindingPropertyIfUndefaultAndUninherited(this, ToolTipProperty, Source, IconHelper.ToolTipProperty);
         FrameworkElementUtil.BindingPropertyIfUndefaultAndUninherited(this, VisibilityProperty, this, ContentProperty, new NullToCollapseConverter());
     }
 }
Exemplo n.º 10
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            this.Dispatcher.BeginInvoke(new Action(() =>
            {
                _cancelButton        = FrameworkElementUtil.FindVisualChild <Button>(this, CancelButtonTemplateName);
                var captionTextBlock = FrameworkElementUtil.FindVisualChild <TextBlock>(this, CaptionTextBlockTemplateName);
                _messageTextBlock    = FrameworkElementUtil.FindVisualChild <TextBlock>(this, MessageTextBlockTemplateName);
                var spinner          = FrameworkElementUtil.FindVisualChild <Spinner>(this, SpinnerTemplateName);

                if (_cancelButton != null)
                {
                    _cancelButton.Style      = _cancelButtonStyle;
                    _cancelButton.Content    = _cancelButtonContent;
                    _cancelButton.Visibility = _canCancel ? Visibility.Visible : Visibility.Collapsed;
                    _cancelButton.Click     += CancelButton_Click;
                }
                if (captionTextBlock != null)
                {
                    if (_captionText == null)
                    {
                        captionTextBlock.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        captionTextBlock.Text = _captionText;
                    }
                }
                if (_messageTextBlock != null)
                {
                    _messageTextBlock.Text = _messageText;
                }
                if (spinner != null)
                {
                    spinner.Style = _spinnerStyle;
                }
            }), DispatcherPriority.DataBind);
        }
Exemplo n.º 11
0
 private void OnIconForegroundChanged()
 {
     if (_iconPresenter != null)
     {
         if (IconForeground != null)
         {
             var bindingProperty = BindingOperations.GetBinding(Source, IconHelper.ForegroundProperty)?.Path?.PathParameters?.FirstOrDefault() as DependencyProperty;
             if (bindingProperty != null && bindingProperty.OwnerType == typeof(Internal.VisualStateHelper))
             {
                 _iconPresenter.Foreground = IconForeground;
             }
         }
         else
         {
             var bindingProperty = BindingOperations.GetBinding(Source, IconHelper.ForegroundProperty)?.Path?.PathParameters?.FirstOrDefault() as DependencyProperty;
             if (bindingProperty != null && bindingProperty.OwnerType == typeof(Internal.VisualStateHelper))
             {
                 FrameworkElementUtil.BindingProperty(_iconPresenter, IconPresenter.ForegroundProperty, Source, IconHelper.ForegroundProperty);
             }
         }
     }
 }
 //取消所有视频选中状态
 private void unselectedAllImage()
 {
     foreach (Canvas fileCanvas in imageListWrap.Children)
     {
         FileListTag tag = (FileListTag)fileCanvas.Tag;
         if (tag.isSelected)
         {
             Button selectButton = (Button)FrameworkElementUtil.getByName(fileCanvas, "selectButton");
             if (selectButton != null)
             {
                 selectButton.Visibility = Visibility.Hidden;
                 selectButton.Background = new ImageBrush
                 {
                     ImageSource = new BitmapImage(new Uri(@"Resources/ico_media_select.png", UriKind.Relative)),
                     Stretch     = Stretch.UniformToFill
                 };
             }
             tag.isSelected = false;
             fileCanvas.Tag = tag;
         }
     }
 }
Exemplo n.º 13
0
        private void ValidateCurrentStateItem()
        {
            if (!IsInitialized)
            {
                return;
            }

            foreach (var item in Items)
            {
                if (item == null)
                {
                    continue;
                }

                if (VerifyState(item.State))
                {
                    FrameworkElementUtil.BindingProperty(this, ContentProperty, item, StateItem.ContentProperty);
                    FrameworkElementUtil.BindingProperty(this, ContentTemplateProperty, item, StateItem.ContentTemplateProperty);
                    FrameworkElementUtil.BindingProperty(this, ContentTemplateSelectorProperty, item, StateItem.ContentTemplateSelectorProperty);
                    break;
                }
            }
        }
Exemplo n.º 14
0
        private static void OnRegistChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var element = (FrameworkElement)d;

            FrameworkElementUtil.BindingProperty(element, BackgroundProperty, element, Control.BackgroundProperty);
            if (element is TabItem)
            {
                FrameworkElementUtil.BindingProperty(element, ForegroundProperty, element, TabItemHelper.ForegroundProperty);
            }
            else
            {
                FrameworkElementUtil.BindingProperty(element, ForegroundProperty, element, Control.ForegroundProperty);
            }
            FrameworkElementUtil.BindingProperty(element, BorderBrushProperty, element, Control.BorderBrushProperty);
            if (element is CheckBox)
            {
                FrameworkElementUtil.BindingProperty(element, GlyphBrushProperty, element, CheckBoxHelper.GlyphBrushProperty);
            }
            if (element is RadioButton)
            {
                FrameworkElementUtil.BindingProperty(element, ToggleBrushProperty, element, RadioButtonHelper.ToggleBrushProperty);
            }
            FrameworkElementUtil.BindingProperty(element, BorderBrushProperty, element, Control.BorderBrushProperty);
            var effectBinding = new MultiBinding()
            {
                Converter = new DropShadowEffectWithDepthConverter(),
            };

            effectBinding.Bindings.Add(CreateBinding(ShadowColorProperty));
            effectBinding.Bindings.Add(CreateBinding(ShadowHelper.BlurRadiusProperty));
            effectBinding.Bindings.Add(CreateBinding(ShadowHelper.ShadowDepthProperty));
            effectBinding.Bindings.Add(CreateBinding(ShadowHelper.DirectionProperty));
            effectBinding.Bindings.Add(CreateBinding(ShadowHelper.OpacityProperty));
            effectBinding.Bindings.Add(CreateBinding(ShadowHelper.RenderingBiasProperty));
            element.SetBinding(EffectProperty, effectBinding);
        }
        /*
         * 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;
        }
        private async void loadImage(int n)
        {
            int count = turnImage_listbox.Items.Count;

            if (count <= 0)
            {
                return;
            }

            try
            {
                for (int a = 0; a < count; a++)
                {
                    ListBoxItem item = (ListBoxItem)turnImage_listbox.Items[a];
                    //左右,第一个,最后一个,第二个
                    if ((a >= n - 1 && a <= n + 1) || a == 0 || a == count - 1 || (n == count - 1 && a == 1))
                    {
                        if (item.Background == null)
                        {
                            int x = a;
                            if (a == count - 1)
                            {
                                x = 0;
                            }
                            string imgUrl = AppDomain.CurrentDomain.BaseDirectory + list[x].url;
                            Console.WriteLine(n + "__" + a);
                            Border border = FrameworkElementUtil.GetChildObject <Border>(item, "Loading");
                            if (border != null)
                            {
                                border.Visibility = Visibility.Visible;
                            }

                            ImageSource source = await Task.Run <ImageSource>(() =>
                            {
                                BitmapImage bitmapImage = new BitmapImage();
                                //打开文件流
                                // using (Stream stream = File.OpenRead(imgUrl))
                                using (Stream stream = new MemoryStream(File.ReadAllBytes(imgUrl)))
                                {
                                    bitmapImage.BeginInit();
                                    bitmapImage.CacheOption      = BitmapCacheOption.OnLoad;
                                    bitmapImage.StreamSource     = stream;
                                    bitmapImage.DecodePixelWidth = currDControl.width;
                                    bitmapImage.EndInit();
                                    //这一句很重要,少了UI线程就不认了。
                                    bitmapImage.Freeze();
                                }
                                return(bitmapImage);
                            });

                            //出炉
                            item.Background = new ImageBrush
                            {
                                ImageSource = source
                                ,
                                Stretch = Stretch.Fill
                            };
                            if (border != null)
                            {
                                border.Visibility = Visibility.Hidden;
                            }
                        }
                    }
                    else
                    {
                        item.Background = null;
                        Console.WriteLine("清空" + n + "__" + a);
                    }
                }


                // bigImage.Source = source;
            }
            catch { }
            GC.Collect();
        }
        /*
         * 保存数据
         */
        private void Submit_Button_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(backgroundMusicButtonLeft.Text))
            {
                MessageBox.Show("请填写按钮左边距;"); return;
            }
            else if (!DataUtil.isInt(backgroundMusicButtonLeft.Text.ToString()))
            {
                MessageBox.Show("按钮左边距必须是整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(backgroundMusicButtonTop.Text.ToString()))
            {
                MessageBox.Show("请填写按钮上边距;"); return;
            }
            else if (!DataUtil.isInt(backgroundMusicButtonTop.Text.ToString()))
            {
                MessageBox.Show("按钮上边距必须是整数;"); return;
            }

            if (string.IsNullOrWhiteSpace(backgroundMusicButtonWidth.Text))
            {
                MessageBox.Show("请填写按钮宽度;"); return;
            }
            else if (!DataUtil.isInt(backgroundMusicButtonLeft.Text.ToString()))
            {
                MessageBox.Show("按钮宽度必须是整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(backgroundMusicButtonHeight.Text.ToString()))
            {
                MessageBox.Show("请填写按钮高度;"); return;
            }
            else if (!DataUtil.isInt(backgroundMusicButtonTop.Text.ToString()))
            {
                MessageBox.Show("按钮高度必须是整数;"); return;
            }

            //1.更新到数据库
            Cfg cfg = cfgBll.get(1);

            cfg.backgroundMusicShow     = (bool)backgroundMusicShow.IsChecked;
            cfg.backgroundMusicAutoplay = (bool)backgroundMusicAutoplay.IsChecked;
            cfg.backgroundMusicLoop     = (bool)backgroundMusicLoop.IsChecked;

            cfg.backgroundMusicButtonWidth  = int.Parse(backgroundMusicButtonWidth.Text);
            cfg.backgroundMusicButtonHeight = int.Parse(backgroundMusicButtonHeight.Text);
            cfg.backgroundMusicButtonLeft   = int.Parse(backgroundMusicButtonLeft.Text);
            cfg.backgroundMusicButtonTop    = int.Parse(backgroundMusicButtonTop.Text);


            StorageFile storageFile = (StorageFile)backgroundMusicUrl.Tag;

            if (storageFile != null && !string.IsNullOrWhiteSpace(backgroundMusicUrl.Text))
            {
                cfg.backgroundMusicId = storageFile.id;
            }
            else
            {
                cfg.backgroundMusicId = 0;
            }

            Canvas       buttonImageCanvas = FrameworkElementUtil.GetChildObject <Canvas>(BackgroundMusicButtonImageWrapPanel, "buttonImageCanvas");
            StorageImage storageImage      = (StorageImage)buttonImageCanvas.Tag;

            if (storageImage != null)
            {
                cfg.backgroundMusicButtonImageId = storageImage.id;
            }
            else
            {
                cfg.backgroundMusicButtonImageId = 0;
            }
            cfgBll.update(cfg);

            //2.更新全局配置
            App.localStorage.cfg = cfg;
            //3.重新加载页面
            mainWindow.reloadWindow();

            Close();
        }
Exemplo n.º 18
0
        private void DeteminingSize()
        {
            if (_headerControl == null)
            {
                return;
            }
            var size = 0d;

            if (Orientation == Orientation.Horizontal)
            {
                size = GetComputedWidth(false);
                var internalHeight = GetComputedHeight(true);
                if (double.IsNaN(internalHeight))
                {
                    FrameworkElementUtil.BindingProperty(this, InternalHeaderHeightProperty, this, ActualHeightProperty);
                }
                else
                {
                    InternalHeaderHeight = internalHeight;
                }
            }
            else
            {
                size = GetComputedHeight(false);
                var internalWidth = GetComputedWidth(true);
                if (double.IsNaN(internalWidth))
                {
                    FrameworkElementUtil.BindingProperty(this, InternalHeaderWidthProperty, this, ActualWidthProperty);
                }
                else
                {
                    InternalHeaderWidth = internalWidth;
                }
            }
            var collectSizeEventArgs = new FormGroupCollectSizeEventArgs(Orientation, size);

            if (!string.IsNullOrEmpty(GroupName))
            {
                CollectSize?.Invoke(this, collectSizeEventArgs);
            }
            if (Orientation == Orientation.Horizontal)
            {
                if (collectSizeEventArgs.Maximuim == InternalHeaderWidth)
                {
                    return;
                }
                InternalHeaderWidth = collectSizeEventArgs.Maximuim;
            }
            else
            {
                if (collectSizeEventArgs.Maximuim == InternalHeaderHeight)
                {
                    return;
                }
                InternalHeaderHeight = collectSizeEventArgs.Maximuim;
            }
            if (!string.IsNullOrEmpty(GroupName))
            {
                var sizeDeteminedEventArgs = new FormGroupSizeDeterminedEventArgs(Orientation, collectSizeEventArgs.Maximuim);
                SizeDetemined?.Invoke(this, sizeDeteminedEventArgs);
            }
        }
Exemplo n.º 19
0
        /*
         * 显示大图
         */
        public static void showBigImage(string imagePath, DControlDto ctl, Grid mainContainer, Cfg cfg)
        {
            FrameworkElement bigImageElement = FrameworkElementUtil.getByName(mainContainer, "bigImageCanvas");

            if (bigImageElement == null)
            {
                Canvas bigImageCanvas = new Canvas();
                bigImageCanvas.Name       = "bigImageCanvas";
                bigImageCanvas.Width      = cfg.screenWidth;
                bigImageCanvas.Height     = cfg.screenHeight;
                bigImageCanvas.Background = Brushes.Transparent;
                Panel.SetZIndex(bigImageCanvas, 10002);

                //图片背景,点击隐藏
                Border borderBg = new Border();
                borderBg.Width               = cfg.screenWidth;
                borderBg.Height              = cfg.screenHeight;
                borderBg.Background          = Brushes.Black;
                borderBg.Opacity             = 0.6;
                borderBg.HorizontalAlignment = HorizontalAlignment.Left;
                borderBg.VerticalAlignment   = VerticalAlignment.Top;
                borderBg.SetValue(Canvas.LeftProperty, 0.0);
                borderBg.SetValue(Canvas.TopProperty, 0.0);
                Panel.SetZIndex(borderBg, 1);
                bigImageCanvas.Children.Add(borderBg);



                //显示大图
                double      maxWidth    = cfg.screenWidth * 0.9;
                double      maxHeight   = cfg.screenHeight * 0.9;
                string      img         = FileUtil.notExistsShowDefault(imagePath, Params.ImageNotExists);
                BitmapImage bitmapImage = FileUtil.readImage(AppDomain.CurrentDomain.BaseDirectory + img);
                double      showWidth   = bitmapImage.Width;
                double      showHeight  = bitmapImage.Height;
                double      w           = bitmapImage.Width / maxWidth;
                double      h           = bitmapImage.Height / maxHeight;
                if (w > 1 && h > 1)
                {
                    if (w > h)
                    {
                        showWidth  = maxWidth;
                        showHeight = bitmapImage.Height / w;
                    }
                    else
                    {
                        showHeight = maxHeight;
                        showWidth  = bitmapImage.Width / h;
                    }
                }
                else if (w > 1)
                {
                    showWidth  = maxWidth;
                    showHeight = bitmapImage.Height / w;
                }
                else if (h > 1)
                {
                    showHeight = maxHeight;
                    showWidth  = bitmapImage.Width / h;
                }

                Canvas innerCanvas = new Canvas();
                innerCanvas.Width  = showWidth;
                innerCanvas.Height = showHeight;
                double left = ctl.left;
                double top  = ctl.top;
                innerCanvas.SetValue(Canvas.LeftProperty, left);
                innerCanvas.SetValue(Canvas.TopProperty, top);
                Panel.SetZIndex(innerCanvas, 2);


                Image image = new Image();
                image.Source = bitmapImage;
                image.Width  = showWidth;
                image.Height = showHeight;
                Panel.SetZIndex(image, 1);
                innerCanvas.Children.Add(image);

                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.Right;
                closebtn.VerticalAlignment   = VerticalAlignment.Top;
                closebtn.SetValue(Canvas.RightProperty, -25.0);
                closebtn.SetValue(Canvas.TopProperty, -25.0);
                Panel.SetZIndex(closebtn, 2);

                closebtn.Click            += (sender, e) => imageCloseBtnClick(bigImageCanvas, borderBg, innerCanvas, ctl, mainContainer);
                closebtn.PreviewTouchDown += imageCloseBtnTouchDown;
                closebtn.PreviewTouchMove += imageCloseBtnTouchMove;
                closebtn.PreviewTouchUp   += (sender, e) => imageCloseBtnClick(bigImageCanvas, borderBg, innerCanvas, ctl, mainContainer);
                innerCanvas.Children.Add(closebtn);


                bigImageCanvas.Children.Add(innerCanvas);
                borderBg.PreviewMouseUp += (sender, e) => imageCloseBtnClick(bigImageCanvas, borderBg, innerCanvas, ctl, mainContainer);
                borderBg.PreviewTouchUp += (sender, e) => imageCloseBtnClick(bigImageCanvas, borderBg, innerCanvas, ctl, mainContainer);

                //手指缩放 移动 旋转
                BehaviorCollection          behaviors = Interaction.GetBehaviors(innerCanvas);
                TranslateZoomRotateBehavior tz        = new TranslateZoomRotateBehavior();
                tz.TranslateFriction       = 0.3;
                tz.RotationalFriction      = 0.4;
                tz.ConstrainToParentBounds = true;
                tz.SupportedGestures       = ManipulationModes.All;
                behaviors.Add(tz);

                TransformGroup group          = new TransformGroup();
                double         scaleX         = ctl.width / innerCanvas.Width;
                double         scaleY         = ctl.height / innerCanvas.Height;
                ScaleTransform scaleTransform = new ScaleTransform();
                scaleTransform.ScaleX = scaleX;
                scaleTransform.ScaleY = scaleY;
                group.Children.Add(scaleTransform);
                innerCanvas.RenderTransform = group;

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

                ShowBigImageUtil.showAnimation(borderBg, innerCanvas, ctl, toTranslateTransformX, toTranslateTransformY);

                mainContainer.Children.Add(bigImageCanvas);
            }
        }