Search Results

Search found 313 results on 13 pages for 'showdialog'.

Page 3/13 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Update UI from an event with a thread

    - by tyrone-tudehope
    Im working on a small application to try out an idea that I have. The idea is to periodically update the UI when event of some sort occurs. In the demo I've created, I'm updating a ProgressDialog every 2 seconds for 15 turns. The problem I am having, which I don't quite understand is that when an event is handled, I send a message to the handler which is supposed to update the message in the ProgressDialog. When this happens however, I get an exception which states that I can't update the UI from that thread. The following code appears in my Activity: ProgressDialog diag; String diagMessage = "Started loading..."; final static int MESSAGE_DATA_RECEIVED = 0; final static int MESSAGE_RECEIVE_COMPLETED = 1; final Handler handler = new Handler(){ @Override public void handleMessage(Message msg){ diag.setMessage(diagMessage); switch(msg.what){ case MESSAGE_DATA_RECEIVED: break; case MESSAGE_RECEIVE_COMPLETED: dismissDialog(); killDialog(); break; } } }; Boolean isRunning = false; /** * Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setupDialog(); if(isRunning){ showDialog(); } setContentView(R.layout.main); } void setupDialog(){ if(diag == null){ diag = new ProgressDialog(ThreadLoading.this); diag.setMessage(diagMessage); } } void showDialog(){ isRunning = true; if(diag != null && !diag.isShowing()){ diag.show(); } } void dismissDialog(){ if(diag != null && diag.isShowing()){ diag.dismiss(); } } void killDialog(){ isRunning = false; } public void onStart(){ super.onStart(); showDialog(); Thread background = new Thread(new Runnable(){ public void run(){ try{ final ThreadRunner tr = new ThreadRunner(); tr.setOnDataReceivedListener(new ThreadRunner.OnDataReceivedListener(){ public void onDataReceived(String message){ diagMessage = message; handler.handleMessage(handler.obtainMessage(MESSAGE_DATA_RECEIVED)); } }); tr.setOnDataDownloadCompletedEventListener(new ThreadRunner.OnDataDownloadCompletedListener(){ public void onDataDownloadCompleted(String message){ diagMessage = message; handler.handleMessage(handler.obtainMessage(MESSAGE_RECEIVE_COMPLETED)); } }); tr.runProcess(); } catch(Throwable t){ throw new RuntimeException(t); } } }); background.start(); } @Override public void onPause(){ super.onPause(); dismissDialog(); } For curiosity sake, here's the code for the ThreadRunner class: public interface OnDataReceivedListener { public void onDataReceived(String message); } public interface OnDataDownloadCompletedListener { public void onDataDownloadCompleted(String message); } private OnDataReceivedListener onDataReceivedEventListener; private OnDataDownloadCompletedListener onDataDownloadCompletedEventListener; int maxLoop = 15; int loopCount = 0; int sleepTime = 2000; public void setOnDataReceivedListener(OnDataReceivedListener onDataReceivedListener){ this.onDataReceivedEventListener = onDataReceivedListener; } public void setOnDataDownloadCompletedEventListener(OnDataDownloadCompletedListener onDataDownloadCompletedListener){ this.onDataDownloadCompletedEventListener = onDataDownloadCompletedListener; } public void runProcess(){ for(loopCount = 0; loopCount < maxLoop; loopCount++){ try{ Thread.sleep(sleepTime); onDataReceivedEventListener.onDataReceived(Integer.toString(loopCount)); } catch(Throwable t){ throw new RuntimeException(t); } } onDataDownloadCompletedEventListener.onDataDownloadCompleted("Download is completed"); } Am I missing something? The logic makes sense to me and it looks like everything should work, I'm using a handler to update the UI like it is recommended. Any help will be appreciated. Thanks, Tyrone P.S. I'm developing for Android 1.5

    Read the article

  • WPF Login Verification Using Active Directory

    - by psheriff
    Back in October of 2009 I created a WPF login screen (Figure 1) that just showed how to create the layout for a login screen. That one sample is probably the most downloaded sample we have. So in this blog post, I thought I would update that screen and also hook it up to show how to authenticate your user against Active Directory. Figure 1: Original WPF Login Screen I have updated not only the code behind for this login screen, but also the look and feel as shown in Figure 2. Figure 2: An Updated WPF Login Screen The UI To create the UI for this login screen you can refer to my October of 2009 blog post to see how to create the borderless window. You can then look at the sample code to see how I created the linear gradient brush for the background. There are just a few differences in this screen compared to the old version. First, I changed the key image and instead of using words for the Cancel and Login buttons, I used some icons. Secondly I added a text box to hold the Domain name that you wish to authenticate against. This text box is automatically filled in if you are connected to a network. In the Window_Loaded event procedure of the winLogin window you can retrieve the user’s domain name from the Environment.UserDomainName property. For example: txtDomain.Text = Environment.UserDomainName The ADHelper Class Instead of coding the call to authenticate the user directly in the login screen I created an ADHelper class. This will make it easier if you want to add additional AD calls in the future. The ADHelper class contains just one method at this time called AuthenticateUser. This method authenticates a user name and password against the specified domain. The login screen will gather the credentials from the user such as their user name and password, and also the domain name to authenticate against. To use this ADHelper class you will need to add a reference to the System.DirectoryServices.dll in .NET. The AuthenticateUser Method In order to authenticate a user against your Active Directory you will need to supply a valid LDAP path string to the constructor of the DirectoryEntry class. The LDAP path string will be in the format LDAP://DomainName. You will also pass in the user name and password to the constructor of the DirectoryEntry class as well. With a DirectoryEntry object populated with this LDAP path string, the user name and password you will now pass this object to the constructor of a DirectorySearcher object. You then perform the FindOne method on the DirectorySearcher object. If the DirectorySearcher object returns a SearchResult then the credentials supplied are valid. If the credentials are not valid on the Active Directory then an exception is thrown. C#public bool AuthenticateUser(string domainName, string userName,  string password){  bool ret = false;   try  {    DirectoryEntry de = new DirectoryEntry("LDAP://" + domainName,                                           userName, password);    DirectorySearcher dsearch = new DirectorySearcher(de);    SearchResult results = null;     results = dsearch.FindOne();     ret = true;  }  catch  {    ret = false;  }   return ret;} Visual Basic Public Function AuthenticateUser(ByVal domainName As String, _ ByVal userName As String, ByVal password As String) As Boolean  Dim ret As Boolean = False   Try    Dim de As New DirectoryEntry("LDAP://" & domainName, _                                 userName, password)    Dim dsearch As New DirectorySearcher(de)    Dim results As SearchResult = Nothing     results = dsearch.FindOne()     ret = True  Catch    ret = False  End Try   Return retEnd Function In the Click event procedure under the Login button you will find the following code that will validate the credentials that the user types into the login window. C#private void btnLogin_Click(object sender, RoutedEventArgs e){  ADHelper ad = new ADHelper();   if(ad.AuthenticateUser(txtDomain.Text,         txtUserName.Text, txtPassword.Password))    DialogResult = true;  else    MessageBox.Show("Unable to Authenticate Using the                      Supplied Credentials");} Visual BasicPrivate Sub btnLogin_Click(ByVal sender As Object, _ ByVal e As RoutedEventArgs)  Dim ad As New ADHelper()   If ad.AuthenticateUser(txtDomain.Text, txtUserName.Text, _                         txtPassword.Password) Then    DialogResult = True  Else    MessageBox.Show("Unable to Authenticate Using the                      Supplied Credentials")  End IfEnd Sub Displaying the Login Screen At some point when your application launches, you will need to display your login screen modally. Below is the code that you would call to display the login form (named winLogin in my sample application). This code is called from the main application form, and thus the owner of the login screen is set to “this”. You then call the ShowDialog method on the login screen to have this form displayed modally. After the user clicks on one of the two buttons you need to check to see what the DialogResult property was set to. The DialogResult property is a nullable type and thus you first need to check to see if the value has been set. C# private void DisplayLoginScreen(){  winLogin win = new winLogin();   win.Owner = this;  win.ShowDialog();  if (win.DialogResult.HasValue && win.DialogResult.Value)    MessageBox.Show("User Logged In");  else    this.Close();} Visual Basic Private Sub DisplayLoginScreen()  Dim win As New winLogin()   win.Owner = Me  win.ShowDialog()  If win.DialogResult.HasValue And win.DialogResult.Value Then    MessageBox.Show("User Logged In")  Else    Me.Close()  End IfEnd Sub Summary Creating a nice looking login screen is fairly simple to do in WPF. Using the Active Directory services from a WPF application should make your desktop programming task easier as you do not need to create your own user authentication system. I hope this article gave you some ideas on how to create a login screen in WPF. NOTE: You can download the complete sample code for this blog entry at my website: http://www.pdsa.com/downloads. Click on Tips & Tricks, then select 'WPF Login Verification Using Active Directory' from the drop down list. Good Luck with your Coding,Paul Sheriff ** SPECIAL OFFER FOR MY BLOG READERS **We frequently offer a FREE gift for readers of my blog. Visit http://www.pdsa.com/Event/Blog for your FREE gift!

    Read the article

  • Android 1.6: "android.view.WindowManager$BadTokenException: Unable to add window -- token null is no

    - by Dan Monego
    I'm trying to open a dialog window, but every time I try to open it it throws this exception: E/AndroidRuntime( 206): Uncaught handler: thread main exiting due to uncaught exception E/AndroidRuntime( 206): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application E/AndroidRuntime( 206): at android.view.ViewRoot.setView(ViewRoot.java:460) E/AndroidRuntime( 206): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177) E/AndroidRuntime( 206): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91) E/AndroidRuntime( 206): at android.app.Dialog.show(Dialog.java:238) E/AndroidRuntime( 206): at android.app.Activity.showDialog(Activity.java:2413) I'm creating it by calling showDialog with the display's id. The onCreateDialog handler logs fine and I can step through it without an issue, but I've attached since it seems like I'm missing something in it: @Override public Dialog onCreateDialog(int id) { Dialog dialog; Context appContext = this.getApplicationContext(); switch(id) { case RENAME_DIALOG_ID: Log.i("Edit", "Creating rename dialog..."); dialog = new Dialog(appContext); dialog.setContentView(R.layout.rename); dialog.setTitle("Rename " + noteName); break; default: dialog = null; break; } return dialog; } Is there something missing from this? Some questions have talked about having this problem when creating a dialog from onCreate, which happen because the activity isn't created yet, but this is coming from a call from a menu object, and the appContext variable seems like it is correctly populated in the debugger.

    Read the article

  • External JS usage in FBML - Cannot access external script

    - by santhakr
    Hi, I am trying to create a small facebook app and associate it to a fan page in a tab. I am trying to include an external javascript file in my page and call a method on a button click event. Below is a part of the code <script language="Javascript" src="http://mysite.com/fb.js"></script> <input type="button" value="Click....." onClick="javascript:showDialog();" /> content of fb.js is as below function showDialog() { new Dialog().showMessage('Dialog', 'Button clickeed'); } When I load the tab in my fan page, it shows an error "Cannot allow external script", whereas when I load the canvas url [http://apps.facebook.com/...] directly and click on the button, it works [shows the dialog]. Does script include works only on the canvas and not on the profile page? I have another question though Initially I had the script src as a relative path but it errored out with the same error - "Cannot allow external script". Can't I use relative path for the external scripts?

    Read the article

  • C#.NET Forms programing - Modal and Non-Modal forms problem

    - by Povilas
    Hello, I have a problem with modality of the forms under C#.NET. Let's say I have main form #0 (see the image below). This form represents main application form, where user can perform various operations. However, from time to time, there is a need to open additional non-modal form to perform additional main application functionality supporting tasks. Let's say this is form #1 in the image. On this #1 form there might be opened few additional modal forms on top of each other (#2 form in the image), and at the end, there is a progress dialog showing a long operation progress and status, which might take from few minutes up to few hours. The problem is that the main form #0 is not responsive until you close all modal forms (#2 in the image). I need that the main form #0 would be operational in this situation. However, if you open a non-modal form in form #2, you can operate with both modal #2 form and newly created non modal form. I need the same behavior between the main form #0 and form #1 with all its child forms. Is it possible? Or am I doing something wrong? Maybe there is some kind of workaround, I really would not like to change all ShowDialog calls to ShowDialog... Thanks, Povilas

    Read the article

  • TimHeuer's FloatableWindow Issue

    - by MarioEspinoza
    Hi, I've some trouble with Tim's FloatableWindow. (<--SourceCode & DLLs) It throws the following Exception once closed the control. Object reference not set to an instance of an object in System.Windows.Controls.FloatableWindow.b__0(Object s, EventArgs args) in System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args) in MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName) First I created a control by using the FloatableWindow template, And then i just created the Window on CodeBehind. private void Button_Click_1(object sender, RoutedEventArgs e) { FloatableWindow1 f1 = new FloatableWindow1();//TheTemplatedOne f1.ShowDialog(); } private void Button_Click_2(object sender, RoutedEventArgs e) { FloatableWindow f = new FloatableWindow(); f.Height = 100; f.Width = 100; f.Background = new SolidColorBrush(Colors.Yellow); f.ShowDialog(); } But stills the same issue... Im not trying to access any information on the Closed EventHandler. Im running v3.0.40624.4 Release of the dll on SL v3.0.50106.0 in a C# project w/RiaServices Thanks

    Read the article

  • Need help making a check statement to make sure al the controls are not blank

    - by Michael Quiles
    This is for a tic tac toe game. I need help making a check statement to see if all the controls' Texts are non-blank, and if they are, you have a draw (if someone had won the previous code would have discovered that). Can you give me a good example using my code. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; using System.Drawing; namespace MyGame { public class Result1 { static private int[,] Winners = new int[,] { // main gameplay Ex: if x is on 0,1,2 x is the winner {0,1,2}, {3,4,5}, {6,7,8}, {0,3,6}, {1,4,7}, {2,5,8}, {0,4,8}, {2,4,6}, }; static public bool CheckWinner(Button[] myControls) { //bolean statement to check for the winner bool gameOver = false; for (int i = 0; i < 8; i++) { int a = Winners[i, 0]; int b = Winners[i, 1]; int c = Winners[i, 2]; Button b1 = myControls[a], b2 = myControls[b], b3 = myControls[c]; if (b1.Text == "" || b2.Text == "" || b3.Text == "") continue; if (b1.Text == b2.Text && b2.Text == b3.Text) { b1.BackColor = b2.BackColor = b3.BackColor = Color.LightCoral; b1.Font = b2.Font = b3.Font = new System.Drawing.Font("Microsoft Sans Serif", 32F, System.Drawing.FontStyle.Italic & System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); gameOver = true; xWinnerForm xWinnerForm = new xWinnerForm(); xWinnerForm.ShowDialog(); //only works with show not showDialog method gets overloaded (b1.Text + " is the Winner"); to get around this I added and image showing the last player } } return gameOver; } } }

    Read the article

  • MissingMethodException thrown when calling new form in Compact Framework

    - by Boerema
    I'm updating an old mobile device application for better flexibility. I had basically added the ability to configure the address of our SQL server in the case that we want to use our test server as opposed to our production server. I don't think this is causing the problem, but I wanted to state it. I also upgraded the project from a VS 2000 project to a VS 2005 project. The issue I am having is that when I try to run the program in the VS emulator for Pocket PC, I get an error. It occurs after our "main menu" form loads and the user selects the next form to load. The form is initialized without issue, but when we try to run the .ShowDialog() method, it throws a System.MissingMethodException. I don't have a lot of experience with the Compact Framework and really have no idea where to start looking for problems. I stepped the debugger through the entire initializing process for the new form and it ran without issue. But, again, when we come to the ShowDialog call, it throws the error. Any ideas in where to start looking or known issues would be greatly appreciated.

    Read the article

  • VB.NET handling data between different forms

    - by niuchu
    Hi, I'm writing a simple application - address book. User enters new addresses and they are added as an entry to a list visible on the main form (frmStart). I use one form to add and edit (AddContForm). Add button on the frmStart works fine, however I experience some problems with the edit button as when I press it and enter new data they are added as new entry however the previous entry is still there. Logic is handled by Contact.vb class. Please let me know how to fix this problem. Here is the code: Contact.vb Public Class Contact Public Contact As String Public Title As String Public Fname As String Public Surname As String Public Address As String Private myCont As String Public Property Cont() Get Return myCont End Get Set(ByVal value) myCont = Value End Set End Property Public Overrides Function ToString() As String Return Me.Cont End Function Public Sub Display() Dim C As New Contact C.Cont = frmAddCont.txtTitle.Text C.Fname = frmAddCont.txtFName.Text C.Surname = frmAddCont.txtSName.Text C.Address = frmAddCont.txtAddress.Text frmStart.lstContact.Items.Add(C) End Sub End Class Here is frmStart.vb Public Class frmStart Public Button As String Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click Button = "" Button = "Add" frmAddCont.ShowDialog() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDel.Click Button = "" Button = "Del" Dim DelCont As Contact DelCont = Me.lstContact.SelectedItem() lstContact.Items.Remove(DelCont) End Sub Private Sub lstContact_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstContact.SelectedIndexChanged End Sub Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click Button = "" Button = "Edit" Dim C As Contact If lstContact.SelectedItem IsNot Nothing Then C = DirectCast(lstContact.SelectedItem, Contact) frmAddCont.ShowDialog() End If End Sub End Class Here is AddContFrm.vb Public Class frmAddCont Public Class ControlObject Dim Title As String Dim FName As String Dim SName As String Dim Address As String Dim TelephoneNumber As Integer Dim emailAddress As String Dim Website As String Dim Photograph As String End Class Private Sub btnConfirmAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConfirmAdd.Click Dim B As String B = frmStart.Button Dim C As New Contact C.Display() Me.Hide() If B = "Edit" Then C = DirectCast(frmStart.lstContact.SelectedItem, Contact) frmStart.lstContact.SelectedItems.Remove(C) End If End Sub Private Sub frmAddCont_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub End Class

    Read the article

  • WinForms programing - Modal and Non-Modal forms problem

    - by Povilas
    I have a problem with modality of the forms under C#.NET. Let's say I have main form #0 (see the image below). This form represents main application form, where user can perform various operations. However, from time to time, there is a need to open additional non-modal form to perform additional main application functionality supporting tasks. Let's say this is form #1 in the image. On this #1 form there might be opened few additional modal forms on top of each other (#2 form in the image), and at the end, there is a progress dialog showing a long operation progress and status, which might take from few minutes up to few hours. The problem is that the main form #0 is not responsive until you close all modal forms (#2 in the image). I need that the main form #0 would be operational in this situation. However, if you open a non-modal form in form #2, you can operate with both modal #2 form and newly created non modal form. I need the same behavior between the main form #0 and form #1 with all its child forms. Is it possible? Or am I doing something wrong? Maybe there is some kind of workaround, I really would not like to change all ShowDialog calls to ShowDialog...

    Read the article

  • Why is a NullReferenceException thrown when a ToolStrip button is clicked twice with code in the `Click` event handler?

    - by Patrick
    I created a clean WindowsFormsApplication solution, added a ToolStrip to the main form, and placed one button on it. I've added also an OpenFileDialog, so that the Click event of the ToolStripButton looks like the following: private void toolStripButton1_Click(object sender, EventArgs e) { openFileDialog1.ShowDialog(); } I didn't change any other properties or events. The funny thing is that when I double-click the ToolStripButton (the second click must be quite fast, before the dialog opens), then cancel both dialogs (or choose a file, it doesn't really matter) and then click in the client area of main form, a NullReferenceException crashes the application (error details attached at the end of the post). Please note that the Click event is implemented while DoubleClick is not. What's even more strange that when the OpenFileDialog is replaced by any user-implemented form, the ToolStripButton blocks from being clicked twice. I'm using VS2008 with .NET3.5. I didn't change many options in VS (only fontsize, workspace folder and line numbering). Does anyone know how to solve this? It is 100% replicable on my machine, is it on others too? One solution that I can think of is disabling the button before calling OpenFileDialog.ShowDialog() and then enabling the button back (but it's not nice). Any other ideas? And now the promised error details: System.NullReferenceException was unhandled Message="Object reference not set to an instance of an object." Source="System.Windows.Forms" StackTrace: at System.Windows.Forms.NativeWindow.WindowClass.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.PeekMessage(MSG& msg, HandleRef hwnd, Int32 msgMin, Int32 msgMax, Int32 remove) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at WindowsFormsApplication1.Program.Main() w C:\Users\Marchewek\Desktop\Workspaces\VisualStudio\WindowsFormsApplication1\Program.cs:line 20 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException:

    Read the article

  • Which technology should I use to pop up a simple form in my add-in DLL?

    - by Decker
    I'm building an assembly that runs as an "add-on" to a vendor's Outlook add-in. When it is time for me to execute my "action", I have to put up a simple window with a few simple controls. The vendor's add-in provides me with the parent window's integer handle. I am able to put up a form pretty easily with WinForms by adding are reference to System.Windows.Forms from my assembly and with the following code: FrmHistoryDisplay frm = new FrmHistoryDisplay(); frm.ShowDialog(new ParentWindowWrapper(_parentWindowHandle)); where ParentWindowWrapper is a shim class around the window handle I'm given private class ParentWindowWrapper : IWin32Window { private int _parentWindowHandle; public ParentWindowWrapper(int parentWindowHandle) { _parentWindowHandle = parentWindowHandle; } public IntPtr Handle { get { return new IntPtr(_parentWindowHandle); } } } The Form's ShowDialog method takes an IWin32Window implementor to wrap the parent's window handle. This all works and seems simple enough. I was just wondering whether something similar can be done with a WPF window rather than a WinForm Form? Should I care?

    Read the article

  • Save PowerPoint slides as images

    - by nihi_l_ist
    I want to save some presentation file as images into some directory and use the code: OpenFileDialog o = new OpenFileDialog(); o.ShowDialog(); if (o.FileName != null) { ApplicationClass pptApplication = new ApplicationClass(); Presentation pptPresentation = pptApplication.Presentations.Open(o.FileName, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse); FolderBrowserDialog fb = new FolderBrowserDialog(); fb.ShowDialog(); for (int i = 0; i < pptPresentation.Slides.Count; i++) { pptPresentation.Slides[i].Export(fb.SelectedPath + "Slide" + (i + 1) + ".jpg", "jpg", 320, 240); } } use namespaces: using Microsoft.Office.Core; using Microsoft.Office.Interop.PowerPoint; But i get the following error: 'Microsoft.Office.Interop.PowerPoint.ApplicationClass' does not contain a definition for 'Presentations' and no extension method 'Presentations' accepting a first argument of type 'Microsoft.Office.Interop.PowerPoint.ApplicationClass' could be found (are you missing a using directive or an assembly reference?) Tho it seems that it has property called Presentations.. What am i doing incorrectly?

    Read the article

  • Need help with if else statement

    - by Michael Quiles
    I'm trying to do an else statement that would tell the user that the game ended in a draw (tic tac toe game). I got it where it works if played and there's a winner it will show another form declaring the winner through an if statement but I cant figure out the its a draw portion. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; using System.Drawing; namespace MyGame { public class Result1 { static private int[,] Winners = new int[,] { // main gameplay Ex: if x is on 0,1,2 x is the winner {0,1,2}, {3,4,5}, {6,7,8}, {0,3,6}, {1,4,7}, {2,5,8}, {0,4,8}, {2,4,6}, }; static public bool CheckWinner(Button[] myControls) { //bolean statement to check for the winner bool gameOver = false; for (int i = 0; i < 8; i++) { int a = Winners[i, 0]; int b = Winners[i, 1]; int c = Winners[i, 2]; Button b1 = myControls[a], b2 = myControls[b], b3 = myControls[c]; if (b1.Text == "" || b2.Text == "" || b3.Text == "") continue; if (b1.Text == b2.Text && b2.Text == b3.Text) { b1.BackColor = b2.BackColor = b3.BackColor = Color.LightCoral; b1.Font = b2.Font = b3.Font = new System.Drawing.Font("Microsoft Sans Serif", 32F, System.Drawing.FontStyle.Italic & System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); gameOver = true; xWinnerForm xWinnerForm = new xWinnerForm(); xWinnerForm.ShowDialog(); //only works with show not showDialog method gets overloaded (b1.Text + " is the Winner"); to get around this I added and image showing the last player } //else statement here for draw what code would I put in? } return gameOver; } } }

    Read the article

  • WindowsFormsApplicationBase SplashScreen makes login form ignore keypresses until I click on it - how to debug?

    - by Tom Bushell
    My WinForms app has a simple modal login form, invoked at startup via ShowDialog(). When I run from inside Visual Studio, everything works fine. I can just type in my User ID, hit the Enter key, and get logged in. But when I run a release build directly, everything looks normal (the login form is active, there's a blinking cursor in the User ID MaskedEditBox), but all keypresses are ignored until I click somewhere on the login form. Very annoying if you are used to doing everything from the keyboard. I've tried to trace through the event handlers, and to set the focus directly with code, to no avail. Any suggestions how to debug this (outside of Visual Studio), or failing that - a possible workaround? Edit Here's the calling code, in my Main Form: private void OfeMainForm_Shown(object sender, EventArgs e) { OperatorLogon(); } private void OperatorLogon() { // Modal dialogs should be in a "using" block for proper disposal using (var logonForm = new C21CfrLogOnForm()) { var dr = logonForm.ShowDialog(this); if (dr == DialogResult.OK) SaveOperatorId(logonForm.OperatorId); else Application.Exit(); } } Edit 2 Didn't think this was relevant, but I'm using Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase for it's splash screen and SingleInstanceController support. I just commented out the splash screen code, and the problem has disappeared. So that's opened up a whole new line of inquiry... Edit 3 Changed title to reflect better understanding of the problem

    Read the article

  • Swing object: first setText() gets "stuck" when using Mac Java SE 6

    - by Tim
    Hi there, I am a Java newbie trying to maintain an application that works fine under J2SE 5.0 (32- and 64-bit) but has a very specific problem when run under Java SE 6 64-bit: [Tims-MPB:~] tlynch% java -version java version "1.6.0_15" Java(TM) SE Runtime Environment (build 1.6.0_15-b03-226) Java HotSpot(TM) 64-Bit Server VM (build 14.1-b02-92, mixed mode) The application is cross-platform and reportedly works correctly on Java SE 6 under Windows, though I haven't been able to verify that myself. The program uses a JTextField for some text entry and a JLabel to indicate the text to be entered. The first time the showDialog() method is called to set the label text and display the dialog, it works correctly, but subsequent calls all result in the display of the label from the initial invocation rather than the one most recently specified via setText(). public void showDialog(String msgText) { System.out.println("set ChatDialog: " + msgText); jLabel1.setText(msgText); jLabel1.repaint(); // I added this; it didn't help System.out.println("get ChatDialog: " + jLabel1.getText()); super.setVisible(true); } [the full text of the class is provided below] The added printlns validate that expected text is passed to the label's setText() method and is confirmed by retrieving it using getText(), but what shows up on the screen/GUI is always the text from the very first time the method was called for the object. A similar issue is observed with a JTextArea used to label another dialog box. These problem are consistent across multiple Mac systems running Java SE 6 under OS 10.5.x and 10.6.x, but they are never observed when one reverts to J2SE 5.0. If there is some background information pertinent to this problem that I have omitted, please let me know. Any insights or advice appreciated. package gui; import java.awt.*; import java.awt.event.KeyEvent; import javax.swing.*; // Referenced classes of package gui: // MyJPanel, ChatDialog_jTextField1_keyAdapter, WarWindow public class ChatDialog extends JDialog { public ChatDialog(JFrame parent, WarWindow w) { super(parent, true); text = ""; borderLayout1 = new BorderLayout(); jPanel1 = new MyJPanel(); borderLayout2 = new BorderLayout(); jPanel2 = new MyJPanel(); jPanel3 = new MyJPanel(); jLabel1 = new JLabel(); jTextField1 = new JTextField(); warWindow = w; try { jbInit(); } catch(Exception exception) { System.out.println("Problem with ChatDialog init"); exception.printStackTrace(); } return; } public String getText() { return text; } void jTextField1_keyPressed(KeyEvent e) { int id = e.getKeyCode(); switch(id) { case 10: // '\n' text = jTextField1.getText(); setVisible(false); break; } } private void jbInit() throws Exception { setLocation(232, 450); setSize(560, 60); setModal(true); setResizable(false); setUndecorated(true); getContentPane().setLayout(borderLayout1); jPanel1.setLayout(borderLayout2); jPanel2.setMinimumSize(new Dimension(10, 20)); jPanel2.setPreferredSize(new Dimension(10, 20)); jLabel1.setPreferredSize(new Dimension(380, 15)); jLabel1.setHorizontalAlignment(0); jLabel1.setText("Chat Message"); jTextField1.setPreferredSize(new Dimension(520, 21)); jTextField1.setRequestFocusEnabled(false); jTextField1.addKeyListener(new ChatDialog_jTextField1_keyAdapter(this)); getContentPane().add(jPanel1, "Center"); jPanel1.add(jPanel2, "North"); jPanel2.add(jLabel1, null); jPanel1.add(jPanel3, "Center"); jPanel3.add(jTextField1, null); } public void setVisible(boolean b) { jTextField1.setText(""); super.setVisible(b); } public void showDialog(String msgText) { System.out.println("set ChatDialog: " + msgText); jLabel1.setText(msgText); jLabel1.repaint(); // I added this; it didn't help System.out.println("get ChatDialog: " + jLabel1.getText()); super.setVisible(true); } void this_keyPressed(KeyEvent e) { int id = e.getKeyCode(); switch(id) { case 10: // '\n' System.exit(88); break; } } BorderLayout borderLayout1; BorderLayout borderLayout2; JLabel jLabel1; JPanel jPanel1; JPanel jPanel2; JPanel jPanel3; JTextField jTextField1; String text; WarWindow warWindow; }

    Read the article

  • TFS API-Process Template currently applied to the Team Project

    - by Tarun Arora
    Download Demo Solution - here In this blog post I’ll show you how to use the TFS API to get the name of the Process Template that is currently applied to the Team Project. You can also download the demo solution attached, I’ve tested this solution against TFS 2010 and TFS 2011.    1. Connecting to TFS Programmatically I have a blog post that shows you from where to download the VS 2010 SP1 SDK and how to connect to TFS programmatically. private TfsTeamProjectCollection _tfs; private string _selectedTeamProject;   TeamProjectPicker tfsPP = new TeamProjectPicker(TeamProjectPickerMode.SingleProject, false); tfsPP.ShowDialog(); this._tfs = tfsPP.SelectedTeamProjectCollection; this._selectedTeamProject = tfsPP.SelectedProjects[0].Name; 2. Programmatically get the Process Template details of the selected Team Project I’ll be making use of the VersionControlServer service to get the Team Project details and the ICommonStructureService to get the Project Properties. private ProjectProperty[] GetProcessTemplateDetailsForTheSelectedProject() { var vcs = _tfs.GetService<VersionControlServer>(); var ics = _tfs.GetService<ICommonStructureService>(); ProjectProperty[] ProjectProperties = null; var p = vcs.GetTeamProject(_selectedTeamProject); string ProjectName = string.Empty; string ProjectState = String.Empty; int templateId = 0; ProjectProperties = null; ics.GetProjectProperties(p.ArtifactUri.AbsoluteUri, out ProjectName, out ProjectState, out templateId, out ProjectProperties); return ProjectProperties; } 3. What’s the catch? The ProjectProperties will contain a property “Process Template” which as a value has the name of the process template. So, you will be able to use the below line of code to get the name of the process template. var processTemplateName = processTemplateDetails.Where(pt => pt.Name == "Process Template").Select(pt => pt.Value).FirstOrDefault();   However, if the process template does not contain the property “Process Template” then you will need to add it. So, the question becomes how do i add the Name property to the Process Template. Download the Process Template from the Process Template Manager on your local        Once you have downloaded the Process Template to your local machine, navigate to the Classification folder with in the template       From the classification folder open Classification.xml        Add a new property <property name=”Process Template” value=”MSF for CMMI Process Improvement v5.0” />           4. Putting it all together… 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 Microsoft.TeamFoundation.Client; using Microsoft.TeamFoundation.VersionControl.Client; using Microsoft.TeamFoundation.Server; using System.Diagnostics; using Microsoft.TeamFoundation.WorkItemTracking.Client; namespace TfsAPIDemoProcessTemplate { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private TfsTeamProjectCollection _tfs; private string _selectedTeamProject; private void btnConnect_Click(object sender, EventArgs e) { TeamProjectPicker tfsPP = new TeamProjectPicker(TeamProjectPickerMode.SingleProject, false); tfsPP.ShowDialog(); this._tfs = tfsPP.SelectedTeamProjectCollection; this._selectedTeamProject = tfsPP.SelectedProjects[0].Name; var processTemplateDetails = GetProcessTemplateDetailsForTheSelectedProject(); listBox1.Items.Clear(); listBox1.Items.Add(String.Format("Team Project Selected => '{0}'", _selectedTeamProject)); listBox1.Items.Add(Environment.NewLine); var processTemplateName = processTemplateDetails.Where(pt => pt.Name == "Process Template") .Select(pt => pt.Value).FirstOrDefault(); if (!string.IsNullOrEmpty(processTemplateName)) { listBox1.Items.Add(Environment.NewLine); listBox1.Items.Add(String.Format("Process Template Name: {0}", processTemplateName)); } else { listBox1.Items.Add(String.Format("The Process Template does not have the 'Name' property set up")); listBox1.Items.Add(String.Format("***TIP: Download the Process Template and in Classification.xml add a new property Name, update the template then you will be able to see the Process Template Name***")); listBox1.Items.Add(String.Format(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -")); } } private ProjectProperty[] GetProcessTemplateDetailsForTheSelectedProject() { var vcs = _tfs.GetService<VersionControlServer>(); var ics = _tfs.GetService<ICommonStructureService>(); ProjectProperty[] ProjectProperties = null; var p = vcs.GetTeamProject(_selectedTeamProject); string ProjectName = string.Empty; string ProjectState = String.Empty; int templateId = 0; ProjectProperties = null; ics.GetProjectProperties(p.ArtifactUri.AbsoluteUri, out ProjectName, out ProjectState, out templateId, out ProjectProperties); return ProjectProperties; } } } Thank you for taking the time out and reading this blog post. If you enjoyed the post, remember to subscribe to http://feeds.feedburner.com/TarunArora. Have you come across a better way of doing this, please share your experience here. Questions/Feedback/Suggestions, etc please leave a comment. Thank You! Share this post : CodeProject

    Read the article

  • How to load Image in C# and set properties of the Picture Box

    - by SAMIR BHOGAYTA
    Create a C# application drag a picture Box, four buttons and open file dialog on the form. Write code on btn_browse Button click ----------------------------------------- private void btn_browse_Click(object sender, System.EventArgs e) { try { OpenFileDialog open = new OpenFileDialog(); open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp"; if (open.ShowDialog()==DialogResult.OK) { pictureBox1.Image = new Bitmap(open.FileName); } } catch (Exception) { throw new ApplicationException("Failed loading image"); } } Write code on btn_StretchImage Button click ------------------------------------------------ private void btn_StretchImage_Click(object sender, System.EventArgs e) { pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; } Write code on btn_AutoSize Button click ------------------------------------------------- private void btn_AutoSize_Click(object sender, System.EventArgs e) { pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; } Write code on btn_CenterImage Button click -------------------------------------------------- private void btn_CenterImage_Click(object sender, System.EventArgs e) { pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; }

    Read the article

  • Open File Dialog MVVM

    - by Jose
    Ok I really would like to know how expert MVVM developers handle an openfile dialog in WPF. I don't really want to do this in my ViewModel(where 'Browse' is referenced via a DelegateCommand) void Browse(object param) { //Add code here OpenFileDialog d = new OpenFileDialog(); if (d.ShowDialog() == true) { //Do stuff } } Because I believe that goes against MVVM methodology. What do I do?

    Read the article

  • C# MP3 Player using winmm.dll

    - by JoeBeez
    I'm trying to bash together a (very) rough MP3 player during my lunch hour, and so far I've got it to play the files, and I'm working on a way of building a list of filenames to enable random songs, but I think I've just hit a snag. Is there a way of knowing when the currently playing MP3 has finished? An event or some such? As it stands I don't think I'd be able to have playlists etc unless this was possible due to it stopping after every playback. I've attatched the whole source below, feel free to pick it apart and give me any feedback you may have, cheers. using System; using System.IO; 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.Runtime.InteropServices; namespace X { public partial class Form1 : Form { List<string> Names = new List<string>(); StreamReader reader = File.OpenText(@"C:\X.txt"); string line; OpenFileDialog ofd = new OpenFileDialog(); StringBuilder buffer = new StringBuilder(128); string CommandString; [DllImport("winmm.dll")] private static extern long mciSendString(string lpstrCommand, StringBuilder lpstrReturnString, int uReturnLength, int hwndCallback); public Form1() { InitializeComponent(); while ((line = reader.ReadLine()) != null) { if (line.Trim() != "") { Names.Add(line.Trim()); } } } private void btnplay_Click(object sender, EventArgs e) { if (ofd.FileName == "") { if (ofd.ShowDialog() == DialogResult.OK) { ofd.Filter = "MP3 Files|*.mp3"; CommandString = "open " + "\"" + ofd.FileName + "\"" + " type MPEGVideo alias Mp3File"; mciSendString(CommandString, null, 0, 0); CommandString = "play Mp3File"; mciSendString(CommandString, null, 0, 0); } } else { CommandString = "play Mp3File"; mciSendString(CommandString, null, 0, 0); } } private void btnpause_Click(object sender, EventArgs e) { CommandString = "pause mp3file"; mciSendString(CommandString, null, 0, 0); } private void btnbrowse_Click(object sender, EventArgs e) { ofd.Filter = "Mp3 files |*.mp3"; if (ofd.ShowDialog() == DialogResult.OK) { txtpath.Text = ofd.FileName; CommandString = "close Mp3File"; mciSendString(CommandString, null, 0, 0); CommandString = "open " + "\"" + ofd.FileName + "\"" + " type MPEGVideo alias Mp3File"; mciSendString(CommandString, null, 0, 0); } } } }

    Read the article

  • Secondary monitor bug: a problem in WPF or in the graphics driver?

    - by emddudley
    I have discovered a strange bug with my WPF application and I am trying to determine whether it is a problem with WPF or my graphics driver so that I can report it to the appropriate company. I have a Quadro FX 1700 with the latest drivers (197.54) on a Windows XP system, running a .NET 3.5 SP1 application. I have dual monitors, and when I maximize then minimize a child window of the main window on my primary monitor, the child window gets drawn on the secondary monitor as well. It appears in both places. I made a sample application (code is below) which induces this behavior. Start the application and ensure the main window is on your primary monitor. Double-click the main window. A green child window should appear. Click the green child window to maximize. Click the green child window to minimize. Can anyone else reproduce this problem? On my system the green child restores, but then it's drawn on both my primary and secondary monitors, rather than just the primary monitor. App.xaml <Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="DualMonitorBug.App" StartupUri="Shell.xaml" /> App.xaml.cs using System.Windows; namespace DualMonitorBug { public partial class App : Application { } } Shell.xaml <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="DualMonitorBug.Shell" Title="Shell" Height="480" Width="640" MouseDoubleClick="ShowDialog" /> Shell.xaml.cs using System.Windows; using System.Windows.Input; namespace DualMonitorBug { public partial class Shell : Window { public Shell() { InitializeComponent(); } private void ShowDialog(object sender, MouseButtonEventArgs e) { DialogWindow dialog = new DialogWindow(); dialog.Owner = this; dialog.Show(); } } } DialogWindow.xaml <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="DualMonitorBug.DialogWindow" Title="Dialog Window" Height="240" Width="320" AllowsTransparency="True" Background="Green" MouseLeftButtonDown="ShowHideDialog" WindowStyle="None" /> DialogWindow.xaml.cs using System.Windows; using System.Windows.Input; namespace DualMonitorBug { public partial class DialogWindow : Window { public DialogWindow() { InitializeComponent(); } private void ShowHideDialog(object sender, MouseButtonEventArgs e) { this.WindowState = (this.WindowState == WindowState.Normal) ? WindowState.Maximized : WindowState.Normal; } } }

    Read the article

  • C# - Close a child form from parent

    - by Nate Shoffner
    I have a parent form and a child form. I need to open the child form at the beginning of a method, do some pretty intensive tasks and then close the child form upon completion. Here is basically what I've tried so far (with no luck): Parent Form: Child child = new Child(); Method() { child.ShowDialog(); //Method code here child.CloseScan(); } Child Form: public void CloseScan() { this.Close(); }

    Read the article

  • Print Preview Control used in a custom Print Preview Dialog.

    - by Kildareflare
    I have successfully implemented printing and print preview for my app using the PrintDocument, PrintDialog and PrintPreviewDialog classes of .NET. However my app uses a toolkit to improve the appearance of the standard .NET controls. There are versions of most .NET controls in the toolkit, but none for the Print controls. Therefore to ensure that the appearance of these controls matches the rest of the app I am creating a custom PrintPreviewDialog based on a toolkit form and embedding a .NET PrintPrewviewControl in it. My problem is that the PrintPreviewControl always shows "No pages to display". I had no trouble getting this to work using the .NET PrintPreviewDialog and cannot see what I am doing wrong. This is a .NET 2.0 PrintPreviewControl and so I know that I need to call InvalidatePreview() after assigning the PrintDocument. However it does not seem to matter where i place it, the PrintPage event handler never gets called... EDIT: I've just noticed that while the original PrintDocument m_printDocument shows a PrintPageHandler in its properties, the m_printPreviewControl.Document does not. Any ideas why it is being lost..? public class PrintEngine { ...rest of class... public PrintEngine() { m_printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage); } public void PrintPreview() { //ORIGINAL CODE USING .NET DIALOG WORK OK //PrintPreviewDialog dlg1 = new PrintPreviewDialog(); //dlg1.Document = m_printDoc; //PrepareImageForPrinting(); //dlg1.ShowDialog(); //CODE USING MY CUSTOM DIALOG DO NOT WORK? MyPrintPreviewDialog dlg2 = new MyPrintPreviewDialog(); dlg2.Document = m_printDoc; PrepareImageForPrinting(); //Creates the m_printImage List dlg2.ShowDialog(); } private void printDoc_PrintPage(object sender, PrintPageEventArgs e) { e.Graphics.DrawImage(m_printImages[m_currentPage], new Point(0, 0)); m_currentPage++; e.HasMorePages = m_currentPage < m_pagesHigh; } }//end PrintEngine class public class MyPrintPreviewDialog : KryptonForm { public PrintDocument Document { get { return m_printPreviewControl.Document; } set { m_printPreviewControl.Document = value; m_printPreviewControl.InvalidatePreview(); } } public MyPrintPreviewDialog() { InitializeComponent(); m_printPreviewControl = new PrintPreviewControl(); m_printPreviewControl.StartPage = 0; } private void MyPrintPreviewDialog_Load(object sender, EventArgs e) { m_printPreviewControl.Document.DefaultPageSettings = new PageSettings(); m_printPreviewControl.Document.PrinterSettings = new PrinterSettings(); m_printPreviewControl.InvalidatePreview(); } }//end MyPrintPreviewDialog class

    Read the article

  • Exception handling problem in release mode

    - by lama-power
    I have application with this code: Module Startup <STAThread()> _ Public Sub Main() Try Application.EnableVisualStyles() Application.SetCompatibleTextRenderingDefault(False) InitApp() Dim login As New LoginForm() Dim main As New MainForm() Application.Run(login) If login.DialogResult = DialogResult.OK Then ActUser = login.LoggedUser main.ShowDialog() End If DisposeApp() Catch ex As Exception ErrMsg(ex, "Error!", ErrorLogger.ErrMsgType.CriticalError) End End Try End Sub End Module in debug mode everithing is OK. But in release mode when somewhere in application exception occurs my global catch in Main method doesn`t catch exception. What is the problem please?

    Read the article

  • Javascript Like Modal Window for WinForms.

    - by JeremySpouken
    Does anybody know a good Modal Window control sort of like the ones used in Javascript but available for WinForms (C#) with the transparent background and all. Example in Javascript http://okonet.ru/projects/modalbox/ Something like ModalCoolForm f = new ModalCoolForm(); f.ShowDialog(this);

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >