mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-23 03:15:48 +02:00
Add an option to change the zoom level
This commit is contained in:
parent
a69b3cd05f
commit
041abe6d7e
@ -14,7 +14,7 @@ namespace TweetDck.Configuration{
|
||||
sealed class UserConfig{
|
||||
private static readonly IFormatter Formatter = new BinaryFormatter();
|
||||
|
||||
private const int CurrentFileVersion = 7;
|
||||
private const int CurrentFileVersion = 8;
|
||||
|
||||
// START OF CONFIGURATION
|
||||
|
||||
@ -68,6 +68,28 @@ public bool MuteNotifications{
|
||||
}
|
||||
}
|
||||
|
||||
public int ZoomLevel{
|
||||
get{
|
||||
return zoomLevel;
|
||||
}
|
||||
|
||||
set{
|
||||
if (zoomLevel == value)return;
|
||||
|
||||
zoomLevel = value;
|
||||
|
||||
if (ZoomLevelChanged != null){
|
||||
ZoomLevelChanged(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double ZoomMultiplier{
|
||||
get{
|
||||
return zoomLevel/100.0;
|
||||
}
|
||||
}
|
||||
|
||||
public string NotificationSoundPath{
|
||||
get{
|
||||
return string.IsNullOrEmpty(notificationSoundPath) ? string.Empty : notificationSoundPath;
|
||||
@ -99,6 +121,9 @@ public TrayIcon.Behavior TrayBehavior{
|
||||
[field:NonSerialized]
|
||||
public event EventHandler MuteToggled;
|
||||
|
||||
[field:NonSerialized]
|
||||
public event EventHandler ZoomLevelChanged;
|
||||
|
||||
[field:NonSerialized]
|
||||
public event EventHandler TrayBehaviorChanged;
|
||||
|
||||
@ -107,6 +132,7 @@ public TrayIcon.Behavior TrayBehavior{
|
||||
|
||||
private int fileVersion;
|
||||
private bool muteNotifications;
|
||||
private int zoomLevel;
|
||||
private string notificationSoundPath;
|
||||
private TrayIcon.Behavior trayBehavior;
|
||||
|
||||
@ -114,6 +140,7 @@ private UserConfig(string file){
|
||||
this.file = file;
|
||||
|
||||
BrowserWindow = new WindowState();
|
||||
ZoomLevel = 100;
|
||||
DisplayNotificationTimer = true;
|
||||
NotificationNonIntrusiveMode = true;
|
||||
NotificationPosition = TweetNotification.Position.TopRight;
|
||||
@ -175,6 +202,11 @@ private void UpgradeFile(){
|
||||
++fileVersion;
|
||||
}
|
||||
|
||||
if (fileVersion == 7){
|
||||
ZoomLevel = 100;
|
||||
++fileVersion;
|
||||
}
|
||||
|
||||
// update the version
|
||||
fileVersion = CurrentFileVersion;
|
||||
Save();
|
||||
|
@ -109,6 +109,7 @@ public FormBrowser(PluginManager pluginManager, UpdaterSettings updaterSettings)
|
||||
UpdateTrayIcon();
|
||||
|
||||
Config.MuteToggled += Config_MuteToggled;
|
||||
Config.ZoomLevelChanged += Config_ZoomLevelChanged;
|
||||
|
||||
this.updates = new UpdateHandler(browser, this, updaterSettings);
|
||||
this.updates.UpdateAccepted += updates_UpdateAccepted;
|
||||
@ -171,8 +172,14 @@ private void browser_LoadingStateChanged(object sender, LoadingStateChangedEvent
|
||||
}
|
||||
|
||||
private void browser_FrameLoadStart(object sender, FrameLoadStartEventArgs e){
|
||||
if (e.Frame.IsMain && BrowserUtils.IsTwitterWebsite(e.Frame)){
|
||||
ScriptLoader.ExecuteFile(e.Frame, "twitter.js");
|
||||
if (e.Frame.IsMain){
|
||||
if (Config.ZoomLevel != 100){
|
||||
BrowserUtils.SetZoomLevel(browser.GetBrowser(), Config.ZoomLevel);
|
||||
}
|
||||
|
||||
if (BrowserUtils.IsTwitterWebsite(e.Frame)){
|
||||
ScriptLoader.ExecuteFile(e.Frame, "twitter.js");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -253,6 +260,10 @@ private void Config_MuteToggled(object sender, EventArgs e){
|
||||
UpdateProperties(PropertyBridge.Properties.MuteNotifications);
|
||||
}
|
||||
|
||||
private void Config_ZoomLevelChanged(object sender, EventArgs e){
|
||||
BrowserUtils.SetZoomLevel(browser.GetBrowser(), Config.ZoomLevel);
|
||||
}
|
||||
|
||||
private void Config_TrayBehaviorChanged(object sender, EventArgs e){
|
||||
UpdateTrayIcon();
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ protected virtual void LoadTweet(TweetNotification tweet){
|
||||
}
|
||||
|
||||
protected virtual void SetNotificationSize(int width, int height){
|
||||
browser.ClientSize = ClientSize = new Size(width, height);
|
||||
browser.ClientSize = ClientSize = new Size((int)Math.Round(width*Program.UserConfig.ZoomMultiplier), (int)Math.Round(height*Program.UserConfig.ZoomMultiplier));
|
||||
}
|
||||
|
||||
protected virtual void OnNotificationReady(){
|
||||
|
@ -26,14 +26,16 @@ static FormNotificationMain(){
|
||||
private static int BaseClientWidth{
|
||||
get{
|
||||
int level = TweetNotification.FontSizeLevel;
|
||||
return level == 0 ? 284 : (int)Math.Round(284.0*(1.0+0.05*level));
|
||||
int width = level == 0 ? 284 : (int)Math.Round(284.0*(1.0+0.05*level));
|
||||
return (int)Math.Round(width*Program.UserConfig.ZoomMultiplier);
|
||||
}
|
||||
}
|
||||
|
||||
private static int BaseClientHeight{
|
||||
get{
|
||||
int level = TweetNotification.FontSizeLevel;
|
||||
return level == 0 ? 118 : (int)Math.Round(118.0*(1.0+0.075*level));
|
||||
int height = level == 0 ? 118 : (int)Math.Round(118.0*(1.0+0.075*level));
|
||||
return (int)Math.Round(height*Program.UserConfig.ZoomMultiplier);
|
||||
}
|
||||
}
|
||||
|
||||
|
61
Core/Other/Settings/TabSettingsGeneral.Designer.cs
generated
61
Core/Other/Settings/TabSettingsGeneral.Designer.cs
generated
@ -34,9 +34,14 @@ private void InitializeComponent() {
|
||||
this.groupTray = new System.Windows.Forms.GroupBox();
|
||||
this.labelTrayIcon = new System.Windows.Forms.Label();
|
||||
this.groupInterface = new System.Windows.Forms.GroupBox();
|
||||
this.labelZoomValue = new System.Windows.Forms.Label();
|
||||
this.trackBarZoom = new System.Windows.Forms.TrackBar();
|
||||
this.labelZoom = new System.Windows.Forms.Label();
|
||||
this.groupUpdates = new System.Windows.Forms.GroupBox();
|
||||
this.zoomUpdateTimer = new System.Windows.Forms.Timer(this.components);
|
||||
this.groupTray.SuspendLayout();
|
||||
this.groupInterface.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.trackBarZoom)).BeginInit();
|
||||
this.groupUpdates.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
@ -116,7 +121,7 @@ private void InitializeComponent() {
|
||||
this.groupTray.Controls.Add(this.checkTrayHighlight);
|
||||
this.groupTray.Controls.Add(this.labelTrayIcon);
|
||||
this.groupTray.Controls.Add(this.comboBoxTrayType);
|
||||
this.groupTray.Location = new System.Drawing.Point(9, 82);
|
||||
this.groupTray.Location = new System.Drawing.Point(9, 145);
|
||||
this.groupTray.Name = "groupTray";
|
||||
this.groupTray.Size = new System.Drawing.Size(183, 93);
|
||||
this.groupTray.TabIndex = 1;
|
||||
@ -135,15 +140,57 @@ private void InitializeComponent() {
|
||||
//
|
||||
// groupInterface
|
||||
//
|
||||
this.groupInterface.Controls.Add(this.labelZoomValue);
|
||||
this.groupInterface.Controls.Add(this.trackBarZoom);
|
||||
this.groupInterface.Controls.Add(this.labelZoom);
|
||||
this.groupInterface.Controls.Add(this.checkSpellCheck);
|
||||
this.groupInterface.Controls.Add(this.checkExpandLinks);
|
||||
this.groupInterface.Location = new System.Drawing.Point(9, 9);
|
||||
this.groupInterface.Name = "groupInterface";
|
||||
this.groupInterface.Size = new System.Drawing.Size(183, 67);
|
||||
this.groupInterface.Size = new System.Drawing.Size(183, 130);
|
||||
this.groupInterface.TabIndex = 0;
|
||||
this.groupInterface.TabStop = false;
|
||||
this.groupInterface.Text = "User Interface";
|
||||
//
|
||||
// labelZoomValue
|
||||
//
|
||||
this.labelZoomValue.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.labelZoomValue.BackColor = System.Drawing.Color.Transparent;
|
||||
this.labelZoomValue.Location = new System.Drawing.Point(139, 93);
|
||||
this.labelZoomValue.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
|
||||
this.labelZoomValue.Name = "labelZoomValue";
|
||||
this.labelZoomValue.Size = new System.Drawing.Size(38, 13);
|
||||
this.labelZoomValue.TabIndex = 4;
|
||||
this.labelZoomValue.Text = "100%";
|
||||
this.labelZoomValue.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
||||
this.toolTip.SetToolTip(this.labelZoomValue, "Changes the zoom level.\r\nAlso affects notifications and screenshots.");
|
||||
//
|
||||
// trackBarZoom
|
||||
//
|
||||
this.trackBarZoom.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.trackBarZoom.AutoSize = false;
|
||||
this.trackBarZoom.LargeChange = 25;
|
||||
this.trackBarZoom.Location = new System.Drawing.Point(6, 92);
|
||||
this.trackBarZoom.Maximum = 200;
|
||||
this.trackBarZoom.Minimum = 50;
|
||||
this.trackBarZoom.Name = "trackBarZoom";
|
||||
this.trackBarZoom.Size = new System.Drawing.Size(141, 30);
|
||||
this.trackBarZoom.SmallChange = 5;
|
||||
this.trackBarZoom.TabIndex = 3;
|
||||
this.trackBarZoom.TickFrequency = 25;
|
||||
this.trackBarZoom.Value = 100;
|
||||
//
|
||||
// labelZoom
|
||||
//
|
||||
this.labelZoom.AutoSize = true;
|
||||
this.labelZoom.Location = new System.Drawing.Point(5, 76);
|
||||
this.labelZoom.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
|
||||
this.labelZoom.Name = "labelZoom";
|
||||
this.labelZoom.Size = new System.Drawing.Size(34, 13);
|
||||
this.labelZoom.TabIndex = 2;
|
||||
this.labelZoom.Text = "Zoom";
|
||||
//
|
||||
// groupUpdates
|
||||
//
|
||||
this.groupUpdates.Controls.Add(this.checkUpdateNotifications);
|
||||
@ -155,6 +202,11 @@ private void InitializeComponent() {
|
||||
this.groupUpdates.TabStop = false;
|
||||
this.groupUpdates.Text = "Updates";
|
||||
//
|
||||
// zoomUpdateTimer
|
||||
//
|
||||
this.zoomUpdateTimer.Interval = 250;
|
||||
this.zoomUpdateTimer.Tick += new System.EventHandler(this.zoomUpdateTimer_Tick);
|
||||
//
|
||||
// TabSettingsGeneral
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@ -168,6 +220,7 @@ private void InitializeComponent() {
|
||||
this.groupTray.PerformLayout();
|
||||
this.groupInterface.ResumeLayout(false);
|
||||
this.groupInterface.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.trackBarZoom)).EndInit();
|
||||
this.groupUpdates.ResumeLayout(false);
|
||||
this.groupUpdates.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
@ -187,5 +240,9 @@ private void InitializeComponent() {
|
||||
private System.Windows.Forms.GroupBox groupUpdates;
|
||||
private System.Windows.Forms.CheckBox checkUpdateNotifications;
|
||||
private System.Windows.Forms.Button btnCheckUpdates;
|
||||
private System.Windows.Forms.Label labelZoom;
|
||||
private System.Windows.Forms.Label labelZoomValue;
|
||||
private System.Windows.Forms.TrackBar trackBarZoom;
|
||||
private System.Windows.Forms.Timer zoomUpdateTimer;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDck.Updates;
|
||||
using TweetDck.Updates.Events;
|
||||
|
||||
@ -21,6 +22,10 @@ public TabSettingsGeneral(UpdateHandler updates){
|
||||
comboBoxTrayType.Items.Add("Close to Tray");
|
||||
comboBoxTrayType.Items.Add("Combined");
|
||||
comboBoxTrayType.SelectedIndex = Math.Min(Math.Max((int)Config.TrayBehavior, 0), comboBoxTrayType.Items.Count-1);
|
||||
|
||||
toolTip.SetToolTip(trackBarZoom, toolTip.GetToolTip(labelZoomValue));
|
||||
trackBarZoom.SetValueSafe(Config.ZoomLevel);
|
||||
labelZoomValue.Text = trackBarZoom.Value+"%";
|
||||
|
||||
checkExpandLinks.Checked = Config.ExpandLinksOnHover;
|
||||
checkSpellCheck.Checked = Config.EnableSpellCheck;
|
||||
@ -32,6 +37,7 @@ public TabSettingsGeneral(UpdateHandler updates){
|
||||
public override void OnReady(){
|
||||
checkExpandLinks.CheckedChanged += checkExpandLinks_CheckedChanged;
|
||||
checkSpellCheck.CheckedChanged += checkSpellCheck_CheckedChanged;
|
||||
trackBarZoom.ValueChanged += trackBarZoom_ValueChanged;
|
||||
|
||||
comboBoxTrayType.SelectedIndexChanged += comboBoxTrayType_SelectedIndexChanged;
|
||||
checkTrayHighlight.CheckedChanged += checkTrayHighlight_CheckedChanged;
|
||||
@ -40,6 +46,10 @@ public override void OnReady(){
|
||||
btnCheckUpdates.Click += btnCheckUpdates_Click;
|
||||
}
|
||||
|
||||
public override void OnClosing(){
|
||||
Config.ZoomLevel = trackBarZoom.Value;
|
||||
}
|
||||
|
||||
private void checkExpandLinks_CheckedChanged(object sender, EventArgs e){
|
||||
Config.ExpandLinksOnHover = checkExpandLinks.Checked;
|
||||
}
|
||||
@ -49,6 +59,17 @@ private void checkSpellCheck_CheckedChanged(object sender, EventArgs e){
|
||||
PromptRestart();
|
||||
}
|
||||
|
||||
private void trackBarZoom_ValueChanged(object sender, EventArgs e){
|
||||
if (trackBarZoom.Value % trackBarZoom.SmallChange != 0){
|
||||
trackBarZoom.Value = trackBarZoom.SmallChange*(int)Math.Floor(((double)trackBarZoom.Value/trackBarZoom.SmallChange)+0.5);
|
||||
}
|
||||
else{
|
||||
zoomUpdateTimer.Stop();
|
||||
zoomUpdateTimer.Start();
|
||||
labelZoomValue.Text = trackBarZoom.Value+"%";
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBoxTrayType_SelectedIndexChanged(object sender, EventArgs e){
|
||||
Config.TrayBehavior = (TrayIcon.Behavior)comboBoxTrayType.SelectedIndex;
|
||||
}
|
||||
@ -82,5 +103,10 @@ private void updates_CheckFinished(object sender, UpdateCheckEventArgs e){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void zoomUpdateTimer_Tick(object sender, EventArgs e){
|
||||
Config.ZoomLevel = trackBarZoom.Value;
|
||||
zoomUpdateTimer.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -88,6 +88,10 @@ public static void DownloadFileAsync(string url, string target, Action<Exception
|
||||
client.DownloadFileAsync(new Uri(url), target);
|
||||
}
|
||||
|
||||
public static void SetZoomLevel(IBrowser browser, int percentage){
|
||||
browser.GetHost().SetZoomLevel(Math.Log(percentage/100.0, 1.2));
|
||||
}
|
||||
|
||||
public static bool IsTweetDeckWebsite(IFrame frame){
|
||||
return frame.Url.Contains("//tweetdeck.twitter.com/");
|
||||
}
|
||||
|
@ -350,7 +350,7 @@
|
||||
|
||||
window.TDGF_triggerScreenshot = function(){
|
||||
if (selectedTweet){
|
||||
var tweetWidth = selectedTweet.width();
|
||||
var tweetWidth = Math.floor(selectedTweet.width());
|
||||
var parent = selectedTweet.parent();
|
||||
|
||||
var isDetail = parent.hasClass("js-tweet-detail");
|
||||
@ -394,7 +394,7 @@
|
||||
width: tweetWidth+"px"
|
||||
}).appendTo(document.body);
|
||||
|
||||
var realHeight = testTweet.height();
|
||||
var realHeight = Math.floor(testTweet.height());
|
||||
testTweet.remove();
|
||||
|
||||
$TD.screenshotTweet(selectedTweet.html(), tweetWidth, realHeight);
|
||||
|
Loading…
Reference in New Issue
Block a user