Exemplo n.º 1
0
        /// <summary>
        /// 在值改变前触发
        /// </summary>
        private static object PreviewColumnsRowsChange(DependencyObject d, object baseValue)
        {
            PreviewListControl control = d as PreviewListControl;

            Size newSize = (Size)baseValue;

            control.uniformGrid.Rows    = (int)newSize.Height;
            control.uniformGrid.Columns = (int)newSize.Width;

            control.uniformGrid.Children.Clear();

            for (int x = 0; x < (int)newSize.Height * (int)newSize.Width; x++)
            {
                control.uniformGrid.Children.Add(new PreviewBoxControl());
                //添加光标移入事件
                control.uniformGrid.Children[x].MouseEnter += (sender, evt) =>
                {
                    int previewBoxIndex = control.uniformGrid.Children.IndexOf((sender as PreviewBoxControl));

                    if (control.CurrentMode == Mode.Posts)
                    {
                        if (previewBoxIndex < control.pageMD5Array.Length)
                        {
                            control.SelectedMD5 = control.pageMD5Array[previewBoxIndex];
                        }
                        else
                        {
                            control.SelectedMD5 = null;
                        }
                    }
                    else
                    {
                        if (previewBoxIndex < control.pageIdSiteArray.Length)
                        {
                            control.SelectedIdSite = control.pageIdSiteArray[previewBoxIndex];
                        }
                        else
                        {
                            control.SelectedIdSite = new KeyValuePair <int, Site>();
                        }
                    }
                };
            }

            control.PreviewBoxCount = (int)newSize.Height * (int)newSize.Width;
            return(baseValue);
        }
Exemplo n.º 2
0
        private static void CurrentModePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            PreviewListControl control = d as PreviewListControl;
            Mode mode = (Mode)e.NewValue;

            bool visible;

            if (mode == Mode.Posts)
            {
                visible = false;
                control.uniformGrid.ContextMenu = control.Resources["PostMenu"] as ContextMenu;
            }
            else
            {
                visible = true;
                control.uniformGrid.ContextMenu = control.Resources["PoolMenu"] as ContextMenu;
            }

            for (int x = 0; x < control.uniformGrid.Children.Count; x++)
            {
                (control.uniformGrid.Children[x] as PreviewBoxControl).PoolTittleVisible = visible;
            }
        }