|
I still don't get your question. What exactly are you having problems with? Is it on retrieving the date time stamps from the file? Or on the subtracting part? By the way, once you've put the date time stamps on a collection class(a List , for example), I'm sure you won't have a problem on the subtraction/addition part because you already have some code for it.
Signature construction in progress. Sorry for the inconvenience.
|
|
|
|
|
Adding the same offset to all entries does not change the speed of the subtitles, it just shifts them in time.
To change the speed, add a different offset depending on the number of nanoseconds (or some other unit) from the start, or stated differently, multiply the time by something.
For example, to convert 23.978 FPS to 23.976, multiply each time by 23.978 / 23.976, or perhaps slightly more accurately (due to rounding), multiply the time by 23.978, then divide it by 23.976. You can factor out the fact that those are not integers by multiplying by 23978 (make sure there is no overflow) and then dividing by 23976, but if you use integer division, the division always rounds downwards and you get no chance to round To Nearest (so you'd get when using doubles and then rounding).
If you're now thinking "what does multiplying a time even mean", it means taking the number of nanoseconds (or some other unit) that the time represents (it's just an offset from the beginning of course), do the math on that number, and convert it back to a time-thing again (with rounded as necessary).
modified 24-Jul-13 6:23am.
|
|
|
|
|
Extraordinary explanation Harold ! Well done.
But if I have to set that time, not knowing the initial time (i will test some predefined values) but if i am not so lucky in finding that value, how I can proceed?
ex of testing pseudocode :
inputTime=? outputTime=23.976 (i check movie properties);
if inputTime = 30, outputting to 23.976 will have the desired effect?
no?
then, if inputTime = 25, outputting to 23.976 will have the desired effect?
no?
then, if inputTime = 23, ...etc
This i will do manually from a list of defaults (30,25,23,etc) -Or writing it myself in a textbox whatever value i feel is right - but orbiting the default values.
My question is:
if I will have 0 for inputTime, How I will do the math then?
Your solution is: t=t*outputTime/inputTime;
if inputTime >0, t will have some specific duration.
if inputTime = 0 (I don't know what encoding can have that subtitle), t =0 and all my sub time will be 0. Subtitle file ruined.
I must make my program to guess the subtitle encoding (Its FPS encoded time) ?
Or go on manually set the inputTime? (from list of defaults and/or textbox with custom values)
Thank you!
~q12~
modified 25-Jul-13 13:17pm.
|
|
|
|
|
I don't know, I can't think of anything except a manual test that probably doesn't even work well:
See what at time the last line from the subs appears (in the sub file), and compare that with the time in the movie that the last line in the subs should appear. Then, assuming the beginning isn't shifted, you could get an approximate ratio with videotime/subtime, or the approximate old FPS with newfps*videotime/subtime.
|
|
|
|
|
Ok, Harold, Thank you very much for your help.
Your answer is the correct one, that helped me.
[newfps*videotime/subtime] - got it now.
|
|
|
|
|
I am setting formauthentication.setauthcoddkie and on the action i have written [authorise] attribute
now if i type the page url directly it redirects me to login page which is correct
but when i login then it still show the login page
how to make sure that once i have logged in it shows the page. i am using my own custom database and tables
i tried
if (HttpContext.User.Identity.IsAuthenticated) also but it is not going to the controller at all
it just kicks out even if i login
any help is appreciated
|
|
|
|
|
If you could post the code for the custom stuff, that would be handy (edit your original question rather than replying to me will be better).
Without your code it's hard to provide an answer, it sounds like the provider isn't honouring your cookie. One thing I will add is that custom-securing apps is both hard and prone to error, so you really should check out your reasons for doing this. The first thing I'd do in your position is a sanity check: Do I really need custom code, and if so can I base (preferably sub-class) it on the existing providers. In the past subclassing has provided me with the functionality I need whilst saving a lot of hassle. This article[^] explains more fully than I can in a reply such as this.
|
|
|
|
|
I'm creating a socket server in which I'm getting a string like this.
IPEndPoint ipEnd = new IPEndPoint(IPAddress.Any, 5656);
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
sock.Bind(ipEnd);
sock.Listen(100);
Socket clientSock = sock.Accept();
while (true)
{
clientData = new byte[1024];
receivedBytesLen = clientSock.Receive(clientData);
clientDataInString = Encoding.ASCII.GetString(clientData, 0, receivedBytesLen);
Console.WriteLine("Received Data{0}",clientDataInString);
if(clientDataInString.Contains("Start"))
{
.....any method call....
}
}
I want to use this clientDataInString or the received string in another method.
Like this:
void abc()
{
if(clientDatainString.containg("A"))
{
Console.Writeline("Print A");
}
else if(clientDatainString.containg("B"))
{
Console.Writeline("Print B");
}
}
How can I use this String like this?
Please Suggest..
|
|
|
|
|
CodingHell wrote: How can I use this String like this?
Please Suggest.. Suggest what? You use this string the same way that you would use any string. Your question is not very clear.
Use the best guess
|
|
|
|
|
I'm unable to use the received string in a method because server socket is working in main method but abc method is not a part of this main.
So my motive is to switch and use received string in other methods of my program except where these are being received.
|
|
|
|
|
Then you need to pass the string to the other method as a fuction parameter.
Use the best guess
|
|
|
|
|
Pass the string as a parameter
[...]
Console.WriteLine("Received Data{0}",clientDataInString);
abc(clientDataInString);
} Of course, abc() has to accept a parameter of type System.String then:
void abc(string input)
{
if(input.Contains("A"))
{
Console.WriteLine("Print A");
}
else if(input.Contains("B"))
{
Console.WriteLine("Print B");
}
}
Ciao,
luker
|
|
|
|
|
I'm new to this, or precisely just realize that visual studio had this in the properties folder below visual studio project.
I'm planning to put important things like connection strings inside.
I tried to save a simple text in the setting and save it.
When I run the application, in the debug folder appear "WindowsFormsApplication1.exe.config" file.
I know that it's the setting I created, but the value of the setting is not inside.
When I re-run the application, it was able to load the text i saved before.
Where did the setting save the value?
Btw sorry for bad english.
|
|
|
|
|
|
private void button1_Click(object sender, EventArgs e)
{
Properties.Settings.Default.Constr = this.textBox1.Text;
Properties.Settings.Default.Save();
}
private void Form1_Load(object sender, EventArgs e)
{
this.textBox1.Text = Properties.Settings.Default.Constr;
}
Constr is the setting I create.
Actually I'm going to put licensing there too, of course I will encrypt it before I save.
Now I still can't find it.
This is what I use > http://msdn.microsoft.com/en-us/library/aa730869%28v=vs.80%29.aspx[^]
|
|
|
|
|
That's only one of the config files. It's like a blueprint holding the values you enter in Visual Studio at coding time.
What your application saves at runtime is stored in a user-dependent copy of that file somewhere in the region of "Documents and Settings/$YourUserName$/Application Data/$Company$/$ApplicationNameWithSomeAlphaNumericFuzz$/$ProductVersion$/user.config"
The exact location may depend on your OS version.
Ciao,
luker
|
|
|
|
|
lukeer wrote: "Documents and Settings/$YourUserName$/Application Data/$Company$/$ApplicationNameWithSomeAlphaNumericFuzz$/$ProductVersion$/user.config"
I found this but nothing inside.
"C:\Documents and Settings\Administrator\Application Data\Microsoft Corporation\Microsoft (R) Visual Studio (R) 2010\1.0.30319.1"
There are no strange company name in Application Data.
Btw thank you for answering.
Edit :
I found it here[^]
It's just like what you answered, I missed Local Settings before Application Data.
Thank you very much.
modified 23-Jul-13 6:00am.
|
|
|
|
|
Midnight Ahri wrote: I found it here[^]
Documented on MSDN[^].
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I have the following Setup:
1) The WPF Thread itself (the MainWindow), which stores the Controls to Display my Content, and the Thread Safe Properties with the content to display.
2) The Update Thread (System.Threading.Thread, not BackgreoundWorker). This Thread updates the Properties of the WPF Thread.
3) The Draw Thread (System.Threading.Thread, not BackgreoundWorker), which actually manipulates the Controls of the WPF Thread (Adding Canvas, Removing Canvas, Setting Text, ...)
My Main problem is the thing, that the WPF Thread is storing the Thread Safe Properties. My Update Routine and Draw Routine are both called very very often (1000 Times a secound).
And thats exactly the problem. The WPF Thread is totally blocked due to the many Get, Set Operations of the other both Threads.
So my first Question is, does someone has an Idea where to store these Properties so the main WPF Thread isn't blocked?
My Secound Problem is the following:
The Update and Draw Thread are both working with the Dispatcher of the WPF thread. If they execute 1000 Times a secound the Dispatcher just runs out of mem (because of too many actions in queue). Is there a way to measure how many actions are in queue and to know if to store another or not. And Secound is there a way to say "Now execute the queue".
I know i can get the state of each dispatcher Object i add. But i don't want to wait till each action is e executed. I want to add as much as possible, so the Update and Draw Thread can run as fast as possible.
My Third side Question is, is my Concept to use WPF for this stupid, or not well planned? Shouldn't i use WPF for this, is there another way to achive my Goal?
My Goal explained:
via Update i have to draw content, very often to be exact, without getting the Part to display the content laggie aka responsive UI.
Please help me with any suggestions or sth else.
As a side Idea i have thought of taking the Thread safe properties into a third thread aka DataThread to store and change, but how can u store Properties into a thread? what is a good way to achive this?
thx in advance
sincerly Synergi
EDIT
Here is an example of one of my Thread Safe Properties. Maybe im loosing much time here. May there is a better Solution for this.
private Nullable<Point> Offset
{
get
{
Nullable<Point> returnValue = null;
object lockObject = objectPool.Aquire();
lockObject = this.offset;
bool locked = false;
bool aquired = false;
System.Threading.Monitor.TryEnter(lockObject, ref locked);
try
{
if (locked)
{
returnValue = this.offset;
aquired = true;
}
}
finally
{
if (locked && aquired)
{
System.Threading.Monitor.Exit(lockObject);
}
}
objectPool.Release(lockObject);
return returnValue;
}
set
{
object lockObject = objectPool.Aquire();
lockObject = this.offset;
bool locked = false;
bool aquired = false;
System.Threading.Monitor.TryEnter(lockObject, ref locked);
try
{
if (locked)
{
if (value.HasValue)
{
this.offset = value.Value;
aquired = true;
}
}
}
finally
{
if (locked && aquired)
{
System.Threading.Monitor.Exit(lockObject);
}
}
objectPool.Release(lockObject);
}
}
modified 22-Jul-13 21:16pm.
|
|
|
|
|
I SERIOUSY DOUBT you're getting 1,000 frames per second nor even have the hardware that can do it. There's just no point to it because the human eye just can't see that. Knock that back to AT MOST 60 frames a second and you might improve your situation dramatically.
|
|
|
|
|
I miss discribed my situation. I dont have over 1000 Frames, my update & Draw Thread are called more then 1000 Times. But that doesn't mean it is really the Render Thread of DirectX.
So now with ur conclusion of slowing it down to 60 fps the gui is now responsive again. Easy Solution.
Side way i still ask if someone knows a way to store properties out of the WPF Thread?
|
|
|
|
|
Hi Folks,
I have a question about the best way to design / redesign my software. I have a program that uses a web services to perform certain tasks. Each task is a different set of request / response classes on the server end and a general function call from the Main Hook. EG.
RequestObject req = new RequestObject("SomeVal");
ResponseObject rsp = new ResponseObject();
rsp = WebServiceHook.Method1(RequestObject);
Each Method takes a different request object and returns a different type of response object.
As it stands i have a class for each of these methods, Each class has a public method Process() that does the interaction. I am trying to determine the best way to group all this code together using OO techniques without sacrificing functionality. I would like just one ProcessMethod in one class that will handle the interaction with the webservice for all the different web methods. So i would only call one ProcessMethod passing a switch of sorts that would define the relevant types and uniques strings that method requires. Some Sample code below:
[ComVisible(false)]
private static InfoRequest infoReq = null;
[ComVisible(false)]
private static InfoResponse infoRsp = null;
public static bool Process(INTERFACEREQUEST COMReq, out INTERFACERESPONSE COMRsp)
{
bool blnReturnVal = false;
CInfoRsp InfoRsp = new CInfoRsp();
CInfoReq InfoReq = (CInfoReq)COMReq;
Globals.dtStart = DateTime.Now;
Globals.Log(Logger.LogLevel.Minimum, Logger.LogType.APIMethodEntryPoint, "SOME TEXT HERE", "AND HERE", InfoReq.SalePointID);
try
{
Globals.TheService.Url = Settings.URL;
infoReq = new InfoRequest();
infoRsp = new InfoResponse();
SetRequest(InfoReq);
CallWEBServiceMethod();
SetCOMResponseValues(InfoRsp);
COMRsp = InfoRsp;
blnReturnVal = AssignCOMResponse(InfoRsp);
}
catch (Exception ee)
{
COMRsp = new CInfoRsp(ee);
blnReturnVal = false;
Globals.Log(Logger.LogLevel.All, Logger.LogType.APIMethodException, ee.ToString() + " " + ee.InnerException);
}
finally
{
InfoRsp = null;
InfoReq = null;
infoReq = null;
infoRsp = null;
GC.Collect();
}
}
Is what i am trying to achieve possible or am i trying to over engineer this solution. It currently works i just find every time i have to add a new web method call i clone one of the existing classes and change the types in the processMethod and anywhere else that's needed. This is quite tedious and prone to bugs.
Thanks In Advance
|
|
|
|
|
|
KeithF wrote: Am i correct in saying this?
Yes.
You'd want an (abstract) base-class that defines the Process method;
public abstract bool Process(BaseProcessArgs args)
{ The factory would return a class that derives from this abstract base-class, with each class having it's own implementation for the Process method. The app would only have to call the method, without knowing specific details on the class.
Varying the parameters can be done in a similar way; EventArgs is a nice example on how to vary parameters, and still have some control. Imagine a base-class for the arguments, called "BaseProcessArgs"; if you'd need to pass a string and an int, your "Args" class would look like below;
class TestArgs: BaseProcessArgs
{
public string TestString { get; set; }
public int TestInt { get; set; }
} Alternatively, if only types will change, you might want to consider a generic class.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Folks,
Question about my design so far, I am wondering if i am going about this the right way?
I have a COM Library created in C#, with COMVisible set to true. This library talks to a 3rd party WebService calling various methods depending on the task at hand. For each Request / Response class exposed by the 3rd party DLL I have a Request / Response Pair (Class and Interface) to Marshal variables specifically for a VC6 application.
Mainly using:
MarshalAs(UnmanagedType.LPStr)]
So with that in my i have added a C# project to the solution to test this code, see test method below:
static void Main(string[] args)
{
ICOMReq iReq = new CCOMReq();
ICOMRsp iRsp = new CCOMRsp();
Link l = new Link();
iReq.Date_Time = DateTime.UtcNow;
iReq.Var2 = "1023758145865";
l.DoMethod1(iReq, out iRsp);
}
The link class looks like so at the moment be but will have all the methods created once the design is correct:
public class Link
{
public bool DoMethod1(ICOMReq _COMReq, out ICOMRsp COMRsp)
{
Method1 WebServiceMethod = new Method1(new Method1Request(), new Method1Response(), (CCOMReq)_COMReq, new CCOMRsp());
WebServiceMethod.Process();
COMRsp = null;
return true;
}
}
Each DoMethod(N) that will be in the link class will look the same performing its task with identical code to the other DoMethods. The key differences between the methods is the Param Types Passed in and the Method1 (Method1Request/Method1Response) type will vary depending on the webmethod to be called.
Class Method1 (There will be one of these for every method I need to implement on the WebService) looks like so:
public class Method1 : WebServiceInterfaceBridge<Method1Request, Method1Response, ICOMReq, ICOMRsp>
{
public Method1(Method1Request WEB_Req, Method1Response WEB_Rsp, CCOMReq COM_Req, ICOMRsp COM_Rsp)
: base(WEB_Req, WEB_Rsp, CBE_Req, CBE_Rsp)
{
WEB_Req.SOME_DATE_TIME = COM_Req.Date_Time;
}
public new void Process()
{
base.Process();
}
public override void LOG()
{
Console.WriteLine(this.WebMethod_Request.MEMBER_VAR_HERE);
}
}
The class (WebServiceInterfaceBridge) that all Method(N) classes will inherit from is shown below:
public abstract class WebServiceInterfaceBridge <T,U,V,W> : WebServiceInterface
where T : class
where U : class
where V : class
where W : class
{
protected T WebMethod_Request;
protected U WebMethod_Response;
protected V COM_Request;
protected W COM_Response;
public WebServiceInterfaceBridge(T tPHSReq, U uPHSRsp, V vCBEReq, W wCBERsp)
{
WebMethod_Request = tPHSReq;
WebMethod_Response = uPHSRsp;
COM_Request = vCBEReq;
COM_Response = wCBERsp;
}
public abstract void LOG();
public void CallWebServiceMethod()
{
WebMethod_Response = CallWebMethod<T, U>(WebMethod_Request);
}
public void Process()
{
LOG();
CallWebServiceMethod();
}
}
And finally here is the class that actually calls the Web service that the WebServiceBridge Class inherits from:
public class WebServiceInterface
{
private ServiceClient WEBSVC = new ServiceClient();
public U CallWebMethod<T, U>(T tRequest)
where T:class
where U:class
{
if (tRequest.GetType() == typeof(Method2Request))
{
Method2Request Req = (Method2Request)(object)tRequest;
Method2Response Rsp = WEBSVC.Method2(Req);
return (U)(object)Rsp;
}
else if (tRequest.GetType() == typeof(Method1Request))
{
Method1Request Req = (Method1Request)(object)tRequest;
Method1Response Rsp = WEBSVC.Method1(Req);
return (U)(object)Rsp;
}
else
{
throw new NullReferenceException();
}
}
}
I have left out my internal classes for marshaling the Req/Rsp's, they are just classes with Member Vars and Get/Set's.
So basically before i carry on with my design I am wondering from an OO point of view if I am approaching this task in the right way or if what I am doing is overkill and could be greatly simplified?
TIA
|
|
|
|
|