Esempio n. 1
0
 public AdminPassword(MainWindow mw, LockWindow lw, globalKeyboardHook hook)
 {
     InitializeComponent();
     _mainwindow = mw;
     _lockwindow = lw;
     hook.unhook();
 }
Esempio n. 2
0
        private void metroButton_logoff_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are your sure you want to close your session ?\n\nNote :- All print job's will be cancelled.", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.Yes)
            {
                try
                {
                    if (mysession.StopSession("Session Close By User", null))
                    {
                        LockWindow lw = new LockWindow(mycomputer, mainwind);
                        lw.Show();
                        server.Stop();
                        backgroundWorker1.CancelAsync();
                        this.Close();
                    }

                    else
                    {
                        MessageBox.Show("Some thing went wrong while closing your session !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 3
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            hour = Convert.ToInt32(label_hour.Text);
            min  = Convert.ToInt32(label_minute.Text);
            sec  = Convert.ToInt32(label_second.Text);

            if (min == 59 && sec == 59)
            {
                label_hour.Text   = (hour + 1).ToString("00");
                label_minute.Text = "00";
                label_second.Text = "00";
                min     = 0;
                sec     = 0;
                isenter = true;
            }

            else if (sec == 59)
            {
                label_minute.Text = (min + 1).ToString("00");
                label_second.Text = "00";
                sec     = 0;
                isenter = true;
            }
            else
            {
                isenter = false;
            }


            if (!isenter)
            {
                label_second.Text = (sec + 1).ToString("00");
            }

            if (isdisconnect)
            {
                try
                {
                    // close the form on the forms thread
                    LockWindow lw = new LockWindow(mycomputer, mainwind);
                    lw.Show();
                    server.Stop();
                    backgroundWorker1.CancelAsync();
                    MiscClass.SetConfigValue("ActiveSession", mysession.Id.ToString() + "{{Session}}" + DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss"));
                    this.Close();
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            label_pagesprinted_value.Text = pagescount;
        }
Esempio n. 4
0
        private void button_start_Click(object sender, EventArgs e)
        {
            try
            {
                if (pc != null)
                {
                    if (MiscClass.CheckNetworkAvailablity(adapter_public, ip_public))
                    {
                        if (checkBox_monitorprocess.Checked)
                        {
                            is_monitorable_public = "Yes";
                        }

                        else
                        {
                            is_monitorable_public = "No";
                        }

                        if (!GetConfigValue("LogPath").Equals(""))
                        {
                            if (Directory.Exists(GetConfigValue("LogPath")))
                            {
                                LockWindow lw = new LockWindow(pc, this);
                                lw.Show();
                                this.Visible       = false;
                                this.ShowInTaskbar = false;
                            }
                            else
                            {
                                MessageBox.Show("LogPath directory is not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }

                        else
                        {
                            MessageBox.Show("LogPath is not set.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 5
0
        private void MainWindow_Load(object sender, EventArgs e)
        {
            try
            {
                toolTip_startbutton.SetToolTip(button_start, "Start session lock");
                var    adapters = NetworkInterface.GetAllNetworkInterfaces();
                string ip       = "";
                foreach (var adapter in adapters)
                {
                    if (adapter.OperationalStatus == OperationalStatus.Down)
                    {
                        ip = "0.0.0.0";
                    }

                    else
                    {
                        ip = adapter.GetIPProperties().UnicastAddresses.Where(x => x.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).Select(y => y.Address.ToString()).SingleOrDefault();
                    }

                    listBox_adapters.Items.Add(adapter.Name + "  -  (" + ip + ")");
                }

                System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

                if (config.AppSettings.Settings["Adapter"] != null)
                {
                    foreach (object ob in listBox_adapters.Items)
                    {
                        if (ob.ToString().StartsWith(config.AppSettings.Settings["Adapter"].Value.Split(new string[] { "  -  (" }, StringSplitOptions.None)[0]))
                        {
                            listBox_adapters.SelectedItem = ob;
                            break;
                        }
                    }


                    ip = listBox_adapters.SelectedItem.ToString().Split(new string[] { "  -  (" }, StringSplitOptions.None)[1].Split(')')[0];
                    label_ip_value.Text = ip;


                    pc = Computer.GetComputerByIp(ip);

                    if (pc != null)
                    {
                        label_pcname_value.Text = pc.PcName;
                    }
                }


                if (config.AppSettings.Settings["MonitorCheck"] != null)
                {
                    if (config.AppSettings.Settings["MonitorCheck"].Value.Equals("Yes"))
                    {
                        checkBox_monitorprocess.Checked = true;
                        is_monitorable_public           = "Yes";
                    }

                    else
                    {
                        checkBox_monitorprocess.Checked = false;
                        is_monitorable_public           = "No";
                    }
                }

                else
                {
                    is_monitorable_public = "No";
                }


                label_logpath_value.Text = GetConfigValue("LogPath").Equals("")?"Not Available":GetConfigValue("LogPath");

                if (!label_pcname_value.Text.Equals("Not Available"))
                {
                    button_start.Enabled = true;

                    if (config.AppSettings.Settings["Autostart"] != null)
                    {
                        if (config.AppSettings.Settings["Autostart"].Value.Equals("Yes"))
                        {
                            if (!label_logpath_value.Text.Equals("Not Available"))
                            {
                                if (Directory.Exists(label_logpath_value.Text))
                                {
                                    LockWindow lw = new LockWindow(pc, this);
                                    lw.Show();
                                    this.Visible       = false;
                                    this.ShowInTaskbar = false;
                                }
                            }
                        }
                    }
                }

                if (config.AppSettings.Settings["Autostart"] != null)
                {
                    if (config.AppSettings.Settings["Autostart"].Value.Equals("Yes"))
                    {
                        checkBox_autostart.Checked = true;
                    }

                    else
                    {
                        checkBox_autostart.Checked = false;
                    }
                }

                adapter_public = config.AppSettings.Settings["Adapter"].Value.Split(new string[] { "  -  (" }, StringSplitOptions.None)[0];
                ip_public      = label_ip_value.Text;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 6
0
        private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            try {
                if (e.UserState != null)
                {
                    if (e.UserState.ToString().StartsWith("Command:"))
                    {
                        if (e.UserState.ToString().Split(':').Count() > 0)
                        {
                            if (e.UserState.ToString().Split(':')[1].Equals("Pause"))
                            {
                                if (mysession.PauseSession(e.UserState.ToString().Split(':').Count() >= 3 ? e.UserState.ToString().Split(':')[2] : "Session Pause By Employee", e.UserState.ToString().Split(':').Count() >= 4 ? HelpingClass.IsNumeric(e.UserState.ToString().Split(':')[3]) ? e.UserState.ToString().Split(':')[3] : 0.ToString() : null))
                                {
                                    LockWindow lw = new LockWindow(mycomputer, mainwind, e.UserState.ToString().Split(':').Count() == 5 ? e.UserState.ToString().Split(':')[4] : "");
                                    lw.Show();
                                    server.Stop();
                                    backgroundWorker1.CancelAsync();
                                    this.Close();
                                }

                                else
                                {
                                    MessageBox.Show("Some thing went wrong while pausing your session by employee !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }

                            else if (e.UserState.ToString().Split(':')[1].Equals("Stop"))
                            {
                                if (mysession.StopSession(e.UserState.ToString().Split(':').Count() >= 3 ? e.UserState.ToString().Split(':')[2] : "Session Close By Employee", e.UserState.ToString().Split(':').Count() >= 4 ? HelpingClass.IsNumeric(e.UserState.ToString().Split(':')[3]) ? e.UserState.ToString().Split(':')[3] : 0.ToString() : null))
                                {
                                    LockWindow lw = new LockWindow(mycomputer, mainwind, e.UserState.ToString().Split(':').Count() == 5 ? e.UserState.ToString().Split(':')[4] : "");
                                    lw.Show();
                                    server.Stop();
                                    backgroundWorker1.CancelAsync();
                                    this.Close();
                                }

                                else
                                {
                                    MessageBox.Show("Some thing went wrong while closing your session by employee !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }


                            else if (e.UserState.ToString().Split(':')[1].Equals("StopShutdown"))
                            {
                                if (mysession.StopSession(e.UserState.ToString().Split(':').Count() >= 3 ? e.UserState.ToString().Split(':')[2] : "Session Close By Employee", e.UserState.ToString().Split(':').Count() >= 4 ? HelpingClass.IsNumeric(e.UserState.ToString().Split(':')[3]) ? e.UserState.ToString().Split(':')[3] : 0.ToString() : null))
                                {
                                    var psi = new ProcessStartInfo("shutdown", "/s /f /t 30");
                                    psi.CreateNoWindow  = true;
                                    psi.UseShellExecute = false;
                                    Process.Start(psi);

                                    LockWindow lw = new LockWindow(mycomputer, mainwind, e.UserState.ToString().Split(':').Count() == 5 ? e.UserState.ToString().Split(':')[4] : "");
                                    lw.Show();
                                    server.Stop();
                                    backgroundWorker1.CancelAsync();
                                    this.Close();
                                }

                                else
                                {
                                    MessageBox.Show("Some thing went wrong while closing your session by employee !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }


                            else if (e.UserState.ToString().Split(':')[1].Equals("PauseShutdown"))
                            {
                                if (mysession.PauseSession(e.UserState.ToString().Split(':').Count() >= 3 ? e.UserState.ToString().Split(':')[2] : "Session Pause By Employee", e.UserState.ToString().Split(':').Count() >= 4 ? HelpingClass.IsNumeric(e.UserState.ToString().Split(':')[3]) ? e.UserState.ToString().Split(':')[3] : 0.ToString() : null))
                                {
                                    var psi = new ProcessStartInfo("shutdown", "/s /f /t 30");
                                    psi.CreateNoWindow  = true;
                                    psi.UseShellExecute = false;
                                    Process.Start(psi);

                                    LockWindow lw = new LockWindow(mycomputer, mainwind, e.UserState.ToString().Split(':').Count() == 5 ? e.UserState.ToString().Split(':')[4] : "");
                                    lw.Show();
                                    server.Stop();
                                    backgroundWorker1.CancelAsync();
                                    this.Close();
                                }

                                else
                                {
                                    MessageBox.Show("Some thing went wrong while pausing your session by employee !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }

                            else if (e.UserState.ToString().Split(':')[1].Equals("StopRestart"))
                            {
                                if (mysession.StopSession(e.UserState.ToString().Split(':').Count() >= 3 ? e.UserState.ToString().Split(':')[2] : "Session Close By Employee", e.UserState.ToString().Split(':').Count() >= 4 ? HelpingClass.IsNumeric(e.UserState.ToString().Split(':')[3]) ? e.UserState.ToString().Split(':')[3] : 0.ToString() : null))
                                {
                                    var psi = new ProcessStartInfo("shutdown", "/r /f /t 30");
                                    psi.CreateNoWindow  = true;
                                    psi.UseShellExecute = false;
                                    Process.Start(psi);

                                    LockWindow lw = new LockWindow(mycomputer, mainwind, e.UserState.ToString().Split(':').Count() == 5 ? e.UserState.ToString().Split(':')[4] : "");
                                    lw.Show();
                                    server.Stop();
                                    backgroundWorker1.CancelAsync();
                                    this.Close();
                                }

                                else
                                {
                                    MessageBox.Show("Some thing went wrong while closing your session by employee !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }

                            else if (e.UserState.ToString().Split(':')[1].Equals("PauseRestart"))
                            {
                                if (mysession.PauseSession(e.UserState.ToString().Split(':').Count() >= 3 ? e.UserState.ToString().Split(':')[2] : "Session Pause By Employee", e.UserState.ToString().Split(':').Count() >= 4 ? HelpingClass.IsNumeric(e.UserState.ToString().Split(':')[3]) ? e.UserState.ToString().Split(':')[3] : 0.ToString() : null))
                                {
                                    var psi = new ProcessStartInfo("shutdown", "/r /f /t 30");
                                    psi.CreateNoWindow  = true;
                                    psi.UseShellExecute = false;
                                    Process.Start(psi);

                                    LockWindow lw = new LockWindow(mycomputer, mainwind, e.UserState.ToString().Split(':').Count() == 5 ? e.UserState.ToString().Split(':')[4] : "");
                                    lw.Show();
                                    server.Stop();
                                    backgroundWorker1.CancelAsync();
                                    this.Close();
                                }

                                else
                                {
                                    MessageBox.Show("Some thing went wrong while pausing your session by employee !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }

                            else
                            {
                                MessageBox.Show("Invalid Command", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }

                        else
                        {
                            MessageBox.Show(e.UserState.ToString(), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }

                    else if (e.UserState.ToString().StartsWith("Message:"))
                    {
                        MessageBox.Show(e.UserState.ToString().Split(':')[1], "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                    else
                    {
                        if (!e.UserState.ToString().EndsWith("WSACancelBlockingCall"))
                        {
                            MessageBox.Show(e.UserState.ToString());
                        }
                    }
                }
            }

            catch (Exception ex) {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }