private void UpdatePreviewOrientation()
        {
            GraffitiPreviewUC previewUc = this._previewUC;

            if (previewUc == null)
            {
                return;
            }
            int orientation = (int)this._orientation;

            previewUc.SetOrientation((DeviceOrientation)orientation);
        }
Beispiel #2
0
        private void UpdatePreviewOrientation()
        {
            GraffitiPreviewUC graffitiPreviewUc = this._previewUC;

            if (graffitiPreviewUc == null)
            {
                return;
            }
            int num = (int)this._orientation;

            graffitiPreviewUc.SetOrientation((DeviceOrientation)num);
        }
        private void Attach_OnClick(object sender, RoutedEventArgs e)
        {
            if (!this._graffitiDrawService.CanUndo || this._isSaving)
            {
                return;
            }
            this._isSaving = true;
            WriteableBitmap bitmap = this.CreateRenderBitmap();
            int             orientationRotateAngle = this.GetOrientationRotateAngle();

            if (orientationRotateAngle != 0)
            {
                bitmap = bitmap.Rotate(orientationRotateAngle);
            }
            this._previewUC = new GraffitiPreviewUC();
            this.UpdatePreviewOrientation();
            bool graffitiSent = false;

            this._previewUC.SendButtonClickAction = (Action)(async() =>
            {
                graffitiSent = true;
                string uriString = string.Format("/{0}", (object)Guid.NewGuid());
                int width = bitmap.PixelWidth;
                int height = bitmap.PixelHeight;
                Stream responseStream = await new GraffitiEncoder(bitmap).Encode();
                if (responseStream == null)
                {
                    this._isSaving = false;
                }
                else
                {
                    ImageCache.Current.TrySetImageForUri(uriString, responseStream);
                    responseStream.Close();
                    this._isSaving = false;
                    ParametersRepository.SetParameterForId("Graffiti", (object)new GraffitiAttachmentItem(uriString, width, height));
                    GC.Collect();
                    Navigator.Current.GoBack();
                }
            });
            this._previewUC.HideCallback = (Action)(() =>
            {
                this._isSaving = false;
                if (graffitiSent)
                {
                    return;
                }

                this.SubscribeToFrameReported();
            });
            this.UnsubscribeFromFrameReported();
            this._previewUC.Show(bitmap, this._orientation);
        }