Search Results

Search found 399 results on 16 pages for 'kerrek sb'.

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

  • Can't write text into textbox in ASP.NET web app

    - by dotnetdev
    Hi, I have an ASP.NET web application. In the codebehind for the .ascx page (which I embed as below), I attempt to write a string to a textbox in a method like this: Code for embedding control: Control ctrl = Page.LoadControl("/RackRecable.ascx"); PlaceHolder1.Controls.Add(ctrl); Method to make string for inserting into textbox: string AppendDetails() { StringBuilder sb = new StringBuilder(); sb.Append("msg" + " " + textbox1.Text etc etc ); return sb.ToString(); } Called as (in codebehind event handler for button click): this.TextBox4.Text = AppendDetails(); I call it by using ATextBox.Text = AppendDetails (in the button click event handler). The textbox TextBox4 is in the designer file so I am confused why the text does not get written into this textbox (it is readonly and enabled). When stepping through, the textbox4 control will successfully show the text I want it to display in quick watch but not in the actual page, it won't. Any ideas? Thanks

    Read the article

  • How can i add an image in html email from lotus domino agent?

    - by mike_x_
    i want to add a simple image into an email which i want to send from a lotus agent. I paste below a part of the code: StringBuilder sb = new StringBuilder(); sb.append("<div><img src=\"http://goo.gl/lziMZN\"></div>"); email.setHTMLPart(sb.toString()); email.send("[email protected]"); I also tried to use an image from my image resources in the nsf. Whatever i tried i get an empty image area (browser-no-image icon) in the email i receive. I also have checked "Allow restricted operations" in my agent. I would prefer it if there is a solution to use an image from my resources and not an external link. Any solutions?

    Read the article

  • Most efficient way to remove special characters from string

    - by ObiWanKenobi
    I want to remove all special characters from a string. Allowed characters are A-Z (uppercase or lowercase), numbers (0-9), underscore (_), or the dot sign (.). I have the following, it works but I suspect (I know!) it's not very efficient: public static string RemoveSpecialCharacters(string str) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < str.Length; i++) { if ((str[i] >= '0' && str[i] <= '9') || (str[i] >= 'A' && str[i] <= 'z' || (str[i] == '.' || str[i] == '_'))) sb.Append(str[i]); } return sb.ToString(); } What is the most efficient way to do this? What would a regular expression look like, and how does it compare with normal string manipulation? The strings that will be cleaned will be rather short, usually between 10 and 30 characters in length.

    Read the article

  • Parsing XHTML results from Bing

    - by Nir
    Hello, i am trying to parse received search queries from bing search engines which are received in xhtml in java. I am using sax XmlReader to read the results but i keep on getting errors. here is my code-this one is for the hadler of the reader: import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; public class XHTMLHandler extends DefaultHandler{ public XHTMLHandler() { super(); } public void startDocument () { System.out.println("Start document"); } public void endDocument () { System.out.println("End document"); } public void startElement (String uri, String name,String qName, Attributes atts) { if ("".equals (uri)) System.out.println("Start element: " + qName); else System.out.println("Start element: {" + uri + "}" + name); } public void endElement (String uri, String name, String qName) { if ("".equals (uri)) System.out.println("End element: " + qName); else System.out.println("End element: {" + uri + "}" + name); } public void startPrefixMapping (String prefix, String uri) throws SAXException { } public void endPrefixMapping (String prefix) throws SAXException { } public void characters (char ch[], int start, int length) { System.out.print("Characters: \""); for (int i = start; i < start + length; i++) { switch (ch[i]) { case '\\': System.out.print("\\\\"); break; case '"': System.out.print("\\\""); break; case '\n': System.out.print("\\n"); break; case '\r': System.out.print("\\r"); break; case '\t': System.out.print("\\t"); break; default: System.out.print(ch[i]); break; } } System.out.print("\"\n"); } } and this is the program itself: import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.HttpRetryException; import java.net.HttpURLConnection; import java.net.URL; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.XMLReaderFactory; public class Searching { private String m_urlBingSearch = "http://www.bing.com/search?q="; private HttpURLConnection m_httpCon; private OutputStreamWriter m_streamWriter; //private BufferedReader m_bufferReader; private URL m_serverAdress; private StringBuilder sb; private String m_line; private InputSource m_inputSrc; public Searching() { m_httpCon = null; m_streamWriter = null; //m_bufferReader = null; m_serverAdress = null; sb = null; m_line = new String(); } public void SearchBing(String searchPrms) throws SAXException,IOException { //set up connection sb = new StringBuilder(); sb.append(m_urlBingSearch); sb.append(searchPrms); m_serverAdress = new URL(sb.toString()); m_httpCon = (HttpURLConnection)m_serverAdress.openConnection(); m_httpCon.setRequestMethod("GET"); m_httpCon.setDoOutput(true); m_httpCon.setConnectTimeout(10000); m_httpCon.connect(); //m_streamWriter = new OutputStreamWriter(m_httpCon.getOutputStream()); //m_bufferReader = new BufferedReader(new InputStreamReader(m_httpCon.getInputStream())); XMLReader reader = XMLReaderFactory.createXMLReader(); XHTMLHandler handle = new XHTMLHandler(); reader.setContentHandler(handle); reader.setErrorHandler(handle); //reader.startPrefixMapping("html", "http://www.w3.org/1999/xhtml"); handle.startPrefixMapping("html", "http://www.w3.org/1999/xhtml"); m_inputSrc = new InputSource(m_httpCon.getInputStream()); reader.parse(m_inputSrc); m_httpCon.disconnect(); } public static void main(String [] args) throws SAXException,IOException { Searching s = new Searching(); s.SearchBing("beatles"); } } this is my error message: Exception in thread "main" java.io.IOException: Server returned HTTP response code: 503 for URL: http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source) at Searching.SearchBing(Searching.java:57) at Searching.main(Searching.java:65) can someone please help? i think it has something to do with dtd but i don't know hot to fix it

    Read the article

  • Multiple fields from LINQ to Text Box

    - by Chuki2
    how can I pass value from selected field (LINQ) to textbox in winforms? If single fields, I just do like this var result = from row in dtValueBranch.AsEnumerable() where row.Field<int>("branchID") == idBranch select row.Field<string>("branchName"); StringBuilder sb = new StringBuilder(); foreach (string s in result) { sb.Append(s + Environment.NewLine); } tbBranch.Text = sb.ToString(); So this is the code LINQ to many fields var result = from row in dtValueBranch.AsEnumerable() where row.Field<int>("branchID") == idBranch select new { BranchName = row["branchName"].ToString(), branchTel = row["branchTel1"].ToString(), // And many more fields }; How can I to implement each fields to each textbox?

    Read the article

  • What is/are the Scala way(s) to implement this Java "byte[] to Hex" class

    - by nicerobot
    I'm specifically interested in Scala (2.8) techniques for building strings with formats as well as interesting ways to make such a capability easily accessible where it's useful (lists of bytes, String, ...?).. public class Hex { public static String valueOf (final byte buf[]) { if (null == buf) { return null; } final StringBuilder sb = new StringBuilder(buf.length * 2); for (final byte b : buf) { sb.append(String.format("%02X", b & 0xff)); } return sb.toString(); } public static String valueOf (final Byteable o) { return valueOf(o.toByteArray()); } } This is only a learning exercise (so the utility and implementation of the Java isn't a concern.) Thanks

    Read the article

  • help me with the following sql query

    - by rupeshmalviya
    could somebody correct my following query, i am novice to software development realm, i am to a string builder object in comma separated form to my query but it's not producing desired result qyery is as follows and string cmd = "SELECT * FROM [placed_student] WHERE passout_year=@passout AND company_id=@companyId AND course_id=@courseId AND branch_id IN('" + sb + "')"; StringBuilder sb = new StringBuilder(); foreach (ListItem li in branch.Items) { if (li.Selected == true) { sb.Append(Convert.ToInt32(li.Value) +", "); } } li is integer value of my check box list which are getting generated may be differne at different time ...please also suggest me some good source to learn sql..

    Read the article

  • How can you generate the same MD5 Hashcode in C# and Java?

    - by Sem Dendoncker
    Hi, I have a function that generates a MD5 hash in C# like this: MD5 md5 = new MD5CryptoServiceProvider(); byte[] result = md5.ComputeHash(data); StringBuilder sb = new StringBuilder(); for (int i = 0; i < result.Length; i++) { sb.Append(result[i].ToString("X2")); } return sb.ToString(); In java my function looks like this: MessageDigest m = MessageDigest.getInstance("MD5"); m.update(bytes,0,bytes.length); String hashcode = new BigInteger(1,m.digest()).toString(16); return hashcode; While the C# code generates: "02945C9171FBFEF0296D22B0607D522D" the java codes generates: "5a700e63fa29a8eae77ebe0443d59239". Is there a way to generate the same md5 hash for the same bytearray? Cheers

    Read the article

  • Better way to load level content in XNA?

    - by user2002495
    Currently I loaded all my assets in XNA in the main Game class. What I want to achieve later is that I only load specific assets for specific levels (the game will consist of many levels). Here is how I load my main assets into the main class: protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); plane = new Player(Content.Load<Texture2D>(@"Player/playerSprite"), 6, 8); plane.animation = "down"; plane.pos = new Vector2(400, 500); plane.fps = 15; Global.currentPos = plane.pos; lvl1 = new Level1(Content.Load<Texture2D>(@"Levels/bgLvl1"), Content.Load<Texture2D>(@"Levels/bgLvl1-other"), new Vector2(0, 0), new Vector2(0, -600)); CommonBullet.LoadContent(Content); CommonEnemyBullet.LoadContent(Content); } protected override void UnloadContent() { } protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); plane.Update(gameTime); lvl1.Update(gameTime); foreach (CommonEnemy ce in cel) { if (ce.CollidesWith(plane)) { ce.hasSpawn = false; } foreach (CommonBullet b in plane.commonBulletList) { if (b.CollidesWith(ce)) { ce.hasSpawn = false; } } ce.Update(gameTime); } LoadCommonEnemy(); base.Update(gameTime); } private void LoadCommonEnemy() { int randY = rand.Next(-600, -10); int randX = rand.Next(0, 750); if (cel.Count < 3) { cel.Add(new CommonEnemy(Content.Load<Texture2D>(@"Enemy/Common/commonEnemySprite"), 7, 2, "left", randX, randY)); } for (int i = 0; i < cel.Count; i++) { if (!cel[i].hasSpawn) { cel.RemoveAt(i); i--; } } } protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.Black); spriteBatch.Begin(); lvl1.Draw(spriteBatch); plane.Draw(spriteBatch); foreach (CommonEnemy ce in cel) { ce.Draw(spriteBatch); } spriteBatch.End(); base.Draw(gameTime); } I wish to load my players, enemies, all in Level1 class. However, when I move my player & enemy code into the Level1 class, the gameTime returns null. Here is my Level1 class: using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Media; using Microsoft.Xna.Framework.Input; using SpaceShooter_Beta.Animation.PlayerCollection; using SpaceShooter_Beta.Animation.EnemyCollection.Common; namespace SpaceShooter_Beta.Levels { public class Level1 { public Texture2D bgTexture1, bgTexture2; public Vector2 bgPos1, bgPos2; public float speed = 5f; Player plane; public Level1(Texture2D texture1, Texture2D texture2, Vector2 pos1, Vector2 pos2) { this.bgTexture1 = texture1; this.bgTexture2 = texture2; this.bgPos1 = pos1; this.bgPos2 = pos2; } public void LoadContent(ContentManager cm) { plane = new Player(cm.Load<Texture2D>(@"Player/playerSprite"), 6, 8); plane.animation = "down"; plane.pos = new Vector2(400, 500); plane.fps = 15; Global.currentPos = plane.pos; } public void Draw(SpriteBatch sb) { sb.Draw(bgTexture1, bgPos1, Color.White); sb.Draw(bgTexture2, bgPos2, Color.White); plane.Draw(sb); } public void Update(GameTime gt) { bgPos1.Y += speed; bgPos2.Y += speed; if (bgPos1.Y >= 600) { bgPos1.Y = -600; } if (bgPos2.Y >= 600) { bgPos2.Y = -600; } plane.Update(gt); } } } Of course when I did this, I delete all my player's code in the main Game class. All of that works fine (no errors) except that the game cannot start. The debugger says that plane.Update(gt); in Level 1 class has null GameTime, same thing with the Draw method in the Level class. Please help, I appreciate for the time. [EDIT] I know that using switch in the main class can be a solution. But I prefer a cleaner solution than that, since using switch still means I need to load all the assets through the main class, the code will be A LOT later on for each levels

    Read the article

  • How to parse xml with multiple, changing namespaces?

    - by sweenrace
    I have the following xml that I'm trying to parse and get the Account Data from <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ns2:SearchResults xmlns="http://www.intuit.com/sb/cdm/v2" xmlns:ns2="http://www.intuit.com/sb/cdm/qbo" xmlns:ns3="http://www.intuit.com/sb/cdm/qbopayroll/v1"> <ns2:CdmCollections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Accounts"> <Account> <Id idDomain="QBO">31</Id> <SyncToken>0</SyncToken> <MetaData> <CreateTime>2010-02-16T18:03:50-08:00</CreateTime> <LastUpdatedTime>2010-02-16T18:03:50-08:00</LastUpdatedTime> </MetaData> <Name>Accounts Payable</Name> <Subtype>AccountsPayable</Subtype> <CurrentBalance>34002.00</CurrentBalance> </Account> <Account> <Id idDomain="QBO">36</Id> <SyncToken>0</SyncToken> <MetaData> <CreateTime>2011-01-11T13:24:14-08:00</CreateTime> <LastUpdatedTime>2011-01-11T13:24:14-08:00</LastUpdatedTime> </MetaData><Name>Accounts Receivable (A/R)</Name> <Subtype>AccountsReceivable</Subtype> <CurrentBalance>1125.85</CurrentBalance> </Account> </ns2:CdmCollections> <ns2:Count>10</ns2:Count> <ns2:CurrentPage>1</ns2:CurrentPage> </ns2:SearchResults> The following code sometimes work such that the I can see that children tags and values of CdmCollections. However, it doesnt always work for the same query. Looking at the raw xml I can see the namespaces change, e.g. sometimes ns2="http://www.intuit.com/sb/cdm/qbo" (works) and other times ns2 = "http://www.intuit.com/sb/cdm/v2" (doesnt work). I thought by using the namespaces array I could handle that issue but its not working. Any suggestions how I can fix this? $account_xml = new SimpleXMLElement($account_query_response); $namespaces = $account_xml->getNamespaces(true); $account_xml->registerXPathNamespace('c', $namespaces["ns2"]); $x = 0; foreach($account_xml->xpath('//c:SearchResults') as $search) { echo "<br>row " . $x; $search->registerXPathNamespace('c', $namespaces["ns2"]); var_dump($search->xpath('//c:CdmCollections')); }

    Read the article

  • Is asp.net caching my sql results?

    - by Christian W
    I have the following method in an App_Code/Globals.cs file: public static XmlDataSource getXmlSourceFromOrgid(int orgid) { XmlDataSource xds = new XmlDataSource(); var ctx = new SensusDataContext(); SqlConnection c = new SqlConnection(ctx.Connection.ConnectionString); c.Open(); SqlCommand cmd = new SqlCommand(String.Format("select orgid, tekst, dbo.GetOrgTreeXML({0}) as Subtree from tblOrg where OrgID = {0}", orgid), c); var rdr = cmd.ExecuteReader(); rdr.Read(); StringBuilder sb = new StringBuilder(); sb.AppendFormat("&lt;node orgid=\"{0}\" tekst=\"{1}\"&gt;",rdr.GetInt32(0),rdr.GetString(1)); sb.Append(rdr.GetString(2)); sb.Append("&lt;/node&gt;"); xds.Data = sb.ToString(); xds.ID = "treedata"; rdr.Close(); c.Close(); return xds; } This gives me an XML-structure to use with the asp.net treeview control (I also use the CssFriendly extender to get nicer code) My problem is that if I logon on my pc with a code that gives me access on a lower level in the tree hierarchy (it's an orgianization hierarchy), it somehow "remembers" what level i logon at. So when my coworker tests from her computer with another code, giving access to another place in the tree, she get's the same tree as me. (The tree is supposed to show your own level and down.) I have added a html-comment to show what orgid it passes to the function, and the orgid passed is correct. So either the treeview caches something serverside, or the sqlquery caches it's result somehow... Any ideas? Sql function: ALTER function [dbo].[GetOrgTreeXML](@orgid int) returns XML begin RETURN (select org.orgid as '@orgid', org.tekst as '@tekst', [dbo].GetOrgTreeXML(org.orgid) from tblOrg org where (@orgid is null and Eier is null) or Eier=@orgid for XML PATH('NODE'), TYPE) end Extra code as requested: int orgid = int.Parse(Session["org"].ToString()); string orgname = context.Orgs.Where(q => q.OrgID == orgid).First().Tekst; debuglit.Text = String.Format("<!-- Id: {0} \n name: {1} -->", orgid, orgname); var orgxml = Globals.getXmlSourceFromOrgid(orgid); tvNavtree.DataSource = orgxml; tvNavtree.DataBind(); Where "debuglit" is a asp:Literal in the aspx file. EDIT: I have narrowed it down. All functions returns correct values. It just doesn't bind to it. I suspect the CssFriendly adapter to have something to do with it. I disabled the CssFriendly adapter and the problem persists... Stepping through it in debug it's correct all the way, with the stepper standing on "tvNavtree.DataBind();" I can hover the pointer over the tvNavtree.Datasource and see that it actually has the correct data. So something must be faulting in the binding process...

    Read the article

  • j2me MIDP: detecting if phone has a data plan

    - by SB
    Is there a way to determine what kind of data plan a device has so an app provides a less rich experience if a data plan is not available? I imagine the connector factory would still be able to return me an HTTPConnection but it would cost the user serious money for lots of data, and I'd like to be nice and prevent that. I thought there would be a way to query device capabilities in the MIDP API, but maybe it's in CLDC?

    Read the article

  • Are there any real benefits to including javascript dynamically rather than as script tags at the bo

    - by SB
    I've read that including the scripts dynamically may provide some better performance, however i'm not really seeing that on the small local tests I'm doing. I created a jquery plugin to dynamically load other plugins as necessary and am curious as to if this is actually a good idea. The following would be called onready or at the bottom of the page(I can provide the source for the plugin if anyone is interested): $.fn.executePlugin( 'qtip', // looks in default folder { required: '/javascript/plugin/easing.js', // not really required for qtip just testing it version: 1, //used for versioning and caching checkelement: '#thumbnail', // will not include plugin if $(element).length==0 css: 'page.css', // include this css file as well with plugin cache:true, // $.ajax will use cache:true success:function() { // success function to be called after the plugin loads - apply qtip to an element $('#thumbnail').qtip( { content: 'Some basic content for the tooltip', // Give it some content, in this case a simple string style: {name:'cream'}, }); } });

    Read the article

  • wpf datagrid extra column in header on left

    - by sb
    I keep getting this button in the header, I can click on the button to select all rows. This misaligns the data from the header. Any ideas? Thanks in Advance. Datagrid image via link: http://picasaweb.google.com/lh/photo/CahvlINknhL5ykIW2zCfIw?feat=directlink <dg:DataGrid.Columns> <dg:DataGridTextColumn Header="Description" Width=".5*" Binding="{Binding Description}"> </dg:DataGridTextColumn> <dg:DataGridTextColumn Header="Type" Width="100" Binding="{Binding Type}"> </dg:DataGridTextColumn> <dg:DataGridTextColumn Header="Amount $" Width="100" Binding="{Binding Amount}"> </dg:DataGridTextColumn> <dg:DataGridTextColumn Header="Effective From Date" Width="100" Binding="{Binding EffectiveFromDate}" IsReadOnly="True"> </dg:DataGridTextColumn> <dg:DataGridTextColumn Header="Effective To Date" Width="100" Binding="{Binding EffectiveToDate}" IsReadOnly="True"> </dg:DataGridTextColumn> <dg:DataGridTextColumn Header="Status" Width="100" Binding="{Binding Status}"> </dg:DataGridTextColumn> </dg:DataGrid.Columns>

    Read the article

  • In Perl, can I limit the length of a line as I read it in from a file (like fgets)

    - by SB
    I'm trying to write a piece of code that reads a file line by line and stores each line, up to a certain amount of input data. I want to guard against the end-user being evil and putting something like a gig of data on one line in addition to guarding against sucking in an abnormally large file. Doing $str = <FILE> will still read in a whole line, and that could be very long and blow up my memory. fgets lets me do this by letting me specify a number of bytes to read during each call and essentially letting me split one long line into my max length. Is there a similar way to do this in perl? I saw something about sv_gets but am not sure how to use it (though I only did a cursory Google search). Thanks.

    Read the article

  • Database solution for 200million writes/day, monthly summarization queries

    - by sb
    Hello. I'm looking for help deciding on which database system to use. (I've been googling and reading for the past few hours; it now seems worthwhile to ask for help from someone with firsthand knowledge.) I need to log around 200 million rows (or more) per 8 hour workday to a database, then perform weekly/monthly/yearly summary queries on that data. The summary queries would be for collecting data for things like billing statements, eg. "How many transactions of type A did each user run this month?" (could be more complex, but that's the general idea). I can spread the database amongst several machines, as necessary, but I don't think I can take old data offline. I'll definitely need to be able to query a month's worth of data, maybe a year. These queries would be for my own use, and wouldn't need to be generated in real-time for an end-user (they could run overnight, if needed). Does anyone have any suggestions as to which databases would be a good fit? P.S. Cassandra looks like it would have no problem handling the writes, but what about the huge monthly table scans? Is anyone familiar with Cassandra/Hadoop MapReduce performance?

    Read the article

  • DoubleAnimation in ScaleTransform

    - by Adam S
    I'm trying, as an exhibition, to use a DoubleAnimation on the ScaleX and ScaleY properties of a ScaleTransform. I have a rectangle (144x144) which I want to make rectangular over five seconds. My XAML: <Window x:Class="ScaleTransformTest.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300" Loaded="Window_Loaded"> <Grid> <Rectangle Name="rect1" Width="144" Height="144" Fill="Aqua"> <Rectangle.RenderTransform> <ScaleTransform ScaleX="1" ScaleY="1" /> </Rectangle.RenderTransform> </Rectangle> </Grid> </Window> My C#: private void Window_Loaded(object sender, RoutedEventArgs e) { ScaleTransform scaly = new ScaleTransform(1, 1); rect1.RenderTransform = scaly; Duration mytime = new Duration(TimeSpan.FromSeconds(5)); Storyboard sb = new Storyboard(); DoubleAnimation danim1 = new DoubleAnimation(1, 1.5, mytime); DoubleAnimation danim2 = new DoubleAnimation(1, 0.5, mytime); sb.Children.Add(danim1); sb.Children.Add(danim2); Storyboard.SetTarget(danim1, scaly); Storyboard.SetTargetProperty(danim1, new PropertyPath(ScaleTransform.ScaleXProperty)); Storyboard.SetTarget(danim2, scaly); Storyboard.SetTargetProperty(danim2, new PropertyPath(ScaleTransform.ScaleYProperty)); sb.Begin(); } Unfortunately, when I run this program, it does nothing. The rectangle stays at 144x144. If I do away with the animation, and just ScaleTransform scaly = new ScaleTransform(1.5, 0.5); rect1.RenderTransform = scaly; it will elongate it instantly, no problem. There is a problem elsewhere. Any suggestions? I have read the discussion at http://www.eggheadcafe.com/software/aspnet/29220878/how-to-animate-tofrom-an.aspx in which someone seems to have gotten a pure-XAML version working, but the code is not shown there. EDIT: At http://stackoverflow.com/questions/2131797/applying-animated-scaletransform-in-code-problem it seems someone had a very similar problem, I am fine with using his method that worked, but what the heck is that string thePath = "(0).(1)[0].(2)"; all about? What are those numbers representing?

    Read the article

  • C# Begin/EndReceive - how do I read large data?

    - by ryeguy
    When reading data in chunks of say, 1024, how do I continue to read from a socket that receives a message bigger than 1024 bytes until there is no data left? Should I just use BeginReceive to read a packet's length prefix only, and then once that is retrieved, use Receive() (in the async thread) to read the rest of the packet? Or is there another way? edit: I thought Jon Skeet's link had the solution, but there is a bit of a speedbump with that code. The code I used is: public class StateObject { public Socket workSocket = null; public const int BUFFER_SIZE = 1024; public byte[] buffer = new byte[BUFFER_SIZE]; public StringBuilder sb = new StringBuilder(); } public static void Read_Callback(IAsyncResult ar) { StateObject so = (StateObject) ar.AsyncState; Socket s = so.workSocket; int read = s.EndReceive(ar); if (read > 0) { so.sb.Append(Encoding.ASCII.GetString(so.buffer, 0, read)); if (read == StateObject.BUFFER_SIZE) { s.BeginReceive(so.buffer, 0, StateObject.BUFFER_SIZE, 0, new AyncCallback(Async_Send_Receive.Read_Callback), so); return; } } if (so.sb.Length > 0) { //All of the data has been read, so displays it to the console string strContent; strContent = so.sb.ToString(); Console.WriteLine(String.Format("Read {0} byte from socket" + "data = {1} ", strContent.Length, strContent)); } s.Close(); } Now this corrected works fine most of the time, but it fails when the packet's size is a multiple of the buffer. The reason for this is if the buffer gets filled on a read it is assumed there is more data; but the same problem happens as before. A 2 byte buffer, for exmaple, gets filled twice on a 4 byte packet, and assumes there is more data. It then blocks because there is nothing left to read. The problem is that the receive function doesn't know when the end of the packet is. This got me thinking to two possible solutions: I could either have an end-of-packet delimiter or I could read the packet header to find the length and then receive exactly that amount (as I originally suggested). There's problems with each of these, though. I don't like the idea of using a delimiter, as a user could somehow work that into a packet in an input string from the app and screw it up. It also just seems kinda sloppy to me. The length header sounds ok, but I'm planning on using protocol buffers - I don't know the format of the data. Is there a length header? How many bytes is it? Would this be something I implement myself? Etc.. What should I do?

    Read the article

  • DataRelation Insert and ForeignKey

    - by Steve
    Guys, I have a winforms application with two DataGridViews displaying a master-detail relationship from my Person and Address tables. Person table has a PersonID field that is auto-incrementing primary key. Address has a PersonID field that is the FK. I fill my DataTables with DataAdapter and set Person.PersonID column's AutoIncrement=true and AutoIncrementStep=-1. I can insert records in the Person DataTable from the DataGridView. The PersonID column displays unique negative values for PersonID. I update the database by calling DataAdapter.Update(PersonTable) and the negative PersonIDs are converted to positive unique values automatically by SQL Server. Here's the rub. The Address DataGridView show the address table which has a DataRelation to Person by PersonID. Inserted Person records have the temporary negative PersonID. I can now insert records into Address via DataGridView and Address.PersonID is set to the negative value from the DataRelation mapping. I call Adapter.Update(AddressTable) and the negative PersonIDs go into the Address table breaking the relationship. How do you guys handle primary/foreign keys using DataTables and master-detail DataGridViews? Thanks! Steve EDIT: After more googling, I found that SqlDataAdapter.RowUpdated event gives me what I need. I create a new command to query the last id inserted by using @@IDENTITY. It works pretty well. The DataRelation updates the Address.PersonID field for me so it's required to Update the Person table first then update the Address table. All the new records insert properly with correct ids in place! Adapter = new SqlDataAdapter(cmd); Adapter.RowUpdated += (s, e) => { if (e.StatementType != StatementType.Insert) return; //set the id for the inserted record SqlCommand c = e.Command.Connection.CreateCommand(); c.CommandText = "select @@IDENTITY id"; e.Row[0] = Convert.ToInt32( c.ExecuteScalar() ); }; Adapter.Fill(this); SqlCommandBuilder sb = new SqlCommandBuilder(Adapter); sb.GetDeleteCommand(); sb.GetUpdateCommand(); sb.GetInsertCommand(); this.Columns[0].AutoIncrement = true; this.Columns[0].AutoIncrementSeed = -1; this.Columns[0].AutoIncrementStep = -1;

    Read the article

  • Controlling the Mc's of a loaded SWF

    - by Ross
    I have a controller.swf which loads an external swf into a movieclip. news_mc = loadEvent.currentTarget.content as MovieClip; the swf is called "news.swf" and has a movieclip on the maintimeline, frame 1 called "sb". I have tried everything to access this such as mews_mc.sb.alpha = 0; but nothing works?

    Read the article

  • StringBuilder vs XmlTextWriter

    - by Wololo
    I am trying to squeeze as much performance as i can from a custom HttpHandler that serves Xml content. I' m wondering which is better for performance. Using the XmlTextWriter class or ad-hoc StringBuilder operations like: StringBuilder sb = new StringBuilder("<?xml version="1.0" encoding="UTF-8" ?>"); sb.AppendFormat("<element>{0}</element>", SOMEVALUE); Does anyone have first hand experience?

    Read the article

  • Swing: Scroll to bottom of JScrollPane, conditionally on current viewport location

    - by I82Much
    Hi all, I am attempting to mimic the functionality of Adium and most other chat clients I've seen, wherein the scrollbars advance to the bottom when new messages come in, but only if you're already there. In other words, if you've scrolled a few lines up and are reading, when a new message comes in it won't jump your position to the bottom of the screen; that would be annoying. But if you're scrolled to the bottom, the program rightly assumes that you want to see the most recent messages at all times, and so auto-scrolls accordingly. I have had a bear of a time trying to mimic this; the platform seems to fight this behavior at all costs. The best I can do is as follows: In constructor: JTextArea chatArea = new JTextArea(); JScrollPane chatAreaScrollPane = new JScrollPane(chatArea); // We will manually handle advancing chat window DefaultCaret caret = (DefaultCaret) chatArea.getCaret(); caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE); In method that handles new text coming in: boolean atBottom = isViewAtBottom(); // Append the text using styles etc to the chatArea if (atBottom) { scrollViewportToBottom(); } public boolean isAtBottom() { // Is the last line of text the last line of text visible? Adjustable sb = chatAreaScrollPane.getVerticalScrollBar(); int val = sb.getValue(); int lowest = val + sb.getVisibleAmount(); int maxVal = sb.getMaximum(); boolean atBottom = maxVal == lowest; return atBottom; } private void scrollToBottom() { chatArea.setCaretPosition(chatArea.getDocument().getLength()); } Now, this works, but it's janky and not ideal for two reasons. By setting the caret position, whatever selection the user may have in the chat area is erased. I can imagine this would be very irritating if he's attempting to copy/paste. Since the advancement of the scroll pane occurs after the text is inserted, there is a split second where the scrollbar is in the wrong position, and then it visually jumps towards the end. This is not ideal. Before you ask, yes I've read this blog post on Text Area Scrolling, but the default scroll to bottom behavior is not what I want. Other related (but to my mind, not completely helpful in this regard) questions: Setting scroll bar on a jscrollpane Making a JScrollPane automatically scroll all the way down. Any help in this regard would be very much appreciated.

    Read the article

  • Swing: Scroll to bottom of JScrollPane, conditional on current viewport location

    - by I82Much
    Hi all, I am attempting to mimic the functionality of Adium and most other chat clients I've seen, wherein the scrollbars advance to the bottom when new messages come in, but only if you're already there. In other words, if you've scrolled a few lines up and are reading, when a new message comes in it won't jump your position to the bottom of the screen; that would be annoying. But if you're scrolled to the bottom, the program rightly assumes that you want to see the most recent messages at all times, and so auto-scrolls accordingly. I have had a bear of a time trying to mimic this; the platform seems to fight this behavior at all costs. The best I can do is as follows: In constructor: JTextArea chatArea = new JTextArea(); JScrollPane chatAreaScrollPane = new JScrollPane(chatArea); // We will manually handle advancing chat window DefaultCaret caret = (DefaultCaret) chatArea.getCaret(); caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE); In method that handles new text coming in: boolean atBottom = isViewAtBottom(); // Append the text using styles etc to the chatArea if (atBottom) { scrollViewportToBottom(); } public boolean isAtBottom() { // Is the last line of text the last line of text visible? Adjustable sb = chatAreaScrollPane.getVerticalScrollBar(); int val = sb.getValue(); int lowest = val + sb.getVisibleAmount(); int maxVal = sb.getMaximum(); boolean atBottom = maxVal == lowest; return atBottom; } private void scrollToBottom() { chatArea.setCaretPosition(chatArea.getDocument().getLength()); } Now, this works, but it's janky and not ideal for two reasons. By setting the caret position, whatever selection the user may have in the chat area is erased. I can imagine this would be very irritating if he's attempting to copy/paste. Since the advancement of the scroll pane occurs after the text is inserted, there is a split second where the scrollbar is in the wrong position, and then it visually jumps towards the end. This is not ideal. Before you ask, yes I've read this blog post on Text Area Scrolling, but the default scroll to bottom behavior is not what I want. Other related (but to my mind, not completely helpful in this regard) questions: Setting scroll bar on a jscrollpane Making a JScrollPane automatically scroll all the way down. Any help in this regard would be very much appreciated.

    Read the article

  • Contact Bubble EditText

    - by toobsco42
    I am trying to create contact bubbles in the MultiAutoCompleteTextView similiar to how it is implemented in the Google+ app. Below is a screen shot: . I have tried to extend the DynamicDrawableSpan class in order to get a spannable drawable in the background of a span of text public class BubbleSpan extends DynamicDrawableSpan { private Context c; public BubbleSpan(Context context) { super(); c = context; } @Override public Drawable getDrawable() { Resources res = c.getResources(); Drawable d = res.getDrawable(R.drawable.oval); d.setBounds(0, 0, 100, 20); return d; } } Where my oval.xml drawable is defined as so: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> <solid android:color="#00000000"/> <stroke android:width="4dp" android:color="#99000000" android:dashWidth="4dp" android:dashGap="2dp" /> <padding android:left="7dp" android:top="7dp" android:right="7dp" android:bottom="7dp" /> <corners android:radius="4dp" /> </shape> In my Activity class that has the MulitAutoCompleteTextView, I set the bubble span like so: final Editable e = tv.getEditableText(); final SpannableStringBuilder sb = new SpannableStringBuilder(); sb.append("some sample text"); sb.setSpan(new BubbleSpan(getApplicationContext()), 0, 6, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); e.append(sb); However, instead of the oval shape displaying behind the first 6 characters in the string, the characters are not visible and there is no oval drawable in the background. If i change the BubbleSpan's getDrawable() method to use a .png instead of a shape drawable: public Drawable getDrawable() { Resources res = c.getResources(); Drawable d = res.getDrawable(android.R.drawable.bottom_bar); d.setBounds(0, 0, 100, 20); return d; } Then the .png will show up but the characters in the string that are a part of the span will not show up. How can I make it so that the characters in the span are displayed in the foreground, meanwhile a custom shape drawable gets displayed in the background? I attempted to also use an ImageSpan instead of subclassing DynamicDrawableSpan but was unsuccessful.

    Read the article

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