diff --git a/.gitignore b/.gitignore index 7b258094..1e672c11 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ bin/ obj/ *.suo *.user +packages \ No newline at end of file diff --git a/Eve-O-Preview/Configuration/IThumbnailConfig.cs b/Eve-O-Preview/Configuration/IThumbnailConfig.cs index d5636293..5dd502ab 100644 --- a/Eve-O-Preview/Configuration/IThumbnailConfig.cs +++ b/Eve-O-Preview/Configuration/IThumbnailConfig.cs @@ -19,7 +19,7 @@ public interface IThumbnailConfig bool HideThumbnailsOnLostFocus { get; set; } bool EnablePerClientThumbnailLayouts { get; set; } - Size ThumbnailSize { get; set; } + Size ThumbnailDefaultSize { get; set; } Size ThumbnailMinimumSize { get; set; } Size ThumbnailMaximumSize { get; set; } @@ -34,10 +34,17 @@ public interface IThumbnailConfig Color ActiveClientHighlightColor { get; set; } int ActiveClientHighlightThickness { get; set; } + bool SyncThumbnailSizes { get; set; } + + bool LockThumbnails { get; set; } + Point GetThumbnailLocation(string currentClient, string activeClient, Point defaultLocation); void SetThumbnailLocation(string currentClient, string activeClient, Point location); - ClientLayout GetClientLayout(string currentClient); + Size GetThumbnailSize(string currentClient, string activeClient, Size defaultSize); + void SetThumbnailSize(string currentClient, string activeClient, Size size); + + ClientLayout GetClientLayout(string currentClient); void SetClientLayout(string currentClient, ClientLayout layout); Keys GetClientHotkey(string currentClient); diff --git a/Eve-O-Preview/Configuration/ThumbnailConfig.cs b/Eve-O-Preview/Configuration/ThumbnailConfig.cs index 73b91040..bbd450ad 100644 --- a/Eve-O-Preview/Configuration/ThumbnailConfig.cs +++ b/Eve-O-Preview/Configuration/ThumbnailConfig.cs @@ -20,7 +20,7 @@ public ThumbnailConfig() this.HideThumbnailsOnLostFocus = false; this.EnablePerClientThumbnailLayouts = false; - this.ThumbnailSize = new Size(250, 150); + this.ThumbnailDefaultSize = new Size(250, 150); this.ThumbnailMinimumSize = new Size(100, 80); this.ThumbnailMaximumSize = new Size(640, 400); @@ -35,6 +35,13 @@ public ThumbnailConfig() this.ActiveClientHighlightColor = Color.GreenYellow; this.ActiveClientHighlightThickness = 3; + this.SyncThumbnailSizes = false; + + this.LockThumbnails = false; + + this.PerClientSizes = new Dictionary>(); + this.FlatSizes = new Dictionary(); + this.PerClientLayout = new Dictionary>(); this.FlatLayout = new Dictionary(); this.ClientLayout = new Dictionary(); @@ -53,7 +60,8 @@ public ThumbnailConfig() public bool HideThumbnailsOnLostFocus { get; set; } public bool EnablePerClientThumbnailLayouts { get; set; } - public Size ThumbnailSize { get; set; } + [JsonProperty("ThumbnailSize")] + public Size ThumbnailDefaultSize { get; set; } public Size ThumbnailMaximumSize { get; set; } public Size ThumbnailMinimumSize { get; set; } @@ -71,7 +79,17 @@ public ThumbnailConfig() public int ActiveClientHighlightThickness { get; set; } + [JsonProperty("SyncSizesToDefault")] + public bool SyncThumbnailSizes { get; set; } + + public bool LockThumbnails { get; set; } + [JsonProperty] + private Dictionary> PerClientSizes { get; set; } + [JsonProperty] + private Dictionary FlatSizes { get; set; } + + [JsonProperty] private Dictionary> PerClientLayout { get; set; } [JsonProperty] private Dictionary FlatLayout { get; set; } @@ -129,7 +147,56 @@ public void SetThumbnailLocation(string currentClient, string activeClient, Poin layoutSource[currentClient] = location; } - public ClientLayout GetClientLayout(string currentClient) + public Size GetThumbnailSize(string currentClient, string activeClient, Size defaultSize) + { + Size size; + + // What this code does: + // If Per-Client layouts are enabled + // and client name is known + // and there is a separate thumbnails layout for this client + // and this layout contains an entry for the current client + // then return that entry + // otherwise try to get client layout from the flat all-clients layout + // If there is no layout too then use the default one + if (this.EnablePerClientThumbnailLayouts && !string.IsNullOrEmpty(activeClient)) + { + Dictionary layoutSource; + if (this.PerClientSizes.TryGetValue(activeClient, out layoutSource) && layoutSource.TryGetValue(currentClient, out size)) + { + return size; + } + } + + return this.FlatSizes.TryGetValue(currentClient, out size) ? size : defaultSize; + } + + public void SetThumbnailSize(string currentClient, string activeClient, Size size) + { + Dictionary layoutSource; + + if (this.EnablePerClientThumbnailLayouts) + { + if (string.IsNullOrEmpty(activeClient)) + { + return; + } + + if (!this.PerClientSizes.TryGetValue(activeClient, out layoutSource)) + { + layoutSource = new Dictionary(); + this.PerClientSizes[activeClient] = layoutSource; + } + } + else + { + layoutSource = this.FlatSizes; + } + + layoutSource[currentClient] = size; + } + + public ClientLayout GetClientLayout(string currentClient) { ClientLayout layout; this.ClientLayout.TryGetValue(currentClient, out layout); @@ -166,8 +233,8 @@ public void SetClientHotkey(string currentClient, Keys hotkey) public void ApplyRestrictions() { this.ThumbnailRefreshPeriod = ThumbnailConfig.ApplyRestrictions(this.ThumbnailRefreshPeriod, 300, 1000); - this.ThumbnailSize = new Size(ThumbnailConfig.ApplyRestrictions(this.ThumbnailSize.Width, this.ThumbnailMinimumSize.Width, this.ThumbnailMaximumSize.Width), - ThumbnailConfig.ApplyRestrictions(this.ThumbnailSize.Height, this.ThumbnailMinimumSize.Height, this.ThumbnailMaximumSize.Height)); + this.ThumbnailDefaultSize = new Size(ThumbnailConfig.ApplyRestrictions(this.ThumbnailDefaultSize.Width, this.ThumbnailMinimumSize.Width, this.ThumbnailMaximumSize.Width), + ThumbnailConfig.ApplyRestrictions(this.ThumbnailDefaultSize.Height, this.ThumbnailMinimumSize.Height, this.ThumbnailMaximumSize.Height)); this.ThumbnailOpacity = ThumbnailConfig.ApplyRestrictions((int)(this.ThumbnailOpacity * 100.00), 20, 100) / 100.00; this.ThumbnailZoomFactor = ThumbnailConfig.ApplyRestrictions(this.ThumbnailZoomFactor, 2, 10); this.ActiveClientHighlightThickness = ThumbnailConfig.ApplyRestrictions(this.ActiveClientHighlightThickness, 1, 6); diff --git a/Eve-O-Preview/Presentation/IThumbnailManager.cs b/Eve-O-Preview/Presentation/IThumbnailManager.cs index 4b54235d..490e24fa 100644 --- a/Eve-O-Preview/Presentation/IThumbnailManager.cs +++ b/Eve-O-Preview/Presentation/IThumbnailManager.cs @@ -10,9 +10,12 @@ public interface IThumbnailManager void Deactivate(); void SetThumbnailState(IntPtr thumbnailId, bool hideAlways); - void SetThumbnailsSize(Size size); + void SetThumbnailsSize(IntPtr id, Size size); void SetupThumbnailFrames(); + void SetThumbnailResizeLock(bool locked); + void SetThumbnailPositionLock(bool locked); + Action> ThumbnailsAdded { get; set; } Action> ThumbnailsUpdated { get; set; } Action> ThumbnailsRemoved { get; set; } diff --git a/Eve-O-Preview/Presentation/MainPresenter.cs b/Eve-O-Preview/Presentation/MainPresenter.cs index 71b9d685..64576020 100644 --- a/Eve-O-Preview/Presentation/MainPresenter.cs +++ b/Eve-O-Preview/Presentation/MainPresenter.cs @@ -43,6 +43,8 @@ public MainPresenter(IApplicationController controller, IMainView view, IThumbna this.View.ThumbnailStateChanged = this.UpdateThumbnailState; this.View.ForumUrlLinkActivated = this.OpenForumUrlLink; this.View.ApplicationExitRequested = this.ExitApplication; + this.View.SyncChanged = this.SyncChanged; + this.View.LockChanged = this.LockChanged; this._thumbnailManager.ThumbnailsAdded = this.ThumbnailsAdded; this._thumbnailManager.ThumbnailsUpdated = this.ThumbnailsUpdated; @@ -54,12 +56,16 @@ private void Activate() { this.LoadApplicationSettings(); this.View.SetForumUrl(MainPresenter.ForumUrl); + if (this._configuration.MinimizeToTray) { this.View.Minimize(); } this._thumbnailManager.Activate(); + + this.SyncChanged(); + this.LockChanged(); } private void Minimize() @@ -88,8 +94,25 @@ private void Close(ViewCloseRequest request) private void UpdateThumbnailsSize() { - this._thumbnailManager.SetThumbnailsSize(this.View.ThumbnailSize); + this.SaveApplicationSettings(); + + if (this.View.SyncThumbnailSizes) + { + this._thumbnailManager.Activate(); + } + } + + private void SyncChanged() + { + this._thumbnailManager.SetThumbnailResizeLock(this.View.SyncThumbnailSizes || this.View.LockThumbnails); //if either is true, lock resize + this._thumbnailManager.Activate(); + } + + private void LockChanged() + { + this._thumbnailManager.SetThumbnailPositionLock(this.View.LockThumbnails); + this._thumbnailManager.SetThumbnailResizeLock(this.View.SyncThumbnailSizes || this.View.LockThumbnails); } private void LoadApplicationSettings() @@ -107,7 +130,7 @@ private void LoadApplicationSettings() this.View.EnablePerClientThumbnailLayouts = this._configuration.EnablePerClientThumbnailLayouts; this.View.SetThumbnailSizeLimitations(this._configuration.ThumbnailMinimumSize, this._configuration.ThumbnailMaximumSize); - this.View.ThumbnailSize = this._configuration.ThumbnailSize; + this.View.ThumbnailSize = this._configuration.ThumbnailDefaultSize; this.View.EnableThumbnailZoom = this._configuration.ThumbnailZoomEnabled; this.View.ThumbnailZoomFactor = this._configuration.ThumbnailZoomFactor; @@ -117,6 +140,10 @@ private void LoadApplicationSettings() this.View.ShowThumbnailFrames = this._configuration.ShowThumbnailFrames; this.View.EnableActiveClientHighlight = this._configuration.EnableActiveClientHighlight; this.View.ActiveClientHighlightColor = this._configuration.ActiveClientHighlightColor; + + this.View.SyncThumbnailSizes = this._configuration.SyncThumbnailSizes; + + this.View.LockThumbnails = this._configuration.LockThumbnails; } private void SaveApplicationSettings() @@ -131,7 +158,7 @@ private void SaveApplicationSettings() this._configuration.HideThumbnailsOnLostFocus = this.View.HideThumbnailsOnLostFocus; this._configuration.EnablePerClientThumbnailLayouts = this.View.EnablePerClientThumbnailLayouts; - this._configuration.ThumbnailSize = this.View.ThumbnailSize; + this._configuration.ThumbnailDefaultSize = this.View.ThumbnailSize; this._configuration.ThumbnailZoomEnabled = this.View.EnableThumbnailZoom; this._configuration.ThumbnailZoomFactor = this.View.ThumbnailZoomFactor; @@ -142,6 +169,10 @@ private void SaveApplicationSettings() this._configuration.EnableActiveClientHighlight = this.View.EnableActiveClientHighlight; this._configuration.ActiveClientHighlightColor = this.View.ActiveClientHighlightColor; + this._configuration.SyncThumbnailSizes = this.View.SyncThumbnailSizes; + + this._configuration.LockThumbnails = this.View.LockThumbnails; + this._configurationStorage.Save(); this.View.RefreshZoomSettings(); @@ -152,6 +183,8 @@ private void SaveApplicationSettings() private void ThumbnailsAdded(IList thumbnails) { this.View.AddThumbnails(this.GetThumbnailViews(thumbnails, false)); + this.LockChanged(); + this.SyncChanged(); } private void ThumbnailsUpdated(IList thumbnails) @@ -208,7 +241,7 @@ private IList GetThumbnailViews(IList private void ThumbnailSizeChanged(Size size) { - this.View.ThumbnailSize = size; + //don't need to change anything here } private void UpdateThumbnailState(IntPtr thumbnailId) diff --git a/Eve-O-Preview/Presentation/ThumbnailManager.cs b/Eve-O-Preview/Presentation/ThumbnailManager.cs index 9888953e..4de0cdc2 100644 --- a/Eve-O-Preview/Presentation/ThumbnailManager.cs +++ b/Eve-O-Preview/Presentation/ThumbnailManager.cs @@ -77,21 +77,39 @@ public void SetThumbnailState(IntPtr thumbnailId, bool hideAlways) thumbnail.IsEnabled = !hideAlways; } - public void SetThumbnailsSize(Size size) + public void SetThumbnailsSize(IntPtr id, Size size) { this.DisableViewEvents(); - foreach (KeyValuePair entry in this._thumbnailViews) - { - entry.Value.ThumbnailSize = size; - entry.Value.Refresh(false); - } + IThumbnailView view; + + if(this._thumbnailViews.TryGetValue(id, out view)) + { + view.ThumbnailSize = size; + view.Refresh(false); + } this.ThumbnailSizeChanged?.Invoke(size); this.EnableViewEvents(); } + public void SetThumbnailResizeLock(bool locked) + { + foreach(IThumbnailView view in this._thumbnailViews.Values) + { + view.SetResizeLocked(locked); + } + } + + public void SetThumbnailPositionLock(bool locked) + { + foreach (IThumbnailView view in this._thumbnailViews.Values) + { + view.SetPositionLocked(locked); + } + } + private void RefreshThumbnails() { IntPtr foregroundWindowHandle = WindowManagerNativeMethods.GetForegroundWindow(); @@ -129,6 +147,7 @@ private void RefreshThumbnails() if (view.Title != ThumbnailManager.DefaultClientTitle) { view.ThumbnailLocation = this._configuration.GetThumbnailLocation(view.Title, this._activeClientTitle, view.ThumbnailLocation); + view.ThumbnailSize = this._configuration.SyncThumbnailSizes ? this._configuration.ThumbnailDefaultSize : this._configuration.GetThumbnailSize(view.Title, this._activeClientTitle, view.ThumbnailSize); } view.SetOpacity(this._configuration.ThumbnailOpacity); @@ -208,7 +227,7 @@ private void UpdateThumbnailsList() if ((view == null) && (processTitle != "")) { - view = this._thumbnailViewFactory.Create(processHandle, processTitle, this._configuration.ThumbnailSize); + view = this._thumbnailViewFactory.Create(processHandle, processTitle, this._configuration.ThumbnailDefaultSize); view.IsEnabled = true; view.IsOverlayEnabled = this._configuration.ShowThumbnailOverlays; view.SetFrames(this._configuration.ShowThumbnailFrames); @@ -216,7 +235,9 @@ private void UpdateThumbnailsList() // Otherwise thumbnail window will be unnecessary resized view.SetSizeLimitations(this._configuration.ThumbnailMinimumSize, this._configuration.ThumbnailMaximumSize); view.SetTopMost(this._configuration.ShowThumbnailsAlwaysOnTop); - view.ThumbnailLocation = this._configuration.GetThumbnailLocation(processTitle, this._activeClientTitle, view.ThumbnailLocation); + + view.ThumbnailLocation = this._configuration.GetThumbnailLocation(processTitle, this._activeClientTitle, view.ThumbnailLocation); + view.ThumbnailSize = this._configuration.SyncThumbnailSizes ? this._configuration.ThumbnailDefaultSize : this._configuration.GetThumbnailSize(processTitle, this._activeClientTitle, view.ThumbnailSize); this._thumbnailViews.Add(processHandle, view); @@ -360,7 +381,12 @@ private void ThumbnailViewResized(IntPtr id) IThumbnailView view = this._thumbnailViews[id]; - this.SetThumbnailsSize(view.ThumbnailSize); + this.SetThumbnailsSize(id, view.ThumbnailSize); + + if (!this._configuration.SyncThumbnailSizes) + { + this._configuration.SetThumbnailSize(view.Title, this._activeClientTitle, view.ThumbnailSize); + } view.Refresh(false); } diff --git a/Eve-O-Preview/UI/Implementation/MainForm.Designer.cs b/Eve-O-Preview/UI/Implementation/MainForm.Designer.cs index bbf116b0..37239635 100644 --- a/Eve-O-Preview/UI/Implementation/MainForm.Designer.cs +++ b/Eve-O-Preview/UI/Implementation/MainForm.Designer.cs @@ -54,6 +54,7 @@ private void InitializeComponent() this.ShowThumbnailsAlwaysOnTopCheckBox = new System.Windows.Forms.CheckBox(); this.HideThumbnailsOnLostFocusCheckBox = new System.Windows.Forms.CheckBox(); this.EnablePerClientThumbnailsLayoutsCheckBox = new System.Windows.Forms.CheckBox(); + this.SyncCheckbox = new System.Windows.Forms.CheckBox(); this.ThumbnailsWidthNumericEdit = new System.Windows.Forms.NumericUpDown(); this.ThumbnailsHeightNumericEdit = new System.Windows.Forms.NumericUpDown(); this.ZoomAnchorPanel = new System.Windows.Forms.Panel(); @@ -77,6 +78,7 @@ private void InitializeComponent() this.ForumLinkLabel = new System.Windows.Forms.LinkLabel(); this.NotifyIcon = new System.Windows.Forms.NotifyIcon(this.components); this.TrayMenu = new System.Windows.Forms.ContextMenuStrip(this.components); + this.LockCheckbox = new System.Windows.Forms.CheckBox(); OpacityLabel = new System.Windows.Forms.Label(); RestoreWindowMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ExitMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -133,6 +135,7 @@ private void InitializeComponent() MainOptionsPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); MainOptionsPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + MainOptionsPanel.Controls.Add(this.LockCheckbox); MainOptionsPanel.Controls.Add(this.ThumbnailOpacityTrackBar); MainOptionsPanel.Controls.Add(this.MinimizeToTrayCheckBox); MainOptionsPanel.Controls.Add(this.EnableClientLayoutTrackingCheckBox); @@ -143,7 +146,7 @@ private void InitializeComponent() MainOptionsPanel.Controls.Add(OpacityLabel); MainOptionsPanel.Location = new System.Drawing.Point(3, 3); MainOptionsPanel.Name = "MainOptionsPanel"; - MainOptionsPanel.Size = new System.Drawing.Size(264, 164); + MainOptionsPanel.Size = new System.Drawing.Size(264, 187); MainOptionsPanel.TabIndex = 0; // // ThumbnailOpacityTrackBar @@ -237,22 +240,34 @@ private void InitializeComponent() // // ThumbnailSizePanel // - ThumbnailSizePanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + ThumbnailSizePanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); ThumbnailSizePanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + ThumbnailSizePanel.Controls.Add(this.SyncCheckbox); ThumbnailSizePanel.Controls.Add(HeigthLabel); ThumbnailSizePanel.Controls.Add(WidthLabel); ThumbnailSizePanel.Controls.Add(this.ThumbnailsWidthNumericEdit); ThumbnailSizePanel.Controls.Add(this.ThumbnailsHeightNumericEdit); - ThumbnailSizePanel.Location = new System.Drawing.Point(3, 173); + ThumbnailSizePanel.Location = new System.Drawing.Point(3, 196); ThumbnailSizePanel.Name = "ThumbnailSizePanel"; - ThumbnailSizePanel.Size = new System.Drawing.Size(264, 28); + ThumbnailSizePanel.Size = new System.Drawing.Size(264, 54); ThumbnailSizePanel.TabIndex = 1; // + // SyncCheckbox + // + this.SyncCheckbox.AutoSize = true; + this.SyncCheckbox.Location = new System.Drawing.Point(3, 30); + this.SyncCheckbox.Name = "SyncCheckbox"; + this.SyncCheckbox.Size = new System.Drawing.Size(123, 17); + this.SyncCheckbox.TabIndex = 16; + this.SyncCheckbox.Text = "Sync sizes to default"; + this.SyncCheckbox.UseVisualStyleBackColor = true; + this.SyncCheckbox.CheckedChanged += new System.EventHandler(this.SyncCheckbox_CheckedChanged); + // // HeigthLabel // HeigthLabel.AutoSize = true; - HeigthLabel.Location = new System.Drawing.Point(150, 5); + HeigthLabel.Location = new System.Drawing.Point(178, 5); HeigthLabel.Name = "HeigthLabel"; HeigthLabel.Size = new System.Drawing.Size(38, 13); HeigthLabel.TabIndex = 14; @@ -263,9 +278,9 @@ private void InitializeComponent() WidthLabel.AutoSize = true; WidthLabel.Location = new System.Drawing.Point(0, 5); WidthLabel.Name = "WidthLabel"; - WidthLabel.Size = new System.Drawing.Size(87, 13); + WidthLabel.Size = new System.Drawing.Size(124, 13); WidthLabel.TabIndex = 13; - WidthLabel.Text = "Thumbnail Width"; + WidthLabel.Text = "Default Thumbnail Width"; // // ThumbnailsWidthNumericEdit // @@ -277,7 +292,7 @@ private void InitializeComponent() 0, 0, 0}); - this.ThumbnailsWidthNumericEdit.Location = new System.Drawing.Point(92, 3); + this.ThumbnailsWidthNumericEdit.Location = new System.Drawing.Point(124, 3); this.ThumbnailsWidthNumericEdit.Maximum = new decimal(new int[] { 999999, 0, @@ -321,7 +336,7 @@ private void InitializeComponent() // // ZoomOptionsPanel // - ZoomOptionsPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + ZoomOptionsPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); ZoomOptionsPanel.BackColor = System.Drawing.SystemColors.Control; ZoomOptionsPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; @@ -330,7 +345,7 @@ private void InitializeComponent() ZoomOptionsPanel.Controls.Add(ZoomAnchorLabel); ZoomOptionsPanel.Controls.Add(this.EnableThumbnailZoomCheckBox); ZoomOptionsPanel.Controls.Add(this.ThumbnailZoomFactorNumericEdit); - ZoomOptionsPanel.Location = new System.Drawing.Point(3, 207); + ZoomOptionsPanel.Location = new System.Drawing.Point(3, 256); ZoomOptionsPanel.Name = "ZoomOptionsPanel"; ZoomOptionsPanel.Size = new System.Drawing.Size(264, 82); ZoomOptionsPanel.TabIndex = 2; @@ -509,13 +524,12 @@ private void InitializeComponent() // // ThumbnailListPanel // - ThumbnailListPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) + ThumbnailListPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); ThumbnailListPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; ThumbnailListPanel.Controls.Add(this.ThumbnailsList); ThumbnailListPanel.Controls.Add(ThumbnailsListLabel); - ThumbnailListPanel.Location = new System.Drawing.Point(3, 350); + ThumbnailListPanel.Location = new System.Drawing.Point(3, 399); ThumbnailListPanel.Name = "ThumbnailListPanel"; ThumbnailListPanel.Size = new System.Drawing.Size(264, 125); ThumbnailListPanel.TabIndex = 5; @@ -531,7 +545,7 @@ private void InitializeComponent() this.ThumbnailsList.IntegralHeight = false; this.ThumbnailsList.Location = new System.Drawing.Point(3, 18); this.ThumbnailsList.Name = "ThumbnailsList"; - this.ThumbnailsList.Size = new System.Drawing.Size(256, 100); + this.ThumbnailsList.Size = new System.Drawing.Size(256, 78); this.ThumbnailsList.TabIndex = 0; this.ThumbnailsList.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.ThumbnailsList_ItemCheck_Handler); // @@ -558,7 +572,7 @@ private void InitializeComponent() // // OverlayOptionsPanel // - OverlayOptionsPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + OverlayOptionsPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); OverlayOptionsPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; OverlayOptionsPanel.Controls.Add(this.HighlightColorLabel); @@ -566,7 +580,7 @@ private void InitializeComponent() OverlayOptionsPanel.Controls.Add(this.EnableActiveClientHighlightCheckBox); OverlayOptionsPanel.Controls.Add(this.ShowThumbnailOverlaysCheckBox); OverlayOptionsPanel.Controls.Add(this.ShowThumbnailFramesCheckBox); - OverlayOptionsPanel.Location = new System.Drawing.Point(3, 295); + OverlayOptionsPanel.Location = new System.Drawing.Point(3, 344); OverlayOptionsPanel.Name = "OverlayOptionsPanel"; OverlayOptionsPanel.Size = new System.Drawing.Size(264, 49); OverlayOptionsPanel.TabIndex = 3; @@ -635,7 +649,7 @@ private void InitializeComponent() // this.ForumLinkLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.ForumLinkLabel.Location = new System.Drawing.Point(4, 478); + this.ForumLinkLabel.Location = new System.Drawing.Point(4, 527); this.ForumLinkLabel.Name = "ForumLinkLabel"; this.ForumLinkLabel.Size = new System.Drawing.Size(264, 33); this.ForumLinkLabel.TabIndex = 0; @@ -662,12 +676,23 @@ private void InitializeComponent() this.TrayMenu.Name = "contextMenuStrip1"; this.TrayMenu.Size = new System.Drawing.Size(152, 76); // + // LockCheckbox + // + this.LockCheckbox.AutoSize = true; + this.LockCheckbox.Location = new System.Drawing.Point(3, 163); + this.LockCheckbox.Name = "LockCheckbox"; + this.LockCheckbox.Size = new System.Drawing.Size(107, 17); + this.LockCheckbox.TabIndex = 7; + this.LockCheckbox.Text = "Lock Thumbnails"; + this.LockCheckbox.UseVisualStyleBackColor = true; + this.LockCheckbox.CheckedChanged += new System.EventHandler(this.LockCheckbox_CheckedChanged); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.SystemColors.Control; - this.ClientSize = new System.Drawing.Size(270, 511); + this.ClientSize = new System.Drawing.Size(270, 561); this.Controls.Add(OverlayOptionsPanel); this.Controls.Add(MainOptionsPanel); this.Controls.Add(ThumbnailSizePanel); @@ -736,5 +761,7 @@ private void InitializeComponent() private CheckBox EnableActiveClientHighlightCheckBox; private Label HighlightColorLabel; private Panel ActiveClientHighlightColorButton; + private CheckBox SyncCheckbox; + private CheckBox LockCheckbox; } } \ No newline at end of file diff --git a/Eve-O-Preview/UI/Implementation/MainForm.cs b/Eve-O-Preview/UI/Implementation/MainForm.cs index da802cd0..e1bde579 100644 --- a/Eve-O-Preview/UI/Implementation/MainForm.cs +++ b/Eve-O-Preview/UI/Implementation/MainForm.cs @@ -244,6 +244,30 @@ public Color ActiveClientHighlightColor } private Color _activeClientHighlightColor; + public bool SyncThumbnailSizes + { + get + { + return this.SyncCheckbox.Checked; + } + set + { + this.SyncCheckbox.Checked = value; + } + } + + public bool LockThumbnails + { + get + { + return this.LockCheckbox.Checked; + } + set + { + this.LockCheckbox.Checked = value; + } + } + public new void Show() { // Registers the current instance as the application's Main Form @@ -338,6 +362,10 @@ public void RefreshZoomSettings() public Action ForumUrlLinkActivated { get; set; } + public Action SyncChanged { get; set; } + + public Action LockChanged { get; set; } + #region UI events private void OptionChanged_Handler(object sender, EventArgs e) { @@ -446,5 +474,17 @@ private void InitZoomAnchorMap() this._zoomAnchorMap[ViewZoomAnchor.S] = this.ZoomAanchorSRadioButton; this._zoomAnchorMap[ViewZoomAnchor.SE] = this.ZoomAanchorSERadioButton; } + + private void SyncCheckbox_CheckedChanged(object sender, EventArgs e) + { + this.ApplicationSettingsChanged?.Invoke(); + this.SyncChanged?.Invoke(); + } + + private void LockCheckbox_CheckedChanged(object sender, EventArgs e) + { + this.ApplicationSettingsChanged?.Invoke(); + this.LockChanged?.Invoke(); + } } } \ No newline at end of file diff --git a/Eve-O-Preview/UI/Implementation/MainForm.resx b/Eve-O-Preview/UI/Implementation/MainForm.resx index f4707493..647498b1 100644 --- a/Eve-O-Preview/UI/Implementation/MainForm.resx +++ b/Eve-O-Preview/UI/Implementation/MainForm.resx @@ -120,9 +120,6 @@ False - - True - False @@ -132,122 +129,44 @@ False - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - False - - True - False - - True - False - - True - - - True + + False - - True + + False False - - True - False - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - False - - True - - - True + + False - - True + + False False - - True - - - True - False - - True + + False False @@ -258,27 +177,6 @@ False - - True - - - True - - - True - - - True - - - True - - - True - - - True - 17, 17 @@ -865,9 +763,6 @@ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////////////// - - True - 36 diff --git a/Eve-O-Preview/UI/Implementation/ThumbnailView.Designer.cs b/Eve-O-Preview/UI/Implementation/ThumbnailView.Designer.cs index 71e6fc93..e7d03a2f 100644 --- a/Eve-O-Preview/UI/Implementation/ThumbnailView.Designer.cs +++ b/Eve-O-Preview/UI/Implementation/ThumbnailView.Designer.cs @@ -19,8 +19,8 @@ private void InitializeComponent() // ThumbnailView // this.AccessibleRole = System.Windows.Forms.AccessibleRole.None; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; + this.AutoValidate = System.Windows.Forms.AutoValidate.EnablePreventFocusChange; this.ClientSize = new System.Drawing.Size(153, 89); this.ControlBox = false; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; @@ -31,6 +31,7 @@ private void InitializeComponent() this.Opacity = 0.1D; this.ShowIcon = false; this.ShowInTaskbar = false; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; this.Text = "Preview"; this.TopMost = true; this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.MouseDown_Handler); diff --git a/Eve-O-Preview/UI/Implementation/ThumbnailView.cs b/Eve-O-Preview/UI/Implementation/ThumbnailView.cs index fd9e6063..3b8d14e5 100644 --- a/Eve-O-Preview/UI/Implementation/ThumbnailView.cs +++ b/Eve-O-Preview/UI/Implementation/ThumbnailView.cs @@ -49,6 +49,9 @@ public ThumbnailView() this._suppressResizeEventsTimestamp = DateTime.UtcNow; + this.PositionLocked = false; + this.ResizeLocked = false; + InitializeComponent(); this._overlay = new ThumbnailOverlay(this, this.MouseDown_Handler); @@ -170,7 +173,10 @@ public void SetOpacity(double opacity) public void SetFrames(bool enable) { - FormBorderStyle style = enable ? FormBorderStyle.SizableToolWindow : FormBorderStyle.None; + //if enabled, sets style to fiexd or sizable depending on what the current state is + FormBorderStyle style = enable + ? FormBorderStyle.SizableToolWindow + : FormBorderStyle.None; // No need to change the borders style if it is ALREADY correct if (this.FormBorderStyle == style) @@ -401,6 +407,35 @@ public void Refresh(bool forceRefresh) this._overlay.Refresh(); } + private bool ResizeLocked { get; set; } + + public void SetResizeLocked(bool locked) + { + this.ResizeLocked = locked; + + } + + private bool PositionLocked { get; set; } + + public void SetPositionLocked(bool locked) + { + this.PositionLocked = locked; + } + + protected override void WndProc(ref Message message) + { + const int WM_NCHITTEST = 0x0084; + const int HTCLIENT = 0x01; + + if (message.Msg == WM_NCHITTEST && this.ResizeLocked) + { + message.Result = new IntPtr(HTCLIENT); + return; + } + + base.WndProc(ref message); + } + #region GUI events protected override CreateParams CreateParams { @@ -545,14 +580,14 @@ private void ProcessCustomMouseMode(bool leftButton, bool rightButton) int offsetY = mousePosition.Y - this._baseMousePosition.Y; this._baseMousePosition = mousePosition; - // Left + Right buttons trigger thumbnail resize + // Left + Right buttons trigger thumbnail resize, if the window isn't fixed // Right button only trigger thumbnail movement - if (leftButton && rightButton) + if (leftButton && rightButton && !this.ResizeLocked) { this.Size = new Size(this.Size.Width + offsetX, this.Size.Height + offsetY); this._baseZoomSize = this.Size; } - else + else if(!this.PositionLocked) { this.Location = new Point(this.Location.X + offsetX, this.Location.Y + offsetY); this._baseZoomLocation = this.Location; diff --git a/Eve-O-Preview/UI/Interface/IMainView.cs b/Eve-O-Preview/UI/Interface/IMainView.cs index b6193add..50c0c936 100644 --- a/Eve-O-Preview/UI/Interface/IMainView.cs +++ b/Eve-O-Preview/UI/Interface/IMainView.cs @@ -42,6 +42,10 @@ public interface IMainView : IView void RemoveThumbnails(IList thumbnails); void RefreshZoomSettings(); + bool SyncThumbnailSizes { get; set; } + + bool LockThumbnails { get; set; } + Action ApplicationExitRequested { get; set; } Action FormActivated { get; set; } Action FormMinimized { get; set; } @@ -50,5 +54,7 @@ public interface IMainView : IView Action ThumbnailsSizeChanged { get; set; } Action ThumbnailStateChanged { get; set; } Action ForumUrlLinkActivated { get; set; } + Action SyncChanged { get; set; } + Action LockChanged { get; set; } } } \ No newline at end of file diff --git a/Eve-O-Preview/UI/Interface/IThumbnailView.cs b/Eve-O-Preview/UI/Interface/IThumbnailView.cs index 20f5b41c..4fe1ad1e 100644 --- a/Eve-O-Preview/UI/Interface/IThumbnailView.cs +++ b/Eve-O-Preview/UI/Interface/IThumbnailView.cs @@ -31,6 +31,9 @@ public interface IThumbnailView : IView void Refresh(bool forceRefresh); + void SetResizeLocked(bool locked); + void SetPositionLocked(bool locked); + Action ThumbnailResized { get; set; } Action ThumbnailMoved { get; set; } Action ThumbnailFocused { get; set; }