Search Results

Search found 1800 results on 72 pages for 'square eyes'.

Page 10/72 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Hover text at mouse created from firefox toolbar add-on

    - by c-square
    Hi all, I'm creating a firefox add-on, and I have a situation where if someone clicks on a specific item in my toolbarbutton menupopup, I want to display some text to appear beside the mouse for a couple seconds. I don't mean mouseover text, because when they click on the item, the I close the menupopup. I mean something like what's shown at this site: http://www.kingsquare.nl/cursormessage The normal way of doing this would be with javascript and a div that would have the text I want to show. Unfortunately, I've discovered that the toolbarbutton can't have an effect on the main window, which is where I'd need to place the div to show. I've tried getting JQuery to work and haven't been successful either. Any help would be greatly appreciated. Thanks!

    Read the article

  • The Importance of Quality Original Content For Your Website SEO

    Webmasters and SEO experts have been quite contradicting themselves, trying to weigh things over whether quality content does matter or if does not. There are a lot who always emphasize that quality content should be the top priority. Put content that is readable to both the human eyes as well as to the eyes of the search engines.

    Read the article

  • Web Content Helps SEO - 3 Super Easy Ways to Keep Your Website Fresh

    To keep your site up-to-date in the eyes of your visitors, as well as in the eyes of the search engines, you've got to look beyond "just getting the site up and live" in the first place. Search engines will eventually give up on sites that just never change in favor of those that continually make improvements and strive to provide their visitors with a fresh experience.

    Read the article

  • Working with Tile Notifications in Windows 8 Store Apps – Part I

    - by dwahlin
    One of the features that really makes Windows 8 apps stand out from others is the tile functionality on the start screen. While icons allow a user to start an application, tiles provide a more engaging way to engage the user and draw them into an application. Examples of “live” tiles on part of my current start screen are shown next: I’ll admit that if you get enough of these tiles going the start screen can actually be a bit distracting. Fortunately, a user can easily disable a live tile by right-clicking on it or pressing and holding a tile on a touch device and then selecting Turn live tile off from the AppBar: The can also make a wide tile smaller (into a square tile) or make a square tile bigger assuming the application supports both squares and rectangles. In this post I’ll walk through how to add tile notification functionality into an application. Both XAML/C# and HTML/JavaScript apps support live tiles and I’ll show the code for both options.   Understanding Tile Templates The first thing you need to know if you want to add custom tile functionality (live tiles) into your application is that there is a collection of tile templates available out-of-the-box. Each tile template has XML associated with it that you need to load, update with your custom data, and then feed into a tile update manager. By doing that you can control what shows in your app’s tile on the Windows 8 start screen. So how do you learn more about the different tile templates and their respective XML? Fortunately, Microsoft has a nice documentation page in the Windows 8 Store SDK. Visit http://msdn.microsoft.com/en-us/library/windows/apps/hh761491.aspx to see a complete list of square and wide/rectangular tile templates that you can use. Looking through the templates you’ll It has the following XML template associated with it:  <tile> <visual> <binding template="TileSquareBlock"> <text id="1">Text Field 1</text> <text id="2">Text Field 2</text> </binding> </visual> </tile> An example of a wide/rectangular tile template is shown next:    <tile> <visual> <binding template="TileWideImageAndText01"> <image id="1" src="image1.png" alt="alt text"/> <text id="1">Text Field 1</text> </binding> </visual> </tile>   To use these tile templates (or others you find interesting), update their content, and get them to show for your app’s tile on the Windows 8 start screen you’ll need to perform the following steps: Define the tile template to use in your app Load the tile template’s XML into memory Modify the children of the <binding> tag Feed the modified tile XML into a new TileNotification instance Feed the TileNotification instance into the Update() method of the TileUpdateManager In the remainder of the post I’ll walk through each of the steps listed above to provide wide and square tile notifications for an application. The wide tile that’s shown will show an image and text while the square tile will only show text. If you’re going to provide custom tile notifications it’s recommended that you provide wide and square tiles since users can switch between the two of them directly on the start screen. Note: When working with tile notifications it’s possible to manipulate and update a tile’s XML template without having to know XML parsing techniques. This can be accomplished using some C# notification extension classes that are available. In this post I’m going to focus on working with tile notifications using an XML parser so that the focus is on the steps required to add notifications to the Windows 8 start screen rather than on external extension classes. You can access the extension classes in the Windows 8 samples gallery if you’re interested.   Steps to Create Custom App Tile Notifications   Step 1: Define the tile template to use in your app Although you can cut-and-paste a tile template’s XML directly into your C# or HTML/JavaScript Windows store app and then parse it using an XML parser, it’s easier to use the built-in TileTemplateType enumeration from the Windows.UI.Notifications namespace. It provides direct access to the XML for the various templates so once you locate a template you like in the documentation (mentioned above), simplify reference it:HTML/JavaScript var notifications = Windows.UI.Notifications; var template = notifications.TileTemplateType.tileWideImageAndText01; .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }   XAML/C# var template = TileTemplateType.TileWideImageAndText01;   Step 2: Load the tile template’s XML into memory Once the target template’s XML is identified, load it into memory using the TileUpdateManager’s GetTemplateContent() method. This method parses the template XML and returns an XmlDocument object:   HTML/JavaScript   var tileXml = notifications.TileUpdateManager.getTemplateContent(template); .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }   XAML/C#  var tileXml = TileUpdateManager.GetTemplateContent(template);   Step 3: Modify the children of the <binding> tag Once the XML for a given template is loaded into memory you need to locate the appropriate <image> and/or <text> elements in the XML and update them with your app data. This can be done using standard XML DOM manipulation techniques. The example code below locates the image folder and loads the path to an image file located in the project into it’s inner text. The code also creates a square tile that consists of text, updates it’s <text> element, and then imports and appends it into the wide tile’s XML.   HTML/JavaScript var image = tileXml.selectSingleNode('//image[@id="1"]'); image.setAttribute('src', 'ms-appx:///images/' + imageFile); image.setAttribute('alt', 'Live Tile'); var squareTemplate = notifications.TileTemplateType.tileSquareText04; var squareTileXml = notifications.TileUpdateManager.getTemplateContent(squareTemplate); var squareTileTextAttributes = squareTileXml.selectSingleNode('//text[@id="1"]'); squareTileTextAttributes.appendChild(squareTileXml.createTextNode(content)); var node = tileXml.importNode(squareTileXml.selectSingleNode('//binding'), true); tileXml.selectSingleNode('//visual').appendChild(node); .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }   XAML/C#var tileXml = TileUpdateManager.GetTemplateContent(template); var text = tileXml.SelectSingleNode("//text[@id='1']"); text.AppendChild(tileXml.CreateTextNode(content)); var image = (XmlElement)tileXml.SelectSingleNode("//image[@id='1']"); image.SetAttribute("src", "ms-appx:///Assets/" + imageFile); image.SetAttribute("alt", "Live Tile"); Debug.WriteLine(image.GetXml()); var squareTemplate = TileTemplateType.TileSquareText04; var squareTileXml = TileUpdateManager.GetTemplateContent(squareTemplate); var squareTileTextAttributes = squareTileXml.SelectSingleNode("//text[@id='1']"); squareTileTextAttributes.AppendChild(squareTileXml.CreateTextNode(content)); var node = tileXml.ImportNode(squareTileXml.SelectSingleNode("//binding"), true); tileXml.SelectSingleNode("//visual").AppendChild(node);  Step 4: Feed the modified tile XML into a new TileNotification instance Now that the XML data has been updated with the desired text and images, it’s time to load the XmlDocument object into a new TileNotification instance:   HTML/JavaScript var tileNotification = new notifications.TileNotification(tileXml); .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }   XAML/C#var tileNotification = new TileNotification(tileXml);  Step 5: Feed the TileNotification instance into the Update() method of the TileUpdateManager Once the TileNotification instance has been created and the XmlDocument has been passed to its constructor, it needs to be passed to the Update() method of a TileUpdator in order to be shown on the Windows 8 start screen:   HTML/JavaScript notifications.TileUpdateManager.createTileUpdaterForApplication().update(tileNotification); .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }   XAML/C#TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);    Once the tile notification is updated it’ll show up on the start screen. An example of the wide and square tiles created with the included demo code are shown next:     Download the HTML/JavaScript and XAML/C# sample application here. In the next post in this series I’ll walk through how to queue multiple tiles and clear a queue.

    Read the article

  • C# - closures over class fields inside an initializer?

    - by Richard Berg
    Consider the following code: using System; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { var square = new Square(4); Console.WriteLine(square.Calculate()); } } class MathOp { protected MathOp(Func<int> calc) { _calc = calc; } public int Calculate() { return _calc(); } private Func<int> _calc; } class Square : MathOp { public Square(int operand) : base(() => _operand * _operand) // runtime exception { _operand = operand; } private int _operand; } } (ignore the class design; I'm not actually writing a calculator! this code merely represents a minimal repro for a much bigger problem that took awhile to narrow down) I would expect it to either: print "16", OR throw a compile time error if closing over a member field is not allowed in this scenario Instead I get a nonsensical exception thrown at the indicated line. On the 3.0 CLR it's a NullReferenceException; on the Silverlight CLR it's the infamous Operation could destabilize the runtime.

    Read the article

  • jQuery animate() and appendTo() problem

    - by Devyn
    Hi! I'm doing a chess game. In there, I want to move an element with effect and then append it to new div. Following is my code. //--> #p70 is just ablove #p80 //--> each square is 64px $('#p80').animate({bottom:'+=64px'},500); //--> move one square above $('#b70').append($('#p80')); //--> append the animated element to owner 'div' The problem is, it moves 2 square( equivalent to 128px) where I only did is 64px. Here is my page and if you click the white square just above the pawn, you'll see the problem. I've tried adding delay(1000) and even javascript setTimeout but nothing works :( Really appreciate your helps in advance!

    Read the article

  • Serialization problem

    - by Falcon eyes
    Hi Every body I have a problem and want help. I have created a phonebook application and it works fine after a awhile i liked to make an upgrade for my application and i started from scratch i didn't inherit it from my old class,and i successes too ,my request "I want to migrate my contacts from the old application to the new one" ,so i made an adapter class for this reason in my new application with the following code using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Windows.Forms; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; namespace PhoneBook { class Adapter { PhoneRecord PhRecord; //the new application object CTeleRecord TelRecord; //the old application object string fileName; public Adapter(string filename) { fileName = filename; } public void convert() { PhRecord = new PhoneRecord(); TelRecord = new CTeleRecord(); FileStream OpFileSt = new FileStream(fileName, FileMode.Open,FileAccess.Read); BinaryFormatter readBin = new BinaryFormatter(); for (; ; ) { try { TelRecord.ResetTheObject(); TelRecord = (CTeleRecord)readBin.Deserialize(OpFileSt); PhRecord.SetName = TelRecord.GetName; PhRecord.SetHomeNumber = TelRecord.GetHomeNumber; PhRecord.SetMobileNumber = TelRecord.GetMobileNumber; PhRecord.SetWorkNumber = TelRecord.GetWorkNumber; PhRecord.SetSpecialNumber = TelRecord.GetSpecialNumber; PhRecord.SetEmail = TelRecord.GetEmail; PhRecord.SetNotes = TelRecord.GetNotes; PhBookContainer.phBookItems.Add(PhRecord); } catch (IOException xxx) { MessageBox.Show(xxx.Message); } catch (ArgumentException tt) { MessageBox.Show(tt.Message); } //if end of file is reached catch (SerializationException x) { MessageBox.Show(x.Message + x.Source); break; } } OpFileSt.Close(); PhBookContainer.Save(@"d:\MyPhBook.pbf"); } } } the problem is when i try to read the file ctreated by my old application i receive serialization exception with this message "Unabel to find assembly 'PhoneBook,Version=1.0.0.0,Culture=neutral,PublicK eyToken=null" and the source of exceptionis mscorlib. when i read the same file with my old application(Which is the origin of the file)i have no problem and idon't know what to do to make my adapter class work.so can somebody help please.

    Read the article

  • Calculating bounding box a certain distance away from a lat/long coordinate in Java

    - by Bryce Thomas
    Given a coordinate (lat, long), I am trying to calculate a square bounding box that is a given distance (e.g. 50km) away from the coordinate. So as input I have lat, long and distance and as output I would like two coordinates; one being the south-west (bottom-left) corner and one being the north-east (top-right) corner. I have seen a couple of answers on here that try to address this question in Python, but I am looking for a Java implementation in particular. Just to be clear, I intend on using the algorithm on Earth only and so I don't need to accommodate a variable radius. It doesn't have to be hugely accurate (+/-20% is fine) and it'll only be used to calculate bounding boxes over small distances (no more than 150km). So I'm happy to sacrifice some accuracy for an efficient algorithm. Any help is much appreciated. Edit: I should have been clearer, I really am after a square, not a circle. I understand that the distance between the center of a square and various points along the square's perimeter is not a constant value like it is with a circle. I guess what I mean is a square where if you draw a line from the center to any one of the four points on the perimeter that results in a line perpendicular to a side of the perimeter, then those 4 lines have the same length.

    Read the article

  • SOLID Liskov Substitution Principle

    - by Omu
    if i have something like class square : figure {} class triangle : figure {} does that mean that i should never ever use the square and triangle classes but only refer to figure ? like never do like this: var x = new square();

    Read the article

  • Fermat factorization method limit

    - by Fakrudeen
    I am trying to implement Fermat's factorization [Algorithm C in Art of computer programming Vol. 2]. Unfortunately in my edition [ISBN 81-7758-335-2], this algorithm is printed incorrectly. what should be the condition on factor-inner loop below? I am running the loop till y <= n [passed in as limit]. (if (< limit y) 0 (factor-inner x (+ y 2) (- r y) limit)) Is there anyway to avoid this condition altogether, as it will double the speed of loop? (define (factor n) (let ( ( square-root (inexact->exact (floor (sqrt n))) ) ) (factor-inner (+ (* 2 square-root) 1) 1 (- (* square-root square-root) n) n) ) ) (define (factor-inner x y r limit) (if (= r 0) (/ (- x y) 2) (begin (display x)(display " ")(display y)(display " ")(display r)(newline) ;(sleep-current-thread 1) (if (< r 0) (factor-inner (+ x 2) y (+ r x) limit) (if (< limit y) 0 (factor-inner x (+ y 2) (- r y) limit)) ) ) ) )

    Read the article

  • Java Graphics on java, 2d array board game.

    - by FILIaS
    I wanna fix a 2D board for a game. I've already fixed other panels for the gui and everything goes well. But the panel for the board cant be printed on the window. I'm a bit confused about it as i think i've followed the same ideas as for the others panels i need. Here's what i've done: /** *Method used to construct the square in the area of the *gui's grid. In this stage a GUISquare array is being constructed, * used in the whole game as *a mean of changing a square graphical state. *@param squares is the squares array from whom the gui grid will be *constructed. *@see getSquare about the correspondance beetween a squareModel and * a GUISquare. */ private void initBoardPanel(SquareModel[][] squares){ BoardPanel.setLayout(new GridLayout(myGame.getHeight(),myGame.getWidth())); //set layout Squares=new GUISquare[myGame.getHeight()][myGame.getWidth()]; grid=new JPanel[myGame.getHeight()][myGame.getWidth()]; for (int i=0; i< myGame.getHeight(); i++){ for (int j=0; j<myGame.getWidth() ; j++){ grid[i][j] = new JPanel( ); GUISquare kout=new GUISquare(i,j); kout.setSquare(myGame.getSquares()[i][j]); kout.draw(myGame.getSquares()[i][j].getGoTo(),myGame.getSquares()[i][j].getNumber()); /*draw method is been called. the first parameter is the number of the square that the player will be moved to if lands in this one square,the second parameter is just the number of the square */ kout.setVisible(true); grid[i][j].add(kout); grid[i][j].setVisible(true); BoardPanel.add(grid[i][j]); BoardPanel.setVisible(true); BoardPanel.setBackground(Color.WHITE); GUISquare temp=this.getSquare(squares[i][i]); Squares[i][j]= temp; } } this.add(BoardPanel,BorderLayout.WEST); // this.pack(); //sets appropriate size for frame this.setVisible(true); //makes frame visible } /** * Transformer for Rand/Move * <br>This method is used to display a square on the screen. */ public void draw(int goTo ,int number) { JPanel panel = new JPanel(); JLabel label1 = new JLabel(""+"Move To"+goTo); JLabel label2 = new JLabel(""+number); JSeparator CellSeparator = new JSeparator(orientation); panel.add(CellSeparator); panel.setLayout(new BorderLayout()); panel.add(label1, BorderLayout.CENTER); panel.add(label2, BorderLayout.LINE_START); } I've posted only one draw method...but all versions are alike.

    Read the article

  • jquery hover menu question

    - by vondip
    Hi all, I am developing a small web app that uses jquery quite a lot. In my app a user can hover an image, which becomes bigger after a few seconds, giving him more details. The problem is that when the image enlarges the image, it takes over the area of the nearby images as well. Now, if the user goes over the second red square (numbered as 2) I would like the currently enlarged image to disappear and instead enlarge the image pictured below as square two. I am not much of a painter, but I have attached a small image to help illustrate the problem. In short, How can I tell jquery to detect when the mouse is over red square number two, yet not raising the event if the mouse is over green square. [in my demo picture, hovering on point]

    Read the article

  • C# wrapper for objects

    - by Haggai
    I'm looking for a way to create a generic wrapper for any object. The wrapper object will behave just like the class it wraps, but will be able to have more properties, variable, methods etc., for e.g. object counting, caching etc. Say the wrapper class be called Wrapper, and the class to be wrapped be called Square and has the constructor Square(double edge_len) and the properties/methods EdgeLength and Area, I would like to use it as follows: Wrapper<Square> mySquare = new Wrapper<Square>(2.5); /* or */ new Square(2.5); Console.Write("Edge {0} -> Area {1}", mySquare.EdgeLength, mySquare.Area); Obviously I can create such a wrapper class for each class I want to wrap, but I'm looking for a general solution, i.e. Wrapper<T> which can handle both primitive and compound types (although in my current situation I would be happy with just wrapping my own classes). Suggestions? Thanks.

    Read the article

  • Problem with mouse event on a user control (wpf).

    - by csciguy
    All, I have a user control, defined as follows. <UserControl x:Class="IDOView.AnimatedCharacter" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:IDOView" mc:Ignorable="d" Background="Transparent" > <Image Name="displayImage" Height="Auto" Width="Auto" Stretch="Fill" IsHitTestVisible="True"/> The control is added to a main page twice, as follows. <local:customControl x:Name="A1" Height="259" Width="197" DisplayImage="circle.png" Canvas.Left="-279" Canvas.Top="-56" MouseLeftButtonUp="DoA1"> <local:customControl x:Name="A1" Height="259" Width="197" DisplayImage="square.png" Canvas.Left="-209" Canvas.Top="-56" MouseLeftButtonUp="DoA2"> Essentially, about half of the circle is behind the square. I need the square image in this case to pass through events to the circle behind it. The square has an element cut out of it (transparent). What is happening now is that the circle event only registers if I click on the region that is not covered by the square. Surely there has to be a way to bubble this event, or click-through?

    Read the article

  • Beginner += in Ruby

    - by WANNABE
    Looking at this block, I can follow the whole program until I hit, sum += square. What is he point of this line, what does it say??? sum = 0 [1, 2, 3, 4].each do |value| square = value * value sum += square end puts sum

    Read the article

  • iPhone OpenGL Template is cheating?

    - by carrots
    XCode's OpenGL template seems to be cheating to solve this "stretched" viewport problem I've been trying to understand for the last 3 hours. In the iphone "OpenGL ES Application" template, the colorful square that bounces up and down on the screen is not really a square at all! ES1Renderer.m (the ES2 file as well) static const GLfloat squareVertices[] = { -0.5f, -0.33f, 0.5f, -0.33f, -0.5f, 0.33f, 0.5f, 0.33f, }; But it comes out looking square on the device/simulator due to the stretching/squashing effect of a non-square viewport. I tried to fix it by fiddling with glFrustumf() but that doesn't seem to change the aspect ratio. I was able to get things looking good (not-stretched) when I fed glViewport() with a 1:1 widht:height.. But this doesn't seem like the answer because it offsets the viewport placement. What's the right way to correct for this stretching and why doesn't XCode do it that way?

    Read the article

  • Is there a programming language with be semantics close to English ?

    - by ivo s
    Most languages allow to 'tweek' to certain extend parts of the syntax (C++,C#) and/or semantics that you will be using in your code (Katahdin, lua). But I have not heard of a language that can just completely define how your code will look like. So isn't there some language which already exists that has such capabilities to override all syntax & define semantics ? Example of what I want to do is basically from the C# code below: foreach(Fruit fruit in Fruits) { if(fruit is Apple) { fruit.Price = fruit.Price/2; } } I want do be able to to write the above code in my perfect language like this: Check if any fruits are Macintosh apples and discount the price by 50%. The advantages that come to my mind looking from a coder's perspective in this "imaginary" language are: It's very clear what is going on (self descriptive) - it's plain English after all even kid would understand my program Hides all complexities which I have to write in C#. But why should I care to learn that if statements, arithmetic operators etc since there are already implemented The disadvantages that I see for a coder who will maintain this program are: Maybe you would express this program differently from me so you may not get all the information that I've expressed in my sentence Programs can be quite verbose and hard to debug but if possible to even proximate this type of syntax above maybe more people would start programming right? That would be amazing I think. I can go to work and just write an essay to draw a square on a winform like this: Create a form called MyGreetingForm. Draw a square with in the middle of MyGreetingFormwith a side of 100 points. In the middle of the square write "Hello! Click here to continue" in Arial font. In the above code the parser must basically guess that I want to use the unnamed square from the previous sentence, it'd be hard to write such a smart parser I guess, yet it's so simple what I want to do. If the user clicks on square in the middle of MyGreetingForm show MyMainForm. In the above code 'basically' the compiler must: 1)generate an event handler 2) check if there is any square in the middle of the form and if there is - 3) hide the form and show another form It looks very hard to do but it doesn't look impossible IMO to me at least approximate this (I can personally generate a parser to perform the 3 steps above np & it's basically the same that it has to do any way when you add even in c# a.MyEvent=+handler; so I don't see a problem here) so I'm thinking maybe somebody already did something like this ? Or is there some practical burden of complexity to create such a 'essay style' programming language which I can't see ? I mean what's the worse that can happen if the parser is not that good? - your program will crash so you have to re-word it:)

    Read the article

  • How to define 2-bit numbers in C, if possible?

    - by Eddy
    For my university process I'm simulating a process called random sequential adsorption. One of the things I have to do involves randomly depositing squares (which cannot overlap) onto a lattice until there is no more room left, repeating the process several times in order to find the average 'jamming' coverage %. Basically I'm performing operations on a large array of integers, of which 3 possible values exist: 0, 1 and 2. The sites marked with '0' are empty, the sites marked with '1' are full. Initially the array is defined like this: int i, j; int n = 1000000000; int array[n][n]; for(j = 0; j < n; j++) { for(i = 0; i < n; i++) { array[i][j] = 0; } } Say I want to deposit 5*5 squares randomly on the array (that cannot overlap), so that the squares are represented by '1's. This would be done by choosing the x and y coordinates randomly and then creating a 5*5 square of '1's with the topleft point of the square starting at that point. I would then mark sites near the square as '2's. These represent the sites that are unavailable since depositing a square at those sites would cause it to overlap an existing square. This process would continue until there is no more room left to deposit squares on the array (basically, no more '0's left on the array) Anyway, to the point. I would like to make this process as efficient as possible, by using bitwise operations. This would be easy if I didn't have to mark sites near the squares. I was wondering whether creating a 2-bit number would be possible, so that I can account for the sites marked with '2'. Sorry if this sounds really complicated, I just wanted to explain why I want to do this.

    Read the article

  • Haskell "Source reduction"

    - by Martin
    I'm revising for an upcoming Haskell exam and I don't understand one of the questions on a past paper. Google turns up nothing useful fst(x, y) = x square i = i * i i) Source reduce, using Haskells lazy evaluation, the expression: fst(square(3+4), square 8) ii) Source reduce, using strict evaluation, the same expression iii) State one advantage of lazy evaluation and one advantage of strict evaluation

    Read the article

  • Multiple Monitors

    - by mroberts
    At my workplace .Net developers get pretty much the same equipment. A decent Dell workstation / Desktop, mine is a Dell Precision 390. One dual core 2.40 GHz. Eight GB RAM. Windows 7 Enterprise 64-bit. Two Dell 20.1 Monitors. I'm happy with this.  The machine is about 3 years old but still runs with some decent speed. New developers are getting a Dell workstation with dual quad processors. I just put in a request for myself and three other developers for an upgraded video card and two additional monitors, for a total of four monitors per person.  We suggested this card, BTW, mainly for the cost.  The move from one monitor to two was fantastic (one might even say life (or work) changing) and truly did increase productivity. Now what about going from 2 monitors to 4?  I'm sure the change is not as dramatic as one to two, but I can't help but to think four monitors is better than two.  But if four is better than two, should we have asked for six?!? Also what about mixing monitor types?  Right now my monitors are the older square type vs. wide-screen.  It's been rumored that we will be getting monitors out of current stock and they will be 22 inch wide-screens.  I understand this, recession and all.  2-20 inch square monitors with 2-22 inch wide-screen monitors...hmmmmm.  I'm thinking I'd rather get 2 additional 17 inch square monitors to put on each side of my 20's. Also, a question was raised about the layout of four monitors. By default, my thought was I'll just put them all on my desk, kinda in a line. I've heard others say they want to stack them in a 2 x 2 square. BTW, loving multi monitor support in Visual studio 2010! I’d love some comments on your experience with one, two, four, or however many monitors from a developers perspective.

    Read the article

  • Warp GameObject Size When Entering/Leaving Area

    - by Julian
    Below I have an image describing the desired functionality I am going for. Let's say you control a square and when you move this square into a given area, any part of your rigidbody/model inside of the area will be magnified upon entering and shrunk upon leaving. So now you more or less are made up of two rectangles, one small and one large. What would be an elegant approach towards achieving this effect?

    Read the article

  • How to represent a Board Panel in Java for a game ? [+code]

    - by FILIaS
    I wanna fix a 2D board for a game. I've already fixed other panels for the Gui and everything goes well. But the panel for the board cant be printed on the window. I'm a bit confused about it as i think i've followed the same ideas as for the others panels i need. Here's what i've done: EDIT:*EDIT* what i'm trying to do is fix a board panel for the game according to the dimensions of the it,hold every square in an array in order to use it after wherever it;s needed. I draw each little square of it with the method draw and put it back to the panel. So, each square on the board is a panel. This is the idea. But as u can see. There are troubles/errors on it. EDIT: code updated. just found a part of the problem. i thought first that i had set background to squared, but i didnt. with this one it appears on the panel a wide black "column". Unfortunately,still none squares. :( One More EDIT: Also,i realized that draw method is never called. when i put the draw method in the following method i can see the squares but they remain small. I redefine them with setSize but still no change. /** *Method used to construct the square in the area of the *gui's grid. In this stage a GUISquare array is being constructed, * used in the whole game as *a mean of changing a square graphical state. *@param squares is the squares array from whom the gui grid will be *constructed. *@see getSquare about the correspondance beetween a squareModel and * a GUISquare. */ private void initBoardPanel(SquareModel[][] squares){ BoardPanel.setLayout(new GridLayout(height ,width )); //set layout SquareRenderer[][] Squares; JPanel[][] grid; Squares=new GUISquare[height][width()]; grid=new JPanel[height()][width()]; for (int i=0; i<height(); i++){ for (int j=0; j<width() ; j++){ grid[i][j] = new JPanel( ); SquareRenderer kout=new SquareRenderer(i,j); koutaki.setSquare(myGame.getSquares()[i][j]); if (myGame.getSquares()[i][j] instanceof SimpleSquareModel){ kout.draw(i,j,"");} else { kout.draw(i,j); } kout.setVisible(true); kout.setBackground(Color.BLACK); kout.setSize(50,50); Squares[i][j]= kout; grid[i][j].setSize(50,50); grid[i][j].setVisible(true); grid[i][j].setBackground(Color.BLACK); BoardPanel.add(kout); BoardPanel.setVisible(true); BoardPanel.setBackground(Color.WHITE); } } this.add(BoardPanel,BorderLayout.WEST); // this.pack(); //sets appropriate size for frame this.setVisible(true); //makes frame visible } IMPLEMENTED BY SQUARERENDERER: /** * Transformer for Snake/Ladder * <br>This method is used to display a square on the screen. */ public void draw(int i,int j) { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); JLabel label1 = new JLabel("Move To"+myGame.getSquares()[i][j].getGoTo()); JLabel label2 = new JLabel(""+myGame.getSquares()[i][j].getSquare()); JSeparator CellSeparator = new JSeparator(orientation); panel.add(CellSeparator); panel.setForeground(Color.ORANGE); panel.add(label2, BorderLayout.NORTH); panel.add(label1, BorderLayout.CENTER); }

    Read the article

  • Not sure why I'm getting a NullPointerException when creating a Swing component

    - by Alex
    The error occurs when creating the Box object. public void drawBoard(Board board){ for(int row = 0; row < 8; row++){ for(int col = 0; col < 8; col++){ Box box = new Box(board.getSquare(col, row).getColour(), col, row); squarePanel[col][row].add(box); } } Board is given from the Game constructor here (another class): public Game() throws Throwable{ View graphics = new View(); board = new Board(); board.setDefault(); graphics.drawBoard(board); } The Board constructor looks like this: public Board(){ grid = new Square[COLUMNS][ROWS]; for(int row = 0; row < 8; row++){ for(int col = 0; col < 8; col++){ grid[col][row] = new Square(this); } } for(int row = 0; row < 8; row++){ for(int col = 0; col < 4; col++){ int odd = 2*col + 1; int even = 2*col; getSquare(odd, row).setColour(Color.BLACK); getSquare(even, row).setColour(Color.WHITE); } } } And finally the Box class: class Box extends JComponent{ Color boxColour; int col, row; public Box(Color boxColour, int col, int row){ this.boxColour = boxColour; this.col = col; this.row = row; repaint(); } public void paint(Graphics drawBox){ drawBox.setColor(boxColour); drawBox.drawRect(50*col, 50*row, 50, 50); drawBox.fillRect(50*col, 50*row, 50, 50); } } So while looping through the array, it uses the two integers as coordinates to create the Box. The coordinates are referenced and then repaint() is run. The box also gets the colour, using the two integers, from the Square in the Board class. Since the colour is already set, before the drawBoard(board) method is run, that shouldn't be a problem, right? Exception in thread "main" java.lang.NullPointerException at View.drawBoard(View.java:38) at Game.<init>(Game.java:21) at Game.main(Game.java:14) The relevant part of Square import java.awt.Color; public class Square { private Piece piece; private Board board; private Color squareColour; public Square(Board board){ this.board = board; } public void setColour(Color squareColour){ this.squareColour = squareColour; } public Color getColour(){ return squareColour; }

    Read the article

  • Is white the best base color to start with when planning to shade sprites within Unity?

    - by SpartanDonut
    I'm looking into prototyping a game in Unity which will consist of solid square sprites / tiles. I figure I can represent different types of objects with different colors for each of the tiles in the game. I figure that I can import a single square sprite and shade it appropriately in Unity as opposed to imported squares of many different colors. My experience with adjusting the hue and saturation within Photoshop shows that white is not an easy color to change as things that are white often stay white. My testing in Unity shows that I can change the "color" of a sprite to anything other than white and the sprite is seemingly shaded appropriately, despite what I would have thought given my Photoshop experience. Since white objects do seem to take on the appropriate color shading when changed within Unity my gut tells me that this is the best base color to begin with, meaning that I can import a single white square sprite and simply adjust the color to represent different objects and object states. Is a white sprite actually the best color sprite to begin with and why does something like this work in Unity as opposed to adjusting the hue and saturation within Photoshop?

    Read the article

  • SDL_DisplayFormat works, but not SDL_DisplayFormatAlpha

    - by Bounderby
    The following code is intended to display a green square on a black background. It executes, but the green square does not show up. However, if I change SDL_DisplayFormatAlpha to SDL_DisplayFormat the square is rendered correctly. So what don't I understand? It seems to me that I am creating *surface with an alpha mask and I am using SDL_MapRGBA to map my green color, so it would be consistent to use SDL_DisplayFormatAlpha as well. (I removed error-checking for clarity, but none of the SDL API calls fail in this example.) #include <SDL.h> int main(int argc, const char *argv[]) { SDL_Init( SDL_INIT_EVERYTHING ); SDL_Surface *screen = SDL_SetVideoMode( 640, 480, 32, SDL_HWSURFACE | SDL_DOUBLEBUF ); SDL_Surface *temp = SDL_CreateRGBSurface( SDL_HWSURFACE, 100, 100, 32, 0, 0, 0, ( SDL_BYTEORDER == SDL_BIG_ENDIAN ? 0x000000ff : 0xff000000 ) ); SDL_Surface *surface = SDL_DisplayFormatAlpha( temp ); SDL_FreeSurface( temp ); SDL_FillRect( surface, &surface->clip_rect, SDL_MapRGBA( screen->format, 0x00, 0xff, 0x00, 0xff ) ); SDL_Rect r; r.x = 50; r.y = 50; SDL_BlitSurface( surface, NULL, screen, &r ); SDL_Flip( screen ); SDL_Delay( 1000 ); SDL_Quit(); return 0; }

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >