=== bgs100 is now known as bgs000 === BlackZ_ is now known as BlackZ === yofel_ is now known as yofel === keffie_jayx_ is now known as keffie_jayx === Raven is now known as Guest56837 [16:00] hi [16:00] hi class === bgs000 is now known as bgs100 === apachelogger is now known as brokenl00gR [20:39] someone knows where i can get yesterday's log? i can't find it here: https://wiki.ubuntu.com/Classroom [20:40] Tiibiidii: http://irclogs.ubuntu.com/2010/06/23/%23ubuntu-classroom.html [20:40] thank you pleia2 [20:40] sure thing [20:58] Hi! [21:00] Hi sirmacik. [21:01] Can't wait for today class (: === ChanServ changed the topic of #ubuntu-classroom to: Welcome to the Ubuntu Classroom - http://wiki.ubuntu.com/Classroom || Support in #ubuntu || Current Class: Introduction to C# Day 2 [21:02] ohai [21:02] Right, Day 2. [21:02] Hi juju2143 [21:02] hi sirmacik [21:04] So open your MonoDevelop and create a new GTK# project. [21:04] Oh just in time [21:04] yep pedro3005 [21:04] juju2143, btw I did my homework [21:05] class time? [21:05] ok [21:05] done (: [21:05] Everyone played with console apps [21:06] yep [21:06] cool then [21:06] Today we'll do graphics. [21:07] So you have your GTK# app. [21:08] You will see some files in your left [21:09] Generally, it's a good idea to make one file per class/window. [21:10] In the user interface, you will see MainWindow, who is an empty window [21:10] Now you would put some buttons in it [21:11] I only see Main.cs [21:11] :( [21:11] ah... [21:11] pedro3005: have You installed gtk-sharp2? [21:11] maybe you have it wrong [21:12] sirmacik, yes [21:12] For me this lib was missing [21:12] god I hate monodevelop [21:12] me too [21:13] juju2143, is there anything else I can use? [21:13] I can't find the buttons and textboxes to drag into the window [21:13] like on Visual Studio [21:13] pedro3005: have you used New Solution -> C# -> GTK# 2.0 Project? [21:13] pedro3005, your favorite text editor [21:13] meebey, yes [21:14] juju2143, wouldn't that be harder? [21:14] lol [21:14] nope [21:14] oh I found them [21:16] Ok so you have a window. [21:16] I'll just install it over [21:17] ok [21:17] now ill move on [21:17] So you have your main window. [21:18] right? [21:18] pedro3005: oh you are not on -chat, I was trying to give you some test commands [21:18] yes <: [21:19] can we move on? [21:20] yes [21:20] Now you would want to put things in it right? [21:20] Alt-Shift-B [21:21] You will see lots of widgets to drag into your window. [21:22] a lot (: [21:22] But in GTK, everything must be in a contener. [21:22] or sth [21:22] First, put a Fixed, then a Button [21:23] Now we will want to rename the button [21:24] Alt+Shift+P [21:24] Now you can edit its properties. [21:24] So you will see its name is button1, we will use it as a variable name to access it. [21:25] in Button Properties, you will want to change the text. [21:25] Now we will want to make it do something [21:26] In the signals tabs, Buttpn Signals > Clicked [21:27] double clich where it says Click here [21:27] ti will create a new function in MainWindow.cs [21:27] named OnButton1Clicked [21:28] got it [21:28] ncie [21:28] nice* [21:30] what's next? [21:30] hm lemme test something [21:30] (: [21:31] hmmm [21:32] ok [21:34] Now in the function add this code: [21:35] MessageDialog dialog = new MessageDialog(this, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok, "Hello World!"); [21:35] dialog.Show(); [21:35] between the {}'s. [21:36] now compile and run [21:37] you see something? [21:37] works great [21:38] Cool. [21:39] So you seen how to show some hello world. [21:39] juju2143: but how to program that dialog to close on click on ok button? [21:39] hmmmm idk [21:39] it's not like Windows Forms. [21:40] you can call dialog.Run(); instead of Show() [21:40] hm maybe you have to create a class based on MessageDialog or sth [21:40] then it will close if you give a response (clicking a button) [21:40] meebey, right [21:41] else you have to implement for each button and window event yourself, Run() is much simpler [21:43] * meebey is the developer of Smuxi which is written in C# and available in Ubuntu and has lots of GTK# experience because of that [21:43] Now looks like my MainWindow crashed [21:43] run() seems to do the same [21:43] meebey, oh cool. [21:43] the dialog is not automatically closing? [21:43] hmmm [21:43] let me try... maybe MessageDialog works differently than Dialog [21:44] hm yeah... [21:44] so the important is that you put omething in a variable of type MessageDialog [21:45] so you create a class, then you can instanciade it in a variable. [21:45] ok, you need to add dialog.Destroy() after .Run() [21:45] .Run() returns the reponse but is not automatically destroying the dialog with it [21:45] yight [21:46] thanks meebey (: [21:46] Oh cool :) [21:46] ok, juju2143 whats next? (; [21:47] Now you will want inputting [21:48] Return in designer [21:49] and add 2 Entry [21:49] Or maybe just one. [21:49] done [21:50] Return in the source, instead of "Hello world", type entry1.Text [21:50] compile and run [21:51] works perfect [21:51] good [21:51] type something in your textbox [21:51] then click the button [21:52] yeah runs good [21:52] Now the problem is that maybe you want to, say, multiply by 2 the number. [21:52] But you can't multiply by 2 a number [21:53] entry1.Text * 2 [21:53] I mean, you can't do that on a string. [21:53] I mean, it's all nice with visuals but I don't understand the code [21:53] yeah [21:54] it's full of things I don't know [21:54] Most of the code, you will not care about that because it works. [21:55] So it works, yay. [21:56] So this code added automatically by the IDE, you will not care unless you are on some advanced level. [21:56] Now you will want to convert entry1.Text in a number [21:58] int number = Convert.ToInt32(entry1.Text); [21:59] then put number * 2 instead of entry1.Text [21:59] in your long MessageDialog line. [21:59] Compile and run. [21:59] hmm [21:59] where I should put that int number line? [22:00] before the MessageDialog line [22:01] In fact, instead of number * 2 it's (number*2).ToString() [22:01] because it needs a string [22:02] Compile and run. [22:03] now put a number, it should multiply it successfully [22:03] works (; [22:03] But what if you put s non-number? [22:04] It crashes. [22:04] With an exception. [22:05] yep [22:06] You may want to do something when it does that: we will do that wit Try/catach [22:06] Try this: [22:06] int number; [22:06] try { [22:06] number = Convert.ToInt32(entry1.Text); [22:07] } [22:07] catch { [22:07] entry2.Text = "OMG we got an error"; [22:07] } [22:08] before the } you would put a return; to stop the function. [22:08] then after } you would put entry2.Text = (number*2).ToString(); [22:08] Compile and run [22:08] witch } [22:08] 'x [22:09] mh [22:09] argh... witch '}'? * [22:09] yeah [22:09] catch { [22:09] entry2.Text = "OMG we got an error"; [22:09] for return and witch for that entry2? [22:09] return; [22:09] } [22:09] oh (; [22:10] [/g 67 [22:10] sorry [22:10] and entry2 you would put a second Entry in your Designer [22:11] oh damn my laptop bacame laggy, i'll Ctrl-alt-Backspace. [22:12] works (; [22:12] :D [22:12] so you learnt the try/catch [22:13] maybe if you put (Exception ex) fter the catch keyword [22:13] the ex variable containing all sorts of infos about the exception becomes available in the catch block [22:14] so this 'ex' variable already exists? [22:16] nope, you defined it [22:17] then the compilers when it enters in the catch, like a function, it will pul all the infos in the var [22:18] now that you made your 1st app in GTK+ [22:18] GTK#* [22:19] (; [22:19] C# is hot! sexiest programming language I have seen ^^ [22:19] You may try to make a method. [22:20] meebey, hehe [22:20] loool meebey [22:20] sebner: you are late stefan, now quickly take a seat! [22:21] meebey: sure :), bouncer is dead :( [22:21] lol. [22:21] last theory today, methods [22:21] tomorrow we'll do whole classes [22:22] between the 2 } at the end. [22:22] private string MultiplyBy2(string number) [22:22] { [22:23] / This is a comment [22:23] // This is a comment [22:23] / This is NOT a comment and won't compile. [22:23] /* But this is a comment [22:23] a multiline [22:24] comment */ [22:24] / Insert here the try/catch block of the last example [22:25] return (num * 2).ToString(); [22:25] } [22:25] I write / instead of // because the way IRC handles lines beginning by / [22:26] juju2143, why is the first line a comment and the third not one? [22:26] / test [22:26] oh funny [22:26] / [22:26] juju2143: just use a whitespace before the / [22:26] because I wanted to write // but I failed and it showed up as / [22:27] ok [22:27] sebner, usually I put a Ctrl-O [22:27] // there [22:27] juju2143, so only // and /* */ right? [22:27] pedro3005, yep [22:27] [22:28] nice [22:29] so in your try{} block you would put int num = Convert.ToString(number); [22:30] and in catch, a MessageDialog saying that the function failed then a return 0; [22:30] juju2143, does C# use finally{} blocks? [22:30] airborn, yes [22:30] thx [22:30] return "oh noes it failed"; [22:32] now in your OnButton1Clicked you would put entry2.Text = MultiplyBy2(entry1.Text); [22:32] now compile and run [22:34] now you would see your number multiplied by 2 [22:35] Now you got an introduction to GTK#. Tomorrow we will see classes and these private/protected/public/static keywords. [22:36] If you have questions, just ask here. [22:36] And you got an intro to methods :P [22:36] (; [22:36] thanks for today juju2143 [22:37] yw :P [22:37] yes, thank you :) [22:37] :) [22:39] only 2 new C# hackers? who will hack all the cool features then into smuxi? ^^ [22:40] 20:25:39 and day3 will be hacking cool smuxi features? [22:40] :-P [22:41] meebey: lol [22:41] meebey: me in summer ;D [22:41] sebner: yay [22:41] sebner: I will get vacation end of july [22:42] meebey: we are speaking about 2011 though :P [22:42] sebner: oh noez [22:42] meebey: gsoc :P you promised me [22:42] moah C# hackaz plx [22:42] sebner: hrhrhr [22:42] meebey: but I'll take a look this summer too ;) [22:42] sebner: I still have to find a gsoc organization... [22:43] meebey: mono [22:43] I dont think they will have much interest in smuxi... they have so many cool mono projects you know... [22:43] meebey: pfff, smuxi is the best :P [22:44] hmm [22:45] juju2143: I've a little problem with understanding of this methods thing. Could You paste somewhere example of working code from todays lesson? [22:46] yeah of course [22:47] protected virtual void OnButton1Clicked(...) { [22:47] entry2.Text = MultiplyBy2(entry1.Text); [22:47] } [22:48] private string MultiplyBy2(string text) { [22:48] int number; [22:48] try { [22:48] number = Convert.ToInt32(text); [22:48] } [22:48] catch { [22:48] return "OMG something happenned"; [22:48] } [22:49] return (number*2).ToString(); [22:49] } [22:49] there it should work [22:49] thanks (: [22:51] :) [22:51] now I see where I failed ;f [22:53] works great [; [23:00] see You tomorrow \o === ChanServ changed the topic of #ubuntu-classroom to: Welcome to the Ubuntu Classroom - http://wiki.ubuntu.com/Classroom || Support in #ubuntu || Upcoming Schedule: http://is.gd/8rtIi === seymour is now known as Guest8762