|
|
Hi, thank you for the help, I will have to study the properties and events then i will test the code written in the answer. thank you
|
|
|
|
|
You're welcome!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
What was wrong with the answer you got on November 6th. when you asked the same question: [^] ?
Why use three Forms when you can use one Form and UserControls ?
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.
|
|
|
|
|
Hi . nothing wrong but i am new to c# and i have to study the events and property then i will test the code. yes i will try to use form and user control instead, thank you
|
|
|
|
|
Build some business logic, i.e. class(es) for storing the text entered form3 and pass it/them to form1 in buttonAddRow_Click
or make something like this
public struct EnteredText
{
public string t1, t2, t3;
};
public partial class Form3 : Form
{
public delegate void ButtonClick(EnteredText data);
public event ButtonClick OnClick;
...
private void buttonAddRow _Click(object sender, EventArgs e)
{
EnteredText args;
args.t1 = textbox1.Text; args.t2 = ...
if (OnClick != null)
OnClick(args);
}
}
Means you copy the text from the boxes into the struct and fire the event OnClick. Somewhere in Form2 you should do something like this:
Form3 f3 = new Form3();
f3.OnClick += f3_OnClick;
f3.Show();
}
private void f3_OnClick(EnteredText txt)
{
}
|
|
|
|
|
Hi, when i use chart to plot, i have 10 line series and each have 1000 points. i use " chart.series.add("series[i]")" to add series in chart. But when they are all in chart, chart speed is slow and delay, Zoom in and annotation are all delayed.
Can above quesiton be solved?
|
|
|
|
|
Yeah. Don't fill the chart with 10,000 points. Reduce the dataset down to what's important and the redraw will speed up dramatically.
If your graph area is only 300 pixels wide, why are you stuffing in 3 times as many points as it can show?
|
|
|
|
|
Yes,you are right,thank you.
I didnot care of the pixels wide, because i need pricision and smooth curve, so i use 1000 points.
have any other solution to solve it? because if i use 300 points, but maybe i need plot 30 series in chartarea, how to solve it greatly ?
|
|
|
|
|
Ummm, perhaps you didn't hear me... The ONLY way to speed up the drawing of the chart, using any off-the-shelf charting library, is to reduce the number of points.
Now, if you tried to roll-your-own charting library, you could put in some optimizations specific to your requirements to speed things up a bit.
No matter what you do the BIGGEST speed boost is to not draw so many points.
|
|
|
|
|
Thank you all, i will adopt you good idea, to reduce points.
|
|
|
|
|
Oh,i found that if 10000points in 1 series, the chart will not be delay.
So i want to know,how to make series, that 1000 points be in one line, other 1000points be another line.... make 10 series type ,but in 1 series collection?
|
|
|
|
|
Which of the hundreds of different chart controls / libraries are you using?
And, as Dave said, a chart with 10,000 points is never going to perform well.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
As Dave and and Richard said, there are quite a few libraries out there, and adding too many points is probably not a good idea.
However, it may be that the library is optimized for this. Have you checked the lib's documentation?
Best,
John
-- LogWizard Meet the Log Viewer that makes monitoring log files a joy!
|
|
|
|
|
Why are you replying to me instead of the OP?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Sorry, it was my mistake.
-- LogWizard Meet the Log Viewer that makes monitoring log files a joy!
|
|
|
|
|
You might not know what you said.
This space for rent
|
|
|
|
|
public class GcmSender
{
private const string GcmUri = "https://android.googleapis.com/gcm/send";
#region Properties
public string DeviceToken { get; set; }
public string ApiKey { get; set; }
public string ResultJson { get; private set; }
#endregion
HttpWebRequest _gcmRequest;
HttpWebResponse _gcmResponse;
public GcmSender()
{
}
public GcmSender(string deviceToken, string apiKey)
{
DeviceToken = deviceToken;
ApiKey = apiKey;
}
public string Send(string message)
{
if (DeviceToken == null || ApiKey == null)
{
return "[ERROR] Device Token or API Key has not been set";
}
InitGcmClient();
PostPayload(message);
try
{
_gcmResponse = _gcmRequest.GetResponse() as HttpWebResponse;
}
catch (WebException we)
{
return "[ERROR] There is a problem within processing GCM message \n" + we.Message;
}
ResultJson = ReadResponse(_gcmResponse);
return ResultJson;
}
private string ReadResponse(HttpWebResponse response)
{
StreamReader responseReader = new StreamReader(response.GetResponseStream());
return responseReader.ReadToEnd();
}
private void InitGcmClient()
{
_gcmRequest = WebRequest.Create(GcmUri) as HttpWebRequest;
if (_gcmRequest != null)
{
_gcmRequest.ContentType = "application/json";
_gcmRequest.UserAgent = "Android GCM Message Sender Client 1.0";
_gcmRequest.Method = "POST";
_gcmRequest.Headers.Add("Authorization", "key=" + ApiKey);
}
}
private void PostPayload(string message)
{
string payloadString = AssembleJSONPayload(DeviceToken, message);
byte[] payloadByte = Encoding.UTF8.GetBytes(payloadString);
_gcmRequest.ContentLength = payloadByte.Length;
using (Stream payloadStream = _gcmRequest.GetRequestStream())
{
payloadStream.Write(payloadByte, 0, payloadByte.Length);
payloadStream.Close();
}
}
private string AssembleJSONPayload(string gcmDeviceToken, string gcmBody)
{
string payloadFormatJSON =
"{{" +
"\"registration_ids\" : [\"{0}\"]," +
"\"data\" : {{" +
" {1} " +
"}}" +
"}}";
string payload = string.Format(payloadFormatJSON, gcmDeviceToken, gcmBody);
Debug.WriteLine("payload : " + payload);
return payload;
}
}
This code works fine in WPF application. when I try this code in wcf it crashes at
_gcmResponse = _gcmRequest.GetResponse() as HttpWebResponse; and says
The remote server returned an error: (400) Bad Request. . Can anyone help me?
|
|
|
|
|
Try some sniffer (like Fiddler) to see what the actual HTTP request is, that may give you a hint why it is 400!
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
Well, on the surface of it looks ok. What do you mean 'try it in wcf'?
One observation is you are storing the web request and response as class members - this seems unusual to me, and means that if you call Send() in a multithreaded manner things are likely to go very wrong.
Other things it could be - proxy connections perhaps although I'd expect a different error and its usual to apply some credentials to the request. Check the account the WCF host is running under..?
Regards,
Rob Philpott.
|
|
|
|
|
I've been struggling with this one for half-a-day and I'm still not figuring out how to do this correctly.
What I am trying to do is set up a popup control that will reactive the owning window in the event that the window looses focus but the user then clicks the popup. The trouble is that, normally, the popup looses focus with the window and the user cannot interact with it until the window is reactivated. Since the popup is always 'On Top', it is always shown even if the parent window gets covered up. This makes it the natural choice for users to return to the application.
This code works only half way.
public partial class App : Application
{
private bool _active;
public bool Active { get { return _active; } }
private void Application_Activated(object sender, EventArgs e)
{
_active = true;
}
private void Application_Deactivated(object sender, EventArgs e)
{
_active = false;
}
}
public void PopupBase_MouseDown(object sender, EventArgs e)
{
App currentApp = Application.Current as App;
if (currentApp != null)
{
if (!currentApp.Active)
{
_owner.Activate();
}
}
}
This only works when the parent object is clicked but I'm having trouble wiring the child controls to trigger the event. If the user clicks anywhere in the popup except directly on a child element it works.
I tried this but it didn't work. The Popup's Child in all cases is a Border class.
public void PopupChild_Loaded(object sender, EventArgs e)
{
AddActivationHandler(this.Child.Child);
}
private void AddActivationHandler(UIElement element)
{
if (element is Panel)
{
Panel pElement = element as Panel;
foreach (UIElement child in pElement.Children)
{
AddActivationHandler(child);
}
}
element.MouseDown += PopupBase_MouseDown;
{
I stepped through and the event handlers do get added but they were never called. Is there another way to have all of a parent's children pass their events back up to a specific control?
After some further reading, is this something that could be handled with Routed Events?
modified 24-Nov-15 17:17pm.
|
|
|
|
|
Well i want to make my progressbar updating dynamicly.
So i know the distance and speed but in my while loop should i work with steps for updating my progress bar?
Well each step should be 10% because i have to update another progress in steps between 0 and 1.
double totalDistance = 7.3
double speed = 1;
double progress = (speed / totalDistance);
double step = progress / 10;
while (progress <= totalDistance)
{
progress += step;
Dispatcher.Invoke(new Action(() => {
SetProgress(0.1);
}));
}
modified 24-Nov-15 13:48pm.
|
|
|
|
|
You have great dreams - but follow the path[^] that leads you toward the light...
|
|
|
|
|
Kris Saelen wrote: So i know the distance and speed but in my while loop should i work with steps
for updating my progress bar? I prefer to use time-intervals; that way the actual process does not need to report each N times. Works best with long distances and small steps.
Would be done by checking in the loop if 250 or 500ms passed, and if true, update the progress.
--edit
Ignore that answer; this is the Lounge, and *all the other forums* are for code. Not this one.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|