Search Results

Search found 182 results on 8 pages for 'pd'.

Page 3/8 | < Previous Page | 1 2 3 4 5 6 7 8  | Next Page >

  • Printing in Silverlight 4

    - by Number8
    Hello, We have an application structured roughly like this: <Grid x:Name="LayoutRoot"> <ScrollViewer> <Canvas x:Name="canvas"> <StackPanel> < Button /><Slider /><Button /></StackPanel> <custom:Blob /> <custom:Blob /> <custom:Blob /> </Canvas> </ScrollViewer> </Grid> Each Blob consists of 1 or more rectangles, lines, and text boxes; they are positioned anywhere on the canvas. If I print the document using the LayoutRoot: PrintDocument pd = new PrintDocument(); pd += (s, pe) => { pe.PageVisual = LayoutRoot; }; pd.Print("Blobs"); ... it is like a print-screen -- the scrollbars, the sliders, the blobs that are visible -- are printed. If I set PageVisual = canvas, nothing is printed. How can I get all the blob objects, and just those objects, to print? Do I need to copy them into another container, and give that container to PageVisual? Can I use a ViewBox to make sure they all fit on one page? Thanks for any pointers....

    Read the article

  • Make datalist into 3 x 3

    - by unknown
    This is my code behind for products page. The prodblem is that my datalist will fill in new items whenever I add a new object in the website. So may I know how to add the codes in so that I can make the datalist into 3x3. Thanks. Code behind Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim Product As New Product Dim DataSet As New DataSet Dim pds As New PagedDataSource DataSet = Product.GetProduct Session("Dataset") = DataSet pds.PageSize = 4 pds.AllowPaging = True pds.CurrentPageIndex = 1 Session("Page") = pds If Not Page.IsPostBack Then UpdateDatabind() End If End Sub Sub UpdateDatabind() Dim DataSet As DataSet = Session("DataSet") If DataSet.Tables(0).Rows.Count > 0 Then pds.DataSource = DataSet.Tables(0).DefaultView Session("Page") = pds dlProducts.DataSource = DataSet.Tables(0).DefaultView dlProducts.DataBind() lblCount.Text = DataSet.Tables(0).Rows.Count End If End Sub Private Sub dlProducts_UpdateCommand(source As Object, e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles dlProducts.UpdateCommand dlProducts.DataBind() End Sub Public Sub PrevNext_Command(source As Object, e As CommandEventArgs) Dim pds As PagedDataSource = Session("Page") Dim CurrentPage = pds.CurrentPageIndex If e.CommandName = "Previous" Then If CurrentPage < 1 Or CurrentPage = pds.IsFirstPage Then CurrentPage = 1 Else CurrentPage -= 1 End If UpdateDatabind() ElseIf e.CommandName = "Next" Then If CurrentPage > pds.PageCount Or CurrentPage = pds.IsLastPage Then CurrentPage = CurrentPage Else CurrentPage += 1 End If UpdateDatabind() End If Response.Redirect("Products.aspx?PageIndex=" & CurrentPage) End Sub this is my code for product.vb Public Function GetProduct() As DataSet Dim strConn As String strConn = ConfigurationManager.ConnectionStrings("HomeFurnitureConnectionString").ToString Dim conn As New SqlConnection(strConn) Dim strSql As String 'strSql = "SELECT * FROM Product p INNER JOIN ProductDetail pd ON p.ProdID = pd.ProdID " & _ ' "WHERE pd.PdColor = (SELECT min(PdColor) FROM ProductDetail as pd1 WHERE pd1.ProdID = p.ProdID)" Dim cmd As New SqlCommand(strSql, conn) Dim ds As New DataSet Dim da As New SqlDataAdapter(cmd) conn.Open() da.Fill(ds) conn.Close() Return ds End Function

    Read the article

  • Why can't add a hot spare in freebsd? Can anybody help me fix it?

    - by hamlet
    Why can't add a hot spare? Can anybody help me fix it? mfiutil add e1:s1 mfid0 mfiutil: Drive 1 is not available My mfi status:: mfiutil show config mfi0 Configuration: 1 arrays, 1 volumes, 0 spares array 0 of 2 drives: drive 0 ( 137G) ONLINE <HITACHI HUS153014VLS300 A410 serial=JFWHSB4C> SAS enclosure 1, slot 0 drive 1 ( 137G) ONLINE <HITACHI HUS153014VLS300 A410 serial=JFWJ3AEC> SAS enclosure 1, slot 1 volume mfid0 (136G) RAID-1 64K OPTIMAL spans: array 0 mfiutil show events 1468 (boot + 25s/BATTERY/WARN) - Battery removed 1475 (boot + 52s/DRIVE/WARN) - PD 00(e1/s0) is not a certified drive 1478 (boot + 52s/DRIVE/WARN) - PD 01(e1/s1) is not a certified drive 1480 (boot + 64s/BATTERY/WARN) - BBU disabled; changing WB virtual disks to WT mfiutil show volumes mfi0 Volumes: Id Size Level Stripe State Cache Name mfid0 ( 136G) RAID-1 64K OPTIMAL Disabled

    Read the article

  • Android ProgressDialog Progress Bar doing things in the right order

    - by FauxReal
    I just about got this, but I have a small problem in the order of things going off. Specifically, in my thread() I am setting up an array that is used by a Spinner. Problem is the Spinner is all set and done basically before my thread() is finished, so it sets itself up with a null array. How do I associate the spinners ArrayAdapter with an array that is being loaded by another thread? I've cut the code down to what I think is necessary to understand the problem, but just let me know if more is needed. The problem occurs whether or not refreshData() is called. Along the same lines, sometimes I want to call loadData() from the menu. Directly following loadData() if I try to fire a toast on the next line this causes a forceclose, which is also because of how I'm implementing ProgressDialog. THANK YOU FOR LOOKING public class CMSHome extends Activity { private static List<String> pmList = new ArrayList<String>(); // Instantiate helpers PMListHelper plh = new PMListHelper(); ProjectObjectHelper poc = new ProjectObjectHelper(); // These objects hold lists and methods for dealing with them private Employees employees; private Projects projects; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Loads data from filesystem, or webservice if necessary loadData(); // Capture spinner and associate pmList with it through ArrayAdapter spinner = (Spinner) findViewById(R.id.spinner); ArrayAdapter<String> adapter = new ArrayAdapter<String>( this, android.R.layout.simple_spinner_item, pmList); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); //---the button is wired to an event handler--- Button btn1 = (Button)findViewById(R.id.btnGetProjects); btn1.setOnClickListener(btnListAllProjectsListener); spinner.setOnItemSelectedListener(new MyOnItemSelectedListener()); } private void loadData() { final ProgressDialog pd = ProgressDialog.show(this, "Please wait", "Loading Data...", true, false); new Thread(new Runnable(){ public void run(){ employees = plh.deserializeEmployeeData(); projects = poc.deserializeProjectData(); // Check to see if data actually loaded, if not then refresh if ((employees == null) || (projects == null)) { refreshData(); } // Load up pmList for spinner control pmList = employees.getPMList(); pd.dismiss(); } }).start(); } private void refreshData() { // Refresh data for Projects projects = poc.refreshData(); poc.saveProjectData(mCtx, projects); // Refresh data for PMList employees = plh.refreshData(); plh.savePMData(mCtx, employees); } } <---- EDIT ----- I tried changing loadData() to the following after Jims suggestion. Not sure if I did this right, still doesn't work: private void loadData() { final ProgressDialog pd = ProgressDialog.show(this, "Please wait", "Loading Data...", true, false); new Thread(new Runnable(){ public void run(){ employees = plh.deserializeEmployeeData(); projects = poc.deserializeProjectData(); // Check to see if data actually loaded, if not return false if ((employees == null) || (projects == null)) { refreshData(); } pd.dismiss(); runOnUiThread(new Runnable() { public void run(){ // Load up pmList for spinner control pmList = employees.getPMList(); } }); } }).start(); }

    Read the article

  • SQL Server 2008: Using Multiple dts Ranges to Build a Set of Dates

    - by raoulcousins
    I'm trying to build a query for a medical database that counts the number of patients that were on at least one medication from a class of medications (the medications listed below in the FAST_MEDS CTE) and had either: 1) A diagnosis of myopathy (the list of diagnoses in the FAST_DX CTE) 2) A CPK lab value above 1000 (the lab value in the FAST_LABS CTE) and this diagnosis or lab happened AFTER a patient was on a statin. The query I've included below does that under the assumption that once a patient is on a statin, they're on a statin forever. The first CTE collects the ids of patients that were on a statin along with the first date of their diagnosis, the second those with a diagnosis, and the third those with a high lab value. After this I count those that match the above criteria. What I would like to do is drop the assumption that once a patient is on a statin, they're on it for life. The table edw_dm.patient_medications has a column called start_dts and end_dts. This table has one row for each prescription written, with start_dts and end_dts denoting the start and end date of the prescription. End_dts could be null, which I'll take to assume that the patient is currently on this medication (it could be a missing record, but I can't do anything about this). If a patient is on two different statins, the start and ends dates can overlap, and there may be multiple records of the same medication for a patient, as in a record showing 3-11-2000 to 4-5-2003 and another for the same patient showing 5-6-2007 to 7-8-2009. I would like to use these two columns to build a query where I'm only counting the patients that had a lab value or diagnosis done during a time when they were already on a statin, or in the first n (say 3) months after they stopped taking a statin. I'm really not sure how to go about rewriting the first CTE to get this information and how to do the comparison after the CTEs are built. I know this is a vague question, but I'm really stumped. Any ideas? As always, thank you in advance. Here's the current query: WITH FAST_MEDS AS ( select distinct statins.mrd_pt_id, min(year(statins.order_dts)) as statin_yr from edw_dm.patient_medications as statins inner join mrd.medications as mrd on statins.mrd_med_id = mrd.mrd_med_id WHERE mrd.generic_nm in ( 'Lovastatin (9664708500)', 'lovastatin-niacin', 'Lovastatin/Niacin', 'Lovastatin', 'Simvastatin (9678583966)', 'ezetimibe-simvastatin', 'niacin-simvastatin', 'ezetimibe/Simvastatin', 'Niacin/Simvastatin', 'Simvastatin', 'Aspirin Buffered-Pravastatin', 'aspirin-pravastatin', 'Aspirin/Pravastatin', 'Pravastatin', 'amlodipine-atorvastatin', 'Amlodipine/atorvastatin', 'atorvastatin', 'fluvastatin', 'rosuvastatin' ) and YEAR(statins.order_dts) IS NOT NULL and statins.mrd_pt_id IS NOT NULL group by statins.mrd_pt_id ) select * into #meds from FAST_MEDS ; --return patients who had a diagnosis in the list and the year that --diagnosis was given with FAST_DX AS ( SELECT pd.mrd_pt_id, YEAR(pd.init_noted_dts) as init_yr FROM edw_dm.patient_diagnoses as pd inner join mrd.diagnoses as mrd on pd.mrd_dx_id = mrd.mrd_dx_id and mrd.icd9_cd in ('728.89','729.1','710.4','728.3','729.0','728.81','781.0','791.3') ) select * into #dx from FAST_DX; --return patients who had a high cpk value along with the year the cpk --value was taken with FAST_LABS AS ( SELECT pl.mrd_pt_id, YEAR(pl.order_dts) as lab_yr FROM edw_dm.patient_labs as pl inner join mrd.labs as mrd on pl.mrd_lab_id = mrd.mrd_lab_id and mrd.lab_nm = 'CK (CPK)' WHERE pl.lab_val between 1000 AND 999998 ) select * into #labs from FAST_LABS; -- count the number of patients who had a lab value or a medication -- value taken sometime AFTER their initial statin diagnosis select count(distinct p.mrd_pt_id) as ct from mrd.patient_demographics as p join #meds as m on p.mrd_pt_id = m.mrd_pt_id AND ( EXISTS ( SELECT 'A' FROM #labs l WHERE p.mrd_pt_id = l.mrd_pt_id and l.lab_yr >= m.statin_yr ) OR EXISTS( SELECT 'A' FROM #dx d WHERE p.mrd_pt_id = d.mrd_pt_id AND d.init_yr >= m.statin_yr ) )

    Read the article

  • Serializing WPF DataTemplates and {Binding Expressions} (from PowerShell?)

    - by Jaykul
    Ok, here's the deal: I have code that works in C#, but when I call it from PowerShell, it fails. I can't quite figure it out, but it's something specific to PowerShell. Here's the relevant code calling the library (assuming you've added a reference ahead of time) from C#: public class Test { [STAThread] public static void Main() { Console.WriteLine( PoshWpf.XamlHelper.RoundTripXaml( "<TextBlock Text=\"{Binding FullName}\" xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"/>" ) ); } } Compiled into an executable, that works fine ... but if you call that method from PowerShell, it returns with no {Binding FullName} for the Text! add-type -path .\PoshWpf.dll [PoshWpf.Test]::Main() I've pasted below the entire code for the library, all wrapped up in a PowerShell Add-Type call so you can just compile it by pasting it into PowerShell (you can leave off the first and last lines if you want to paste it into a new console app in Visual Studio. To output (from PowerShell 2) as an executable, just change the -OutputType parameter to ConsoleApplication and the -OutputAssembly to PoshWpf.exe (or something). Thus, you can see that running the SAME CODE from the executable gives you the correct output. But running the two lines as above or manually calling [PoshWpf.XamlHelper]::RoundTripXaml or [PoshWpf.XamlHelper]::ConvertToXaml from PowerShell just doesn't seem to work at all ... HELP?! Add-Type -TypeDefinition @" using System; using System.ComponentModel; using System.Globalization; using System.Linq; using System.Windows; using System.Windows.Data; using System.Windows.Markup; namespace PoshWpf { public class Test { [STAThread] public static void Main() { Console.WriteLine( PoshWpf.XamlHelper.RoundTripXaml( "<TextBlock Text=\"{Binding FullName}\" xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"/>" ) ); } } public class BindingTypeDescriptionProvider : TypeDescriptionProvider { private static readonly TypeDescriptionProvider _DEFAULT_TYPE_PROVIDER = TypeDescriptor.GetProvider(typeof(Binding)); public BindingTypeDescriptionProvider() : base(_DEFAULT_TYPE_PROVIDER) { } public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance) { ICustomTypeDescriptor defaultDescriptor = base.GetTypeDescriptor(objectType, instance); return instance == null ? defaultDescriptor : new BindingCustomTypeDescriptor(defaultDescriptor); } } public class BindingCustomTypeDescriptor : CustomTypeDescriptor { public BindingCustomTypeDescriptor(ICustomTypeDescriptor parent) : base(parent) { } public override PropertyDescriptorCollection GetProperties(Attribute[] attributes) { PropertyDescriptor pd; var pdc = new PropertyDescriptorCollection(base.GetProperties(attributes).Cast<PropertyDescriptor>().ToArray()); if ((pd = pdc.Find("Source", false)) != null) { pdc.Add(TypeDescriptor.CreateProperty(typeof(Binding), pd, new Attribute[] { new DefaultValueAttribute("null") })); pdc.Remove(pd); } return pdc; } } public class BindingConverter : ExpressionConverter { public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { return (destinationType == typeof(MarkupExtension)) ? true : false; } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(MarkupExtension)) { var bindingExpression = value as BindingExpression; if (bindingExpression == null) throw new Exception(); return bindingExpression.ParentBinding; } return base.ConvertTo(context, culture, value, destinationType); } } public static class XamlHelper { static XamlHelper() { // this is absolutely vital: TypeDescriptor.AddProvider(new BindingTypeDescriptionProvider(), typeof(Binding)); TypeDescriptor.AddAttributes(typeof(BindingExpression), new Attribute[] { new TypeConverterAttribute(typeof(BindingConverter)) }); } public static string RoundTripXaml(string xaml) { return XamlWriter.Save(XamlReader.Parse(xaml)); } public static string ConvertToXaml(object wpf) { return XamlWriter.Save(wpf); } } } "@ -language CSharpVersion3 -reference PresentationCore, PresentationFramework, WindowsBase -OutputType Library -OutputAssembly PoshWpf.dll Again, you can get an executable by just altering the last line like so: "@ -language CSharpVersion3 -reference PresentationCore, PresentationFramework, WindowsBase -OutputType ConsoleApplication -OutputAssembly PoshWpf.exe

    Read the article

  • Leveraging .Net 4.0 Framework Tools For Encrypting Web Configuration Sections

    - by Sam Abraham
    I would like to share a few points with regards to encrypting web configuration sections in .Net 4.0. This information is also applicable to .Net 3.5 and 2.0. Two methods can work perfectly for encrypting connection strings in a Web project configuration file:   1-Do It All Yourself! In this approach, helper functions for encrypting/decrypting configuration file content are implemented. Program would explicitly retrieve appropriate content from configuration file then decrypt it appropriately.  Disadvantages of this implementation would be the added overhead for maintaining the encryption/decryption code as well the burden of always ensuring sections are appropriately decrypted before use and encrypted appropriately whenever edited.   2- Leverage the .Net 4.0 Framework (The Way to go!) Fortunately, all needed tools for protecting configuration files are built-in to the .Net 2.0/3.5/4.0 versions with very little setup needed. To encrypt connection strings, one can use the ASP.Net IIS Registration Tool (Aspnet_regiis.exe). Note that a 64-bit version of the tool also exists under the Framework64 folder for 64-bit systems. The command we need to encrypt our web.config file connection strings is simply the following:   Aspnet_regiis –pe “connectionstrings” –app “/sampleApplication” –prov “RsaProtectedConfigurationProvider”   To later decrypt this configuration section:   Aspnet_regiis –pd “connectionstrings” –app “/SampleApplication”   The following is a brief description of the command line options used in the example above. Aspnet_regiis supports many more options which you can read about in the links provided for reference below.   Option Description -pe  Section name to encrypt -pd  Section name to decrypt -app  Web application name -prov  Encryption/Decryption provider   ASP.Net automatically decrypts the content of the Web.Config file at runtime so no programming changes are needed.   Another tool, aspnet_setreg.exe is to be used if certain configuration file sections pertinent to the .Net runtime are to be encrypted. For more information on when and how to use aspnet_setreg, please refer to the references below.   Hope this helps!   Some great references concerning the topic:   http://msdn.microsoft.com/en-us/library/ff650037.aspx http://msdn.microsoft.com/en-us/library/zhhddkxy.aspx http://msdn.microsoft.com/en-us/library/dtkwfdky.aspx http://msdn.microsoft.com/en-us/library/68ze1hb2.aspx

    Read the article

  • How to sort & Group in Android?

    - by crickpatel0024
    I have ArrayList and I want to sort and group all data by header in Android. How it is possible in Android? please help me.below me from owner And set header Me And Joe Manager From owner And set Header in listview. How to do that in Android? My code in below:: public class Request extends Activity { private String assosiatetoken; private ArrayList<All_Request_data_dto> list = new ArrayList<All_Request_data_dto>(); ListView lv; Button back; private Spinner spndata; String[] reqspinner = { "Request Date", "Last Update", "Type", "Owner", "State" }; ArrayAdapter<String> adapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.request); assosiatetoken = MyApplication.getToken(); new doinbackground(this).execute(); back = (Button) findViewById(R.id.button1); spndata = (Spinner) findViewById(R.id.list_all_quize_req); adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, reqspinner); spndata.setAdapter(adapter); lv = (ListView) findViewById(R.id.listrequestdata); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> a, View v, int position, long id) { Intent edit = new Intent(Request.this, Request_webview.class); // edit.putExtra("Cat_url", url_link); startActivity(edit); } }); spndata.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long arg3) { switch (position) { case 0: list = DBAdpter.requestUserData(assosiatetoken); Collections.sort(list, byDate1); // Collections.reverse(list); for (int i = 0; i < list.size(); i++) { if (list.get(i).submitDate != null) { lv.setAdapter(new MyListAdapter( getApplicationContext(), list)); } } break; case 1: list = DBAdpter.requestUserData(assosiatetoken); Collections.sort(list, byDate); for (int i = 0; i < list.size(); i++) { if (list.get(i).lastModifiedDate != null) { lv.setAdapter(new MyListAdapter( getApplicationContext(), list)); } } break; case 2: list = DBAdpter.requestUserData(assosiatetoken); Collections.sort(list, byDate3); // Collections.reverse(list); for (int i = 0; i < list.size(); i++) { if (list.get(i).state != null) { lv.setAdapter(new MyListAdapter( getApplicationContext(), list)); } } break; case 3: list = DBAdpter.requestUserData(assosiatetoken); for (int i = 0; i < list.size(); i++) { lv.setAdapter(new MyListAdapter( getApplicationContext(), list)); } break; default: break; } } public void onNothingSelected(AdapterView<?> arg0) { } }); back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); } static final Comparator<All_Request_data_dto> byDate = new Comparator<All_Request_data_dto>() { SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a"); public int compare(All_Request_data_dto ord1, All_Request_data_dto ord2) { java.util.Date d1 = null; java.util.Date d2 = null; try { d1 = sdf.parse(ord1.lastModifiedDate); d2 = sdf.parse(ord2.lastModifiedDate); } catch (java.text.ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } return (d1.getTime() > d2.getTime() ? -1 : 1); // descending // return (d1.getTime() > d2.getTime() ? 1 : -1); //ascending } }; static final Comparator<All_Request_data_dto> byDate1 = new Comparator<All_Request_data_dto>() { SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a"); public int compare(All_Request_data_dto ord1, All_Request_data_dto ord2) { java.util.Date d1 = null; java.util.Date d2 = null; try { d1 = sdf.parse(ord1.submitDate); d2 = sdf.parse(ord2.submitDate); } catch (java.text.ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } return (d1.getTime() > d2.getTime() ? -1 : 1); // descending // return (d1.getTime() > d2.getTime() ? 1 : -1); //ascending } }; static final Comparator<All_Request_data_dto> byDate3 = new Comparator<All_Request_data_dto>() { public int compare(All_Request_data_dto ord1, All_Request_data_dto ord2) { String d1 = null; String d2 = null; d1 = ord1.state; d2 = ord2.state; return d1.compareToIgnoreCase(d2); } }; class doinbackground extends AsyncTask<Void, Void, Void> { ProgressDialog pd; private Context ctx; public doinbackground(Context c) { ctx = c; } @Override protected void onPreExecute() { super.onPreExecute(); pd = new ProgressDialog(ctx); pd.setMessage("Loading..."); pd.show(); } @Override protected Void doInBackground(Void... Params) { return null; } @Override protected void onPostExecute(Void result) { super.onPostExecute(result); pd.cancel(); } } public class MyListAdapter extends BaseAdapter { private ArrayList<All_Request_data_dto> list; public MyListAdapter(Context mContext, ArrayList<All_Request_data_dto> list) { this.list = list; } public int getCount() { return list.size(); } public All_Request_data_dto getItem(int position) { return list.get(position); } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { // if (convertView == null) { LayoutInflater inflator = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); convertView = inflator.inflate(R.layout.custom_request_data, null); TextView req_id = (TextView) convertView.findViewById(R.id.req_txt); TextView date = (TextView) convertView.findViewById(R.id.date_txt); TextView owner = (TextView) convertView .findViewById(R.id.owner_txt); TextView state = (TextView) convertView .findViewById(R.id.state_txt); req_id.setText(list.get(position).requestId + " - " + list.get(position).title); date.setText(list.get(position).lastModifiedDate + " - " + list.get(position).submitDate); owner.setText(list.get(position).owner); state.setText(list.get(position).state); // } return convertView; } } }

    Read the article

  • Find only physical network adapters with WMI Win32_NetworkAdapter class

    - by Mladen Prajdic
    WMI is Windows Management Instrumentation infrastructure for managing data and machines. We can access it by using WQL (WMI querying language or SQL for WMI). One thing to remember from the WQL link is that it doesn't support ORDER BY. This means that when you do SELECT * FROM wmiObject, the returned order of the objects is not guaranteed. It can return adapters in different order based on logged-in user, permissions of that user, etc… This is not documented anywhere that I've looked and is derived just from my observations. To get network adapters we have to query the Win32_NetworkAdapter class. This returns us all network adapters that windows detect, real and virtual ones, however it only supplies IPv4 data. I've tried various methods of combining properties that are common on all systems since Windows XP. The first thing to do to remove all virtual adapters (like tunneling, WAN miniports, etc…) created by Microsoft. We do this by adding WHERE Manufacturer!='Microsoft' to our WMI query. This greatly narrows the number of adapters we have to work with. Just on my machine it went from 20 adapters to 5. What was left were one real physical Realtek LAN adapter, 2 virtual adapters installed by VMware and 2 virtual adapters installed by VirtualBox. If you read the Win32_NetworkAdapter help page you'd notice that there's an AdapterType that enumerates various adapter types like LAN or Wireless and AdapterTypeID that gives you the same information as AdapterType only in integer form. The dirty little secret is that these 2 properties don't work. They are both hardcoded, AdapterTypeID to "0" and AdapterType to "Ethernet 802.3". The only exceptions I've seen so far are adapters that have no values at all for the two properties, "RAS Async Adapter" that has values of AdapterType = "Wide Area Network" and AdapterTypeID = "3" and various tunneling adapters that have values of AdapterType = "Tunnel" and AdapterTypeID = "15". In the help docs there isn't even a value for 15. So this property was of no help. Next property to give hope is NetConnectionId. This is the name of the network connection as it appears in the Control Panel -> Network Connections. Problem is this value is also localized into various languages and can have different names for different connection. So both of these properties don't help and we haven't even started talking about eliminating virtual adapters. Same as the previous one this property was also of no help. Next two properties I checked were ConfigManagerErrorCode and NetConnectionStatus in hopes of finding disabled and disconnected adapters. If an adapter is enabled but disconnected the ConfigManagerErrorCode = 0 with different NetConnectionStatus. If the adapter is disabled it reports ConfigManagerErrorCode = 22. This looked like a win by using (ConfigManagerErrorCode=0 or ConfigManagerErrorCode=22) in our condition. This way we get enabled (connected and disconnected adapters). Problem with all of the above properties is that none of them filter out the virtual adapters installed by virtualization software like VMware and VirtualBox. The last property to give hope is PNPDeviceID. There's an interesting observation about physical and virtual adapters with this property. Every virtual adapter PNPDeviceID starts with "ROOT\". Even VMware and VirtualBox ones. There were some really, really old physical adapters that had PNPDeviceID starting with "ROOT\" but those were in pre win XP era AFAIK. Since my minimum system to check was Windows XP SP2 I didn't have to worry about those. The only virtual adapter I've seen to not have PNPDeviceID start with "ROOT\" is the RAS Async Adapter for Wide Area Network. But because it is made by Microsoft we've eliminated it with the first condition for the manufacturer. Using the PNPDeviceID has so far proven to be really effective and I've tested it on over 20 different computers of various configurations from Windows XP laptops with wireless and bluetooth cards to virtualized Windows 2008 R2 servers. So far it always worked as expected. I will appreciate you letting me know if you find a configuration where it doesn't work. Let's see some C# code how to do this: ManagementObjectSearcher mos = null;// WHERE Manufacturer!='Microsoft' removes all of the // Microsoft provided virtual adapters like tunneling, miniports, and Wide Area Network adapters.mos = new ManagementObjectSearcher(@"SELECT * FROM Win32_NetworkAdapter WHERE Manufacturer != 'Microsoft'");// Trying the ConfigManagerErrorCode and NetConnectionStatus variations // proved to still not be enough and it returns adapters installed by // the virtualization software like VMWare and VirtualBox// ConfigManagerErrorCode = 0 -> Device is working properly. This covers enabled and/or disconnected devices// ConfigManagerErrorCode = 22 AND NetConnectionStatus = 0 -> Device is disabled and Disconnected. // Some virtual devices report ConfigManagerErrorCode = 22 (disabled) and some other NetConnectionStatus than 0mos = new ManagementObjectSearcher(@"SELECT * FROM Win32_NetworkAdapter WHERE Manufacturer != 'Microsoft' AND (ConfigManagerErrorCode = 0 OR (ConfigManagerErrorCode = 22 AND NetConnectionStatus = 0))");// Final solution with filtering on the Manufacturer and PNPDeviceID not starting with "ROOT\"// Physical devices have PNPDeviceID starting with "PCI\" or something else besides "ROOT\"mos = new ManagementObjectSearcher(@"SELECT * FROM Win32_NetworkAdapter WHERE Manufacturer != 'Microsoft' AND NOT PNPDeviceID LIKE 'ROOT\\%'");// Get the physical adapters and sort them by their index. // This is needed because they're not sorted by defaultIList<ManagementObject> managementObjectList = mos.Get() .Cast<ManagementObject>() .OrderBy(p => Convert.ToUInt32(p.Properties["Index"].Value)) .ToList();// Let's just show all the properties for all physical adapters.foreach (ManagementObject mo in managementObjectList){ foreach (PropertyData pd in mo.Properties) Console.WriteLine(pd.Name + ": " + (pd.Value ?? "N/A"));}   That's it. Hope this helps you in some way.

    Read the article

  • hp -ux remote cpio copy

    - by soField
    REMOTE SERVER remsh remoteserverhostname -l remoteusername find /tmp/a1/ | cpio -o > /tmp/paketr.cpio LOCAL SERVER rcp remoteserverhostname:/tmp/paketr.cpio /tmp/aaa cpio -idmv < /tmp/paketr.cpio i'am trying to get and create directory structure from remote server to local server i can do this with following command list but i wonder if i can do this with just one command by running cpio with pass-through mode remsh remoteserverhostname find /tmp/a1 | cpio -pd /tmp current </tmp/tmp/a1/b1/y1> newer current </tmp/tmp/a1/b1/z1> newer current </tmp/tmp/a1/b2/l2smc> newer "/tmp/a1/b3": No such file or directory Cannot stat </tmp/a1/b3>. 0 blocks so when i try to cpio -pd option , i am expecting it to create directories for me but it does not i was using rcp but its not preserving symbolic links :( what can i do ? hp-ux

    Read the article

  • remote cpio copy

    - by soField
    remsh remoteserverhostname -l remoteusername find /tmp/a1/ | cpio -o > /tmp/paketr.cpio rcp remoteserverhostname:/tmp/paketr.cpio /tmp/aaa cpio -idmv < /tmp/paketr.cpio i'am trying to get and create directory structure from remote server to local server i can do this with following command list but i wonder if i can do this with just one command by running cpio with pass-through mode remsh remoteserverhostname find /tmp/a1 | cpio -pd /tmp current </tmp/tmp/a1/b1/y1> newer current </tmp/tmp/a1/b1/z1> newer current </tmp/tmp/a1/b2/l2smc> newer "/tmp/a1/b3": No such file or directory Cannot stat </tmp/a1/b3>. 0 blocks so when i try to cpio -pd option , i am expecting it to create directories for me but it does not what can i do ?

    Read the article

  • Android: Memory leak due to AsyncTask

    - by Manu
    Hello, I'm stuck with a memory leak that I cannot fix. I identified where it occurs, using the MemoryAnalizer but I vainly struggle to get rid of it. Here is the code: public class MyActivity extends Activity implements SurfaceHolder.Callback { ... Camera.PictureCallback mPictureCallbackJpeg = new Camera.PictureCallback() { public void onPictureTaken(byte[] data, Camera c) { try { // log the action Log.e(getClass().getSimpleName(), "PICTURE CALLBACK JPEG: data.length = " + data); // Show the ProgressDialog on this thread pd = ProgressDialog.show(MyActivity.this, "", "Préparation", true, false); // Start a new thread that will manage the capture new ManageCaptureTask().execute(data, c); } catch(Exception e){ AlertDialog.Builder dialog = new AlertDialog.Builder(MyActivity.this); ... dialog.create().show(); } } class ManageCaptureTask extends AsyncTask<Object, Void, Boolean> { protected Boolean doInBackground(Object... args) { Boolean isSuccess = false; // initialize the bitmap before the capture ((myApp) getApplication()).setBitmapX(null); try{ // Check if it is a real device or an emulator TelephonyManager telmgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); String deviceID = telmgr.getDeviceId(); boolean isEmulator = "000000000000000".equalsIgnoreCase(deviceID); // get the bitmap if (isEmulator) { ((myApp) getApplication()).setBitmapX(BitmapFactory.decodeFile(imageFileName)); } else { ((myApp) getApplication()).setBitmapX(BitmapFactory.decodeByteArray((byte[]) args[0], 0, ((byte[])args[0]).length)); } ((myApp) getApplication()).setImageForDB(ImageTools.resizeBmp(((myApp) getApplication()).getBmp())); // convert the bitmap into a grayscale image and display it in the preview ((myApp) getApplication()).setImage(makeGrayScale()); isSuccess = true; } catch (Exception connEx){ errorMessageFromBkgndThread = getString(R.string.errcapture); } return isSuccess; } protected void onPostExecute(Boolean result) { // Pass the result data back to the main activity if (MyActivity.this.pd != null) { MyActivity.this.pd.dismiss(); } if (result){ ((ImageView) findViewById(R.id.apercu)).setImageBitmap(((myApp) getApplication()).getBmp()); ((myApp) getApplication()).setBitmapX(null); } else{ // there was an error ErrAlert(); } } } }; private void ErrAlert(){ // notify the user about the error AlertDialog.Builder dialog = new AlertDialog.Builder(this); ... dialog.create().show(); } } MemoryAnalyzer indicated the memory leak at: ((myApp) getApplication()).setBitmapX(BitmapFactory.decodeByteArray((byte[]) args[0], 0, ((byte[])args[0]).length)); I am grateful for any suggestion, thank you in advance.

    Read the article

  • android: showing a progress dialog

    - by mtmurdock
    I have looked at the Android API and other posts here on stackoverflow, but have not been able to figure this out. My app downloads files to the sd card. I would like to pop a "loading..." dialog while the file is downloading and then have it disappear when the download is finished. This is what i came up with using the android API: ProgressDialog pd = ProgressDialog.show(this,"","Loading. Please wait...",true); //download file pd.cancel(); however the dialog doesn't actually show. when i debug it, it claims that it is showing, but it is obviously not on the screen. what can i do?

    Read the article

  • Effective way of String splitting

    - by openidsujoy
    I have a completed string like this N:Pay in Cash++RGI:40++R:200++T:Purchase++IP:N++IS:N++PD:PC++UCP:598.80++UPP:0.00++TCP:598.80++TPP:0.00++QE:1++QS:1++CPC:USD++PPC:Points++D:Y++E:Y++IFE:Y++AD:Y++IR:++MV:++CP:~ ~N:ERedemption++RGI:42++R:200++T:Purchase++IP:N++IS:N++PD:PC++UCP:598.80++UPP:0.00++TCP:598.80++TPP:0.00++QE:1++QS:1++CPC:USD++PPC:Points++D:Y++E:Y++IFE:Y++AD:Y++IR:++MV:++CP: this string is like this It's list of PO's(Payment Options) which are separated by ~~ this list may contains one or more PO contains only Key-Value Pairs which separated by : spaces are denoted by ++ I need to extract the values for Key "RGI" and "N". I can do it via for loop , I want a efficient way to do this. any help on this.

    Read the article

  • Library for Dataflow in C

    - by msutherl
    How can I do dataflow (pipes and filters, stream processing, flow based) in C? And not with UNIX pipes. I recently came across stream.py. Streams are iterables with a pipelining mechanism to enable data-flow programming and easy parallelization. The idea is to take the output of a function that turns an iterable into another iterable and plug that as the input of another such function. While you can already do this using function composition, this package provides an elegant notation for it by overloading the operator. I would like to duplicate a simple version of this kind of functionality in C. I particularly like the overloading of the operator to avoid function composition mess. Wikipedia points to this hint from a Usenet post in 1990. Why C? Because I would like to be able to do this on microcontrollers and in C extensions for other high level languages (Max, Pd*, Python). * (ironic given that Max and Pd were written, in C, specifically for this purpose – I'm looking for something barebones)

    Read the article

  • Effective way of String spliting C#

    - by openidsujoy
    I have a completed string like this N:Pay in Cash++RGI:40++R:200++T:Purchase++IP:N++IS:N++PD:PC++UCP:598.80++UPP:0.00++TCP:598.80++TPP:0.00++QE:1++QS:1++CPC:USD++PPC:Points++D:Y++E:Y++IFE:Y++AD:Y++IR:++MV:++CP:~ ~N:ERedemption++RGI:42++R:200++T:Purchase++IP:N++IS:N++PD:PC++UCP:598.80++UPP:0.00++TCP:598.80++TPP:0.00++QE:1++QS:1++CPC:USD++PPC:Points++D:Y++E:Y++IFE:Y++AD:Y++IR:++MV:++CP: this string is like this It's list of PO's(Payment Options) which are separated by ~~ this list may contains one or more PO contains only Key-Value Pairs which separated by : spaces are denoted by ++ I need to extract the values for Key "RGI" and "N". I can do it via for loop , I want a efficient way to do this. any help on this.

    Read the article

  • how to access android app's certificate from inside the app?

    - by Yan
    Hi All, Im trying to access the certificate/signature from inside an android app, so that I can do something with the certificate. I googled a bit and found the code below: Class c = getClass(); ProtectionDomain pd = c.getProtectionDomain(); CodeSource cs = pd.getCodeSource(); Certificate[] signingCertificates = cs.getCertificates(); String st = signingCertificates[0].toString(); but c.getProtectionDomain() returns null. anyone can help? many thanks.

    Read the article

  • Effective way of String splitting C#

    - by openidsujoy
    I have a completed string like this N:Pay in Cash++RGI:40++R:200++T:Purchase++IP:N++IS:N++PD:PC++UCP:598.80++UPP:0.00++TCP:598.80++TPP:0.00++QE:1++QS:1++CPC:USD++PPC:Points++D:Y++E:Y++IFE:Y++AD:Y++IR:++MV:++CP:~ ~N:ERedemption++RGI:42++R:200++T:Purchase++IP:N++IS:N++PD:PC++UCP:598.80++UPP:0.00++TCP:598.80++TPP:0.00++QE:1++QS:1++CPC:USD++PPC:Points++D:Y++E:Y++IFE:Y++AD:Y++IR:++MV:++CP: this string is like this It's list of PO's(Payment Options) which are separated by ~~ this list may contains one or more PO contains only Key-Value Pairs which separated by : spaces are denoted by ++ I need to extract the values for Key "RGI" and "N". I can do it via for loop , I want a efficient way to do this. any help on this.

    Read the article

  • HP pavilion dv4 1413la

    - by Pablo Bastidas
    I had Ubuntu 10.10 in my Laptop Hp Pavilion dv4 1413la one year ago, I bought a Lenovo and I gave my wife the HP. She had Windows 7 but she said me that I intalled Ubuntu 11.11. I installed ubuntu 11.11 in the HP but i had problems. It freezing frecuently and i don't know What happen The touch mouse work for a moment an after doesn't work y kill genome-session and work again Please help me. PD: I don't speak English, I speak Spanish, I was trying, excuse me if I write bad.

    Read the article

  • How to see the lists of my videos in Shotwell?

    - by Joe Cabezas
    I made an import from my camera (photos and videos), and after imported them, the "last sync" item, shows me the photos and videos i've recently imported. But if I click any Event in the "Events" tree (left side), only shows my photos... How to see my videos imported that day also? using shotwell 0.12.3 (default in ubuntu 12.10) pics: Last import preview: http://i.stack.imgur.com/uVnQR.png Event preview: http://i.stack.imgur.com/WTuSg.png PD: sorry I have no rights yet to post pictures

    Read the article

  • openvpn port 53 bypasses allows restrictions ( find similar ports)

    - by user181216
    scenario of wifi : i'm using wifi in hostel which having cyberoam firewall and all the computer which uses that access point. that access point have following configuration default gateway : 192.168.100.1 primary dns server : 192.168.100.1 here, when i try to open a website the cyberoam firewall redirects the page to a login page (with correct login information, we can browse internet else not), and also website access and bandwidth limitations. once i've heard about pd-proxy which finds open port and tunnels through a port ( usually udp 53). using pd-proxy with UDP 53 port, i can browse internet without login, even bandwidth limit is bypassed !!! and another software called openvpn with connecting openvpn server through udp port 53 i can browse internet without even login into the cyberoam. both of softwares uses port 53, specially openvpn with port 53, now i've a VPS server in which i can install openvpn server and connect through the VPS server to browse internet. i know why that is happening because with pinging on some website(eb. google.com) it returns it's ip address that means it allows dns queries without login. but the problem is there is already DNS service is running on the VPS server on port 53. and i can only use 53 port to bypass the limitations as i think. and i can not run openvpn service on my VPS server on port 53. so how to scan the wifi for vulnerable ports like 53 so that i can figure out the magic port and start a openvpn service on VPS on the same port. ( i want to scan similar vulnerable ports like 53 on cyberoam in which the traffic can be tunneled, not want to scan services running on ports). improvement of the question with retags and edits are always welcomed... NOTE : all these are for Educational purpose only, i'm curious about network related knowledge.....

    Read the article

  • openvpn port 53 bypasses allows restrictions ( find similar ports)

    - by user181216
    scenario of wifi : i'm using wifi in hostel which having cyberoam firewall and all the computer which uses that access point. that access point have following configuration default gateway : 192.168.100.1 primary dns server : 192.168.100.1 here, when i try to open a website the cyberoam firewall redirects the page to a login page (with correct login information, we can browse internet else not), and also website access and bandwidth limitations. once i've heard about pd-proxy which finds open port and tunnels through a port ( usually udp 53). using pd-proxy with UDP 53 port, i can browse internet without login, even bandwidth limit is bypassed !!! and another software called openvpn with connecting openvpn server through udp port 53 i can browse internet without even login into the cyberoam. both of softwares uses port 53, specially openvpn with port 53, now i've a VPS server in which i can install openvpn server and connect through the VPS server to browse internet. i know why that is happening because with pinging on some website(eb. google.com) it returns it's ip address that means it allows dns queries without login. but the problem is there is already DNS service is running on the VPS server on port 53. and i can only use 53 port to bypass the limitations as i think. and i can not run openvpn service on my VPS server on port 53. so how to scan the wifi for vulnerable ports like 53 so that i can figure out the magic port and start a openvpn service on VPS on the same port. ( i want to scan similar vulnerable ports like 53 on cyberoam in which the traffic can be tunneled, not want to scan services running on ports). improvement of the question with retags and edits are always welcomed... NOTE : all these are for Educational purpose only, i'm curious about network related knowledge.....

    Read the article

  • Accessing the Atlassian Crowd SOAP API with Suds (python SOAP library)

    - by SeanOC
    Has anybody had any recent success with accessing the Crowd SOAP API via the Suds Python library? I've found a few people successfully doing it in the past but Atlassian seems to have changed their WSDL since then to make the existing advice not entirely helpful. Below is the simplest example I've been trying: from suds.client import Client url = 'https://crowd.hugeinc.com/services/SecurityServer?wsdl' client = Client(url) Unfortunately that generates the following error: Traceback (most recent call last): File "<input>", line 1, in <module> File "/Users/soconnor/.virtualenvs/hugeface/lib/python2.6/site-packages/suds/client.py", line 116, in __init__ sd = ServiceDefinition(self.wsdl, s) File "/Users/soconnor/.virtualenvs/hugeface/lib/python2.6/site-packages/suds/servicedefinition.py", line 58, in __init__ self.paramtypes() File "/Users/soconnor/.virtualenvs/hugeface/lib/python2.6/site-packages/suds/servicedefinition.py", line 137, in paramtypes item = (pd[1], pd[1].resolve()) File "/Users/soconnor/.virtualenvs/hugeface/lib/python2.6/site-packages/suds/xsd/sxbasic.py", line 63, in resolve raise TypeNotFound(qref) TypeNotFound: Type not found: '(AuthenticatedToken, http://authentication.integration.crowd.atlassian.com, )' I've tried to both binding and doctors to fix this problem to no avail. Neither approach resulted in any change. Any further recommendations or suggestions would be incredibly helpful.

    Read the article

  • How to call a new thread from button click

    - by Lynnooi
    Hi, I'm trying to call a thread on a button click (btn_more) but i cant get it right. The thread is to get some data and update the images. The problem i have is if i only update 4 or 5 images then it works fine. But if i load more than 5 images i will get a force close. At times when the internet is slow I will face the same problem too. Can please help me to solve this problem or provide me some guidance? Here is the error i got from LogCat: 04-19 18:51:44.907: ERROR/AndroidRuntime(1034): Uncaught handler: thread main exiting due to uncaught exception 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): java.lang.NullPointerException 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at mobile9.android.gallery.GalleryWallpapers.setWallpaperThumb(GalleryWallpapers.java:383) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at mobile9.android.gallery.GalleryWallpapers.access$4(GalleryWallpapers.java:320) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at mobile9.android.gallery.GalleryWallpapers$1.handleMessage(GalleryWallpapers.java:266) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at android.os.Handler.dispatchMessage(Handler.java:99) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at android.os.Looper.loop(Looper.java:123) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at android.app.ActivityThread.main(ActivityThread.java:4310) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at java.lang.reflect.Method.invokeNative(Native Method) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at java.lang.reflect.Method.invoke(Method.java:521) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at dalvik.system.NativeStart.main(Native Method) My Code: public class GalleryWallpapers extends Activity implements Runnable { public static String MODEL = android.os.Build.MODEL ; private static final String rootURL = "http://www.uploadhub.com/mobile9/gallery/c/"; private int wallpapers_count = 0; private int ringtones_count = 0; private int index = 0; private int folder_id; private int page; private int page_counter = 1; private String family; private String keyword; private String xmlURL = ""; private String thread_op = "xml"; private ImageButton btn_back; private ImageButton btn_home; private ImageButton btn_filter; private ImageButton btn_search; private TextView btn_more; private ProgressDialog pd; GalleryExampleHandler myExampleHandler = new GalleryExampleHandler(); Context context = GalleryWallpapers.this.getBaseContext(); Drawable image; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); MODEL = "HTC Legend"; // **needs to be remove after testing** try { MODEL = URLEncoder.encode(MODEL,"UTF-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.gallerywallpapers); Bundle b = this.getIntent().getExtras(); family = b.getString("fm").trim(); folder_id = Integer.parseInt(b.getString("fi")); keyword = b.getString("kw").trim(); page = Integer.parseInt(b.getString("page").trim()); WindowManager w = getWindowManager(); Display d = w.getDefaultDisplay(); final int width = d.getWidth(); final int height = d.getHeight(); xmlURL = rootURL + "wallpapers/1/?output=rss&afm=wallpapers&mdl=" + MODEL + "&awd=" + width + "&aht=" + height; if (folder_id > 0) { xmlURL = xmlURL + "&fi=" + folder_id; } pd = ProgressDialog.show(GalleryWallpapers.this, "", "Loading...", true, false); Thread thread = new Thread(GalleryWallpapers.this); thread.start(); btn_more = (TextView) findViewById(R.id.btn_more); btn_more.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { myExampleHandler.filenames.clear(); myExampleHandler.authors.clear(); myExampleHandler.duration.clear(); myExampleHandler.fileid.clear(); btn_more.setBackgroundResource(R.drawable.btn_more_click); page = page + 1; thread_op = "xml"; xmlURL = rootURL + "wallpapers/1/?output=rss&afm=wallpapers&mdl=" + MODEL + "&awd=" + width + "&aht=" + height; xmlURL = xmlURL + "&pg2=" + page; index = 0; pd = ProgressDialog.show(GalleryWallpapers.this, "", "Loading...", true, false); Thread thread = new Thread(GalleryWallpapers.this); thread.start(); } }); } public void run() { if(thread_op.equalsIgnoreCase("xml")){ readXML(); } else if(thread_op.equalsIgnoreCase("getImg")){ getWallpaperThumb(); } handler.sendEmptyMessage(0); } private Handler handler = new Handler() { @Override public void handleMessage(Message msg) { int count = 0; if (!myExampleHandler.filenames.isEmpty()){ count = myExampleHandler.filenames.size(); } count = 6; if(thread_op.equalsIgnoreCase("xml")){ pd.dismiss(); thread_op = "getImg"; btn_more.setBackgroundResource(R.drawable.btn_more); } else if(thread_op.equalsIgnoreCase("getImg")){ setWallpaperThumb(); index++; if (index < count){ Thread thread = new Thread(GalleryWallpapers.this); thread.start(); } } } }; private void readXML(){ if (xmlURL.length() != 0) { try { /* Create a URL we want to load some xml-data from. */ URL url = new URL(xmlURL); /* Get a SAXParser from the SAXPArserFactory. */ SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); /* Get the XMLReader of the SAXParser we created. */ XMLReader xr = sp.getXMLReader(); /* * Create a new ContentHandler and apply it to the * XML-Reader */ xr.setContentHandler(myExampleHandler); /* Parse the xml-data from our URL. */ xr.parse(new InputSource(url.openStream())); /* Parsing has finished. */ /* * Our ExampleHandler now provides the parsed data to * us. */ ParsedExampleDataSet parsedExampleDataSet = myExampleHandler .getParsedData(); } catch (Exception e) { //showDialog(DIALOG_SEND_LOG); } } } private void getWallpaperThumb(){ int i = this.index; if (!myExampleHandler.filenames.elementAt(i).toString().equalsIgnoreCase("")){ image = ImageOperations(context, myExampleHandler.thumbs.elementAt(i).toString(), "image.jpg"); } } private void setWallpaperThumb(){ int i = this.index; if (myExampleHandler.filenames.elementAt(i).toString() != null) { String file_info = myExampleHandler.filenames.elementAt(i).toString(); String author = "\nby " + myExampleHandler.authors.elementAt(i).toString(); final String folder = myExampleHandler.folder_id.elementAt(folder_id).toString(); final String fid = myExampleHandler.fileid.elementAt(i).toString(); ImageView imgView = new ImageView(context); TextView tv_filename = null; TextView tv_author = null; switch (i + 1) { case 1: imgView = (ImageView) findViewById(R.id.image1); tv_filename = (TextView) findViewById(R.id.filename1); tv_author = (TextView) findViewById(R.id.author1); break; case 2: imgView = (ImageView) findViewById(R.id.image2); tv_filename = (TextView) findViewById(R.id.filename2); tv_author = (TextView) findViewById(R.id.author2); break; case 3: imgView = (ImageView) findViewById(R.id.image3); tv_filename = (TextView) findViewById(R.id.filename3); tv_author = (TextView) findViewById(R.id.author3); break; case 4: . . . . . case 10: imgView = (ImageView) findViewById(R.id.image10); tv_filename = (TextView) findViewById(R.id.filename10); tv_author = (TextView) findViewById(R.id.author10); break; } if (image.getIntrinsicHeight() > 0) { imgView.setImageDrawable(image); } else { imgView.setImageResource(R.drawable.default_wallpaper); } tv_filename.setText(file_info); tv_author.setText(author); imgView.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { // Perform action on click } }); } } private Drawable ImageOperations(Context ctx, String url, String saveFilename) { try { InputStream is = (InputStream) this.fetch(url); Drawable d = Drawable.createFromStream(is, "src"); return d; } catch (MalformedURLException e) { e.printStackTrace(); return null; } catch (IOException e) { e.printStackTrace(); return null; } } }

    Read the article

  • custom collection in property grid

    - by guyl
    Hi guys. I'm using this article as a reference to use custom collection in propertygrid: LINK When I open the collectioneditor and remove all items then I press OK, I get an exception if null. How can i solve that ? I am using: public T this[int index] { get { if (List.Count == 0) { return default(T); } else { return (T)this.List[index]; } } } as a getter for an item, of course if I have no object how can i restart the whole collection ? this is the whole code /// <summary> /// A generic folder settings collection to use in a property grid. /// </summary> /// <typeparam name="T">can be import or export folder settings.</typeparam> [Serializable] [TypeConverter(typeof(FolderSettingsCollectionConverter)), Editor(typeof(FolderSettingsCollectionEditor), typeof(UITypeEditor))] public class FolderSettingsCollection_New<T> : CollectionBase, ICustomTypeDescriptor { private bool m_bRestrictNumberOfItems; private int m_bNumberOfItems; private Dictionary<string, int> m_UID2Idx = new Dictionary<string, int>(); private T[] arrTmp; /// <summary> /// C'tor, can determine the number of objects to hold. /// </summary> /// <param name="bRestrictNumberOfItems">restrict the number of folders to hold.</param> /// <param name="iNumberOfItems">The number of folders to hold.</param> public FolderSettingsCollection_New(bool bRestrictNumberOfItems = false , int iNumberOfItems = 1) { m_bRestrictNumberOfItems = bRestrictNumberOfItems; m_bNumberOfItems = iNumberOfItems; } /// <summary> /// Add folder to collection. /// </summary> /// <param name="t">Folder to add.</param> public void Add(T t) { if (m_bRestrictNumberOfItems) { if (this.List.Count >= m_bNumberOfItems) { return; } } int index = this.List.Add(t); if (t is WriteDataFolderSettings || t is ReadDataFolderSettings) { FolderSettingsBase tmp = t as FolderSettingsBase; m_UID2Idx.Add(tmp.UID, index); } } /// <summary> /// Remove folder to collection. /// </summary> /// <param name="t">Folder to remove.</param> public void Remove(T t) { this.List.Remove(t); if (t is WriteDataFolderSettings || t is ReadDataFolderSettings) { FolderSettingsBase tmp = t as FolderSettingsBase; m_UID2Idx.Remove(tmp.UID); } } /// <summary> /// Gets ot sets a folder. /// </summary> /// <param name="index">The index of the folder in the collection.</param> /// <returns>A folder object.</returns> public T this[int index] { get { //if (List.Count == 0) //{ // return default(T); //} //else //{ return (T)this.List[index]; //} } } /// <summary> /// Gets or sets a folder. /// </summary> /// <param name="sUID">The UID of the folder.</param> /// <returns>A folder object.</returns> public T this[string sUID] { get { if (this.Count == 0 || !m_UID2Idx.ContainsKey(sUID)) { return default(T); } else { return (T)this.List[m_UID2Idx[sUID]]; } } } /// <summary> /// /// </summary> /// <param name="sUID"></param> /// <returns></returns> public bool ContainsItemByUID(string sUID) { return m_UID2Idx.ContainsKey(sUID); } /// <summary> /// /// </summary> /// <returns></returns> public String GetClassName() { return TypeDescriptor.GetClassName(this, true); } /// <summary> /// /// </summary> /// <returns></returns> public AttributeCollection GetAttributes() { return TypeDescriptor.GetAttributes(this, true); } /// <summary> /// /// </summary> /// <returns></returns> public String GetComponentName() { return TypeDescriptor.GetComponentName(this, true); } /// <summary> /// /// </summary> /// <returns></returns> public TypeConverter GetConverter() { return TypeDescriptor.GetConverter(this, true); } /// <summary> /// /// </summary> /// <returns></returns> public EventDescriptor GetDefaultEvent() { return TypeDescriptor.GetDefaultEvent(this, true); } /// <summary> /// /// </summary> /// <returns></returns> public PropertyDescriptor GetDefaultProperty() { return TypeDescriptor.GetDefaultProperty(this, true); } /// <summary> /// /// </summary> /// <param name="editorBaseType"></param> /// <returns></returns> public object GetEditor(Type editorBaseType) { return TypeDescriptor.GetEditor(this, editorBaseType, true); } /// <summary> /// /// </summary> /// <param name="attributes"></param> /// <returns></returns> public EventDescriptorCollection GetEvents(Attribute[] attributes) { return TypeDescriptor.GetEvents(this, attributes, true); } /// <summary> /// /// </summary> /// <returns></returns> public EventDescriptorCollection GetEvents() { return TypeDescriptor.GetEvents(this, true); } /// <summary> /// /// </summary> /// <param name="pd"></param> /// <returns></returns> public object GetPropertyOwner(PropertyDescriptor pd) { return this; } /// <summary> /// /// </summary> /// <param name="attributes"></param> /// <returns></returns> public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { return GetProperties(); } /// <summary> /// Called to get the properties of this type. /// </summary> /// <returns></returns> public PropertyDescriptorCollection GetProperties() { // Create a collection object to hold property descriptors PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null); // Iterate the list of employees for (int i = 0; i < this.List.Count; i++) { // Create a property descriptor for the employee item and add to the property descriptor collection CollectionPropertyDescriptor_New<T> pd = new CollectionPropertyDescriptor_New<T>(this, i); pds.Add(pd); } // return the property descriptor collection return pds; } public T[] ToArray() { if (arrTmp == null) { arrTmp = new T[List.Count]; for (int i = 0; i < List.Count; i++) { arrTmp[i] = (T)List[i]; } } return arrTmp; } } /// <summary> /// Enable to display data about a collection in a property grid. /// </summary> /// <typeparam name="T">Folder object.</typeparam> public class CollectionPropertyDescriptor_New<T> : PropertyDescriptor { private FolderSettingsCollection_New<T> collection = null; private int index = -1; /// <summary> /// /// </summary> /// <param name="coll"></param> /// <param name="idx"></param> public CollectionPropertyDescriptor_New(FolderSettingsCollection_New<T> coll, int idx) : base("#" + idx.ToString(), null) { this.collection = coll; this.index = idx; } /// <summary> /// /// </summary> public override AttributeCollection Attributes { get { return new AttributeCollection(null); } } /// <summary> /// /// </summary> /// <param name="component"></param> /// <returns></returns> public override bool CanResetValue(object component) { return true; } /// <summary> /// /// </summary> public override Type ComponentType { get { return this.collection.GetType(); } } /// <summary> /// /// </summary> public override string DisplayName { get { if (this.collection[index] != null) { return this.collection[index].ToString(); } else { return null; } } } public override string Description { get { return ""; } } /// <summary> /// /// </summary> /// <param name="component"></param> /// <returns></returns> public override object GetValue(object component) { if (this.collection[index] != null) { return this.collection[index]; } else { return null; } } /// <summary> /// /// </summary> public override bool IsReadOnly { get { return false; } } public override string Name { get { return "#" + index.ToString(); } } /// <summary> /// /// </summary> public override Type PropertyType { get { return this.collection[index].GetType(); } } public override void ResetValue(object component) { } /// <summary> /// /// </summary> /// <param name="component"></param> /// <returns></returns> public override bool ShouldSerializeValue(object component) { return true; } /// <summary> /// /// </summary> /// <param name="component"></param> /// <param name="value"></param> public override void SetValue(object component, object value) { // this.collection[index] = value; } }

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8  | Next Page >