Esempio n. 1
0
        private void InitUI()
        {
            Action    action    = null;
            DataTable dataTable = MSCE.GetDataTable("select UserID,UserName,MeetingID from NowLogin");

            if (dataTable.Rows.Count > 0)
            {
                if (UserID.Equals(""))
                {
                    FromIndividualSign = true;
                    UserID             = dataTable.Rows[0]["UserID"].ToString();
                    UserName           = dataTable.Rows[0]["UserName"].ToString();
                }
                else
                {
                    FromIndividualSign = false;
                    btnBack.Visibility = Visibility.Visible;
                }
                MeetingID    = dataTable.Rows[0]["MeetingID"].ToString();
                txtName.Text = UserName + " 您好";
            }
            if (!PicUrl.Equals(""))
            {
                txtPLS.Visibility            = Visibility.Collapsed;
                SignPadPanel.Visibility      = Visibility.Collapsed;
                imgSignedPicPanel.Visibility = Visibility.Visible;
                TaskFactory factory = Task.Factory;
                if (action == null)
                {
                    action = new Action(_003CInitUI_003Eb__20);
                }
                factory.StartNew(action);
            }
            if (Settings.Default.EnableSignOut && FromIndividualSign)
            {
                btnSignOut.Visibility = Visibility.Visible;
                if (PicUrl.Equals(""))
                {
                    FormatConvertedBitmap formatConvertedBitmap = new FormatConvertedBitmap();
                    formatConvertedBitmap.BeginInit();
                    formatConvertedBitmap.Source            = (BitmapSource)imgSignOut.Source;
                    formatConvertedBitmap.DestinationFormat = PixelFormats.Gray32Float;
                    formatConvertedBitmap.EndInit();
                    imgSignOut.Source     = formatConvertedBitmap;
                    txtSignOut.Foreground = Brushes.Gray;
                    btnSignOut.ToolTip    = "您尚未簽到,無法簽退";
                    btnSignOut.IsEnabled  = false;
                    btnSignOut.Visibility = Visibility.Hidden;
                }
                else
                {
                    btnSignOut.Visibility = Visibility.Visible;
                }
            }
        }
Esempio n. 2
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));
        }
Esempio n. 3
0
 private void _003CInitEvent_003Eb__6(object sender, MouseButtonEventArgs e)
 {
     if (!PicUrl.Equals("") || StackLines.Count > 0)
     {
         MessageBoxResult messageBoxResult = MessageBox.Show("是否要清除簽名檔", "系統訊息", MessageBoxButton.OKCancel);
         if (messageBoxResult == MessageBoxResult.Cancel)
         {
             return;
         }
         PicUrl = "";
     }
     imgSignedPicPanel.Visibility = Visibility.Collapsed;
     txtPLS.Visibility            = Visibility.Visible;
     SignPadPanel.Visibility      = Visibility.Visible;
     SignPad.Children.Clear();
     StackLines.Clear();
 }
Esempio n. 4
0
        private void InitUI()
        {
            DrawingAttributes da = new DrawingAttributes();

            da.Width  = 7;
            da.Height = 7;
            SignPad.DefaultDrawingAttributes = da;

            // 這裡因為要判斷btnBack.Visibility = Visibility.Visible;
            // 所以把DB查詢邏輯放到這裡。
            DataTable dt = MSCE.GetDataTable("select UserID,UserName,MeetingID from NowLogin");

            if (dt.Rows.Count > 0)
            {
                if (UserID.Equals("") == true)
                {
                    FromIndividualSign = true;
                    UserID             = dt.Rows[0]["UserID"].ToString();
                    UserName           = dt.Rows[0]["UserName"].ToString();
                }
                else
                {
                    FromIndividualSign = false;
                    btnBack.Visibility = Visibility.Visible;
                }
                MeetingID    = dt.Rows[0]["MeetingID"].ToString();
                txtName.Text = UserName + " 您好";
            }

            if (PicUrl.Equals("") == false)
            {
                txtPLS.Visibility            = Visibility.Collapsed;
                SignPadPanel.Visibility      = Visibility.Collapsed;
                imgSignedPicPanel.Visibility = Visibility.Visible;

                Task.Factory.StartNew(() =>
                {
                    try
                    {
                        var webClient         = new WebClient();
                        webClient.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.Revalidate);
                        var buffer            = webClient.DownloadData(PicUrl);
                        var bitmapImage       = new BitmapImage();

                        using (var stream = new MemoryStream(buffer))
                        {
                            //初始化圖片到記憶體
                            bitmapImage.BeginInit();
                            bitmapImage.CacheOption  = BitmapCacheOption.OnLoad;
                            bitmapImage.StreamSource = stream;
                            bitmapImage.EndInit();
                            bitmapImage.Freeze();
                        }

                        //this.Dispatcher.BeginInvoke((Action)(() => imgSignedPic.Source = bitmapImage));

                        this.Dispatcher.BeginInvoke((Action)(() =>
                        {
                            if (sb != null)
                            {
                                sb.Stop();
                            }
                            imgSignedPic.Source = bitmapImage;
                        }));
                    }
                    catch (Exception ex)
                    {
                        LogTool.Debug(ex);
                    }
                });
            }

            if (PaperLess_Emeeting.Properties.Settings.Default.EnableSignOut == true && FromIndividualSign == true)
            {
                btnSignOut.Visibility = Visibility.Visible;

                //沒有簽到過,簽退圖示反灰
                if (PicUrl.Equals("") == true)
                {
                    FormatConvertedBitmap newFormatedBitmapSource = new FormatConvertedBitmap();

                    // BitmapSource objects like FormatConvertedBitmap can only have their properties
                    // changed within a BeginInit/EndInit block.
                    newFormatedBitmapSource.BeginInit();

                    // Use the BitmapSource object defined above as the source for this new
                    // BitmapSource (chain the BitmapSource objects together).
                    newFormatedBitmapSource.Source = (BitmapSource)imgSignOut.Source;

                    // Set the new format to Gray32Float (grayscale).
                    newFormatedBitmapSource.DestinationFormat = PixelFormats.Gray32Float;
                    newFormatedBitmapSource.EndInit();

                    imgSignOut.Source     = newFormatedBitmapSource;
                    txtSignOut.Foreground = System.Windows.Media.Brushes.Gray;
                    btnSignOut.ToolTip    = "您尚未簽到,無法簽退";
                    btnSignOut.IsEnabled  = false;
                    btnSignOut.Visibility = Visibility.Hidden;
                }
                else
                {
                    btnSignOut.Visibility = Visibility.Visible;
                }
            }
        }
Esempio n. 5
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); });
        }
Esempio n. 6
0
        private void InitEvent()
        {
            Home Home_Window = Application.Current.Windows.OfType <Home>().FirstOrDefault();

            if (Home_Window != null)
            {
                Home_Window.KeyDown += Home_Window_KeyDown;
            }

            btnYes.MouseEnter += (sender, e) => { MouseTool.ShowHand(); };
            btnYes.MouseLeave += (sender, e) => { MouseTool.ShowArrow(); };
            btnYes.MouseDown  += btnYes_MouseDown;

            btnNO.MouseEnter += (sender, e) => { MouseTool.ShowHand(); };
            btnNO.MouseLeave += (sender, e) => { MouseTool.ShowArrow(); };
            btnNO.MouseDown  += (sender, e) =>
            {
                if (PicUrl.Equals("") == false || StackLines.Count > 0)
                {
                    MessageBoxResult result = MessageBox.Show("是否要清除簽名檔", "系統訊息", MessageBoxButton.OKCancel);

                    if (result == MessageBoxResult.Cancel)
                    {
                        return;
                    }
                    PicUrl = "";
                }
                imgSignedPicPanel.Visibility = Visibility.Collapsed;
                txtPLS.Visibility            = Visibility.Visible;
                SignPadPanel.Visibility      = Visibility.Visible;
                SignPad.Children.Clear();
                SignPad.Strokes.Clear();
                StackLines.Clear();
            };

            btnBack.MouseEnter          += (sender, e) => { MouseTool.ShowHand(); };
            btnBack.MouseLeave          += (sender, e) => { MouseTool.ShowArrow(); };
            btnBack.MouseLeftButtonDown += (sender, e) => { Home_GoBackTogSignPictureCT_Event("", ""); };

            SignPad.MouseEnter += (sender, e) => { MouseTool.ShowPen(); };
            SignPad.MouseLeave += (sender, e) => { MouseTool.ShowArrow(); };
            //SignPad.MouseDown += SignPad_MouseDown;
            //SignPad.MouseMove += SignPad_MouseMove;
            //SignPad.MouseUp += SignPad_MouseUp;
            SignPad.PreviewMouseLeftButtonDown += (sender, e) =>
            {
                txtPLS.Visibility = Visibility.Collapsed;
            };



            imgSignedPicPanel.MouseEnter += (sender, e) => { MouseTool.ShowPen(); };
            imgSignedPicPanel.MouseLeave += (sender, e) => { MouseTool.ShowArrow(); };
            imgSignedPicPanel.PreviewMouseLeftButtonDown += (sender, e) =>
                                                            //imgSignedPicPanel.MouseLeftButtonDown += (sender, e) =>
            {
                imgSignedPicPanel.Visibility = Visibility.Collapsed;
                txtPLS.Visibility            = Visibility.Visible;
                SignPadPanel.Visibility      = Visibility.Visible;
            };

            btnSignOut.MouseEnter          += (sender, e) => { MouseTool.ShowHand(); };
            btnSignOut.MouseLeave          += (sender, e) => { MouseTool.ShowArrow(); };
            btnSignOut.MouseLeftButtonDown += (sender, e) =>
            {
                MessageBoxResult result = MessageBox.Show("您確定要簽退?", "系統訊息", MessageBoxButton.YesNo);
                if (result != MessageBoxResult.Yes)
                {
                    return;
                }

                MouseTool.ShowLoading();

                GetSignOutUpload.AsyncPOST(MeetingID, DeptID, UserID, (so) => { GetSignOutUpload_DoAction(so); });
            };
        }