What does assert do? for example in the function?
private static int charAt(String s, int d) {
assert d >= 0 && d <= s.length();
if (d == s.length()) return -1;
return s.charAt(d);
}
Hi,
i have a container div which is position:relative and the squares are position:absolute because i want to play with their positions.
Like what you see, the container does not fit the content except if the squares are positioned in Relative, is there a solution for this?
I don't want to just set the height for container because the squares are not static so i want something that resizes automatically.
Thanks
Looking in Process Explorer it uses; Virtual Size: 550,000k , Working Set: 28000k
Why does my simple hello world console app use so much memory?
I take it the difference between the Working Set and Virtual Size means that difference will be paged to disk?
/I am running 64 bit XP.
Thanks
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello world");
Console.ReadLine();
}
}
Is there an easier/better way to access the RequestContext from within a custom Membership Provider than the following (and further, will this method even work):
private static RequestContext GetRequestContext()
{
HttpContextBase contextBase =
new HttpContextWrapper(HttpContext.Current);
return new RequestContext(
contextBase,
RouteTable.Routes.GetRouteData(contextBase));
}
Ok - I am being a bit geeky but girls can be geeks to
When we do something like double.isNan what exactly is happening.
If double was a class I would understand it, but double is a struct and is a value type so how does C# actually call a static method on a value type?
If I want to get a user that has the email address of '[email protected]', how do I pass that as a parameter in linq?
ie.:
var a = from u in Users
where u.Email = @email
Select u;
So this would be used in my method:
public static GetuserByEmail(string email)
Do I just pass in the variable or?
How can I add a new page in the webapp directory in lift that can be accessed by users?
Currently only the index.html can be accessed through http://localhost:8080/ or http://localhost:8080/index.html
Say I add a static file newpage.html into webapp dir, then what can I do so users can access it through http://localhost:8080/newpage.html ?
What is the Url.Content() of asp.net mvc equivalent in php?
I have a file that use my style.css from both pathes:
'artciles/123/name'
'artciles/123'
How can I use links to static content, witout using absolute urls?
The CakePHP Cookbook states that a Model can use a file (csv for example) instead of an actual database table but I couldn't find any implementation for it.
I was wondering if it is possible to use an Array of data as a model in CakePHP since I have a fairly static set of data which is important to me in a relationship with another table but it doesn't make a whole lot of sense to create a complete table for it.
Is it possible to implement a CakePHP Model using an Array?
I am developing a C# VS 2008 and SQL Server 2008 website. However, I get the below error now when I first run this:
The DataSourceID of 'GridView1' must be the ID of a control of type
IDataSource. A control with ID 'AdventureWorks3.mdf' could not be found
What is causing this error? Here is my default.aspx file. I have configured GridView1 to use my AdventureWorks3.mdf file, stored in my App_Data folder. Do I need to add this folder name to this ASPX file?
<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
<asp:Panel runat="server" ID="AuthenticatedMessagePanel">
<asp:Label runat="server" ID="WelcomeBackMessage"></asp:Label>
<table>
<tr >
<td>
<asp:Label ID="tableLabel" runat="server" Font-Bold="True"
Text="Select target table:"></asp:Label>
</td>
<td>
<asp:Label ID="inputLabel" runat="server" Font-Bold="True"
Text="Select input file:"></asp:Label>
</td></tr>
<tr><td valign="top">
<asp:Label ID="feedbackLabel" runat="server"></asp:Label>
<asp:GridView ID="GridView1" runat="server" style="WIDTH: 400px;" CellPadding="4" ForeColor="#333333"
GridLines="None" onselectedindexchanged="GridView1_SelectedIndexChanged"
AutoGenerateSelectButton="True" DataSourceID="AdventureWorks3.mdf" >
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
</td>
<td valign="top">
<input id="uploadFile" type="file" size="26" runat="server" name="uploadFile"
title="UploadFile" class="greybar"
enableviewstate="True" />
</td></tr>
</table>
</asp:Panel>
<asp:Panel runat="Server" ID="AnonymousMessagePanel">
<asp:HyperLink runat="server" ID="lnkLogin" Text="Log In" NavigateUrl="~/Login.aspx">
</asp:HyperLink>
</asp:Panel> </asp:Content>
Or what about my ASPX.CS file? Is this the problem?
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.IO;
using System.Drawing;
using System.ComponentModel;
using System.Data.SqlClient;
using ADONET_namespace;
using System.Security.Principal;
//using System.Windows;
public partial class _Default : System.Web.UI.Page
//namespace AddFileToSQL
{
//protected System.Web.UI.HtmlControls.HtmlInputFile uploadFile;
protected System.Web.UI.HtmlControls.HtmlInputButton btnOWrite;
protected System.Web.UI.HtmlControls.HtmlInputButton btnAppend;
protected System.Web.UI.WebControls.Label Label1;
protected static string inputfile = "";
public static string targettable;
public static string selection;
// Number of controls added to view state
protected int default_NumberOfControls
{
get
{
if (ViewState["default_NumberOfControls"] != null)
{
return (int)ViewState["default_NumberOfControls"];
}
else
{
return 0;
}
}
set
{
ViewState["default_NumberOfControls"] = value;
}
}
protected void uploadFile_onclick(object sender, EventArgs e)
{
}
protected void Load_GridData()
{
GridView1.DataSource = ADONET_methods.DisplaySchemaTables();
GridView1.DataBind();
}
protected void btnOWrite_Click(object sender, EventArgs e)
{
if (uploadFile.PostedFile.ContentLength > 0)
{
feedbackLabel.Text = "You do not have sufficient access to overwrite table records.";
}
else
{
feedbackLabel.Text = "This file does not contain any data.";
}
}
protected void btnAppend_Click(object sender, EventArgs e)
{
string fullpath = Page.Request.PhysicalApplicationPath;
string path = uploadFile.PostedFile.FileName;
if (File.Exists(path))
{
// Create a file to write to.
try
{
StreamReader sr = new StreamReader(path);
string s = "";
while (sr.Peek() > 0)
s = sr.ReadLine();
sr.Close();
}
catch (IOException exc)
{
Console.WriteLine(exc.Message + "Cannot open file.");
return;
}
}
if (uploadFile.PostedFile.ContentLength > 0)
{
inputfile = System.IO.File.ReadAllText(path);
Session["Message"] = inputfile;
Response.Redirect("DataMatch.aspx");
}
else
{
feedbackLabel.Text = "This file does not contain any data.";
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (Request.IsAuthenticated)
{
WelcomeBackMessage.Text = "Welcome back, " + User.Identity.Name + "!";
// Reference the CustomPrincipal / CustomIdentity
CustomIdentity ident = User.Identity as CustomIdentity;
if (ident != null)
WelcomeBackMessage.Text += string.Format(" You are the {0} of {1}.", ident.Title, ident.CompanyName);
AuthenticatedMessagePanel.Visible = true;
AnonymousMessagePanel.Visible = false;
//if (!Page.IsPostBack)
//{
// Load_GridData();
//}
}
else
{
AuthenticatedMessagePanel.Visible = false;
AnonymousMessagePanel.Visible = true;
}
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow row = GridView1.SelectedRow;
targettable = row.Cells[2].Text;
}
}
I have an app in the app store that uses a wildcard bundle identifier. I want to implement in-app purchashing , which requires a non wildcard ID. How do I convert the wildcard ID of an existing app to a static ID for in-app purchase and push notification?
I have installed xcode 3.2 with iphone SDK. (without Mac OS 10.4 SDK). WHen i create new project i only got these options for Mac OS
-- Application
-- Framework and Library
-- Application plugin
-- System plugin
--Other
But a book named: Programming Object C 2.0. From which i am learning object C. Its showing XCode with these templates for Mac OS
--Application
--Audio Units
--Automater actions
--Bundles
--Command Line Utility
--dynamic library
--Framework
--Java
--Kernal Extensions
--Standard Apple plugin
--Static Library
--Other
I need the Command Line Utility template so that can create sample projects mentioned in book.
Right now I have
private static void iterateall(BinaryTree foo) {
if(foo!= null){
System.out.println(foo.node);
iterateall(foo.left);
iterateall(foo.right);
}
}
Can you change it to Iteration instead of a recursion?
I've got a Jlist inside a JScrollPane and I've set a prototype value so that it doesn't have to calculate the width for big lists, but just uses this default width.
Now, the problem is that the Jlist is for some reason replacing the end of an element with dots (...) so that a horizontal scrollbar will never be shown.
How do I disable with "wrapping"? So that long elements are not being replaced with dots if they are wider than the Jlist's width?
I've reproduced the issue in a small example application. Please run it if you don't understand what I mean:
import javax.swing.*;
import java.awt.*;
public class Test
{
//window
private static final int windowWidth = 450;
private static final int windowHeight = 500;
//components
private JFrame frame;
private JList classesList;
private DefaultListModel classesListModel;
public Test()
{
load();
}
private void load()
{
//create window
frame = new JFrame("Test");
frame.setSize(windowWidth, windowHeight);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setUndecorated(true);
frame.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
//classes list
classesListModel = new DefaultListModel();
classesList = new JList(classesListModel);
classesList.setPrototypeCellValue("prototype value");
classesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
classesList.setVisibleRowCount(20);
JScrollPane scrollClasses = new JScrollPane(classesList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
for (int i = 0; i < 200; i++)
{
classesListModel.addElement("this is a long string, does not fit in width");
}
//panel
JPanel drawingArea = new JPanel();
drawingArea.setBackground(Color.white);
drawingArea.add(scrollClasses);
frame.add(drawingArea);
//set visible
frame.setVisible(true);
}
}
Even if you force horizontal scrollbar, you still won't be able to scroll because the element is actually not wider than the width because of the dot (...) wrapping.
Thanks in advance.
This is the handler, in the main Thread, which shows and dismisses a progress dialog.
public static final int SHOW = 0;
public static final int DISMISS = 1;
public Handler pdHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
Log.i(TAG, "+ handleMessage(msg:" + msg + ")");
switch(msg.what) {
case SHOW:
pd = ProgressDialog.show(LogViewer.this, "", getText(R.string.loading_msg), true);
break;
case DISMISS:
if(pd != null) {
pd.dismiss();
pd = null;
}
break;
}
}
};
The message to show the progress is:
pdHandler.sendMessage(pdHandler.obtainMessage(SHOW));
The message to dismiss it is:
pdHandler.sendMessage(pdHandler.obtainMessage(DISMISS));
It works well when I call it before I start an AsyncTask, the AsyncTask onPostExecute() dismisses it.
But when it runs within a runnable (runOnUiThread), the dialog does not show. Examining the
pd variable on the debugger, it shows that is is created, it is running and it is visible, but in practice it is not visible.
Any suggestion?
UPDATE:
I did the obvious test I should have done in the first place. I commented the DISMISS message. And the progress dialog did show up. It appeared too late, after the runnable was finished.
I undestand now that the DISMISS message did dismiss the not-yet-visible ProgressDialog, that's why I did not see it.
The question becomes now: I need the ProgressDialog to show BEFORE the runnable code is executed. And it is not so straight forward. My call hierarchy is like this:
onScrollEventChanged
--> runOnUiThread (
--> checkScrollLimits
--> if need to scroll
show ProgressDialog "Loading"
get new data into table
dismiss ProgressDIalog
)
I tried something like this:
onScrollEventChanged
--> checkScrollLimits
--> if need to scroll
show ProgressDialog "Loading"
--> runOnUiThread (
get new data into table
dismiss ProgressDIalog
)
But still the dismiss message got there before the ProgressDialog could show.
According to Logcat there is a five second interval between the arrival of the SHOW message and the arrival of the DISMISS message.
UPDATE II:
I though I will use the isShowing() method of ProgressDIalog
pd = ProgressDialog.show(...)
while(!pd.isShowing());
But it does not help at all, it returns true even if the dialog is not showing yet.
A friend of mine came to me with this strange behavior which i can't explain, any insight view would be appreciated.
Im running VS 2005 (C# 2.0), the following code show the behavior
int rr = "test".IndexOf("");
Console.WriteLine(rr.ToString());
the above code, print "0" which clearly show it should have return -1
This also happen in Java where the following Class show the behavior:
public class Test{
public static void main(String[] args){
System.out.println("Result->"+("test".indexOf("")));
}
}
Im running Java 1.6.0_17
Hello guys
does anyone know how to convert this SQL statement to a LINQ to a List?
SELECT TOP(5) COUNT(CategoryId), CategoryName
FROM Tickets
GROUP BY CategoryName
The result would be something like
public static List<Categories> List()
{
MyEntities db = new MyEntities();
/* here it should return a list o Category type */;
return db.Category.GroupBy(...).OrderBy(...);
}
Two questions. First question is I'm trying to create a simple form that when you press a button, it adds a Person object to the ArrayList. However, since I am not used to GUIs, I tried creating one and am first just trying to get the user input from the JTextField, create an ActionListener object of the appropriate type, so once that works, then I can pass in all the JTextField inputs to create my Person object. Unfortunately, I am not getting any data when I type in something to the firstName JTextField and was wondering if someone could look at my code below.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.List;
import java.util.ArrayList;
public class AddressBook
{
public static void main(String[] args)
{
EventQueue.invokeLater(new Runnable()
{
public void run()
{
AddressBookFrame frame = new AddressBookFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JMenuBar menuBar = new JMenuBar();
frame.setJMenuBar(menuBar);
JMenu fileMenu = new JMenu("File");
JMenuItem openItem = new JMenuItem("Open");
JMenuItem saveItem = new JMenuItem("Save");
JMenuItem saveAsItem = new JMenuItem("Save As");
JMenuItem printItem = new JMenuItem("Print");
JMenuItem exitItem = new JMenuItem("Exit");
fileMenu.add(openItem);
fileMenu.add(saveItem);
fileMenu.add(saveAsItem);
fileMenu.add(printItem);
fileMenu.add(exitItem);
menuBar.add(fileMenu);
JMenu editMenu = new JMenu("Edit");
JMenuItem newItem = new JMenuItem("New");
JMenuItem editItem = new JMenuItem("Edit");
JMenuItem deleteItem = new JMenuItem("Delete");
JMenuItem findItem = new JMenuItem("Find");
JMenuItem firstItem = new JMenuItem("First");
JMenuItem previousItem = new JMenuItem("Previous");
JMenuItem nextItem = new JMenuItem("Next");
JMenuItem lastItem = new JMenuItem("Last");
editMenu.add(newItem);
editMenu.add(editItem);
editMenu.add(deleteItem);
editMenu.add(findItem);
editMenu.add(firstItem);
editMenu.add(previousItem);
editMenu.add(nextItem);
editMenu.add(lastItem);
menuBar.add(editMenu);
JMenu helpMenu = new JMenu("Help");
JMenuItem documentationItem = new JMenuItem("Documentation");
JMenuItem aboutItem = new JMenuItem("About");
helpMenu.add(documentationItem);
helpMenu.add(aboutItem);
menuBar.add(helpMenu);
frame.setVisible(true);
}
});
}
}
class AddressBookFrame extends JFrame
{
public AddressBookFrame()
{
setLayout(new BorderLayout());
setTitle("Address Book");
setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
AddressBookToolBar toolBar = new AddressBookToolBar();
add(toolBar, BorderLayout.NORTH);
AddressBookStatusBar aStatusBar = new AddressBookStatusBar("5");
add(aStatusBar, BorderLayout.SOUTH);
AddressBookForm form = new AddressBookForm();
add(form, BorderLayout.CENTER);
}
public static final int DEFAULT_WIDTH = 500;
public static final int DEFAULT_HEIGHT = 500;
}
/* Create toolbar buttons and add buttons to toolbar */
class AddressBookToolBar extends JPanel
{
public AddressBookToolBar()
{
setLayout(new FlowLayout(FlowLayout.LEFT));
JToolBar bar = new JToolBar();
JButton newButton = new JButton("New");
JButton editButton = new JButton("Edit");
JButton deleteButton = new JButton("Delete");
JButton findButton = new JButton("Find");
JButton firstButton = new JButton("First");
JButton previousButton = new JButton("Previous");
JButton nextButton = new JButton("Next");
JButton lastButton = new JButton("Last");
bar.add(newButton);
bar.add(editButton);
bar.add(deleteButton);
bar.add(findButton);
bar.add(firstButton);
bar.add(previousButton);
bar.add(nextButton);
bar.add(lastButton);
add(bar);
}
}
/* Creates the status bar string */
class AddressBookStatusBar extends JPanel
{
public AddressBookStatusBar(String statusBarString)
{
setLayout(new FlowLayout(FlowLayout.LEFT));
this.statusBarString = new JLabel("Total number of people: " + statusBarString);
add(this.statusBarString);
}
private JLabel statusBarString;
private int totalContacts;
}
class AddressBookForm extends JPanel
{
public AddressBookForm()
{
this.setLayout(new GridLayout(2, 1));
JPanel formPanel = new JPanel();
formPanel.setLayout(new GridLayout(4, 2));
JTextField firstName = new JTextField(20);
JTextField lastName = new JTextField(20);
JTextField telephone = new JTextField(20);
JTextField email = new JTextField(20);
JLabel firstNameLabel = new JLabel("First Name: ", JLabel.LEFT);
formPanel.add(firstNameLabel);
formPanel.add(firstName);
JLabel lastNameLabel = new JLabel("Last Name: ", JLabel.LEFT);
formPanel.add(lastNameLabel);
formPanel.add(lastName);
JLabel telephoneLabel = new JLabel("Telephone: ", JLabel.LEFT);
formPanel.add(telephoneLabel);
formPanel.add(telephone);
JLabel emailLabel = new JLabel("Email: ", JLabel.LEFT);
formPanel.add(emailLabel);
formPanel.add(email);
add(formPanel);
JPanel buttonPanel = new JPanel();
JButton insertButton = new JButton("Insert");
JButton displayButton = new JButton("Display");
// create button actions
AddressBookManager insertAction = new AddressBookManager(firstName.getText());
insertButton.addActionListener(insertAction);
buttonPanel.add(insertButton);
buttonPanel.add(displayButton);
add(buttonPanel);
}
private List<Person> addressList = new ArrayList<Person>();
private class AddressBookManager implements ActionListener
{
public AddressBookManager(String text)
{
// addressList.add(
setName(text);
System.out.println("Test" + text);
}
public void actionPerformed(ActionEvent e)
{
System.out.println("Hello" + name);
}
public void setName(String name)
{
this.name = name;
}
private String name;
}
}
Second question is, how do I make my form not take up the whole center space. I don't like the stretch look and was hoping the JTextFields could be just one line long, not a big box. Same thing with the buttons. Any thoughts? Thanks.
This is very similar to a question I asked the other day but my page code has become significantly more complicated and I need to revisit it. I've been using the following code:
$('#myLink').click(function() {
$('#myImg').attr('src', 'newImg.jpg');
setTimeout(function() { $('#myImg').attr('src', 'oldImg.jpg'); }, 15000);
});
To replace an image for a set period of time (15 seconds) when the link is clicked, then after 15 seconds, revert to the original image.
However now, I'd like to run a snippet of javascript as well when the link is clicked (in addition to replacing the image), and only when the link is clicked (it's related to the 15 second image) and then have the js code disappear as well after the 15 seconds...however I'm not sure how to have jquery send js code into the page...Basically I just want jQuery to "echo" this code onto the page underneath the 15 second while I am there, but I don't know how jquery formats this "echo".
Does this question make sense?
interval = 500;
imgsrc = "webcam/image.jpg";
function Refresh() {
tmp = new Date();
tmp = "?" + tmp.getTime();
document.images["image1"].src = imgsrc + tmp;
setTimeout("Refresh()", interval);
}
Refresh();
It's script for a webcam. Basically it takes a new picture every half a second and replaces it on the page. You must forgive me, I'm new to jquery, I don't know how to make this script work in a jquery context.
i'm sorry, I'm explaining badly. This is what I need to happen, step by step:
1) User comes to the page and there is a static image that says "Click here to view webcam"
2) User clicks image
3) Image is replaced by live webcam image, which is refreshed every .5 seconds by the second script in my question.
4) After 15 seconds the live webcam reverts back to the static image saying "click here to view webcam"
It is ONLY during that 15 second interval that I wan the webcam refresh script running, otherwise it's wasting bandwidth on an element that isn't even shown. Sorry for the confusion.
A Java method call may be parameterized like in the following code:
class Test
{
<T> void test()
{
}
public static void main(String[] args)
{
new Test().<Object>test();
// ^^^^^^^^
}
}
I found out this is possible from the Eclipse Java Formatter settings dialog and wondered if there are any cases where this is useful or required.
I am in need of some help with trying to figure out how to go about checking the users session and seeing if they are still logged in or not.
The problem being is because i have a static page that pretty much loads everything into "tabs" using jquery. So when the user navigates the page, it really never leaves that same page they started out on. Hints my problem in trying to determine if they are still logged in or not when they click on update their information on their profile or whatnot.
In the setup of my test cases, I have this code:
ApplicationContext context = new ClassPathXmlApplicationContext(
"spring/common.xml"
);
StaticListableBeanFactory testBeanFactory = new StaticListableBeanFactory();
How do I connect the two in such a way that tests can register beans in the testBeanFactory during setup and the rest of the application uses them instead of the ones defined in common.xml?
Note: I need to mix a static (common.xml) and a dynamic configuration. I can't use XML for the latter because that would mean to write 1000 XML files.
I am trying to make a image viewer/album creator in visual studio, wpf. The image paths for each album is stored in an xml document which i bind to to show the images from each album in a listbox.
The problem is when i add a image or an album at runtime and write it to the xml document. I can't seem to make the bindings to the xml document update so they show the new images and albums aswell.
Calling Refresh() on the XmlDataProvider doesn't change anything.
I don't wish to redo the binding of the XmlDataProvider, just make it read from the same source again.
XAML:
...
<Grid.DataContext>
<XmlDataProvider x:Name="Images" Source="Data/images.xml" XPath="/albums/album[@name='no album']/image" />
</Grid.DataContext>
...
<Label Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Bottom" Padding="0" Margin="0,0,0,5" Content="{x:Static resx:Resource.AddImageLabel}"/>
<TextBox Grid.Row="1" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Name="newImagePath" Margin="0" />
<Button Grid.Row="1" Grid.Column="2" HorizontalAlignment="Left" VerticalAlignment="Bottom" Name="newImagePathButton" Content="{x:Static resx:Resource.BrowseImageButton}" Click="newImagePathButton_Click" />
...
<ListBox Grid.Column="0" Grid.ColumnSpan="4" Grid.Row="3" HorizontalAlignment="Stretch" Name="thumbnailList" VerticalAlignment="Bottom" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding BindingGroupName=Images}" SelectedIndex="0" Background="#FFE0E0E0" Height="110">
...
Code behind:
private void newImagePathButton_Click(object sender, RoutedEventArgs e)
{
string imagePath = newImagePath.Text;
albumCreator.addImage(imagePath, null);
//Reset import image elements to default
newImagePath.Text = "";
//Refresh thumbnail listbox
Images.Refresh();
Console.WriteLine("Image added!");
}
public void addImage(string source, XmlElement parent)
{
if (parent == null)
{
//Use default album
parent = (XmlElement)root.FirstChild;
}
//Create image element with source element within
XmlElement newImage = xmlDoc.CreateElement(null, "image", null);
XmlElement newSource = xmlDoc.CreateElement(null, "source", null);
newSource.InnerText = source;
newImage.AppendChild(newSource);
//Add image element to parent
parent.AppendChild(newImage);
xmlDoc.Save(xmlFile);
}
Thank you very much for any help!