Exemplo n.º 1
0
 public MasterControl()
 {
     InitializeComponent();
     GradientState                 = new m_GradientState();
     AnchPixNum                    = 3;
     PxPySlider.ValueChanged      += PxPySlider_ValueChanged;
     ParameterSlider.ValueChanged += ParameterSlider_ValueChanged;
 }
 public PixelBoardControl(m_GradientState gState, m_ProxyState pState, Point imageSize, Boolean opacityAllowed)
 {
     InitializeComponent();
     GradientState  = gState;
     ProxyState     = pState;
     ImageSize      = imageSize;
     OpacityAllowed = opacityAllowed;
     AnchorPixels   = new List <AnchorPixelControl>();
 }
        public GradinetControl(Int32 imageWidth, Int32 imageHeight, Boolean opacityAllowed)
        {
            InitializeComponent();

            Result = 0;

            mergedChannelsBitmap = new WriteableBitmap(Constants.PreviewBitmapWidth, Constants.PreviewBitmapHeight, 96, 96, PixelFormats.Bgra32, null);
            gradinetBitmap       = new WriteableBitmap(Constants.PreviewBitmapWidth, Constants.PreviewBitmapHeight, 96, 96, PixelFormats.Bgra32, null);

            GradientState = new m_GradientState();
            GradientState.ActiveAnchPixs = 3;

            ProxyState = new m_ProxyState();
            ProxyState.ViewportLocationH = 0;
            ProxyState.ViewportLocationV = 0;
            ProxyState.ZoomFactor        = 1.0;

            pixelBoardControl = new PixelBoardControl(GradientState, ProxyState, new Point(imageWidth, imageHeight), opacityAllowed);
            pixelBoardControl.GradientState = GradientState;
            pixelBoardControl.AnchorPixelRequestedColorChange += pixelBoardControl_AnchorPixelRequestedColorChange;
            pixelBoardControl.AnchorPixelChanged          += pixelBoardControl_AnchorPixelChanged;
            pixelBoardControl.ProxyStateChanged           += pixelBoardControl_ProxyStateChanged;
            pixelBoardControl.NumberOfAnchorPixelsChanged += pixelBoardControl_NumberOfAnchorPixelsChanged;
            pixelBoardControl.LegacyParametersChanged     += pixelBoardControl_LegacyParametersChanged;
            mainGrid.Children.Add(pixelBoardControl);

            masterControl.GradientState         = GradientState;
            masterControl.GradientStateChanged += masterControl_GradientStateChanged;

            addAnchorPixelControl.OpacityAllowed = opacityAllowed;

            ChannelsImage.Source = mergedChannelsBitmap;
            GradientImage.Source = gradinetBitmap;


            gradientUpdateTimer          = new DispatcherTimer();
            gradientUpdateTimer.Interval = new TimeSpan(0, 0, 0, 0, Constants.NonRealTimeMode_EventDefferingInterval_InMiliseconds);
            gradientUpdateTimer.Tick    += gradientUpdateTimer_Tick;


            Double zoomX, zoomY;

            zoomX = (SystemParameters.MaximizedPrimaryScreenWidth - 400) / imageWidth;
            zoomY = (SystemParameters.MaximizedPrimaryScreenHeight - 100) / imageHeight;

            if (zoomX < zoomY)
            {
                zoomControl.FitZoom = zoomX;
            }
            else
            {
                zoomControl.FitZoom = zoomY;
            }

            if (zoomControl.FitZoom < 1)
            {
                zoomControl.ZoomComboBox.SelectedIndex = 12;
            }


            ImageBrush backgroundImageBrush = new ImageBrush(getBackgroundBitmap());

            backgroundImageBrush.TileMode      = TileMode.Tile;
            backgroundImageBrush.Viewport      = new Rect(0, 0, 16, 16);
            backgroundImageBrush.ViewportUnits = BrushMappingMode.Absolute;
            backgroundImageBrush.Stretch       = Stretch.None;
            ImageRect.Fill = backgroundImageBrush;
        }