|
The path is in 2D space; i.e. relative to x and y for your purposes. Why make the object "relative to the incline of the plane" ?
|
|
|
|
|
I would consider using WPF.
WPF has "storyboard" controls that can animate multiple properties; on different elements; at different rates; at the same time.
You should be able to find WPF Storyboard samples in the docs and be up and running in no time.
|
|
|
|
|
Yes, that would be nice. But I can only use GDI+ for this project...
|
|
|
|
|
It sounds like you're trying to implement an animation of the block sliding down the plane. If so, here's what you need to do...
Grab the wallclock time when you start the animation, then at each refresh, find out the difference between the starting wallclock time and the current wallclock time, and solve the equations to determine where to draw the block for that point in time.
You could also do delta times and solve the equation incrementally, but errors start to creep in that way, so you might as well do the above.
.NET wise, You're looking to capture DateTime.Now and then get TimeSpan from the differences. TimeSpan.TotalSeconds is probably what you want or your formulas.
We can program with only 1's, but if all you've got are zeros, you've got nothing.
|
|
|
|
|
in many mvc application i have seen people use virtual keyword. i like to know the reason.
i have seen a video from this url https://www.youtube.com/watch?v=BSgAA8y5ViU which generate UI from model with scaffolding
so see this code first
public class Student
{
public int StudentId;
public string StudentName;
public int CourseId;
public virtual Course Courses { get; set; }
}
public class Course
{
public int CourseId;
public string CourseName;
public string Description;
public ICollection<Student> Students {get;set;}
public ICollection<Lecture> Lectures { get; set; }
}
public class Lecture
{
public int LectureId;
public string LectureName;
public int CourseId;
public virtual Course Courses { get; set; }
}
1) why lecture and student class has common property called CourseId ?
2) see below code
public ICollection<Student> Students {get;set;}
public ICollection<Lecture> Lectures { get; set; }
why they use ICollection ? they can use here list etc ?
3) why Courses property has been declared with virtual keyword in lecture and student class ?
please help me to understand the real use of virtual keyword
public virtual Course Courses { get; set; }
in what kind of scenario we use virtual keyword ? what is advantage ?
please explain the reason why people use virtual keyword with EF ?
thanks
tbhattacharjee
|
|
|
|
|
|
In Entity Framework, properties are declared as virtual to allow for change-tracking, and for lazy-loading of related entities. EF dynamically generates a proxy class derived from your POCO class to add these features, and needs to override the properties to do so.
Requirements for Creating POCO Proxies[^]
The CourseId and (incorrectly named) Courses properties are used to define a one-to-many foreign-key relationship to the Course entity:
Entity Framework Relationships & Navigation Properties[^]
The relationship between students and courses doesn't make logical sense - one student can currently only take one course. In a real example, I would expect to see a many-to-many relationship.
The type of a navigation property must implement ICollection<T> to allow for lazy-loading. Whilst you could use IList<T> , it usually doesn't make sense, since the related entities don't have a defined order. (You could also use a concrete type, but it's generally better to stick with an interface.)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
"virtual" WAS supposed to reflect that this particular property was a "navigation" property; I could probably find a reference if I tried; but I do not think there was ever any "practical" explanation.
I would omit the keyword and still wind up with relationships simply based on names; I had to explicitly resort to "ignoring" those properties to keep EF from "assuming" things.
Same with ICollection; it's usually easier to simply always use Lists, if you plan to use LINQ anyway.
Virtual, ICollection AND "partial classes" are all about "extending" basic POCO's; and not any particular EF magic, IMO.
Oh; and I control "lazy loading" via EF dbContext configuration options and run-time calls; not any C# "keywords".
|
|
|
|
|
Hello,
I am developing an application which triggers when there is a windows explorer window in foreground. My application triggers a window (form) which will be placed on screen near the opened windows explorer (Planning to keep it just below the search option).
I am not opening the windows explorer in my code, instead user will open windows explorer and I will trigger my application whenever there is a windows explorer in foreground.
Here is my code,
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text;
public class Form1
{
private void Form1_Load(System.Object sender, System.EventArgs e)
{
Timer1.Interval = 100;
Timer1.Start();
}
private void Timer1_Tick(System.Object sender, System.EventArgs e)
{
dynamic hWnd = GetForegroundWindow();
if (ClassName(hWnd) == "CabinetWClass") {
Timer1.Stop();
using (Form2 f2 = new Form2()) {
f2.ShowDialog();
}
}
}
#region "API"
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern Int32 GetClassName(System.IntPtr hWnd, System.Text.StringBuilder lpClassName, Int32 nMaxCount);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr GetForegroundWindow();
private string ClassName(IntPtr hWnd)
{
StringBuilder sb = new StringBuilder(256);
GetClassName(hWnd, sb, 256);
return sb.ToString;
}
public Form1()
{
Load += Form1_Load;
}
#endregion
}
But I am not getting anything to get the window position of foreground "windows explorer" window.
Is there any way to read the position of current foreground “Windows Explorer” window using .net?
modified 16-Aug-16 4:58am.
|
|
|
|
|
This probably isn't going to work quite the way you want, due to the way Windows Explorer works - it doesn't always open a new top-level process for an instance. At the moment I have two Windows Explorer processes: one with a single Main window (and the title is the folder name) and one with two sub windows (and it's title is an empty string). How I got there? Depends on how you open the window. The "one off" one was opened by an app, the other two were opened from the task bar...
But you probably want to start here:
Process[] all = Process.GetProcesses();
foreach (Process p in all)
{
string name = p.ProcessName;
IntPtr hWnd = p.MainWindowHandle;
string title = p.MainWindowTitle;
if (p.ProcessName.Contains("explorer"))
{
Console.WriteLine("{0}:{1}", p.ProcessName, p.MainWindowTitle);
}
}
The handle should give you the location of the main window (but you may need to do some delving to find "combined" windows)
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
sorry for the confusion, I have edited the question. I facing trouble in getting window position of windows explorer.
|
|
|
|
|
srikrishnathanthri wrote: dynamic hWnd = GetForegroundWindow();
No need to declare hWnd as dynamic ; just declare it as IntPtr . You're not using any dynamic resolution[^] on the variable, so you're just slowing your code down for no reason.
If you want to find the position of a window, you need to call GetWindowRect :
GetWindowRect function (Windows)[^]
GetWindowRect: pinvoke.net[^]
[StructLayout(LayoutKind.Sequential)]
private struct RECT
{
public int Left;
public int Top;
public int Right;
public int Bottom;
public System.Drawing.Point Location
{
get { return new System.Drawing.Point(Left, Top); }
}
}
[DllImport("user32.dll", SetLastError=true)]
private static extern bool GetWindowRect(IntPtr hwnd, out RECT lpRect);
private static System.Drawing.Point GetWindowLocation(IntPtr hWnd)
{
RECT lpRect;
if (!GetWindowRect(hWnd, out lpRect)) return System.Drawing.Point.Empty;
return lpRect.Location;
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I want to set the autocomplete to the textbox using LINQ to entities.
This is my code:
using (Reference_TraductionEntities context = new Reference_TraductionEntities())
{
var source = new AutoCompleteStringCollection();
var name = from a in context.Feuil1Prenom
where a.PRENOMF.StartsWith("i")
select a.PRENOMF;
source.AddRange(name.ToArray());
textBox1.AutoCompleteCustomSource = source;
textBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
}
This code is OK , but just with the character "i ", I want autocomplete with any character entry in textbox
How can i fix it ?
Thanks,
|
|
|
|
|
Change StartsWith("i") to actually contain the text the user is typing.
This space for rent
|
|
|
|
|
Very Thanks Pete O'Hanlon !!!
I replace starts with "i" to starts with textbox1.text ...
It works !!!
|
|
|
|
|
You're welcome. Glad you got it sorted.
This space for rent
|
|
|
|
|
hi guys i am converting java code to use sentiwordnet
tempDictionary.get(synTerm).put(synTermRank,
synsetScore);
that line in java how we can write in C#.
i triedlike tthat tempdict[synterm].Add(syntermrank, sysnsetscore);
|
|
|
|
|
|
Does anyone has accounting software source code which includes trial balance, profit & loss a/c and balance sheet??
|
|
|
|
|
Yes
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Yes, many software and finance companies. However, they are unlikely to give it to anyone for nothing.
|
|
|
|
|
This is not a proper question for this site (hence the responses you already got), I would encourage you to either make a specific question or google for what you are looking for. Or just navigate through sourceforge or github.
If you think you can do a thing or think you can't do a thing, you're right - Henry Ford
Emmanuel Medina Lopez
|
|
|
|
|
Background
I'm working with a special type of "offline files"/"File sync"-system, and need to compare a users files on his/her computer en on the file server. The place I'm working at, was tricked by a Microsoft rep back in 2011, to use a system that works kind of like OneDrive. The user have their files on their laptop, and when connected to the organization's network, the files are synched with the file server
The situation
Now that they are migrating to Windows 10, and actual OneDrive, I've discovered a problem: the files aren't always synched. The process is now to run a set of tools on the users' computers,to check for errors, and if there is, (and there's plenty of errors), the user need to confirm which file is the correct one.
The problem
I've been testing WinMerge, and similar programs, but they are mostly garbage for the use I need them for. I need flexibility, meaning that i need complex filtering options, (e.g. folder names to increase processing speed), but also the options to look at files in different manners, (hashes of files, metadata, or byte-for-byte). THis could actually be done in powershell pretty "easily", however, the user will have to interact with this in a meaningfull and friendly way, so an interface is therefore needed, which allows for sorting, opening selected files, copying, copy to third party location, copy to same location with a pre/su-fix. Options to reduce timeconsumption, (quick mode which only checks metadata, or hashmode, which is in the middle, or slow mode byte-for-byte)
My solution (thus far)
Create this as a C# program, with a nice interface, (I've made the interface, and it's actually very nice), I've tested some simple file comparisons, but I need you guys' input. Am I doing this right or is there a piece of software that I haven't found yet??
Thanks for all input 
|
|
|
|
|
I wrote some software that did this back about 2010 and originally used the Sync Framework to do the work, but ended up hand rolling so much of my own code that there's very little original SF left in there. The approach I took was more than you'll need to do because you're looking at, effectively, a one time operation but my solution took care of client/server/server syncing - anyway, the crux of the checks - you check the file lengths first - if they are different, you don't need to do any further checking as you have a potential problem file; then you create a hash of both files, if they don't match, you have files that need checking. The vast majority of cases are caught by the file length as it's comparatively rare that you'll end up with different files that are the same size.
This space for rent
|
|
|
|
|
Why don't you use the aforementioned Powershell to run a scan/replace script and toss that into NETLOGON. Seems like that would be easier and more sensible, as it sounds like you're using organizational shares.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|