|
This is more about the ASP.Net than the .Net framework. The question you posted is not really clear. Here is what I assume you are saying:
There is a web page with a map in it. A user can draw a circle on the map and then click a button which opens a dialog. When you click somewhere else, the pop up is lost.
If this is correct, you are looking for a modal dialog. There are plenty available on the web which are jQuery and/or bootstrap based. Take a look and choose the one that suits you. This however means that you will not be able to operate the map while pop up is on.
There is still a question of how are you showing the form? Is this a redirect? pop up? something else?
"It is easy to decipher extraterrestrial signals after deciphering Javascript and VB6 themselves.", ISanti[ ^]
|
|
|
|
|
"
When you click somewhere else, the pop up is lost. "
No. Acctly, when I put the map in expanded mode, and make a circle on the map and click the circle button, the window that should appear above the map, it is hidden behind the map. When I exit from expanded mode, the window appears.
In the link below, I take a screenshot of web page screen. In the screenshot, the rectangular blue image is the hidden window behind the map.
UploadDeImagens.com.br - 27155-1.jpg[^]
|
|
|
|
|
I am also interested in this question, I will be glad to hear good advice.
|
|
|
|
|
This is my first project. .Net project is used for me how to create database and design page in mini project.
|
|
|
|
|
|
I need to parse what can potentially be a deep directory tree (Windows User Profile Directory), and populate a TreeView with the files and subdirectories. I have code that "works," but it's a little slow, and it hangs up the form more than I like.
Obviously, it takes a while to parse the profile tree, and I will eventually run that code in a separate thread, but another problem that I'm having is the TreeView displays the root node, collapsed, initially, and expanding that node holds the UI up again, and it takes 5 seconds or so to expand and become responsive again.
Just wondering if anyone could give me some pointers that may optimize the processes?
Thanks.
This is my Form1.cs code. Not much interesting outside of it.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Collections.Specialized;
namespace Migration_Wizard {
public partial class Form1 : Form {
bool debug_on = true;
public enum LOG_LEVEL {
debug = 0,
info = 1,
warning = 2,
error = 3,
access = 4
}
DirectoryInfo profiles_obj;
StringCollection inaccessible = new StringCollection();
StringCollection momentaries = new StringCollection();
StringCollection copy_failures = new StringCollection();
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam);
private const int WM_VSCROLL = 277;
private const int SB_PAGEBOTTOM = 7;
internal static void ScrollToBottom(RichTextBox richTextBox) {
SendMessage(richTextBox.Handle, WM_VSCROLL, (IntPtr)SB_PAGEBOTTOM, IntPtr.Zero);
richTextBox.SelectionStart = richTextBox.Text.Length;
}
public Form1() {
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) {
profiles_obj = new DirectoryInfo(@"C:\Users");
DirectoryInfo[] profiles = profiles_obj.GetDirectories();
foreach(DirectoryInfo profile in profiles) {
if(
profile.Name != "All Users" &&
profile.Name != "Default" &&
profile.Name != "Default User" &&
profile.Name != "Public"
) {
profileNameCbx.Items.Add(profile);
}
}
}
private void ProfileNameCbx_SelectedValueChanged(object sender, EventArgs e) {
var profileDir_path = @"C:\Users\" + profileNameCbx.Text;
if (Directory.Exists(profileDir_path)) {
browserTV.Nodes.Clear();
TreeNode root = browserTV.Nodes.Add(profileDir_path, profileNameCbx.Text, 0);
ParseProfile(root);
}
}
public void ParseProfile(TreeNode parent_node) {
DirectoryInfo parent_di = new DirectoryInfo(parent_node.Name);
FileInfo[] files = null;
DirectoryInfo[] subDirs = null;
try {
files = parent_di.GetFiles("*.*").Where(file =>
(file.Attributes & FileAttributes.Hidden) == 0).ToArray();
}
catch(UnauthorizedAccessException e) {
inaccessible.Add(parent_di.FullName);
Log(e.Message, LOG_LEVEL.access);
}
catch (DirectoryNotFoundException e) {
momentaries.Add(parent_di.FullName);
Log(e.Message, LOG_LEVEL.warning);
}
catch (Exception e) {
Log(e.Message, LOG_LEVEL.debug);
}
if(files != null) {
subDirs = parent_di.GetDirectories().Where(directory =>
(directory.Attributes & FileAttributes.Hidden) == 0).ToArray(); ;
foreach(DirectoryInfo dir in subDirs) {
TreeNode this_node = parent_node.Nodes.Add(dir.FullName, dir.Name, 0);
ParseProfile(this_node);
}
foreach (FileInfo f in files) {
parent_node.Nodes.Add(f.FullName, f.Name, 1);
}
}
}
public void Log(string msg, LOG_LEVEL lvl) {
Color orig = consolRTB.SelectionColor;
switch (lvl) {
case LOG_LEVEL.debug:
if (debug_on) {
consolRTB.SelectionColor = Color.FromArgb(225, 226, 239);
}
break;
case LOG_LEVEL.info:
consolRTB.SelectionColor = Color.FromArgb(170,246,131);
break;
case LOG_LEVEL.warning:
consolRTB.SelectionColor = Color.FromArgb(255, 217, 125);
break;
case LOG_LEVEL.error:
consolRTB.SelectionColor = Color.FromArgb(238, 96, 85);
break;
case LOG_LEVEL.access:
consolRTB.SelectionColor = Color.FromArgb(145, 196, 242);
break;
}
consolRTB.AppendText(String.Concat("\n",msg,"\n"));
consolRTB.SelectionColor = orig;
}
private void ConsolRTB_TextChanged(object sender, EventArgs e) {
if (autoscrollChB.Checked) {
ScrollToBottom(consolRTB);
}
}
private void AutoscrollChB_CheckedChanged(object sender, EventArgs e) {
if (autoscrollChB.Checked) {
ScrollToBottom(consolRTB);
}
}
}
}
|
|
|
|
|
GetFiles and GetDirectories return an array containing all files/directories found. The methods can't return until that array has been populated. You should probably try using EnumerateFiles and EnumerateDirectories instead, and try to remove the ToArray calls.
DirectoryInfo.EnumerateFiles Method (System.IO) | Microsoft Docs[^]
DirectoryInfo.EnumerateDirectories Method (System.IO) | Microsoft Docs[^]
You're also going to want to skip "reparse-point" directories, which can have your code running around in circles.
Reparse Points - Windows applications | Microsoft Docs[^]
There's no need to pass *.* as the search pattern; just omit the parameter.
I'd be inclined to avoid the simple LINQ filters, since you're processing a lot of directories.
Try something like this:
public void ParseProfile(TreeNode parent_node, DirectoryInfo parent_di = null)
{
if (parent_di == null) parent_di = new DirectoryInfo(parent_node.Name);
try
{
foreach (DirectoryInfo dir in parent_di.EnumerateDirectories())
{
if ((dir.Attributes & FileAttributes.Hidden) != 0) continue;
if ((dir.Attributes & FileAttributes.ReparsePoint) != 0) continue;
TreeNode this_node = parent_node.Nodes.Add(dir.FullName, dir.Name, 0);
ParseProfile(this_node, dir);
}
foreach (FileInfo file in parent_di.EnumerateFiles())
{
if ((file.Attributes & FileAttributes.Hidden) != 0) continue;
parent_node.Nodes.Add(file.FullName, file.Name, 1);
}
}
catch (UnauthorizedAccessException e)
{
inaccessible.Add(parent_di.FullName);
Log(e.Message, LOG_LEVEL.access);
}
catch (DirectoryNotFoundException e)
{
momentaries.Add(parent_di.FullName);
Log(e.Message, LOG_LEVEL.warning);
}
catch (Exception e)
{
Log(e.Message, LOG_LEVEL.debug);
throw;
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
modified 14-Aug-19 4:24am.
|
|
|
|
|
This is definitely better. Thank you. As you say, EnumerateX methods perform much better, and the code is just nicer/cleaner.
Used a separate thread for ParseProfile, and I'm happy with the performance now.
I still have the issue when I expand the root node in the TreeView, but I think the only way I'm going to make that act any better is to populate the treeview as needed when nodes are expanded.
Again, thank you. This is a nice improvement.
modified 14-Aug-19 10:40am.
|
|
|
|
|
Harley Burton wrote: One small typo in the second foreach block if anyone is using this. (file, and f names)
Thanks - I've fixed the typo.
Harley Burton wrote: Used a separate thread for ParseProfile
If you're running it from a background thread, you might need to Invoke the methods that manipulate the tree.
How to: Make thread-safe calls to Windows Forms controls | Microsoft Docs[^]
Eg:
TreeNode this_node = (TreeNode)Invoke((Func<TreeNode, DirectoryInfo, TreeNode>)((p, d) => p.Nodes.Add(d.FullName, d.Name, 0)), parent_node, dir); and:
Invoke((Action<TreeNode, FileInfo>)((p, f) => p.Nodes.Add(f.FullName, f.Name, 1)), parent_node, file);
Harley Burton wrote: I still have the issue when I expand the root node in the TreeView, but I think the only way I'm going to make that act any better is to populate the treeview as needed when nodes are expanded.
I'd agree with that - populate a single level at a time when a directory node is expanded. You'll obviously need to add a "dummy" node to each directory node so that you can expand it.
TreeView.BeforeExpand Event (System.Windows.Forms) | Microsoft Docs[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks again. I had already handled everything to get it working as a background thread, but I WAS trying to figure out the best way to populate the treeview as needed. I was headed down the wrong path, and dummy nodes will even allow me to only display the expand element [+] on nodes with children, so that's a bonus.
|
|
|
|
|
I'm using a Visual Studio 2017 Setup project to install a Windows Service.
The Application folder's DefaultLocation is set to "[ProgramFilesFolder][Manufacturer][ProductName]"
The Manufacturer property is set to "My Company". The ProductName property is set to "My Product".
When I run this Installer, it dumps all files into the root of c:. The Manufacturer and Product folders are not created.
Anyone have any idea what's wrong?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
What is a Visual Studio 2017 Setup project?
Are you talking about InstallShield Limited Edition?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
|
Is there information about an example of a tiff file display for .net core?
|
|
|
|
|
Possibly, and Google will know where to find it.
|
|
|
|
|
I couldnt find it
|
|
|
|
|
Maybe there is no such product.
|
|
|
|
|
Ignore the server; use a Javascript solution instead:
https://github.com/seikichi/tiff.js[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I'm trying to install a .net Windows Service on a PC with WIn 10 running. Windows Defender is running, and this installation has to be done without turning it off. The setup will be called from another setup. We CAN addd the setup.exe to the list of allowed apps.
So, I've tried creating a VS installer Project by following this. It works in stat it sees to install, but the service istself doesn't appear in the Servics dialog.
So, if I manually turn on Real-Time Protection in Windows Defender and use InstallUtil, it installs fine. But with Real-Time Protection on it fails, so I'm trying to get the Installer to work.
I'm open to suggestions here.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Have your main installer call InstallUtil to install the service.
Never mind, I didn't read carefully enough.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Kevin Marois wrote: if I manually turn on Real-Time Protection ... it installs fine. But with Real-Time Protection on it fails
Was that first "on" meant to be an "off"?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I built a project payroll management system with vb 2012, MS Access 200 db, Crystal Report XI. In report section when I want to see a employee salary detail record for more than 2 year the report showing month year field not arranged like March_2019 than November_2016, January_2018 want to short by November_2016 than January_2018, March_2019. My access db table contain Month_Year format. So please help me to short the report.
|
|
|
|
|
NSE India wrote: So please help me to short the report.
Do you mean "sort?"
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Assuming you're storing the data in the correct data type - ie: as a date - then you need to sort by the raw date value before you format it. Otherwise, it will be sorted alphabetically, and "August 2019" will come before "January 2010".
If you're storing the data as a string instead of a date, then you don't stand a chance. Fix the data storage first.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I have a project that is referencing Newtonsoft.Json V11, but, some other assembly in my solution is is referencing Newtonsoft.Json V6.
I beleive that some 3rd party assembly is the culprit, but how do I find it? is there a tool to list all assemblies and their dependancies?
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|