Exemplo n.º 1
0
        /// <summary>
        /// Constructor for a LayoutManager instance.
        /// </summary>
        /// <param name="pTarget">Target canvas which will hold all photo slices and this manager will take effect on.</param>
        /// <param name="pDataSource">Data source for this manager instance.</param>
        /// <param name="pBtnSortCanvas">Sort layout trigger canvas.</param>
        /// <param name="pBtnRandomCanvas">Random layout trigger canvas.</param>
        /// <param name="pZoomOutTrigger">Zoomout trigter canvas.</param>
        /// <param name="pSortNavi">Sort navigator.</param>
        public LayoutManager(Canvas pTarget, PhotoDataSet pDataSource, Canvas pBtnSortCanvas, Canvas pBtnRandomCanvas, Canvas pZoomOutTrigger, SortNavigator pSortNavi, GenuineSlice pGenuineSlice, TracingIcon pTracingIcon, Image pScreenArrowLeft, Image pScreenArrowRight)
        {
            _target = pTarget;
            _targetShadow = pTarget.FindName("PhotoHolderShadow") as Canvas;
            _sortNavi = pSortNavi;
            _dataSource = pDataSource;
            _zoomOutTrigger = pZoomOutTrigger;
            _btnSort = pBtnSortCanvas;
            _btnSort.Cursor = Cursors.Hand;
            _btnRandom = pBtnRandomCanvas;
            _btnRandom.Cursor = Cursors.Hand;
            _genuineSlice = pGenuineSlice;
            _isSliceRequest = false;
            _tracingMouse = pTracingIcon;
            _screenArrowLeft = pScreenArrowLeft;
            _screenArrowRight = pScreenArrowRight;

            // Generate random & sort params
            GenerateLayoutPostion();
            // Fill thums to thumHolder
            FillThumHolder();

            // Event register.
            _target.MouseLeftButtonUp += new MouseEventHandler(_target_MouseLeftButtonUp);
            _zoomOutTrigger.MouseLeftButtonUp += new MouseEventHandler(_zoomOutTrigger_MouseLeftButtonUp);
            _zoomInStoryboard = _target.FindName("ZoomIn") as Storyboard;
            _zoomOutStoryboard = _target.FindName("ZoomOut") as Storyboard;
            _rotateToAngleStoryboard = _target.FindName("RotateToAngle") as Storyboard;
            _animateToPositionStoryboard = _target.FindName("AnimateToPosition") as Storyboard;
            _zoomInStoryboard.Completed += new EventHandler(_zoomInStoryboard_Completed);
            _zoomOutStoryboard.Completed += new EventHandler(_zoomOutStoryboard_Completed);
            _layoutStandByStoryboard = _target.FindName("LayoutStandBy") as Storyboard;
            _layoutStandByStoryboard.Completed += new EventHandler(_layoutStandByStoryboard_Completed);

            _btnSort.MouseLeftButtonUp += new MouseEventHandler(_btnSort_MouseLeftButtonUp);
            _btnSort.MouseEnter += new MouseEventHandler(_btnSort_MouseEnter);
            _btnSort.MouseLeave += new EventHandler(_btnSort_MouseLeave);
            _btnRandom.MouseLeftButtonUp += new MouseEventHandler(_btnRandom_MouseLeftButtonUp);
            _btnRandom.MouseEnter += new MouseEventHandler(_btnRandom_MouseEnter);
            _btnRandom.MouseLeave += new EventHandler(_btnRandom_MouseLeave);

            _screenArrowLeft.MouseLeftButtonUp += new MouseEventHandler(_screenArrowLeft_MouseLeftButtonUp);
            _screenArrowRight.MouseLeftButtonUp += new MouseEventHandler(_screenArrowRight_MouseLeftButtonUp);

            // By default, enter sorted layout.
            _status = AlbumStatus.Hanging;     // clear status
            Status = AlbumStatus.Sorted;
            _zoomStatus = ZoomStatus.Out;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor for a LayoutManager instance.
        /// </summary>
        /// <param name="pTarget">Target canvas which will hold all photo slices and this manager will take effect on.</param>
        /// <param name="pDataSource">Data source for this manager instance.</param>
        /// <param name="pBtnSortCanvas">Sort layout trigger canvas.</param>
        /// <param name="pBtnRandomCanvas">Random layout trigger canvas.</param>
        /// <param name="pZoomOutTrigger">Zoomout trigter canvas.</param>
        /// <param name="pSortNavi">Sort navigator.</param>
        public LayoutManager(Canvas pTarget, PhotoDataSet pDataSource, Canvas pBtnSortCanvas, Canvas pBtnRandomCanvas, Canvas pZoomOutTrigger, SortNavigator pSortNavi, GenuineSlice pGenuineSlice, TracingIcon pTracingIcon, Image pScreenArrowLeft, Image pScreenArrowRight)
        {
            _target           = pTarget;
            _targetShadow     = pTarget.FindName("PhotoHolderShadow") as Canvas;
            _sortNavi         = pSortNavi;
            _dataSource       = pDataSource;
            _zoomOutTrigger   = pZoomOutTrigger;
            _btnSort          = pBtnSortCanvas;
            _btnSort.Cursor   = Cursors.Hand;
            _btnRandom        = pBtnRandomCanvas;
            _btnRandom.Cursor = Cursors.Hand;
            _genuineSlice     = pGenuineSlice;
            _isSliceRequest   = false;
            _tracingMouse     = pTracingIcon;
            _screenArrowLeft  = pScreenArrowLeft;
            _screenArrowRight = pScreenArrowRight;

            // Generate random & sort params
            GenerateLayoutPostion();
            // Fill thums to thumHolder
            FillThumHolder();

            // Event register.
            _target.MouseLeftButtonUp         += new MouseEventHandler(_target_MouseLeftButtonUp);
            _zoomOutTrigger.MouseLeftButtonUp += new MouseEventHandler(_zoomOutTrigger_MouseLeftButtonUp);
            _zoomInStoryboard                   = _target.FindName("ZoomIn") as Storyboard;
            _zoomOutStoryboard                  = _target.FindName("ZoomOut") as Storyboard;
            _rotateToAngleStoryboard            = _target.FindName("RotateToAngle") as Storyboard;
            _animateToPositionStoryboard        = _target.FindName("AnimateToPosition") as Storyboard;
            _zoomInStoryboard.Completed        += new EventHandler(_zoomInStoryboard_Completed);
            _zoomOutStoryboard.Completed       += new EventHandler(_zoomOutStoryboard_Completed);
            _layoutStandByStoryboard            = _target.FindName("LayoutStandBy") as Storyboard;
            _layoutStandByStoryboard.Completed += new EventHandler(_layoutStandByStoryboard_Completed);

            _btnSort.MouseLeftButtonUp   += new MouseEventHandler(_btnSort_MouseLeftButtonUp);
            _btnSort.MouseEnter          += new MouseEventHandler(_btnSort_MouseEnter);
            _btnSort.MouseLeave          += new EventHandler(_btnSort_MouseLeave);
            _btnRandom.MouseLeftButtonUp += new MouseEventHandler(_btnRandom_MouseLeftButtonUp);
            _btnRandom.MouseEnter        += new MouseEventHandler(_btnRandom_MouseEnter);
            _btnRandom.MouseLeave        += new EventHandler(_btnRandom_MouseLeave);

            _screenArrowLeft.MouseLeftButtonUp  += new MouseEventHandler(_screenArrowLeft_MouseLeftButtonUp);
            _screenArrowRight.MouseLeftButtonUp += new MouseEventHandler(_screenArrowRight_MouseLeftButtonUp);

            // By default, enter sorted layout.
            _status     = AlbumStatus.Hanging; // clear status
            Status      = AlbumStatus.Sorted;
            _zoomStatus = ZoomStatus.Out;
        }
Exemplo n.º 3
0
        private void OnResponseDownload(IAsyncResult iar)
        {
            try
            {
                HttpWebResponse response =
                    ((HttpWebRequest)iar.AsyncState).EndGetResponse(iar);
                if (response.StatusCode != HttpStatusCode.OK)
                {
                    throw new ApplicationException("HttpStatusCode " + response.StatusCode.ToString() + " was returned.");
                }
                StreamReader responseReader = new StreamReader(response.GetResponseStream());

                string jsonData = responseReader.ReadToEnd();
                responseReader.Close();
                response.Close();
                XmlReader xr = XmlReader.Create(new StringReader(jsonData));
                xr.ReadToFollowing("string");
                xr.Read();

                JavaScriptSerializer jss = new JavaScriptSerializer();
                PhotoClass           pc  = jss.Deserialize <PhotoClass>(xr.Value);

                _photoDataSet = new PhotoDataSet();
                _photoDataSet.FillDummy(pc.items);


                InitailizeAlbum();
                SyncPhotoData();
                SyncToHost();
            }

            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
            }
        }
Exemplo n.º 4
0
        private void OnResponseDownload(IAsyncResult iar)
        {
            try
            {
                HttpWebResponse response =
                    ((HttpWebRequest)iar.AsyncState).EndGetResponse(iar);
                if (response.StatusCode != HttpStatusCode.OK)
                    throw new ApplicationException("HttpStatusCode " + response.StatusCode.ToString() + " was returned.");
                StreamReader responseReader = new StreamReader(response.GetResponseStream());

                string jsonData = responseReader.ReadToEnd();
                responseReader.Close();
                response.Close();
                XmlReader xr = XmlReader.Create(new StringReader(jsonData));
                xr.ReadToFollowing("string");
                xr.Read();

                JavaScriptSerializer jss = new JavaScriptSerializer();
                PhotoClass pc = jss.Deserialize<PhotoClass>(xr.Value);
                
                _photoDataSet = new PhotoDataSet();
                _photoDataSet.FillDummy(pc.items);


                InitailizeAlbum();
                SyncPhotoData();
                SyncToHost();


                
            }

            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
            }
        }