|
I have been posting about my SignalR project and about how I have been unable to connect to the SignalR server component on my server.
Here is a simple Sample SignalR Chat APp.
Run the app, start the server. Then open an additional Client and you'll see that it works fine.
I have then copied the server project's files to my Server, opened a port, disabled the firewall, and attempted to connect.
Depending on the things I try, I get different error messages, all telling me in some way that it could not find the server, or timed out, etc.
At this point I'm really desperate. I MUST get a SignalR server working on my Server. I'd be willing to pay to get help.
If anyone know how to do this, please help.
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
What i'm doing wrong?
Basic binding to Combobox ItemsSource.
What I have tried:
C#
public partial class MainWindow : Window
{
ObservableCollection<string> _items = new ObservableCollection<string> { "a1", "a2" };
public ObservableCollection<string> Items
{
get { return _items; }
set { _items = value; }
}
public MainWindow()
{
InitializeComponent();
var aa = a1;
}
}
XAML
<StackPanel>
<ComboBox Name="a1" ItemsSource="{Binding Items}">
</ComboBox>
</StackPanel>
|
|
|
|
|
You haven't set a DataContext. Without that, WPF doesn't know what you are trying to bind to. With the code you have there, after your call to InitializeComponent(); put this in:
DataContext = this; That should do it.
This space for rent
|
|
|
|
|
Yes. It works. Thank you. And for full short answer.
modified 11-Aug-16 0:55am.
|
|
|
|
|
You're welcome. Glad you got it working.
This space for rent
|
|
|
|
|
Not if he is binding to a List of strings!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I have searched the internet and can't find an answer to my question. In one of my WPF XMAL pages which is a Views I am using a GridView to load and binding values for each DisplayMemberBinding row. What I need to do is raise a row selected event but the GridView does not contain that event. How do I create a row selected event for the WPF GridView?
|
|
|
|
|
Are you sure you mean a GridView[^]? That can only be used as a view mode for a ListView[^], which does have a SelectionChanged event[^].
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Yes it is in a ListView. Now I see the SelectionChange event. How would you recommend determining which row was selected?
|
|
|
|
|
|
Richard, Thank you very much.
|
|
|
|
|
Hi,
I'm coding a little application for my company, the idea is very simple:
I would like to copy a directory from a server location to a local folder and I want to show the progress by using a progress bar.
I already integrated the copy of the directory by using this code:
using System;
using System.IO;
class DirectoryCopyExample {
static void Main() {
DirectoryCopy(".", @".\temp", true);
}
private static void DirectoryCopy(string sourceDirName, string destDirName, bool copySubDirs) {
DirectoryInfo dir = new DirectoryInfo(sourceDirName);
if (!dir.Exists) {
throw new DirectoryNotFoundException("Source directory does not exist or could not be found: " + sourceDirName);
}
DirectoryInfo[] dirs = dir.GetDirectories();
if (!Directory.Exists(destDirName)) {
Directory.CreateDirectory(destDirName);
}
FileInfo[] files = dir.GetFiles();
foreach(FileInfo file in files) {
string temppath = Path.Combine(destDirName, file.Name);
file.CopyTo(temppath, false);
}
if (copySubDirs) {
foreach(DirectoryInfo subdir in dirs) {
string temppath = Path.Combine(destDirName, subdir.Name);
DirectoryCopy(subdir.FullName, temppath, copySubDirs);
}
}
}
}
For the integration of the progress bar according to the number of files/sizes I can't find anything
Can someone help me with this?
Thank you!
|
|
|
|
|
Member 12674678 wrote: For the integration of the progress bar according to the number of files/sizes I can't find anything Where did you look? Google has lots of suggestions: wpf progress bar - Google Search[^].
|
|
|
|
|
i found this code (thanks for your link):
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;
namespace copynestedfolderformapplication
{
public partial class Form1 : Form
{
int maxbytes = 0;
int copied = 0;
int total=0;
public Form1()
{
InitializeComponent();
}
private void copybtn_Click(object sender, EventArgs e)
{
Copy1(@"F:\Posts", @"G:\copydata");
MessageBox.Show("Done");
}
public void Copy1(string sourceDirectory, string targetDirectory)
{
DirectoryInfo diSource = new DirectoryInfo(sourceDirectory);
DirectoryInfo diTarget = new DirectoryInfo(targetDirectory);
GetSize(diSource, diTarget);
maxbytes = maxbytes / 1024;
progressBar1.Maximum = maxbytes;
CopyAll(diSource, diTarget);
}
public void CopyAll(DirectoryInfo source, DirectoryInfo target)
{
if (Directory.Exists(target.FullName) == false)
{
Directory.CreateDirectory(target.FullName);
}
foreach (FileInfo fi in source.GetFiles())
{
fi.CopyTo(Path.Combine(target.ToString(), fi.Name), true);
total += (int)fi.Length;
copied += (int)fi.Length;
copied /= 1024;
progressBar1.Step =copied;
progressBar1.PerformStep();
label1.Text = (total/1048576).ToString() + "MB of " + (maxbytes/1024).ToString() + "MB copied";
label1.Refresh();
}
foreach (DirectoryInfo diSourceSubDir in source.GetDirectories())
{
DirectoryInfo nextTargetSubDir = target.CreateSubdirectory(diSourceSubDir.Name);
CopyAll(diSourceSubDir, nextTargetSubDir);
}
}
public void GetSize(DirectoryInfo source, DirectoryInfo target)
{
if (Directory.Exists(target.FullName) == false)
{
Directory.CreateDirectory(target.FullName);
}
foreach (FileInfo fi in source.GetFiles())
{
maxbytes += (int)fi.Length;
}
foreach (DirectoryInfo diSourceSubDir in source.GetDirectories())
{
DirectoryInfo nextTargetSubDir = target.CreateSubdirectory(diSourceSubDir.Name);
GetSize(diSourceSubDir, nextTargetSubDir);
}
}
}
}
where do i need to include the Backgroundworker in this code?
|
|
|
|
|
That's Windows Forms, not WPF. Your first sample was a Console application. How much do you currently have as WPF?
This space for rent
|
|
|
|
|
|
That doesn't answer the question I asked - you might as well have replied with "I like cheese". How much do you currently have as WPF?
This space for rent
|
|
|
|
|
I have been trying to do this without luck. What I'm trying to do is use an Outlook email link to run a local WPF exe with a parameter. I have been trying several things. First I created a .bat file and tried to kick it off directly from the email link (and Word link):
c:\users\steve\debug\MasterPage.bat 100
The batch files looks like this:
C:\users\steve\debug\MasterPage.exe %1
So that doesn't work so I changed the link to point to a html file running a JavaScript function calling the exe directly:
function callProgram()
{
var objShell = new ActivexObject("Shell.Application");
objShell.ShellExecute("cmd.exe", "C:\\cd C:\\Debug\\MasterPage.exe 1", "C:\\WINDOWS\\system32", "open", 1);
}
Nothing seems to work. If anyone can help please do.
|
|
|
|
|
Any half-decent email client will not execute Javascript in the body of the message, and will not allow links to launch local applications. If they did, it would be a major security vulnerability.
Give your users a command to copy and paste into the "Run" dialog (Win+R).
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I found the answer:
script language=JavaScript
function launchExecutable(executableFullPath)
{
var shellActiveXObject = new ActiveXObject("WScript.Shell");
shellActiveXObject.Run(executableFullPath, 1, false);
shellActiveXObject = null;
}
script
|
|
|
|
|
That might work in your environment but it won't work in mine. Yes, we use Outlook/Exchange. Policies prevent us from doing what you came up with, for very obvious security reasons.
|
|
|
|
|
That is only ever going to work on your system so there is little point in trying to run it from an email message.
|
|
|
|
|
Create a service (Windows service; FileWatcher event handler; SQL Server agent; whatever) that monitors for the arrival and related events of the email(s) in question; and then kicks off the WPF app.
Or have the WPF app "hide" (and monitor) until the email arrives and triggers a "show".
Event triggers and handlers.
|
|
|
|
|
I understand having a windows service monitor an event but what event in the email would kick off the Windows service starting the app and how would the parameter be accessed by the app on startup?
|
|
|
|
|
You start by examining how your mail is received, where it is stored, and what events are associated with it. At the very least, the contents of a given folder (or database) will be updated which can be monitored by a File Watcher (or other "monitor") class instance.
Get your "link" to save something if you can't figure the rest out.
|
|
|
|