Skip to content

Commit 5f29206

Browse files
committed
Fixed zooming issues and added a custom Zoom editor dialog
1 parent cd5fff2 commit 5f29206

15 files changed

+329
-54
lines changed

ForumSurfer/Browser/BrowserHelper.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,7 @@ namespace ForumSurfer.Browser
1111
{
1212
public static class BrowserHelper
1313
{
14-
//private void MuteJSErrors()
15-
//{
16-
// dynamic activeX = this.wbFeed.GetType().InvokeMember("ActiveXInstance",
17-
// BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
18-
// null, this.wbFeed, new object[] { });
19-
// activeX.Silent = true;
20-
//}
21-
22-
23-
24-
14+
2515
private static void SetBrowserFeatureControlKey(string feature, string appName, uint value)
2616
{
2717
using (var key = Registry.CurrentUser.CreateSubKey(
@@ -68,6 +58,7 @@ public static void SetBrowserFeatureControl()
6858
SetBrowserFeatureControlKey("FEATURE_WEBSOCKET", fileName, 1);
6959
SetBrowserFeatureControlKey("FEATURE_WINDOW_RESTRICTIONS ", fileName, 0);
7060
SetBrowserFeatureControlKey("FEATURE_XMLHTTP", fileName, 1);
61+
SetBrowserFeatureControlKey("FEATURE_96DPI_PIXEL", fileName, 1);
7162
}
7263

7364
private static UInt32 GetBrowserEmulationMode()

ForumSurfer/Data/Host.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public static List<Host> LoadAll()
3131
feedHost.Title = feed.Host;
3232
feedHost.Location = new Uri("http://" + feed.Host);
3333
feedHost.Zoom = 100;
34+
feedHost.TextZoom = 2;
3435
feed.ParentHost = feedHost;
3536
results.Add(feedHost);
3637
}
@@ -83,6 +84,11 @@ FROM Hosts
8384
if (!(reader["zoom"] == null))
8485
host.Zoom = (int)Int64.Parse(reader["zoom"].ToString());
8586
}
87+
if (!(reader["textzoom"] is DBNull))
88+
{
89+
if (!(reader["textzoom"] == null))
90+
host.TextZoom = (int)Int64.Parse(reader["textzoom"].ToString());
91+
}
8692
host.Title = reader["uri"].ToString();
8793
}
8894
else
@@ -98,7 +104,8 @@ public void Save()
98104
{
99105
String sql = @"
100106
UPDATE Hosts
101-
SET zoom = $zoom
107+
SET zoom = $zoom,
108+
textzoom = $textzoom
102109
WHERE uri = $uri;
103110
";
104111

@@ -111,6 +118,7 @@ UPDATE Hosts
111118
SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
112119
command.Parameters.AddWithValue("$uri", Title);
113120
command.Parameters.AddWithValue("$zoom", Zoom);
121+
command.Parameters.AddWithValue("$textzoom", TextZoom);
114122
command.ExecuteNonQuery();
115123

116124
tran.Commit();

ForumSurfer/Data/Repository.cs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace ForumSurfer.Data
1111
public class Repository
1212
{
1313
public const String DatabaseName = "ForumSurfer.sqlite";
14-
public const String DatabaseVersion = "1.0.1";
14+
public const String DatabaseVersion = "1.0.2";
1515

1616
public static String DatabaseFolder
1717
{
@@ -98,10 +98,6 @@ WHERE NOT EXISTS (
9898
FROM GlobalOptions
9999
WHERE option_id = 1
100100
);
101-
102-
UPDATE GlobalOptions
103-
SET value = $version
104-
WHERE option_id = 1;
105101
";
106102

107103
using (SQLiteConnection m_dbConnection = new SQLiteConnection(ConnectionString))
@@ -121,7 +117,7 @@ UPDATE GlobalOptions
121117
command = new SQLiteCommand(sqlCreateTableBoilerplate, m_dbConnection);
122118
command.ExecuteNonQuery();
123119
command = new SQLiteCommand(sqlInsertDatabaseVersion, m_dbConnection);
124-
command.Parameters.AddWithValue("$version", DatabaseVersion);
120+
command.Parameters.AddWithValue("$version", "1.0.1");
125121
command.ExecuteNonQuery();
126122
tran.Commit();
127123
}
@@ -130,6 +126,25 @@ UPDATE GlobalOptions
130126
tran.Rollback();
131127
throw;
132128
}
129+
130+
string versionSql = "SELECT value FROM GlobalOptions WHERE option_id = 1";
131+
SQLiteCommand cmd = new SQLiteCommand(versionSql, m_dbConnection);
132+
string dbVersion = (string)cmd.ExecuteScalar();
133+
134+
if (dbVersion.Equals("1.0.1"))
135+
{
136+
tran = m_dbConnection.BeginTransaction();
137+
138+
//string sql = "ALTER TABLE Hosts ADD TextZoom int null;";
139+
//cmd = new SQLiteCommand(sql, m_dbConnection);
140+
//cmd.ExecuteNonQuery();
141+
142+
string sql = "UPDATE GlobalOptions SET value = '1.0.2' WHERE option_id = 1;";
143+
cmd = new SQLiteCommand(sql, m_dbConnection);
144+
int i = cmd.ExecuteNonQuery();
145+
146+
tran.Commit();
147+
}
133148
}
134149
}
135150
}

ForumSurfer/ForumSurfer.csproj

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
<Compile Include="Model\Settings.cs" />
133133
<Compile Include="Model\SyndicationFeedXmlReader.cs" />
134134
<Compile Include="ViewModel\BoilerplateAnswer.cs" />
135+
<Compile Include="ViewModel\ZoomEditorViewModel.cs" />
135136
<Compile Include="ViewModel\BoilerplateEditorViewModel.cs" />
136137
<Compile Include="ViewModel\MainViewModel.cs" />
137138
<Compile Include="ViewModel\SendBoilerplateMessage.cs" />
@@ -140,12 +141,22 @@
140141
<Compile Include="ViewModel\TreeViewModel.cs" />
141142
<Compile Include="ViewModel\TreeNodeViewModel.cs" />
142143
<Compile Include="ViewModel\ViewModelLocator.cs" />
144+
<Compile Include="View\ZoomDialog.xaml.cs">
145+
<DependentUpon>ZoomDialog.xaml</DependentUpon>
146+
</Compile>
143147
<Compile Include="View\BoilerplateDialog.xaml.cs">
144148
<DependentUpon>BoilerplateDialog.xaml</DependentUpon>
145149
</Compile>
150+
<Compile Include="View\ZoomEditor.xaml.cs">
151+
<DependentUpon>ZoomEditor.xaml</DependentUpon>
152+
</Compile>
146153
<Compile Include="View\BoilerplateEditor.xaml.cs">
147154
<DependentUpon>BoilerplateEditor.xaml</DependentUpon>
148155
</Compile>
156+
<Page Include="View\ZoomDialog.xaml">
157+
<Generator>MSBuild:Compile</Generator>
158+
<SubType>Designer</SubType>
159+
</Page>
149160
<Page Include="View\BoilerplateDialog.xaml">
150161
<SubType>Designer</SubType>
151162
<Generator>MSBuild:Compile</Generator>
@@ -154,6 +165,10 @@
154165
<SubType>Designer</SubType>
155166
<Generator>MSBuild:Compile</Generator>
156167
</Page>
168+
<Page Include="View\ZoomEditor.xaml">
169+
<Generator>MSBuild:Compile</Generator>
170+
<SubType>Designer</SubType>
171+
</Page>
157172
<Page Include="View\MainWindow.xaml">
158173
<Generator>MSBuild:Compile</Generator>
159174
<SubType>Designer</SubType>

ForumSurfer/Model/Host.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class Host : RSSNode
1111
public Uri Location { get; set; }
1212
public string Title { get; set; }
1313
public int Zoom { get; set; }
14+
public int TextZoom { get; set; }
1415
public List<Feed> Feeds { get; set; }
1516

1617
public Object SortKey
@@ -31,6 +32,7 @@ public Host(Host h) : this()
3132
this.Location = h.Location;
3233
this.Title = h.Title;
3334
this.Zoom = h.Zoom;
35+
this.TextZoom = h.TextZoom;
3436
this.Feeds = h.Feeds;
3537
}
3638

ForumSurfer/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@
5151
// You can specify all the values or you can default the Build and Revision Numbers
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("1.4.0.8")]
54+
[assembly: AssemblyVersion("1.4.1.0")]
5555

ForumSurfer/View/MainWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@
271271
<ContextMenu>
272272
<MenuItem Header="Mark As Read" Command="{Binding Path=DataContext.MarkFeedReadCommand, Source={x:Reference MainWin}}" />
273273
<MenuItem Header="Delete" Command="{Binding Path=DataContext.DeleteFeedCommand, Source={x:Reference MainWin}}" />
274-
<MenuItem Header="Edit" Command="{Binding Path=DataContext.EditFeedCommand, Source={x:Reference MainWin}}" />
274+
<MenuItem Header="Properties" Command="{Binding Path=DataContext.EditFeedCommand, Source={x:Reference MainWin}}" />
275275
</ContextMenu>
276276
</TextBlock.ContextMenu>
277277
</TextBlock>

ForumSurfer/View/MainWindow.xaml.cs

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -146,21 +146,31 @@ private void sendTextViaScript(dynamic document, string text)
146146
private object ReceiveSetZoomMessage(SendSetZoomMessage msg)
147147
{
148148
zoomLevel = msg.Zoom;
149+
textZoom = msg.TextZoom;
149150
if (msg.SetImmediately)
150151
{
151-
setBrowserZoom(zoomLevel);
152+
setBrowserZoom(zoomLevel, textZoom);
152153
}
153154
return null;
154155
}
155156

156157

157158
private void WbFeed_LoadCompleted(object sender, NavigationEventArgs e)
158159
{
159-
setBrowserZoom(zoomLevel);
160+
MuteJSErrors();
161+
setBrowserZoom(zoomLevel, textZoom);
162+
}
163+
164+
private void MuteJSErrors()
165+
{
166+
dynamic activeX = this.wbFeed.GetType().InvokeMember("ActiveXInstance",
167+
BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
168+
null, this.wbFeed, new object[] { });
169+
activeX.Silent = true;
160170
}
161171

162172

163-
private void setBrowserZoom(object zoomPercent)
173+
private void setBrowserZoom(object zoomPercent, object textZoomLevel)
164174
{
165175
try
166176
{
@@ -171,19 +181,12 @@ private void setBrowserZoom(object zoomPercent)
171181
comWebBrowser = webBrowserInfo.GetValue(wbFeed);
172182
if (comWebBrowser != null)
173183
{
174-
object textZoomO = textZoom;
184+
object textZoomO = 0;
185+
textZoomO = textZoomLevel;
175186
InternetExplorer ie = (InternetExplorer)comWebBrowser;
176-
try
177-
{
178-
if((int)zoomPercent > 100)
179-
ie.ExecWB(SHDocVw.OLECMDID.OLECMDID_ZOOM, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref textZoomO, IntPtr.Zero);
180-
}
181-
catch (Exception ex1)
182-
{
183-
Debug.Print(ex1.Message);
184-
}
185187
ie.ExecWB(SHDocVw.OLECMDID.OLECMDID_OPTICAL_ZOOM, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref zoomPercent, IntPtr.Zero);
186-
188+
ie.ExecWB(SHDocVw.OLECMDID.OLECMDID_ZOOM, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref textZoomO, IntPtr.Zero);
189+
ie.ExecWB(SHDocVw.OLECMDID.OLECMDID_ZOOM, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref textZoomO, IntPtr.Zero);
187190
}
188191
}
189192
catch (Exception ex)
@@ -198,6 +201,34 @@ private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e
198201
Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
199202
e.Handled = true;
200203
}
201-
204+
205+
206+
207+
//private void TextZoomUD_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double?> e)
208+
//{
209+
// string z = TextZoomUD.Value.ToString();
210+
// object zz;
211+
// try
212+
// {
213+
// zz = Int32.Parse(z);
214+
// }
215+
// catch (Exception)
216+
// {
217+
// return;
218+
// }
219+
220+
// if (wbFeed == null)
221+
// return;
222+
223+
// FieldInfo webBrowserInfo = wbFeed.GetType().GetField("_axIWebBrowser2", BindingFlags.Instance | BindingFlags.NonPublic);
224+
// object comWebBrowser = null;
225+
// if (webBrowserInfo != null)
226+
// comWebBrowser = webBrowserInfo.GetValue(wbFeed);
227+
// if (comWebBrowser != null)
228+
// {
229+
// InternetExplorer ie = (InternetExplorer)comWebBrowser;
230+
// ie.ExecWB(SHDocVw.OLECMDID.OLECMDID_ZOOM, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref zz, IntPtr.Zero);
231+
// }
232+
//}
202233
}
203234
}

ForumSurfer/View/ZoomDialog.xaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Dialog:CustomDialog x:Class="ForumSurfer.View.ZoomDialog"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:ForumSurfer.View"
7+
mc:Ignorable="d"
8+
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
9+
xmlns:Dialog="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
10+
Style="{StaticResource NewCustomDialogStyle}">
11+
12+
13+
14+
<StackPanel>
15+
<local:ZoomEditor />
16+
</StackPanel>
17+
18+
19+
</Dialog:CustomDialog>
20+

ForumSurfer/View/ZoomDialog.xaml.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Shapes;
14+
15+
namespace ForumSurfer.View
16+
{
17+
/// <summary>
18+
/// Interaction logic for BoilerplateDialog.xaml
19+
/// </summary>
20+
public partial class ZoomDialog : MahApps.Metro.Controls.Dialogs.CustomDialog
21+
{
22+
public ZoomDialog()
23+
{
24+
InitializeComponent();
25+
}
26+
}
27+
}

ForumSurfer/View/ZoomEditor.xaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<UserControl x:Class="ForumSurfer.View.ZoomEditor"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:ForumSurfer.ViewModel"
7+
mc:Ignorable="d"
8+
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
9+
d:DesignHeight="200" d:DesignWidth="300">
10+
11+
12+
<UserControl.Resources>
13+
<Style TargetType="{x:Type Control}" x:Key="ControlStyle">
14+
<Setter Property="FontFamily" Value="Segoe UI"/>
15+
<Setter Property="FontSize" Value="15" />
16+
</Style>
17+
<Style TargetType="{x:Type Label}" x:Key="LabelStyle" BasedOn="{StaticResource ControlStyle}" />
18+
<Style TargetType="{x:Type TextBox}" x:Key="TextStyle" BasedOn="{StaticResource ControlStyle}" />
19+
</UserControl.Resources>
20+
21+
22+
<Grid>
23+
<Grid.RowDefinitions>
24+
<RowDefinition Height="auto" />
25+
<RowDefinition Height="auto" />
26+
<RowDefinition Height="auto" />
27+
</Grid.RowDefinitions>
28+
<Grid.ColumnDefinitions>
29+
<ColumnDefinition Width="200" />
30+
</Grid.ColumnDefinitions>
31+
<DockPanel>
32+
<Label DockPanel.Dock="Top" Style="{StaticResource LabelStyle}">
33+
Page Zoom
34+
</Label>
35+
<Controls:NumericUpDown Minimum="20" Maximum="500" Interval="10" Value="{Binding PageZoom, Mode=TwoWay}"/>
36+
</DockPanel>
37+
<DockPanel Grid.Row="1">
38+
<Label DockPanel.Dock="Top" Style="{StaticResource LabelStyle}">
39+
Text Zoom
40+
</Label>
41+
<Controls:NumericUpDown Name="TextZoomUD" Minimum="0" Maximum="4" Interval="1" Value="{Binding TextZoom, Mode=TwoWay}" />
42+
</DockPanel>
43+
<DockPanel Grid.Row="2" LastChildFill="False">
44+
<Button DockPanel.Dock="Right" Margin="10" Padding="10" FontFamily="Segoe UI" Background="{DynamicResource AccentColorBrush}" Foreground="White" Command="{Binding CancelCommand}">Cancel</Button>
45+
<Button DockPanel.Dock="Right" Margin="10" Padding="10" FontFamily="Segoe UI" Background="{DynamicResource AccentColorBrush}" Foreground="White" Command="{Binding OKCommand}">OK</Button>
46+
</DockPanel>
47+
</Grid>
48+
</UserControl>

0 commit comments

Comments
 (0)