예제 #1
0
        private void btnYes_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (StackLines.Count < 1 || txtPLS.Visibility == Visibility.Visible)
            {
                if (!PicUrl.Equals(""))
                {
                    MessageBox.Show("已簽名,欲重新簽名請先按x清除");
                }
                else
                {
                    MessageBox.Show("請簽名後上傳");
                }
                return;
            }
            string    text      = "";
            DataTable dataTable = MSCE.GetDataTable("select AllowIpRange from NowLogin");

            if (dataTable.Rows.Count > 0)
            {
                text = dataTable.Rows[0]["AllowIpRange"].ToString();
            }
            if (!text.Equals("") && !IpTool.CheckInNowWifi(text))
            {
                string courseOrMeeting_String = Settings.Default.CourseOrMeeting_String;
                AutoClosingMessageBox.Show(string.Format("您不在{0}室範圍內,無法使用此功能", courseOrMeeting_String.Equals("課程") ? "教" : courseOrMeeting_String));
                return;
            }
            string path = System.IO.Path.Combine(ClickOnceTool.GetFilePath(), Settings.Default.SignInFolder);

            path = System.IO.Path.Combine(path, MeetingID, UserID);
            Directory.CreateDirectory(path);
            string      str     = Guid.NewGuid().ToString();
            string      path2   = str + ".png";
            string      text2   = System.IO.Path.Combine(path, path2);
            Application current = Application.Current;

            CanvasTool.SaveCanvas(current.Windows[0], SignPad, 96, text2);
            MouseTool.ShowLoading();
            if (UserID.Equals("guest"))
            {
                UserID_Origin = UserID;
                UserID        = "";
            }
            else if (UserID.Equals("dept"))
            {
                UserID_Origin = UserID;
                UserID        = "";
            }
            GetSigninDataUpload.AsyncPOST(MeetingID, UserID, DeptID, text2, new Action <SigninDataUpload>(_003CbtnYes_MouseDown_003Eb__1f));
        }
예제 #2
0
        private void btnYes_MouseDown(object sender, MouseButtonEventArgs e)
        {
            //if (StackLines.Count < 1 || txtPLS.Visibility == Visibility.Visible)
            if (SignPad.Strokes.Count < 1 || txtPLS.Visibility == Visibility.Visible)
            {
                if (PicUrl.Equals("") == false)
                {
                    MessageBox.Show("已簽名,欲重新簽名請先按x清除");
                    return;
                }
                else
                {
                    MessageBox.Show("請簽名後上傳");
                    return;
                }
            }


            string    AllowIpRange = "";
            DataTable dt           = MSCE.GetDataTable("select AllowIpRange from NowLogin");

            if (dt.Rows.Count > 0)
            {
                AllowIpRange = dt.Rows[0]["AllowIpRange"].ToString();
            }
            if (PaperLess_Emeeting.Properties.Settings.Default.HasIpRangeMode == true && AllowIpRange.Equals("") == false && IpTool.CheckInNowWifi(AllowIpRange) == false)
            {
                string CourseOrMeeting_String = PaperLess_Emeeting.Properties.Settings.Default.CourseOrMeeting_String;
                AutoClosingMessageBox.Show(string.Format("您不在{0}室範圍內,無法使用此功能", CourseOrMeeting_String.Equals("課程") ? "教" : CourseOrMeeting_String));
                return;
            }

            // 系統暫存資料夾
            //string tempPath = System.IO.Path.GetTempPath(); //Environment.GetEnvironmentVariable("TEMP");
            string SignInFolder = System.IO.Path.Combine(ClickOnceTool.GetFilePath(), PaperLess_Emeeting.Properties.Settings.Default.SignInFolder);

            SignInFolder = System.IO.Path.Combine(SignInFolder, MeetingID, UserID);
            Directory.CreateDirectory(SignInFolder);
            string      GUID         = Guid.NewGuid().ToString();
            string      tempFileName = GUID + ".png";
            string      filePath     = System.IO.Path.Combine(SignInFolder, tempFileName);
            Application app          = Application.Current;

            //(1) Canvas
            CanvasTool.SaveCanvas(app.Windows[0], this.SignPad, 96, filePath);

            //(2) InkCanvas
            //double width = SignPad.ActualWidth;
            //double height = SignPad.ActualHeight;
            //RenderTargetBitmap bmpCopied = new RenderTargetBitmap((int)Math.Round(width), (int)Math.Round(height), 96, 96, PixelFormats.Default);
            //DrawingVisual dv = new DrawingVisual();
            //using (DrawingContext dc = dv.RenderOpen())
            //{
            //    VisualBrush vb = new VisualBrush(SignPad);
            //    dc.DrawRectangle(vb, null, new Rect(new System.Windows.Point(), new System.Windows.Size(width, height)));
            //}
            //bmpCopied.Render(dv);
            //System.Drawing.Bitmap bitmap;
            //using (MemoryStream outStream = new MemoryStream())
            //{
            //    // from System.Media.BitmapImage to System.Drawing.Bitmap
            //    BitmapEncoder enc = new BmpBitmapEncoder();
            //    enc.Frames.Add(BitmapFrame.Create(bmpCopied));
            //    enc.Save(outStream);
            //    bitmap = new System.Drawing.Bitmap(outStream);
            //}

            //EncoderParameter qualityParam =new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 85L);

            //// Jpeg image codec
            //ImageCodecInfo jpegCodec = getEncoderInfo("image/jpeg");

            //if (jpegCodec == null)
            //    return;

            //EncoderParameters encoderParams = new EncoderParameters(1);
            //encoderParams.Param[0] = qualityParam;
            //Bitmap btm = new Bitmap(bitmap);
            //bitmap.Dispose();
            //btm.Save(filePath, jpegCodec, encoderParams);
            //btm.Dispose();

            //SigninDataUpload sdu = GetSigninDataUpload.POST(MeetingID, "UserID", filePath);
            MouseTool.ShowLoading();

            if (UserID.Equals("guest") == true)
            {
                UserID_Origin = UserID;
                UserID        = "";
            }
            else if (UserID.Equals("dept") == true)
            {
                UserID_Origin = UserID;
                UserID        = "";
            }
            GetSigninDataUpload.AsyncPOST(MeetingID, UserID, DeptID, filePath, (sdu) => { GetSigninDataUpload_DoAction(sdu); });
        }