Skip to content

Commit

Permalink
minimally tweak UI elements and make Microsoft Visual Studio :: XAML …
Browse files Browse the repository at this point in the history
…Designer *NOT* barf a hairball (Fatal System Exception) on many XAML dialogs/panels in Qiqqa.

The key to the latter is tweaked the dialog setup/init code such that XDevProc (which is part of Visual Studio) can execute that part of the Qiqqa code and thus render the panel -- or at least not b0rk and fail on it when you open the XAML file in the Designer.

---

WARNING NOTE:

TODO: The bit at the end is a copy/dump off SO where the same problem as #40

Must be tweaked and then retried with Qiqqa as it didn't fly for me yet. :-(

The blunter hack of tweaked the Qiqqa code and sneakily support XDesProc code flow too
by moving the Theme loader into Utilities.GUI is nice, but somehow still makes Designer
blue-wave the Brushes and NOT render them.

---

```
<UserControl.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
			<ResourceDictionary Source="pack://application:,,,/Styles;component/Resources.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</UserControl.Resources>
```
  • Loading branch information
GerHobbelt committed Aug 9, 2019
1 parent 3d1b26f commit af670a8
Show file tree
Hide file tree
Showing 12 changed files with 106 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Windows;
using System.Windows.Controls;
using Qiqqa.Brainstorm.Nodes;
using Utilities.Misc;

namespace Qiqqa.Brainstorm.SceneManager
{
Expand Down Expand Up @@ -43,6 +44,17 @@ void DoHorizontal()
double mid = (ObjSceneRenderingControl.current_viewport_topleft.X + ObjSceneRenderingControl.ActualWidth / ObjSceneRenderingControl.CurrentPowerScale / 2);
double visible = ObjSceneRenderingControl.ActualWidth / ObjSceneRenderingControl.CurrentPowerScale;

#if DEBUG
// Are we looking at this dialog in the Visual Studio Designer?
if (Runtime.IsRunningInVisualStudioDesigner && 0 == ObjSceneRenderingControl.NodeControls.Count && Double.IsNaN(mid))
{
min = Math.Min(min, 0);
max = Math.Max(max, 8000);
mid = 2500;
visible = 225;
}
#endif

horizonal_changing = true;
ScrollHorizonal.Minimum = min;
ScrollHorizonal.Maximum = max;
Expand Down
19 changes: 19 additions & 0 deletions Qiqqa/Chat/ChatControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,25 @@
xmlns:commongui="clr-namespace:Qiqqa.Common.GUI"
xmlns:local_gui="clr-namespace:Utilities.GUI;assembly=Utilities"
>
<!--
WARNING NOTE:
TODO: This is copy/dump off SO where the same problem as https://github.com/jimmejardine/qiqqa-open-source/issues/40
Must be tweaked and then retried with Qiqqa as it didn't fly for me yet. :-(
The blunter hack of tweaked the Qiqqa code and sneakily support XDesProc code flow too
by moving the Theme loader into Utilities.GUI is nice, but somehow still makes Designer
blue-wave the Brushes and NOT render them.
- - - - - - -
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Styles;component/Resources.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
-->
<Grid>
<DockPanel>
<local_gui:AugmentedBorder DockPanel.Dock="Top">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:commongui="clr-namespace:Qiqqa.Common.GUI"
xmlns:local_gui="clr-namespace:Utilities.GUI;assembly=Utilities"
xmlns:local_utilities="clr-namespace:Qiqqa.Common.GUI" Width="640" Height="640"
xmlns:local_utilities="clr-namespace:Qiqqa.Common.GUI" Width="640" Height="600"
Title="Unexpected error in Qiqqa!"
x:Name="UnhandledExceptionBox"
>
Expand Down Expand Up @@ -42,16 +42,16 @@
<TextBlock />

<local_gui:AugmentedInfoBarItemControl Header="Exception Trees" x:Name="TextExceptionsRegion" Collapsed="False">
<TextBox Name="TextExceptions" Height="200" AcceptsReturn="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" />
<TextBox Name="TextExceptions" Height="637" AcceptsReturn="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" />
</local_gui:AugmentedInfoBarItemControl>

<local_gui:AugmentedInfoBarItemControl Header="Recent Logs" Collapsed="False">
<TextBox Name="TextLogs" Height="200" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" />
<TextBox Name="TextLogs" Height="430" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" />
</local_gui:AugmentedInfoBarItemControl>


<local_gui:AugmentedInfoBarItemControl Header="Machine Stats" Collapsed="False">
<TextBox Name="TextMachineStats" Height="200" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" />
<TextBox Name="TextMachineStats" Height="450" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" />
</local_gui:AugmentedInfoBarItemControl>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ void ButtonApplyBibTeX_Click(object sender, RoutedEventArgs e)
}
}


// ---------------------------------------------------------------------------------------------------


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public partial class GenericLibraryExplorerControl : UserControl

public GenericLibraryExplorerControl()
{
Theme.Initialize();

InitializeComponent();

TreeSearchTerms.Background = ThemeColours.Background_Brush_Blue_LightToDark;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public partial class TagExplorerControl : UserControl

public TagExplorerControl()
{
Theme.Initialize();

InitializeComponent();

this.ToolTip = "Here are the Tags you have added to your documents. " + GenericLibraryExplorerControl.YOU_CAN_FILTER_TOOLTIP;
Expand Down
5 changes: 1 addition & 4 deletions Qiqqa/Main/MainEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,7 @@ private static void DoPostUpgrade(SplashScreenWindow splashscreen_window)
// NB NB NB NB: You CANT USE ANYTHING IN THE USER CONFIG AT THIS POINT - it is not yet decided until LOGIN has completed...

splashscreen_window.UpdateMessage("Loading themes");
ThemeColours.AddToApplicationResources(application);
ThemeTextStyles.AddToApplicationResources(application);
ThemeScrollbar.AddToApplicationResources(application);
ThemeTabItem.AddToApplicationResources(application);
Theme.Initialize(application);
DualTabbedLayout.GetWindowOverride = delegate() { return new StandardWindow(); };

// Force tooltips to stay open
Expand Down
30 changes: 30 additions & 0 deletions Utilities/GUI/Theme.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace Utilities.GUI
{
public class Theme
{
private static int theme_init_count = 0;

public static void Initialize(Application application = null)
{
// NB NB NB NB: You CANT USE ANYTHING IN THE USER CONFIG AT THIS POINT - it is not yet decided until LOGIN has completed...

++theme_init_count;

Application app = Application.Current;
Logging.Debug("current vs application: {0}", app == application);

ThemeColours.AddToApplicationResources(app);
ThemeTextStyles.AddToApplicationResources(app);
ThemeScrollbar.AddToApplicationResources(app);
ThemeTabItem.AddToApplicationResources(app);

// NB NB NB NB: You CANT USE ANYTHING IN THE USER CONFIG AT THIS POINT - it is not yet decided until LOGIN has completed...
}
}
}
42 changes: 21 additions & 21 deletions Utilities/GUI/ThemeColours.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,27 +110,27 @@ static ThemeColours()

public static void AddToApplicationResources(Application application)
{
application.Resources.Add("Background_Color_Neutral_VeryLight", Background_Color_Neutral_VeryLight);
application.Resources.Add("Background_Color_Neutral_Light", Background_Color_Neutral_Light);
application.Resources.Add("Background_Color_Neutral_Medium", Background_Color_Neutral_Medium);

application.Resources.Add("Background_Color_Blue_Light", Background_Color_Blue_Light);
application.Resources.Add("Background_Color_Blue_Dark", Background_Color_Blue_Dark);
application.Resources.Add("Background_Color_Blue_VeryDark", Background_Color_Blue_VeryDark);
application.Resources.Add("Background_Color_Blue_VeryVeryDark", Background_Color_Blue_VeryVeryDark);
application.Resources.Add("Background_Color_Blue_VeryVeryVeryDark", Background_Color_Blue_VeryVeryVeryDark);

application.Resources.Add("Background_Brush_Blue_Light", Background_Brush_Blue_Light);
application.Resources.Add("Background_Brush_Blue_Dark", Background_Brush_Blue_Dark);
application.Resources.Add("Background_Brush_Blue_VeryDark", Background_Brush_Blue_VeryDark);
application.Resources.Add("Background_Brush_Blue_VeryVeryDark", Background_Brush_Blue_VeryVeryDark);
application.Resources.Add("Background_Brush_Blue_VeryVeryVeryDark", Background_Brush_Blue_VeryVeryVeryDark);

application.Resources.Add("Background_Brush_Blue_LightToVeryLight", Background_Brush_Blue_LightToVeryLight);
application.Resources.Add("Background_Brush_Blue_LightToDark", Background_Brush_Blue_LightToDark);
application.Resources.Add("Background_Brush_Blue_VeryDarkToDark", Background_Brush_Blue_VeryDarkToDark);

application.Resources.Add("Background_Brush_Warning", Background_Brush_Warning);
if (!application.Resources.Contains("Background_Color_Neutral_VeryLight")) application.Resources.Add("Background_Color_Neutral_VeryLight", Background_Color_Neutral_VeryLight);
if (!application.Resources.Contains("Background_Color_Neutral_Light")) application.Resources.Add("Background_Color_Neutral_Light", Background_Color_Neutral_Light);
if (!application.Resources.Contains("Background_Color_Neutral_Medium")) application.Resources.Add("Background_Color_Neutral_Medium", Background_Color_Neutral_Medium);

if (!application.Resources.Contains("Background_Color_Blue_Light")) application.Resources.Add("Background_Color_Blue_Light", Background_Color_Blue_Light);
if (!application.Resources.Contains("Background_Color_Blue_Dark")) application.Resources.Add("Background_Color_Blue_Dark", Background_Color_Blue_Dark);
if (!application.Resources.Contains("Background_Color_Blue_VeryDark")) application.Resources.Add("Background_Color_Blue_VeryDark", Background_Color_Blue_VeryDark);
if (!application.Resources.Contains("Background_Color_Blue_VeryVeryDark")) application.Resources.Add("Background_Color_Blue_VeryVeryDark", Background_Color_Blue_VeryVeryDark);
if (!application.Resources.Contains("Background_Color_Blue_VeryVeryVeryDark")) application.Resources.Add("Background_Color_Blue_VeryVeryVeryDark", Background_Color_Blue_VeryVeryVeryDark);

if (!application.Resources.Contains("Background_Brush_Blue_Light")) application.Resources.Add("Background_Brush_Blue_Light", Background_Brush_Blue_Light);
if (!application.Resources.Contains("Background_Brush_Blue_Dark")) application.Resources.Add("Background_Brush_Blue_Dark", Background_Brush_Blue_Dark);
if (!application.Resources.Contains("Background_Brush_Blue_VeryDark")) application.Resources.Add("Background_Brush_Blue_VeryDark", Background_Brush_Blue_VeryDark);
if (!application.Resources.Contains("Background_Brush_Blue_VeryVeryDark")) application.Resources.Add("Background_Brush_Blue_VeryVeryDark", Background_Brush_Blue_VeryVeryDark);
if (!application.Resources.Contains("Background_Brush_Blue_VeryVeryVeryDark")) application.Resources.Add("Background_Brush_Blue_VeryVeryVeryDark", Background_Brush_Blue_VeryVeryVeryDark);

if (!application.Resources.Contains("Background_Brush_Blue_LightToVeryLight")) application.Resources.Add("Background_Brush_Blue_LightToVeryLight", Background_Brush_Blue_LightToVeryLight);
if (!application.Resources.Contains("Background_Brush_Blue_LightToDark")) application.Resources.Add("Background_Brush_Blue_LightToDark", Background_Brush_Blue_LightToDark);
if (!application.Resources.Contains("Background_Brush_Blue_VeryDarkToDark")) application.Resources.Add("Background_Brush_Blue_VeryDarkToDark", Background_Brush_Blue_VeryDarkToDark);

if (!application.Resources.Contains("Background_Brush_Warning")) application.Resources.Add("Background_Brush_Warning", Background_Brush_Warning);


// And then the associated XAML file
Expand Down
8 changes: 4 additions & 4 deletions Utilities/GUI/ThemeTextStyles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ public class ThemeTextStyles

public static void AddToApplicationResources(Application application)
{
application.Resources.Add("FontFamily_Standard", FontFamily_Standard);
application.Resources.Add("FontFamily_Header", FontFamily_Header);
application.Resources.Add("Color_Neutral_Medium", Color_Neutral_Medium);
application.Resources.Add("Brush_Neutral_Medium", Brush_Neutral_Medium);
if (!application.Resources.Contains("FontFamily_Standard")) application.Resources.Add("FontFamily_Standard", FontFamily_Standard);
if (!application.Resources.Contains("FontFamily_Header")) application.Resources.Add("FontFamily_Header", FontFamily_Header);
if (!application.Resources.Contains("Color_Neutral_Medium")) application.Resources.Add("Color_Neutral_Medium", Color_Neutral_Medium);
if (!application.Resources.Contains("Brush_Neutral_Medium")) application.Resources.Add("Brush_Neutral_Medium", Brush_Neutral_Medium);
}
}
}
10 changes: 10 additions & 0 deletions Utilities/Misc/Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,15 @@ public static string StartupDirectory
return Path.GetDirectoryName(new Uri(Assembly.GetEntryAssembly().CodeBase).LocalPath);
}
}

public static bool IsRunningInVisualStudioDesigner
{
get
{
// Are we looking at this dialog in the Visual Studio Designer?
string appname = System.Reflection.Assembly.GetEntryAssembly().FullName;
return appname.Contains("XDesProc");
}
}
}
}
1 change: 1 addition & 0 deletions Utilities/Utilities.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@
<Compile Include="GUI\SpaceAvoidingGrid.cs" />
<Compile Include="GUI\Syncfusion\GridDataControl_DistinctCountAggregate.cs" />
<Compile Include="GUI\Syncfusion\SummaryColumnTools.cs" />
<Compile Include="GUI\Theme.cs" />
<Compile Include="GUI\ThemeColours.cs">
<SubType>Code</SubType>
</Compile>
Expand Down

0 comments on commit af670a8

Please sign in to comment.