Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            CustomForm form = new CustomForm();

            // 모달리스 form창 생성 (새로운 화면이 열려도 기존에 있던 화면 조작 가능)
            form.Show();

            // 모달 form창 생성 (새로운 화면을 띄웠을 때 기존 화면 조작 불가능)
            form.ShowDialog();
        }
Exemplo n.º 2
0
 /// <summary>
 /// 显示自定义窗体
 /// </summary>
 /// <param name="control">显示的视图</param>
 /// <param name="showInTaskbar">是否在任务栏上显示图标</param>
 /// <param name="close">关闭窗口的回调</param>
 /// <returns>返回DialogResult</returns>
 public static DialogResult ShowForm(UserControl control, bool showInTaskbar, CloseFormHandle close)
 {
     using (CustomForm newForm = new CustomForm(control, showInTaskbar, close))
     {
         DialogResult res = newForm.ShowDialog();
         ////如过关闭窗口释放资源
         //if (res == DialogResult.Cancel)
         //{
         //    newForm.Dispose();
         //}
         return(res);
     }
 }
Exemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            /*MessageBox.Show("hello");
             * MessageBox.Show("Hodu","안녕하세요");
             * MessageBox.Show("Deuk", "안뇽하세요", MessageBoxButtons.RetryCancel);*/
            /*DialogResult result;
             * do
             * {
             *  result = MessageBox.Show("Deuk", "안뇽하세요", MessageBoxButtons.RetryCancel);
             * } while (result == DialogResult.Retry);*/
            CustomForm form = new CustomForm();

            //form.Show(); //모달리스 (기존 화면 조작 가능)
            form.ShowDialog(); //모달 (기존화면 조작 불가능)
        }
Exemplo n.º 4
0
            public void Start()
            {
                Console.WriteLine("Checking for update.");

                if (_client == null)
                {
                    _client = new WebClient();
                }

                _client.Proxy = null;
                Checking      = true;

                try
                {
#if BETA
                    CustomForm form = new CustomForm()
                    {
                        Text          = "Check for updates",
                        StartPosition = FormStartPosition.CenterScreen,
                        ControlBox    = false,
                        Sizable       = false,
                        Icon          = Icon.ExtractAssociatedIcon(Application.ExecutablePath),
                        Size          = new Size(350, 150),
                        TopMost       = true
                    };

                    Label label = new Label()
                    {
                        Font      = new Font("Segoe UI", 20, FontStyle.Regular),
                        ForeColor = Color.White,
                        Text      = "Checking...",
                        AutoSize  = true,
                    };
                    label.Location = new Point(form.Width / 2 - label.Width / 2 - 25, form.Height / 2 - label.Height / 2);
                    label.Parent   = form;
                    form.Show();

                    Version checkedVersion = new Version(_client.DownloadString(new Uri("http://razorenhanced.org/download/Version-EM-Beta.txt")));

                    if (checkedVersion > MainCore.MapVersion)
                    {
                        form.Close();

                        form = new CustomForm()
                        {
                            Text          = "New updates available!",
                            StartPosition = FormStartPosition.CenterScreen,
                            ControlBox    = false,
                            Sizable       = false,
                            Icon          = Icon.ExtractAssociatedIcon(Application.ExecutablePath),
                            Size          = new Size(350, 150),
                            TopMost       = true
                        };

                        label = new Label()
                        {
                            Font      = new Font("Segoe UI", 20, FontStyle.Regular),
                            ForeColor = Color.White,
                            Text      = "Updating...",
                            AutoSize  = true,
                        };
                        label.Location = new Point(form.Width / 2 - label.Width / 2 - 25, form.Height / 2 - label.Height / 2);
                        label.Parent   = form;

                        Task.Run(() =>
                        {
                            string path = Path.Combine(Path.GetTempPath(), "Enhanced-Map-Beta.zip");

                            if (File.Exists(path))
                            {
                                File.Delete(path);
                            }

                            _client.DownloadFile("http://razorenhanced.org/download/Enhanced-Map-Beta.zip", path);

                            string pathtoextract = Path.Combine(Path.GetTempPath(), "map-beta");
                            if (Directory.Exists(pathtoextract))
                            {
                                Directory.Delete(pathtoextract, true);
                            }

                            ZipFile.ExtractToDirectory(path, pathtoextract);

                            Process p = new Process
                            {
                                StartInfo =
                                {
                                    FileName        = Path.Combine(pathtoextract, "EnhancedMap.exe"),
                                    UseShellExecute = false,
                                    Arguments       =
                                        $"--source \"{Application.ExecutablePath}\" --pid {Process.GetCurrentProcess().Id} --action update"
                                }
                            };
                            p.Start();
                            Process.GetCurrentProcess().Kill();
                        });

                        form.ShowDialog();
                    }
                    if (form != null && !form.Disposing)
                    {
                        form.Close();
                    }
#else
                    _client.DownloadStringCompleted += m_Client_DownloadStringCompleted;
                    _client.DownloadStringAsync(new Uri("http://razorenhanced.org/download/Version-EM.txt"));
#endif
                }
                catch (WebException webEx)
                {
                    Checking = false;
                    MessageBox.Show("Failed to comunicate with server", "Error");
                }
                catch (Exception ex)
                {
                    Checking = false;
                    MessageBox.Show("Failed to download new version.", "Error");
                }
            }
Exemplo n.º 5
0
        private void button2_Click(object sender, EventArgs e)
        {
            CustomForm form = new CustomForm();

            form.ShowDialog();
        }
Exemplo n.º 6
0
        private void button5_Click(object sender, EventArgs e)
        {
            var customForm = new CustomForm();

            customForm.ShowDialog();
        }
Exemplo n.º 7
0
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            try
            {
                // may throw exception if its doesn' find a database
                voteAppEntities entities = DbUtils.AppEntities;
            }
            catch (Exception ex)
            {
                MessageBox.Show("NOT CONNECTED TO A DATABASE!", "MISSING DATA", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                Trace.WriteLine(ex.Message);
                return;
            }

            bool isLicensed = RegistryUtils.IsLicensed();

            if (!isLicensed)
            {
                // check if app is already activated through windows registry
                using (LicenseForm enterLicense = new LicenseForm())
                {
                    //enterLicense.ShowDialog();
                    Application.Run(enterLicense);
                    isLicensed = enterLicense.DialogResult == DialogResult.OK;
                }
            }

            // invalid license
            if (!isLicensed)
            {
                return;
            }

            // if there is at least one user (superadmin) show the login form
            if (DbUtils.AppEntities.Users.Any(user => user.Type == TypeUser.SuperAdmin) == false)
            {
                CreateAdminConfigurations configs = new CreateAdminConfigurations
                {
                    Title    = "Create super admin!",
                    TypeUser = TypeUser.SuperAdmin
                };
                bool showLoginForm = false;
                //User loginUser = null;
                using (CreateAdminForm formCreateSuperAdmin = new CreateAdminForm(configs))
                {
                    if (formCreateSuperAdmin.ShowDialog() == DialogResult.OK)
                    {
                        showLoginForm = formCreateSuperAdmin.User != null;
                    }
                }
                if (showLoginForm)
                {
                    using (CustomForm customForm = new CustomForm())
                    {
                        customForm.ShowDialog();
                    }
                }
            }

            Application.Run(new LoginForm());
        }
Exemplo n.º 8
0
        private void btnCustom_Click(object sender, EventArgs e)
        {
            CustomForm form = new CustomForm(this);

            form.ShowDialog();
        }
Exemplo n.º 9
0
        private void ShowCustomForm()
        {
            CustomForm customForm = new CustomForm(parent, food);

            customForm.ShowDialog();
        }