Close() public method

public Close ( ) : void
return void
示例#1
1
		public void SelectRow_ShouldMaintain_ActivePosition()
		{
			// set up special conditions
			var grid = new Grid();
			grid.Redim(1, 1);
			grid[0, 0] = new Cell();
			
			var form = new Form();
			form.Controls.Add(grid);
			form.Show();

			grid.SelectionMode = GridSelectionMode.Row;
			grid.Selection.EnableMultiSelection = false;
			
			
			// just assert that we have correct conditions for test, 
			// active position should not be empty
			grid.Selection.Focus(new Position(0, 0), true);
			Assert.AreEqual(new Position(0, 0), grid.Selection.ActivePosition);
			
			// this method causes first row to be selected. Should not fail 
			// it failed once in RowSelection.SelectRow method
			// As call to ResetSelection asked to maintain focus, a stack overflow was raised
			grid.Selection.SelectRow(0, true);
			Assert.AreEqual(new Position(0, 0), grid.Selection.ActivePosition);
			
			// destroy
			form.Close();
			form.Dispose();
		}
        public static string ShowDialog(string text, string currentValue, string promptName)
        {
            System.Windows.Forms.Form prompt = new System.Windows.Forms.Form();
            prompt.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
            prompt.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            prompt.ClientSize = new System.Drawing.Size(284, 67);
            prompt.MaximizeBox = false;
            prompt.MinimizeBox = false;
            prompt.Text = promptName;
            prompt.FormBorderStyle = FormBorderStyle.FixedSingle;
            prompt.Name = "dlgPrompt";
            prompt.Font = new Font("Calibri", 9, FontStyle.Regular);
            prompt.StartPosition = FormStartPosition.CenterParent;

            System.Windows.Forms.Label textLabel = new System.Windows.Forms.Label() { Location = new System.Drawing.Point(12, 5), Size = new System.Drawing.Size(185, 23), Text = text, TextAlign = System.Drawing.ContentAlignment.MiddleLeft };
            System.Windows.Forms.TextBox textBox = new System.Windows.Forms.TextBox() { Location = new System.Drawing.Point(12, 34), Size = new System.Drawing.Size(185, 23), Text = currentValue };
            System.Windows.Forms.Button confirmation = new System.Windows.Forms.Button() { Location = new System.Drawing.Point(217, 5), Size = new System.Drawing.Size(55, 23), Text = "OK" };
            System.Windows.Forms.Button cancel = new System.Windows.Forms.Button() { Location = new System.Drawing.Point(217, 34), Size = new System.Drawing.Size(55, 23), Text = "Cancel" };

            confirmation.Click += (sender, e) => { prompt.Close(); };
            cancel.Click += (sender, e) => { textBox.Text = string.Empty;  prompt.Close(); };

            prompt.Controls.Add(confirmation);
            prompt.Controls.Add(cancel);
            prompt.Controls.Add(textLabel);
            prompt.Controls.Add(textBox);
            prompt.ShowDialog();

            return textBox.Text;
        }
示例#3
0
 public static string ShowDialog(string text, string caption, string defaultValue = "")
 {
     Form prompt = new Form();
     prompt.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
     prompt.Width = 250;
     prompt.Height = 150;
     prompt.Text = caption;
     Label textLabel = new Label() { Left = 10, Top = 10, Text = text, AutoSize = true };
     TextBox textBox = new TextBox() { Left = 10, Top = 35, Width = 210 };
     textBox.Text = defaultValue;
     Button confirmation = new Button() { Text = "OK", Left = 10, Width = 60, Top = 70 };
     Button cancel = new Button() { Text = "Cancel", Left = 90, Width = 60, Top = 70 };
     confirmation.Click += (sender, e) => { prompt.DialogResult = DialogResult.OK; prompt.Close(); };
     cancel.Click += (sender, e) => { prompt.DialogResult = DialogResult.Cancel; prompt.Close(); };
     prompt.Controls.Add(confirmation);
     prompt.Controls.Add(cancel);
     prompt.Controls.Add(textLabel);
     prompt.Controls.Add(textBox);
     prompt.AcceptButton = confirmation;
     prompt.CancelButton = cancel;
     DialogResult Result = prompt.ShowDialog();
     if (Result == DialogResult.Cancel)
         return null;
     if (Result == DialogResult.OK)
         return textBox.Text;
     else
         return null;
 }
        private void button4_Click(object sender, EventArgs e)
        {
            Form prompt = new Form();
            prompt.Width = 500;
            prompt.Height = 150;
            prompt.FormBorderStyle = FormBorderStyle.FixedDialog;
            prompt.Text = "Cancel an order";
            prompt.StartPosition = FormStartPosition.CenterScreen;
            Label textLabel = new Label() { Left = 50, Top = 20, Width = 400, Text = "Enter tracking number to cancel:" };
            TextBox textBox = new TextBox() { Left = 50, Top = 50, Width = 400 };
            Button confirmation = new Button() { Text = "Ok", Left = 350, Width = 100, Top = 70 };
            Button cancel = new Button() { Text = "Cancel", Left = 250, Width = 100, Top = 70 };
            confirmation.DialogResult = DialogResult.OK;
            confirmation.Click += (sndr, evnt) => { prompt.Close(); };
            cancel.Click += (sndr, evnt) => { prompt.Close(); };
            prompt.Controls.Add(textBox);
            prompt.Controls.Add(confirmation);
            prompt.Controls.Add(cancel);
            prompt.Controls.Add(textLabel);
            prompt.CancelButton = cancel;
            prompt.AcceptButton = confirmation;
            DialogResult result = prompt.ShowDialog();

            if (result != System.Windows.Forms.DialogResult.OK || textBox.Text.Length == 0)
                return;

            DeleteShipmentRequest req = new DeleteShipmentRequest();
            req.WebAuthenticationDetail = plugin.auth;
            req.ClientDetail = plugin.clientDetail;
            req.Version = new VersionId();

            req.TransactionDetail = new TransactionDetail();
            req.TransactionDetail.CustomerTransactionId = textBox.Text;

            req.TrackingId = new TrackingId();
            req.TrackingId.TrackingNumber = textBox.Text;
            req.TrackingId.TrackingIdType = TrackingIdType.EXPRESS;
            req.TrackingId.TrackingIdTypeSpecified = true;

            req.DeletionControl = DeletionControlType.DELETE_ALL_PACKAGES;

            var reply = plugin.svc.deleteShipment(req);

            if (reply.HighestSeverity == NotificationSeverityType.SUCCESS) {
                MessageBox.Show("Success");
            } else {
                var output = "";

                for (int i = 0; i < reply.Notifications.Length; i++)
                {
                    Notification notification = reply.Notifications[i];
                    output += string.Format("Notification no. {0}\n", i);
                    output += string.Format(" Severity: {0}\n", notification.Severity);
                    output += string.Format(" Code: {0}\n", notification.Code);
                    output += string.Format(" Message: {0}\n", notification.Message);
                    output += string.Format(" Source: {0}\n", notification.Source);
                }
                MessageBox.Show("Failed!\n\n" + output);
            }
        }
示例#5
0
        private void OpenDialog(System.Windows.Forms.Form pObjForm)
        {
            OpenFileDialog lObjDialog = new OpenFileDialog();

            lObjDialog.Title       = mStrTitle;
            lObjDialog.Multiselect = false;
            if (mStrFilter != null)
            {
                lObjDialog.Filter = mStrFilter;
            }
            //dialog.SelectedPath = @"C:\Users\ssandoval\Desktop\ELGA.2018\ELGA.AddOn.PayrollPolicyXML\XML Samples";
            //----------------------------------------------------------------//
            if (lObjDialog.ShowDialog() == DialogResult.OK)
            {
                lObjDialog.Dispose();
                pObjForm.Close();
                SelectedFile = lObjDialog.FileName;
            }
            else
            {
                lObjDialog.Dispose();
                pObjForm.Close();
                SelectedFile = "";
            }
        }
示例#6
0
        public static string ShowDialog(string text, string caption, string value, bool isPassword)
        {
            Form prompt = new Form();
            prompt.Width = 264;
            prompt.Height = 140;
            prompt.Text = caption;
            Label textLabel = new Label() { Left = 12, Top = 22, Text = text, Width = 210 };
            TextBox textBox = new TextBox() { Text = value, Left = 12, Top = 52, Width = 230 };
            if (isPassword)
            {
                textBox = new TextBox() { Text = value, Left = 12, Top = 52, Width = 230, PasswordChar = '*' };
            }
            else
            {
                textBox = new TextBox() { Text = value, Left = 12, Top = 52, Width = 230 };
            }

            textBox.Focus();
            textBox.KeyDown += (sender, e) =>
            {
                if (e.KeyValue != 13)
                    return;

                prompt.Close();
            };
            Button confirmation = new Button() { Text = "Ok", Left = 142, Width = 100, Top = 78 };
            confirmation.Click += (sender, e) => { prompt.Close(); };
            prompt.Controls.Add(confirmation);
            prompt.Controls.Add(textLabel);
            prompt.Controls.Add(textBox);
            prompt.StartPosition = FormStartPosition.CenterParent;
            prompt.ShowDialog();
            return textBox.Text;
        }
        public static string ShowTextDialog(string caption)
        {
            var prompt = new Form()
            {
                FormBorderStyle = FormBorderStyle.FixedDialog,
                MinimizeBox = false,
                MaximizeBox = false,
                Width = 200,
                Height = 110,
                Text = caption,
                StartPosition = FormStartPosition.CenterScreen,
            };

            var cancel = new Button();
            cancel.Click += (sender, e) => prompt.Close();
            prompt.CancelButton = cancel;

            var textBox = new TextBox() { Left = 20, Top = 20, Width = 160, Height = 80, Text = "" };
            var confirmation = new Button() { Text = "Ok", Left = 50, Top = 50, Width = 100, DialogResult = DialogResult.OK };
            confirmation.Click += (sender, e) => { prompt.Close(); };

            prompt.Controls.Add(textBox);
            prompt.Controls.Add(confirmation);
            prompt.AcceptButton = confirmation;

            textBox.Select(0, textBox.Text.Length);

            if (prompt.ShowDialog() == DialogResult.OK)
            {
                return textBox.Text;
            }
            return null;
        }
示例#8
0
        private static void Button_Click(object sender, EventArgs e)
        {
            Button button = (Button)sender;

            switch (button.Name)
            {
            case "Yes":
                DialogRes = DialogResult.Yes;
                break;

            case "No":
                DialogRes = DialogResult.No;
                break;

            case "Cancel":
                DialogRes = DialogResult.Cancel;
                break;

            case "OK":
                DialogRes = DialogResult.OK;
                break;

            default:
                DialogRes = DialogResult.Cancel;
                break;
            }
            frm.Close();
        }
示例#9
0
        public static string ShowDialog(string text, string caption, string initalValue="")
        {
            Label textLabel = new Label() { Left = 30, Top = 5, Width = 200, Text = text };
            TextBox textBox = new TextBox() { Left = 30, Top = 35, Width = 200, Text = initalValue };
            Button confirmation = new Button() { Text = "Ok", Left = 105, Width = 70, Top = 80 };
            Button cancel = new Button() { Text = "Cancel", Left = 180, Width = 70, Top = 80 };
            Form prompt = new Form {Text = caption, ShowIcon = false, AcceptButton = confirmation, CancelButton = cancel,
                AutoSize = true, MaximizeBox = false, MinimizeBox = false, AutoSizeMode = AutoSizeMode.GrowAndShrink,
                SizeGripStyle = SizeGripStyle.Hide, ShowInTaskbar = false, StartPosition = FormStartPosition.CenterParent};

            confirmation.Click += (sender, e) =>
                {
                    prompt.DialogResult = DialogResult.OK;
                    prompt.Close();
                };
            cancel.Click += (sender, e) =>
                {
                    textBox.Clear();
                    prompt.DialogResult = DialogResult.Cancel;
                    prompt.Close();
                };

            prompt.Controls.Add(confirmation);
            prompt.Controls.Add(cancel);
            prompt.Controls.Add(textLabel);
            prompt.Controls.Add(textBox);
            prompt.ActiveControl = textBox;

            var result = prompt.ShowDialog();

            return result == DialogResult.OK ? textBox.Text.Trim() : null;
        }
示例#10
0
文件: MainForm.cs 项目: Yogr/Wizard
        private void FileNew_menuitem_Click(object sender, EventArgs e)
        {
            string newFileName = "";

            Form form = new Form();
            form.Width = 500;
            form.Height = 150;
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.Text = "New Wizard Project File";
            form.StartPosition = FormStartPosition.WindowsDefaultLocation;
            Label textLabel = new Label() { Left = 50, Top = 20, Text = "Name:" };
            TextBox textBox = new TextBox() { Left = 50, Top = 50, Width = 400 };
            Button confirmation = new Button() { Text = "Ok", Left = 350, Width = 100, Top = 70, DialogResult = DialogResult.OK };
            confirmation.Click += (formsender, forme) => { newFileName = textBox.Text; form.Close(); };
            form.Controls.Add(textBox);
            form.Controls.Add(confirmation);
            form.Controls.Add(textLabel);
            form.AcceptButton = confirmation;

            DialogResult result = form.ShowDialog();

            if(DialogResult.OK == result) // Create new file
            {
                _CreateNewMasterFile(newFileName);
            }
            form.Close();
        }
示例#11
0
 private void button1_Click(object sender, EventArgs e)
 {
     save();
     if (!System.Diagnostics.Debugger.IsAttached)
     {
         System.Diagnostics.Process.Start(Application.ExecutablePath, String.Join(" ", Environment.GetCommandLineArgs())); // to start new instance of application
         parent.Close();                                                                                                   //to turn off current app
     }
 }
示例#12
0
 private static void btnAdd_Click(object sender, EventArgs e)
 {
     //MessageBox.Show(frm.Controls["panels"].Controls["text1"].Text);
     frm.Controls["lblUkupno"].Text = "";
     ResultFind  = "Ponisti";
     ResultValue = "";
     DialogRes   = DialogResult.OK;
     frm.Close();
 }
示例#13
0
        public static string Show(string message)
        {
            string answer = string.Empty;

            using (var ask = new Form())
            {
                var stack_styles = new Dictionary<object, object>();
                stack_styles.Add("background", "mistyrose");
                stack_styles.Add("heigth", "1.0");
                stack_styles.Add("width", "1.0");
                var stack = new Stack(stack_styles);
                var para = new Para();
                para.Text = message;
                stack.AddControl(para);

                var edit_box = new TextBox();
                stack.AddControl(edit_box);

                var flow_styles = new Dictionary<object, object>();
                flow_styles.Add("background", "gray");
                flow_styles.Add("width", "0.9");
                var flow = new Flow(flow_styles);
                flow.FlowDirection = FlowDirection.RightToLeft;

                var button_ok = new SteelToeBoots.Library.Elements.Button();
                button_ok.Text = "OK";
                button_ok.Click += (object o, EventArgs e) => {
                    answer = edit_box.Text;
                    ask.Close();
                };
                flow.AddControl(button_ok);

                var button_canel = new SteelToeBoots.Library.Elements.Button();
                button_canel.Text = "Cancel";
                button_canel.Click += (object o, EventArgs e) => {
                    answer = string.Empty;
                    ask.Close();
                };
                flow.AddControl(button_canel);

                stack.AddControl(flow);

                ask.Text = "Boots ask:";
                //ask.AddControl(stack);
                ask.Controls.Add(stack);

                ask.ShowDialog();
            }

            return answer;
        }
示例#14
0
    static Control FormWidget(Racr.AstNode n)
    {
        var form = new System.Windows.Forms.Form();

        form.Text = "Questionnaire";
        var file = new MenuItem("&File");
        var open = new MenuItem("&Open");
        var save = new MenuItem("&Save");
        var quit = new MenuItem("&Quit");

        open.Click += (object sender, EventArgs e) => {
            var ofd = new OpenFileDialog();
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                var parser = new Parser(QL.Ql, File.ReadAllText(ofd.FileName));
                var ast    = parser.ParseAst();
                ast.Render();
                Questionnaire.UpdateQuestions(ast);
                form.Closed -= FormClosed;
                form.Close();
            }
        };
        save.Click += (object sender, EventArgs e) => {
            var sfd = new SaveFileDialog();
            if (sfd.ShowDialog() == DialogResult.OK && sfd.FileName != "")
            {
                File.WriteAllText(sfd.FileName, n.SExpr());
            }
        };
        quit.Click  += (object sender, EventArgs e) => form.Close();
        form.Closed += FormClosed;

        file.MenuItems.Add(open);
        file.MenuItems.Add(save);
        file.MenuItems.Add(quit);
        form.Menu = new MainMenu();
        form.Menu.MenuItems.Add(file);

        var panel = new FlowLayoutPanel();

        panel.AutoSize      = true;
        panel.AutoScroll    = true;
        panel.Dock          = DockStyle.Fill;
        panel.FlowDirection = FlowDirection.TopDown;
        panel.WrapContents  = false;
        form.Controls.Add(panel);
        form.Show();
        return(panel);
    }
示例#15
0
        void RegisterQuickieText()
        {
            DockPanel.Click += (s, a) =>
            {
                var tb = new System.Windows.Forms.TextBox();
                var f  = new System.Windows.Forms.Form();

                tb.KeyDown += (kps, kpa) =>
                {
                    if (kpa.KeyCode == Keys.Escape)
                    {
                        f.Close();
                    }
                    if (kpa.KeyCode == Keys.Enter)
                    {
                        var command = tb.Text.ToLowerInvariant();
                        // Do some more intelligent stuff
                        // than this:

                        if (command.StartsWith("remove"))
                        {
                            var id = command.Split(' ')[1];
                            Hierarchy.Remove(long.Parse(id));
                        }

                        if (command == "com")
                        {
                            this.Commands.Add("Hey " + this.Commands.Count(), (n, x) => { MessageBox.Show(n.NodeDataAdapter.GetDisplayName()); }, "Nice one buddy");
                        }
                        if (command == "comr")
                        {
                            var first = this.Commands.First();
                            //  if (first != null) Hierarchy.Commands.RemoveItem(first);
                        }
                        f.Close();
                    }
                };


                tb.Width          = 300;
                tb.Font           = Consolas975;
                f.WindowState     = FormWindowState.Normal;
                f.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
                f.Controls.Add(tb);
                f.Show();
                f.SetDesktopLocation(Cursor.Position.X, Cursor.Position.Y);
                f.ClientSize = tb.Size;
            };
        }
示例#16
0
        public static string ShowDialog(string text, string caption)
        {
            System.Windows.Forms.Form prompt = new System.Windows.Forms.Form()
            {
                Width           = 500,
                Height          = 150,
                FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog,
                Text            = caption,
                StartPosition   = System.Windows.Forms.FormStartPosition.CenterScreen,
                RightToLeft     = RightToLeft.Yes,
            };
            Label textLabel = new Label()
            {
                Left = 50, Top = 20
            };
            TextBox textBox = new TextBox()
            {
                Left = 50, Top = 50, Width = 400
            };
            Button confirmation = new Button()
            {
                Text = "Ok", Left = 350, Width = 100, Top = 70, DialogResult = DialogResult.OK
            };

            textBox.Text = text;


            confirmation.Click += (sender, e) => { prompt.Close(); };
            prompt.Controls.Add(textBox);
            prompt.Controls.Add(confirmation);
            prompt.Controls.Add(textLabel);
            prompt.AcceptButton = confirmation;

            return(prompt.ShowDialog() == DialogResult.OK ? textBox.Text : "");
        }
示例#17
0
        public void TampilkanGraph(bool autoClose)
        {
            form = new System.Windows.Forms.Form();
            graph.GraphAttr.EdgeAttr.ArrowHeadAtTarget = Microsoft.Glee.Drawing.ArrowStyle.None;
            graph.GraphAttr.Orientation = Microsoft.Glee.Drawing.Orientation.Landscape;

            //contoh input
            //bind the graph to the viewer
            viewer.Graph = graph;
            //associate the viewer with the form
            form.SuspendLayout();
            viewer.Dock = System.Windows.Forms.DockStyle.Fill;
            form.Controls.Add(viewer);
            form.ResumeLayout();

            //show the form
            form.StartPosition = FormStartPosition.CenterParent;
            if (autoClose)
            {
                Task.Delay(TimeSpan.FromSeconds(0.75))
                .ContinueWith((t) => form.Close(), TaskScheduler.FromCurrentSynchronizationContext());
            }
            form.ShowDialog();

            //System.Threading.Thread.Sleep(5000);
            //form.DialogResult = DialogResult.Abort;
            //form.Close();
            //form = new System.Windows.Forms.Form();
            //viewer = new Microsoft.Glee.GraphViewerGdi.GViewer();
        }
示例#18
0
 private void btnAccept_Click(object sender, EventArgs e)
 {
     ValidateChildren(ValidationConstraints.Enabled);
     if (!string.IsNullOrEmpty(tbOldPass.Text))
     {
         if (!string.IsNullOrEmpty(tbNewPass.Text))
         {
             if (!string.IsNullOrEmpty(tbCheckPass.Text))
             {
                 int rs = AccountDAO.Instance.ChangePass();
                 if (rs > 0)
                 {
                     if (checklang == "Họ Tên:")
                     {
                         MessageBox.Show("Đổi mật khẩu thành công", "Thông báo", MessageBoxButtons.OK);
                     }
                     else
                     {
                         MessageBox.Show("Change password successfully", "Notification", MessageBoxButtons.OK);
                     }
                     this.Close();
                     System.Windows.Forms.Form f = System.Windows.Forms.Application.OpenForms["_frmSalesManage"];
                     f.Close();
                 }
             }
         }
     }
 }
示例#19
0
        public static void ShowDialog_Text_Combo(string caption, string text, string text2 , ref string defText1, List<string> comboItems, out string selectedItem)
        {
            Form prompt = new Form();
            prompt.Width = 280;
            prompt.Height = 180;
            prompt.Text = caption;
            Label textLabel = new Label() { Left = 16, Top = 10, Width = 240, Text = text };
            TextBox textBox = new TextBox() { Left = 16, Top = 35, Width = 240, TabIndex = 0, TabStop = true, Text = defText1 };
            //CheckBox ckbx = new CheckBox() { Left = 16, Top = 60, Width = 240, Text = boolStr };

            Label textLabel2 = new Label() { Left = 16, Top = 60, Width = 240, Text = text2 };
            ComboBox cbox = new ComboBox() { Left = 16, Top = 85, Width = 240, DataSource = comboItems, TabStop = true };

            Button confirmation = new Button() { Text = "OK", Left = 16, Width = 80, Top = 110, TabIndex = 1, TabStop = true };
            confirmation.Click += (sender, e) =>
            {
                prompt.Close();
            };
            prompt.Controls.Add(textLabel);
            prompt.Controls.Add(textBox);

            prompt.Controls.Add(textLabel2);
            prompt.Controls.Add(cbox);

            //prompt.Controls.Add(ckbx);
            prompt.Controls.Add(confirmation);
            prompt.AcceptButton = confirmation;
            prompt.StartPosition = FormStartPosition.CenterScreen;
            prompt.ShowDialog();
            defText1 = textBox.Text;
            selectedItem = (string)cbox.SelectedItem;
        }
示例#20
0
 public static void Close(Form form)
 {
     if (form.InvokeRequired)
         form.Invoke(new CloseDelegate(Close), form);
     else
         form.Close();
 }
 public void AddPoseCombination(Window window, PoseCombination poseCombination, bool isEdit, int editIndex, Form form)
 {
     if (isEdit && !window.IsExistPoseCombinationEdit(poseCombination, editIndex))
     {
         window.RemovePoseCombinationByIndex(editIndex);
         window.InsertPoseCombination(editIndex, poseCombination);
         form.Close();
     }
     else if (!isEdit && !window.IsExistPoseCombination(poseCombination))
     {
         window.AddPoseCombination(poseCombination);
         form.Close();
     }
     else
         MessageBox.Show("此手勢組合已選擇過!!!", "警告", MessageBoxButtons.OK);
 }
示例#22
0
		public void ForeColorTest ()
		{
			ProgressBar progressBar = new ProgressBar ();
#if NET_2_0
			Assert.AreEqual (SystemColors.Highlight, progressBar.ForeColor, "#A1");
#else
			Assert.AreEqual (SystemColors.ControlText, progressBar.ForeColor, "#A1");
#endif
			progressBar.ForeColor = Color.Red;
			Assert.AreEqual (Color.Red, progressBar.ForeColor, "#A2");
			progressBar.ForeColor = Color.White;
			Assert.AreEqual (Color.White, progressBar.ForeColor, "#A3");

			Form form = new Form ();
			form.ShowInTaskbar = false;
			form.Controls.Add (progressBar);
			form.Show ();

			Assert.AreEqual (Color.White, progressBar.ForeColor, "#B1");
			progressBar.ForeColor = Color.Red;
			Assert.AreEqual (Color.Red, progressBar.ForeColor, "#B2");
			progressBar.ForeColor = Color.Red;
			Assert.AreEqual (Color.Red, progressBar.ForeColor, "#B3");
			progressBar.ForeColor = Color.Blue;
			Assert.AreEqual (Color.Blue, progressBar.ForeColor, "#B4");
			
			form.Close ();
		}
        private void btnAdd_Click(object sender, EventArgs e)
        {
            var win = new Form();

            var label = new Label {Text = "Node text (\f for format code):", AutoSize = true, Dock = DockStyle.Top};
            var button = new Button {Text = "Add", Dock = DockStyle.Right};
            var input = new TextBox {Dock = DockStyle.Bottom};

            button.Click += (o, args) =>
                                {
                                    var selection = treeView.SelectedNode;
                                    var addition = Regex.Replace(input.Text, @"(?<!\\)\\f", "\f");
                                    if(selection == null)
                                    {
                                        treeView.Nodes.Add(addition);
                                    }
                                    else
                                    {
                                        selection.Nodes.Add(addition);
                                    }
                                    win.Close();
                                };

            win.Controls.Add(input);
            win.Controls.Add(button);
            win.Controls.Add(label);
            win.AcceptButton = button;

            win.Width = 300;
            win.Height = 72;

            win.Text = "Add Node";
            win.ShowDialog();
            input.Select();
        }
示例#24
0
        public static string ShowDialog(string text, string caption, String value)
        {
            Form prompt = new Form();
            prompt.Width = 500;
            prompt.Height = 200;
            prompt.Text = caption;

            prompt.FormBorderStyle = FormBorderStyle.FixedToolWindow;

            Label textLabel = new Label() { Left = 50, Top = 20, Width = 400, Text = text + @":",
                Font = new Font("Microsoft Sans Serif", 10, FontStyle.Bold)
            };

            TextBox textBox = new TextBox() { Left = 50, Top = 50, Width = 400 ,Text = value,
                Height = 100, Font = new Font("Microsoft Sans Serif", 24, FontStyle.Regular)
            };

            Button confirmation = new Button() { Text = "Ok", Left = 350, Width = 100, Top = 125,
                Height = 35, Font = new Font("Microsoft Sans Serif", 10, FontStyle.Regular) };
            confirmation.Click += (sender, e) => { prompt.Close(); };
            prompt.Controls.Add(confirmation);
            prompt.Controls.Add(textLabel);
            prompt.Controls.Add(textBox);
            prompt.ShowDialog();
            return textBox.Text;
        }
        public Magnifier(Form form, bool isLens)
        {
            this.isLens = isLens;
            oldIsLens = isLens;//Used to track changes of the isLens variable because changing the cursor settings of the magnifier requiers recreating the magnifier
            magnification = 2.0f;
            this.form = form;

            if (form == null)
                throw new ArgumentNullException("form");

            initialized = NativeMethods.MagInitialize();
            if (initialized)
            {
                SetupMagnifier();
                //UpdateMaginifier();

                this.form.Resize += new EventHandler(form_Resize);
                this.form.FormClosing += new FormClosingEventHandler(form_FormClosing);
                timer = new Timer();
                timer.Tick += new EventHandler(timer_Tick);
                timer.Interval = NativeMethods.USER_TIMER_MINIMUM;
                timer.Enabled = true;
                //HookManager.MouseMove += new MouseEventHandler(mouseMove);
            }
            else
            {
                form.Close();
            }
        }
示例#26
0
        /// <summary>
        /// Devuelve o crea una instancia de un tipo de Formulario de la aplicación de forma genérica
        /// </summary>
        /// <param name="currentForm">Referencia del formulario origen de la llamada</param>
        /// <param name="newFormType">Tipo del formulario a crear</param>
        /// <param name="newForm">Referencia actual del formulario a crear (puede que ya exista)</param>
        /// <param name="forceCreate">Si es true, siempre se creará una instancia nueva, y si es false intentará devolver la instancia existente.</param>
        /// <returns></returns>
        private static Form getGenericFormInstance(Form currentForm, Type newFormType, Form newForm, Boolean forceCreate)
        {
            if (newForm == null || forceCreate)
            {
                // Hay que crear una instancia nueva
                if (newForm != null)
                {
                    // Si ya existía, lo cerramos antes de crear otro, liberando los recursos utilizados por el mismo.
                    newForm.Close();
                    newForm.Dispose();
                }
                // Creamos el nuevo formulario
                newForm = (Form)Activator.CreateInstance(newFormType);
            }

            // Mostramos el nuevo formulario
            newForm.Show();

            if (currentForm != null)
            {
                // Si nos llegó la referencia al formulario origen de la 'navegación', lo ocultamos (la referencia está guardada para recuperarla después)
                currentForm.Hide();
            }
            return newForm;
        }
示例#27
0
 public static string ShowDialog(string text, string caption, List<string> comboitems)
 {
     prompt = new Form();
     prompt.SizeChanged += new System.EventHandler(SimpleCombo_SizeChanged);
     prompt.AutoSizeMode = AutoSizeMode.GrowOnly;
     prompt.Padding = new Padding(50);
     prompt.Text = caption;
     textLabel = new Label() { Text = text, AutoSize = true};
     textLabel.Left = (int)Math.Ceiling((double)(prompt.Width - textLabel.Width) * 0.5);
     textLabel.Top = (int)Math.Ceiling((double)(prompt.Height - textLabel.Height) * 0.25);
     comboBox = new ComboBox() { DataSource = comboitems, MinimumSize = new System.Drawing.Size(500,20)};
     comboBox.Left = (int)Math.Ceiling((double)(prompt.Width - comboBox.Width) * 0.5);
     comboBox.Top = (int)Math.Ceiling((double)(prompt.Height - comboBox.Height) * 0.5);
     confirmation = new Button() {Text = "OK" };
     confirmation.Left = (int)Math.Ceiling((double)(prompt.Width - confirmation.Width) * 0.5);
     confirmation.Top = (int)Math.Ceiling((double)(prompt.Height - confirmation.Height) * 0.75);
     confirmation.Click += (sender, e) => { prompt.Close(); };
     prompt.Controls.Add(confirmation);
     prompt.Controls.Add(textLabel);
     prompt.Controls.Add(comboBox);
     prompt.AcceptButton = confirmation;
     prompt.AutoSize = true;
     prompt.Refresh();
     prompt.ShowDialog();
     return comboBox.SelectedItem.ToString();
 }
示例#28
0
        internal JsHostWindowObject(Form parent)
        {
            parentForm = parent;
            handle = parent.Handle;

            var winObj = AddObject("hostWindow");

            winObj.AddFunction("close").Execute += (sender, e) => parentForm.UpdateUI(() => parentForm.Close());
            winObj.AddFunction("minimize").Execute += (sender, e) => parent.UpdateUI(() => {
                parentForm.UpdateUI(() =>
                {
                    if (parentForm.WindowState == FormWindowState.Minimized)
                    {
                        NativeMethods.SendMessage(handle, NativeMethods.WindowsMessage.WM_SYSCOMMAND, (IntPtr)NativeMethods.SysCommand.SC_RESTORE, IntPtr.Zero);
                    }
                    else
                    {
                        NativeMethods.SendMessage(handle, NativeMethods.WindowsMessage.WM_SYSCOMMAND, (IntPtr)NativeMethods.SysCommand.SC_MINIMIZE, IntPtr.Zero);
                    }
                });
            });
            winObj.AddFunction("maximize").Execute += (sender, e) => parent.UpdateUI(() => {
                parentForm.UpdateUI(() =>
                {
                    if (parentForm.WindowState == FormWindowState.Maximized)
                    {
                        NativeMethods.SendMessage(handle, NativeMethods.WindowsMessage.WM_SYSCOMMAND, (IntPtr)NativeMethods.SysCommand.SC_RESTORE, IntPtr.Zero);
                    }
                    else
                    {
                        NativeMethods.SendMessage(handle, NativeMethods.WindowsMessage.WM_SYSCOMMAND, (IntPtr)NativeMethods.SysCommand.SC_MAXIMIZE, IntPtr.Zero);
                    }
                });
            });
        }
示例#29
0
        /// <summary>
        /// Default menu's Event Handler
        /// </summary>
        private void DefaultMenuHandler(object sender, System.EventArgs e)
        {
            try
            {
                switch (((MenuItem)sender).Text)
                {
                case "Animate":
                    Animate(-1, 100);
                    break;

                case "Stop Animation":
                    OnStatusChanged(this, new SystemTrayNotificationEventArgs(SystemTrayNotificationEventType.StopingAnimation));
                    keepAnimationAlive = false;
                    break;

                case "Hide Icon":
                    OnStatusChanged(this, new SystemTrayNotificationEventArgs(SystemTrayNotificationEventType.Hiding));
                    notifyIcon.Visible = false;
                    break;

                case "Exit Application":
                    notifyIcon.Visible = false;
                    mainForm.Close();
                    break;
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "Error");
            }
        }
示例#30
0
        private static Form CreatePingForm()
        {
            var form = new Form() {AutoSize = true, AutoSizeMode = AutoSizeMode.GrowAndShrink, Padding = new Padding(10), Text = "Ping Command"};

            FlowLayoutPanel stack;
            form.Controls.Add(stack = new FlowLayoutPanel() {Dock = DockStyle.Fill, AutoSize = true, AutoSizeMode = AutoSizeMode.GrowAndShrink, FlowDirection = FlowDirection.TopDown});

            stack.Controls.Add(new Label() {AutoSize = true, Dock = DockStyle.Top, Text = "Running the ping command.", Padding = new Padding(5)});
            Label labelWaitOrResult;
            stack.Controls.Add(labelWaitOrResult = new Label() {AutoSize = true, Dock = DockStyle.Top, Text = "Please wait…", BackColor = Color.Yellow, Padding = new Padding(5)});

            ConEmuControl conemu;
            var sbText = new StringBuilder();
            stack.Controls.Add(conemu = new ConEmuControl() {AutoStartInfo = null, MinimumSize = new Size(800, 600), Dock = DockStyle.Top});
            ConEmuSession session = conemu.Start(new ConEmuStartInfo() {AnsiStreamChunkReceivedEventSink = (sender, args) => sbText.Append(args.GetMbcsText()), ConsoleProcessCommandLine = "ping 8.8.8.8"});
            session.ConsoleProcessExited += delegate
            {
                Match match = Regex.Match(sbText.ToString(), @"\(.*\b(?<pc>\d+)%.*?\)", RegexOptions.Multiline);
                if(!match.Success)
                {
                    labelWaitOrResult.Text = "Ping execution completed, failed to parse the result.";
                    labelWaitOrResult.BackColor = Color.PaleVioletRed;
                }
                else
                {
                    labelWaitOrResult.Text = $"Ping execution completed, lost {match.Groups["pc"].Value} per cent of packets.";
                    labelWaitOrResult.BackColor = Color.Lime;
                }
            };
            session.ConsoleEmulatorClosed += delegate { form.Close(); };

            return form;
        }
        protected override void OnMouseClick(MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                System.Windows.Forms.Form F = FindForm();

                switch (_ControlButton)
                {
                case Button.Minimize:
                    F.WindowState = FormWindowState.Minimized;
                    break;

                case Button.MaximizeRestore:
                    if (F.WindowState == FormWindowState.Normal)
                    {
                        F.WindowState = FormWindowState.Maximized;
                    }
                    else
                    {
                        F.WindowState = FormWindowState.Normal;
                    }
                    break;

                case Button.Close:
                    F.Close();
                    break;
                }
            }

            Invalidate();
            base.OnMouseClick(e);
        }
示例#32
0
 private void saveButton_Click(object sender, EventArgs e)
 {
     save();
     if (!CrewChief.Debugging)
     {
         // have to add "multi" to the start args so the app can restart
         List <String> startArgs = new List <string>();
         startArgs.AddRange(Environment.GetCommandLineArgs());
         if (!startArgs.Contains("multi"))
         {
             startArgs.Add("multi");
         }
         System.Diagnostics.Process.Start(Application.ExecutablePath, String.Join(" ", startArgs.ToArray())); // to start new instance of application
         parent.Close();                                                                                      //to turn off current app
     }
 }
示例#33
0
        public static string ShowDialog(string text, string caption, List <string> list)
        {
            System.Windows.Forms.Form prompt = new System.Windows.Forms.Form()
            {
                Width           = 500,
                Height          = 550,
                FormBorderStyle = FormBorderStyle.FixedDialog,
                Text            = caption,
                StartPosition   = FormStartPosition.CenterScreen
            };
            Label textLabel = new Label()
            {
                Left = 50, Top = 20, Text = text, Width = 1000
            };
            ListBox listBox = new ListBox()
            {
                Left = 50, Top = 50, Width = 400
            };

            list.Insert(0, "none");
            listBox.DataSource = list;
            Button confirmation = new Button()
            {
                Text = "Ok", Left = 350, Width = 100, Top = 400, DialogResult = DialogResult.OK
            };

            confirmation.Click += (sender, e) => { prompt.Close(); };
            prompt.Controls.Add(listBox);
            prompt.Controls.Add(confirmation);
            prompt.Controls.Add(textLabel);
            prompt.AcceptButton = confirmation;

            return(prompt.ShowDialog() == DialogResult.OK ? listBox.Text : "none");
        }
示例#34
0
        protected override void OnMouseUp(MouseEventArgs mevent)
        {
            base.OnMouseUp(mevent);
            //
            switch (this.eDockPanelFloatFormButtonItemStyle)
            {
            case DockPanelFloatFormButtonItemStyle.eMaxButton:
                System.Windows.Forms.Form form = this.OperationForm;
                if (form == null)
                {
                    return;
                }
                if (form.WindowState == FormWindowState.Maximized)
                {
                    form.WindowState = FormWindowState.Normal;
                }
                else
                {
                    form.WindowState = FormWindowState.Maximized;
                }
                break;

            case DockPanelFloatFormButtonItemStyle.eCloseButton:
                System.Windows.Forms.Form form2 = this.OperationForm;
                if (form2 != null)
                {
                    form2.Close();
                }
                break;
            }
        }
        private static void AuthorizeClient(AppServiceClient appServiceClient)
        {
            Form frm = new Form();
            frm.Width = 640;
            frm.Height = 480;

            WebBrowser browser = new WebBrowser();
            browser.Dock = DockStyle.Fill;

            browser.DocumentCompleted += (sender, e) =>
            {
                if (e.Url.AbsoluteUri.IndexOf(URL_TOKEN) > -1)
                {
                    var encodedJson = e.Url.AbsoluteUri.Substring(e.Url.AbsoluteUri.IndexOf(URL_TOKEN) + URL_TOKEN.Length);
                    var decodedJson = Uri.UnescapeDataString(encodedJson);
                    var result = JsonConvert.DeserializeObject<dynamic>(decodedJson);
                    string userId = result.user.userId;
                    string userToken = result.authenticationToken;

                    appServiceClient.SetCurrentUser(userId, userToken);

                    frm.Close();
                }
            };

            browser.Navigate(string.Format(@"{0}login/twitter", GW_URL));

            frm.Controls.Add(browser);
            frm.ShowDialog();
        }
示例#36
0
 public void FormClosing(Form frmSource)
 {
     if (frmSource != null)
     {
         frmSource.Close();
     }
 }
示例#37
0
 private void EnableCoroutining(Form host)
 {
     try
     {
         using (basicNoUI = new BasicNoUIObj())
         {
             // replace with your application's secret
             basicNoUI.Secret = new Guid("00000000-0000-0000-0000-000000000000");
             basicNoUI.Initialize();
             basicNoUI.AttachToForm(host, ManageConstants.OnDoEvents);
             // this application's UI executes from this script
             // Note: the application will not return from this call
             // until the application is closing down.
             basicNoUI.RunThis("Sub Main\r\nDo\r\nWait .01\r\nLoop\r\nEnd Sub");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.StackTrace + ": " + ex.Message);
     }
     finally
     {
         if (basicNoUI != null)
         {
             // When we get here, the application is exiting from the infnite loop
             basicNoUI = null;
             host.Close();
         }
         else
         {
             MessageBox.Show("Not able to enable parallel processing of scripts!");
         }
     }
 }
示例#38
0
        public static DialogResult ShowDialog(Form parent, Form dialog)
        {
            //Enabled = false;
            Form shadow = new Form();
            shadow.MinimizeBox = false;
            shadow.MaximizeBox = false;
            shadow.ControlBox = false;

            shadow.Text = "";
            shadow.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            //shadow.Size = Size;
            shadow.BackColor = Color.Black;
            shadow.Opacity = 0.3;
            shadow.ShowInTaskbar = false;
            shadow.WindowState = FormWindowState.Maximized;
            shadow.Show();
            //shadow.Location = Location;
            shadow.Enabled = false;

            var mask = new frmOpacity(parent, dialog);
            dialog.StartPosition = FormStartPosition.CenterParent;
            //mask.Show();
            var result = dialog.ShowDialog(mask);
            mask.Close();
            shadow.Close();
            return result;
        }
示例#39
0
 /// <summary>
 /// Shows a blank game screen.
 /// </summary>
 /// <param name="form">This form will be hidden.</param>
 public static void EnterNewPuzzle(Form form)
 {
     form.Hide();
     GameForm gform = new GameForm(new Grid(), false);
     gform.ShowDialog();
     form.Close();
 }
        /// <summary>
        /// Returns a SharePoint on-premises / SharePoint Online ClientContext object. Requires claims based authentication with FedAuth cookie.
        /// </summary>
        /// <param name="siteUrl">Site for which the ClientContext object will be instantiated</param>
        /// <param name="icon">Optional icon to use for the popup form</param>
        /// <returns>ClientContext to be used by CSOM code</returns>
        public ClientContext GetWebLoginClientContext(string siteUrl, System.Drawing.Icon icon = null)
        {
            var cookies = new CookieContainer();
            var siteUri = new Uri(siteUrl);

            var thread = new Thread(() =>
            {
                var form = new System.Windows.Forms.Form();
                if (icon != null)
                {
                    form.Icon = icon;
                }
                var browser = new System.Windows.Forms.WebBrowser
                {
                    ScriptErrorsSuppressed = true,
                    Dock = DockStyle.Fill
                };


                form.SuspendLayout();
                form.Width  = 900;
                form.Height = 500;
                form.Text   = string.Format("Log in to {0}", siteUrl);
                form.Controls.Add(browser);
                form.ResumeLayout(false);

                browser.Navigate(siteUri);

                browser.Navigated += (sender, args) =>
                {
                    if (siteUri.Host.Equals(args.Url.Host))
                    {
                        var cookieString = CookieReader.GetCookie(siteUrl).Replace("; ", ",").Replace(";", ",");
                        if (Regex.IsMatch(cookieString, "FedAuth", RegexOptions.IgnoreCase))
                        {
                            var _cookies = cookieString.Split(',').Where(c => c.StartsWith("FedAuth", StringComparison.InvariantCultureIgnoreCase) || c.StartsWith("rtFa", StringComparison.InvariantCultureIgnoreCase));
                            cookies.SetCookies(siteUri, string.Join(",", _cookies));
                            form.Close();
                        }
                    }
                };

                form.Focus();
                form.ShowDialog();
                browser.Dispose();
            });

            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            thread.Join();

            if (cookies.Count > 0)
            {
                var ctx = new ClientContext(siteUrl);
                ctx.ExecutingWebRequest += (sender, e) => e.WebRequestExecutor.WebRequest.CookieContainer = cookies;
                return(ctx);
            }

            return(null);
        }
示例#41
0
        public static DialogResult ShowDialog(this DefultForm form, UserControl Childe, Size sizeForm)
        {
            using (var Temp = new System.Windows.Forms.Form())
            {
                //Temp.Dock = System.Windows.Forms.DockStyle.Fill;
                Temp.WindowState     = System.Windows.Forms.FormWindowState.Maximized;
                Temp.BackColor       = System.Drawing.Color.SlateGray;
                Temp.Opacity         = 0.7D;
                Temp.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
                Temp.ShowInTaskbar   = false;
                Temp.StartPosition   = FormStartPosition.CenterParent;
                Temp.KeyDown        += (sender, e) =>
                {
                    if (e.KeyCode == System.Windows.Forms.Keys.Escape)
                    {
                        form.Close();
                    }
                };
                Temp.Load += (sender, e) =>
                {
                    Childe.Dock = DockStyle.Fill;
                    form.panel1.Controls.Add(Childe);
                    form.Size          = sizeForm;
                    form.StartPosition = FormStartPosition.CenterParent;
                    form.ShowDialog();
                    Temp.Close();
                };
                Temp.ShowDialog();
            }

            return(form.DialogResult);
        }
		public void TestTabMovement_DoesLoopCorrectly_ThroughSpannedRowCells()
		{
			using (var form = new Form())
			{
				
				Grid grid1 = new Grid();
				grid1.Redim(40,3);
				grid1.FixedColumns = 1;
				grid1.FixedRows = 1;

				Random rnd = new Random();
				for (int r = 0; r < grid1.RowsCount/2; r++)
				{
					for (int c = 0; c < grid1.ColumnsCount; c++)
					{
						grid1[r * 2, c] = new SourceGrid.Cells.Cell(r*c);
						grid1[r * 2, c].RowSpan = 2;
					}
				}
				
				form.Controls.Add(grid1);
				form.Show();
				
				Assert.AreEqual(true, grid1.Selection.Focus(new Position(0, 0), true));
				Assert.AreEqual(new Position(0, 0), grid1.Selection.ActivePosition);
				
				Assert.AreEqual(true, grid1.Selection.Focus(new Position(1, 0), true));
				Assert.AreEqual(new Position(1, 0), grid1.Selection.ActivePosition);
				
				form.Close();
			}
		}
示例#43
0
        private static DialogResult DisplayForm(object[] parms)
        {
            MenuItem mnu = (MenuItem)parms[0];

            System.Windows.Forms.Form frm = CTechCore.Tools.Forms.IsFormInstantiated(mnu.RuntimeFormType).FirstOrDefault();
            if (frm != null)
            {
                frm.Close();
                frm.Dispose();
                frm = null;
            }

            if (mnu.RequiresParametersOnConstructer)
            {
                frm = (System.Windows.Forms.Form)Activator.CreateInstance(mnu.RuntimeFormType, parms);
            }
            else
            {
                frm = (System.Windows.Forms.Form)Activator.CreateInstance(mnu.RuntimeFormType, new object[] { });
            }
            frm.WindowState   = FormWindowState.Normal;
            frm.StartPosition = FormStartPosition.CenterScreen;
            if (!mnu.DisplayAllFormBeforeLoad)
            {
                frm.MdiParent = CTechCore.Tools.Forms.IsFormInstantiated("frmMain").FirstOrDefault();
                frm.Show();
            }
            else
            {
                frm.ShowDialog();
            }
            return(DialogResult.OK);
        }
示例#44
0
        public static string ShowDialog(string text, string caption)
        {
            System.Windows.Forms.Form prompt = new System.Windows.Forms.Form();
            prompt.Width  = 500;
            prompt.Height = 150;
            prompt.Text   = caption;
            Label textLabel = new Label()
            {
                Left = 50, Top = 20, Text = text
            };

            System.Windows.Forms.TextBox textBox = new System.Windows.Forms.TextBox()
            {
                Left = 50, Top = 50, Width = 400
            };
            Button confirmation = new Button()
            {
                Text = "Ok", Left = 350, Width = 100, Top = 70
            };

            confirmation.Click += (sender, e) => { prompt.Close(); };
            prompt.Controls.Add(confirmation);
            prompt.Controls.Add(textLabel);
            prompt.Controls.Add(textBox);
            prompt.ShowDialog();
            return(textBox.Text);
        }
示例#45
0
 /// <summary>
 /// Function for close message
 /// </summary>
 /// <param name="frm"></param>
 public static void CloseMessage(System.Windows.Forms.Form frm)
 {
     if ((MessageBox.Show("Are you sure to exit ? ", "ShopIn", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) == DialogResult.Yes)
     {
         frm.Close();
     }
 }
示例#46
0
        /// <summary>
        /// Shows the exception viewer.
        /// </summary>
        /// <param name="errorMessage">The error message.</param>
        /// <param name="actionType">Type of the action.</param>
        /// <param name="source">The source.</param>
        private static void ShowExceptionViewer(string errorMessage, ActionType actionType, System.Windows.Forms.Form source)
        {
            try
            {
                string tempErrorMessage = errorMessage.Replace("\\n", "\n");
                MessageBox.Show(tempErrorMessage, ConfigurationWrapper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                switch (actionType)
                {
                case ExceptionManager.ActionType.CloseCurrentForm:
                {
                    source.Close();
                    break;
                }

                case ExceptionManager.ActionType.CloseApplication:
                {
                    Application.Exit(new System.ComponentModel.CancelEventArgs(true));
                    break;
                }
                }
            }
            catch (Exception)
            {
            }
            //////ExceptionViewer exceptionViewer = new ExceptionViewer(errorMessage, actionType);
            //////exceptionViewer.Owner = source;
            //////exceptionViewer.ShowDialog();
            //////exceptionViewer.Dispose();
        }
		public static void ShowDialog( string Header, string Message )
		{
			Form Dialog = new Form();

			Dialog.Width			= 400;
			Dialog.Height			= 120;
			Dialog.Text				= Header;
			Dialog.FormBorderStyle	= FormBorderStyle.FixedDialog;

			Label LabelMessage = new Label() 
			{ 
				//Left		= 0, 
				//Top		= 0, 
				Width		= Dialog.Width,
				Height		= Dialog.Height / 2,
				Text		= Message, 
				TextAlign	= ContentAlignment.MiddleCenter,
				Font		= new Font( SystemFonts.MessageBoxFont.FontFamily.Name, 12.0f, FontStyle.Bold, GraphicsUnit.Point ) 
			};

			LabelMessage.TextAlign = ContentAlignment.MiddleCenter;

			Button ButtonOK = new Button() { Text = "OK", Left = Dialog.Width - 100, Width = 80, Top = Dialog.Height - 70 };

			ButtonOK.Click += ( sender, e ) => { Dialog.Close(); };

			Dialog.Controls.Add( ButtonOK );
			Dialog.Controls.Add( LabelMessage );
			Dialog.ShowDialog();
		}
示例#48
0
 public static string ShowDialog(string text, string caption)
 {
     Form prompt = new Form();
     prompt.SizeGripStyle = SizeGripStyle.Hide;
     prompt.MaximizeBox = false;
     prompt.FormBorderStyle = FormBorderStyle.FixedSingle;
     prompt.Width = 500;
     prompt.Height = 150;
     prompt.Text = caption;
     Label textLabel = new Label() { Left = 50, Top=20, Text=text, Width=400 };
     TextBox textBox = new TextBox() { Left = 50, Top=50, Width=400 };
     Button confirmation = new Button() { Text = "Doorgaan", Left=350, Width=100, Top=80 };
     confirmation.Click += (sender, e) => {
         if(textBox.Text.Length > 0) {
             prompt.Close();
         } else {
             MessageBox.Show("Geen data ingevoerd. Voer de gevraagde gegevens in om door te gaan.", "Geen data ingevoerd.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     };
     prompt.Controls.Add(confirmation);
     prompt.Controls.Add(textLabel);
     prompt.Controls.Add(textBox);
     prompt.FormClosing += (sender, e) => {
         if(textBox.Text.Length == 0) {
             var result = MessageBox.Show("Geen data ingevoerd. Voer de gevraagde gegevens in om door te gaan. Druk op Annuleren om service te stoppen", "Geen data ingevoerd.", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
             if(result == DialogResult.Cancel){
                 Application.ExitThread();
             } else {
                 e.Cancel = true;
             }
         }
     };
     prompt.ShowDialog();
     return textBox.Text;
 }
 public static System.Windows.Forms.DialogResult DimAndShowDialog(this System.Windows.Forms.Form parentForm, System.Windows.Forms.Form dlg)
 {
     System.Windows.Forms.DialogResult result = System.Windows.Forms.DialogResult.None;
     var dimForm = new System.Windows.Forms.Form()
     {
         Text = "",
         ControlBox = false,
         FormBorderStyle = System.Windows.Forms.FormBorderStyle.None,
         Size = parentForm.Size,
         Location = parentForm.Location,
         BackColor = System.Drawing.Color.Black,
         ShowInTaskbar = false,
         Opacity = .5
     };
     dlg.FormClosing += (oSender, oE) =>
     {
         dimForm.Close();
         dimForm = null;
     };
     dimForm.Shown += (oSender, oE) =>
     {
         dimForm.Location = parentForm.Location;
         result = dlg.ShowDialog();
         parentForm.Focus();
     };
     dimForm.ShowDialog();
     return result;
 }
示例#50
0
 public static void volverAPadreYCerrar(Form ventanaPadre, Form ventana)
 {
     ventanaPadre.Visible = true;
     ventanaPadre.Activate();
     ventanaPadre.Select();
     ventana.Close();
 }
示例#51
0
 static public void CloseSplashScreen()
 {
     if (_splashForm != null)
     {
         _splashForm.Close();
         _splashForm = null;
     }
 }
示例#52
0
文件: frmFloor.cs 项目: pcthanh/POS
 private void CloseFormTool()
 {
     System.Windows.Forms.Form f1 = System.Windows.Forms.Application.OpenForms["frmTool"];
     if (f1 != null)
     {
         f1.Close();
     }
 }
示例#53
0
        private void OpenChildForm(System.Windows.Forms.Form childForm)
        {
            if (currentChildForm != null)
            {
                currentChildForm.Close();
            }

            currentChildForm          = childForm;
            childForm.TopLevel        = false;
            childForm.FormBorderStyle = FormBorderStyle.None;
            childForm.Dock            = DockStyle.Fill;
            panelDekstop.Controls.Add(childForm);
            panelDekstop.Tag = childForm;
            childForm.BringToFront();
            childForm.Show();
            labelTextH.Text = childForm.Text;
        }
 private void dlgClassFile_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (frmPrev != null)
     {
         frmPrev.Close();
         frmPrev = null;
     }
 }
 private void OpenOrSaveDialog(FileDialog dialog, System.Windows.Forms.Form form)
 {
     dialog.Title            = "Messages.FileDialogTitle";
     dialog.Filter           = filter; //"TXT files (*.txt)|*.txt|All files (*.*)|*.*";
     dialog.InitialDirectory = folder;
     dialog.FileName         = file;
     //----------------------------------------------------------------//
     if (dialog.ShowDialog() == DialogResult.OK)
     {
         form.Close();
         SelectedFile = dialog.FileName;
     }
     else
     {
         form.Close();
         SelectedFile = "";
     }
 }
示例#56
0
 protected override void ExitThreadCore()
 {
     if (mainForm != null)
     {
         // before we exit, give the main form a chance to clean itself up.
         mainForm.Close();
     }
     base.ExitThreadCore();
 }
示例#57
0
        private void FolderDialog(System.Windows.Forms.Form form)
        {
            FolderBrowserDialog dialog = new FolderBrowserDialog();

            dialog.Description = Messages.FolderDialogTitle;
            dialog.RootFolder  = Environment.SpecialFolder.MyComputer;
            //----------------------------------------------------------------//
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                form.Close();
                SelectedFolder = dialog.SelectedPath;
            }
            else
            {
                form.Close();
                SelectedFolder = "";
            }
        }
示例#58
0
        // Event handler invoked when the PropertyValueDialogControl indicates that the dialog should close
        private void OnCloseParentDialog(object sender, EventArgs e)
        {
            // Unhook on to the system user-preference changed event.
            SystemEvents.UserPreferenceChanged -= new UserPreferenceChangedEventHandler(OnUserPreferenceChanged);

            if (_dialogWindow != null)
            {
                _dialogWindow.Close();
            }
        }
        public static string ShowDialog(string text, string currentValue, string promptName)
        {
            System.Windows.Forms.Form prompt = new System.Windows.Forms.Form();
            prompt.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
            prompt.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
            prompt.ClientSize          = new System.Drawing.Size(284, 67);
            prompt.MaximizeBox         = false;
            prompt.MinimizeBox         = false;
            prompt.Text            = promptName;
            prompt.FormBorderStyle = FormBorderStyle.FixedSingle;
            prompt.Name            = "dlgPrompt";
            prompt.Font            = new Font("Calibri", 9, FontStyle.Regular);
            prompt.StartPosition   = FormStartPosition.CenterParent;

            System.Windows.Forms.Label textLabel = new System.Windows.Forms.Label()
            {
                Location = new System.Drawing.Point(12, 5), Size = new System.Drawing.Size(185, 23), Text = text, TextAlign = System.Drawing.ContentAlignment.MiddleLeft
            };
            System.Windows.Forms.TextBox textBox = new System.Windows.Forms.TextBox()
            {
                Location = new System.Drawing.Point(12, 34), Size = new System.Drawing.Size(185, 23), Text = currentValue
            };
            System.Windows.Forms.Button confirmation = new System.Windows.Forms.Button()
            {
                Location = new System.Drawing.Point(217, 5), Size = new System.Drawing.Size(55, 23), Text = "OK"
            };
            System.Windows.Forms.Button cancel = new System.Windows.Forms.Button()
            {
                Location = new System.Drawing.Point(217, 34), Size = new System.Drawing.Size(55, 23), Text = "Cancel"
            };

            confirmation.Click += (sender, e) => { prompt.Close(); };
            cancel.Click       += (sender, e) => { textBox.Text = string.Empty;  prompt.Close(); };

            prompt.Controls.Add(confirmation);
            prompt.Controls.Add(cancel);
            prompt.Controls.Add(textLabel);
            prompt.Controls.Add(textBox);
            prompt.ShowDialog();

            return(textBox.Text);
        }
示例#60
0
        public static void SingleInstance(this System.Windows.Forms.Form formApp)
        {
            bool   createdNew;
            string appName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;

            mutex = new Mutex(true, appName, out createdNew);
            if (!createdNew)
            {
                formApp.Close();
            }
        }