public async void CalibrateMagnetometer(MetroWindow window)
        {
            var controller = await window.ShowProgressAsync("Please wait...", "Setting up Magnetometer Calibration.", true);

            await Task.Delay(3000);
            controller.SetTitle("Magnetometer Calibration");
            for (int i = 0; i < 101; i++)
            {
                controller.SetProgress(i / 100.0);
                controller.SetMessage(string.Format("Rotate the controller in all directions: {0}%", i));

                if (controller.IsCanceled) break;
                await Task.Delay(100);
            }
            await controller.CloseAsync();

            if (controller.IsCanceled)
            {
                await window.ShowMessageAsync("Magnetometer Calibration", "Calibration has been cancelled.");
            }
            else
            {
                await window.ShowMessageAsync("Magnetometer Calibration", "Calibration finished successfully.");
            }
        }
Exemplo n.º 2
0
        private async Task <bool> checkFields()
        {
            bool ifAllCorrect = false;

            MahApps.Metro.Controls.MetroWindow window = Window.GetWindow(this) as MahApps.Metro.Controls.MetroWindow;

            if (cmbProducts.SelectedItem == null)
            {
                await window.ShowMessageAsync("Products", "Please select product.");
            }
            else if (string.IsNullOrEmpty(txtQuantity.Text))
            {
                await window.ShowMessageAsync("Quantity", "Please input value.");
            }
            else if (string.IsNullOrEmpty(txtQuantity.Text))
            {
                await window.ShowMessageAsync("Total", "Please input value.");
            }
            else
            {
                ifAllCorrect = true;
            }

            return(ifAllCorrect);
        }
Exemplo n.º 3
0
        private async void loadProductsOnCombo()
        {
            try
            {
                cmbProducts.Items.Clear();
                conDB = new ConnectionDB();
                MongoClient client     = conDB.initializeMongoDB();
                var         db         = client.GetDatabase("DBFH");
                var         collection = db.GetCollection <Products>("Products");

                var filter = Builders <Products> .Filter.And(
                    Builders <Products> .Filter.Where(p => p.isDeleted == false));

                List <Products> lstPayments = collection.Find(filter).ToList();

                foreach (Products p in lstPayments)
                {
                    cmbProducts.Items.Add(p);
                }
            }
            catch (Exception ex)
            {
                await window.ShowMessageAsync("EXCEPTION", "ERROR LOADING DATA " + ex.Message);
            }
        }
		public static async Task<MessageDialogResult> ShowDeleteMultipleGameStatsMessage(MetroWindow window, int count)
		{
			var settings = new MetroDialogSettings {AffirmativeButtonText = "Yes", NegativeButtonText = "No"};
			return
				await
				window.ShowMessageAsync("Delete Games",
				                        "This will delete the selected games (" + count + ").\n\nAre you sure?",
				                        MessageDialogStyle.AffirmativeAndNegative, settings);
		}
		public static async Task<MessageDialogResult> ShowDeleteGameStatsMessage(MetroWindow window, GameStats stats)
		{
			var settings = new MetroDialogSettings {AffirmativeButtonText = "Yes", NegativeButtonText = "No"};
			return
				await
				window.ShowMessageAsync("Delete Game",
				                        stats.Result + " vs " + stats.OpponentHero + "\nfrom " + stats.StartTime + "\n\nAre you sure?",
				                        MessageDialogStyle.AffirmativeAndNegative, settings);
		}
Exemplo n.º 6
0
        public void disconnect()
        {
            ThisWindow.Close();
            MainWindow x = new MainWindow();

            x.Show();
            MahApps.Metro.Controls.MetroWindow wd = Window.GetWindow(x) as MahApps.Metro.Controls.MetroWindow;
            if (wd != null)
            {
                wd.ShowMessageAsync("You were Disconnected ", " You were disconnected and sent back to login Window");
            }
        }
Exemplo n.º 7
0
        private async Task <List <Clients> > loadDataGridDetails()
        {
            List <Clients> lstDS = new List <Clients>();

            conDB = new ConnectionDB();
            try
            {
                MongoClient client     = conDB.initializeMongoDB();
                var         db         = client.GetDatabase("DBFH");
                var         collection = db.GetCollection <Clients>("Clients");
                var         filter     = Builders <Clients> .Filter.And(
                    Builders <Clients> .Filter.Where(p => p.isDeleted == false));

                lstDS = collection.Find(filter).ToList();

                lstDS = lstDS.OrderBy(cc => cc.LastName).ToList();
            }
            catch (Exception ex)
            {
                await window.ShowMessageAsync("ERROR", "Caused by: " + ex.StackTrace);
            }
            return(lstDS);
        }
Exemplo n.º 8
0
		public async Task<object> Execute( MetroWindow window, object args )
		{
			ConfirmationServiceArgs csa = args as ConfirmationServiceArgs;
			Debug.Assert( csa != null );

			MetroDialogSettings settings = new MetroDialogSettings
			{
				AffirmativeButtonText = csa.OkText,
				NegativeButtonText = csa.CancelText
			};

			var result = await window.ShowMessageAsync( csa.Title, csa.Message, MessageDialogStyle.AffirmativeAndNegative, settings );

			return result == MessageDialogResult.Affirmative;
		}
 public async void CallMessageModal(MetroWindow metroWindow, string title, string message)
 {
     var metroDialogSettings = new MetroDialogSettings
     {
         
         CustomResourceDictionary =
             new ResourceDictionary
             {
                 //TODO: Change from default
                 Source = new Uri("pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.MahApps.Dialogs.xaml")
             },
         NegativeButtonText = "CANCEL",
         SuppressDefaultResources = true
     };
     await metroWindow.ShowMessageAsync(title, message, MessageDialogStyle.Affirmative, metroDialogSettings);
 }
Exemplo n.º 10
0
        private async void Btn_overTimeReasonReg_Click(object sender, RoutedEventArgs e)
        {
            ClientConfig cf = InitSetting.CConf;

            MahApps.Metro.Controls.MetroWindow window = Window.GetWindow(this) as MahApps.Metro.Controls.MetroWindow;

            if (txtOverTimeReason.Text.Trim() == "")
            {
                await window.ShowMessageAsync("알림창", "내용을 입력하여 주시기 바랍니다.");
            }
            else
            {
                cf.overtimeReason = txtOverTimeReason.Text.Trim();
                this.Close();
                MainWindow mw = (MainWindow)Application.Current.Windows.OfType <Window>().SingleOrDefault(x => x.IsActive);

                mw.Opacity = 1;
            }
        }
 public async Task<bool> CallAcceptModal(MetroWindow metroWindow, string title, string message)
 {
     var metroDialogSettings = new MetroDialogSettings
     {
         CustomResourceDictionary =
             new ResourceDictionary
             {
                 //TODO: Change from default
                 Source = new Uri("pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.MahApps.Dialogs.xaml")
             },
         AffirmativeButtonText = "OK",
         NegativeButtonText = "CANCEL",
         SuppressDefaultResources = true
     };
     
     MessageDialogResult userChoice =  await metroWindow.ShowMessageAsync(title, message, MessageDialogStyle.AffirmativeAndNegative, metroDialogSettings);
     var result = userChoice == MessageDialogResult.Affirmative;
     return result;
 }
Exemplo n.º 12
0
        private async void CheckIdleTimer_Tick(object sender, System.EventArgs e)
        {
            moveTime.Content = "Total time : " + Win32.GetTickCount().ToString() + "; " + "Last input time : " + Win32.GetLastInputTime().ToString();

            //20분 이석처리시 (1000 -> 1초, 60000 -> 1분)
            if (Win32.GetIdleTime() > 1200000)
            {
                _moveFg = 1;
                Win32.LockWorkStation();
            }
            else
            {
                if (_moveFg == 1)
                {
                    _moveFg = 0;
                    MahApps.Metro.Controls.MetroWindow window = Window.GetWindow(this) as MahApps.Metro.Controls.MetroWindow;
                    if (window != null)
                    {
                        await window.ShowMessageAsync("알림창", "다시 자리로 돌아오셨습니다.");
                    }
                }
            }
        }
Exemplo n.º 13
0
 public void connect()
 {
     if (pass != null && name != null)
     {
         UserSet USER = new UserSet();
         USER = ctx.UserSets.SingleOrDefault(u => u.login == name);
         if (USER != null)
         {
             if (USER.password == pass && (Roles(USER) == 1 || Roles(USER) == 2 || Roles(USER) == 3))
             {
                 acceuil acceuil = new acceuil(USER.profile);
                 acceuil.Show();
                 ThisWindow.Close();
                 MahApps.Metro.Controls.MetroWindow window = Window.GetWindow(acceuil) as MahApps.Metro.Controls.MetroWindow;
                 if (window != null)
                 {
                     DateTime dt = DateTime.Today;
                     string   mt = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(dt.Month);
                     window.ShowMessageAsync("Hello " + USER.login, "It is ' " + dt.DayOfWeek + " the " + dt.Day + " of " + mt + " '. ");
                 }
             }
             else
             {
                 MessageBox.Show("Wrong Pass! Please verify");
             }
         }
         else
         {
             MessageBox.Show("User Doesn't Exist ! Please verify");
         }
     }
     else
     {
         MessageBox.Show("Wrong UserName! Please verify");
     }
 }
Exemplo n.º 14
0
        private async void regWorkData(String workDate, String _sDateTime, String _eDateTime, int sTime, int eTime)
        {
            try
            {
                MahApps.Metro.Controls.MetroWindow window = Window.GetWindow(this) as MahApps.Metro.Controls.MetroWindow;

                ClientConfig cf = InitSetting.CConf;

                //18:00이후 인경우만 처리(저녁)
                int _dinnerTime = 0;
                if (!(bool)cheDinner.IsChecked)
                {
                    if (sTime <= 180000 && eTime > 190000)
                    {
                        _dinnerTime = 60;
                    }
                }

                //12:00이후 인경우만 처리 (점심)
                int _lunchTime = 0;
                if (sTime <= 120000 && eTime > 130000)
                {
                    _lunchTime = 60;
                }

                WorkEntity we = new WorkEntity()
                {
                    id       = cf.userID,
                    workDate = workDate
                };

                String result   = await new CallWebApi().CallPostApiWorks("workInfoFind", we);
                Works  workList = JsonConvert.DeserializeObject <Works>(result);

                //같은 날자에 등록되어 있는 자료가 있음.
                if (workList.workList.Count > 0)
                {
                    var totalWorkHour = workList.workList
                                        .Where(w => (
                                                   (
                                                       (
                                                           double.Parse(w.workTimeS) <= double.Parse(_sDateTime)
                                                           &&
                                                           double.Parse(w.workTimeE) > double.Parse(_sDateTime)
                                                       )
                                                       ||
                                                       (
                                                           double.Parse(w.workTimeS) < double.Parse(_eDateTime)
                                                           &&
                                                           double.Parse(w.workTimeE) >= double.Parse(_eDateTime)
                                                       )
                                                   ) &&
                                                   w.workHour > 0
                                                   )
                                               ).ToList <WorkEntity>();

                    if (totalWorkHour.Count > 0)
                    {
                        //MessageBox.Show("등록된 자료중에 시간이 중복되는 자료가 있습니다.");
                        await window.ShowMessageAsync("알림창", "등록된 자료중에 시간이 중복되는 자료가 있습니다.");

                        return;
                    }
                }

                //저장할 항목
                we.workTimeS  = _sDateTime;
                we.workTimeE  = _eDateTime;
                we.dinnerTime = _dinnerTime;
                we.lunchTime  = _lunchTime;

                DateTime workStart = CDateTime.GetDateFrom_yyyyMMddHHmmss(_sDateTime);
                DateTime workEnd   = CDateTime.GetDateFrom_yyyyMMddHHmmss(_eDateTime);

                TimeSpan TS = new TimeSpan(workEnd.Ticks - workStart.Ticks);

                //총근무시간
                int spanMinute = (int)TS.TotalMinutes - _dinnerTime - _lunchTime;
                we.workHour = spanMinute;

                /*
                 * 야근시간계산법
                 * 야근시간(기본 8시간 근무시)
                 * 18시 이후에 근무하는 것은 기본적으로 야근으로 처리
                 * 주말이나 휴일 근무일 경우 모드 연장근무로 처리
                 */

                int overTime = spanMinute - 480;
                if (sTime >= 180000)
                {
                    overTime = spanMinute;
                }

                var _day = CDateTime.GetDayOfWeekHangul(workStart);

                if ((bool)cheHoly.IsChecked || _day.Equals("토") || _day.Equals("일"))
                {
                    overTime = spanMinute;
                }

                we.workOver = overTime <= 0 ? 0 : overTime;

                //오버타임인데 이유가 없을 경우
                if (overTime > 0 && overTimeReason.Content.ToString().Trim().Length == 0)
                {
                    MainWindow mw = (MainWindow)Application.Current.Windows.OfType <Window>().SingleOrDefault(x => x.IsActive);

                    pop_inputReason popup = new pop_inputReason();
                    popup.Owner = mw;
                    mw.Opacity  = 0.8;
                    popup.ShowDialog();

                    if (cf.overtimeReason.Trim() == "")
                    {
                        await window.ShowMessageAsync("알림창", "야근이유가 등록되지 않았습니다.");

                        return;
                    }
                }

                we.overTimeReason = cf.overtimeReason;

                if (overTime > 0)
                {
                    we.status = "0";
                }
                else
                {
                    we.status = "1";
                }

                //등록처리
                result = await new CallWebApi().CallPostApiWorks("workInfoAdd", we);
                var rtn = JsonConvert.DeserializeObject <Dictionary <string, string> >(result);

                foreach (KeyValuePair <string, string> item in rtn)
                {
                    if (item.Key.Equals("result") && item.Value.Equals("NG"))
                    {
                        if (window != null)
                        {
                            await window.ShowMessageAsync("알림창", "등록에 실패하였습니다. 관리자에게 문의 부탁드립니다.");
                        }
                        break;
                    }
                    else
                    {
                        if (window != null)
                        {
                            if (overTime > 0)
                            {
                                await window.ShowMessageAsync("알림창", "등록었습니다. 야근이 있는 경우 승인 후 야근시간이 반영되어 집니다.");
                            }
                            else
                            {
                                await window.ShowMessageAsync("알림창", "등록되었습니다.");
                            }
                        }
                        break;
                    }
                }
                GetList();
                cf.overtimeReason = "";
            }
            catch { }
        }
Exemplo n.º 15
0
        private async void regWorkData(String workDate, String _sDateTime, String _eDateTime)
        {
            try
            {
                MahApps.Metro.Controls.MetroWindow window = Window.GetWindow(this) as MahApps.Metro.Controls.MetroWindow;

                ClientConfig cf = InitSetting.CConf;

                //18:00이후 인경우만 처리(저녁)
                int _dinnerTime = 0;

                //12:00이후 인경우만 처리 (점심)
                int _lunchTime = 0;

                WorkEntity we = new WorkEntity()
                {
                    id       = cf.userID,
                    workDate = workDate
                };

                //저장할 항목
                we.workTimeS  = _sDateTime;
                we.workTimeE  = _eDateTime;
                we.dinnerTime = _dinnerTime;
                we.lunchTime  = _lunchTime;

                DateTime workStart = CDateTime.GetDateFrom_yyyyMMddHHmmss(_sDateTime);
                DateTime workEnd   = CDateTime.GetDateFrom_yyyyMMddHHmmss(_eDateTime);

                TimeSpan TS = new TimeSpan(workEnd.Ticks - workStart.Ticks);

                //총근무시간
                int spanMinute = (int)TS.TotalMinutes - _dinnerTime - _lunchTime;
                we.workHour = 0;

                //야근시간
                int overTime = spanMinute * -1;
                we.workOver = overTime;

                we.overTimeReason = vacationReason.Text;
                we.status         = "0";

                //등록처리
                String result = await new CallWebApi().CallPostApiWorks("workInfoAdd", we);
                var    rtn    = JsonConvert.DeserializeObject <Dictionary <string, string> >(result);

                foreach (KeyValuePair <string, string> item in rtn)
                {
                    if (item.Key.Equals("result") && item.Value.Equals("NG"))
                    {
                        if (window != null)
                        {
                            await window.ShowMessageAsync("알림창", "등록에 실패하였습니다. 관리자에게 문의 부탁드립니다.");
                        }
                        break;
                    }
                    else
                    {
                        if (window != null)
                        {
                            await window.ShowMessageAsync("알림창", "등록었습니다. 승인 후 시간이 반영되어 집니다.");
                        }
                        break;
                    }
                }
                GetList();
                cf.overtimeReason = "";
            }
            catch { }
        }
        public async void StartMagnetometerCalibrationTask(MetroWindow window)
        {
            CancelUpdateTask();
            _ctsMagnetometerCalibration = new CancellationTokenSource();
            var controller = await window.ShowProgressAsync("Magnetometer Calibration", null, true);
            CancellationToken token = _ctsMagnetometerCalibration.Token;
            try
            {
                await Task.Run(() =>
                {
                    PsMoveApi.psmove_reset_magnetometer_calibration(_motionController.Handle);
                    int oldRange = 0;
                    bool calibrationFinished = false;
                    Color color = _motionController.Color;
                    while (!token.IsCancellationRequested && !calibrationFinished)
                    {
                        while (PsMoveApi.psmove_poll(_motionController.Handle) > 0)
                        {
                            float ax, ay, az;
                            PsMoveApi.psmove_get_magnetometer_vector(_motionController.Handle, out ax, out ay, out az);

                            int range = PsMoveApi.psmove_get_magnetometer_calibration_range(_motionController.Handle);
                            MagnetometerCalibrationProgress = 100*range/320;
                            if (MagnetometerCalibrationProgress > 100) MagnetometerCalibrationProgress = 100;
                            else if (MagnetometerCalibrationProgress < 0) MagnetometerCalibrationProgress = 0;
                            controller.SetProgress(MagnetometerCalibrationProgress/100.0);

                            float r = (color.r/100)*MagnetometerCalibrationProgress;
                            float g = (color.g/100)*MagnetometerCalibrationProgress;
                            float b = (color.b/100)*MagnetometerCalibrationProgress;
                            SetLED(new Color(r, g, b));
                            PsMoveApi.psmove_update_leds(_motionController.Handle);

                            if (controller.IsCanceled)
                            {
                                CancelMagnetometerCalibrationTask();
                            }

                            if (range >= 320)
                            {
                                if (oldRange > 0)
                                {
                                    PsMoveApi.psmove_save_magnetometer_calibration(_motionController.Handle);
                                    calibrationFinished = true;
                                    break;
                                }
                            }
                            else if (range > oldRange)
                            {
                                controller.SetMessage(string.Format("Rotate the controller in all directions: {0}%...",
                                    MagnetometerCalibrationProgress));
                                oldRange = range;
                            }
                        }
                    }
                });
            }
            catch (OperationCanceledException)
            {

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }

            await controller.CloseAsync();
            if (controller.IsCanceled)
            {
                await window.ShowMessageAsync("Magnetometer Calibration", "Calibration has been cancelled.");
            }
            else
            {
                await window.ShowMessageAsync("Magnetometer Calibration", "Calibration finished successfully.");
            }
        }
Exemplo n.º 17
0
        private async void regWorkData(String workDate, String _sDateTime, String _eDateTime, int sTime, int eTime)
        {
            try
            {
                MahApps.Metro.Controls.MetroWindow window = Window.GetWindow(this) as MahApps.Metro.Controls.MetroWindow;

                ClientConfig cf = InitSetting.CConf;

                //18:00이후 인경우만 처리(저녁)
                int _dinnerTime = 0;

                if (sTime <= 180000 && eTime > 190000)
                {
                    _dinnerTime = 60;
                }

                //12:00이후 인경우만 처리 (점심)
                int _lunchTime = 0;
                if (sTime <= 120000 && eTime > 130000)
                {
                    _lunchTime = 60;
                }

                WorkEntity we = new WorkEntity()
                {
                    id       = cf.userID,
                    workDate = workDate
                };

                String result   = await new CallWebApi().CallPostApiWorks("workInfoFind", we);
                Works  workList = JsonConvert.DeserializeObject <Works>(result);

                //같은 날자에 등록되어 있는 자료가 있음.
                if (workList.workList.Count > 0)
                {
                    var totalWorkHour = workList.workList
                                        .Where(w => (
                                                   (
                                                       double.Parse(w.workTimeS) <= double.Parse(_sDateTime)
                                                       &&
                                                       double.Parse(w.workTimeE) > double.Parse(_sDateTime)
                                                   )
                                                   ||
                                                   (
                                                       double.Parse(w.workTimeS) < double.Parse(_eDateTime)
                                                       &&
                                                       double.Parse(w.workTimeE) >= double.Parse(_eDateTime)
                                                   )
                                                   )
                                               ).ToList <WorkEntity>();

                    if (totalWorkHour.Count > 0)
                    {
                        MessageBox.Show("등록된 자료중에 시간이 중복되는 자료가 있습니다.");
                        return;
                    }
                }

                //저장할 항목
                we.workTimeS  = _sDateTime;
                we.workTimeE  = _eDateTime;
                we.dinnerTime = _dinnerTime;
                we.lunchTime  = _lunchTime;

                DateTime workStart = CDateTime.GetDateFrom_yyyyMMddHHmmss(_sDateTime);
                DateTime workEnd   = CDateTime.GetDateFrom_yyyyMMddHHmmss(_eDateTime);

                TimeSpan TS = new TimeSpan(workEnd.Ticks - workStart.Ticks);

                //총근무시간
                int spanMinute = (int)TS.TotalMinutes - _dinnerTime - _lunchTime;
                we.workHour = spanMinute;

                //야근시간
                int overTime = spanMinute - 480;
                we.workOver = overTime <= 0 ? 0 : overTime;

                if (overTime > 0)
                {
                    we.status = "0";
                }
                else
                {
                    we.status = "1";
                }

                //등록처리
                result = await new CallWebApi().CallPostApiWorks("workInfoAdd", we);
                var rtn = JsonConvert.DeserializeObject <Dictionary <string, string> >(result);

                foreach (KeyValuePair <string, string> item in rtn)
                {
                    if (item.Key.Equals("result") && item.Value.Equals("NG"))
                    {
                        if (window != null)
                        {
                            this.Show();
                            await window.ShowMessageAsync("알림창", "등록에 실패하였습니다. 관리자에게 문의 부탁드립니다.");
                        }
                        break;
                    }
                    else
                    {
                        if (window != null)
                        {
                            if (overTime > 0)
                            {
                                this.Show();
                                cf.workStatus = "0";
                                await window.ShowMessageAsync("알림창", "등록었습니다. 야근이 있는 경우 승인 후 야근시간이 반영되어 집니다.");
                            }
                            else
                            {
                                cf.workStatus = "0";
                                _uc_dashboard = new uc_DashBoard();
                                uc_Class.Uc_Link(Contents_Border, _uc_dashboard);
                            }
                        }
                        break;
                    }
                }
                cf.overtimeReason = "";
            }
            catch
            {
            }
        }