• Advertisement

Enerjak

Member
  • Content count

    370
  • Joined

  • Last visited

Community Reputation

277 Neutral

About Enerjak

  • Rank
    Member

Personal Information

  • Interests
    Art
    Audio
    Business
    Design
    DevOps
    Education
    Production
    Programming
    QA
  1. protected void menuImage_ChildClick(Object sender, EventArgs e) { if(pbxPhoto.Image != null && sender is MenuItem) { MenuItem mi = (MenuItem)sender; pbxPhoto.SizeMode = modeMenuArray[mi.Index]; pbxPhoto.Invalidate(); } } I'm trying to make one click function to handle multiple menus. Using this code does not work when I click the menu buttons after the image is loaded in the picture box. Here is where I set the event handler of both menu items. // // menuStretch // this.menuStretch.Name = "menuStretch"; this.menuStretch.Size = new System.Drawing.Size(152, 22); this.menuStretch.Text = "S&tretch to Fit"; this.menuStretch.Click += new System.EventHandler(this.menuImage_ChildClick); // // menuActual // this.menuActual.Name = "menuActual"; this.menuActual.Size = new System.Drawing.Size(152, 22); this.menuActual.Text = "&Actual Size"; this.menuActual.Click += new System.EventHandler(this.menuImage_ChildClick); Menu Stretch and Menu Actual are ToolStripMenuItems, which don't have an index variable as I've noticed. How do I get this to work? Otherwise I have to make a separate event function per menu item, which, depending on the amount of image properties, could be a a lot.
  2. Whoops! Here is the right link: https://stackoverflow.com/questions/9763796/reading-from-a-text-file-and-splitting-each-individual-line-into-different-arra go all the way down.
  3. I found this on Google: https://stackoverflow.com/questions/24041113/error-1-inconsistent-accessibility-return-type-is-less-accessible-than-method It shows how to split the lines into an array using a delimiter - like you said I should use. I should have searched more than make a post on it. Thanks for your help.
  4. I got the code in Java to work. Here is the fixed code: package address_book; import java.io.*; import java.util.*; import javax.swing.*; public class application { public static void main(String[] args) { Scanner file = null; person per = null; try { file = new Scanner(new File("address_book.txt")); String firstName = ""; String lastName = ""; String address = ""; while(file.hasNext()) { firstName = file.next(); lastName = file.next(); address = file.nextLine(); per = new person(firstName, lastName, address); } file.close(); System.out.println(per.getFirstName() + " " + per.getLastName() + " " + per.getAddress()); } catch(FileNotFoundException e) { } } } This is what it outputs: And here is the address book file again just for reference: As you can see from the fixed code above, I have made three string variables, firstName, lastName, and address. In order to get the first name from the file, I used Scanner.next(), which reads the string "Robert." Scanner.next() only reads one string until there is a space. Next I read in the last name using another Scanner.next() to get the last name. The Scanner.nextline() gets the rest of the line in the file - which is the address.
  5. No, Name and address are not on separate lines. However, the code I wrote here: package Def; import java.io.*; import java.util.Scanner; import javax.swing.JOptionPane; public class Application { public void main(String[] ages) { try { Scanner scan = new Scanner(new File("Address_book.txt")); String Name = ""; String Address = ""; while(scan.hasNext()) { Name = scan.next(); Address = scan.next(); } JOptionPane.showMessageDialog(null, Name); scan.close(); } catch(FileNotFoundException e) { } } } This should load Address_book.txt - which for some reason it doesn't, but that's another problem all together.
  6. I've recently begun to learn C#. As you can see from this code snippet: Scanner file = new Scanner(new File("hashValues.txt")); String miningDay = ""; String currency = ""; double netPayOut = 0.0; String i = ""; String walletID = ""; Array hashValues; while(file.hasNext()) { miningDay = file.next(); currency = file.next(); netPayOut = file.nextDouble(); i = file.next(); walletID = file.next(); } Java has a class called Scanner which allows you to open a file through the file class. The Scanner class has functions to read individual strings, as well as int and double data types. Does C# have something similar to this? I tried to do something like this, but it doesn't really work. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Globalization; using System.IO; namespace Mod3_Lab1 { class Program { static void Main(string[] args) { StreamReader addressBook = null; String Name = ""; String Address = ""; try { addressBook = new StreamReader("address_book.txt"); while(!addressBook.EndOfStream) { Name = addressBook.ReadLine(); Address = addressBook.ReadLine(); } addressBook.Close(); Console.WriteLine("Name: " + Name); Console.WriteLine("Address: " + Address); } catch(FileNotFoundException) { } } } } Here is the output:
  7.   Should I do that for the outer loop as well?    Edit: Ignore this, I got what you meant. 
  8. I thought I'd try my hand at adding buttons pragmatically using arrays. I have this little function that I thought would work well enough:  private bool createButtons() { bool bButtonsCreated = false; int row = NumPad.RowCount; int col = NumPad.ColumnCount; int i = 1; int j = 1; int num = (i * j); for (i = 1; i < row; i++) { for(j = 1; i < col; j++) { // set the text for the buttons. CalcButtons = new Button[num]; CalcButtons[num] = new Button(); CalcButtons[num].Text = "7"; CalcButtons[num - 1].Text = "8"; CalcButtons[num - 2].Text = "9"; CalcButtons[num - 3].Text = "4"; CalcButtons[num - 4].Text = "5"; CalcButtons[num - 5].Text = "6"; CalcButtons[num - 6].Text = "1"; CalcButtons[num - 7].Text = "2"; CalcButtons[num - 8].Text = "3"; CalcButtons[num].Size = new Size(60, 60); } } if(CalcButtons[num] != null) { bButtonsCreated = true; NumPad.Container.Add(CalcButtons[num]); } else { MessageBox.Show("Buttons not created", "Error", MessageBoxButtons.OK); } return bButtonsCreated; } However, as you can see, it gives out an indexOutOfBounds exception:      What can I do to fix this? Is this the right way to use arrays to do this? 
  9. I'm trying to make an about book using C#. Now, I used a template for it. I edited the assembly description in the properties window. The text shows up in design mode, however, when the application is ran the description box is empty. What can I do to fix this?    Could using .NET 4.0 be the reason for this bug? Is it even a bug or an error on my part? I'm using visual studio 2013.   Design mode:     Application running.      please let me know if you need anything else. 
  10. I was able to use Direcr3D9's debug layer when I was using windows 7. I had to switch to windows 10 because it (windows 7) couldn't find the drivers automatically for my hardware, which included the network card to get online so I was screwed. I could just use Direct3D9 without a debug layer but that will make it harder to know when something messed up, such as not releasing  com objects, devices, surfaces. That's the thing. 
  11. Okay, do I have Graphics tools installed:      I'm trying to use Direct3D9's debugging layer. I've set it up in the control panel as you can see:     And I have Debugging info enabled in Visual Studio:     How do I fix this issue? Cause even though that is all set up, nothing gets written to the output window.  
  12. Okay, I downloaded the graphics tools and everything works now. Thanks to everyone for putting up with me.
  13. So in other words, to use the Debugging layer on windows 10, I would need to install visual studio 2015?
  14. After all that, it still doesn't work when using the debugging flag. Am I missing something? I was getting the error with the application verifier checked off and it installed the windows 8 SDK. I'm not sure what else to do to get this to work using the debug layer. I guess getting windows 10 as soon as it came out was a bad idea....(I heard the risks but I still downloaded it when they offered it for free.) Not really sure where to from here.    P.S. sorry for double posting.
  15. Okay, you know what? I give up on this project. I removed the debug flag and it worked. However, the debug flag is important to weed out errors. I searched for the D3D11_1SDKLayers.dll and it finds it on my PC. so I do have it. I did try to install windows 8 SDK but get error 2753. I've tried to find an answer for that error but couldn't find one that actually worked. Maybe I didn't try hard enough? I'm tired right now so I may search more about this error later.
  • Advertisement