|
Solved it, I think: instead of cluttering up the classes in question with a do-nothing multiply() function, I can pass an anonymous function for the m parameter of integerExponentiate(). I hadn't used anonymous functions before.
|
|
|
|
|
See if this givs you some ideas:
public static class GenericMathExtensions
{
public static double? Exp<T>(this T tvalue, double topower)
where T :
struct,
IComparable,
IComparable<T>,
IConvertible,
IEquatable<T>,
IFormattable
{
if (typeof(T).IsNumeric())
{
try
{
return Math.Pow(Convert.ToDouble(tvalue), topower);
}
catch
{
}
}
return null;
}
public static bool IsNumeric(this Type type)
{
switch (Type.GetTypeCode(type))
{
case TypeCode.Byte:
case TypeCode.SByte:
case TypeCode.UInt16:
case TypeCode.UInt32:
case TypeCode.UInt64:
case TypeCode.Int16:
case TypeCode.Int32:
case TypeCode.Int64:
case TypeCode.Decimal:
case TypeCode.Double:
case TypeCode.Single:
return true;
case TypeCode.Object:
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>))
{
return Nullable.GetUnderlyingType(type).IsNumeric();
}
return false;
default:
return false;
}
}
} Note: the Convert.ToDouble method can handle other types than those this code restricts the usage to.
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
Message Removed
modified 20-Mar-18 12:21pm.
|
|
|
|
|
i cant find a solution to create a chat application without the need to a server
all the project and idea i found are all based on a server and client
how can be done with just client in each pc and the clients are in the same local network so they need to discover each other IP and send the message to each other
|
|
|
|
|
The simple solution is to have an app that acts as both client and server.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
Do you know how to create an application which has a Server an a Client ?
In this case see my description - if not use Google to find some Examples and look how they work and try to understand the functionality.
|
|
|
|
|
Use the code you have found as a basis: start your app as a client, and look for an appropriate server. If you find one, connect to it and chat away.
If you don't, close the client, and open a server. The server then waits for another app to connect.
Or, start as a server, then open a client as well and search for other servers.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Additional to the answer of OriginalGriff :
The communication allways needs a Server (and could have one or more Clients).
So you could do the following :
You start your application as Client and try to connect a Server (I would use the synchronous methods here). If you don't get a response after a time (defined by you) there is no Server availible and perhaps your must be the Server (or you are not connected to a network ???) - so you switch to different methods (and tasks) in your application.
|
|
|
|
|
Have a look at SignalR
SignalR | Microsoft Docs
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Read up on the SNMP protocal, or automation of "net send" or "msg command"
Director of Transmogrification Services
Shinobi of Query Language
Master of Yoda Conditional
|
|
|
|
|
hi!
string format = "ss";
DateTime now = DateTime.Now;
string s = now.ToString(format);
ComPort.Write(s.Substring(0, 1));
ComPort.Write(s.Substring(1, 1)); // Only this (last one) execute
want to send two strings of second for example "05" to comport, but receive only last statement, Help Please
currently using these statements within timer tick
|
|
|
|
|
|
Hi Guys,
I would like to build a C#,Windows form application which will export all entries such as labels,textboxes,radio buttons to a pdf file. I am aware of itextsharp.dll and attached it to project as reference but couldn't archieve much.
I basically put 4 label/textbox and once I click button pdf will be generated at given path..
Is there anyone can advise me how to do?
Thank you.
modified 13-Feb-19 21:02pm.
|
|
|
|
|
The first thing you need to do is to decide what you want your PDF document to look like. Is it to be a simple document consisting of lines of text, or is it to be an image of your form? In either case you will need to use the various iTextSharp methods to create it. Some articles to get you started can be found at: codeproject: iTextsharp - Google Search[^].
|
|
|
|
|
Since you can do all this "manually", what parts do you want to automate?
1) create form with controls
2) print screen (with or without form active)
3) copy / crop in Paint
4) print to any PDF print driver
The 25 cent solution.
Otherwise, one needs to learn about "client areas" in Windows.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
hi I created form like below, goal is that all user inputs and form items should be on generated pdf.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace d1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
}
}
}
modified 13-Feb-19 21:02pm.
|
|
|
|
|
If that's the best you can do for a response, then stick to "Print Screen".
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
how is it possible? would you please help me on this?
modified 13-Feb-19 21:02pm.
|
|
|
|
|
Please can anyone help with a project I'm working on. I'm trying to create a way of running an Azure message queue receiver in a permanently running background thread which immediately updates controls on a WPF page when a new message comes in. I've been playing with examples found on the web which download messages and display them in a console window but I'm struggling to work out how to pass the received messages over to a textbox control on an WPF page.
This is what I have been playing with which seems to work perfectly.....
namespace AzureMessagingReceiver
{
using System;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.ServiceBus;
class Program
{
const string ServiceBusConnectionString = "######.......";
const string QueueName = "#####......";
static IQueueClient queueClient;
static void Main(string[] args)
{
MainAsync().GetAwaiter().GetResult();
}
static async Task MainAsync()
{
queueClient = new QueueClient(ServiceBusConnectionString, QueueName);
Console.WriteLine("======================================================");
Console.WriteLine("Press ENTER key to exit after receiving all the messages.");
Console.WriteLine("======================================================");
RegisterOnMessageHandlerAndReceiveMessages();
Console.ReadKey();
await queueClient.CloseAsync();
}
static void RegisterOnMessageHandlerAndReceiveMessages()
{
var messageHandlerOptions = new MessageHandlerOptions(ExceptionReceivedHandler)
{
MaxConcurrentCalls = 1,
AutoComplete = false
};
queueClient.RegisterMessageHandler(ProcessMessagesAsync, messageHandlerOptions);
}
static async Task ProcessMessagesAsync(Message message, CancellationToken token)
{
Console.WriteLine($"Received message: SequenceNumber:{message.SystemProperties.SequenceNumber} Body:{Encoding.UTF8.GetString(message.Body)}");
await queueClient.CompleteAsync(message.SystemProperties.LockToken);
}
static Task ExceptionReceivedHandler(ExceptionReceivedEventArgs exceptionReceivedEventArgs)
{
Console.WriteLine($"Message handler encountered an exception {exceptionReceivedEventArgs.Exception}.");
var context = exceptionReceivedEventArgs.ExceptionReceivedContext;
Console.WriteLine("Exception context for troubleshooting:");
Console.WriteLine($"- Endpoint: {context.Endpoint}");
Console.WriteLine($"- Entity Path: {context.EntityPath}");
Console.WriteLine($"- Executing Action: {context.Action}");
return Task.CompletedTask;
}
}
}
.....just need help with how to turn this into what I need.
Any assistance greatly appreciated!
|
|
|
|
|
WPF relies heavily on INotifyPropertyChanged. You can use this to your advantage so that, when your data changes, you simply raise a PropertyChanged event.
This space for rent
|
|
|
|
|
1) Add messages received to a concurrent queue
2) When adding, start a "queue worker" if not already started
3) Queue worker dequeues messages and updates WPF window in progress reporting event
4) Queue worker runs until queue is empty,
or
1) Use a dispatcher timer to poll for new messages while updating WPF UI on same thread
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Hello All,
Using toggleClass and hasClass in javascript to toggle between 'SelectAll' and 'DeselectAll', to control the checkboxes. 'SelectAll' would check all the checkboxes, and 'DeselectAll' would deselect them all at once. This works fine in my development environment, but in staging server, the button does not invoke any action. It does nothing.
How does one go about debugging another environment, which does not have VS installed?
I have pasted a snippet - thank you!
script type="text/javascript">
$(function () {
$("#SelectAll").click(function () {
var $this = $(this);
$this.toggleClass('SelectAll');
if ($this.hasClass('SelectAll')) {
$this.text('DeselectAll');
$this.val('DeselectAll');
var ischecked = true;
} else {
$this.text('SelectAll');
$this.val('SelectAll');
var ischecked = false;
}
});
});
</script>
|
|
|
|
|
There is a subtle clue in that code as to why this is the wrong forum. It's hidden in two places; the first being that this forum is for C# and the second is in you code when it says javascript. You might have more luck if you don't just randomly pick a forum.
This space for rent
|
|
|
|
|
This is an MVC solution, but i shall post this in the javascript forum.
Thank you.
|
|
|
|