How about, "One does not simply understand quantum mechanics".
FocusedWolf
Posts
-
Microsoft makes quantum computing simple(r) to understand -
Blurry Borderline In FlowDocumentOk i figured out a way that works, although its a bit ugly:
A button
As for why, my code is based on this: http://stackoverflow.com/questions/3798262/how-to-collapse-a-paragraph although i've been improving it. The idea is add or remove a paragraph block below the expander block based on the state of the expander. That + code to handle the copy to clipboard to convert the uielements to text (in this case, getting the header string of the expander) and the result is an interactive flowdocument with collapsing regions and copy support.
-
Blurry Borderline In FlowDocumentIt seems no amount of SnapsToDevicePixels="True" and/or UseLayoutRounding="True" can make the border around a Paragraph sharp:
A button A button A button
However i can use RenderOptions.EdgeMode="Aliased" which makes the border sharp, but distorts the Expander:
A button
So, is there any way to make the border sharp without hurting the documents appearance? :-D
-
The New Layout.Is their a way to go back to the "old" productive layout? :-D
-
IBM produces first working chips modeled on the human brainThis comes to mind: http://www.youtube.com/watch?v=JJRLoGYtkEM[^]
-
VirtualizationMode="Recycling" Issue And Hackish Fix??Ok i figured it out. It has to do with the Text property. It gets changed when the items get recycled, when scrolling the list, and for some reason the "HighlightPhrase" property doesn't also get set when doing this and apparently this isn't an issue because the value of "HighlightPhrase" doesn't change when scrolling anyway. It just works, now ;P This is what makes it work (note: "new" keyword usage because this class inherits TextBlock):
public new string Text { get { return (string)GetValue(TextProperty); } set { SetValue(TextProperty, value); } } public new static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(HighlightTextBlock), new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.AffectsRender, new PropertyChangedCallback(UpdateHighlighting))); private static void UpdateHighlighting(DependencyObject d, DependencyPropertyChangedEventArgs e) { ApplyHighlight(d as HighlightTextBlock); }
See article for latest code: Highlight Searched Text in WPF ListView[^]
-
VirtualizationMode="Recycling" Issue And Hackish Fix??Source: http://www.fileplay.net/file/15671/highlightsearchedtextinlistview[^] Hi, Normally i'd try to strip code down to it's minimum and post it here, but this is one of those instances where the bare minimum = 6 files so please pardon the need to download ;P The Setup: Their's a listview with 3000 items with virtualization enabled in recycling mode. The ItemsSource property is bound to a collection of elements of type "Person". In the MainWindow i setup DataTemplates so the "Person" instances are represented by a custom control called "HighlightTextBlock" [it highlights portions of its text with a colored background if it matches its "HighlightPhrase" dependency property]. In MainWindow.xaml.cs the "FilterItems(...)" function uses a CollectionView to filter items so only ones with highlighted text are shown in the list. The Issue: If you type some letters into the search box and then scroll down then you will see lots of items where the highlighting doesn't occur. Interestingly the problem doesn't occur if you enlarge the window to show more items. The Hackish Fix: In HighlightTextBlock.cs, in the OnHighlightPhraseChanged(...) function [which fires when its associated dependency property "HighlightPhrase" changes], i found that the presence of this code "fixes" the problem:
tb.Text = tb.Text;
Btw trying things like
tb.InvalidateVisual();
had no effect here, and the HighlightPhraseProperty is using
FrameworkPropertyMetadataOptions.AffectsRender
The Crappy Fix: If VirtualizingStackPanel.VirtualizationMode="Standard" is used then the problem goes away (without using the Hackish Fix). Interestingly this guy had issues while scrolling with recycling-virtualization mode that didn't manifest when recycling-standard mode was used: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/a4792b31-0a0d-49e1-bcf1-62bb8e4e5326/[^] Not Filtering With Collection Fix: The problem goes away if the contents of the "FilterItems(...)" function, in MainWindow.xam
-
Git: Inserting a commit below root?(If a mod has a better idea of where to move this question then by all means move it. I figure this forum is the closest match due to the increased odds that a professional C/C++ programmer would know about Git) I am trying to insert a commit below the current initial-commit in a git repository. This is a local project/repository that isn't being shared, so my evil intentions won't affect others :P The closest i've gotten was following the instructions here: http://stackoverflow.com/questions/645450/git-how-to-insert-a-commit-as-the-first-shifting-all-the-others[^] Unfortunately those instructions discard all branches coming off of master, which i don't want to happen.
-
Maintain TextBox selection despite window loosing focus?Ok, i was able to replace half of the solution with wpf-acceptable code, i.e. for a separate stackpanel, which contained controls which i didn't want to steal focus from my textbox, i simply set that stackpanel to have this property: FocusManager.IsFocusScope="true", and what i understand this did was create a separate focus-tree/scope/thing so those controls would not be able to affect my textboxes focus. (source: http://wpfhacks.blogspot.com/2009/06/correct-way-keep-selection-in-textbox.html) But so far i do not see an alternative to the following code, which prevents the textbox from being notified that the window lost focus:
#region WndProc in order to prevent the textbox from loosing focus when the window losses focus const int WM_KILLFOCUS = 8; protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); HwndSource source = PresentationSource.FromVisual(this) as HwndSource; source.AddHook(WndProc); } IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { if (msg == WM_KILLFOCUS) handled = true; return IntPtr.Zero; } #endregion
modified on Tuesday, October 26, 2010 5:38 PM
-
Maintain TextBox selection despite window loosing focus?I figured it out. Was pretty easy lol. Just added this to my main window to consume the WM_KILLFOCUS message, and by doing so i disabled the textbox from ever getting notified that focus for the app has been lost :D
const int WM_KILLFOCUS = 8; protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); HwndSource source = PresentationSource.FromVisual(this) as HwndSource; source.AddHook(WndProc); } IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { if (msg == WM_KILLFOCUS) handled = true; return IntPtr.Zero; }
Additionally, i also subscribed to the TextBox's LostFocus event in order to prevent the textbox from losing focus to another control, which would also result in the TextBox loosing the selection highlighting.private void textBoxReadingMaterial_LostFocus(object sender, RoutedEventArgs e) { e.Handled = true; //prevents selection from being lost }
modified on Sunday, October 24, 2010 1:54 AM
-
Maintain TextBox selection despite window loosing focus?Yep, i've done a fair amount of goggling with no success. Did anyone ever figure out a solution to this problem? The one solution that i tried was connecting to the textbox's lostfocus event, and then setting e.handled = true. Yep it didn't work xD
-
SpeechSynthesizer memory leakNo i didn't write that code... it's just a random google result from searching for other people experiencing this problem. Anyway recently i changed the code to just use the class the way people would expect to use it (i.e. no hacky tricks to fight the memory leak) and the memory consumption was about 400 kb/s. Some things you can try to see the effect is give the reader a few pages of words to read, and set the Rate property to some number like 7 or 10. Subscribing to these events may also be a factor (SpeakCompleted and SpeakProgress). I've noticed that if i just let the program go then it will get to the point of holding about 40-50 mb of ram where it almost stops allocating, and a few minutes later it will get a few more mb. So i'm wondering if this is a true memory leak or by design (i.e. if it has to read a lot then it allocates all this memory). However one thing i notice is when it finished reading, it doesn't flush the memory because the program is still holding onto 46 mb.
-
SpeechSynthesizer memory leakSorry i thought everyone knew about this :) Here's from some other people that have experienced it: http://stackoverflow.com/questions/2204012/constant-memory-leak-in-speechsynthesizer[^] Little translation action for this one: http://translate.googleusercontent.com/translate_c?hl=en&sl=de&u=http://www.eggheadcafe.com/software/aspnet/34136900/memoryleak-in-speechsynth.aspx&prev=/search%3Fq%3Dspeechsynthesizer%2Bmemory%2Bleak%26hl%3Den&rurl=translate.google.com&twu=1&usg=ALkJrhhmXs1dqrvH8fgXvkgr_s4qn1wQkA[^] To summarize the effect, the more words that the SpeechSynthesizer .net framework object has to read, the more megabytes of memory it consumes. It's not long before it's soaking up a few hundred mb. First effect, which sets on rather quickly, is the reader gets slower and slower. I have tried various hacky attempts to dispose and create new objects, but it wasn't 100% successful (besides introduces a noticeable delay). This is from the first link:
what happens if you don't create a new SpeechSynthesizer object on each pass? – Eric Brown Feb 19 at 20:50
Eric, I tried it that way the first time through and it is actually worse. This was why I tried creating and destroying the object with each call. It did improve slightly, but still doesn't solve the issue. Any call to SpeechSynthesizer leaves behind WAVEHDR and WaveHeader objects that grows the private memory until it crashes. – DudeFX Feb 19 at 23:34
-
SpeechSynthesizer memory leakWas wondering if anyone knows of a workaround for the annoying memory leak in SpeechSynthesizer.
-
Zoom Desktop like Windows 7 Magnifier?Ya i think your right :P Anyways i think i found what i was looking for: http://msdn.microsoft.com/en-us/library/ms692402(VS.85).aspx
-
Zoom Desktop like Windows 7 Magnifier?I was wondering if their are some apis i can call for zooming in on the desktop like the windows 7 program called Magnifier does?
-
window above everything else including taskbar + start-button?How about a way to just draw on top of any desktop program... not actually using a circular window that is always topmost above the most topmost other window? Wait!!! i remember i had a computer once where if you changed the volume using the keyboard, that some graphics showing the volume were drawn across the screen... i think they were visible even in a directx game...
modified on Monday, October 12, 2009 12:18 AM
-
window above everything else including taskbar + start-button?How can i do this. Really need this thing to be even immune to z-order changing. Almost like how a mouse cursor is drawn above everything else. I need this because i'm working on a class project to in effect create 2 additional cursors on the desktop... windows only allows 1, but if i can fake it somehow?
-
Please please please please ...If by vb you mean vb.net, then it's really easy to do... just unpack the solution and copy it into your vb.net project... then go into visual studio, load your vb.net project, and then right click on your solution and click "Add Existing Project" and navigate to the project file in the dll project. After you do that, you have to go to your vb.net project, and expand the area called "References", and then a window pops up... click the "Project" tab... the c# project should be listed... add it. Now what this means is the classes in the c# project should be callable from the vb.net project (although i never tried it... but that functionality is said to exist :P). ---------------- If by vb you mean... old vb... not vb.net... then you'd have to rewrite all of the code to get it to work. I have no real experience with old vb so can't help with that :P
-
WPF sleeping-monitor-un-painted-windows problemI've created a bug report here: https://connect.microsoft.com/WPF/feedback/ViewFeedback.aspx?FeedbackID=486671[^] If you experienced the issue i described (please vote in the "Validation" box on that bug report), or found a workaround (then post it here and there also).