|
You have all the information you need to do your own research now.
|
|
|
|
|
The only example I could give you - other than that in the two links - is basically to do it all for you, and that isn't what we are here for!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
sir, i want to resize the controls like label,picturebox,textbox,barcode,etc proportionally in c#...
thanks in advance..
|
|
|
|
|
|
Where's the question part? How to do so? There are some examples out there, listed on Google.
I'd recommend against it though; it isn't very helpful to have a 640x480 form resize to fill the entire 1024x768.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: it isn't very helpful to have a 640x480 form resize to fill the entire 1024x768.
It's very Metro though!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Hi All
My goal is create a usercontrol with some childs controls enabling the editing, in design mode, of this childs, so i'll rearrange the positions of childs.
I found the (partial) solution to my problem generating another problem.
I'll try to explain my problem:
1 Create a UserControl
2 Drop on it a Label (name Label1) at the coordinates 1,1 (EXAMPLE)
3 the code of Control must be appear like this:
//--------------------------------------------------
[Designer(typeof(cntLabelDesigner))] // <-- Use of a custom designer to enable edit of the childs
public partial class cntBaseTextBox : UserControl {
// Expose the label1 creating a public property and serializing it
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public Label lbl { get { return this.Label1; } }
public cntBaseTextBox() {
InitializeComponent();
}
}
// Custom class designer
class cntLabelDesigner : ControlDesigner {
public override void Initialize(IComponent comp) {
base.Initialize(comp);
if (this.Control is cntBaseTextBox) {
var uc = this.Control as cntBaseTextBox;
this.EnableDesignMode(uc.lbl, "xLabel");
}
}
}
//--------------------------------------------------
4 create a form and drop the usercontrol on it, the coordinates writed on form ..designer.cs for the label are 1,1 ....
NOW THE PROBLEM
If i move my label in another position seem to be all OK but if you see the new coordinates wrote on form ..designer.cs are relative to the forms and not relative to the parent control ... infact if i save and recall my form the label will be in another position or is disappeared because it's coordinates ar outside the usercontrol.
Can anyone help me ?
This is a normal behavior or is an IDE's Bug ?
I'm using VS community 2013 Upgrade 4 ...
Thanx in Advance and SFMBE.
Emanuele
-----------------------------------------------------------
After hour and hour of purisms ... i found a Quick & Dirty solution (bleahhh!). On UserContrl Load Events i test if label coordinates are changed (so the coordinates are referred on client area) .. if so i correct the substracting to it the coordinate of user control ... i know that this is a stink solution.
Anyoone had a better solution or can say me if this behaviour is a bug ?
private void cntBaseTextBox_Load(object sender, EventArgs e) {
if (!this.Label.Location.Equals(new Point(4, 4))){
this.Label.Location = new Point(this.Label.Location.X - this.Location.X, this.Label.Location.Y - this.Location.Y);
}
}
modified 29-Apr-15 10:31am.
|
|
|
|
|
This is a normal behavior or is an IDE's Bug ? Well, it's a "normal" behavior in the sense it is doing what your code tells it to do.
If I reproduce your code in Visual Studio 2013, compiling with FrameWork 4.5, I can reliably crash Visual Studio !
Getting the design-time functionality in a UserControl you want is very difficult, and I believe, but am not certain, that it would require writing a custom type-designer.
I'd like to mention two alternatives:
1. by exposing the internal Controls in the UserControl with Public Properties, you do get the ability at design-time ... when you drag-drop the UserControl into a Form, or Panel, or whatever ... to use the Property Browser to edit all aspects of the internal Controls exposed by your the UserControl's public properties.
2. You can enable your UserControl instances ... placed on a Form or whatever ... so you can drag and drop other controls onto/into them: see this Tip/Trick I wrote: [^].
Hope this is helpful !
«To kill an error's as good a service, sometimes better than, establishing new truth or fact.» Charles Darwin in "Prospero's Precepts"
|
|
|
|
|
Thanks for the answer.
I tried the code on sharp-develop and the behavior is the same so isn't an IDE behavior.
My primary goal "WAS" move various controls inside the usercontrol visually. The exposure of property was relatively a secondary problem for me ...
But i noticed that when i enabledign for subcontrols and i move that subcontrols, they loose the "coordinate-link" with the usercontrol, so if i move the user control the subcontrols don't follows .... this aspect have destroyed my dreams 8))) ... so i now i had a classic usercontrol with some subcontrols and an associated smart tags window with a visual configuration style property that change the positions of subcontrols ...
|
|
|
|
|
Recently with the precious help of some forum users i have developed a search application of folders and subfolders. Here's the code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
namespace Procura_Desenhos1._1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void txt_procura_TextChanged(object sender, EventArgs e)
{
}
private void btn_procura_Click(object sender, EventArgs e)
{
string toFind = txt_procura.Text;
var root = new DirectoryInfo(@"c:\");
var matchingDirectories = SafeEnumerateDirectories(root)
.Where(d => string.Equals(d.Name, toFind, StringComparison.OrdinalIgnoreCase))
;
foreach (DirectoryInfo directory in matchingDirectories)
{
Process.Start(new ProcessStartInfo
{
FileName = directory.FullName,
UseShellExecute = true,
Verb = "open"
});
}
}
public static IEnumerable<DirectoryInfo> SafeEnumerateDirectories(DirectoryInfo root)
{
if (root == null) throw new ArgumentNullException("root");
if (!root.Exists) return Enumerable.Empty<DirectoryInfo>();
return SafeEnumerateDirectoriesCore(root);
}
private static IEnumerable<DirectoryInfo> SafeEnumerateDirectoriesCore(DirectoryInfo root)
{
var searchPaths = new Stack<DirectoryInfo>();
searchPaths.Push(root);
while (searchPaths.Count != 0)
{
DirectoryInfo currentPath = searchPaths.Pop();
yield return currentPath;
DirectoryInfo[] subFolders = null;
try
{
foreach (var subDirectory in currentPath.EnumerateDirectories())
{
searchPaths.Push(subDirectory);
}
}
catch (UnauthorizedAccessException)
{
}
}
}
}
}
However the path C: it was only for testing (var root = new DirectoryInfo (@ "C: \");) the goal is that the application search folders on a local server (var root = new DirectoryInfo (@ "\ vgst \ clients \ ");). Inside the folder clients there are hundreds and hundreds of subdirectories with a unique ID that is not repeated, this ID is the reference sale. Already tested and the application works however is very slow in searching ,sometimes takes several minutes to open the folder that we sent to search. Is there any way to accelerate this search?
Thanks again,
|
|
|
|
|
Member 11401516 wrote: Is there any way to accelerate this search
Yes store you data in a database instead of the file system. This is a classic reason why file systems are NOT use to store voluminous data.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Yes, it takes forever to enumerate the directory tree of a drive. No, you're not going to get it to go very much faster at all.
|
|
|
|
|
The first time you do a search, store the directory paths and files in a collection.
Next time, make sure all searches will be against this collection rather than the file directory.
Your search will be faster for future requests.
There is an overhead associated with this approach.
It is good in situations where the file structure is not going to change immediately.
Once the program is closed or the file structure changes, you will have to build / update the collection once again.
|
|
|
|
|
Sounds like Google Desktop, dunnit?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: Sounds like Google Desktop, dunnit?
I don't know. I once built something like this some years ago. Of course, the list was never expected to change.
|
|
|
|
|
I can't help but think that part of the problem is the fact that you're doing a traversal and then doing a search of the results of the traversal. Why not combine the two operations and only return the values that match? You might be tempted to take advantage of something like Parallel.For to help with the traversal because the search looks to be atomic but I would advise against it; ultimately, you're always going to be limited by the hardware and you could well end up making the drive head do more work than it needs to as it jumps around reading the allocation tables because different cores are processing demanding access.
|
|
|
|
|
In the original question[^], he was looking for sub-directories with a specific name at any depth in the tree. To do that, you have to recursively look at all directories, not just the ones that match the name you're looking for.
For example, if you're looking for a directory called "drivers", the parent directories are called "Windows" and "System32". If you only looked inside directories called "drivers", you'd never find it.
However, this new question does make it sound more like he's looking for a directory which is an immediate child of the root directory, which makes the searchPattern parameter a viable option.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
As I said in the comments, if the directories you're looking for are immediate children of the root directory, you'll probably get faster results using this:
private void btn_procura_Click(object sender, EventArgs e)
{
string toFind = txt_procura.Text;
var root = new DirectoryInfo(@"c:\");
var matchingDirectories = root.EnumerateDirectories(toFind, SearchOption.TopDirectoryOnly);
foreach (DirectoryInfo directory in matchingDirectories)
{
Process.Start(new ProcessStartInfo
{
FileName = directory.FullName,
UseShellExecute = true,
Verb = "open"
});
}
}
That will also let you use wildcard characters (* and ? ) in the search box.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I once wrote similar thing and used recursive methods to traverse the folders.
It was quite performant, but indeed searching through files can be time consuming.
What you could do is write some sort of service that creates an index of some sort and make your code search through that index.
just thinking out loud.
|
|
|
|
|
I have this function which append an array of byte to an other array of bytes
but the problem appears when the source contains '\0'
this what I have :
private void Aes_Strcat(sbyte[] a_pchResult, sbyte[] pchResult, int m_iBlockSize)
{
int x = 0;
while (a_pchResult[x] != 0)
{
x++;
}
Buffer.BlockCopy(pchResult, 0, a_pchResult, x, m_iBlockSize);
}
here when the a_pchResult contains for example { -10, 15,3,45,17,25,0,56,41,12,0,0,0,0,0,0}
and I want to add pchResult to it at the end (it means after the '12' element)
but as you say it will add it after '25' because it find the '0' before the end.
any idea how know the last position to add the new array at the end of source array if it contains '\0' element.
|
|
|
|
|
Please do not post the same thing in multiple places - it wastes time and annoys people.
You already have this is QA - so pick one and stick to it!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
.
modified 28-Jan-19 5:54am.
|
|
|
|
|
string filesToDelete = @"roremove.doc";
string[] fileList = System.IO.Directory.GetFiles(rootFolder, filesToDelete);
foreach(string file in fileList)
Here rootFolder is the path of the directory where you have all the files listed.
|
|
|
|
|
|
Message Closed
modified 28-Jan-19 5:55am.
|
|
|
|