Search Results

Search found 3195 results on 128 pages for 'tip and tricks'.

Page 52/128 | < Previous Page | 48 49 50 51 52 53 54 55 56 57 58 59  | Next Page >

  • Average mail quota usage: tricks to implement unlimited email quota.

    - by Marco Demaio
    I suppose that hosters who provides unlimited mail quota are only claiming it unlimited, and hope that they won't run out of disk space. Correct me if I'm wrong. In order to do such trick they will have probably to calculate the average real quota used by the average user. Let's say on a 100 GB space hosting I offer to 20 x 1GB emails, obviously if all user fill their mail my server would stop working cause they would require 200 GB, but I think I can expect this trick to work cause it will never happen (or it's extermly unprobable) that all user fills up all their mails. But the QUESTTIONS are: What's the average email usage? Can we say that a user normally fills up 1/2 or 1/3 of the quota you provide him? Thanks to any answers/suggetions you might provide.

    Read the article

  • tricks for speeding up tar while tarring up a huge directory of little files?

    - by Trevor Harrison
    I'm trying to tar up a directory that has about 3M tiny files in it. Tar is chugging along, but I'm thinking its going to take longer than I can wait. I'm wondering if telling tar to not store metadata (owner, group, perms) would reduce the churn on reading and re-reading this huge directory and maybe speed things up, and if there is a tar switch that does this. My initial perusal of the man page only gets me something like --no-xattrs, which looks like a start, but I was hoping someone had some specific knowledge.

    Read the article

  • what are all the Optimize tricks that you know for asp.net code ?

    - by Aristos
    After some time of many code programming on asp.net, I discover the very big speed different between string and StringBuilder. I know that is very common and known but I just mention it for start. The second think that I have found to speed up the code, is to use the const, and not the static, for declare my configuration constants value (especial the strings). With the const, the compiler not create new object, but just place the value, on the point that you have ask it, but with the static declaration, is create a new memory object and keep its on the memory. My third trick, is when I search for string, I use hash values, and not the string itself. For example, if I need a List<string SomeValues, and place inside strings that I need to search them, I prefer to use List<int SomeHashValue, and I use the hash value to locate the strings. My forth thought that I was wandering, is if is better to place big strings in one line, or separate them in different lines with the + symbol to be more easy to read out. I make some tests and see that the compiler make a good job is some split the string, in many lines, using the + symbol. What other tricks/tips do you know and use on your programming to make it run faster, and maybe use less memory. Well I know, that some times, to make something run faster, you need more memory, more cache. My priority is on speed. Because Speed Counts.

    Read the article

  • What are the best tricks for learning how to -think- in Objective-C?

    - by Braintapper
    Before I get flamed out for not checking previous questions, I have read most of the tutorials, and have Hillegass' book, as well as O'Reilly's book on it. I'm not asking for tips on Cocoa or what IDE to use. Where my issue lies - my 'mental muscle memory' is making it hard for me to read Objective-C code. I have no problems at all reading Java and C code and understanding what's going on. Maybe I'm getting to old to learn a new syntax, but it's a struggle shifting mental gears and looking at Objective-C code and just "getting it" (I thought it might be an isolated case, but I have other friends who are seasoned devs who have said the same thing). Are there any tricks that any non-Objective-C programmers who now know Objective-C used to help process the syntactical differences when learning it? For some reason, I get dyslexic when reading Objective-C code. Maybe I'm not meant to be able to learn it (and that's ok too). I was hoping/wondering if there might be others who have had the same experience.

    Read the article

  • How to set tooltips on ListView Subitems in .Net

    - by Ryan
    I am trying to set the tool tip text for some of my subitems in my listview control. I am unable to get the tool tip to show up. Anyone have any suggestions? Private _timer As Timer Private Sub Timer() If _timer Is Nothing Then _timer = New Timer _timer.Interval = 500 AddHandler _timer.Tick, AddressOf TimerTick _timer.Start() End If End Sub Private Sub TimerTick(ByVal sender As Object, ByVal e As EventArgs) _timer.Enabled = False End Sub Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs) If Not _timer.Enabled Then Dim item = Me.HitTest(e.X, e.Y) If Not item Is Nothing AndAlso Not item.SubItem Is Nothing Then If item.SubItem.Text = "" Then Dim tip = New ToolTip Dim p = item.SubItem.Bounds tip.ToolTipTitle = "Status" tip.ShowAlways = True tip.Show("FOO", Me, e.X, e.Y, 1000) _timer.Enabled = True End If End If End If MyBase.OnMouseMove(e) End Sub

    Read the article

  • jQuery fadeIn is not working in Internet Explorer

    - by Nazaf
    I have the following HTML DIV which does not work using FadeIn in IE: $(".tip").fadeIn("slow"); /* Is not working in IE. */ $(".tip").show(); /* Works well in IE, that's weird. */ <div class="tip" style="width: 220px; display: none;"> <div class="tip-header"> <span><b>Title</b></span> <div class="right close"><a href="javascript:void(0);">close</a> <img alt="" src="/Images/close-normal.png"/></div> </div> <div class="tip-content">EBody comes here.</div> </div> .tip { display: block; z-index: 99999; position: fixed; background-color: #ffffff; -moz-box-shadow: 2px 2px 10px 2px rgba(0, 0, 0, 0.6); -webkit-box-shadow: 2px 2px 10px 2px rgba(0, 0, 0, 0.6); border:solid 1px #82C2FA; -moz-border-radius: 8px; -webkit-border-radius: 8px; } .tip-header { padding: 8px; min-height: 10px; -moz-border-radius-topleft: 8px; -moz-border-radius-topright: 8px; -webkit-border-radius-topright: 8px; -webkit-border-radius-topleft: 8px; background-color: #CFE6FD; border-bottom: 1px solid #82C2FA; } .tip-header span { font-size: 14px; color: #666666; } .tip-content { padding: 8px; text-align: left; font-size: 12px; } .close, .whats-this { cursor: pointer; } .close a { color: #085FBC; text-decoration: none; } .close img { vertical-align: bottom; }

    Read the article

  • why this jquery code doesn't work if i add class to <P>

    - by metal-gear-solid
    It works var tip = "<p>Most computers will open PDF documents automatically, but you may need to download <a title='Link to Adobe website-opens in a new window'"; tip +=" href='http://www.adobe.com/products/acrobat/readstep2.html' target='_blank'>Adobe Reader</a>.</p>"; if($("div#maincontent a[href*='.pdf']").length>0){ $("div#maincontent").children(":last-child").after(tip); but it not var tip = "<p class="adobe-reader-download">Most computers will open PDF documents automatically, but you may need to download <a title='Link to Adobe website-opens in a new window'"; tip +=" href='http://www.adobe.com/products/acrobat/readstep2.html' target='_blank'>Adobe Reader</a>.</p>"; if($("div#maincontent a[href*='.pdf']").length>0){ $("div#maincontent").children(":last-child").after(tip);

    Read the article

  • "Tool tip" covered by ToolStripItems if they have dropdown items?

    - by Theis
    In Windows Forms - if the dropdown items of a MenuStrip has tooltips and dropdown items themselves the tooltip will have about a 50% chance of showing up below the ToolStripItems. What is the workaround? To repro you can create the MenuStrip in Visual Studio or just add the following code to a form and then try to hover your mouse over the menu items to get a tooltip: //Make a menu strip MenuStrip menu = new MenuStrip(); this.Controls.Add(menu); //Add category "File" ToolStripMenuItem fileItem = new ToolStripMenuItem("File"); menu.Items.Add(fileItem); //Add items for (int i = 0; i < 10; i++) { ToolStripMenuItem item = new ToolStripMenuItem("item"); item.ToolTipText = "item tooltip"; item.DropDownItems.Add("sub item"); fileItem.DropDownItems.Add(item); } I am using .NET 3.5

    Read the article

  • Resharper Tip/Trick... is this possible?

    - by Perpetualcoder
    How can I have Resharper convert code file like using Stuff; using Stuff.MoreStuff; using Stuff.MoreStuff.EvenMoreStuff; namespace CoolStuff { // src code } To namespace CoolStuff { #region Using Statements using Stuff; using Stuff.MoreStuff; using Stuff.MoreStuff.EvenMoreStuff; #endregion // src code } I just like it this way, it "I think" is in one of the stylecop rules too. I would appreciate any kind of help. Thanks

    Read the article

  • Vim html.erb snippets?? snipMate Need a vim tip!

    - by Daniel Upton
    Hi, I've started using Vim for my rails development (who hasn't!).. And i'm loving it except that when im in a html.erb file (HTML and Ruby).. I get no snipMate snippets, I would like both html and ruby... or just html would be fine, How would i do this? Would i need to write a set of snippets? if so is there a way of pulling in existing snippets without copying them? Is there a way of telling vim to go into html mode when it sees .html erb? Thanks Daniel

    Read the article

  • Am I missing a flag or something? RewriteRule tip needed

    - by Kirill
    RewriteEngine On RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)$ index.php?p=$1&l=$2 RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/$ index.php?p=$1&l=$2 this works fine if I do site.com/param_one/param_two/, but returns a 404 when I omit param_two. I'm a newbie to routing requests with htaccess, is there a simple quick fix?

    Read the article

  • What tricks do you use to get yourself "in the zone"?

    - by Tim Jarvis
    Once I am "in the zone" I am extremely productive and code just flows out of me, often I can get 2 or 3 days coding done in 1 day. But I find that often its hard to get to that place, I find myself procrastinating, getting distracted by other things (SO for example). Is this experience common? How do you force yourself into that state of mind? Is it simply something you can't force?

    Read the article

  • What are some tricks I can use with macros?

    - by Sasha
    In our legacy code, as well as our modern code, we use macros to perform nifty solutions like code generations, etc. And we make use of both the # and ## operators. I am curious how other developers use macros to do cool things, if they use them at all.

    Read the article

  • Submit form without page reloading

    - by Camran
    I have a classifieds website, and on the page where ads are showed, I am creating a "Send a tip to a friend" form... So anybody who wants can send a tip of the ad to some friends email-adress. I am guessing the form must be submitted to a php page right? <form name='tip' method='post' action='tip.php'> Tip somebody: <input name="tip_email" type="text" size="30" onfocus="tip_div(1);" onblur="tip_div(2);"/> <input type="submit" value="Skicka Tips"/> <input type="hidden" name="ad_id" /> </form> When submitting the form, the page gets reloaded... I don't want that... Is there any way to make it not reload and still send the mail? Preferrably without ajax or jquery... Thanks

    Read the article

  • php Mail function; Is this way of using it safe?

    - by Camran
    I have a classifieds website, and inside each classified, there is a small form. This form is for users to be able to tip their "friends": <form action="/bincgi/tip.php" method="post" name="tipForm" id="tipForm"> Tip: <input name="email2" id="email2" type="text" size="30 /> <input type="submit" value="Skicka Tips"/> <input type="hidden" value="<?php echo $ad_id;?>" name="ad_id2" id="ad_id2" /> <input type="hidden" value="<?php echo $headline;?>" name="headline2" id="headline2" /> </form> The form is then submitted to a tip.php page, and here is my Q, is this below code safe, ie is it good enough or do I need to make some sanitations and more safety details? $to = filter_var($_POST['email2'], FILTER_SANITIZE_EMAIL); $ad_id = $_POST['ad_id2']; $headline = $_POST['headline2']; $subject = 'You got a tip'; $message ='Hi. You got a tip: '.$headline.'.\n'; $headers = 'From: [email protected]\r\n'; mail($to, $subject, $message, $headers); I haven't tested the above yet.

    Read the article

  • Silverlight Cream for May 12, 2010 -- #860

    - by Dave Campbell
    In this Issue: Miroslav Miroslavov(-2-), Mike Snow(-2-, -3-), Paul Sheriff, Fadi Abdelqader, Jeremy Likness, Marlon Grech, and Victor Gaudioso. Shoutouts: Andy Beaulieu has a cool WP7 game up and is looking for opinions/comments: Droppy Pop: A Windows Phone 7 Game Karl Shifflett has code and video tutorials up for the app he wrote for the WPF LOB tour he just did: Stuff – WPF Line of Business Using MVVM Video Tutorial From SilverlightCream.com: Flipping panels I had missed this 3rd part of the CompleteIT explanation. In this post Miroslav Miroslavov describes the page flipping they're doing. Great explanation and all the code included. Flying objects against you The 4th part of the CompleteIT explanation is blogged by Miroslav Miroslavov where he is discussing the screen elements 'flying toward' the user. Silverlight Tip of the Day #17 – Double Click Mike Snow's Tip of the Day 17 is showing how to implement mouse double-clicks either for an individual control or for an entire app. Silverlight Tip of the Day #18 – Elastic Scrolling In Mike Snow's Tip of the Day 18, he's talking about and showing some 'elastic' scrolling in his image viewer application. He's asking for opinions and suggestions. Silverlight Tip of the Day #19 – Using Bing Maps in Silverlight Mike Snow's Tips are getting more elaborate :) ... Number 19 is about using the BingMap control in your Silverlight app. Control to Control Binding in WPF/Silverlight Paul Sheriff demonstrates control to control binding... saving a bunch of code behind in the process. Project included. Your First Step to the Silverlight Voice/Video Chatting Client/Server Fadi Abdelqader has a post up at CodeProject using the WebCam and Mic features of Silverlight 4 to setup a voice & video chatting app. MVVM Coding by Convention (Convention over Configuration) Jeremy Likness discusses Convention over Configuration and gives up some good MVVM nuggets along the way... check out his nice long post and grab the source for the project too... and also check out the external links he has in there. MEFedMVVM changes >> from cool to cooler Marlon Grech has refactored MEFedMVVM, and in addition is working with other MVVM framework folks to use some of the same MEF techniques in theirs... code on CodePlex New Silverlight Video Tutorial: How to Create a Silverlight Paging System to Load new Pages In Victor Gaudioso's latest video tutorial he builds a ContentHolder UserControl that will load any page on demand into your MainPage.xaml Stay in the 'Light! Twitter SilverlightNews | Twitter WynApse | WynApse.com | Tagged Posts | SilverlightCream Join me @ SilverlightCream | Phoenix Silverlight User Group Technorati Tags: Silverlight    Silverlight 3    Silverlight 4    Windows Phone MIX10

    Read the article

  • How to save image drawn on a JPanel?

    - by swift
    I have a panel with transparent background which i use to draw an image. now problem here is when i draw anything on panel and save the image as a JPEG file its saving the image with black background but i want it to be saved as same, as i draw on the panel. what should be done for this? plz guide me j Client.java public class Client extends Thread { static DatagramSocket datasocket; static DatagramSocket socket; Point point; Whiteboard board; Virtualboard virtualboard; JLayeredPane layerpane; BufferedImage image; public Client(DatagramSocket datasocket) { Client.datasocket=datasocket; } //This function is responsible to connect to the server public static void connect() { try { socket=new DatagramSocket (9000); //client connection socket port= 9000 datasocket=new DatagramSocket (9005); //client data socket port= 9002 ByteArrayOutputStream baos=new ByteArrayOutputStream(); DataOutputStream dos=new DataOutputStream(baos); //this is to tell server that this is a connection request dos.writeChar('c'); dos.close(); byte[]data=baos.toByteArray(); //Server IP address InetAddress ip=InetAddress.getByName("10.123.97.154"); //create the UDP packet DatagramPacket packet=new DatagramPacket(data, data.length,ip , 8000); socket.send(packet); Client client=new Client(datasocket); client.createFrame(); client.run(); } catch(Exception e) { e.printStackTrace(); } } //This function is to create the JFrame public void createFrame() { JFrame frame=new JFrame("Whiteboard"); frame.setVisible(true); frame.setBackground(Color.black); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(680,501); frame.addWindowListener(new WindowAdapter() { public void windowOpened(WindowEvent e) {} public void windowClosing(WindowEvent e) { close(); } }); layerpane=frame.getLayeredPane(); board= new Whiteboard(datasocket); image = new BufferedImage(590,463, BufferedImage.TYPE_INT_ARGB); board.setBounds(74,2,590,463); board.setImage(image); virtualboard=new Virtualboard(); virtualboard.setImage(image); virtualboard.setBounds(74,2,590,463); layerpane.add(virtualboard,new Integer(2));//Panel where remote user draws layerpane.add(board,new Integer(3)); layerpane.add(board.colourButtons(),new Integer(1)); layerpane.add(board.shapeButtons(),new Integer(0)); //frame.add(paper.addButtons(),BorderLayout.WEST); } /* * This function is overridden from the thread class * This function listens for incoming packets from the server * which contains the points drawn by the other client */ public void run () { while (true) { try { byte[] buffer = new byte[512]; DatagramPacket packet = new DatagramPacket(buffer, buffer.length); datasocket.receive(packet); InputStream in=new ByteArrayInputStream(packet.getData(), packet.getOffset(),packet.getLength()); DataInputStream din=new DataInputStream(in); int x=din.readInt(); int y=din.readInt(); String varname=din.readLine(); String var[]=varname.split("-",4); point=new Point(x,y); virtualboard.addPoint(point, var[0], var[1],var[2],var[3]); } catch (IOException ex) { ex.printStackTrace(); } } } //This function is to broadcast the newly drawn point to the server public void broadcast (Point p,String varname,String shape,String event, String color) { try { ByteArrayOutputStream baos=new ByteArrayOutputStream(); DataOutputStream dos=new DataOutputStream(baos); dos.writeInt(p.x); dos.writeInt(p.y); dos.writeBytes(varname); dos.writeBytes("-"); dos.writeBytes(shape); dos.writeBytes("-"); dos.writeBytes(event); dos.writeBytes("-"); dos.writeBytes(color); dos.close(); byte[]data=baos.toByteArray(); InetAddress ip=InetAddress.getByName("10.123.97.154"); DatagramPacket packet=new DatagramPacket(data, data.length,ip , 8002); datasocket.send(packet); } catch (Exception e) { e.printStackTrace(); } } //This function is to close the client's connection with the server public void close() { try { ByteArrayOutputStream baos=new ByteArrayOutputStream(); DataOutputStream dos=new DataOutputStream(baos); //This is to tell server that this is request to remove the client dos.writeChar('r'); dos.close(); byte[]data=baos.toByteArray(); //Server IP address InetAddress ip=InetAddress.getByName("10.123.97.154"); DatagramPacket packet=new DatagramPacket(data, data.length,ip , 8000); socket.send(packet); System.out.println("closed"); } catch(Exception e) { e.printStackTrace(); } } public static void main(String[] args) throws Exception { connect(); } } Whiteboard.java class Whiteboard extends JPanel implements MouseListener,MouseMotionListener,ActionListener,KeyListener { BufferedImage image; Boolean tooltip=false; int post; String shape; String selectedcolor="black"; Color color=Color.black; //Color color=Color.white; Point start; Point end; Point mp; Point tip; int keycode; String fillshape; Point fillstart=new Point(); Point fillend=new Point(); int noofside; Button r=new Button("rect"); Button rectangle=new Button("rect"); Button line=new Button("line"); Button roundrect=new Button("roundrect"); Button polygon=new Button("poly"); Button text=new Button("text"); JButton save=new JButton("Save"); Button elipse=new Button("elipse"); ImageIcon fillicon=new ImageIcon("images/fill.jpg"); JButton fill=new JButton(fillicon); ImageIcon erasericon=new ImageIcon("images/eraser.gif"); JButton erase=new JButton(erasericon); JButton[] colourbutton=new JButton[28]; String selected; Point label; String key=""; int ex,ey;//eraser DatagramSocket dataSocket; JButton button = new JButton("test"); Client client; Boolean first; int w,h; public Whiteboard(DatagramSocket dataSocket) { try { UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } setLayout(null); setOpaque(false); setBackground(new Color(237,237,237)); this.dataSocket=dataSocket; client=new Client(dataSocket); addKeyListener(this); addMouseListener(this); addMouseMotionListener(this); setBorder(BorderFactory.createLineBorder(Color.black)); } public void paintComponent(Graphics g) { try { super.paintComponent(g); g.drawImage(image, 0, 0, this); Graphics2D g2 = (Graphics2D)g; if(color!=null) g2.setPaint(color); if(start!=null && end!=null) { if(selected==("elipse")) g2.drawOval(start.x, start.y,(end.x-start.x),(end.y-start.y)); else if(selected==("rect")) g2.drawRect(start.x, start.y, (end.x-start.x),(end.y-start.y)); else if(selected==("rrect")) g2.drawRoundRect(start.x, start.y, (end.x-start.x),(end.y-start.y),11,11); else if(selected==("line")) g2.drawLine(start.x,start.y,end.x,end.y); else if(selected==("poly")) { g2.drawLine(start.x,start.y,end.x,end.y); client.broadcast(start, "start", "poly", "drag", selectedcolor); client.broadcast(end, "end", "poly", "drag", selectedcolor); } } if(tooltip==true) { System.out.println(selected); if(selected=="text") { g2.drawString("|", tip.x, tip.y-5); g2.drawString("Click to add text", tip.x+10, tip.y+23); g2.drawString("__", label.x+post, label.y); } if(selected=="erase") { g2.setPaint(new Color(237,237,237)); g2.fillRect(tip.x-10,tip.y-10,10,10); g2.setPaint(color); g2.drawRect(tip.x-10,tip.y-10,10,10); } } } catch(Exception e) {} } //Function to draw the shape on image public void draw() { Graphics2D g2 = (Graphics2D) image.createGraphics(); Font font=new Font("Times New Roman",Font.PLAIN,14); g2.setFont(font); g2.setPaint(color); if(start!=null && end!=null) { if(selected=="line") g2.drawLine(start.x, start.y, end.x, end.y); else if(selected=="elipse") g2.drawOval(start.x, start.y, (end.x-start.x),(end.y-start.y)); else if(selected=="rect") g2.drawRect(start.x, start.y, (end.x-start.x),(end.y-start.y)); else if(selected==("rrect")) g2.drawRoundRect(start.x, start.y, (end.x-start.x),(end.y-start.y),11,11); else if(selected==("poly")) { g2.drawLine(start.x,start.y,end.x,end.y); client.broadcast(start, "start", "poly", "release", selectedcolor); client.broadcast(end, "end", "poly", "release", selectedcolor); } fillstart=start; fillend=end; fillshape=selected; } if(selected!="poly") { start=null; end=null; } if(label!=null) { if(selected==("text")) { g2.drawString(key,label.x,label.y); client.broadcast(label, key, "text", "release", selectedcolor); } } repaint(); g2.dispose(); } //Function which provides the erase functionality public void erase() { Graphics2D pic=(Graphics2D) image.createGraphics(); Color erasecolor=new Color(237,237,237); pic.setPaint(erasecolor); if(start!=null) pic.fillRect(start.x-10, start.y-10, 10, 10); } //To set the size of the image public void setImage(BufferedImage image) { this.image = image; } //Function to add buttons into the panel, calling this function returns a panel public JPanel shapeButtons() { JPanel shape=new JPanel(); shape.setBackground(new Color(181, 197, 210)); shape.setLayout(new GridLayout(5,2,2,4)); shape.setBounds(0, 2, 74, 166); rectangle.addActionListener(this); rectangle.setToolTipText("Rectangle"); line.addActionListener( this); line.setToolTipText("Line"); erase.addActionListener(this); erase.setToolTipText("Eraser"); roundrect.addActionListener(this); roundrect.setToolTipText("Round edge Rectangle"); polygon.addActionListener(this); polygon.setToolTipText("Polygon"); text.addActionListener(this); text.setToolTipText("Text"); fill.addActionListener(this); fill.setToolTipText("Fill with colour"); elipse.addActionListener(this); elipse.setToolTipText("Elipse"); save.addActionListener(this); shape.add(elipse); shape.add(rectangle); shape.add(roundrect); shape.add(polygon); shape.add(line); shape.add(text); shape.add(fill); shape.add(erase); shape.add(save); return shape; } public JPanel colourButtons() { JPanel colourbox=new JPanel(); colourbox.setBackground(new Color(181, 197, 210)); colourbox.setLayout(new GridLayout(8,2,8,8)); colourbox.setBounds(0,323,70,140); //colourbox.add(empty); for(int i=0;i<16;i++) { colourbutton[i]=new JButton(); colourbox.add(colourbutton[i]); if(i==0) colourbutton[0].setBackground(Color.black); else if(i==1) colourbutton[1].setBackground(Color.white); else if(i==2) colourbutton[2].setBackground(Color.red); else if(i==3) colourbutton[3].setBackground(Color.orange); else if(i==4) colourbutton[4].setBackground(Color.blue); else if(i==5) colourbutton[5].setBackground(Color.green); else if(i==6) colourbutton[6].setBackground(Color.pink); else if(i==7) colourbutton[7].setBackground(Color.magenta); else if(i==8) colourbutton[8].setBackground(Color.cyan); else if(i==9) colourbutton[9].setBackground(Color.black); else if(i==10) colourbutton[10].setBackground(Color.yellow); else if(i==11) colourbutton[11].setBackground(new Color(131,168,43)); else if(i==12) colourbutton[12].setBackground(new Color(132,0,210)); else if(i==13) colourbutton[13].setBackground(new Color(193,17,92)); else if(i==14) colourbutton[14].setBackground(new Color(129,82,50)); else if(i==15) colourbutton[15].setBackground(new Color(64,128,128)); colourbutton[i].addActionListener(this); } return colourbox; } public void fill() { if(selected=="fill") { Graphics2D g2 = (Graphics2D) image.getGraphics(); g2.setPaint(color); System.out.println("Fill"); if(fillshape=="elipse") g2.fillOval(fillstart.x, fillstart.y, (fillend.x-fillstart.x),(fillend.y-fillstart.y)); else if(fillshape=="rect") g2.fillRect(fillstart.x, fillstart.y, (fillend.x-fillstart.x),(fillend.y-fillstart.y)); else if(fillshape==("rrect")) g2.fillRoundRect(fillstart.x, fillstart.y, (fillend.x-fillstart.x),(fillend.y-fillstart.y),11,11); // else if(fillshape==("poly")) // g2.drawPolygon(x,y,2); } repaint(); } //To save the image drawn public void save() { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(bos); JFileChooser fc = new JFileChooser(); fc.showSaveDialog(this); encoder.encode(image); byte[] jpgData = bos.toByteArray(); FileOutputStream fos = new FileOutputStream(fc.getSelectedFile()+".jpeg"); fos.write(jpgData); fos.close(); //add replce confirmation here } catch (IOException e) { System.out.println(e); } } public void mouseClicked(MouseEvent e) { } @Override public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent arg0) { } public void mousePressed(MouseEvent e) { if(selected=="line"||selected=="text") { start=e.getPoint(); client.broadcast(start,"start", selected,"press", selectedcolor); } else if(selected=="elipse"||selected=="rect"||selected=="rrect") mp = e.getPoint(); else if(selected=="poly") { if(first==true) { start=e.getPoint(); //client.broadcast(start,"start", selected,"press", selectedcolor); } else if(first==false) { end=e.getPoint(); repaint(); //client.broadcast(end,"end", selected,"press", selectedcolor); } } else if(selected=="erase") { start=e.getPoint(); erase(); } } public void mouseReleased(MouseEvent e) { if(selected=="text") { System.out.println("Reset"); key=""; post=0; label=new Point(); label=e.getPoint(); grabFocus(); } if(start!=null && end!=null) { if(selected=="line") { end=e.getPoint(); client.broadcast(end,"end", selected,"release", selectedcolor); draw(); } else if(selected=="elipse"||selected=="rect"||selected=="rrect") { end.x = Math.max(mp.x,e.getX()); end.y = Math.max(mp.y,e.getY()); client.broadcast(end,"end", selected,"release", selectedcolor); draw(); } else if(selected=="poly") { draw(); first=false; start=end; end=null; } } } public void mouseDragged(MouseEvent e) { if(end==null) end = new Point(); if(start==null) start = new Point(); if(selected=="line") { end=e.getPoint(); client.broadcast(end,"end", selected,"drag", selectedcolor); } else if(selected=="erase") { start=e.getPoint(); erase(); client.broadcast(start,"start", selected,"drag", selectedcolor); } else if(selected=="elipse"||selected=="rect"||selected=="rrect") { start.x = Math.min(mp.x,e.getX()); start.y = Math.min(mp.y,e.getY()); end.x = Math.max(mp.x,e.getX()); end.y = Math.max(mp.y,e.getY()); client.broadcast(start,"start", selected,"drag", selectedcolor); client.broadcast(end,"end", selected,"drag", selectedcolor); } else if(selected=="poly") end=e.getPoint(); System.out.println(tooltip); if(tooltip==true) { if(selected=="erase") { Graphics2D g2=(Graphics2D) getGraphics(); tip=e.getPoint(); g2.drawRect(tip.x-10,tip.y-10,10,10); } } repaint(); } public void mouseMoved(MouseEvent e) { if(selected=="text" ||selected=="erase") { tip=new Point(); tip=e.getPoint(); tooltip=true; repaint(); } } public void actionPerformed(ActionEvent e) { if(e.getSource()==elipse) selected="elipse"; else if(e.getSource()==line) selected="line"; else if(e.getSource()==rectangle) selected="rect"; else if(e.getSource()==erase) { selected="erase"; tooltip=true; System.out.println(selected); erase(); } else if(e.getSource()==roundrect) selected="rrect"; else if(e.getSource()==polygon) { selected="poly"; first=true; start=null; } else if(e.getSource()==text) { selected="text"; tooltip=true; } else if(e.getSource()==fill) { selected="fill"; fill(); } else if(e.getSource()==save) save(); if(e.getSource()==colourbutton[0]) { color=Color.black; selectedcolor="black"; } else if(e.getSource()==colourbutton[1]) { color=Color.white; selectedcolor="white"; } else if(e.getSource()==colourbutton[2]) { color=Color.red; selectedcolor="red"; } else if(e.getSource()==colourbutton[3]) { color=Color.orange; selectedcolor="orange"; } else if(e.getSource()==colourbutton[4]) { selectedcolor="blue"; color=Color.blue; } else if(e.getSource()==colourbutton[5]) { selectedcolor="green"; color=Color.green; } else if(e.getSource()==colourbutton[6]) { selectedcolor="pink"; color=Color.pink; } else if(e.getSource()==colourbutton[7]) { selectedcolor="magenta"; color=Color.magenta; } else if(e.getSource()==colourbutton[8]) { selectedcolor="cyan"; color=Color.cyan; } } @Override public void keyPressed(KeyEvent e) { //System.out.println(e.getKeyChar()+" : "+e.getKeyCode()); if(label!=null) { if(e.getKeyCode()==10) //Check for Enter key { label.y=label.y+14; key=""; post=0; repaint(); } else if(e.getKeyCode()==8) //Backspace { try{ Graphics2D g2 = (Graphics2D) image.getGraphics(); g2.setPaint(new Color(237,237,237)); g2.fillRect(label.x+post-7, label.y-13, 14, 17); if(post>0) post=post-6; keycode=0; key=key.substring(0, key.length()-1); System.out.println(key.substring(0, key.length())); repaint(); Point broadcastlabel=new Point(); broadcastlabel.x=label.x+post-7; broadcastlabel.y=label.y-13; client.broadcast(broadcastlabel, key, "text", "backspace", selectedcolor); } catch(Exception ex) {} } //Block invalid keys else if(!(e.getKeyCode()>=16 && e.getKeyCode()<=20 || e.getKeyCode()>=112 && e.getKeyCode()<=123 || e.getKeyCode()>=33 && e.getKeyCode()<=40 || e.getKeyCode()>=144 && e.getKeyCode()<=145 || e.getKeyCode()>=524 && e.getKeyCode()<=525 ||e.getKeyCode()==27||e.getKeyCode()==155 ||e.getKeyCode()==127)) { key=key+e.getKeyChar(); post=post+6; draw(); } } } @Override public void keyReleased(KeyEvent e) { } @Override public void keyTyped(KeyEvent e) { } } class Button extends JButton { String name; int i; public Button(String name) { this.name=name; try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception e) { e.printStackTrace(); } } public Button(int i) { this.i=i; } public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D)g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //g2.setStroke(new BasicStroke(1.2f)); if (name == "line") g.drawLine(5,5,30,30); if (name == "elipse") g.drawOval(5,7,25,20); if (name== "rect") g.drawRect(5,5,25,23); if (name== "roundrect") g.drawRoundRect(5,5,25,23,10,10); int a[]=new int[]{20,9,20,23,20}; int b[]=new int[]{9,23,25,20,9}; if (name== "poly") g.drawPolyline(a, b, 5); if (name== "text") g.drawString("Text",8, 24); } }

    Read the article

  • Quickly check Airtel Broadband usage details

    - by Gopinath
    If you are an Airtel India broadband user here is a quick tip to find out usage details. From your broadband connected device just visit Airtel’s web page and you’ll get  the usage statistics. The best part is the page displays statistics automatically, you don’t need to enter broadband connection details or login to Airtel website. It just works! The page displays your monthly data transfer limits, the amount of data transfer bandwidth that is available for the rest of the month and the number of days left in the month. This is a pretty useful tip to keep tabs on your broadband usage. Thanks Amit for the tip.

    Read the article

  • Installing Microsoft VX1000 webcam

    - by KRistian
    I found a tutorial with people saying it works; here are the instructions I followed. I opened a shell as root on my system and launched the following: wget http://linuxtv.org/hg/v4l-dvb/archive/tip.tar.gz tar zxvf tip.tar.gz cd v4l... (whatever the newly created directory name is) make all sudo make install Then I edited /etc/modprobe.d/blacklist-custom and added blacklist sn9c102. After reboot, I launched sudo gstreamer-properties. However when I type tar zxvf tip.tar.gz it displays: tar: You may not specify more than one `-Acdtrux' or `--test-label' option Try `tar --help' or `tar --usage' for more information. Why? How can I do this? Thanks in advance.

    Read the article

  • Moving a body in a specific direction using XNA with Farseer Physics

    - by Code Assasssin
    I have a custom polygon attached to a body, which looks like this: What I am trying to accomplish is getting the body to move according to wherever the tip of the body is. So far this is what I've tried: if (ks.IsKeyDown(Keys.Up)) { body.ApplyForce(new Vector2(0, -20),body.GetLocalPoint(new Vector2(0,0))); } if (ks.IsKeyDown(Keys.Left)) { body.ApplyTorque(-500); } if (ks.IsKeyDown(Keys.Right)) { body.ApplyTorque(500); } The body rotates fine - but when I try making the body accelerate according to the tip of the body - assuming I have specified the tip correctly(I am pretty sure I haven't), it just spins around, as if I have applied Torque to it. Can anyone point me in the right direction of how to fix this problem?

    Read the article

  • VS2010 Launch Presentations

    Last week I was in Vegas to present at the DevConnections / VS2010 Launch event.  The show was well-attended and everybody I spoke to agreed it was educational and enjoyable.  My three talks were all on Wednesday, 14 April 2010, including one at 8am for which I was impressed to see a large turnout in attendance.   Pragmatic ASP.NET Tips, Tricks, and Tools My first session was on tips, tricks, and tools for ASP.NET developers.  This is a talk Ive given in past years, but which I refine every time.  I usually like to have a full session to devote to tools, and a separate talk just for Tips and Tricks, but for this show I was only given the one 75-minute slot, so I had to cut some materials to make things fit.  The talk went well, all the demos work, and the attendees seemed to enjoy it, and I like giving it, so hopefully I can continue to present on this topic in future DevConnections shows. Download the ASP.NET Tips, Tricks, and Tools slides and demos.   Whats New in ASP.NET MVC 2 My second talk of the day followed immediately after the Tips and Tricks talk, and was a brand new talk for me.  I have to throw out a thank-you to Phil for letting me see his MIX slide deck before he gave his talk, as that was a big help.  The official whats new document online is also worth checking out if youre interested in this subject.  Download the Whats New in ASP.NET MVC 2 slides and demos.   SOLIDify Your ASP.NET MVC 2 Application Just because youre using a ASP.NET MVC doesnt mean your code cant still end up being a big ball of mud.  This session describes a number of principles of software design that can help ensure applications remain loosely-coupled and malleable even as they age and increase in features and complexity.  This was my last talk of the day and did have one minor demo failure involving a database constraint.  Ive given this talk many times before, and in this case I had to fit it into a 60-minute timeslot, so Im not sure I had quite enough time to drive home all of the concepts to everyone in the audience.  That said, I did hear a number of positive comments on how the talk went, so thats encouraging. Download the SOLIDify Your ASP.NET MVC 2 Application slides and demos.   In my sessions, I promised to have these posted by the end of the weekend theyre going up at 10pm Sunday night (my time) 2 hours to spare!  Enjoy! Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

< Previous Page | 48 49 50 51 52 53 54 55 56 57 58 59  | Next Page >