/// <summary> /// Affiche un champ contenant plusieurs informations, separes par SEPARATEUR_LISTE, /// un lien pour chaque morceau d'information /// </summary> /// <param name="key"></param> /// <param name="link"></param> /// <param name="texte"></param> private void afficheInfoLinks(Label key, LinkLabel link, string texte) { char[] SEPARATEURS = { ',' }; if (texte?.Length > 0) { key.Show(); link.Show(); link.Links.Clear(); string[] valeurs = texte.Split(BaseFilms.SEPARATEUR_LISTES_CHAR); string label = ""; int start = 0; foreach (string url in valeurs) { label += url + ", "; int length = url.Length; LinkLabel.Link lk = new LinkLabel.Link(start, length, $"https://www.google.com/search?q={InternetUtils.urlRecherche(url)}"); link.Links.Add(lk); start += length + 2; } link.Text = label; } else { key?.Hide(); link?.Hide(); } }
private void afficheInfoLink(Label key, LinkLabel link, string texte, object data) { if (texte?.Length > 0) { key?.Show(); link.Links.Clear(); link.Text = texte; link.Links.Add(0, texte.Length, data); } else { key?.Hide(); link?.Hide(); } }
private void BtnNext_Click(object sender, EventArgs e) { this.rtfInfo.Clear(); llAESInfo.Hide(); llListOfInfectedFiles.Hide(); this.lbTitle.Hide(); this.tbPassInput.Show(); this.btnNext.Hide(); this.BtnVerify.Show(); this.rtfInfo.AppendText("Enter password to unlock, then click 'Verify' to begin decryption."); this.rtfInfo.Select(this.rtfInfo.GetFirstCharIndexFromLine(0), this.rtfInfo.Lines[0].Length); this.rtfInfo.SelectionBullet = true; this.rtfInfo.DeselectAll(); }
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { i++; if (i % 2 == 1) { a.Location = new Point(1150, 70); a.Size = new Size(87, 30); a.Text = "Delete User"; this.Controls.Add(a); a.Show(); b.Location = new Point(1150, 110); b.Size = new Size(87, 30); b.Text = "Log out"; this.Controls.Add(b); b.Show(); } else { a.Hide(); b.Hide(); } }
private AppErrorDialog() { if (!appErrorInitialized) { Application.EnableVisualStyles(); appErrorInitialized = true; } string title = FL.AppErrorDialogTitle; string appName = FL.AppName; if (!string.IsNullOrEmpty(appName)) { title = appName + " – " + title; } this.BackColor = SystemColors.Window; this.ControlBox = false; this.MinimizeBox = false; this.MaximizeBox = false; this.Font = SystemFonts.MessageBoxFont; this.FormBorderStyle = FormBorderStyle.FixedDialog; this.ShowInTaskbar = false; this.Size = new Size(550, 300); this.StartPosition = FormStartPosition.CenterScreen; this.Text = title; this.TopMost = true; tablePanel = new TableLayoutPanel(); tablePanel.Dock = DockStyle.Fill; tablePanel.RowCount = 6; tablePanel.RowStyles.Add(new RowStyle(SizeType.AutoSize)); tablePanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100)); tablePanel.RowStyles.Add(new RowStyle(SizeType.AutoSize)); tablePanel.RowStyles.Add(new RowStyle(SizeType.AutoSize)); tablePanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 0)); tablePanel.RowStyles.Add(new RowStyle(SizeType.AutoSize)); tablePanel.ColumnCount = 1; tablePanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); this.Controls.Add(tablePanel); introLabel = new Label(); introLabel.BackColor = Color.FromArgb(221, 74, 59); introLabel.ForeColor = Color.White; introLabel.Dock = DockStyle.Fill; introLabel.AutoSize = true; introLabel.Font = new Font( SystemFonts.MessageBoxFont.FontFamily, SystemFonts.MessageBoxFont.SizeInPoints * 1.3f, SystemFonts.MessageBoxFont.Style); introLabel.MaximumSize = new Size(this.ClientSize.Width, 0); introLabel.Padding = new Padding(6, 4, 7, 6); introLabel.Margin = new Padding(); introLabel.UseCompatibleTextRendering = false; introLabel.UseMnemonic = false; tablePanel.Controls.Add(introLabel); tablePanel.SetRow(introLabel, 0); tablePanel.SetColumn(introLabel, 0); errorPanel = new Panel(); errorPanel.AutoScroll = true; errorPanel.Dock = DockStyle.Fill; errorPanel.Margin = new Padding(7, 8, 10, 6); errorPanel.Padding = new Padding(); tablePanel.Controls.Add(errorPanel); tablePanel.SetRow(errorPanel, 1); tablePanel.SetColumn(errorPanel, 0); errorLabel = new Label(); errorLabel.AutoSize = true; errorLabel.MaximumSize = new Size(this.ClientSize.Width - 20, 0); errorLabel.Padding = new Padding(); errorLabel.Margin = new Padding(); errorLabel.UseCompatibleTextRendering = false; errorLabel.UseMnemonic = false; errorPanel.Controls.Add(errorLabel); logLabel = new LinkLabel(); logLabel.AutoSize = true; logLabel.MaximumSize = new Size(this.ClientSize.Width - 20, 0); logLabel.Margin = new Padding(8, 6, 10, 0); logLabel.Padding = new Padding(); if (FL.LogFileBasePath != null) { logLabel.Text = string.Format(FL.AppErrorDialogLogPath, FL.LogFileBasePath.Replace("\\", "\\\u200B") + "*.fl"); string dir = Path.GetDirectoryName(FL.LogFileBasePath).Replace("\\", "\\\u200B"); logLabel.LinkArea = new LinkArea(FL.AppErrorDialogLogPath.IndexOf("{0}", StringComparison.Ordinal), dir.Length); logLabel.LinkClicked += (s, e) => { Process.Start(Path.GetDirectoryName(FL.LogFileBasePath)); }; } else { logLabel.Text = FL.AppErrorDialogNoLog; logLabel.LinkArea = new LinkArea(0, 0); } logLabel.UseCompatibleTextRendering = false; logLabel.UseMnemonic = false; tablePanel.Controls.Add(logLabel); tablePanel.SetRow(logLabel, 2); tablePanel.SetColumn(logLabel, 0); detailsLabel = new LinkLabel(); detailsLabel.AutoSize = true; detailsLabel.Margin = new Padding(7, 6, 10, 10); detailsLabel.Padding = new Padding(); detailsLabel.TabIndex = 11; detailsLabel.Text = FL.AppErrorDialogDetails; detailsLabel.UseCompatibleTextRendering = false; detailsLabel.Visible = CanShowDetails; tablePanel.Controls.Add(detailsLabel); tablePanel.SetRow(detailsLabel, 3); tablePanel.SetColumn(detailsLabel, 0); var attr = new TypeConverterAttribute(typeof(ExpandableObjectConverter)); TypeDescriptor.AddAttributes(typeof(Exception), attr); grid = new PropertyGrid(); grid.Dock = DockStyle.Fill; grid.Margin = new Padding(10, 10, 10, 10); grid.ToolbarVisible = false; grid.HelpVisible = false; grid.PropertySort = PropertySort.Alphabetical; grid.UseCompatibleTextRendering = false; grid.Visible = false; tablePanel.Controls.Add(grid); tablePanel.SetRow(grid, 4); tablePanel.SetColumn(grid, 0); bool isGridColumnResized = false; grid.Resize += (s, e) => { if (!isGridColumnResized) { isGridColumnResized = true; // Source: http://stackoverflow.com/a/14475276/143684 FieldInfo fi = grid.GetType().GetField("gridView", BindingFlags.Instance | BindingFlags.NonPublic); if (fi != null) { Control view = fi.GetValue(grid) as Control; if (view != null) { MethodInfo mi = view.GetType().GetMethod("MoveSplitterTo", BindingFlags.Instance | BindingFlags.NonPublic); if (mi != null) { mi.Invoke(view, new object[] { 170 }); } mi = view.GetType().GetMethod("set_GrayTextColor", BindingFlags.Instance | BindingFlags.NonPublic); if (mi != null) { mi.Invoke(view, new object[] { Color.Black }); } } } } }; detailsLabel.LinkClicked += (s, e) => { detailsLabel.Hide(); this.Height += 300; this.Top -= Math.Min(this.Top - 4, 150); tablePanel.RowStyles[4].Height = 350; grid.Visible = true; }; buttonsPanel = new TableLayoutPanel(); buttonsPanel.AutoSize = true; buttonsPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink; buttonsPanel.BackColor = SystemColors.Control; buttonsPanel.Dock = DockStyle.Fill; buttonsPanel.Margin = new Padding(); buttonsPanel.Padding = new Padding(10, 10, 10, 10); buttonsPanel.ColumnCount = 4; buttonsPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); buttonsPanel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); buttonsPanel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); buttonsPanel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); tablePanel.Controls.Add(buttonsPanel); tablePanel.SetRow(buttonsPanel, 5); tablePanel.SetColumn(buttonsPanel, 0); sendCheckBox = new CheckBox(); sendCheckBox.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom; sendCheckBox.AutoSize = true; sendCheckBox.Enabled = FL.CanSubmitLog; if (sendCheckBox.Enabled) { sendCheckBox.Checked = true; } sendCheckBox.FlatStyle = FlatStyle.System; sendCheckBox.Margin = new Padding(); sendCheckBox.Padding = new Padding(); sendCheckBox.Text = FL.AppErrorDialogSendLogs; sendCheckBox.UseCompatibleTextRendering = false; buttonsPanel.Controls.Add(sendCheckBox); buttonsPanel.SetRow(sendCheckBox, 0); buttonsPanel.SetColumn(sendCheckBox, 0); nextButton = new Button(); nextButton.AutoSize = true; nextButton.AutoSizeMode = AutoSizeMode.GrowAndShrink; nextButton.FlatStyle = FlatStyle.System; nextButton.Margin = new Padding(6, 0, 0, 0); nextButton.Padding = new Padding(2, 1, 2, 1); nextButton.Text = FL.AppErrorDialogNext; nextButton.UseCompatibleTextRendering = false; nextButton.UseVisualStyleBackColor = true; nextButton.Visible = false; nextButton.Click += (s, e) => { ShowNextError(); }; buttonsPanel.Controls.Add(nextButton); buttonsPanel.SetRow(nextButton, 0); buttonsPanel.SetColumn(nextButton, 1); terminateButton = new Button(); terminateButton.AutoSize = true; terminateButton.AutoSizeMode = AutoSizeMode.GrowAndShrink; terminateButton.FlatStyle = FlatStyle.System; terminateButton.Margin = new Padding(6, 0, 0, 0); terminateButton.Padding = new Padding(2, 1, 2, 1); terminateButton.Text = FL.AppErrorDialogTerminate; terminateButton.UseCompatibleTextRendering = false; terminateButton.UseVisualStyleBackColor = true; terminateButton.Click += (s, e) => { StartSubmitTool(); Close(); FL.Shutdown(); Environment.Exit(1); }; buttonsPanel.Controls.Add(terminateButton); buttonsPanel.SetRow(terminateButton, 0); buttonsPanel.SetColumn(terminateButton, 2); continueButton = new Button(); continueButton.AutoSize = true; continueButton.AutoSizeMode = AutoSizeMode.GrowAndShrink; continueButton.FlatStyle = FlatStyle.System; continueButton.Margin = new Padding(6, 0, 0, 0); continueButton.Padding = new Padding(2, 1, 2, 1); continueButton.Text = FL.AppErrorDialogContinue; continueButton.UseCompatibleTextRendering = false; continueButton.UseVisualStyleBackColor = true; continueButton.Click += (s, e) => { StartSubmitTool(); Close(); }; buttonsPanel.Controls.Add(continueButton); buttonsPanel.SetRow(continueButton, 0); buttonsPanel.SetColumn(continueButton, 3); }
private AppErrorDialog() { if (!appErrorInitialized) { Application.EnableVisualStyles(); appErrorInitialized = true; } string title = FL.AppErrorDialogTitle; string appName = FL.AppName; if (!string.IsNullOrEmpty(appName)) { title = appName + " – " + title; } AutoScaleDimensions = new SizeF(96, 96); AutoScaleMode = AutoScaleMode.Dpi; scaleFactor = CurrentAutoScaleDimensions.Width / 96; BackColor = SystemColors.Window; ControlBox = false; MinimizeBox = false; MaximizeBox = false; Font = SystemFonts.MessageBoxFont; FormBorderStyle = FormBorderStyle.FixedDialog; ShowInTaskbar = false; Size = new Size(Scale(550), Scale(350)); StartPosition = FormStartPosition.CenterScreen; Text = title; TopMost = true; tablePanel = new TableLayoutPanel(); tablePanel.Dock = DockStyle.Fill; tablePanel.RowCount = 6; tablePanel.RowStyles.Add(new RowStyle(SizeType.AutoSize)); tablePanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100)); tablePanel.RowStyles.Add(new RowStyle(SizeType.AutoSize)); tablePanel.RowStyles.Add(new RowStyle(SizeType.AutoSize)); tablePanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 0)); tablePanel.RowStyles.Add(new RowStyle(SizeType.AutoSize)); tablePanel.ColumnCount = 1; tablePanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); Controls.Add(tablePanel); introLabel = new Label(); introLabel.BackColor = Color.FromArgb(221, 74, 59); introLabel.ForeColor = Color.White; introLabel.Dock = DockStyle.Fill; introLabel.AutoSize = true; introLabel.Font = new Font( SystemFonts.MessageBoxFont.FontFamily, SystemFonts.MessageBoxFont.SizeInPoints * 1.3f, SystemFonts.MessageBoxFont.Style); introLabel.MaximumSize = new Size(ClientSize.Width, 0); introLabel.Padding = Scale(new Padding(6, 4, 7, 6)); introLabel.Margin = new Padding(); introLabel.UseCompatibleTextRendering = false; introLabel.UseMnemonic = false; tablePanel.Controls.Add(introLabel); tablePanel.SetRow(introLabel, 0); tablePanel.SetColumn(introLabel, 0); errorPanel = new Panel(); errorPanel.AutoScroll = true; errorPanel.Dock = DockStyle.Fill; errorPanel.Margin = Scale(new Padding(7, 8, 10, 6)); errorPanel.Padding = new Padding(); tablePanel.Controls.Add(errorPanel); tablePanel.SetRow(errorPanel, 1); tablePanel.SetColumn(errorPanel, 0); errorLabel = new Label(); errorLabel.AutoSize = true; // Always keep the vertical scrollbar width free because the label wouldn't get smaller // when the vertical scrollbar appears and then the horizontal scrollbar kicks in as well. errorLabel.MaximumSize = new Size(errorPanel.ClientSize.Width - SystemInformation.VerticalScrollBarWidth - 2, 0); errorLabel.Padding = new Padding(); errorLabel.Margin = new Padding(); errorLabel.UseCompatibleTextRendering = false; errorLabel.UseMnemonic = false; errorPanel.Controls.Add(errorLabel); logLabel = new LinkLabel(); logLabel.AutoSize = true; logLabel.MaximumSize = new Size(ClientSize.Width - Scale(20), 0); logLabel.Margin = Scale(new Padding(8, 6, 10, 0)); logLabel.Padding = new Padding(); if (FL.LogFileBasePath != null) { logLabel.Text = string.Format(FL.AppErrorDialogLogPath, FL.LogFileBasePath.Replace("\\", "\\\u200B") + "*.fl"); string dir = Path.GetDirectoryName(FL.LogFileBasePath).Replace("\\", "\\\u200B"); logLabel.LinkArea = new LinkArea(FL.AppErrorDialogLogPath.IndexOf("{0}", StringComparison.Ordinal), dir.Length); logLabel.LinkClicked += (s, e) => { Process.Start(Path.GetDirectoryName(FL.LogFileBasePath)); }; } else { logLabel.Text = FL.AppErrorDialogNoLog; logLabel.LinkArea = new LinkArea(0, 0); } logLabel.UseCompatibleTextRendering = false; logLabel.UseMnemonic = false; tablePanel.Controls.Add(logLabel); tablePanel.SetRow(logLabel, 2); tablePanel.SetColumn(logLabel, 0); detailsLabel = new LinkLabel(); detailsLabel.AutoSize = true; detailsLabel.Margin = Scale(new Padding(7, 6, 10, 10)); detailsLabel.Padding = new Padding(); detailsLabel.TabIndex = 11; detailsLabel.Text = FL.AppErrorDialogDetails; detailsLabel.UseCompatibleTextRendering = false; detailsLabel.Visible = CanShowDetails; tablePanel.Controls.Add(detailsLabel); tablePanel.SetRow(detailsLabel, 3); tablePanel.SetColumn(detailsLabel, 0); var attr = new TypeConverterAttribute(typeof(ExpandableObjectConverter)); TypeDescriptor.AddAttributes(typeof(Exception), attr); grid = new PropertyGrid(); grid.Dock = DockStyle.Fill; grid.Margin = Scale(new Padding(10, 10, 10, 10)); grid.ToolbarVisible = false; grid.HelpVisible = false; grid.PropertySort = PropertySort.Alphabetical; grid.UseCompatibleTextRendering = false; grid.Visible = false; tablePanel.Controls.Add(grid); tablePanel.SetRow(grid, 4); tablePanel.SetColumn(grid, 0); bool isGridColumnResized = false; grid.Resize += (s, e) => { if (!isGridColumnResized) { isGridColumnResized = true; // Source: http://stackoverflow.com/a/14475276/143684 FieldInfo fi = grid.GetType().GetField("gridView", BindingFlags.Instance | BindingFlags.NonPublic); if (fi != null) { Control view = fi.GetValue(grid) as Control; if (view != null) { MethodInfo mi = view.GetType().GetMethod("MoveSplitterTo", BindingFlags.Instance | BindingFlags.NonPublic); if (mi != null) { mi.Invoke(view, new object[] { Scale(170) }); } mi = view.GetType().GetMethod("set_GrayTextColor", BindingFlags.Instance | BindingFlags.NonPublic); if (mi != null) { mi.Invoke(view, new object[] { Color.Black }); } } } } }; detailsLabel.LinkClicked += (s, e) => { detailsLabel.Hide(); int maxHeight = Screen.FromControl(this).Bounds.Height; int missingHeight = 0; int desiredHeight = Height + Scale(300); Height = desiredHeight; if (Height < desiredHeight) { // A window is automatically constrained to the size of its screen, so we can // compare the current size with what we had requested to know how much is // missing for the layout. missingHeight = desiredHeight - Height; } Top -= Scale(Math.Min(Top - 4, 150)); if (Top < 0) { Top = 0; } tablePanel.RowStyles[4].Height = Scale(350) - missingHeight; grid.Visible = true; }; buttonsPanel = new TableLayoutPanel(); buttonsPanel.AutoSize = true; buttonsPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink; buttonsPanel.BackColor = SystemColors.Control; buttonsPanel.Dock = DockStyle.Fill; buttonsPanel.Margin = new Padding(); buttonsPanel.Padding = Scale(new Padding(10, 10, 10, 10)); buttonsPanel.ColumnCount = 4; buttonsPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); buttonsPanel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); buttonsPanel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); buttonsPanel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); tablePanel.Controls.Add(buttonsPanel); tablePanel.SetRow(buttonsPanel, 5); tablePanel.SetColumn(buttonsPanel, 0); sendCheckBox = new CheckBox(); sendCheckBox.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom; sendCheckBox.AutoSize = true; sendCheckBox.Enabled = FL.CanSubmitLog; if (sendCheckBox.Enabled) { sendCheckBox.Checked = true; } sendCheckBox.FlatStyle = FlatStyle.System; sendCheckBox.Margin = new Padding(); sendCheckBox.Padding = new Padding(); sendCheckBox.Text = FL.AppErrorDialogSendLogs; sendCheckBox.UseCompatibleTextRendering = false; buttonsPanel.Controls.Add(sendCheckBox); buttonsPanel.SetRow(sendCheckBox, 0); buttonsPanel.SetColumn(sendCheckBox, 0); nextButton = new Button(); nextButton.AutoSize = true; nextButton.AutoSizeMode = AutoSizeMode.GrowAndShrink; nextButton.FlatStyle = FlatStyle.System; nextButton.Margin = Scale(new Padding(6, 0, 0, 0)); nextButton.Padding = Scale(new Padding(2, 1, 2, 1)); nextButton.Text = FL.AppErrorDialogNext; nextButton.UseCompatibleTextRendering = false; nextButton.UseVisualStyleBackColor = true; nextButton.Visible = false; nextButton.Click += (s, e) => { ShowNextError(); }; buttonsPanel.Controls.Add(nextButton); buttonsPanel.SetRow(nextButton, 0); buttonsPanel.SetColumn(nextButton, 1); terminateButton = new Button(); terminateButton.AutoSize = true; terminateButton.AutoSizeMode = AutoSizeMode.GrowAndShrink; terminateButton.FlatStyle = FlatStyle.System; terminateButton.Margin = Scale(new Padding(6, 0, 0, 0)); terminateButton.Padding = Scale(new Padding(2, 1, 2, 1)); terminateButton.Text = FL.AppErrorDialogTerminate; terminateButton.UseCompatibleTextRendering = false; terminateButton.UseVisualStyleBackColor = true; terminateButton.Click += (s, e) => { StartSubmitTool(); Close(); FL.Shutdown(); Environment.Exit(1); }; buttonsPanel.Controls.Add(terminateButton); buttonsPanel.SetRow(terminateButton, 0); buttonsPanel.SetColumn(terminateButton, 2); continueButton = new Button(); continueButton.AutoSize = true; continueButton.AutoSizeMode = AutoSizeMode.GrowAndShrink; continueButton.FlatStyle = FlatStyle.System; continueButton.Margin = Scale(new Padding(6, 0, 0, 0)); continueButton.Padding = Scale(new Padding(2, 1, 2, 1)); continueButton.Text = FL.AppErrorDialogContinue; continueButton.UseCompatibleTextRendering = false; continueButton.UseVisualStyleBackColor = true; continueButton.Click += (s, e) => { StartSubmitTool(); Close(); }; buttonsPanel.Controls.Add(continueButton); buttonsPanel.SetRow(continueButton, 0); buttonsPanel.SetColumn(continueButton, 3); }