Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > .NET Languages
You last visited: Today at 23:05

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



WPF label problem

Discussion on WPF label problem within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1
Trade Restricted
 
elite*gold: LOCKED
Join Date: Oct 2016
Posts: 321
Received Thanks: 79
Exclamation WPF label problem

Hi, if got recently being trying WPF and my problem is update an label (i know how to do but i think it's something wrong).
Here is an sample of code, and i cant understand why it's not changing after TCP result.

Code:
public void check()
{
MainMenu x = new MainMenu();
            //PING -> WORLD Server
            if (_tcpREC(Convert.ToInt32(Properties.Settings.Default["worldport"].ToString())) == true)
            {
                x.dksv.Content = "Online";
                x.dksv.Foreground = Brushes.Green;
            }
            else
            {
                x.dksv.Content = "Offline";
                x.dksv.Foreground = Brushes.Red;
            }
}
public Boolean _tcpREC(int port)
        {
            IniFile configFile = new IniFile();
            //Check if is open or not on the server ip 
            using (TcpClient rec = new TcpClient())
            {
                try
                {
                    rec.Connect(configFile.Read("Server Name", "MSSQL"), port);
                    if (rec.Connected == true)
                    {
                        return true;
                    }

                }
                catch
                {
                    return false;
                }
            
            }
And basicly i dont get label's updated.
x = my new other form
Underfisk is offline  
Old 02/24/2017, 11:48   #2
 
Ludder231's Avatar
 
elite*gold: 0
Join Date: Aug 2010
Posts: 880
Received Thanks: 113
do you have multiple forms? are you working with multiple threads? i guess you need to invoke your label.
Ludder231 is offline  
Old 02/24/2017, 12:11   #3
 
XYZ-Cannon's Avatar
 
elite*gold: 0
Join Date: Jul 2011
Posts: 1,773
Received Thanks: 866
First of all you don't need to check a boolean in your if-statement (your == true is useless).
You are creating a new Main Menu everytime you check? Use better method names and split your method. By checking something you should never create a new interface.
XYZ-Cannon is offline  
Old 02/24/2017, 20:26   #4
 
elite*gold: 0
Join Date: Apr 2008
Posts: 495
Received Thanks: 817
Why you don't use Databinding with WPF ()?
schnewin is offline  
Old 02/24/2017, 21:09   #5
Trade Restricted
 
elite*gold: LOCKED
Join Date: Oct 2016
Posts: 321
Received Thanks: 79
Talking

Btw im new at wpf, and i remmeber from Java to test the object and variables as static , and they work well now but i still can't understand well what's the best way to invoke the forms. And yes, i'm using multiple

Quote:
Originally Posted by XYZ-Cannon View Post
First of all you don't need to check a boolean in your if-statement (your == true is useless).
You are creating a new Main Menu everytime you check? Use better method names and split your method. By checking something you should never create a new interface.
Thx, and iam looking for a way to test multiple socket tests like i do in this way, but i think its not the best way to test the port. If you could recommend something i'll try ofc.
Underfisk is offline  
Old 02/27/2017, 11:09   #6
 
XYZ-Cannon's Avatar
 
elite*gold: 0
Join Date: Jul 2011
Posts: 1,773
Received Thanks: 866
Quote:
Originally Posted by Underfisk View Post
Btw im new at wpf, and i remmeber from Java to test the object and variables as static , and they work well now but i still can't understand well what's the best way to invoke the forms. And yes, i'm using multiple



Thx, and iam looking for a way to test multiple socket tests like i do in this way, but i think its not the best way to test the port. If you could recommend something i'll try ofc.
How about testing a port with a method and implement a parameter like the number of the port you want to test? F.e.:

checkPort(int portnumber){}
XYZ-Cannon is offline  
Old 02/27/2017, 12:48   #7
Trade Restricted
 
elite*gold: LOCKED
Join Date: Oct 2016
Posts: 321
Received Thanks: 79
Im doing it right now, i get the port but i need to make a "big" if statement for check if is online or not. basicly i'm trying to find a way to send multiple ports but i think gotta try send a full array with the ports numbers and return
Underfisk is offline  
Reply


Similar Threads Similar Threads
(S) Label Design & Label Covers etc.
02/11/2015 - Artist Trading - 6 Replies
German: Hallo Liebe Community, ich bin DJ/Producer & besitze ein eigenes Label. Momentan suchen wir Designer damit wir schöne Cover für Alben haben etc. Diese Cover werden in diesen Stores erscheinen: iTunes,Beatport,Amazon Mp3, Shazam,Spotify,dj tunes, & viele andere Stores!
Label -2
04/08/2013 - .NET Languages - 13 Replies
Hey ;) Wie kann ich von eine Label (Label13.text) -2 abziehen? Label13.Text -2 geht leider nicht ! Label 13.Text habe ich in einer function weiter oben angegeben, also den wert !
[AutoIT]Problem mit Label !
01/02/2011 - AutoIt - 4 Replies
Hallo Leute . Ich sitze zur Zeit an einem Projekt und komme bei einer stelle einfach nicht weiter. Das Problem ist das ich es einfach nicht schaffe einen Label jede 20 Sekunden um 50 zu erweitern also so : 20 = 50 dan wieder 20 sekunden vorbei = 100 usw. Hier mal ein anfangs Code : HotKeySet ("1","-Start") HotKeySet ("2","-Pause") #include <GUIConstantsEx.au3>
[Problem]Inputbox + Label
08/21/2010 - AutoIt - 4 Replies
Hi ich will das mein Program eine inputbox öffnet und das in einem Label angiebt :) so habe ich es versucht $name = Inputbox("Name","Bitte gebe deinen namen ein") und dan öffnet sich ein fenster sozusamen ein minni spiel wo der name in einen Label stehen soll :) $Label1 = GUICtrlCreateLabel("Name: $name", 8, 8, 97, 20) //edit habe die löseung ;) aber ein anderes problem
Run - Label?
02/22/2010 - GW Bots - 3 Replies
Hallo an alle Pvpers, Ich hab in meiner GUI ein Label dass anzeigen soll wieviele Runs bisher gemacht wurden. Dies soll immer erneuert werden nachdem "/resign" eingegeben wurde. ICh dachte schon an: Funktioniert aber nich. Oder was ich mir auch noch gedacht habe war: Kann mir jmd helfen?



All times are GMT +1. The time now is 23:05.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.