Can a Window(System.Windows) know whether it is opened by Show() or ShowDialog()?  If DialogResult is set on a window which is opened by Show() method, it throws an InvalidOperationException().  Is there any way to know how the window is opened and to avoid it? Should I use try-catch?  public partial class Window1 : Window {     public Window1() {         InitializeComponent();     }      private void CancelButton_OnClick([NotNull] object sender, [NotNull] RoutedEventArgs e) {         DialogResult = false; // throws an InvalidOperationException.     } }
What's the easiest way to figure out if a window is opened modally or not?  CLARIFICATION:  I open a window calling   myWindow.ShowDialog();   I have a footer with an "OK" &amp; "Cancel" button that I only want to show if the window is opened modally. Now I realize I can set a property by doing this:  myWindow.IsModal = true; myWindow.ShowDialog();   But I want the window itself to make that determination. I want to check in the Loaded event of the window whether or not it is modal.  UPDATE  The IsModal property doesn't actually exist in a WPF window. It's a property that I have created. ShowDialog() blocks the current thread.   I'm guessing I can determine if the Window is opened via ShowDialog() by checking if the current thread is blocked. How would I go about doing that?
I recently tried to use QGIS and I wondered if you can convert a draft ArcGIS map (*.mxd file) into a QGIS project (*.qgs file).   This would avoid thematize the entire project. Given this XML, what XPath returns all elements whose prop attribute contains Foo (the first three nodes):  &lt;bla&gt;  &lt;a prop="Foo1"/&gt;  &lt;a prop="Foo2"/&gt;  &lt;a prop="3Foo"/&gt;  &lt;a prop="Bar"/&gt; &lt;/bla&gt; When adding image from Wikimedia Commons, automatically add author/license/link Many Stack Exchange questions and answers embed images from Wikimedia Commons. It is probably the most used image source here. Good news Thanks to their license, all images from Wikimedia Commons can be legally used inside Stack Exchange. Bad news The only requirement is to cite the author/license (), an easy task, but we are totally failing at it, only maybe 1% of Commons images used here are properly cited. That makes our use of these images illegal, and could expose Stack Exchange to various legal threats. Not my problem, you could say, but this is also important because , bringing Stack Exchange closer to closed-data sites like Yahoo! Answers or Experts-Exchange. Proposed solution When using the image addition widget, the widget should detect whether the image's URL has a *.wikimedia.org domain, and if yes:  (optional) Transfer the image to imgur, for perennity reasons. Retrieve the author name and license name from Commons (there is a very reliable API that gives that). Concatenate into a proper citation, maybe something like &quot;*Credit: [&quot; + author + &quot;](&quot; + commonsPageURL + &quot;) , [&quot; + license + &quot;](&quot; + licenseURL + &quot;)*&quot; Insert the citation at the same time as the image's MarkDown.  Benefits:  Remove a large part of Stack Exchange's copyright violations. Makes us a good citizen in the open data world. Remember what happens to sites who disregard ethics (Experts Exchange). Consistent citations. Zero added burden for the users. How to insert pipe symbol in (La)TeX? How to insert pipe symbol | in TeX (LaTeX)?  I have tried this sample with pdflatex tmp.tex  \documentclass{extarticle} \begin{document} \textpipe \end{document}   And it give undefined control sequence error  This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian) restricted \write18 enabled. entering extended mode (./tmp.tex LaTeX2e &lt;2009/09/24&gt; Babel &lt;v3.8l&gt; and hyphenation patterns for english, usenglishmax, dumylang, noh yphenation, loaded. (/usr/share/texmf-texlive/tex/latex/extsizes/extarticle.cls Document Class: extarticle 1996/10/08 v1.0 Non Standard LaTeX document class (/usr/share/texmf-texlive/tex/latex/base/size10.clo) (/usr/share/texmf-texlive/tex/latex/base/exscale.sty)) No file tmp.aux. ! Undefined control sequence. l.3 \textpipe Could not make temporary scratch layer permanent I want to make a temporary scratch layer permanent but it shows  Could not make temporary scratch layer permanent. Error: Creation of field addr:street_1 failed (OGR error: Can't create field addr_str_4 in Shape DBF file, reason unknown.) How can I fix this error?  This is my attribute table. What is "superuser" and how do I get that privilege? How to dynamically add JSF components I have recently upgraded SQL Server 2000 database to 2008 R2.    What I did was:   Shutdown SQL Server 2000 (express) service on old machine, Move datafiles (mydatabase.mdf and mydatabase.ldf) to new machine, Run SQL Server Management Studio 2008, Connect to local database engine, Attach datafiles to database. Change the compatibility level of database to SQL 2008 (100).     Question: What else should I do to make migration complete?  I want to:   use new features like checksumming and full recovery model, make this database to be exactly as it was created in SQL 2008 R2, make this database to be fully compatibile, correct and be perfect suited for new, SQL 2008 R2 database engine.     In other words: I just want to know how to correctly and completly convert old SQL 2000 database to new 2008 R2 database, be calm that everything is done right and be happy with all new features.    I'm asking this question, because I've found a lot of sites on the Internet that says so many different things that makes me confused: some say that it is required to rebuild indexes, another says to do other things... and now I know nothing so I want to hear experienced person opinion and clear, step-by-step instructions. I work for very small company, I'm on my own and I don't want to screw things up.    Sir, I'm really impressed with your answer, I wasn't expecting so much.    So some comments:   The database is now in production. As I said, it was upgraded using deattach-attach method as I desribed in first post and as described on MSDN:  It had to be done quickly, so I was forced to do it that way. Let's forget about how inappropriate could it was and focus on current situation. The users/persmission is not a problem here - there are only few and permissions are simple. The application which use database is compatibile with SQL 2000 till 2012 so this is not a problem either. The database file (MDF) isn't big - only about 1GB.     Few more questions:   You recommend to use backup/restore method, but I did as written above, so can I encounter any problems now? Everything worked without any problem. About checksumming and full recovery model: it wasn't available/enabled on SQL 2000, so I want to use them now. You said that the only thing I need to do is to enable those options in database properties? I've read somewhere, that it isn't enough and I should also rebuild indexes or something. I really don't know, I just asking. I'm prepairing to migrate this database to SQL 2012 - so first it was from SQL 2000 to 2008 R2, now it will be from 2008 R2 to 2012 (it was impossible to do this directly because of lack of support of SQL 2000 databases in SQL 2012). So I understand that I should follow your guide: backup it in 2008 R2 and restore in 2012, then do the rest of your tips, right? Please explain me the backup/restore method: Is it like a dump of database to SQL queries and then restoring it by executing a bunch of queries? Will this method by the way "defragment" my database? If not, how to defragment/optimize it manually? As we were using SQL 2000 Express for years (no management interface), we were doing backups simply by stopping engine and RAR the DATA directory. For now, as we are on SQL 2008, isn't this still better than using backup function in Management Studio? Full recovery mode with frequent Transaction log backups - Where is the Transaction log stored - is it the LDF file? How sould I backup it properly?     I know that my questions may sound silly, I'm not professional database admin, but I am the only person here who can do such "hard core" task like upgrading the database engine. I'm also sure that your knowleadge will help a lot to other people like me.  Thank you very much for your time and knowleadge, I really appreciate this. Do I need internet/3G to use GPS? I have a Samsung Galaxy S2 that has some problems with the GPS: If I use internet my navigation works but when I turn the 3G off, GPS does not work.  Do I need internet/3G to use GPS? What is a bus error? What does the "bus error" message mean, and how does it differ from a segfault? How can I change iTunes country of region when having some credit in my account? I moved to Canada and I want to change my country of region from USA to Canada, but when I try to change it ( by click on my account in the iTunes Store and going to my Account Page) it showed me this error: "You have a store credit balance; you must spend your balance before you can change stores"    I must mention I have redeem 100$ to my account but I don't have any intention to spent it now, what is my option? How to delete specific lines from a txt file I have a Bash script that writes data into a log file, then from that I take out stuff I want using the sed command. That gives me a file data.txt. What I want to know is how I go about deleting specific line inside that data.txt file.  For example:  123 456 789   I want to remove the 2nd line, containing 456 so that I only have  123  789   I tried with sed '2d' data.txt but it doesn't work.  I use this command to create data.txt from log.log:  sed -nE '1s/.{1}(.{2}).*/\1/p;' log.log &gt;&gt; data.txt My Alt + Tab menu looks and works oddly MikTex 2.9 Installation Error: File name database capacity exceeded. Prove that for every odd integer n, there is a group... Prove that for every odd integer n, there is a group with exactly n elements of order 2.  I am new to abstract algebra and proofs in general. Proving existence is difficult for me, but I will show what I have.  $$n = 2k + 1$$ $$k \in \mathbb{Z^+}$$  $$\exists G \supset H = (a_1 , a_2 , ..., a_n, e)$$  $$s.t. |a_1| = |a_2| = ... = |a_n| = 2$$  My instinct is to use Lagrange's Theorem, although I would like to try another method to prove this as we have not gone over cosets in class yet. If someone could just give me a hint of how to start, it would be very beneficial. Thank you. Is a +1/+1 counter I get from, say Unleash or Undying different than +1/+1 from something like  or ? $\mathbb Z[i]/ \langle 1+2i \rangle \cong \mathbb Z_5$ Can't access my home directory "Encrypted private directory is not setup properly" Hi I'm trying to access my home directory on my laptop hard drive through a live usb. I cannot boot into the OS on the hard drive and the home and root directory is encrypted. I have the encryption key but when I try to run the tool to gain access it pops up for a second then disappears and when I run the command in Terminal it says "Encrypted private directory is not setup properly". What are my options on getting into the directory? I really need to get the data off my laptop. Running 64 bit programs on a 32 bit system This is a question thats been bothering me a while. I don't even know if it makes sense or not (like if it is a physics question or becoming a philosophical one). But here it goes. The crux of my question basically is that we all know that we can't see light (like in its photon or electromagnetic wave form) directly when it is traveling past us. However, we also know that the way we see objects is by light reflecting off them. This then means that we are "seeing" the light reflecting from the object which then sends the signal to our brain saying that we are seeing a particular object. We know that both light traveling past us and light reflected from objects are made of photons (so they are the same kind)? So then my question is that what is happening to the photon of a light after it is reflected from the objects, that causes us to see it or the object, but on the other hand we can't see light as it is directly traveling past us.