diff --git a/AppSettingsDialog.Designer.cs b/AppSettingsDialog.Designer.cs
new file mode 100644
index 0000000..b1528b3
--- /dev/null
+++ b/AppSettingsDialog.Designer.cs
@@ -0,0 +1,150 @@
+namespace Trizbort {
+ partial class AppSettingsDialog {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing) {
+ if (disposing && (components != null)) {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent() {
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AppSettingsDialog));
+ this.panel1 = new System.Windows.Forms.Panel();
+ this.m_okButton = new System.Windows.Forms.Button();
+ this.m_cancelButton = new System.Windows.Forms.Button();
+ this.groupBox1 = new System.Windows.Forms.GroupBox();
+ this.m_invertWheelCheckBox = new System.Windows.Forms.CheckBox();
+ this.m_dragButtonComboBox = new System.Windows.Forms.ComboBox();
+ this.label1 = new System.Windows.Forms.Label();
+ this.panel1.SuspendLayout();
+ this.groupBox1.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // panel1
+ //
+ this.panel1.Controls.Add(this.m_okButton);
+ this.panel1.Controls.Add(this.m_cancelButton);
+ this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.panel1.Location = new System.Drawing.Point(10, 136);
+ this.panel1.Name = "panel1";
+ this.panel1.Size = new System.Drawing.Size(305, 35);
+ this.panel1.TabIndex = 2;
+ //
+ // m_okButton
+ //
+ this.m_okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.m_okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
+ this.m_okButton.Location = new System.Drawing.Point(149, 12);
+ this.m_okButton.Name = "m_okButton";
+ this.m_okButton.Size = new System.Drawing.Size(75, 23);
+ this.m_okButton.TabIndex = 0;
+ this.m_okButton.Text = "OK";
+ this.m_okButton.UseVisualStyleBackColor = true;
+ //
+ // m_cancelButton
+ //
+ this.m_cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.m_cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.m_cancelButton.Location = new System.Drawing.Point(230, 12);
+ this.m_cancelButton.Name = "m_cancelButton";
+ this.m_cancelButton.Size = new System.Drawing.Size(75, 23);
+ this.m_cancelButton.TabIndex = 1;
+ this.m_cancelButton.Text = "Cancel";
+ this.m_cancelButton.UseVisualStyleBackColor = true;
+ //
+ // groupBox1
+ //
+ this.groupBox1.Controls.Add(this.label1);
+ this.groupBox1.Controls.Add(this.m_dragButtonComboBox);
+ this.groupBox1.Controls.Add(this.m_invertWheelCheckBox);
+ this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.groupBox1.Location = new System.Drawing.Point(10, 10);
+ this.groupBox1.Name = "groupBox1";
+ this.groupBox1.Size = new System.Drawing.Size(305, 126);
+ this.groupBox1.TabIndex = 3;
+ this.groupBox1.TabStop = false;
+ this.groupBox1.Text = "Preferences";
+ //
+ // m_invertWheelCheckBox
+ //
+ this.m_invertWheelCheckBox.AutoSize = true;
+ this.m_invertWheelCheckBox.Location = new System.Drawing.Point(32, 61);
+ this.m_invertWheelCheckBox.Name = "m_invertWheelCheckBox";
+ this.m_invertWheelCheckBox.Size = new System.Drawing.Size(152, 17);
+ this.m_invertWheelCheckBox.TabIndex = 0;
+ this.m_invertWheelCheckBox.Text = "Invert Mouse Wheel Zoom";
+ this.m_invertWheelCheckBox.UseVisualStyleBackColor = true;
+ //
+ // m_dragButtonComboBox
+ //
+ this.m_dragButtonComboBox.FormattingEnabled = true;
+ this.m_dragButtonComboBox.Items.AddRange(new object[] {
+ "Middle Button",
+ "Right Button"});
+ this.m_dragButtonComboBox.Location = new System.Drawing.Point(181, 25);
+ this.m_dragButtonComboBox.Name = "m_dragButtonComboBox";
+ this.m_dragButtonComboBox.Size = new System.Drawing.Size(118, 21);
+ this.m_dragButtonComboBox.TabIndex = 1;
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(16, 28);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(159, 13);
+ this.label1.TabIndex = 2;
+ this.label1.Text = "Mouse Button for Canvas Drag:";
+ //
+ // AppSettingsDialog
+ //
+ this.AcceptButton = this.m_okButton;
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.CancelButton = this.m_cancelButton;
+ this.ClientSize = new System.Drawing.Size(325, 181);
+ this.Controls.Add(this.groupBox1);
+ this.Controls.Add(this.panel1);
+ this.Font = new System.Drawing.Font("Tahoma", 8.25F);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "AppSettingsDialog";
+ this.Padding = new System.Windows.Forms.Padding(10);
+ this.ShowIcon = false;
+ this.ShowInTaskbar = false;
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "Application Settings";
+ this.panel1.ResumeLayout(false);
+ this.groupBox1.ResumeLayout(false);
+ this.groupBox1.PerformLayout();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Panel panel1;
+ private System.Windows.Forms.Button m_okButton;
+ private System.Windows.Forms.Button m_cancelButton;
+ private System.Windows.Forms.GroupBox groupBox1;
+ private System.Windows.Forms.CheckBox m_invertWheelCheckBox;
+ private System.Windows.Forms.ComboBox m_dragButtonComboBox;
+ private System.Windows.Forms.Label label1;
+ }
+}
\ No newline at end of file
diff --git a/AppSettingsDialog.cs b/AppSettingsDialog.cs
new file mode 100644
index 0000000..134a84b
--- /dev/null
+++ b/AppSettingsDialog.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+
+namespace Trizbort
+{
+ public partial class AppSettingsDialog : Form
+ {
+ public AppSettingsDialog()
+ {
+ InitializeComponent();
+ }
+
+ public bool InvertMouseWheel
+ {
+ get { return m_invertWheelCheckBox.Checked; }
+ set { m_invertWheelCheckBox.Checked = value; }
+ }
+
+ public int MouseDragButton
+ {
+ get { return m_dragButtonComboBox.SelectedIndex; }
+ set { m_dragButtonComboBox.SelectedIndex = value; }
+ }
+ }
+}
diff --git a/AppSettingsDialog.resx b/AppSettingsDialog.resx
new file mode 100644
index 0000000..1b8aec1
--- /dev/null
+++ b/AppSettingsDialog.resx
@@ -0,0 +1,150 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+
+
+ AAABAAIAEBAQAAEABAAoAQAAJgAAABAQAAABACAAaAQAAE4BAAAoAAAAEAAAACAAAAABAAQAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAgAAAAICAAIAAAACAAIAAgIAAAICAgADAwMAAAAD/AAD/
+ AAAA//8A/wAAAP8A/wD//wAA////AAAAAAAAAAAAAAAAAAAAAAAA///wAAAAAADwAP/w//AAAPAA8AD/
+ 8AAA8AD/8P/wAAD///AAAAAAAA8PAAAPAAAADw8AAA8AAAAAAAAP//8AAA//AA8ADwAAD/8P/wAPAAAP
+ /wAPAA8AAAAAAA///wAAAAAAAAAAAAAAAAAAAAAA//8NCv//DQrBgw0KwAMNCsADDQrAAw0KwYMNCuPH
+ DQrjxw0KwYMNCsADDQrAAw0KwAMNCsGDDQr//w0K//8NCigAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/AAAAPwAAAD8AAAA/AAAAPwAAAD8AAAAAAAAAPwAA
+ AD8AAAA/AAAAPwAAAD8AAAA/AAAAAAAAAAAAAAAA//////////////////////////8AAAA/AAAAAAAA
+ AP8AAAD/AAAA/wAAAP8AAAD/AAAAPwAAAAAAAAAAAAAAAP////8AAAD/AAAA/wAAAP//////////////
+ //8AAAD/////////////////AAAA/wAAAD8AAAAAAAAAAAAAAAD/////AAAA/wAAAP8AAAD//////wAA
+ AP8AAAD/AAAA/////////////////wAAAP8AAAA/AAAAAAAAAAAAAAAA/////wAAAP8AAAD/AAAA////
+ /////////////wAAAP////////////////8AAAD/AAAAPwAAAAAAAAAAAAAAAP//////////////////
+ ////////AAAAPwAAAAAAAAD/AAAA/wAAAP8AAAD/AAAA/wAAAD8AAAAAAAAAAAAAAAAAAAAA/////wAA
+ AP//////AAAAAAAAAAAAAAAAAAAAAAAAAP//////AAAA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///
+ //8AAAD//////wAAAD8AAAA/AAAAAAAAAD8AAAD//////wAAAP8AAAA/AAAAPwAAAAAAAAAAAAAAAAAA
+ AP8AAAD/AAAA/wAAAP8AAAD/AAAAPwAAAAD//////////////////////////wAAAD8AAAAAAAAAAAAA
+ AAAAAAD/////////////////AAAA/wAAAP8AAAD//////wAAAP8AAAD/AAAA//////8AAAA/AAAAAAAA
+ AAAAAAAAAAAA/////////////////wAAAP////////////////8AAAD/AAAA/wAAAP//////AAAAPwAA
+ AAAAAAAAAAAAAAAAAP////////////////8AAAD/AAAA/wAAAP//////AAAA/wAAAP8AAAD//////wAA
+ AD8AAAAAAAAAAAAAAAAAAAD/AAAA/wAAAP8AAAD/AAAA/wAAAD8AAAAA////////////////////////
+ //8AAAA/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAA//+sQcCBrEHAgaxBwAGsQcABrEHAAaxBwIGsQePHrEHAgaxBwIGsQcAB
+ rEHAAaxBwAGsQcCBrEH//6xB//+sQQ==
+
+
+
\ No newline at end of file
diff --git a/Canvas.cs b/Canvas.cs
index bec70b9..2c0ffa8 100644
--- a/Canvas.cs
+++ b/Canvas.cs
@@ -1,2278 +1,2289 @@
-/*
- Copyright (c) 2010 by Genstein
-
- This file is (or was originally) part of Trizbort, the Interactive Fiction Mapper.
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
-*/
-
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Drawing;
-using System.Drawing.Drawing2D;
-using System.Windows.Forms;
-using System.Diagnostics;
-using PdfSharp.Drawing;
-
-namespace Trizbort
-{
- internal partial class Canvas : UserControl, IAutomapCanvas
- {
- public Canvas()
- {
- InitializeComponent();
-
- SetStyle(ControlStyles.Selectable, true);
- TabStop = true;
- TabIndex = 0;
-
- SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true);
- DoubleBuffered = true;
- m_cornerPanel.BackColor = SystemColors.Control;
-
- PreviewKeyDown += OnPreviewKeyDown;
-
- m_recomputeTimer = new System.Threading.Timer(OnRecomputeTimerTick);
-
- Project.ProjectChanged += OnProjectChanged;
- OnProjectChanged(this, new ProjectChangedEventArgs(null, Project.Current));
-
- Settings.Changed += OnSettingsChanged;
- OnSettingsChanged(this, EventArgs.Empty);
-
- m_threadSafeAutomapCanvas = new MultithreadedAutomapCanvas(this);
- m_minimap.Canvas = this;
- }
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- StopAutomapping();
- if (components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose(disposing);
- }
-
- protected override void WndProc(ref Message m)
- {
- switch (m.Msg)
- {
- case 0x0007: // WM_SETFOCUS
- // do not pass focus to our child controls
- m.Result = IntPtr.Zero;
- return;
- }
- base.WndProc(ref m);
- }
-
- private void RequestRecomputeSmartSegments()
- {
- m_smartLineSegmentsUpToDate = false;
- m_recomputeTimer.Change(RecomputeNMillisecondsAfterChange, RecomputeNMillisecondsAfterChange);
- }
-
- private void OnRecomputeTimerTick(object state)
- {
- m_recomputeTimer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);
-
- var context = new DrawingContext(ZoomFactor);
- var elements = DepthSortElements();
-
- foreach (var element in elements)
- {
- element.PreDraw(context);
- }
-
- foreach (var element in elements)
- {
- element.RecomputeSmartLineSegments(context);
- }
-
- m_smartLineSegmentsUpToDate = true;
- Invalidate();
- }
-
- private void OnProjectChanged(object sender, ProjectChangedEventArgs e)
- {
- if (e.OldProject != null)
- {
- e.OldProject.Elements.Added -= OnElementAdded;
- e.OldProject.Elements.Removed -= OnElementRemoved;
-
- foreach (var element in e.OldProject.Elements)
- {
- element.Changed -= OnElementChanged;
- }
- }
- if (e.NewProject != null)
- {
- e.NewProject.Elements.Added += OnElementAdded;
- e.NewProject.Elements.Removed += OnElementRemoved;
-
- foreach (var element in e.NewProject.Elements)
- {
- element.Changed += OnElementChanged;
- }
- }
-
- Reset();
- ZoomToFit();
- }
-
- private void OnSettingsChanged(object sender, EventArgs e)
- {
- RequestRecomputeSmartSegments();
- BackColor = Settings.Color[Colors.Canvas];
- Invalidate();
- }
-
- private void OnElementAdded(object sender, ItemEventArgs e)
- {
- if (e.Item is Room)
- {
- var room = (Room)e.Item;
- room.Size = m_newRoomSize;
- room.IsDark = m_newRoomIsDark;
- room.ObjectsPosition = m_newRoomObjectsPosition;
- }
- e.Item.Changed += OnElementChanged;
- Project.Current.IsDirty = true;
- RequestRecomputeSmartSegments();
- Invalidate();
- }
-
- private void OnElementRemoved(object sender, ItemEventArgs e)
- {
- m_selectedElements.Remove(e.Item);
- UpdateSelection();
- EndDrag();
- UpdateDragHover(PointToClient(Control.MousePosition));
-
- Project.Current.IsDirty = true;
- e.Item.Changed -= OnElementChanged;
- RequestRecomputeSmartSegments();
- Invalidate();
- }
-
- private void OnElementChanged(object sender, EventArgs e)
- {
- if (sender is Room)
- {
- SetRoomDefaultsFrom((Room)sender);
- }
- if (sender is Connection)
- {
- SetConnectionDefaultsFrom((Connection)sender);
- }
- Invalidate();
- Project.Current.IsDirty = true;
- RequestRecomputeSmartSegments();
- }
-
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public float ZoomFactor
- {
- get { return m_zoomFactor; }
- set
- {
- if (m_zoomFactor != value)
- {
- m_zoomFactor = value;
- Invalidate();
- }
- }
- }
-
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public Vector Origin
- {
- get { return m_origin; }
- set
- {
- if (m_origin != value)
- {
- m_origin = value;
- Invalidate();
- }
- }
- }
-
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public Rect Viewport
- {
- get
- {
- var origin = Origin;
- var size = ClientToCanvas(new SizeF(Width, Height));
- return new Rect(origin.X - size.Width / 2, origin.Y - size.Height / 2, size.Width, size.Height);
- }
- }
-
- protected override void OnPaint(PaintEventArgs e)
- {
- if (DesignMode)
- {
- e.Graphics.Clear(Settings.Color[Colors.Canvas]);
- return;
- }
-
- using (var nativeGraphics = Graphics.FromHdc(e.Graphics.GetHdc()))
- {
- using (var graphics = XGraphics.FromGraphics(nativeGraphics, new XSize(Width, Height)))
- {
- Draw(graphics, false, Width, Height);
- }
- }
- e.Graphics.ReleaseHdc();
-
- // update our scroll bars, unless this paint event was caused by the scroll bars,
- // in which case messing with them may cause the scroll bars to throw exceptions.
- if (!m_doNotUpdateScrollBarsNextPaint)
- {
- UpdateScrollBars();
- }
- m_doNotUpdateScrollBarsNextPaint = false;
-
- // update the minimap
- m_minimap.Invalidate();
- m_minimap.Update();
- }
-
- public Rect ComputeCanvasBounds(bool includePadding)
- {
- var bounds = Rect.Empty;
- foreach (var element in Project.Current.Elements)
- {
- bounds = element.UnionBoundsWith(bounds, true);
- }
-
- if (includePadding)
- {
- // HACK: fudge the canvas size to allow for overhanging line/object text
- bounds.Inflate(Math.Max(Settings.LineFont.GetHeight(), Settings.SmallFont.GetHeight()) * 24);
- }
- return bounds;
- }
-
- ///
- /// Draw the current project.
- ///
- /// The graphics with which to draw.
- /// True if rendering to PDF, an image, etc.; false if rendering to a window.
- /// The width of the drawing area.
- /// The height of the drawing area.
- public void Draw(XGraphics graphics, bool finalRender, float width, float height)
- {
- var stopwatch = new Stopwatch();
- stopwatch.Start();
-
- var zoomFactor = ZoomFactor;
- var origin = Origin;
- if (finalRender)
- {
- // zoom to fit (0,0)-(width,height)
- var canvasBounds = ComputeCanvasBounds(true);
- ZoomFactor = Math.Min(canvasBounds.Width > 0 ? width / canvasBounds.Width : 1.0f, canvasBounds.Height > 0 ? height / canvasBounds.Height : 1.0f);
- Origin = new Vector(canvasBounds.X + canvasBounds.Width / 2, canvasBounds.Y + canvasBounds.Height / 2);
- }
-
- using (var palette = new Palette())
- {
- if (finalRender)
- {
- graphics.Clear(Settings.Color[Colors.Canvas]);
- }
-
- if (!finalRender)
- {
- DrawGrid(graphics, palette);
- }
-
- graphics.TranslateTransform(width / 2, height / 2);
- graphics.ScaleTransform(ZoomFactor, ZoomFactor);
- graphics.TranslateTransform(-Origin.X, -Origin.Y);
-
- if (Settings.DebugShowFPS && !finalRender)
- {
- var canvasBounds = ComputeCanvasBounds(true);
- graphics.DrawRectangle(XPens.Purple, canvasBounds.ToRectangleF());
- }
-
- if (Settings.ShowOrigin && !finalRender)
- {
- var pen = palette.Pen(Drawing.Mix(Settings.Color[Colors.Canvas], Settings.Color[Colors.SmallText], 3, 1));
- var n = Settings.GridSize;
- graphics.DrawLine(pen, -n, 0, n, 0);
- graphics.DrawLine(pen, 0, -n, 0, n);
- }
-
- graphics.SmoothingMode = XSmoothingMode.AntiAlias;
-
- DrawElements(graphics, palette, finalRender);
- if (!finalRender)
- {
- DrawHandles(graphics, palette);
- DrawPorts(graphics, palette);
- DrawMarquee(graphics, palette);
- }
-
- stopwatch.Stop();
- if (Settings.DebugShowFPS && !finalRender)
- {
- var fps = 1.0f / (float)(stopwatch.Elapsed.TotalSeconds);
- graphics.Graphics.Transform = new Matrix();
- graphics.DrawString(string.Format("{0} ms ({1} fps) {2} rebuilds", stopwatch.Elapsed.TotalMilliseconds, fps, TextBlock.RebuildCount), Settings.LargeFont, Brushes.Red, new PointF(10, 10 + Settings.LargeFont.GetHeight()));
- }
- }
-
- ZoomFactor = zoomFactor;
- Origin = origin;
- }
-
- private void DrawGrid(XGraphics graphics, Palette palette)
- {
- if (Settings.IsGridVisible && Settings.GridSize * ZoomFactor > 10)
- {
- var topLeft = Settings.Snap(ClientToCanvas(new PointF(-Settings.GridSize * ZoomFactor, -Settings.GridSize * ZoomFactor)));
- var bottomRight = Settings.Snap(ClientToCanvas(new PointF(Width + Settings.GridSize * ZoomFactor, Height + Settings.GridSize * ZoomFactor)));
- var points = new List();
- var even = true;
- for (float x = topLeft.X; x <= bottomRight.X; x += Settings.GridSize)
- {
- var start = CanvasToClient(new Vector(x, topLeft.Y));
- var end = CanvasToClient(new Vector(x, bottomRight.Y));
- if (even)
- {
- points.Add(start);
- points.Add(end);
- }
- else
- {
- points.Add(end);
- points.Add(start);
- }
- even = !even;
- if (Settings.DebugDisableGridPolyline)
- {
- graphics.DrawLine(palette.GridPen, start, end);
- }
- }
- if (!Settings.DebugDisableGridPolyline)
- {
- graphics.DrawLines(palette.GridPen, points.ToArray());
- }
- points = new List();
- for (float y = topLeft.Y; y <= bottomRight.Y; y += Settings.GridSize)
- {
- var start = CanvasToClient(new Vector(topLeft.X, y));
- var end = CanvasToClient(new Vector(bottomRight.X, y));
- if (even)
- {
- points.Add(start);
- points.Add(end);
- }
- else
- {
- points.Add(end);
- points.Add(start);
- }
- even = !even;
- if (Settings.DebugDisableGridPolyline)
- {
- graphics.DrawLine(palette.GridPen, start, end);
- }
- }
- if (!Settings.DebugDisableGridPolyline)
- {
- graphics.DrawLines(palette.GridPen, points.ToArray());
- }
- }
- }
-
- private List DepthSortElements()
- {
- var elements = new List();
- elements.AddRange(Project.Current.Elements);
- elements.Sort();
- return elements;
- }
-
- private void DrawElements(XGraphics graphics, Palette palette, bool finalRender)
- {
- if (Settings.DebugDisableElementRendering)
- return;
-
- bool disabledHandDrawLinesForSpeed = false;
- if (!finalRender && ZoomFactor < 0.75f && Settings.HandDrawn)
- {
- disabledHandDrawLinesForSpeed = true;
- Settings.HandDrawnUnchecked = false;
- }
-
- var context = new DrawingContext(ZoomFactor);
- context.UseSmartLineSegments = m_smartLineSegmentsUpToDate;
- var elements = DepthSortElements();
-
- if (!context.UseSmartLineSegments)
- {
- foreach (var element in elements)
- {
- element.PreDraw(context);
- element.Flagged = false;
- }
- }
- else
- {
- foreach (var element in elements)
- {
- element.Flagged = false;
- }
- }
-
- foreach (var element in m_selectedElements)
- {
- element.Flagged = true;
- }
-
- var clipToScreen = new RectangleF(Origin.X - Width / 2 / ZoomFactor, Origin.Y - Height / 2 / ZoomFactor, Width / ZoomFactor, Height / ZoomFactor);
-
- foreach (var element in elements)
- {
- context.Selected = element.Flagged && !finalRender;
- context.Hover = !context.Selected && element == HoverElement && !finalRender;
- if (context.Hover && DragMode == DragModes.MovePort)
- {
- // special case: when we're creating or moving a line, don't highlight elements we hover over;
- // we don't want it to look like these elements can dock with the line, since they can't.
- context.Hover = false;
- }
-
- try
- {
- var elementBounds = element.UnionBoundsWith(Rect.Empty, true).ToRectangleF();
- if (finalRender || clipToScreen.IntersectsWith(elementBounds))
- {
- element.Draw(graphics, palette, context);
- }
- }
- catch (Exception)
- {
- // avoid GDI+ exceptions (vast shapes, etc.) taking down the canvas
- }
- }
-
- if (disabledHandDrawLinesForSpeed)
- {
- Settings.HandDrawnUnchecked = true;
- }
- }
-
- private void DrawHandles(XGraphics graphics, Palette palette)
- {
- if (m_handles.Count == 0)
- {
- return;
- }
-
- var context = new DrawingContext(ZoomFactor);
-
- if (m_handles.Count > 1)
- {
- var bounds = Rect.Empty;
-
- foreach (var handle in m_handles)
- {
- if (bounds == Rect.Empty)
- {
- bounds = new Rect(handle.Position, Vector.Zero);
- }
- else
- {
- bounds = bounds.Union(handle.Position);
- }
- }
- bounds.X += Settings.HandleSize / 2f;
- bounds.Y += Settings.HandleSize / 2f;
- graphics.DrawRectangle(palette.ResizeBorderPen, bounds.ToRectangleF());
- }
-
-
- foreach (var handle in m_handles)
- {
- context.Selected = handle == HoverHandle;
- handle.Draw(this, graphics, palette, context);
- }
- }
-
- private void DrawPorts(XGraphics graphics, Palette palette)
- {
- var context = new DrawingContext(ZoomFactor);
-
- // draw all non-selected ports
- foreach (var port in m_ports)
- {
- if (HoverPort == port)
- {
- // we'll draw this port last
- continue;
- }
-
- context.Selected = false;
- port.Draw(this, graphics, palette, context);
- }
-
- if (HoverPort != null)
- {
- // lastly, always the port under the mouse, if any
- context.Selected = true;
- HoverPort.Draw(this, graphics, palette, context);
- }
- }
-
- private void DrawMarquee(XGraphics graphics, Palette palette)
- {
- var marqueeRect = GetMarqueeCanvasBounds();
- if (marqueeRect.Width > 0 && marqueeRect.Height > 0)
- {
- //var topLeft = CanvasToClient(new Vector(marqueeRect.X, marqueeRect.Y));
- //var bottomRight = CanvasToClient(new Vector(marqueeRect.X + marqueeRect.Width, marqueeRect.Y + marqueeRect.Height));
- //var rect = new RectangleF(topLeft.X, topLeft.Y, bottomRight.X - topLeft.X, bottomRight.Y - topLeft.Y);
- graphics.DrawRectangle(palette.MarqueeFillBrush, marqueeRect.ToRectangleF());
- var topLeft = new PointF(marqueeRect.Left, marqueeRect.Top);
- var topRight = new PointF(marqueeRect.Right, marqueeRect.Top);
- var bottomLeft = new PointF(marqueeRect.Left, marqueeRect.Bottom);
- var bottomRight = new PointF(marqueeRect.Right, marqueeRect.Bottom);
- graphics.DrawLine(palette.MarqueeBorderPen, topLeft, topRight);
- graphics.DrawLine(palette.MarqueeBorderPen, topRight, bottomRight);
- graphics.DrawLine(palette.MarqueeBorderPen, bottomLeft, bottomRight);
- graphics.DrawLine(palette.MarqueeBorderPen, topLeft, bottomLeft);
- }
- }
-
- public PointF CanvasToClient(Vector v)
- {
- v.X -= Origin.X;
- v.X *= ZoomFactor;
- v.X += Width / 2;
- v.Y -= Origin.Y;
- v.Y *= ZoomFactor;
- v.Y += Height / 2;
- return new PointF(v.X, v.Y);
- }
-
- public Vector ClientToCanvas(PointF p)
- {
- p.X -= Width / 2;
- p.X /= ZoomFactor;
- p.X += Origin.X;
- p.Y -= Height / 2;
- p.Y /= ZoomFactor;
- p.Y += Origin.Y;
- return new Vector(p.X, p.Y);
- }
-
- public SizeF CanvasToClient(SizeF s)
- {
- s.Width *= ZoomFactor;
- s.Height *= ZoomFactor;
- return s;
- }
-
- public SizeF ClientToCanvas(SizeF s)
- {
- s.Width /= ZoomFactor;
- s.Height /= ZoomFactor;
- return s;
- }
-
- protected override void OnMouseWheel(MouseEventArgs e)
- {
- if (e.X < 0 || e.X > Width || e.Y < 0 || e.Y > Width)
- return;
-
- var pos = ClientToCanvas(new PointF(e.X, e.Y));
-
- if (e.Delta < 0)
- {
- ZoomIn();
- }
- else if (e.Delta > 0 && ZoomFactor > 1/100.0f)
- {
- ZoomOut();
- }
-
- Vector newPos = ClientToCanvas(new PointF(e.X, e.Y));
- Origin = Origin - (newPos - pos);
-
- Invalidate();
- UpdateDragHover(e.Location);
-
- base.OnMouseWheel(e);
- }
-
- private bool IsMiddleButton(MouseEventArgs e)
- {
- return e.Button == MouseButtons.Middle || (e.Button == MouseButtons.Right && Control.ModifierKeys == Keys.Shift);
- }
-
- protected override void OnMouseDown(MouseEventArgs e)
- {
- var clientPos = new PointF(e.X, e.Y);
- var canvasPos = ClientToCanvas(clientPos);
- m_lastMouseDownPosition = e.Location;
-
- if (DragMode != DragModes.None)
- return;
-
- if (IsMiddleButton(e))
- {
- BeginDragPan(clientPos, canvasPos);
- }
- else if (e.Button == MouseButtons.Left)
- {
- if (CanSelectElements)
- {
- BeginDragMove(clientPos, canvasPos);
- }
- if (DragMode == DragModes.None)
- {
- if (HoverPort != null && CanDrawLine)
- {
- BeginDragDrawLine();
- }
- }
- }
-
- base.OnMouseDown(e);
- }
-
- protected override void OnMouseUp(MouseEventArgs e)
- {
- EndDrag();
- base.OnMouseUp(e);
- }
-
- protected override void OnMouseMove(MouseEventArgs e)
- {
- // ignore spurious mouse move events
- if (m_lastKnownMousePosition == e.Location)
- {
- return;
-
- }
- m_lastKnownMousePosition = e.Location;
-
- UpdateDragHover(e.Location);
- base.OnMouseMove(e);
- }
-
- private void UpdateDragHover(Point mousePosition)
- {
- m_lastKnownMousePosition = mousePosition;
-
- var clientPos = new PointF(mousePosition.X, mousePosition.Y);
- var canvasPos = ClientToCanvas(clientPos);
-
- switch (DragMode)
- {
- case DragModes.Pan:
- DoDragPan(clientPos, canvasPos);
- break;
- case DragModes.MoveElement:
- DoDragMoveElement(clientPos, canvasPos);
- break;
- case DragModes.MoveResizeHandle:
- DoDragMoveResizeHandle(clientPos, canvasPos);
- break;
- case DragModes.MovePort:
- HoverElement = HitTestElement(canvasPos, true);
- HoverPort = HitTestPort(canvasPos);
- DoDragMovePort(clientPos, canvasPos);
- break;
- case DragModes.None:
- HoverHandle = HitTestHandle(canvasPos); // set first; it will RecreatePorts() if the value changes
- HoverPort = HitTestPort(canvasPos);
- HoverElement = HitTestElement(canvasPos, false);
- break;
- case DragModes.DrawLine:
- if (new Vector(m_lastMouseDownPosition).Distance(new Vector(mousePosition)) > Settings.DragDistanceToInitiateNewConnection)
- {
- var startPos = new PointF(m_lastMouseDownPosition.X, m_lastMouseDownPosition.Y);
- BeginDrawConnection(startPos, ClientToCanvas(startPos));
- }
- break;
- case DragModes.Marquee:
- if (m_dragMarqueeLastPosition != canvasPos)
- {
- m_dragMarqueeLastPosition = canvasPos;
- Invalidate();
- }
- break;
- }
- }
-
- protected override void OnMouseDoubleClick(MouseEventArgs e)
- {
- if (e.Button == MouseButtons.Left)
- {
- if (CanSelectElements && HasSingleSelectedElement && SelectedElement.HasDialog)
- {
- SelectedElement.ShowDialog();
- }
- }
- base.OnMouseDoubleClick(e);
- }
-
- void OnPreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
- {
- if (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down || e.KeyCode == Keys.Left || e.KeyCode == Keys.Right)
- {
- e.IsInputKey = true;
- }
- }
-
- protected override void OnKeyDown(KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- if (SelectedElement == null)
- {
- // select the room closest to the center of the viewport
- var viewportCenter = Viewport.Center;
- Room closestRoom = null;
- var closestDistance = float.MaxValue;
- foreach (var element in Project.Current.Elements)
- {
- if (element is Room)
- {
- var room = (Room)element;
- var roomCenter = room.InnerBounds.Center;
- var distance = roomCenter.Distance(viewportCenter);
- if (distance < closestDistance)
- {
- closestRoom = room;
- closestDistance = distance;
- }
- }
- }
- SelectedElement = closestRoom;
- EnsureVisible(SelectedElement);
- }
- else if (HasSingleSelectedElement && SelectedElement.HasDialog)
- {
- SelectedElement.ShowDialog();
- }
- }
- else if (e.KeyCode == Keys.Escape && SelectedElement != null)
- {
- // clear selection
- SelectedElement = null;
- }
- else if (e.KeyCode == Keys.A && e.Control)
- {
- // select all
- SelectAll();
- }
- else if (e.KeyCode == Keys.Add || e.KeyCode == Keys.Oemplus)
- {
- ZoomIn();
- }
- else if (e.KeyCode == Keys.Subtract || e.KeyCode == Keys.OemMinus)
- {
- ZoomOut();
- }
- else if (e.KeyCode == Keys.Home)
- {
- if (e.Control)
- {
- ZoomToFit();
- }
- else
- {
- ResetZoomOrigin();
- }
- }
- else if (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down)
- {
- Origin += new Vector(0, (e.KeyCode == Keys.Down ? 1 : -1) * Viewport.Height / (e.Shift ? 5 : 10));
- }
- else if (e.KeyCode == Keys.Left || e.KeyCode == Keys.Right)
- {
- Origin += new Vector((e.KeyCode == Keys.Right ? 1 : -1) * Viewport.Width / (e.Shift ? 5 : 10), 0);
- }
- else if (e.KeyCode == Keys.R)
- {
- AddRoom(true);
- }
- else if (e.KeyCode == Keys.T)
- {
- if (NewConnectionStyle == ConnectionStyle.Solid)
- {
- NewConnectionStyle = ConnectionStyle.Dashed;
- }
- else
- {
- NewConnectionStyle = ConnectionStyle.Solid;
- }
- ApplyConnectionStyle(NewConnectionStyle);
- }
- else if (e.KeyCode == Keys.A)
- {
- if (NewConnectionFlow == ConnectionFlow.TwoWay)
- {
- NewConnectionFlow = ConnectionFlow.OneWay;
- }
- else
- {
- NewConnectionFlow = ConnectionFlow.TwoWay;
- }
- ApplyConnectionFlow(NewConnectionFlow);
- }
- else if (e.KeyCode == Keys.P)
- {
- ApplyNewPlainConnectionSettings();
- }
- else if (e.KeyCode == Keys.U)
- {
- NewConnectionLabel = ConnectionLabel.Up;
- ApplyConnectionLabel(NewConnectionLabel);
- }
- else if (e.KeyCode == Keys.D)
- {
- NewConnectionLabel = ConnectionLabel.Down;
- ApplyConnectionLabel(NewConnectionLabel);
- }
- else if (e.KeyCode == Keys.I)
- {
- NewConnectionLabel = ConnectionLabel.In;
- ApplyConnectionLabel(NewConnectionLabel);
- }
- else if (e.KeyCode == Keys.O)
- {
- NewConnectionLabel = ConnectionLabel.Out;
- ApplyConnectionLabel(NewConnectionLabel);
- }
- else if (e.KeyCode == Keys.V)
- {
- ReverseLineDirection();
- }
- else if (e.KeyCode == Keys.K)
- {
- foreach (var element in m_selectedElements)
- {
- if (element is Room)
- {
- var room = (Room)element;
- room.IsDark = !room.IsDark;
- }
- }
- }
- else if (e.KeyCode == Keys.F1 && Control.ModifierKeys == Keys.Control)
- {
- Settings.DebugShowFPS = !Settings.DebugShowFPS;
- Invalidate();
- }
- else if (e.KeyCode == Keys.F2 && Control.ModifierKeys == Keys.Control)
- {
- Settings.DebugDisableElementRendering = !Settings.DebugDisableElementRendering;
- Invalidate();
- }
- else if (e.KeyCode == Keys.F3 && Control.ModifierKeys == Keys.Control)
- {
- Settings.DebugDisableLineRendering = !Settings.DebugDisableLineRendering;
- Invalidate();
- }
- else if (e.KeyCode == Keys.F4 && Control.ModifierKeys == Keys.Control)
- {
- Settings.DebugDisableTextRendering = !Settings.DebugDisableTextRendering;
- Invalidate();
- }
- else if (e.KeyCode == Keys.F5 && Control.ModifierKeys == Keys.Control)
- {
- Settings.DebugDisableGridPolyline = !Settings.DebugDisableGridPolyline;
- Invalidate();
- }
- else if (e.KeyCode == Keys.F5)
- {
- // for diagnostic purposes, cancel single stepping
- if (IsAutomapping)
- {
- m_automap.RunToCompletion();
- }
- }
- else if (e.KeyCode == Keys.F11)
- {
- // for diagnostic purposes, allow single stepping
- m_automap.Step();
- }
- else if (e.KeyCode >= Keys.NumPad0 && e.KeyCode <= Keys.NumPad9)
- {
- // the numeric keypad keys allow rooms to be quickly selected or added.
- CompassPoint? compassPoint = null;
- switch (e.KeyCode)
- {
- case Keys.NumPad8:
- compassPoint = CompassPoint.North;
- break;
- case Keys.NumPad9:
- compassPoint = CompassPoint.NorthEast;
- break;
- case Keys.NumPad6:
- compassPoint = CompassPoint.East;
- break;
- case Keys.NumPad3:
- compassPoint = CompassPoint.SouthEast;
- break;
- case Keys.NumPad2:
- compassPoint = CompassPoint.South;
- break;
- case Keys.NumPad1:
- compassPoint = CompassPoint.SouthWest;
- break;
- case Keys.NumPad4:
- compassPoint = CompassPoint.West;
- break;
- case Keys.NumPad7:
- compassPoint = CompassPoint.NorthWest;
- break;
- }
- if (compassPoint.HasValue)
- {
- if (!SelectRoomRelativeToSelectedRoom(compassPoint.Value))
- {
- if (Control.ModifierKeys == Settings.KeypadNavigationCreationModifier)
- {
- AddOrConnectRoomRelativeToSelectedRoom(compassPoint.Value);
- }
- else if (Control.ModifierKeys == Settings.KeypadNavigationUnexploredModifier)
- {
- AddUnexploredConnectionToSelectedRoom(compassPoint.Value);
- }
- }
- }
- }
-
- base.OnKeyDown(e);
- }
-
- ///
- /// Select the room in the given direction from the selected room;
- ///
- /// The direction to consider.
- /// True if a new room was found and selected; false otherwise.
- private bool SelectRoomRelativeToSelectedRoom(CompassPoint compassPoint)
- {
- if (SelectedElement is Room)
- {
- var room = (Room)SelectedElement;
- var nextRoom = GetRoomInApproximateDirectionFromRoom(room, compassPoint);
- if (nextRoom != null)
- {
- SelectedElement = nextRoom;
- EnsureVisible(SelectedElement);
- return true;
- }
- }
- return false;
- }
-
- ///
- /// Find a room adjacent to the selected room in the given direction;
- /// if found, connect the rooms. If not, create a new room in that direction.
- ///
- /// The direction to consider.
- /// True if a new connection/room was made; false otherwise.
- private bool AddOrConnectRoomRelativeToSelectedRoom(CompassPoint compassPoint)
- {
- if (SelectedElement is Room)
- {
- var room = (Room)SelectedElement;
- var rect = room.InnerBounds;
- rect.Inflate(Settings.PreferredDistanceBetweenRooms + room.Width / 2, Settings.PreferredDistanceBetweenRooms + room.Height / 2);
- var centerOfNewRoom = rect.GetCorner(compassPoint);
-
- var existing = HitTestElement(centerOfNewRoom, false);
- if (existing is Room)
- {
- // just connect the rooms together
- AddConnection(room, compassPoint, (Room)existing, CompassPointHelper.GetOpposite(compassPoint));
- SelectedElement = existing;
- EnsureVisible(SelectedElement);
- }
- else
- {
- // new room entirely
- var newRoom = new Room(Project.Current);
-
- newRoom.Position = new Vector(centerOfNewRoom.X - room.Width / 2, centerOfNewRoom.Y - room.Height / 2); ;
- newRoom.Size = room.Size;
-
- Project.Current.Elements.Add(newRoom);
- AddConnection(room, compassPoint, newRoom, CompassPointHelper.GetOpposite(compassPoint));
- SelectedElement = newRoom;
- EnsureVisible(SelectedElement);
- Refresh();
- newRoom.ShowDialog();
- }
- return true;
- }
- return false;
- }
-
- ///
- /// Add an "unexplored" (loopback) connection from
- ///
- ///
- ///
- private bool AddUnexploredConnectionToSelectedRoom(CompassPoint compassPoint)
- {
- if (SelectedElement is Room)
- {
- var room = (Room)SelectedElement;
- AddConnection(room, compassPoint, room, compassPoint);
- return true;
- }
- return false;
- }
-
- ///
- /// Add a new connection between the given rooms.
- ///
- /// The first room.
- /// The direction of the connection in the first room.
- /// The second room.
- /// The direction of the connection in the second room.
- private Connection AddConnection(Room roomOne, CompassPoint compassPointOne, Room roomTwo, CompassPoint compassPointTwo)
- {
- var vertexOne = new Vertex(roomOne.PortAt(compassPointOne));
- var vertexTwo = new Vertex(roomTwo.PortAt(compassPointTwo));
- var connection = new Connection(Project.Current, vertexOne, vertexTwo);
- Project.Current.Elements.Add(connection);
- return connection;
- }
-
- ///
- /// Get a room which can be found in the given direction from the given room.
- ///
- /// The initial room.
- /// The direction to consider.
- /// The room which can be found in that direction, or null if none.
- ///
- /// If no room can be found exactly in that direction, then consider the directions
- /// either side. For example, after checking east and finding nothing, check
- /// east-north-east and east-south-east.
- ///
- private Room GetRoomInApproximateDirectionFromRoom(Room room, CompassPoint compassPoint)
- {
- var nextRoom = GetRoomInExactDirectionFromRoom(room, compassPoint);
- if (nextRoom == null)
- {
- nextRoom = GetRoomInExactDirectionFromRoom(room, CompassPointHelper.RotateAntiClockwise(compassPoint));
- }
- if (nextRoom == null)
- {
- nextRoom = GetRoomInExactDirectionFromRoom(room, CompassPointHelper.RotateClockwise(compassPoint));
- }
- return nextRoom;
- }
-
- ///
- /// Get a room which can be found in the given direction from the given room.
- ///
- /// The initial room.
- /// The direction to consider.
- /// The room which can be found in that direction, or null if none.
- private Room GetRoomInExactDirectionFromRoom(Room room, CompassPoint compassPoint)
- {
- var connections = room.GetConnections(compassPoint);
- foreach (var connection in connections)
- {
- foreach (var vertex in connection.VertexList)
- {
- var port = vertex.Port;
- if (port != null && port.Owner != room && port.Owner is Room)
- {
- return (Room)port.Owner;
- }
- }
- }
- return null;
- }
-
- ///
- /// Ensure the given element is visible, without changing the zoom factor.
- ///
- /// The element to make visible.
- private void EnsureVisible(Element element)
- {
- Rect rect = Rect.Empty;
- rect = element.UnionBoundsWith(rect, false);
- if (rect != Rect.Empty)
- {
- Origin = rect.Center;
- }
- }
-
- ///
- /// Ensure the given point is visible.
- ///
- /// The canvas position to make visible.
- private void EnsureVisible(Vector canvasPos)
- {
- var topLeft = ClientToCanvas(PointF.Empty);
- var bottomRight = ClientToCanvas(new PointF(Width, Height));
- var dx = 0.0f;
- var dy = 0.0f;
- if (canvasPos.X < topLeft.X)
- {
- dx -= topLeft.X - canvasPos.X;
- }
- if (canvasPos.Y < topLeft.Y)
- {
- dy -= topLeft.Y - canvasPos.Y;
- }
- if (canvasPos.X > bottomRight.X)
- {
- dx += canvasPos.X - bottomRight.X;
- }
- if (canvasPos.Y > bottomRight.Y)
- {
- dy += canvasPos.Y - bottomRight.Y;
- }
- if (dx != 0 || dy != 0)
- {
- var origin = Origin;
- Origin = new Vector(origin.X + dx, origin.Y + dy);
- }
- }
-
- private void BeginDragPan(PointF clientPos, Vector canvasPos)
- {
- DragMode = DragModes.Pan;
- m_panPosition = clientPos;
- Cursor = Cursors.NoMove2D;
- Capture = true;
- }
-
- private void BeginDragMove(PointF clientPos, Vector canvasPos)
- {
- if (HoverHandle != null)
- {
- DragMode = DragModes.MoveResizeHandle;
- m_dragResizeHandleLastPosition = canvasPos; // unsnapped
- Capture = true;
- }
- else if (HoverPort != null)
- {
- if (HoverPort is MoveablePort)
- {
- m_dragMovePort = (MoveablePort)HoverPort;
- m_dragOffsetCanvas = Settings.Snap(canvasPos - HoverPort.Position);
- DragMode = DragModes.MovePort;
- Capture = true;
- }
- }
- else
- {
- var hitElement = HitTestElement(canvasPos, false);
-
- bool alreadySelected = m_selectedElements.Contains(hitElement);
- if (!alreadySelected && (Control.ModifierKeys & (Keys.Control|Keys.Shift)) == Keys.None)
- {
- // if clicking on empty space, or an unselected element, without holding Control/Shift, clear the current selection.
- m_selectedElements.Clear();
- }
- else if (hitElement != null)
- {
- // if clicking on a selected element, remove it from the selection;
- // we do this since element's size handles etc. belong to the SelectedElement
- // which is the last one in the list, so we want to add this one back to the end
- // of the list as the user seems more interested in it and may want handles.
- m_selectedElements.Remove(hitElement);
- }
- if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
- {
- if (!alreadySelected && hitElement != null)
- {
- // if we're holding shift and we clicked an element which wasn't already selected, select it.
- m_selectedElements.Add(hitElement);
- }
- }
- else if (hitElement != null)
- {
- // if we're not holding shift, ensure the current element is selected.
- // we're safe to re-add it since it will definitely have been removed already
- // if it was selected, by the above logic.
- m_selectedElements.Add(hitElement);
- }
-
- // now we've finished messing with the set of selected elements,
- // update handles, ports, and take defaults for new elements from the most recently selected element.
- UpdateSelection();
-
- if (hitElement != null && m_selectedElements.Contains(hitElement))
- {
- // if we ended up with the hit element being selected, initiate a drag move.
- DragMode = DragModes.MoveElement;
- canvasPos = Settings.Snap(canvasPos);
- m_dragOffsetCanvas = canvasPos;
- Capture = true;
- }
- else if (hitElement == null)
- {
- // if we didn't hit anything at all, begin a new marquee selection.
- DragMode = DragModes.Marquee;
- m_dragOffsetCanvas = canvasPos;
- m_dragMarqueeLastPosition = canvasPos;
- Capture = true;
- }
- }
- Invalidate();
- }
-
- private void BeginDragDrawLine()
- {
- DragMode = DragModes.DrawLine;
- Capture = true;
- }
-
- private void BeginDrawConnection(PointF clientPos, Vector canvasPos)
- {
- Connection connection;
- HoverPort = HitTestPort(canvasPos);
- if (HoverPort != null && !(HoverPort is MoveablePort))
- {
- // Only from non-moveable ports, until we fix docking.
- // See also DoDragMovePort().
- connection = new Connection(Project.Current, new Vertex(HoverPort), new Vertex(HoverPort));
- }
- else
- {
- var pos = Settings.Snap(canvasPos);
- connection = new Connection(Project.Current, new Vertex(pos), new Vertex(pos));
- }
- connection.Style = NewConnectionStyle;
- connection.Flow = NewConnectionFlow;
- connection.SetText(NewConnectionLabel);
- Project.Current.Elements.Add(connection);
- SelectedElement = connection;
- m_dragMovePort = (MoveablePort)connection.Ports[1];
- m_dragOffsetCanvas = Settings.Snap(canvasPos - connection.VertexList[0].Position);
- HoverPort = null;
- DragMode = DragModes.MovePort;
- Capture = true;
- }
-
- public void AddRoom(bool atCursor)
- {
- var room = new Room(Project.Current);
- Vector pos;
- if (atCursor && ClientRectangle.Contains(PointToClient(Control.MousePosition)))
- {
- // center on the mouse cursor
- pos = ClientToCanvas(PointToClient(Control.MousePosition));
- }
- else
- {
- // center on the origin
- pos = new Vector(Origin.X - room.Size.X / 2, Origin.Y - room.Size.Y / 2);
- }
-
- // rooms' origins are in the top left corner
- pos -= room.Size / 2;
-
- // snap to the grid, if required
- pos = Settings.Snap(pos);
-
- bool clash = true;
- while (clash)
- {
- clash = false;
- foreach (var element in Project.Current.Elements)
- {
- if (element is IMoveable && ((IMoveable)element).Position == pos)
- {
- pos.X += Math.Max(2, Settings.GridSize);
- pos.Y += Math.Max(2, Settings.GridSize);
- clash = true;
- }
- }
- }
- room.Position = pos;
- Project.Current.Elements.Add(room);
- SelectedElement = room;
- }
-
- private void DoDragPan(PointF clientPos, Vector canvasPos)
- {
- var delta = Drawing.Subtract(m_panPosition, clientPos);
- delta = Drawing.Divide(delta, ZoomFactor);
- Origin = new Vector(Origin.X + delta.X, Origin.Y + delta.Y);
- m_panPosition = clientPos;
- }
-
- private void DoDragMoveElement(PointF clientPos, Vector canvasPos)
- {
- canvasPos = Settings.Snap(canvasPos);
- foreach (var element in m_selectedElements)
- {
- MoveElementBy(element, canvasPos - m_dragOffsetCanvas);
- }
- m_dragOffsetCanvas = canvasPos;
- }
-
- private void MoveElementBy(Element element, Vector delta)
- {
- if (element is IMoveable)
- {
- // move any selected moveable elements
- var moveable = (IMoveable)element;
- moveable.Position += delta;
- }
-
- if (element is Connection)
- {
- // move any free floating points on selected connections
- var connection = (Connection)element;
- foreach (var vertex in connection.VertexList)
- {
- if (vertex.Port == null)
- {
- vertex.Position += delta;
- }
- }
- }
- }
-
- private void DoDragMoveResizeHandle(PointF clientPos, Vector canvasPos)
- {
- // the mouse has moved this much on the canvas since we last successfully resized the element
- var delta = canvasPos - m_dragResizeHandleLastPosition;
-
- if (HoverHandle != null)
- {
- // work out to whether and where we'd like to move the element's corner/edge
- var newPosition = HoverHandle.OwnerPosition + delta;
- if (newPosition != HoverHandle.OwnerPosition)
- {
- // we'd like to move the element's corner/edge;
- // try to do so
- var oldPosition = HoverHandle.OwnerPosition;
- HoverHandle.OwnerPosition = Settings.Snap(newPosition);
-
- // *NOTE 1: *IN THEORY* you'd imagine we could just set the corner/edge position to
- // a grid-snapped version of the mouse position on the canvas. This would work if
- // our handles were directly over the corner/edge we're resizing, but they may not
- // be since we may want to display both resize handles and "draw a new connection"
- // ports for a corner/edge and so move the resize handles outward so both will fit.
- // Hence this mucking about with delta values instead.
- //
- // *NOTE 2: That said, *IN THEORY* you'd imagine we would just set m_dragResizeHandleLastPosition
- // to canvasPos here, regardless of whether we actually resized the element.
- // This is true but for a couple of subtle issues:
- //
- // i) Elements have a minimum size (even if it's a width and height of 0). If we're
- // dragging the buttom right corner of an element up/left, we want the element to stop
- // at said minimum size, and this is handled by the ResizeHandle. However, our mouse
- // cursor may keep moving up/left in the meantime; when it eventually moves down/right
- // again, we want the element NOT to resize until the mouse cursor is actually over a
- // position such that if we moved the element's corner/edge that way it would grow in size.
- // (Try resizing a window in Windows and see what I mean.) We achieve this by not changing
- // m_dragResizeHandleLastPosition unless we actually effect a change.
- //
- // ii) Snap to grid. If we just set the last position to the canvas mouse position, then
- // when resizing you'll observe that the mouse cursor "desyncs" with the element's
- // corner edge the larger we make the element. This is because of accumulated error
- // in m_dragResizeHandleLastPosition due to the snap. An easy way to resolve this is
- // to apply the delta by which we actually resized the element instead of using
- // the canvas mouse position.
- if (HoverHandle.OwnerPosition.X != oldPosition.X)
- {
- // we managed to move the element's corner/edge horizontally, on the X axis;
- // on this axis, apply the effective delta to our the basis for future movement.
- m_dragResizeHandleLastPosition.X += HoverHandle.OwnerPosition.X - oldPosition.X;
- }
- if (HoverHandle.OwnerPosition.Y != oldPosition.Y)
- {
- // likewise for the vertical/Y axis
- m_dragResizeHandleLastPosition.Y += HoverHandle.OwnerPosition.Y - oldPosition.Y;
- }
- }
- }
- }
-
- private void DoDragMovePort(PointF clientPos, Vector canvasPos)
- {
- if (HoverPort != null && HoverPort != m_dragMovePort)
- {
- if (m_dragMovePort.DockedAt != HoverPort && (!(HoverPort is MoveablePort) || ((MoveablePort)HoverPort).DockedAt != m_dragMovePort))
- {
-
- // TODO: Docking disabled until a decent mechanism is worked out.
- // Currently can cause infinite loops which can crash the program;
- // eg. dock A to B, B to C, C to A.
- // Also after docking A to B, moving B brings A but moving A doesn't bring B.
- // Perhaps some form of "weld" to make the vertices actually the same?
- // And a corresponding "unweld" option?
- // Or simply detect circular references and refuse to make them,
- // always move them all together, etc.
-
- // m_dragMovePort.DockAt(HoverPort);
-
- // Until docking re-enabled, treat as positional move;
- // but do dock to rooms etc. as that's safe.
- // See also BeginDrawConnection().
- if (!(HoverPort is MoveablePort))
- {
- m_dragMovePort.DockAt(HoverPort);
- }
- else
- {
- canvasPos = Settings.Snap(canvasPos);
- m_dragMovePort.SetPosition(canvasPos - m_dragOffsetCanvas);
- }
- }
- else
- {
- // leave docking alone, and don't snap to grid
- }
- }
- else
- {
- canvasPos = Settings.Snap(canvasPos);
- m_dragMovePort.SetPosition(canvasPos - m_dragOffsetCanvas);
- }
- }
-
- private void EndDrag()
- {
- if (DragMode == DragModes.MovePort)
- {
- // clear the selection now the line is drawn
- SelectedElement = null;
-
- if (m_dragMovePort.Owner is Connection)
- {
- // remove dead connections
- var connection = (Connection)m_dragMovePort.Owner;
- bool same = true;
- if (connection.VertexList.Count > 0)
- {
- var pos = connection.VertexList[0].Position;
- foreach (Vertex v in connection.VertexList)
- {
- if (v.Port != null && v.Port.Owner is Room)
- {
- // keep connections attached to rooms;
- // if they don't go anywhere, they
- // go back to the room, which is significant.
- same = false;
- }
-
- var distance = v.Position.Distance(pos);
- if (distance > Numeric.Small)
- {
- // keep connections which visibly go anywhere
- same = false;
- }
- }
- }
- if (same)
- {
- // remove connections which don't go anywhere useful
- Project.Current.Elements.Remove(connection);
- }
- }
- }
- else if (DragMode == DragModes.Marquee)
- {
- var marqueeRect = GetMarqueeCanvasBounds();
- if ((Control.ModifierKeys & (Keys.Shift | Keys.Control)) == Keys.None)
- {
- m_selectedElements.Clear();
- }
- foreach (var element in HitTest(marqueeRect, false))
- {
- if (!m_selectedElements.Contains(element))
- {
- m_selectedElements.Add(element);
- }
- else if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
- {
- if (m_selectedElements.Contains(element))
- {
- m_selectedElements.Remove(element);
- }
- }
- }
- UpdateSelection();
- }
- DragMode = DragModes.None;
- HoverHandle = null;
- Capture = false;
- Cursor = null;
- Invalidate();
- }
-
- private List HitTest(Rect rect, bool roomsOnly)
- {
- var list = new List();
- foreach (var element in Project.Current.Elements)
- {
- if ((!roomsOnly || element is Room) && element.Intersects(rect))
- {
- list.Add(element);
- }
- }
- return list;
- }
-
- private Rect GetMarqueeCanvasBounds()
- {
- if (DragMode != DragModes.Marquee)
- {
- return Rect.Empty;
- }
- var topLeft = m_dragOffsetCanvas;
- var bottomRight = ClientToCanvas(PointToClient(Control.MousePosition));
- if (bottomRight.X < topLeft.X)
- {
- Numeric.Swap(ref bottomRight.X, ref topLeft.X);
- }
- if (bottomRight.Y < topLeft.Y)
- {
- Numeric.Swap(ref bottomRight.Y, ref topLeft.Y);
- }
- return new Rect(topLeft.X, topLeft.Y, bottomRight.X - topLeft.X, bottomRight.Y - topLeft.Y);
- }
-
- private float SnapToElementSizeAtCurrentZoomFactor
- {
- get { return Settings.SnapToElementSize; }
- }
-
- private Element HitTestElement(Vector canvasPos, bool includeMargins)
- {
- List closest = new List();
- float closestDistance = float.MaxValue;
- foreach (var element in DepthSortElements()) // sort into drawing order
- {
- if (DragMode == DragModes.MovePort && m_dragMovePort.Owner == element)
- {
- // when moving a port on an element, don't try to dock it to that element itself
- continue;
- }
-
- float distance = element.Distance(canvasPos, includeMargins);
- if (distance <= SnapToElementSizeAtCurrentZoomFactor)
- {
- if (Numeric.ApproxEqual(distance, closestDistance))
- {
- closest.Add(element);
- }
- else if (distance < closestDistance)
- {
- closest.Clear();
- closest.Add(element);
- closestDistance = distance;
- }
- }
- }
-
- if (closest.Count == 0)
- {
- return null;
- }
- return closest[closest.Count - 1]; // choose the topmost element
- }
-
- private ResizeHandle HitTestHandle(Vector canvasPos)
- {
- // examine handles, topmost (drawn) to lowermost
- for (int index = m_handles.Count - 1; index >= 0; --index)
- {
- var handle = m_handles[index];
- if (handle.HitTest(canvasPos))
- {
- return handle;
- }
- }
- return null;
- }
-
- private Port HitTestPort(Vector canvasPos)
- {
- Port closest = null;
- float closestDistance = float.MaxValue;
-
- foreach (var port in m_ports)
- {
- if (DragMode == DragModes.MovePort && port == m_dragMovePort)
- {
- // when dragging a port, don't try to dock it with itself
- continue;
- }
-
- float distance = port.Distance(canvasPos);
-
- var snapDistance = SnapToElementSizeAtCurrentZoomFactor;
-
- var bounds = port.Owner.UnionBoundsWith(Rect.Empty, true);
- if (bounds.Contains(canvasPos))
- {
- if (DragMode == DragModes.MovePort)
- {
- // if we're dragging a line to set its end point and are over a room, ALWAYS snap to ports:
- // we do this to avoid the user accidentally making a connection that "nearly" goes to a room.
- snapDistance = float.MaxValue;
- }
- else
- {
- // if we'starting a new line and are over a room, NEVER snap to ports:
- // we do this if hit testing inside so we can more easily select small rooms and not their ports
- snapDistance = 0;
- }
- }
-
- if (distance <= snapDistance && distance < closestDistance)
- {
- closest = port;
- closestDistance = distance;
- }
- }
- return closest;
- }
-
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public Element SelectedElement
- {
- get { return m_selectedElements.Count > 0 ? m_selectedElements[m_selectedElements.Count - 1] : null; }
- set
- {
- var selectedElement = m_selectedElements.Count > 0 ? m_selectedElements[m_selectedElements.Count - 1] : null;
- if (selectedElement != value)
- {
- m_selectedElements.Clear();
- if (value != null)
- {
- m_selectedElements.Add(value);
- }
- UpdateSelection();
- }
- }
- }
-
- public int SelectedElementCount
- {
- get { return m_selectedElements.Count; }
- }
-
- public bool HasSingleSelectedElement
- {
- get { return SelectedElementCount == 1; }
- }
-
- public bool HasSelectedElement() where T : Element
- {
- foreach (var element in m_selectedElements)
- {
- if (element is T)
- {
- return true;
- }
- }
- return false;
- }
-
- public IEnumerable SelectedElements
- {
- get { return m_selectedElements; }
- }
-
- void UpdateSelection()
- {
- RecreateHandles();
- RecreatePorts();
- // only if we have a single element selected;
- // otherwise selecting multiple items will cause one to override the others' settings!
- var selectedElement = SelectedElement;
- if (selectedElement is Connection)
- {
- SetConnectionDefaultsFrom((Connection)selectedElement);
- }
- else if (selectedElement is Room)
- {
- SetRoomDefaultsFrom((Room)selectedElement);
- }
- Invalidate();
- }
-
- public void SelectAll()
- {
- m_selectedElements.Clear();
- m_selectedElements.AddRange(Project.Current.Elements);
- UpdateSelection();
- }
-
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- private ResizeHandle HoverHandle
- {
- get { return m_hoverHandle; }
- set
- {
- if (m_hoverHandle != value)
- {
- m_hoverHandle = value;
- Invalidate();
- }
- }
- }
-
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- private Port HoverPort
- {
- get { return m_hoverPort; }
- set
- {
- if (m_hoverPort != value)
- {
- m_hoverPort = value;
- Invalidate();
- }
- }
- }
-
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public Element HoverElement
- {
- get
- {
- return m_hoverElement;
- }
- set
- {
- if (m_hoverElement != value)
- {
- m_hoverElement = value;
- RecreatePorts();
- }
- }
- }
-
- private void RecreateHandles()
- {
- HoverHandle = null;
- m_handles.Clear();
- var element = SelectedElement;
- if (CanSelectElements && element is ISizeable && HasSingleSelectedElement)
- {
- var sizeable = (ISizeable)element;
- m_handles.Add(new ResizeHandle(CompassPoint.North, sizeable));
- m_handles.Add(new ResizeHandle(CompassPoint.South, sizeable));
- m_handles.Add(new ResizeHandle(CompassPoint.East, sizeable));
- m_handles.Add(new ResizeHandle(CompassPoint.West, sizeable));
- m_handles.Add(new ResizeHandle(CompassPoint.NorthWest, sizeable));
- m_handles.Add(new ResizeHandle(CompassPoint.NorthEast, sizeable));
- m_handles.Add(new ResizeHandle(CompassPoint.SouthWest, sizeable));
- m_handles.Add(new ResizeHandle(CompassPoint.SouthEast, sizeable));
- }
-
- Invalidate();
- }
-
- private void RecreatePorts()
- {
- HoverPort = null;
- m_ports.Clear();
-
- // decide if we want ports on the element under the mouse cursor; if so, add them
- if (HoverElement is Room && !m_selectedElements.Contains(HoverElement))
- {
- // we're hovering over a non-selected room;
- // (we don't show ports on selected rooms since they get handles already and it's too confusing;
- // we don't show ports on lines we're hovering over, since we don't allow line-line connections
- // right now as the algorithm's borked somewhere and can end up with nastiness)
- if (DragMode == DragModes.MovePort || (CanDrawLine && SelectedElement == null))
- {
- // when we're either:
- // i) currently dragging a new or existing line's end point, OR
- // ii) can draw a new line, and haven't got anything selelected
- // then we're safe to show ports on the room we're overing over
- // from which new connections can be drawn.
- // We're trying to avoid visual clashes between (stacking of), and
- // associated selection problems with, a selected connection and the
- // ports of the room joined to one end of the connection.
- // Rather than special casing this which might confuse the user as to
- // when they can draw lines and when they can't we make the general rule
- // that if you've got something selected you can't draw a line.
- m_ports.AddRange(HoverElement.Ports);
- }
- }
-
- // decide if we want movable ports on the selected element; if so, add them
- // (currently movable ports only apply to connections, and if we want to be able
- // to move a connection we must show them.)
- var needMovablePortsOnSelectedElement = CanSelectElements;
- if (needMovablePortsOnSelectedElement && HasSingleSelectedElement)
- {
- foreach (var port in SelectedElement.Ports)
- {
- if (port is MoveablePort)
- {
- m_ports.Add(port);
- }
- }
- }
-
- Invalidate();
- }
-
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- private DragModes DragMode
- {
- get { return m_dragMode; }
- set
- {
- m_dragMode = value;
- RecreatePorts();
- }
- }
-
- public bool CanSelectElements
- {
- get { return true; }
- }
-
- public bool CanDrawLine
- {
- get { return true; }
- }
-
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public ConnectionStyle NewConnectionStyle
- {
- get { return m_newConnectionStyle; }
- set
- {
- if (m_newConnectionStyle != value)
- {
- m_newConnectionStyle = value;
- RaiseNewConnectionStyleChanged();
- }
- }
- }
-
- public void ApplyConnectionStyle(ConnectionStyle connectionStyle)
- {
- foreach (var element in m_selectedElements)
- {
- if (element is Connection)
- {
- var connection = (Connection)element;
- connection.Style = connectionStyle;
- }
- }
- Invalidate();
- }
-
- public event EventHandler NewConnectionStyleChanged;
-
- private void RaiseNewConnectionStyleChanged()
- {
- var changed = NewConnectionStyleChanged;
- if (changed != null)
- {
- changed(this, EventArgs.Empty);
- }
- }
-
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public ConnectionFlow NewConnectionFlow
- {
- get { return m_newConnectionFlow; }
- set
- {
- if (m_newConnectionFlow != value)
- {
- m_newConnectionFlow = value;
- RaiseNewConnectionFlowChanged();
- }
- }
- }
-
- public void ApplyConnectionFlow(ConnectionFlow connectionFlow)
- {
- foreach (var element in m_selectedElements)
- {
- if (element is Connection)
- {
- var connection = (Connection)element;
- connection.Flow = connectionFlow;
- }
- }
- Invalidate();
- }
-
- public event EventHandler NewConnectionFlowChanged;
-
- private void RaiseNewConnectionFlowChanged()
- {
- var changed = NewConnectionFlowChanged;
- if (changed != null)
- {
- changed(this, EventArgs.Empty);
- }
- }
-
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public ConnectionLabel NewConnectionLabel
- {
- get { return m_newConnectionLabel; }
- set
- {
- if (m_newConnectionLabel != value)
- {
- m_newConnectionLabel = value;
- RaiseNewConnectionLabelChanged();
- }
- }
- }
-
- public void ApplyConnectionLabel(ConnectionLabel connectionLabel)
- {
- foreach (var element in m_selectedElements)
- {
- if (element is Connection)
- {
- var connection = (Connection)element;
- connection.SetText(connectionLabel);
- }
- }
- Invalidate();
- }
-
- public event EventHandler NewConnectionLabelChanged;
-
- private void RaiseNewConnectionLabelChanged()
- {
- var changed = NewConnectionLabelChanged;
- if (changed != null)
- {
- changed(this, EventArgs.Empty);
- }
- }
-
- public override Cursor Cursor
- {
- get
- {
- if (CanDrawLine && ((HoverPort != null && !(HoverPort is MoveablePort)) || DragMode == DragModes.MovePort))
- {
- return Drawing.DrawLineCursor;
- }
-
- if (HoverPort != null && HoverPort is MoveablePort)
- {
- return Drawing.MoveLineCursor;
- }
-
- if (HoverHandle != null)
- {
- var cursor = HoverHandle.Cursor;
- if (cursor != null)
- {
- return cursor;
- }
- }
-
- if (HoverElement != null && HoverElement is IMoveable && m_selectedElements.Contains(HoverElement))
- {
- return Cursors.SizeAll;
- }
- return base.Cursor;
- }
- set
- {
- base.Cursor = value;
- }
- }
-
- public void ResetZoomOrigin()
- {
- Origin = ComputeCanvasBounds(false).Center;
- ZoomFactor = 1.0f;
- }
-
- public void ZoomIn()
- {
- if (ZoomFactor < 100.0f)
- {
- ZoomFactor *= 1.25f;
- }
- }
-
- public void ZoomOut()
- {
- if (ZoomFactor > 1 / 100.0f)
- {
- ZoomFactor /= 1.25f;
- }
- }
-
- public void ZoomToFit()
- {
- ResetZoomOrigin();
- var canvasBounds = ComputeCanvasBounds(false);
- while (!Viewport.Contains(canvasBounds))
- {
- ZoomOut();
- }
- }
-
- private void SetRoomDefaultsFrom(Room room)
- {
- m_newRoomSize = room.Size;
- m_newRoomIsDark = room.IsDark;
- m_newRoomObjectsPosition = room.ObjectsPosition;
- }
-
- private void SetConnectionDefaultsFrom(Connection connection)
- {
- NewConnectionFlow = connection.Flow;
- NewConnectionStyle = connection.Style;
- }
-
- public void ReverseLineDirection()
- {
- foreach (var element in m_selectedElements)
- {
- if (element is Connection)
- {
- var connection = (Connection)element;
- connection.Reverse();
- }
- }
- }
-
- public void DeleteSelection()
- {
- var doomedElements = new List(m_selectedElements);
- foreach (var element in doomedElements)
- {
- Project.Current.Elements.Remove(element);
- }
- m_selectedElements.Clear();
- UpdateSelection();
- }
-
- public void ApplyNewPlainConnectionSettings()
- {
- // apply sequentially as each change will affect our defaults,
- // so setting the style will cause us to take the existing flow and label, etc.
- NewConnectionStyle = ConnectionStyle.Solid;
- ApplyConnectionStyle(NewConnectionStyle);
-
- NewConnectionFlow = ConnectionFlow.TwoWay;
- ApplyConnectionFlow(NewConnectionFlow);
-
- NewConnectionLabel = ConnectionLabel.None;
- ApplyConnectionLabel(NewConnectionLabel);
- }
-
- public void UpdateScrollBars()
- {
- m_updatingScrollBars = true;
-
- var topLeft = PointF.Empty;
- var displaySize = new PointF(Math.Max(0, Width - m_vScrollBar.Width), Math.Max(0,Height - m_hScrollBar.Height));
-
- Rect clientBounds;
- if (Project.Current.Elements.Count > 0)
- {
- Rect canvasBounds = Rect.Empty;
- foreach (var element in Project.Current.Elements)
- {
- canvasBounds = element.UnionBoundsWith(canvasBounds, true);
- }
-
- var tl = CanvasToClient(canvasBounds.Position);
- var br = CanvasToClient(canvasBounds.GetCorner(CompassPoint.SouthEast));
- clientBounds = new Rect(tl.X, tl.Y, br.X - tl.X, br.Y - tl.Y);
- }
- else
- {
- // if there's nothing on the canvas, don't include the origin (0,0) as a "thing" to scroll to
- clientBounds = new Rect(topLeft.X, topLeft.Y, displaySize.X, displaySize.Y);
- }
-
- if (!Settings.InfiniteScrollBounds && topLeft.Y <= clientBounds.Top && topLeft.Y + displaySize.Y >= clientBounds.Bottom)
- {
- m_vScrollBar.Enabled = false;
- }
- else
- {
- m_vScrollBar.Enabled = true;
- m_vScrollBar.Minimum = (int)Math.Min(topLeft.Y, clientBounds.Top);
- m_vScrollBar.Maximum = (int)Math.Max(topLeft.Y + displaySize.Y, clientBounds.Bottom) - 1; // -1 since Maximum is actually maximum value + 1; see MSDN.
- m_vScrollBar.Value = (int)Math.Max(m_vScrollBar.Minimum, Math.Min(m_vScrollBar.Maximum, topLeft.Y));
- m_vScrollBar.LargeChange = (int)displaySize.Y;
- m_vScrollBar.SmallChange = (int)(displaySize.Y / 10);
- }
-
- if (!Settings.InfiniteScrollBounds && topLeft.X <= clientBounds.Left && topLeft.X + displaySize.X >= clientBounds.Right)
- {
- m_hScrollBar.Enabled = false;
- }
- else
- {
- m_hScrollBar.Enabled = true;
- m_hScrollBar.Minimum = (int)Math.Min(topLeft.X, clientBounds.Left);
- m_hScrollBar.Maximum = (int)Math.Max(topLeft.X + displaySize.X, clientBounds.Right) - 1; // -1 since Maximum is actually maximum value + 1; see MSDN.
- m_hScrollBar.Value = (int)Math.Max(m_hScrollBar.Minimum, Math.Min(m_hScrollBar.Maximum, topLeft.X));
- m_hScrollBar.LargeChange = (int)displaySize.X;
- m_hScrollBar.SmallChange = (int)(displaySize.X / 10);
- }
-
- m_updatingScrollBars = false;
- }
-
- private void ScrollBar_Scroll(object sender, ScrollEventArgs e)
- {
- if (m_updatingScrollBars)
- {
- return;
- }
-
- // the scroll bar will Invalidate() and Update() us; avoid exceptions
- m_doNotUpdateScrollBarsNextPaint = true;
-
- var clientDelta = e.NewValue - e.OldValue;
- if (Settings.InfiniteScrollBounds && e.Type == ScrollEventType.SmallIncrement || e.Type == ScrollEventType.SmallDecrement)
- {
- // since our canvas is infinite, allow the user to use the
- // scroll bar arrows to keep scrolling past the bounds.
- if (Math.Abs(clientDelta) != m_vScrollBar.SmallChange)
- {
- clientDelta = m_vScrollBar.SmallChange * (e.Type == ScrollEventType.SmallIncrement ? 1 : -1);
- }
- }
- if (clientDelta != 0)
- {
- if (sender == m_vScrollBar)
- {
- Origin += new Vector(ClientToCanvas(new SizeF(0, clientDelta)));
- }
- else
- {
- Origin += new Vector(ClientToCanvas(new SizeF(clientDelta, 0)));
- }
- }
- }
-
- public bool MinimapVisible
- {
- get { return m_minimap.Visible; }
- set
- {
- m_minimap.Visible = value;
- if (!m_minimap.Visible)
- {
- m_vScrollBar.Top = 0;
- m_vScrollBar.Height = Height - m_cornerPanel.Height;
- }
- else
- {
- m_vScrollBar.Top = m_minimap.Bottom;
- m_vScrollBar.Height = Height - m_cornerPanel.Height - m_minimap.Height;
- }
- }
- }
-
- private enum DragModes
- {
- None,
- Pan,
- MoveElement,
- MoveResizeHandle,
- MovePort,
- Marquee,
- DrawLine,
- }
-
- private void Reset()
- {
- ZoomFactor = 1;
- Origin = Vector.Zero;
- SelectedElement = null;
- HoverElement = null;
- HoverHandle = null;
- HoverPort = null;
- DragMode = DragModes.None;
- NewConnectionStyle = ConnectionStyle.Solid;
- NewConnectionFlow = ConnectionFlow.TwoWay;
- m_newRoomSize = new Vector(Settings.GridSize * 3, Settings.GridSize * 2);
- m_newRoomIsDark = false;
- m_newRoomObjectsPosition = CompassPoint.South;
- RequestRecomputeSmartSegments();
- StopAutomapping();
- }
-
- private float m_zoomFactor;
- private Vector m_origin;
-
- private List m_selectedElements = new List();
- private Element m_hoverElement;
- private ResizeHandle m_hoverHandle;
- private Port m_hoverPort;
-
- private Point m_lastKnownMousePosition;
- private Point m_lastMouseDownPosition;
- private DragModes m_dragMode;
- private PointF m_panPosition;
- private Vector m_dragOffsetCanvas;
- private MoveablePort m_dragMovePort;
- private Vector m_dragMarqueeLastPosition;
- private Vector m_dragResizeHandleLastPosition;
-
- private List m_handles = new List();
- private List m_ports = new List();
-
- private ConnectionStyle m_newConnectionStyle;
- private ConnectionFlow m_newConnectionFlow;
- private ConnectionLabel m_newConnectionLabel;
- private Vector m_newRoomSize;
- private bool m_newRoomIsDark;
- private CompassPoint m_newRoomObjectsPosition;
- private System.Threading.Timer m_recomputeTimer;
- private bool m_updatingScrollBars;
- private bool m_doNotUpdateScrollBarsNextPaint;
-
- private static readonly int RecomputeNMillisecondsAfterChange = 500;
- private static bool m_smartLineSegmentsUpToDate = false;
- }
-}
+/*
+ Copyright (c) 2010 by Genstein
+
+ This file is (or was originally) part of Trizbort, the Interactive Fiction Mapper.
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+*/
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Windows.Forms;
+using System.Diagnostics;
+using PdfSharp.Drawing;
+
+namespace Trizbort
+{
+ internal partial class Canvas : UserControl, IAutomapCanvas
+ {
+ public Canvas()
+ {
+ InitializeComponent();
+
+ SetStyle(ControlStyles.Selectable, true);
+ TabStop = true;
+ TabIndex = 0;
+
+ SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true);
+ DoubleBuffered = true;
+ m_cornerPanel.BackColor = SystemColors.Control;
+
+ PreviewKeyDown += OnPreviewKeyDown;
+
+ m_recomputeTimer = new System.Threading.Timer(OnRecomputeTimerTick);
+
+ Project.ProjectChanged += OnProjectChanged;
+ OnProjectChanged(this, new ProjectChangedEventArgs(null, Project.Current));
+
+ Settings.Changed += OnSettingsChanged;
+ OnSettingsChanged(this, EventArgs.Empty);
+
+ m_threadSafeAutomapCanvas = new MultithreadedAutomapCanvas(this);
+ m_minimap.Canvas = this;
+ }
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ StopAutomapping();
+ if (components != null)
+ {
+ components.Dispose();
+ }
+ }
+ base.Dispose(disposing);
+ }
+
+ protected override void WndProc(ref Message m)
+ {
+ switch (m.Msg)
+ {
+ case 0x0007: // WM_SETFOCUS
+ // do not pass focus to our child controls
+ m.Result = IntPtr.Zero;
+ return;
+ }
+ base.WndProc(ref m);
+ }
+
+ private void RequestRecomputeSmartSegments()
+ {
+ m_smartLineSegmentsUpToDate = false;
+ m_recomputeTimer.Change(RecomputeNMillisecondsAfterChange, RecomputeNMillisecondsAfterChange);
+ }
+
+ private void OnRecomputeTimerTick(object state)
+ {
+ m_recomputeTimer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);
+
+ var context = new DrawingContext(ZoomFactor);
+ var elements = DepthSortElements();
+
+ foreach (var element in elements)
+ {
+ element.PreDraw(context);
+ }
+
+ foreach (var element in elements)
+ {
+ element.RecomputeSmartLineSegments(context);
+ }
+
+ m_smartLineSegmentsUpToDate = true;
+ Invalidate();
+ }
+
+ private void OnProjectChanged(object sender, ProjectChangedEventArgs e)
+ {
+ if (e.OldProject != null)
+ {
+ e.OldProject.Elements.Added -= OnElementAdded;
+ e.OldProject.Elements.Removed -= OnElementRemoved;
+
+ foreach (var element in e.OldProject.Elements)
+ {
+ element.Changed -= OnElementChanged;
+ }
+ }
+ if (e.NewProject != null)
+ {
+ e.NewProject.Elements.Added += OnElementAdded;
+ e.NewProject.Elements.Removed += OnElementRemoved;
+
+ foreach (var element in e.NewProject.Elements)
+ {
+ element.Changed += OnElementChanged;
+ }
+ }
+
+ Reset();
+ ZoomToFit();
+ }
+
+ private void OnSettingsChanged(object sender, EventArgs e)
+ {
+ RequestRecomputeSmartSegments();
+ BackColor = Settings.Color[Colors.Canvas];
+ Invalidate();
+ }
+
+ private void OnElementAdded(object sender, ItemEventArgs e)
+ {
+ if (e.Item is Room)
+ {
+ var room = (Room)e.Item;
+ room.Size = m_newRoomSize;
+ room.IsDark = m_newRoomIsDark;
+ room.ObjectsPosition = m_newRoomObjectsPosition;
+ }
+ e.Item.Changed += OnElementChanged;
+ Project.Current.IsDirty = true;
+ RequestRecomputeSmartSegments();
+ Invalidate();
+ }
+
+ private void OnElementRemoved(object sender, ItemEventArgs e)
+ {
+ m_selectedElements.Remove(e.Item);
+ UpdateSelection();
+ EndDrag();
+ UpdateDragHover(PointToClient(Control.MousePosition));
+
+ Project.Current.IsDirty = true;
+ e.Item.Changed -= OnElementChanged;
+ RequestRecomputeSmartSegments();
+ Invalidate();
+ }
+
+ private void OnElementChanged(object sender, EventArgs e)
+ {
+ if (sender is Room)
+ {
+ SetRoomDefaultsFrom((Room)sender);
+ }
+ if (sender is Connection)
+ {
+ SetConnectionDefaultsFrom((Connection)sender);
+ }
+ Invalidate();
+ Project.Current.IsDirty = true;
+ RequestRecomputeSmartSegments();
+ }
+
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public float ZoomFactor
+ {
+ get { return m_zoomFactor; }
+ set
+ {
+ if (m_zoomFactor != value)
+ {
+ m_zoomFactor = value;
+ Invalidate();
+ }
+ }
+ }
+
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Vector Origin
+ {
+ get { return m_origin; }
+ set
+ {
+ if (m_origin != value)
+ {
+ m_origin = value;
+ Invalidate();
+ }
+ }
+ }
+
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Rect Viewport
+ {
+ get
+ {
+ var origin = Origin;
+ var size = ClientToCanvas(new SizeF(Width, Height));
+ return new Rect(origin.X - size.Width / 2, origin.Y - size.Height / 2, size.Width, size.Height);
+ }
+ }
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ if (DesignMode)
+ {
+ e.Graphics.Clear(Settings.Color[Colors.Canvas]);
+ return;
+ }
+
+ using (var nativeGraphics = Graphics.FromHdc(e.Graphics.GetHdc()))
+ {
+ using (var graphics = XGraphics.FromGraphics(nativeGraphics, new XSize(Width, Height)))
+ {
+ Draw(graphics, false, Width, Height);
+ }
+ }
+ e.Graphics.ReleaseHdc();
+
+ // update our scroll bars, unless this paint event was caused by the scroll bars,
+ // in which case messing with them may cause the scroll bars to throw exceptions.
+ if (!m_doNotUpdateScrollBarsNextPaint)
+ {
+ UpdateScrollBars();
+ }
+ m_doNotUpdateScrollBarsNextPaint = false;
+
+ // update the minimap
+ m_minimap.Invalidate();
+ m_minimap.Update();
+ }
+
+ public Rect ComputeCanvasBounds(bool includePadding)
+ {
+ var bounds = Rect.Empty;
+ foreach (var element in Project.Current.Elements)
+ {
+ bounds = element.UnionBoundsWith(bounds, true);
+ }
+
+ if (includePadding)
+ {
+ // HACK: fudge the canvas size to allow for overhanging line/object text
+ bounds.Inflate(Math.Max(Settings.LineFont.GetHeight(), Settings.SmallFont.GetHeight()) * 24);
+ }
+ return bounds;
+ }
+
+ ///
+ /// Draw the current project.
+ ///
+ /// The graphics with which to draw.
+ /// True if rendering to PDF, an image, etc.; false if rendering to a window.
+ /// The width of the drawing area.
+ /// The height of the drawing area.
+ public void Draw(XGraphics graphics, bool finalRender, float width, float height)
+ {
+ var stopwatch = new Stopwatch();
+ stopwatch.Start();
+
+ var zoomFactor = ZoomFactor;
+ var origin = Origin;
+ if (finalRender)
+ {
+ // zoom to fit (0,0)-(width,height)
+ var canvasBounds = ComputeCanvasBounds(true);
+ ZoomFactor = Math.Min(canvasBounds.Width > 0 ? width / canvasBounds.Width : 1.0f, canvasBounds.Height > 0 ? height / canvasBounds.Height : 1.0f);
+ Origin = new Vector(canvasBounds.X + canvasBounds.Width / 2, canvasBounds.Y + canvasBounds.Height / 2);
+ }
+
+ using (var palette = new Palette())
+ {
+ if (finalRender)
+ {
+ graphics.Clear(Settings.Color[Colors.Canvas]);
+ }
+
+ if (!finalRender)
+ {
+ DrawGrid(graphics, palette);
+ }
+
+ graphics.TranslateTransform(width / 2, height / 2);
+ graphics.ScaleTransform(ZoomFactor, ZoomFactor);
+ graphics.TranslateTransform(-Origin.X, -Origin.Y);
+
+ if (Settings.DebugShowFPS && !finalRender)
+ {
+ var canvasBounds = ComputeCanvasBounds(true);
+ graphics.DrawRectangle(XPens.Purple, canvasBounds.ToRectangleF());
+ }
+
+ if (Settings.ShowOrigin && !finalRender)
+ {
+ var pen = palette.Pen(Drawing.Mix(Settings.Color[Colors.Canvas], Settings.Color[Colors.SmallText], 3, 1));
+ var n = Settings.GridSize;
+ graphics.DrawLine(pen, -n, 0, n, 0);
+ graphics.DrawLine(pen, 0, -n, 0, n);
+ }
+
+ graphics.SmoothingMode = XSmoothingMode.AntiAlias;
+
+ DrawElements(graphics, palette, finalRender);
+ if (!finalRender)
+ {
+ DrawHandles(graphics, palette);
+ DrawPorts(graphics, palette);
+ DrawMarquee(graphics, palette);
+ }
+
+ stopwatch.Stop();
+ if (Settings.DebugShowFPS && !finalRender)
+ {
+ var fps = 1.0f / (float)(stopwatch.Elapsed.TotalSeconds);
+ graphics.Graphics.Transform = new Matrix();
+ graphics.DrawString(string.Format("{0} ms ({1} fps) {2} rebuilds", stopwatch.Elapsed.TotalMilliseconds, fps, TextBlock.RebuildCount), Settings.LargeFont, Brushes.Red, new PointF(10, 10 + Settings.LargeFont.GetHeight()));
+ }
+ }
+
+ ZoomFactor = zoomFactor;
+ Origin = origin;
+ }
+
+ private void DrawGrid(XGraphics graphics, Palette palette)
+ {
+ if (Settings.IsGridVisible && Settings.GridSize * ZoomFactor > 10)
+ {
+ var topLeft = Settings.Snap(ClientToCanvas(new PointF(-Settings.GridSize * ZoomFactor, -Settings.GridSize * ZoomFactor)));
+ var bottomRight = Settings.Snap(ClientToCanvas(new PointF(Width + Settings.GridSize * ZoomFactor, Height + Settings.GridSize * ZoomFactor)));
+ var points = new List();
+ var even = true;
+ for (float x = topLeft.X; x <= bottomRight.X; x += Settings.GridSize)
+ {
+ var start = CanvasToClient(new Vector(x, topLeft.Y));
+ var end = CanvasToClient(new Vector(x, bottomRight.Y));
+ if (even)
+ {
+ points.Add(start);
+ points.Add(end);
+ }
+ else
+ {
+ points.Add(end);
+ points.Add(start);
+ }
+ even = !even;
+ if (Settings.DebugDisableGridPolyline)
+ {
+ graphics.DrawLine(palette.GridPen, start, end);
+ }
+ }
+ if (!Settings.DebugDisableGridPolyline)
+ {
+ graphics.DrawLines(palette.GridPen, points.ToArray());
+ }
+ points = new List();
+ for (float y = topLeft.Y; y <= bottomRight.Y; y += Settings.GridSize)
+ {
+ var start = CanvasToClient(new Vector(topLeft.X, y));
+ var end = CanvasToClient(new Vector(bottomRight.X, y));
+ if (even)
+ {
+ points.Add(start);
+ points.Add(end);
+ }
+ else
+ {
+ points.Add(end);
+ points.Add(start);
+ }
+ even = !even;
+ if (Settings.DebugDisableGridPolyline)
+ {
+ graphics.DrawLine(palette.GridPen, start, end);
+ }
+ }
+ if (!Settings.DebugDisableGridPolyline)
+ {
+ graphics.DrawLines(palette.GridPen, points.ToArray());
+ }
+ }
+ }
+
+ private List DepthSortElements()
+ {
+ var elements = new List();
+ elements.AddRange(Project.Current.Elements);
+ elements.Sort();
+ return elements;
+ }
+
+ private void DrawElements(XGraphics graphics, Palette palette, bool finalRender)
+ {
+ if (Settings.DebugDisableElementRendering)
+ return;
+
+ bool disabledHandDrawLinesForSpeed = false;
+ if (!finalRender && ZoomFactor < 0.75f && Settings.HandDrawn)
+ {
+ disabledHandDrawLinesForSpeed = true;
+ Settings.HandDrawnUnchecked = false;
+ }
+
+ var context = new DrawingContext(ZoomFactor);
+ context.UseSmartLineSegments = m_smartLineSegmentsUpToDate;
+ var elements = DepthSortElements();
+
+ if (!context.UseSmartLineSegments)
+ {
+ foreach (var element in elements)
+ {
+ element.PreDraw(context);
+ element.Flagged = false;
+ }
+ }
+ else
+ {
+ foreach (var element in elements)
+ {
+ element.Flagged = false;
+ }
+ }
+
+ foreach (var element in m_selectedElements)
+ {
+ element.Flagged = true;
+ }
+
+ var clipToScreen = new RectangleF(Origin.X - Width / 2 / ZoomFactor, Origin.Y - Height / 2 / ZoomFactor, Width / ZoomFactor, Height / ZoomFactor);
+
+ foreach (var element in elements)
+ {
+ context.Selected = element.Flagged && !finalRender;
+ context.Hover = !context.Selected && element == HoverElement && !finalRender;
+ if (context.Hover && DragMode == DragModes.MovePort)
+ {
+ // special case: when we're creating or moving a line, don't highlight elements we hover over;
+ // we don't want it to look like these elements can dock with the line, since they can't.
+ context.Hover = false;
+ }
+
+ try
+ {
+ var elementBounds = element.UnionBoundsWith(Rect.Empty, true).ToRectangleF();
+ if (finalRender || clipToScreen.IntersectsWith(elementBounds))
+ {
+ element.Draw(graphics, palette, context);
+ }
+ }
+ catch (Exception)
+ {
+ // avoid GDI+ exceptions (vast shapes, etc.) taking down the canvas
+ }
+ }
+
+ if (disabledHandDrawLinesForSpeed)
+ {
+ Settings.HandDrawnUnchecked = true;
+ }
+ }
+
+ private void DrawHandles(XGraphics graphics, Palette palette)
+ {
+ if (m_handles.Count == 0)
+ {
+ return;
+ }
+
+ var context = new DrawingContext(ZoomFactor);
+
+ if (m_handles.Count > 1)
+ {
+ var bounds = Rect.Empty;
+
+ foreach (var handle in m_handles)
+ {
+ if (bounds == Rect.Empty)
+ {
+ bounds = new Rect(handle.Position, Vector.Zero);
+ }
+ else
+ {
+ bounds = bounds.Union(handle.Position);
+ }
+ }
+ bounds.X += Settings.HandleSize / 2f;
+ bounds.Y += Settings.HandleSize / 2f;
+ graphics.DrawRectangle(palette.ResizeBorderPen, bounds.ToRectangleF());
+ }
+
+
+ foreach (var handle in m_handles)
+ {
+ context.Selected = handle == HoverHandle;
+ handle.Draw(this, graphics, palette, context);
+ }
+ }
+
+ private void DrawPorts(XGraphics graphics, Palette palette)
+ {
+ var context = new DrawingContext(ZoomFactor);
+
+ // draw all non-selected ports
+ foreach (var port in m_ports)
+ {
+ if (HoverPort == port)
+ {
+ // we'll draw this port last
+ continue;
+ }
+
+ context.Selected = false;
+ port.Draw(this, graphics, palette, context);
+ }
+
+ if (HoverPort != null)
+ {
+ // lastly, always the port under the mouse, if any
+ context.Selected = true;
+ HoverPort.Draw(this, graphics, palette, context);
+ }
+ }
+
+ private void DrawMarquee(XGraphics graphics, Palette palette)
+ {
+ var marqueeRect = GetMarqueeCanvasBounds();
+ if (marqueeRect.Width > 0 && marqueeRect.Height > 0)
+ {
+ //var topLeft = CanvasToClient(new Vector(marqueeRect.X, marqueeRect.Y));
+ //var bottomRight = CanvasToClient(new Vector(marqueeRect.X + marqueeRect.Width, marqueeRect.Y + marqueeRect.Height));
+ //var rect = new RectangleF(topLeft.X, topLeft.Y, bottomRight.X - topLeft.X, bottomRight.Y - topLeft.Y);
+ graphics.DrawRectangle(palette.MarqueeFillBrush, marqueeRect.ToRectangleF());
+ var topLeft = new PointF(marqueeRect.Left, marqueeRect.Top);
+ var topRight = new PointF(marqueeRect.Right, marqueeRect.Top);
+ var bottomLeft = new PointF(marqueeRect.Left, marqueeRect.Bottom);
+ var bottomRight = new PointF(marqueeRect.Right, marqueeRect.Bottom);
+ graphics.DrawLine(palette.MarqueeBorderPen, topLeft, topRight);
+ graphics.DrawLine(palette.MarqueeBorderPen, topRight, bottomRight);
+ graphics.DrawLine(palette.MarqueeBorderPen, bottomLeft, bottomRight);
+ graphics.DrawLine(palette.MarqueeBorderPen, topLeft, bottomLeft);
+ }
+ }
+
+ public PointF CanvasToClient(Vector v)
+ {
+ v.X -= Origin.X;
+ v.X *= ZoomFactor;
+ v.X += Width / 2;
+ v.Y -= Origin.Y;
+ v.Y *= ZoomFactor;
+ v.Y += Height / 2;
+ return new PointF(v.X, v.Y);
+ }
+
+ public Vector ClientToCanvas(PointF p)
+ {
+ p.X -= Width / 2;
+ p.X /= ZoomFactor;
+ p.X += Origin.X;
+ p.Y -= Height / 2;
+ p.Y /= ZoomFactor;
+ p.Y += Origin.Y;
+ return new Vector(p.X, p.Y);
+ }
+
+ public SizeF CanvasToClient(SizeF s)
+ {
+ s.Width *= ZoomFactor;
+ s.Height *= ZoomFactor;
+ return s;
+ }
+
+ public SizeF ClientToCanvas(SizeF s)
+ {
+ s.Width /= ZoomFactor;
+ s.Height /= ZoomFactor;
+ return s;
+ }
+
+ private bool IsZoomIn(int delta) {
+ return (!Settings.InvertMouseWheel && delta < 0) || (Settings.InvertMouseWheel && delta > 0);
+ }
+
+ private bool IsZoomOut(int delta) {
+ return (!Settings.InvertMouseWheel && delta > 0) || (Settings.InvertMouseWheel && delta < 0);
+ }
+
+ protected override void OnMouseWheel(MouseEventArgs e)
+ {
+ if (e.X < 0 || e.X > Width || e.Y < 0 || e.Y > Width)
+ return;
+
+ var pos = ClientToCanvas(new PointF(e.X, e.Y));
+
+ if (IsZoomIn(e.Delta))
+ {
+ ZoomIn();
+ }
+ else if (IsZoomOut(e.Delta) && ZoomFactor > 1/100.0f)
+ {
+ ZoomOut();
+ }
+
+ Vector newPos = ClientToCanvas(new PointF(e.X, e.Y));
+ Origin = Origin - (newPos - pos);
+
+ Invalidate();
+ UpdateDragHover(e.Location);
+
+ base.OnMouseWheel(e);
+ }
+
+ private bool IsDragButton(MouseEventArgs e)
+ {
+ return
+ ( Settings.MouseDragButton == 0 && (e.Button == MouseButtons.Middle || (e.Button == MouseButtons.Right && Control.ModifierKeys == Keys.Shift)))
+ ||
+ ( Settings.MouseDragButton == 1 && (e.Button == MouseButtons.Right));
+ }
+
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ var clientPos = new PointF(e.X, e.Y);
+ var canvasPos = ClientToCanvas(clientPos);
+ m_lastMouseDownPosition = e.Location;
+
+ if (DragMode != DragModes.None)
+ return;
+
+ if (IsDragButton(e))
+ {
+ BeginDragPan(clientPos, canvasPos);
+ }
+ else if (e.Button == MouseButtons.Left)
+ {
+ if (CanSelectElements)
+ {
+ BeginDragMove(clientPos, canvasPos);
+ }
+ if (DragMode == DragModes.None)
+ {
+ if (HoverPort != null && CanDrawLine)
+ {
+ BeginDragDrawLine();
+ }
+ }
+ }
+
+ base.OnMouseDown(e);
+ }
+
+ protected override void OnMouseUp(MouseEventArgs e)
+ {
+ EndDrag();
+ base.OnMouseUp(e);
+ }
+
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ // ignore spurious mouse move events
+ if (m_lastKnownMousePosition == e.Location)
+ {
+ return;
+
+ }
+ m_lastKnownMousePosition = e.Location;
+
+ UpdateDragHover(e.Location);
+ base.OnMouseMove(e);
+ }
+
+ private void UpdateDragHover(Point mousePosition)
+ {
+ m_lastKnownMousePosition = mousePosition;
+
+ var clientPos = new PointF(mousePosition.X, mousePosition.Y);
+ var canvasPos = ClientToCanvas(clientPos);
+
+ switch (DragMode)
+ {
+ case DragModes.Pan:
+ DoDragPan(clientPos, canvasPos);
+ break;
+ case DragModes.MoveElement:
+ DoDragMoveElement(clientPos, canvasPos);
+ break;
+ case DragModes.MoveResizeHandle:
+ DoDragMoveResizeHandle(clientPos, canvasPos);
+ break;
+ case DragModes.MovePort:
+ HoverElement = HitTestElement(canvasPos, true);
+ HoverPort = HitTestPort(canvasPos);
+ DoDragMovePort(clientPos, canvasPos);
+ break;
+ case DragModes.None:
+ HoverHandle = HitTestHandle(canvasPos); // set first; it will RecreatePorts() if the value changes
+ HoverPort = HitTestPort(canvasPos);
+ HoverElement = HitTestElement(canvasPos, false);
+ break;
+ case DragModes.DrawLine:
+ if (new Vector(m_lastMouseDownPosition).Distance(new Vector(mousePosition)) > Settings.DragDistanceToInitiateNewConnection)
+ {
+ var startPos = new PointF(m_lastMouseDownPosition.X, m_lastMouseDownPosition.Y);
+ BeginDrawConnection(startPos, ClientToCanvas(startPos));
+ }
+ break;
+ case DragModes.Marquee:
+ if (m_dragMarqueeLastPosition != canvasPos)
+ {
+ m_dragMarqueeLastPosition = canvasPos;
+ Invalidate();
+ }
+ break;
+ }
+ }
+
+ protected override void OnMouseDoubleClick(MouseEventArgs e)
+ {
+ if (e.Button == MouseButtons.Left)
+ {
+ if (CanSelectElements && HasSingleSelectedElement && SelectedElement.HasDialog)
+ {
+ SelectedElement.ShowDialog();
+ }
+ }
+ base.OnMouseDoubleClick(e);
+ }
+
+ void OnPreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
+ {
+ if (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down || e.KeyCode == Keys.Left || e.KeyCode == Keys.Right)
+ {
+ e.IsInputKey = true;
+ }
+ }
+
+ protected override void OnKeyDown(KeyEventArgs e)
+ {
+ if (e.KeyCode == Keys.Enter)
+ {
+ if (SelectedElement == null)
+ {
+ // select the room closest to the center of the viewport
+ var viewportCenter = Viewport.Center;
+ Room closestRoom = null;
+ var closestDistance = float.MaxValue;
+ foreach (var element in Project.Current.Elements)
+ {
+ if (element is Room)
+ {
+ var room = (Room)element;
+ var roomCenter = room.InnerBounds.Center;
+ var distance = roomCenter.Distance(viewportCenter);
+ if (distance < closestDistance)
+ {
+ closestRoom = room;
+ closestDistance = distance;
+ }
+ }
+ }
+ SelectedElement = closestRoom;
+ EnsureVisible(SelectedElement);
+ }
+ else if (HasSingleSelectedElement && SelectedElement.HasDialog)
+ {
+ SelectedElement.ShowDialog();
+ }
+ }
+ else if (e.KeyCode == Keys.Escape && SelectedElement != null)
+ {
+ // clear selection
+ SelectedElement = null;
+ }
+ else if (e.KeyCode == Keys.A && e.Control)
+ {
+ // select all
+ SelectAll();
+ }
+ else if (e.KeyCode == Keys.Add || e.KeyCode == Keys.Oemplus)
+ {
+ ZoomIn();
+ }
+ else if (e.KeyCode == Keys.Subtract || e.KeyCode == Keys.OemMinus)
+ {
+ ZoomOut();
+ }
+ else if (e.KeyCode == Keys.Home)
+ {
+ if (e.Control)
+ {
+ ZoomToFit();
+ }
+ else
+ {
+ ResetZoomOrigin();
+ }
+ }
+ else if (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down)
+ {
+ Origin += new Vector(0, (e.KeyCode == Keys.Down ? 1 : -1) * Viewport.Height / (e.Shift ? 5 : 10));
+ }
+ else if (e.KeyCode == Keys.Left || e.KeyCode == Keys.Right)
+ {
+ Origin += new Vector((e.KeyCode == Keys.Right ? 1 : -1) * Viewport.Width / (e.Shift ? 5 : 10), 0);
+ }
+ else if (e.KeyCode == Keys.R)
+ {
+ AddRoom(true);
+ }
+ else if (e.KeyCode == Keys.T)
+ {
+ if (NewConnectionStyle == ConnectionStyle.Solid)
+ {
+ NewConnectionStyle = ConnectionStyle.Dashed;
+ }
+ else
+ {
+ NewConnectionStyle = ConnectionStyle.Solid;
+ }
+ ApplyConnectionStyle(NewConnectionStyle);
+ }
+ else if (e.KeyCode == Keys.A)
+ {
+ if (NewConnectionFlow == ConnectionFlow.TwoWay)
+ {
+ NewConnectionFlow = ConnectionFlow.OneWay;
+ }
+ else
+ {
+ NewConnectionFlow = ConnectionFlow.TwoWay;
+ }
+ ApplyConnectionFlow(NewConnectionFlow);
+ }
+ else if (e.KeyCode == Keys.P)
+ {
+ ApplyNewPlainConnectionSettings();
+ }
+ else if (e.KeyCode == Keys.U)
+ {
+ NewConnectionLabel = ConnectionLabel.Up;
+ ApplyConnectionLabel(NewConnectionLabel);
+ }
+ else if (e.KeyCode == Keys.D)
+ {
+ NewConnectionLabel = ConnectionLabel.Down;
+ ApplyConnectionLabel(NewConnectionLabel);
+ }
+ else if (e.KeyCode == Keys.I)
+ {
+ NewConnectionLabel = ConnectionLabel.In;
+ ApplyConnectionLabel(NewConnectionLabel);
+ }
+ else if (e.KeyCode == Keys.O)
+ {
+ NewConnectionLabel = ConnectionLabel.Out;
+ ApplyConnectionLabel(NewConnectionLabel);
+ }
+ else if (e.KeyCode == Keys.V)
+ {
+ ReverseLineDirection();
+ }
+ else if (e.KeyCode == Keys.K)
+ {
+ foreach (var element in m_selectedElements)
+ {
+ if (element is Room)
+ {
+ var room = (Room)element;
+ room.IsDark = !room.IsDark;
+ }
+ }
+ }
+ else if (e.KeyCode == Keys.F1 && Control.ModifierKeys == Keys.Control)
+ {
+ Settings.DebugShowFPS = !Settings.DebugShowFPS;
+ Invalidate();
+ }
+ else if (e.KeyCode == Keys.F2 && Control.ModifierKeys == Keys.Control)
+ {
+ Settings.DebugDisableElementRendering = !Settings.DebugDisableElementRendering;
+ Invalidate();
+ }
+ else if (e.KeyCode == Keys.F3 && Control.ModifierKeys == Keys.Control)
+ {
+ Settings.DebugDisableLineRendering = !Settings.DebugDisableLineRendering;
+ Invalidate();
+ }
+ else if (e.KeyCode == Keys.F4 && Control.ModifierKeys == Keys.Control)
+ {
+ Settings.DebugDisableTextRendering = !Settings.DebugDisableTextRendering;
+ Invalidate();
+ }
+ else if (e.KeyCode == Keys.F5 && Control.ModifierKeys == Keys.Control)
+ {
+ Settings.DebugDisableGridPolyline = !Settings.DebugDisableGridPolyline;
+ Invalidate();
+ }
+ else if (e.KeyCode == Keys.F5)
+ {
+ // for diagnostic purposes, cancel single stepping
+ if (IsAutomapping)
+ {
+ m_automap.RunToCompletion();
+ }
+ }
+ else if (e.KeyCode == Keys.F11)
+ {
+ // for diagnostic purposes, allow single stepping
+ m_automap.Step();
+ }
+ else if (e.KeyCode >= Keys.NumPad0 && e.KeyCode <= Keys.NumPad9)
+ {
+ // the numeric keypad keys allow rooms to be quickly selected or added.
+ CompassPoint? compassPoint = null;
+ switch (e.KeyCode)
+ {
+ case Keys.NumPad8:
+ compassPoint = CompassPoint.North;
+ break;
+ case Keys.NumPad9:
+ compassPoint = CompassPoint.NorthEast;
+ break;
+ case Keys.NumPad6:
+ compassPoint = CompassPoint.East;
+ break;
+ case Keys.NumPad3:
+ compassPoint = CompassPoint.SouthEast;
+ break;
+ case Keys.NumPad2:
+ compassPoint = CompassPoint.South;
+ break;
+ case Keys.NumPad1:
+ compassPoint = CompassPoint.SouthWest;
+ break;
+ case Keys.NumPad4:
+ compassPoint = CompassPoint.West;
+ break;
+ case Keys.NumPad7:
+ compassPoint = CompassPoint.NorthWest;
+ break;
+ }
+ if (compassPoint.HasValue)
+ {
+ if (!SelectRoomRelativeToSelectedRoom(compassPoint.Value))
+ {
+ if (Control.ModifierKeys == Settings.KeypadNavigationCreationModifier)
+ {
+ AddOrConnectRoomRelativeToSelectedRoom(compassPoint.Value);
+ }
+ else if (Control.ModifierKeys == Settings.KeypadNavigationUnexploredModifier)
+ {
+ AddUnexploredConnectionToSelectedRoom(compassPoint.Value);
+ }
+ }
+ }
+ }
+
+ base.OnKeyDown(e);
+ }
+
+ ///
+ /// Select the room in the given direction from the selected room;
+ ///
+ /// The direction to consider.
+ /// True if a new room was found and selected; false otherwise.
+ private bool SelectRoomRelativeToSelectedRoom(CompassPoint compassPoint)
+ {
+ if (SelectedElement is Room)
+ {
+ var room = (Room)SelectedElement;
+ var nextRoom = GetRoomInApproximateDirectionFromRoom(room, compassPoint);
+ if (nextRoom != null)
+ {
+ SelectedElement = nextRoom;
+ EnsureVisible(SelectedElement);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ ///
+ /// Find a room adjacent to the selected room in the given direction;
+ /// if found, connect the rooms. If not, create a new room in that direction.
+ ///
+ /// The direction to consider.
+ /// True if a new connection/room was made; false otherwise.
+ private bool AddOrConnectRoomRelativeToSelectedRoom(CompassPoint compassPoint)
+ {
+ if (SelectedElement is Room)
+ {
+ var room = (Room)SelectedElement;
+ var rect = room.InnerBounds;
+ rect.Inflate(Settings.PreferredDistanceBetweenRooms + room.Width / 2, Settings.PreferredDistanceBetweenRooms + room.Height / 2);
+ var centerOfNewRoom = rect.GetCorner(compassPoint);
+
+ var existing = HitTestElement(centerOfNewRoom, false);
+ if (existing is Room)
+ {
+ // just connect the rooms together
+ AddConnection(room, compassPoint, (Room)existing, CompassPointHelper.GetOpposite(compassPoint));
+ SelectedElement = existing;
+ EnsureVisible(SelectedElement);
+ }
+ else
+ {
+ // new room entirely
+ var newRoom = new Room(Project.Current);
+
+ newRoom.Position = new Vector(centerOfNewRoom.X - room.Width / 2, centerOfNewRoom.Y - room.Height / 2); ;
+ newRoom.Size = room.Size;
+
+ Project.Current.Elements.Add(newRoom);
+ AddConnection(room, compassPoint, newRoom, CompassPointHelper.GetOpposite(compassPoint));
+ SelectedElement = newRoom;
+ EnsureVisible(SelectedElement);
+ Refresh();
+ newRoom.ShowDialog();
+ }
+ return true;
+ }
+ return false;
+ }
+
+ ///
+ /// Add an "unexplored" (loopback) connection from
+ ///
+ ///
+ ///
+ private bool AddUnexploredConnectionToSelectedRoom(CompassPoint compassPoint)
+ {
+ if (SelectedElement is Room)
+ {
+ var room = (Room)SelectedElement;
+ AddConnection(room, compassPoint, room, compassPoint);
+ return true;
+ }
+ return false;
+ }
+
+ ///
+ /// Add a new connection between the given rooms.
+ ///
+ /// The first room.
+ /// The direction of the connection in the first room.
+ /// The second room.
+ /// The direction of the connection in the second room.
+ private Connection AddConnection(Room roomOne, CompassPoint compassPointOne, Room roomTwo, CompassPoint compassPointTwo)
+ {
+ var vertexOne = new Vertex(roomOne.PortAt(compassPointOne));
+ var vertexTwo = new Vertex(roomTwo.PortAt(compassPointTwo));
+ var connection = new Connection(Project.Current, vertexOne, vertexTwo);
+ Project.Current.Elements.Add(connection);
+ return connection;
+ }
+
+ ///
+ /// Get a room which can be found in the given direction from the given room.
+ ///
+ /// The initial room.
+ /// The direction to consider.
+ /// The room which can be found in that direction, or null if none.
+ ///
+ /// If no room can be found exactly in that direction, then consider the directions
+ /// either side. For example, after checking east and finding nothing, check
+ /// east-north-east and east-south-east.
+ ///
+ private Room GetRoomInApproximateDirectionFromRoom(Room room, CompassPoint compassPoint)
+ {
+ var nextRoom = GetRoomInExactDirectionFromRoom(room, compassPoint);
+ if (nextRoom == null)
+ {
+ nextRoom = GetRoomInExactDirectionFromRoom(room, CompassPointHelper.RotateAntiClockwise(compassPoint));
+ }
+ if (nextRoom == null)
+ {
+ nextRoom = GetRoomInExactDirectionFromRoom(room, CompassPointHelper.RotateClockwise(compassPoint));
+ }
+ return nextRoom;
+ }
+
+ ///
+ /// Get a room which can be found in the given direction from the given room.
+ ///
+ /// The initial room.
+ /// The direction to consider.
+ /// The room which can be found in that direction, or null if none.
+ private Room GetRoomInExactDirectionFromRoom(Room room, CompassPoint compassPoint)
+ {
+ var connections = room.GetConnections(compassPoint);
+ foreach (var connection in connections)
+ {
+ foreach (var vertex in connection.VertexList)
+ {
+ var port = vertex.Port;
+ if (port != null && port.Owner != room && port.Owner is Room)
+ {
+ return (Room)port.Owner;
+ }
+ }
+ }
+ return null;
+ }
+
+ ///
+ /// Ensure the given element is visible, without changing the zoom factor.
+ ///
+ /// The element to make visible.
+ private void EnsureVisible(Element element)
+ {
+ Rect rect = Rect.Empty;
+ rect = element.UnionBoundsWith(rect, false);
+ if (rect != Rect.Empty)
+ {
+ Origin = rect.Center;
+ }
+ }
+
+ ///
+ /// Ensure the given point is visible.
+ ///
+ /// The canvas position to make visible.
+ private void EnsureVisible(Vector canvasPos)
+ {
+ var topLeft = ClientToCanvas(PointF.Empty);
+ var bottomRight = ClientToCanvas(new PointF(Width, Height));
+ var dx = 0.0f;
+ var dy = 0.0f;
+ if (canvasPos.X < topLeft.X)
+ {
+ dx -= topLeft.X - canvasPos.X;
+ }
+ if (canvasPos.Y < topLeft.Y)
+ {
+ dy -= topLeft.Y - canvasPos.Y;
+ }
+ if (canvasPos.X > bottomRight.X)
+ {
+ dx += canvasPos.X - bottomRight.X;
+ }
+ if (canvasPos.Y > bottomRight.Y)
+ {
+ dy += canvasPos.Y - bottomRight.Y;
+ }
+ if (dx != 0 || dy != 0)
+ {
+ var origin = Origin;
+ Origin = new Vector(origin.X + dx, origin.Y + dy);
+ }
+ }
+
+ private void BeginDragPan(PointF clientPos, Vector canvasPos)
+ {
+ DragMode = DragModes.Pan;
+ m_panPosition = clientPos;
+ Cursor = Cursors.NoMove2D;
+ Capture = true;
+ }
+
+ private void BeginDragMove(PointF clientPos, Vector canvasPos)
+ {
+ if (HoverHandle != null)
+ {
+ DragMode = DragModes.MoveResizeHandle;
+ m_dragResizeHandleLastPosition = canvasPos; // unsnapped
+ Capture = true;
+ }
+ else if (HoverPort != null)
+ {
+ if (HoverPort is MoveablePort)
+ {
+ m_dragMovePort = (MoveablePort)HoverPort;
+ m_dragOffsetCanvas = Settings.Snap(canvasPos - HoverPort.Position);
+ DragMode = DragModes.MovePort;
+ Capture = true;
+ }
+ }
+ else
+ {
+ var hitElement = HitTestElement(canvasPos, false);
+
+ bool alreadySelected = m_selectedElements.Contains(hitElement);
+ if (!alreadySelected && (Control.ModifierKeys & (Keys.Control|Keys.Shift)) == Keys.None)
+ {
+ // if clicking on empty space, or an unselected element, without holding Control/Shift, clear the current selection.
+ m_selectedElements.Clear();
+ }
+ else if (hitElement != null)
+ {
+ // if clicking on a selected element, remove it from the selection;
+ // we do this since element's size handles etc. belong to the SelectedElement
+ // which is the last one in the list, so we want to add this one back to the end
+ // of the list as the user seems more interested in it and may want handles.
+ m_selectedElements.Remove(hitElement);
+ }
+ if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
+ {
+ if (!alreadySelected && hitElement != null)
+ {
+ // if we're holding shift and we clicked an element which wasn't already selected, select it.
+ m_selectedElements.Add(hitElement);
+ }
+ }
+ else if (hitElement != null)
+ {
+ // if we're not holding shift, ensure the current element is selected.
+ // we're safe to re-add it since it will definitely have been removed already
+ // if it was selected, by the above logic.
+ m_selectedElements.Add(hitElement);
+ }
+
+ // now we've finished messing with the set of selected elements,
+ // update handles, ports, and take defaults for new elements from the most recently selected element.
+ UpdateSelection();
+
+ if (hitElement != null && m_selectedElements.Contains(hitElement))
+ {
+ // if we ended up with the hit element being selected, initiate a drag move.
+ DragMode = DragModes.MoveElement;
+ canvasPos = Settings.Snap(canvasPos);
+ m_dragOffsetCanvas = canvasPos;
+ Capture = true;
+ }
+ else if (hitElement == null)
+ {
+ // if we didn't hit anything at all, begin a new marquee selection.
+ DragMode = DragModes.Marquee;
+ m_dragOffsetCanvas = canvasPos;
+ m_dragMarqueeLastPosition = canvasPos;
+ Capture = true;
+ }
+ }
+ Invalidate();
+ }
+
+ private void BeginDragDrawLine()
+ {
+ DragMode = DragModes.DrawLine;
+ Capture = true;
+ }
+
+ private void BeginDrawConnection(PointF clientPos, Vector canvasPos)
+ {
+ Connection connection;
+ HoverPort = HitTestPort(canvasPos);
+ if (HoverPort != null && !(HoverPort is MoveablePort))
+ {
+ // Only from non-moveable ports, until we fix docking.
+ // See also DoDragMovePort().
+ connection = new Connection(Project.Current, new Vertex(HoverPort), new Vertex(HoverPort));
+ }
+ else
+ {
+ var pos = Settings.Snap(canvasPos);
+ connection = new Connection(Project.Current, new Vertex(pos), new Vertex(pos));
+ }
+ connection.Style = NewConnectionStyle;
+ connection.Flow = NewConnectionFlow;
+ connection.SetText(NewConnectionLabel);
+ Project.Current.Elements.Add(connection);
+ SelectedElement = connection;
+ m_dragMovePort = (MoveablePort)connection.Ports[1];
+ m_dragOffsetCanvas = Settings.Snap(canvasPos - connection.VertexList[0].Position);
+ HoverPort = null;
+ DragMode = DragModes.MovePort;
+ Capture = true;
+ }
+
+ public void AddRoom(bool atCursor)
+ {
+ var room = new Room(Project.Current);
+ Vector pos;
+ if (atCursor && ClientRectangle.Contains(PointToClient(Control.MousePosition)))
+ {
+ // center on the mouse cursor
+ pos = ClientToCanvas(PointToClient(Control.MousePosition));
+ }
+ else
+ {
+ // center on the origin
+ pos = new Vector(Origin.X - room.Size.X / 2, Origin.Y - room.Size.Y / 2);
+ }
+
+ // rooms' origins are in the top left corner
+ pos -= room.Size / 2;
+
+ // snap to the grid, if required
+ pos = Settings.Snap(pos);
+
+ bool clash = true;
+ while (clash)
+ {
+ clash = false;
+ foreach (var element in Project.Current.Elements)
+ {
+ if (element is IMoveable && ((IMoveable)element).Position == pos)
+ {
+ pos.X += Math.Max(2, Settings.GridSize);
+ pos.Y += Math.Max(2, Settings.GridSize);
+ clash = true;
+ }
+ }
+ }
+ room.Position = pos;
+ Project.Current.Elements.Add(room);
+ SelectedElement = room;
+ }
+
+ private void DoDragPan(PointF clientPos, Vector canvasPos)
+ {
+ var delta = Drawing.Subtract(m_panPosition, clientPos);
+ delta = Drawing.Divide(delta, ZoomFactor);
+ Origin = new Vector(Origin.X + delta.X, Origin.Y + delta.Y);
+ m_panPosition = clientPos;
+ }
+
+ private void DoDragMoveElement(PointF clientPos, Vector canvasPos)
+ {
+ canvasPos = Settings.Snap(canvasPos);
+ foreach (var element in m_selectedElements)
+ {
+ MoveElementBy(element, canvasPos - m_dragOffsetCanvas);
+ }
+ m_dragOffsetCanvas = canvasPos;
+ }
+
+ private void MoveElementBy(Element element, Vector delta)
+ {
+ if (element is IMoveable)
+ {
+ // move any selected moveable elements
+ var moveable = (IMoveable)element;
+ moveable.Position += delta;
+ }
+
+ if (element is Connection)
+ {
+ // move any free floating points on selected connections
+ var connection = (Connection)element;
+ foreach (var vertex in connection.VertexList)
+ {
+ if (vertex.Port == null)
+ {
+ vertex.Position += delta;
+ }
+ }
+ }
+ }
+
+ private void DoDragMoveResizeHandle(PointF clientPos, Vector canvasPos)
+ {
+ // the mouse has moved this much on the canvas since we last successfully resized the element
+ var delta = canvasPos - m_dragResizeHandleLastPosition;
+
+ if (HoverHandle != null)
+ {
+ // work out to whether and where we'd like to move the element's corner/edge
+ var newPosition = HoverHandle.OwnerPosition + delta;
+ if (newPosition != HoverHandle.OwnerPosition)
+ {
+ // we'd like to move the element's corner/edge;
+ // try to do so
+ var oldPosition = HoverHandle.OwnerPosition;
+ HoverHandle.OwnerPosition = Settings.Snap(newPosition);
+
+ // *NOTE 1: *IN THEORY* you'd imagine we could just set the corner/edge position to
+ // a grid-snapped version of the mouse position on the canvas. This would work if
+ // our handles were directly over the corner/edge we're resizing, but they may not
+ // be since we may want to display both resize handles and "draw a new connection"
+ // ports for a corner/edge and so move the resize handles outward so both will fit.
+ // Hence this mucking about with delta values instead.
+ //
+ // *NOTE 2: That said, *IN THEORY* you'd imagine we would just set m_dragResizeHandleLastPosition
+ // to canvasPos here, regardless of whether we actually resized the element.
+ // This is true but for a couple of subtle issues:
+ //
+ // i) Elements have a minimum size (even if it's a width and height of 0). If we're
+ // dragging the buttom right corner of an element up/left, we want the element to stop
+ // at said minimum size, and this is handled by the ResizeHandle. However, our mouse
+ // cursor may keep moving up/left in the meantime; when it eventually moves down/right
+ // again, we want the element NOT to resize until the mouse cursor is actually over a
+ // position such that if we moved the element's corner/edge that way it would grow in size.
+ // (Try resizing a window in Windows and see what I mean.) We achieve this by not changing
+ // m_dragResizeHandleLastPosition unless we actually effect a change.
+ //
+ // ii) Snap to grid. If we just set the last position to the canvas mouse position, then
+ // when resizing you'll observe that the mouse cursor "desyncs" with the element's
+ // corner edge the larger we make the element. This is because of accumulated error
+ // in m_dragResizeHandleLastPosition due to the snap. An easy way to resolve this is
+ // to apply the delta by which we actually resized the element instead of using
+ // the canvas mouse position.
+ if (HoverHandle.OwnerPosition.X != oldPosition.X)
+ {
+ // we managed to move the element's corner/edge horizontally, on the X axis;
+ // on this axis, apply the effective delta to our the basis for future movement.
+ m_dragResizeHandleLastPosition.X += HoverHandle.OwnerPosition.X - oldPosition.X;
+ }
+ if (HoverHandle.OwnerPosition.Y != oldPosition.Y)
+ {
+ // likewise for the vertical/Y axis
+ m_dragResizeHandleLastPosition.Y += HoverHandle.OwnerPosition.Y - oldPosition.Y;
+ }
+ }
+ }
+ }
+
+ private void DoDragMovePort(PointF clientPos, Vector canvasPos)
+ {
+ if (HoverPort != null && HoverPort != m_dragMovePort)
+ {
+ if (m_dragMovePort.DockedAt != HoverPort && (!(HoverPort is MoveablePort) || ((MoveablePort)HoverPort).DockedAt != m_dragMovePort))
+ {
+
+ // TODO: Docking disabled until a decent mechanism is worked out.
+ // Currently can cause infinite loops which can crash the program;
+ // eg. dock A to B, B to C, C to A.
+ // Also after docking A to B, moving B brings A but moving A doesn't bring B.
+ // Perhaps some form of "weld" to make the vertices actually the same?
+ // And a corresponding "unweld" option?
+ // Or simply detect circular references and refuse to make them,
+ // always move them all together, etc.
+
+ // m_dragMovePort.DockAt(HoverPort);
+
+ // Until docking re-enabled, treat as positional move;
+ // but do dock to rooms etc. as that's safe.
+ // See also BeginDrawConnection().
+ if (!(HoverPort is MoveablePort))
+ {
+ m_dragMovePort.DockAt(HoverPort);
+ }
+ else
+ {
+ canvasPos = Settings.Snap(canvasPos);
+ m_dragMovePort.SetPosition(canvasPos - m_dragOffsetCanvas);
+ }
+ }
+ else
+ {
+ // leave docking alone, and don't snap to grid
+ }
+ }
+ else
+ {
+ canvasPos = Settings.Snap(canvasPos);
+ m_dragMovePort.SetPosition(canvasPos - m_dragOffsetCanvas);
+ }
+ }
+
+ private void EndDrag()
+ {
+ if (DragMode == DragModes.MovePort)
+ {
+ // clear the selection now the line is drawn
+ SelectedElement = null;
+
+ if (m_dragMovePort.Owner is Connection)
+ {
+ // remove dead connections
+ var connection = (Connection)m_dragMovePort.Owner;
+ bool same = true;
+ if (connection.VertexList.Count > 0)
+ {
+ var pos = connection.VertexList[0].Position;
+ foreach (Vertex v in connection.VertexList)
+ {
+ if (v.Port != null && v.Port.Owner is Room)
+ {
+ // keep connections attached to rooms;
+ // if they don't go anywhere, they
+ // go back to the room, which is significant.
+ same = false;
+ }
+
+ var distance = v.Position.Distance(pos);
+ if (distance > Numeric.Small)
+ {
+ // keep connections which visibly go anywhere
+ same = false;
+ }
+ }
+ }
+ if (same)
+ {
+ // remove connections which don't go anywhere useful
+ Project.Current.Elements.Remove(connection);
+ }
+ }
+ }
+ else if (DragMode == DragModes.Marquee)
+ {
+ var marqueeRect = GetMarqueeCanvasBounds();
+ if ((Control.ModifierKeys & (Keys.Shift | Keys.Control)) == Keys.None)
+ {
+ m_selectedElements.Clear();
+ }
+ foreach (var element in HitTest(marqueeRect, false))
+ {
+ if (!m_selectedElements.Contains(element))
+ {
+ m_selectedElements.Add(element);
+ }
+ else if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
+ {
+ if (m_selectedElements.Contains(element))
+ {
+ m_selectedElements.Remove(element);
+ }
+ }
+ }
+ UpdateSelection();
+ }
+ DragMode = DragModes.None;
+ HoverHandle = null;
+ Capture = false;
+ Cursor = null;
+ Invalidate();
+ }
+
+ private List HitTest(Rect rect, bool roomsOnly)
+ {
+ var list = new List();
+ foreach (var element in Project.Current.Elements)
+ {
+ if ((!roomsOnly || element is Room) && element.Intersects(rect))
+ {
+ list.Add(element);
+ }
+ }
+ return list;
+ }
+
+ private Rect GetMarqueeCanvasBounds()
+ {
+ if (DragMode != DragModes.Marquee)
+ {
+ return Rect.Empty;
+ }
+ var topLeft = m_dragOffsetCanvas;
+ var bottomRight = ClientToCanvas(PointToClient(Control.MousePosition));
+ if (bottomRight.X < topLeft.X)
+ {
+ Numeric.Swap(ref bottomRight.X, ref topLeft.X);
+ }
+ if (bottomRight.Y < topLeft.Y)
+ {
+ Numeric.Swap(ref bottomRight.Y, ref topLeft.Y);
+ }
+ return new Rect(topLeft.X, topLeft.Y, bottomRight.X - topLeft.X, bottomRight.Y - topLeft.Y);
+ }
+
+ private float SnapToElementSizeAtCurrentZoomFactor
+ {
+ get { return Settings.SnapToElementSize; }
+ }
+
+ private Element HitTestElement(Vector canvasPos, bool includeMargins)
+ {
+ List closest = new List();
+ float closestDistance = float.MaxValue;
+ foreach (var element in DepthSortElements()) // sort into drawing order
+ {
+ if (DragMode == DragModes.MovePort && m_dragMovePort.Owner == element)
+ {
+ // when moving a port on an element, don't try to dock it to that element itself
+ continue;
+ }
+
+ float distance = element.Distance(canvasPos, includeMargins);
+ if (distance <= SnapToElementSizeAtCurrentZoomFactor)
+ {
+ if (Numeric.ApproxEqual(distance, closestDistance))
+ {
+ closest.Add(element);
+ }
+ else if (distance < closestDistance)
+ {
+ closest.Clear();
+ closest.Add(element);
+ closestDistance = distance;
+ }
+ }
+ }
+
+ if (closest.Count == 0)
+ {
+ return null;
+ }
+ return closest[closest.Count - 1]; // choose the topmost element
+ }
+
+ private ResizeHandle HitTestHandle(Vector canvasPos)
+ {
+ // examine handles, topmost (drawn) to lowermost
+ for (int index = m_handles.Count - 1; index >= 0; --index)
+ {
+ var handle = m_handles[index];
+ if (handle.HitTest(canvasPos))
+ {
+ return handle;
+ }
+ }
+ return null;
+ }
+
+ private Port HitTestPort(Vector canvasPos)
+ {
+ Port closest = null;
+ float closestDistance = float.MaxValue;
+
+ foreach (var port in m_ports)
+ {
+ if (DragMode == DragModes.MovePort && port == m_dragMovePort)
+ {
+ // when dragging a port, don't try to dock it with itself
+ continue;
+ }
+
+ float distance = port.Distance(canvasPos);
+
+ var snapDistance = SnapToElementSizeAtCurrentZoomFactor;
+
+ var bounds = port.Owner.UnionBoundsWith(Rect.Empty, true);
+ if (bounds.Contains(canvasPos))
+ {
+ if (DragMode == DragModes.MovePort)
+ {
+ // if we're dragging a line to set its end point and are over a room, ALWAYS snap to ports:
+ // we do this to avoid the user accidentally making a connection that "nearly" goes to a room.
+ snapDistance = float.MaxValue;
+ }
+ else
+ {
+ // if we'starting a new line and are over a room, NEVER snap to ports:
+ // we do this if hit testing inside so we can more easily select small rooms and not their ports
+ snapDistance = 0;
+ }
+ }
+
+ if (distance <= snapDistance && distance < closestDistance)
+ {
+ closest = port;
+ closestDistance = distance;
+ }
+ }
+ return closest;
+ }
+
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Element SelectedElement
+ {
+ get { return m_selectedElements.Count > 0 ? m_selectedElements[m_selectedElements.Count - 1] : null; }
+ set
+ {
+ var selectedElement = m_selectedElements.Count > 0 ? m_selectedElements[m_selectedElements.Count - 1] : null;
+ if (selectedElement != value)
+ {
+ m_selectedElements.Clear();
+ if (value != null)
+ {
+ m_selectedElements.Add(value);
+ }
+ UpdateSelection();
+ }
+ }
+ }
+
+ public int SelectedElementCount
+ {
+ get { return m_selectedElements.Count; }
+ }
+
+ public bool HasSingleSelectedElement
+ {
+ get { return SelectedElementCount == 1; }
+ }
+
+ public bool HasSelectedElement() where T : Element
+ {
+ foreach (var element in m_selectedElements)
+ {
+ if (element is T)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public IEnumerable SelectedElements
+ {
+ get { return m_selectedElements; }
+ }
+
+ void UpdateSelection()
+ {
+ RecreateHandles();
+ RecreatePorts();
+ // only if we have a single element selected;
+ // otherwise selecting multiple items will cause one to override the others' settings!
+ var selectedElement = SelectedElement;
+ if (selectedElement is Connection)
+ {
+ SetConnectionDefaultsFrom((Connection)selectedElement);
+ }
+ else if (selectedElement is Room)
+ {
+ SetRoomDefaultsFrom((Room)selectedElement);
+ }
+ Invalidate();
+ }
+
+ public void SelectAll()
+ {
+ m_selectedElements.Clear();
+ m_selectedElements.AddRange(Project.Current.Elements);
+ UpdateSelection();
+ }
+
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ private ResizeHandle HoverHandle
+ {
+ get { return m_hoverHandle; }
+ set
+ {
+ if (m_hoverHandle != value)
+ {
+ m_hoverHandle = value;
+ Invalidate();
+ }
+ }
+ }
+
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ private Port HoverPort
+ {
+ get { return m_hoverPort; }
+ set
+ {
+ if (m_hoverPort != value)
+ {
+ m_hoverPort = value;
+ Invalidate();
+ }
+ }
+ }
+
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Element HoverElement
+ {
+ get
+ {
+ return m_hoverElement;
+ }
+ set
+ {
+ if (m_hoverElement != value)
+ {
+ m_hoverElement = value;
+ RecreatePorts();
+ }
+ }
+ }
+
+ private void RecreateHandles()
+ {
+ HoverHandle = null;
+ m_handles.Clear();
+ var element = SelectedElement;
+ if (CanSelectElements && element is ISizeable && HasSingleSelectedElement)
+ {
+ var sizeable = (ISizeable)element;
+ m_handles.Add(new ResizeHandle(CompassPoint.North, sizeable));
+ m_handles.Add(new ResizeHandle(CompassPoint.South, sizeable));
+ m_handles.Add(new ResizeHandle(CompassPoint.East, sizeable));
+ m_handles.Add(new ResizeHandle(CompassPoint.West, sizeable));
+ m_handles.Add(new ResizeHandle(CompassPoint.NorthWest, sizeable));
+ m_handles.Add(new ResizeHandle(CompassPoint.NorthEast, sizeable));
+ m_handles.Add(new ResizeHandle(CompassPoint.SouthWest, sizeable));
+ m_handles.Add(new ResizeHandle(CompassPoint.SouthEast, sizeable));
+ }
+
+ Invalidate();
+ }
+
+ private void RecreatePorts()
+ {
+ HoverPort = null;
+ m_ports.Clear();
+
+ // decide if we want ports on the element under the mouse cursor; if so, add them
+ if (HoverElement is Room && !m_selectedElements.Contains(HoverElement))
+ {
+ // we're hovering over a non-selected room;
+ // (we don't show ports on selected rooms since they get handles already and it's too confusing;
+ // we don't show ports on lines we're hovering over, since we don't allow line-line connections
+ // right now as the algorithm's borked somewhere and can end up with nastiness)
+ if (DragMode == DragModes.MovePort || (CanDrawLine && SelectedElement == null))
+ {
+ // when we're either:
+ // i) currently dragging a new or existing line's end point, OR
+ // ii) can draw a new line, and haven't got anything selelected
+ // then we're safe to show ports on the room we're overing over
+ // from which new connections can be drawn.
+ // We're trying to avoid visual clashes between (stacking of), and
+ // associated selection problems with, a selected connection and the
+ // ports of the room joined to one end of the connection.
+ // Rather than special casing this which might confuse the user as to
+ // when they can draw lines and when they can't we make the general rule
+ // that if you've got something selected you can't draw a line.
+ m_ports.AddRange(HoverElement.Ports);
+ }
+ }
+
+ // decide if we want movable ports on the selected element; if so, add them
+ // (currently movable ports only apply to connections, and if we want to be able
+ // to move a connection we must show them.)
+ var needMovablePortsOnSelectedElement = CanSelectElements;
+ if (needMovablePortsOnSelectedElement && HasSingleSelectedElement)
+ {
+ foreach (var port in SelectedElement.Ports)
+ {
+ if (port is MoveablePort)
+ {
+ m_ports.Add(port);
+ }
+ }
+ }
+
+ Invalidate();
+ }
+
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ private DragModes DragMode
+ {
+ get { return m_dragMode; }
+ set
+ {
+ m_dragMode = value;
+ RecreatePorts();
+ }
+ }
+
+ public bool CanSelectElements
+ {
+ get { return true; }
+ }
+
+ public bool CanDrawLine
+ {
+ get { return true; }
+ }
+
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public ConnectionStyle NewConnectionStyle
+ {
+ get { return m_newConnectionStyle; }
+ set
+ {
+ if (m_newConnectionStyle != value)
+ {
+ m_newConnectionStyle = value;
+ RaiseNewConnectionStyleChanged();
+ }
+ }
+ }
+
+ public void ApplyConnectionStyle(ConnectionStyle connectionStyle)
+ {
+ foreach (var element in m_selectedElements)
+ {
+ if (element is Connection)
+ {
+ var connection = (Connection)element;
+ connection.Style = connectionStyle;
+ }
+ }
+ Invalidate();
+ }
+
+ public event EventHandler NewConnectionStyleChanged;
+
+ private void RaiseNewConnectionStyleChanged()
+ {
+ var changed = NewConnectionStyleChanged;
+ if (changed != null)
+ {
+ changed(this, EventArgs.Empty);
+ }
+ }
+
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public ConnectionFlow NewConnectionFlow
+ {
+ get { return m_newConnectionFlow; }
+ set
+ {
+ if (m_newConnectionFlow != value)
+ {
+ m_newConnectionFlow = value;
+ RaiseNewConnectionFlowChanged();
+ }
+ }
+ }
+
+ public void ApplyConnectionFlow(ConnectionFlow connectionFlow)
+ {
+ foreach (var element in m_selectedElements)
+ {
+ if (element is Connection)
+ {
+ var connection = (Connection)element;
+ connection.Flow = connectionFlow;
+ }
+ }
+ Invalidate();
+ }
+
+ public event EventHandler NewConnectionFlowChanged;
+
+ private void RaiseNewConnectionFlowChanged()
+ {
+ var changed = NewConnectionFlowChanged;
+ if (changed != null)
+ {
+ changed(this, EventArgs.Empty);
+ }
+ }
+
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public ConnectionLabel NewConnectionLabel
+ {
+ get { return m_newConnectionLabel; }
+ set
+ {
+ if (m_newConnectionLabel != value)
+ {
+ m_newConnectionLabel = value;
+ RaiseNewConnectionLabelChanged();
+ }
+ }
+ }
+
+ public void ApplyConnectionLabel(ConnectionLabel connectionLabel)
+ {
+ foreach (var element in m_selectedElements)
+ {
+ if (element is Connection)
+ {
+ var connection = (Connection)element;
+ connection.SetText(connectionLabel);
+ }
+ }
+ Invalidate();
+ }
+
+ public event EventHandler NewConnectionLabelChanged;
+
+ private void RaiseNewConnectionLabelChanged()
+ {
+ var changed = NewConnectionLabelChanged;
+ if (changed != null)
+ {
+ changed(this, EventArgs.Empty);
+ }
+ }
+
+ public override Cursor Cursor
+ {
+ get
+ {
+ if (CanDrawLine && ((HoverPort != null && !(HoverPort is MoveablePort)) || DragMode == DragModes.MovePort))
+ {
+ return Drawing.DrawLineCursor;
+ }
+
+ if (HoverPort != null && HoverPort is MoveablePort)
+ {
+ return Drawing.MoveLineCursor;
+ }
+
+ if (HoverHandle != null)
+ {
+ var cursor = HoverHandle.Cursor;
+ if (cursor != null)
+ {
+ return cursor;
+ }
+ }
+
+ if (HoverElement != null && HoverElement is IMoveable && m_selectedElements.Contains(HoverElement))
+ {
+ return Cursors.SizeAll;
+ }
+ return base.Cursor;
+ }
+ set
+ {
+ base.Cursor = value;
+ }
+ }
+
+ public void ResetZoomOrigin()
+ {
+ Origin = ComputeCanvasBounds(false).Center;
+ ZoomFactor = 1.0f;
+ }
+
+ public void ZoomIn()
+ {
+ if (ZoomFactor < 100.0f)
+ {
+ ZoomFactor *= 1.25f;
+ }
+ }
+
+ public void ZoomOut()
+ {
+ if (ZoomFactor > 1 / 100.0f)
+ {
+ ZoomFactor /= 1.25f;
+ }
+ }
+
+ public void ZoomToFit()
+ {
+ ResetZoomOrigin();
+ var canvasBounds = ComputeCanvasBounds(false);
+ while (!Viewport.Contains(canvasBounds))
+ {
+ ZoomOut();
+ }
+ }
+
+ private void SetRoomDefaultsFrom(Room room)
+ {
+ m_newRoomSize = room.Size;
+ m_newRoomIsDark = room.IsDark;
+ m_newRoomObjectsPosition = room.ObjectsPosition;
+ }
+
+ private void SetConnectionDefaultsFrom(Connection connection)
+ {
+ NewConnectionFlow = connection.Flow;
+ NewConnectionStyle = connection.Style;
+ }
+
+ public void ReverseLineDirection()
+ {
+ foreach (var element in m_selectedElements)
+ {
+ if (element is Connection)
+ {
+ var connection = (Connection)element;
+ connection.Reverse();
+ }
+ }
+ }
+
+ public void DeleteSelection()
+ {
+ var doomedElements = new List(m_selectedElements);
+ foreach (var element in doomedElements)
+ {
+ Project.Current.Elements.Remove(element);
+ }
+ m_selectedElements.Clear();
+ UpdateSelection();
+ }
+
+ public void ApplyNewPlainConnectionSettings()
+ {
+ // apply sequentially as each change will affect our defaults,
+ // so setting the style will cause us to take the existing flow and label, etc.
+ NewConnectionStyle = ConnectionStyle.Solid;
+ ApplyConnectionStyle(NewConnectionStyle);
+
+ NewConnectionFlow = ConnectionFlow.TwoWay;
+ ApplyConnectionFlow(NewConnectionFlow);
+
+ NewConnectionLabel = ConnectionLabel.None;
+ ApplyConnectionLabel(NewConnectionLabel);
+ }
+
+ public void UpdateScrollBars()
+ {
+ m_updatingScrollBars = true;
+
+ var topLeft = PointF.Empty;
+ var displaySize = new PointF(Math.Max(0, Width - m_vScrollBar.Width), Math.Max(0,Height - m_hScrollBar.Height));
+
+ Rect clientBounds;
+ if (Project.Current.Elements.Count > 0)
+ {
+ Rect canvasBounds = Rect.Empty;
+ foreach (var element in Project.Current.Elements)
+ {
+ canvasBounds = element.UnionBoundsWith(canvasBounds, true);
+ }
+
+ var tl = CanvasToClient(canvasBounds.Position);
+ var br = CanvasToClient(canvasBounds.GetCorner(CompassPoint.SouthEast));
+ clientBounds = new Rect(tl.X, tl.Y, br.X - tl.X, br.Y - tl.Y);
+ }
+ else
+ {
+ // if there's nothing on the canvas, don't include the origin (0,0) as a "thing" to scroll to
+ clientBounds = new Rect(topLeft.X, topLeft.Y, displaySize.X, displaySize.Y);
+ }
+
+ if (!Settings.InfiniteScrollBounds && topLeft.Y <= clientBounds.Top && topLeft.Y + displaySize.Y >= clientBounds.Bottom)
+ {
+ m_vScrollBar.Enabled = false;
+ }
+ else
+ {
+ m_vScrollBar.Enabled = true;
+ m_vScrollBar.Minimum = (int)Math.Min(topLeft.Y, clientBounds.Top);
+ m_vScrollBar.Maximum = (int)Math.Max(topLeft.Y + displaySize.Y, clientBounds.Bottom) - 1; // -1 since Maximum is actually maximum value + 1; see MSDN.
+ m_vScrollBar.Value = (int)Math.Max(m_vScrollBar.Minimum, Math.Min(m_vScrollBar.Maximum, topLeft.Y));
+ m_vScrollBar.LargeChange = (int)displaySize.Y;
+ m_vScrollBar.SmallChange = (int)(displaySize.Y / 10);
+ }
+
+ if (!Settings.InfiniteScrollBounds && topLeft.X <= clientBounds.Left && topLeft.X + displaySize.X >= clientBounds.Right)
+ {
+ m_hScrollBar.Enabled = false;
+ }
+ else
+ {
+ m_hScrollBar.Enabled = true;
+ m_hScrollBar.Minimum = (int)Math.Min(topLeft.X, clientBounds.Left);
+ m_hScrollBar.Maximum = (int)Math.Max(topLeft.X + displaySize.X, clientBounds.Right) - 1; // -1 since Maximum is actually maximum value + 1; see MSDN.
+ m_hScrollBar.Value = (int)Math.Max(m_hScrollBar.Minimum, Math.Min(m_hScrollBar.Maximum, topLeft.X));
+ m_hScrollBar.LargeChange = (int)displaySize.X;
+ m_hScrollBar.SmallChange = (int)(displaySize.X / 10);
+ }
+
+ m_updatingScrollBars = false;
+ }
+
+ private void ScrollBar_Scroll(object sender, ScrollEventArgs e)
+ {
+ if (m_updatingScrollBars)
+ {
+ return;
+ }
+
+ // the scroll bar will Invalidate() and Update() us; avoid exceptions
+ m_doNotUpdateScrollBarsNextPaint = true;
+
+ var clientDelta = e.NewValue - e.OldValue;
+ if (Settings.InfiniteScrollBounds && e.Type == ScrollEventType.SmallIncrement || e.Type == ScrollEventType.SmallDecrement)
+ {
+ // since our canvas is infinite, allow the user to use the
+ // scroll bar arrows to keep scrolling past the bounds.
+ if (Math.Abs(clientDelta) != m_vScrollBar.SmallChange)
+ {
+ clientDelta = m_vScrollBar.SmallChange * (e.Type == ScrollEventType.SmallIncrement ? 1 : -1);
+ }
+ }
+ if (clientDelta != 0)
+ {
+ if (sender == m_vScrollBar)
+ {
+ Origin += new Vector(ClientToCanvas(new SizeF(0, clientDelta)));
+ }
+ else
+ {
+ Origin += new Vector(ClientToCanvas(new SizeF(clientDelta, 0)));
+ }
+ }
+ }
+
+ public bool MinimapVisible
+ {
+ get { return m_minimap.Visible; }
+ set
+ {
+ m_minimap.Visible = value;
+ if (!m_minimap.Visible)
+ {
+ m_vScrollBar.Top = 0;
+ m_vScrollBar.Height = Height - m_cornerPanel.Height;
+ }
+ else
+ {
+ m_vScrollBar.Top = m_minimap.Bottom;
+ m_vScrollBar.Height = Height - m_cornerPanel.Height - m_minimap.Height;
+ }
+ }
+ }
+
+ private enum DragModes
+ {
+ None,
+ Pan,
+ MoveElement,
+ MoveResizeHandle,
+ MovePort,
+ Marquee,
+ DrawLine,
+ }
+
+ private void Reset()
+ {
+ ZoomFactor = 1;
+ Origin = Vector.Zero;
+ SelectedElement = null;
+ HoverElement = null;
+ HoverHandle = null;
+ HoverPort = null;
+ DragMode = DragModes.None;
+ NewConnectionStyle = ConnectionStyle.Solid;
+ NewConnectionFlow = ConnectionFlow.TwoWay;
+ m_newRoomSize = new Vector(Settings.GridSize * 3, Settings.GridSize * 2);
+ m_newRoomIsDark = false;
+ m_newRoomObjectsPosition = CompassPoint.South;
+ RequestRecomputeSmartSegments();
+ StopAutomapping();
+ }
+
+ private float m_zoomFactor;
+ private Vector m_origin;
+
+ private List m_selectedElements = new List();
+ private Element m_hoverElement;
+ private ResizeHandle m_hoverHandle;
+ private Port m_hoverPort;
+
+ private Point m_lastKnownMousePosition;
+ private Point m_lastMouseDownPosition;
+ private DragModes m_dragMode;
+ private PointF m_panPosition;
+ private Vector m_dragOffsetCanvas;
+ private MoveablePort m_dragMovePort;
+ private Vector m_dragMarqueeLastPosition;
+ private Vector m_dragResizeHandleLastPosition;
+
+ private List m_handles = new List();
+ private List m_ports = new List();
+
+ private ConnectionStyle m_newConnectionStyle;
+ private ConnectionFlow m_newConnectionFlow;
+ private ConnectionLabel m_newConnectionLabel;
+ private Vector m_newRoomSize;
+ private bool m_newRoomIsDark;
+ private CompassPoint m_newRoomObjectsPosition;
+ private System.Threading.Timer m_recomputeTimer;
+ private bool m_updatingScrollBars;
+ private bool m_doNotUpdateScrollBarsNextPaint;
+
+ private static readonly int RecomputeNMillisecondsAfterChange = 500;
+ private static bool m_smartLineSegmentsUpToDate = false;
+ }
+}
diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs
index 4cafd11..8a538fd 100644
--- a/MainForm.Designer.cs
+++ b/MainForm.Designer.cs
@@ -1,857 +1,867 @@
-/*
- Copyright (c) 2010 by Genstein
-
- This file is (or was originally) part of Trizbort, the Interactive Fiction Mapper.
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
-*/
-
-namespace Trizbort
-{
- partial class MainForm
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
- this.m_menuStrip = new System.Windows.Forms.MenuStrip();
- this.m_fileMenu = new System.Windows.Forms.ToolStripMenuItem();
- this.m_fileNewMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
- this.m_fileOpenMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.toolStripSeparator9 = new System.Windows.Forms.ToolStripSeparator();
- this.m_fileSaveMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.m_fileSaveAsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.toolStripSeparator10 = new System.Windows.Forms.ToolStripSeparator();
- this.m_fileExportMenu = new System.Windows.Forms.ToolStripMenuItem();
- this.m_fileExportPDFMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.m_fileExportImageMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.toolStripMenuItem9 = new System.Windows.Forms.ToolStripSeparator();
- this.m_fileExportInform7MenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.tADSToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.toolStripSeparator12 = new System.Windows.Forms.ToolStripSeparator();
- this.m_fileRecentMapsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.toolStripMenuItem7 = new System.Windows.Forms.ToolStripSeparator();
- this.m_fileExitMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.m_editMenu = new System.Windows.Forms.ToolStripMenuItem();
- this.m_editAddRoomMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator();
- this.m_editRenameMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.m_editIsDarkMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
- this.m_lineStylesMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.m_plainLinesMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripSeparator();
- this.m_toggleDottedLinesMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.m_toggleDirectionalLinesMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
- this.m_upLinesMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.m_downLinesMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator();
- this.m_inLinesMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.m_outLinesMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.m_reverseLineMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.toolStripSeparator8 = new System.Windows.Forms.ToolStripSeparator();
- this.m_editSelectAllMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.m_editSelectNoneMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.toolStripMenuItem8 = new System.Windows.Forms.ToolStripSeparator();
- this.m_editDeleteMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
- this.m_editPropertiesMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.m_viewMenu = new System.Windows.Forms.ToolStripMenuItem();
- this.m_viewZoomMenu = new System.Windows.Forms.ToolStripMenuItem();
- this.m_viewZoomInMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.m_viewZoomOutMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator();
- this.m_viewZoomFiftyPercentMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.m_viewZoomOneHundredPercentMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.m_viewZoomTwoHundredPercentMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.m_viewEntireMapMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.m_viewResetMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.toolStripMenuItem6 = new System.Windows.Forms.ToolStripSeparator();
- this.m_viewMinimapMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.automappingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.m_automapStartMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.m_automapStopMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.m_projectMenu = new System.Windows.Forms.ToolStripMenuItem();
- this.m_projectSettingsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.toolStripSeparator11 = new System.Windows.Forms.ToolStripSeparator();
- this.m_projectResetToDefaultSettingsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.m_helpMenu = new System.Windows.Forms.ToolStripMenuItem();
- this.m_onlineHelpMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.m_checkForUpdatesMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripSeparator();
- this.m_helpAboutMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.m_toolStrip = new System.Windows.Forms.ToolStrip();
- this.m_toggleDottedLinesButton = new System.Windows.Forms.ToolStripButton();
- this.m_toggleDirectionalLinesButton = new System.Windows.Forms.ToolStripButton();
- this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
- this.m_automapBar = new Trizbort.AutomapBar();
- this.m_canvas = new Trizbort.Canvas();
- this.inform6ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.toolStripMenuItem10 = new System.Windows.Forms.ToolStripSeparator();
- this.m_menuStrip.SuspendLayout();
- this.m_toolStrip.SuspendLayout();
- this.SuspendLayout();
- //
- // m_menuStrip
- //
- this.m_menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.m_fileMenu,
- this.m_editMenu,
- this.m_viewMenu,
- this.automappingToolStripMenuItem,
- this.m_projectMenu,
- this.m_helpMenu});
- this.m_menuStrip.Location = new System.Drawing.Point(0, 0);
- this.m_menuStrip.Name = "m_menuStrip";
- this.m_menuStrip.Size = new System.Drawing.Size(624, 24);
- this.m_menuStrip.TabIndex = 1;
- //
- // m_fileMenu
- //
- this.m_fileMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.m_fileNewMenuItem,
- this.toolStripSeparator1,
- this.m_fileOpenMenuItem,
- this.toolStripSeparator9,
- this.m_fileSaveMenuItem,
- this.m_fileSaveAsMenuItem,
- this.toolStripSeparator10,
- this.m_fileExportMenu,
- this.toolStripSeparator12,
- this.m_fileRecentMapsMenuItem,
- this.toolStripMenuItem7,
- this.m_fileExitMenuItem});
- this.m_fileMenu.Name = "m_fileMenu";
- this.m_fileMenu.Size = new System.Drawing.Size(37, 20);
- this.m_fileMenu.Text = "&File";
- this.m_fileMenu.DropDownOpening += new System.EventHandler(this.FileMenu_DropDownOpening);
- //
- // m_fileNewMenuItem
- //
- this.m_fileNewMenuItem.Name = "m_fileNewMenuItem";
- this.m_fileNewMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N)));
- this.m_fileNewMenuItem.Size = new System.Drawing.Size(182, 22);
- this.m_fileNewMenuItem.Text = "&New Map";
- this.m_fileNewMenuItem.Click += new System.EventHandler(this.FileNewMenuItem_Click);
- //
- // toolStripSeparator1
- //
- this.toolStripSeparator1.Name = "toolStripSeparator1";
- this.toolStripSeparator1.Size = new System.Drawing.Size(179, 6);
- //
- // m_fileOpenMenuItem
- //
- this.m_fileOpenMenuItem.Name = "m_fileOpenMenuItem";
- this.m_fileOpenMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
- this.m_fileOpenMenuItem.Size = new System.Drawing.Size(182, 22);
- this.m_fileOpenMenuItem.Text = "&Open Map...";
- this.m_fileOpenMenuItem.Click += new System.EventHandler(this.FileOpenMenuItem_Click);
- //
- // toolStripSeparator9
- //
- this.toolStripSeparator9.Name = "toolStripSeparator9";
- this.toolStripSeparator9.Size = new System.Drawing.Size(179, 6);
- //
- // m_fileSaveMenuItem
- //
- this.m_fileSaveMenuItem.Name = "m_fileSaveMenuItem";
- this.m_fileSaveMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
- this.m_fileSaveMenuItem.Size = new System.Drawing.Size(182, 22);
- this.m_fileSaveMenuItem.Text = "&Save Map";
- this.m_fileSaveMenuItem.Click += new System.EventHandler(this.FileSaveMenuItem_Click);
- //
- // m_fileSaveAsMenuItem
- //
- this.m_fileSaveAsMenuItem.Name = "m_fileSaveAsMenuItem";
- this.m_fileSaveAsMenuItem.Size = new System.Drawing.Size(182, 22);
- this.m_fileSaveAsMenuItem.Text = "Save Map &As...";
- this.m_fileSaveAsMenuItem.Click += new System.EventHandler(this.FileSaveAsMenuItem_Click);
- //
- // toolStripSeparator10
- //
- this.toolStripSeparator10.Name = "toolStripSeparator10";
- this.toolStripSeparator10.Size = new System.Drawing.Size(179, 6);
- //
- // m_fileExportMenu
- //
- this.m_fileExportMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.m_fileExportPDFMenuItem,
- this.m_fileExportImageMenuItem,
- this.toolStripMenuItem9,
- this.m_fileExportInform7MenuItem,
- this.tADSToolStripMenuItem,
- this.toolStripMenuItem10,
- this.inform6ToolStripMenuItem});
- this.m_fileExportMenu.Name = "m_fileExportMenu";
- this.m_fileExportMenu.Size = new System.Drawing.Size(182, 22);
- this.m_fileExportMenu.Text = "&Export";
- //
- // m_fileExportPDFMenuItem
- //
- this.m_fileExportPDFMenuItem.Name = "m_fileExportPDFMenuItem";
- this.m_fileExportPDFMenuItem.Size = new System.Drawing.Size(152, 22);
- this.m_fileExportPDFMenuItem.Text = "&PDF...";
- this.m_fileExportPDFMenuItem.Click += new System.EventHandler(this.FileExportPDFMenuItem_Click);
- //
- // m_fileExportImageMenuItem
- //
- this.m_fileExportImageMenuItem.Name = "m_fileExportImageMenuItem";
- this.m_fileExportImageMenuItem.Size = new System.Drawing.Size(152, 22);
- this.m_fileExportImageMenuItem.Text = "&Image...";
- this.m_fileExportImageMenuItem.Click += new System.EventHandler(this.FileExportImageMenuItem_Click);
- //
- // toolStripMenuItem9
- //
- this.toolStripMenuItem9.Name = "toolStripMenuItem9";
- this.toolStripMenuItem9.Size = new System.Drawing.Size(149, 6);
- //
- // m_fileExportInform7MenuItem
- //
- this.m_fileExportInform7MenuItem.Name = "m_fileExportInform7MenuItem";
- this.m_fileExportInform7MenuItem.Size = new System.Drawing.Size(152, 22);
- this.m_fileExportInform7MenuItem.Text = "Inform &7...";
- this.m_fileExportInform7MenuItem.Click += new System.EventHandler(this.FileExportInform7MenuItem_Click);
- //
- // tADSToolStripMenuItem
- //
- this.tADSToolStripMenuItem.Name = "tADSToolStripMenuItem";
- this.tADSToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
- this.tADSToolStripMenuItem.Text = "&TADS...";
- this.tADSToolStripMenuItem.Click += new System.EventHandler(this.FileExportTadsMenuItem_Click);
- //
- // toolStripSeparator12
- //
- this.toolStripSeparator12.Name = "toolStripSeparator12";
- this.toolStripSeparator12.Size = new System.Drawing.Size(179, 6);
- //
- // m_fileRecentMapsMenuItem
- //
- this.m_fileRecentMapsMenuItem.Name = "m_fileRecentMapsMenuItem";
- this.m_fileRecentMapsMenuItem.Size = new System.Drawing.Size(182, 22);
- this.m_fileRecentMapsMenuItem.Text = "&Recent Maps";
- //
- // toolStripMenuItem7
- //
- this.toolStripMenuItem7.Name = "toolStripMenuItem7";
- this.toolStripMenuItem7.Size = new System.Drawing.Size(179, 6);
- //
- // m_fileExitMenuItem
- //
- this.m_fileExitMenuItem.Name = "m_fileExitMenuItem";
- this.m_fileExitMenuItem.Size = new System.Drawing.Size(182, 22);
- this.m_fileExitMenuItem.Text = "E&xit";
- this.m_fileExitMenuItem.Click += new System.EventHandler(this.FileExitMenuItem_Click);
- //
- // m_editMenu
- //
- this.m_editMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.m_editAddRoomMenuItem,
- this.toolStripSeparator6,
- this.m_editRenameMenuItem,
- this.m_editIsDarkMenuItem,
- this.toolStripSeparator2,
- this.m_lineStylesMenuItem,
- this.m_reverseLineMenuItem,
- this.toolStripSeparator8,
- this.m_editSelectAllMenuItem,
- this.m_editSelectNoneMenuItem,
- this.toolStripMenuItem8,
- this.m_editDeleteMenuItem,
- this.toolStripSeparator3,
- this.m_editPropertiesMenuItem});
- this.m_editMenu.Name = "m_editMenu";
- this.m_editMenu.Size = new System.Drawing.Size(39, 20);
- this.m_editMenu.Text = "&Edit";
- //
- // m_editAddRoomMenuItem
- //
- this.m_editAddRoomMenuItem.Name = "m_editAddRoomMenuItem";
- this.m_editAddRoomMenuItem.ShortcutKeyDisplayString = "R";
- this.m_editAddRoomMenuItem.Size = new System.Drawing.Size(180, 22);
- this.m_editAddRoomMenuItem.Text = "&Add Room";
- this.m_editAddRoomMenuItem.Click += new System.EventHandler(this.EditAddRoomMenuItem_Click);
- //
- // toolStripSeparator6
- //
- this.toolStripSeparator6.Name = "toolStripSeparator6";
- this.toolStripSeparator6.Size = new System.Drawing.Size(177, 6);
- //
- // m_editRenameMenuItem
- //
- this.m_editRenameMenuItem.Name = "m_editRenameMenuItem";
- this.m_editRenameMenuItem.ShortcutKeyDisplayString = "";
- this.m_editRenameMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F2;
- this.m_editRenameMenuItem.Size = new System.Drawing.Size(180, 22);
- this.m_editRenameMenuItem.Text = "Re&name";
- this.m_editRenameMenuItem.Click += new System.EventHandler(this.EditRenameMenuItem_Click);
- //
- // m_editIsDarkMenuItem
- //
- this.m_editIsDarkMenuItem.Name = "m_editIsDarkMenuItem";
- this.m_editIsDarkMenuItem.ShortcutKeyDisplayString = "K";
- this.m_editIsDarkMenuItem.Size = new System.Drawing.Size(180, 22);
- this.m_editIsDarkMenuItem.Text = "Is Dar&k Room";
- this.m_editIsDarkMenuItem.Click += new System.EventHandler(this.EditIsDarkMenuItem_Click);
- //
- // toolStripSeparator2
- //
- this.toolStripSeparator2.Name = "toolStripSeparator2";
- this.toolStripSeparator2.Size = new System.Drawing.Size(177, 6);
- //
- // m_lineStylesMenuItem
- //
- this.m_lineStylesMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.m_plainLinesMenuItem,
- this.toolStripMenuItem3,
- this.m_toggleDottedLinesMenuItem,
- this.m_toggleDirectionalLinesMenuItem,
- this.toolStripMenuItem1,
- this.m_upLinesMenuItem,
- this.m_downLinesMenuItem,
- this.toolStripMenuItem2,
- this.m_inLinesMenuItem,
- this.m_outLinesMenuItem});
- this.m_lineStylesMenuItem.Name = "m_lineStylesMenuItem";
- this.m_lineStylesMenuItem.ShortcutKeyDisplayString = "";
- this.m_lineStylesMenuItem.Size = new System.Drawing.Size(180, 22);
- this.m_lineStylesMenuItem.Text = "&Line Styles";
- //
- // m_plainLinesMenuItem
- //
- this.m_plainLinesMenuItem.Name = "m_plainLinesMenuItem";
- this.m_plainLinesMenuItem.ShortcutKeyDisplayString = "P";
- this.m_plainLinesMenuItem.Size = new System.Drawing.Size(172, 22);
- this.m_plainLinesMenuItem.Text = "Plain";
- this.m_plainLinesMenuItem.Click += new System.EventHandler(this.PlainLinesMenuItem_Click);
- //
- // toolStripMenuItem3
- //
- this.toolStripMenuItem3.Name = "toolStripMenuItem3";
- this.toolStripMenuItem3.Size = new System.Drawing.Size(169, 6);
- //
- // m_toggleDottedLinesMenuItem
- //
- this.m_toggleDottedLinesMenuItem.Name = "m_toggleDottedLinesMenuItem";
- this.m_toggleDottedLinesMenuItem.ShortcutKeyDisplayString = "T";
- this.m_toggleDottedLinesMenuItem.Size = new System.Drawing.Size(172, 22);
- this.m_toggleDottedLinesMenuItem.Text = "Dotted";
- this.m_toggleDottedLinesMenuItem.Click += new System.EventHandler(this.ToggleDottedLines_Click);
- //
- // m_toggleDirectionalLinesMenuItem
- //
- this.m_toggleDirectionalLinesMenuItem.Name = "m_toggleDirectionalLinesMenuItem";
- this.m_toggleDirectionalLinesMenuItem.ShortcutKeyDisplayString = "A";
- this.m_toggleDirectionalLinesMenuItem.Size = new System.Drawing.Size(172, 22);
- this.m_toggleDirectionalLinesMenuItem.Text = "One Way Arrow";
- this.m_toggleDirectionalLinesMenuItem.Click += new System.EventHandler(this.ToggleDirectionalLines_Click);
- //
- // toolStripMenuItem1
- //
- this.toolStripMenuItem1.Name = "toolStripMenuItem1";
- this.toolStripMenuItem1.Size = new System.Drawing.Size(169, 6);
- //
- // m_upLinesMenuItem
- //
- this.m_upLinesMenuItem.Name = "m_upLinesMenuItem";
- this.m_upLinesMenuItem.ShortcutKeyDisplayString = "U";
- this.m_upLinesMenuItem.Size = new System.Drawing.Size(172, 22);
- this.m_upLinesMenuItem.Text = "Up";
- this.m_upLinesMenuItem.Click += new System.EventHandler(this.UpLinesMenuItem_Click);
- //
- // m_downLinesMenuItem
- //
- this.m_downLinesMenuItem.Name = "m_downLinesMenuItem";
- this.m_downLinesMenuItem.ShortcutKeyDisplayString = "D";
- this.m_downLinesMenuItem.Size = new System.Drawing.Size(172, 22);
- this.m_downLinesMenuItem.Text = "Down";
- this.m_downLinesMenuItem.Click += new System.EventHandler(this.DownLinesMenuItem_Click);
- //
- // toolStripMenuItem2
- //
- this.toolStripMenuItem2.Name = "toolStripMenuItem2";
- this.toolStripMenuItem2.Size = new System.Drawing.Size(169, 6);
- //
- // m_inLinesMenuItem
- //
- this.m_inLinesMenuItem.Name = "m_inLinesMenuItem";
- this.m_inLinesMenuItem.ShortcutKeyDisplayString = "I";
- this.m_inLinesMenuItem.Size = new System.Drawing.Size(172, 22);
- this.m_inLinesMenuItem.Text = "In";
- this.m_inLinesMenuItem.Click += new System.EventHandler(this.InLinesMenuItem_Click);
- //
- // m_outLinesMenuItem
- //
- this.m_outLinesMenuItem.Name = "m_outLinesMenuItem";
- this.m_outLinesMenuItem.ShortcutKeyDisplayString = "O";
- this.m_outLinesMenuItem.Size = new System.Drawing.Size(172, 22);
- this.m_outLinesMenuItem.Text = "Out";
- this.m_outLinesMenuItem.Click += new System.EventHandler(this.OutLinesMenuItem_Click);
- //
- // m_reverseLineMenuItem
- //
- this.m_reverseLineMenuItem.Name = "m_reverseLineMenuItem";
- this.m_reverseLineMenuItem.ShortcutKeyDisplayString = "V";
- this.m_reverseLineMenuItem.Size = new System.Drawing.Size(180, 22);
- this.m_reverseLineMenuItem.Text = "Reverse Line";
- this.m_reverseLineMenuItem.Click += new System.EventHandler(this.ReverseLineMenuItem_Click);
- //
- // toolStripSeparator8
- //
- this.toolStripSeparator8.Name = "toolStripSeparator8";
- this.toolStripSeparator8.Size = new System.Drawing.Size(177, 6);
- //
- // m_editSelectAllMenuItem
- //
- this.m_editSelectAllMenuItem.Name = "m_editSelectAllMenuItem";
- this.m_editSelectAllMenuItem.ShortcutKeyDisplayString = "Ctrl + A";
- this.m_editSelectAllMenuItem.Size = new System.Drawing.Size(180, 22);
- this.m_editSelectAllMenuItem.Text = "Select All";
- this.m_editSelectAllMenuItem.Click += new System.EventHandler(this.EditSelectAllMenuItem_Click);
- //
- // m_editSelectNoneMenuItem
- //
- this.m_editSelectNoneMenuItem.Name = "m_editSelectNoneMenuItem";
- this.m_editSelectNoneMenuItem.ShortcutKeyDisplayString = "Escape";
- this.m_editSelectNoneMenuItem.Size = new System.Drawing.Size(180, 22);
- this.m_editSelectNoneMenuItem.Text = "Select None";
- this.m_editSelectNoneMenuItem.Click += new System.EventHandler(this.EditSelectNoneMenuItem_Click);
- //
- // toolStripMenuItem8
- //
- this.toolStripMenuItem8.Name = "toolStripMenuItem8";
- this.toolStripMenuItem8.Size = new System.Drawing.Size(177, 6);
- //
- // m_editDeleteMenuItem
- //
- this.m_editDeleteMenuItem.Name = "m_editDeleteMenuItem";
- this.m_editDeleteMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Delete;
- this.m_editDeleteMenuItem.Size = new System.Drawing.Size(180, 22);
- this.m_editDeleteMenuItem.Text = "&Delete";
- this.m_editDeleteMenuItem.Click += new System.EventHandler(this.EditDeleteMenuItem_Click);
- //
- // toolStripSeparator3
- //
- this.toolStripSeparator3.Name = "toolStripSeparator3";
- this.toolStripSeparator3.Size = new System.Drawing.Size(177, 6);
- //
- // m_editPropertiesMenuItem
- //
- this.m_editPropertiesMenuItem.Name = "m_editPropertiesMenuItem";
- this.m_editPropertiesMenuItem.ShortcutKeyDisplayString = "Enter";
- this.m_editPropertiesMenuItem.Size = new System.Drawing.Size(180, 22);
- this.m_editPropertiesMenuItem.Text = "P&roperties";
- this.m_editPropertiesMenuItem.Click += new System.EventHandler(this.EditPropertiesMenuItem_Click);
- //
- // m_viewMenu
- //
- this.m_viewMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.m_viewZoomMenu,
- this.m_viewEntireMapMenuItem,
- this.m_viewResetMenuItem,
- this.toolStripMenuItem6,
- this.m_viewMinimapMenuItem});
- this.m_viewMenu.Name = "m_viewMenu";
- this.m_viewMenu.Size = new System.Drawing.Size(44, 20);
- this.m_viewMenu.Text = "&View";
- //
- // m_viewZoomMenu
- //
- this.m_viewZoomMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.m_viewZoomInMenuItem,
- this.m_viewZoomOutMenuItem,
- this.toolStripSeparator7,
- this.m_viewZoomFiftyPercentMenuItem,
- this.m_viewZoomOneHundredPercentMenuItem,
- this.m_viewZoomTwoHundredPercentMenuItem});
- this.m_viewZoomMenu.Name = "m_viewZoomMenu";
- this.m_viewZoomMenu.Size = new System.Drawing.Size(204, 22);
- this.m_viewZoomMenu.Text = "&Zoom";
- //
- // m_viewZoomInMenuItem
- //
- this.m_viewZoomInMenuItem.Name = "m_viewZoomInMenuItem";
- this.m_viewZoomInMenuItem.ShortcutKeyDisplayString = "+ / Mouse Wheel";
- this.m_viewZoomInMenuItem.Size = new System.Drawing.Size(189, 22);
- this.m_viewZoomInMenuItem.Text = "&In";
- this.m_viewZoomInMenuItem.Click += new System.EventHandler(this.ViewZoomInMenuItem_Click);
- //
- // m_viewZoomOutMenuItem
- //
- this.m_viewZoomOutMenuItem.Name = "m_viewZoomOutMenuItem";
- this.m_viewZoomOutMenuItem.ShortcutKeyDisplayString = "- / Mouse Wheel";
- this.m_viewZoomOutMenuItem.Size = new System.Drawing.Size(189, 22);
- this.m_viewZoomOutMenuItem.Text = "&Out";
- this.m_viewZoomOutMenuItem.Click += new System.EventHandler(this.ViewZoomOutMenuItem_Click);
- //
- // toolStripSeparator7
- //
- this.toolStripSeparator7.Name = "toolStripSeparator7";
- this.toolStripSeparator7.Size = new System.Drawing.Size(186, 6);
- //
- // m_viewZoomFiftyPercentMenuItem
- //
- this.m_viewZoomFiftyPercentMenuItem.Name = "m_viewZoomFiftyPercentMenuItem";
- this.m_viewZoomFiftyPercentMenuItem.Size = new System.Drawing.Size(189, 22);
- this.m_viewZoomFiftyPercentMenuItem.Text = "&50%";
- this.m_viewZoomFiftyPercentMenuItem.Click += new System.EventHandler(this.ViewZoomFiftyPercentMenuItem_Click);
- //
- // m_viewZoomOneHundredPercentMenuItem
- //
- this.m_viewZoomOneHundredPercentMenuItem.Name = "m_viewZoomOneHundredPercentMenuItem";
- this.m_viewZoomOneHundredPercentMenuItem.Size = new System.Drawing.Size(189, 22);
- this.m_viewZoomOneHundredPercentMenuItem.Text = "&100%";
- this.m_viewZoomOneHundredPercentMenuItem.Click += new System.EventHandler(this.ViewZoomOneHundredPercentMenuItem_Click);
- //
- // m_viewZoomTwoHundredPercentMenuItem
- //
- this.m_viewZoomTwoHundredPercentMenuItem.Name = "m_viewZoomTwoHundredPercentMenuItem";
- this.m_viewZoomTwoHundredPercentMenuItem.Size = new System.Drawing.Size(189, 22);
- this.m_viewZoomTwoHundredPercentMenuItem.Text = "&200%";
- this.m_viewZoomTwoHundredPercentMenuItem.Click += new System.EventHandler(this.ViewZoomTwoHundredPercentMenuItem_Click);
- //
- // m_viewEntireMapMenuItem
- //
- this.m_viewEntireMapMenuItem.Name = "m_viewEntireMapMenuItem";
- this.m_viewEntireMapMenuItem.ShortcutKeyDisplayString = "Ctrl + Home";
- this.m_viewEntireMapMenuItem.Size = new System.Drawing.Size(204, 22);
- this.m_viewEntireMapMenuItem.Text = "&Entire Map";
- this.m_viewEntireMapMenuItem.Click += new System.EventHandler(this.ViewEntireMapMenuItem_Click);
- //
- // m_viewResetMenuItem
- //
- this.m_viewResetMenuItem.Name = "m_viewResetMenuItem";
- this.m_viewResetMenuItem.ShortcutKeyDisplayString = "Home";
- this.m_viewResetMenuItem.Size = new System.Drawing.Size(204, 22);
- this.m_viewResetMenuItem.Text = "&Reset";
- this.m_viewResetMenuItem.Click += new System.EventHandler(this.ViewResetMenuItem_Click);
- //
- // toolStripMenuItem6
- //
- this.toolStripMenuItem6.Name = "toolStripMenuItem6";
- this.toolStripMenuItem6.Size = new System.Drawing.Size(201, 6);
- //
- // m_viewMinimapMenuItem
- //
- this.m_viewMinimapMenuItem.Name = "m_viewMinimapMenuItem";
- this.m_viewMinimapMenuItem.Size = new System.Drawing.Size(204, 22);
- this.m_viewMinimapMenuItem.Text = "&Mini Map";
- this.m_viewMinimapMenuItem.Click += new System.EventHandler(this.ViewMinimapMenuItem_Click);
- //
- // automappingToolStripMenuItem
- //
- this.automappingToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.m_automapStartMenuItem,
- this.m_automapStopMenuItem});
- this.automappingToolStripMenuItem.Name = "automappingToolStripMenuItem";
- this.automappingToolStripMenuItem.Size = new System.Drawing.Size(69, 20);
- this.automappingToolStripMenuItem.Text = "&Automap";
- //
- // m_automapStartMenuItem
- //
- this.m_automapStartMenuItem.Name = "m_automapStartMenuItem";
- this.m_automapStartMenuItem.Size = new System.Drawing.Size(107, 22);
- this.m_automapStartMenuItem.Text = "&Start...";
- this.m_automapStartMenuItem.Click += new System.EventHandler(this.AutomapStartMenuItem_Click);
- //
- // m_automapStopMenuItem
- //
- this.m_automapStopMenuItem.Name = "m_automapStopMenuItem";
- this.m_automapStopMenuItem.Size = new System.Drawing.Size(107, 22);
- this.m_automapStopMenuItem.Text = "S&top";
- this.m_automapStopMenuItem.Click += new System.EventHandler(this.AutomapStopMenuItem_Click);
- //
- // m_projectMenu
- //
- this.m_projectMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.m_projectSettingsMenuItem,
- this.toolStripSeparator11,
- this.m_projectResetToDefaultSettingsMenuItem});
- this.m_projectMenu.Name = "m_projectMenu";
- this.m_projectMenu.Size = new System.Drawing.Size(48, 20);
- this.m_projectMenu.Text = "&Tools";
- //
- // m_projectSettingsMenuItem
- //
- this.m_projectSettingsMenuItem.Name = "m_projectSettingsMenuItem";
- this.m_projectSettingsMenuItem.Size = new System.Drawing.Size(199, 22);
- this.m_projectSettingsMenuItem.Text = "&Settings...";
- this.m_projectSettingsMenuItem.Click += new System.EventHandler(this.ProjectSettingsMenuItem_Click);
- //
- // toolStripSeparator11
- //
- this.toolStripSeparator11.Name = "toolStripSeparator11";
- this.toolStripSeparator11.Size = new System.Drawing.Size(196, 6);
- //
- // m_projectResetToDefaultSettingsMenuItem
- //
- this.m_projectResetToDefaultSettingsMenuItem.Name = "m_projectResetToDefaultSettingsMenuItem";
- this.m_projectResetToDefaultSettingsMenuItem.Size = new System.Drawing.Size(199, 22);
- this.m_projectResetToDefaultSettingsMenuItem.Text = "&Restore Default Settings";
- this.m_projectResetToDefaultSettingsMenuItem.Click += new System.EventHandler(this.ProjectResetToDefaultSettingsMenuItem_Click);
- //
- // m_helpMenu
- //
- this.m_helpMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.m_onlineHelpMenuItem,
- this.m_checkForUpdatesMenuItem,
- this.toolStripMenuItem4,
- this.m_helpAboutMenuItem});
- this.m_helpMenu.Name = "m_helpMenu";
- this.m_helpMenu.Size = new System.Drawing.Size(44, 20);
- this.m_helpMenu.Text = "&Help";
- //
- // m_onlineHelpMenuItem
- //
- this.m_onlineHelpMenuItem.Name = "m_onlineHelpMenuItem";
- this.m_onlineHelpMenuItem.Size = new System.Drawing.Size(171, 22);
- this.m_onlineHelpMenuItem.Text = "Online Help";
- this.m_onlineHelpMenuItem.Click += new System.EventHandler(this.HelpAndSupportMenuItem_Click);
- //
- // m_checkForUpdatesMenuItem
- //
- this.m_checkForUpdatesMenuItem.Name = "m_checkForUpdatesMenuItem";
- this.m_checkForUpdatesMenuItem.Size = new System.Drawing.Size(171, 22);
- this.m_checkForUpdatesMenuItem.Text = "Check for &Updates";
- this.m_checkForUpdatesMenuItem.Click += new System.EventHandler(this.CheckForUpdatesMenuItem_Click);
- //
- // toolStripMenuItem4
- //
- this.toolStripMenuItem4.Name = "toolStripMenuItem4";
- this.toolStripMenuItem4.Size = new System.Drawing.Size(168, 6);
- //
- // m_helpAboutMenuItem
- //
- this.m_helpAboutMenuItem.Name = "m_helpAboutMenuItem";
- this.m_helpAboutMenuItem.Size = new System.Drawing.Size(171, 22);
- this.m_helpAboutMenuItem.Text = "&About";
- this.m_helpAboutMenuItem.Click += new System.EventHandler(this.HelpAboutMenuItem_Click);
- //
- // m_toolStrip
- //
- this.m_toolStrip.AutoSize = false;
- this.m_toolStrip.Dock = System.Windows.Forms.DockStyle.Left;
- this.m_toolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
- this.m_toolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.m_toggleDottedLinesButton,
- this.m_toggleDirectionalLinesButton});
- this.m_toolStrip.Location = new System.Drawing.Point(0, 24);
- this.m_toolStrip.Name = "m_toolStrip";
- this.m_toolStrip.Padding = new System.Windows.Forms.Padding(1, 0, 1, 0);
- this.m_toolStrip.Size = new System.Drawing.Size(38, 420);
- this.m_toolStrip.TabIndex = 2;
- //
- // m_toggleDottedLinesButton
- //
- this.m_toggleDottedLinesButton.AutoSize = false;
- this.m_toggleDottedLinesButton.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("m_toggleDottedLinesButton.BackgroundImage")));
- this.m_toggleDottedLinesButton.CheckOnClick = true;
- this.m_toggleDottedLinesButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
- this.m_toggleDottedLinesButton.Image = global::Trizbort.Properties.Resources.LineStyle;
- this.m_toggleDottedLinesButton.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
- this.m_toggleDottedLinesButton.ImageTransparentColor = System.Drawing.Color.Magenta;
- this.m_toggleDottedLinesButton.Name = "m_toggleDottedLinesButton";
- this.m_toggleDottedLinesButton.Size = new System.Drawing.Size(32, 32);
- this.m_toggleDottedLinesButton.Text = "Toggle Dotted Lines (T)";
- this.m_toggleDottedLinesButton.Click += new System.EventHandler(this.ToggleDottedLines_Click);
- //
- // m_toggleDirectionalLinesButton
- //
- this.m_toggleDirectionalLinesButton.AutoSize = false;
- this.m_toggleDirectionalLinesButton.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("m_toggleDirectionalLinesButton.BackgroundImage")));
- this.m_toggleDirectionalLinesButton.CheckOnClick = true;
- this.m_toggleDirectionalLinesButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
- this.m_toggleDirectionalLinesButton.Image = global::Trizbort.Properties.Resources.LineDirection;
- this.m_toggleDirectionalLinesButton.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
- this.m_toggleDirectionalLinesButton.ImageTransparentColor = System.Drawing.Color.Magenta;
- this.m_toggleDirectionalLinesButton.Name = "m_toggleDirectionalLinesButton";
- this.m_toggleDirectionalLinesButton.Size = new System.Drawing.Size(32, 32);
- this.m_toggleDirectionalLinesButton.Text = "Toggle One Way Arrow Lines (A)";
- this.m_toggleDirectionalLinesButton.Click += new System.EventHandler(this.ToggleDirectionalLines_Click);
- //
- // toolStripSeparator4
- //
- this.toolStripSeparator4.Name = "toolStripSeparator4";
- this.toolStripSeparator4.Size = new System.Drawing.Size(6, 6);
- //
- // m_automapBar
- //
- this.m_automapBar.BackColor = System.Drawing.SystemColors.Info;
- this.m_automapBar.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.m_automapBar.Dock = System.Windows.Forms.DockStyle.Bottom;
- this.m_automapBar.ForeColor = System.Drawing.SystemColors.InfoText;
- this.m_automapBar.Location = new System.Drawing.Point(38, 415);
- this.m_automapBar.MaximumSize = new System.Drawing.Size(4096, 29);
- this.m_automapBar.MinimumSize = new System.Drawing.Size(2, 29);
- this.m_automapBar.Name = "m_automapBar";
- this.m_automapBar.Size = new System.Drawing.Size(586, 29);
- this.m_automapBar.Status = "(Status)";
- this.m_automapBar.TabIndex = 4;
- //
- // m_canvas
- //
- this.m_canvas.BackColor = System.Drawing.Color.White;
- this.m_canvas.Dock = System.Windows.Forms.DockStyle.Fill;
- this.m_canvas.Location = new System.Drawing.Point(38, 24);
- this.m_canvas.MinimapVisible = true;
- this.m_canvas.Name = "m_canvas";
- this.m_canvas.Size = new System.Drawing.Size(586, 420);
- this.m_canvas.TabIndex = 3;
- //
- // inform6ToolStripMenuItem
- //
- this.inform6ToolStripMenuItem.Name = "inform6ToolStripMenuItem";
- this.inform6ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
- this.inform6ToolStripMenuItem.Text = "Inform &6...";
- this.inform6ToolStripMenuItem.Click += new System.EventHandler(this.FileExportInform6MenuItem_Click);
- //
- // toolStripMenuItem10
- //
- this.toolStripMenuItem10.Name = "toolStripMenuItem10";
- this.toolStripMenuItem10.Size = new System.Drawing.Size(149, 6);
- //
- // MainForm
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(624, 444);
- this.Controls.Add(this.m_automapBar);
- this.Controls.Add(this.m_canvas);
- this.Controls.Add(this.m_toolStrip);
- this.Controls.Add(this.m_menuStrip);
- this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
- this.MainMenuStrip = this.m_menuStrip;
- this.Name = "MainForm";
- this.Text = "Trizbort - Interactive Fiction Mapper";
- this.Load += new System.EventHandler(this.MainForm_Load);
- this.m_menuStrip.ResumeLayout(false);
- this.m_menuStrip.PerformLayout();
- this.m_toolStrip.ResumeLayout(false);
- this.m_toolStrip.PerformLayout();
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private System.Windows.Forms.MenuStrip m_menuStrip;
- private System.Windows.Forms.ToolStripMenuItem m_fileMenu;
- private System.Windows.Forms.ToolStripMenuItem m_fileExitMenuItem;
- private System.Windows.Forms.ToolStripMenuItem m_projectMenu;
- private System.Windows.Forms.ToolStripMenuItem m_projectSettingsMenuItem;
- private System.Windows.Forms.ToolStripMenuItem m_fileNewMenuItem;
- private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
- private System.Windows.Forms.ToolStripMenuItem m_editMenu;
- private System.Windows.Forms.ToolStripMenuItem m_editAddRoomMenuItem;
- private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
- private System.Windows.Forms.ToolStripMenuItem m_editDeleteMenuItem;
- private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
- private System.Windows.Forms.ToolStripMenuItem m_editPropertiesMenuItem;
- private System.Windows.Forms.ToolStrip m_toolStrip;
- private System.Windows.Forms.ToolStripButton m_toggleDottedLinesButton;
- private System.Windows.Forms.ToolStripButton m_toggleDirectionalLinesButton;
- private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
- private System.Windows.Forms.ToolStripSeparator toolStripSeparator6;
- private System.Windows.Forms.ToolStripMenuItem m_lineStylesMenuItem;
- private Canvas m_canvas;
- private System.Windows.Forms.ToolStripMenuItem m_viewMenu;
- private System.Windows.Forms.ToolStripMenuItem m_viewZoomMenu;
- private System.Windows.Forms.ToolStripMenuItem m_viewZoomInMenuItem;
- private System.Windows.Forms.ToolStripMenuItem m_viewZoomOutMenuItem;
- private System.Windows.Forms.ToolStripSeparator toolStripSeparator7;
- private System.Windows.Forms.ToolStripMenuItem m_viewZoomFiftyPercentMenuItem;
- private System.Windows.Forms.ToolStripMenuItem m_viewZoomOneHundredPercentMenuItem;
- private System.Windows.Forms.ToolStripMenuItem m_viewZoomTwoHundredPercentMenuItem;
- private System.Windows.Forms.ToolStripMenuItem m_viewResetMenuItem;
- private System.Windows.Forms.ToolStripMenuItem m_editRenameMenuItem;
- private System.Windows.Forms.ToolStripMenuItem m_editIsDarkMenuItem;
- private System.Windows.Forms.ToolStripSeparator toolStripSeparator8;
- private System.Windows.Forms.ToolStripMenuItem m_fileOpenMenuItem;
- private System.Windows.Forms.ToolStripSeparator toolStripSeparator9;
- private System.Windows.Forms.ToolStripMenuItem m_fileSaveMenuItem;
- private System.Windows.Forms.ToolStripMenuItem m_fileSaveAsMenuItem;
- private System.Windows.Forms.ToolStripSeparator toolStripSeparator10;
- private System.Windows.Forms.ToolStripSeparator toolStripSeparator11;
- private System.Windows.Forms.ToolStripMenuItem m_projectResetToDefaultSettingsMenuItem;
- private System.Windows.Forms.ToolStripMenuItem m_fileExportMenu;
- private System.Windows.Forms.ToolStripMenuItem m_fileExportPDFMenuItem;
- private System.Windows.Forms.ToolStripMenuItem m_fileExportImageMenuItem;
- private System.Windows.Forms.ToolStripSeparator toolStripSeparator12;
- private System.Windows.Forms.ToolStripMenuItem m_helpMenu;
- private System.Windows.Forms.ToolStripMenuItem m_helpAboutMenuItem;
- private System.Windows.Forms.ToolStripMenuItem m_plainLinesMenuItem;
- private System.Windows.Forms.ToolStripSeparator toolStripMenuItem3;
- private System.Windows.Forms.ToolStripMenuItem m_toggleDottedLinesMenuItem;
- private System.Windows.Forms.ToolStripMenuItem m_toggleDirectionalLinesMenuItem;
- private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
- private System.Windows.Forms.ToolStripMenuItem m_upLinesMenuItem;
- private System.Windows.Forms.ToolStripMenuItem m_downLinesMenuItem;
- private System.Windows.Forms.ToolStripSeparator toolStripMenuItem2;
- private System.Windows.Forms.ToolStripMenuItem m_inLinesMenuItem;
- private System.Windows.Forms.ToolStripMenuItem m_outLinesMenuItem;
- private System.Windows.Forms.ToolStripMenuItem m_reverseLineMenuItem;
- private System.Windows.Forms.ToolStripMenuItem m_onlineHelpMenuItem;
- private System.Windows.Forms.ToolStripSeparator toolStripMenuItem4;
- private System.Windows.Forms.ToolStripMenuItem m_checkForUpdatesMenuItem;
- private System.Windows.Forms.ToolStripMenuItem automappingToolStripMenuItem;
- private System.Windows.Forms.ToolStripMenuItem m_automapStartMenuItem;
- private System.Windows.Forms.ToolStripMenuItem m_automapStopMenuItem;
- private AutomapBar m_automapBar;
- private System.Windows.Forms.ToolStripSeparator toolStripMenuItem6;
- private System.Windows.Forms.ToolStripMenuItem m_viewMinimapMenuItem;
- private System.Windows.Forms.ToolStripMenuItem m_fileExportInform7MenuItem;
- private System.Windows.Forms.ToolStripMenuItem m_fileRecentMapsMenuItem;
- private System.Windows.Forms.ToolStripSeparator toolStripMenuItem7;
- private System.Windows.Forms.ToolStripMenuItem m_editSelectAllMenuItem;
- private System.Windows.Forms.ToolStripMenuItem m_editSelectNoneMenuItem;
- private System.Windows.Forms.ToolStripSeparator toolStripMenuItem8;
- private System.Windows.Forms.ToolStripMenuItem m_viewEntireMapMenuItem;
- private System.Windows.Forms.ToolStripSeparator toolStripMenuItem9;
- private System.Windows.Forms.ToolStripMenuItem tADSToolStripMenuItem;
- private System.Windows.Forms.ToolStripSeparator toolStripMenuItem10;
- private System.Windows.Forms.ToolStripMenuItem inform6ToolStripMenuItem;
- }
-}
-
+/*
+ Copyright (c) 2010 by Genstein
+
+ This file is (or was originally) part of Trizbort, the Interactive Fiction Mapper.
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+*/
+
+namespace Trizbort
+{
+ partial class MainForm
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
+ this.m_menuStrip = new System.Windows.Forms.MenuStrip();
+ this.m_fileMenu = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_fileNewMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
+ this.m_fileOpenMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripSeparator9 = new System.Windows.Forms.ToolStripSeparator();
+ this.m_fileSaveMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_fileSaveAsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripSeparator10 = new System.Windows.Forms.ToolStripSeparator();
+ this.m_fileExportMenu = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_fileExportPDFMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_fileExportImageMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripMenuItem9 = new System.Windows.Forms.ToolStripSeparator();
+ this.m_fileExportInform7MenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.tADSToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripMenuItem10 = new System.Windows.Forms.ToolStripSeparator();
+ this.inform6ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripSeparator12 = new System.Windows.Forms.ToolStripSeparator();
+ this.m_fileRecentMapsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripMenuItem7 = new System.Windows.Forms.ToolStripSeparator();
+ this.m_fileExitMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_editMenu = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_editAddRoomMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator();
+ this.m_editRenameMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_editIsDarkMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
+ this.m_lineStylesMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_plainLinesMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripSeparator();
+ this.m_toggleDottedLinesMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_toggleDirectionalLinesMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
+ this.m_upLinesMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_downLinesMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator();
+ this.m_inLinesMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_outLinesMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_reverseLineMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripSeparator8 = new System.Windows.Forms.ToolStripSeparator();
+ this.m_editSelectAllMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_editSelectNoneMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripMenuItem8 = new System.Windows.Forms.ToolStripSeparator();
+ this.m_editDeleteMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
+ this.m_editPropertiesMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_viewMenu = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_viewZoomMenu = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_viewZoomInMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_viewZoomOutMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator();
+ this.m_viewZoomFiftyPercentMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_viewZoomOneHundredPercentMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_viewZoomTwoHundredPercentMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_viewEntireMapMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_viewResetMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripMenuItem6 = new System.Windows.Forms.ToolStripSeparator();
+ this.m_viewMinimapMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.automappingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_automapStartMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_automapStopMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_projectMenu = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_projectSettingsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_appSettingsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripSeparator11 = new System.Windows.Forms.ToolStripSeparator();
+ this.m_projectResetToDefaultSettingsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_helpMenu = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_onlineHelpMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_checkForUpdatesMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripSeparator();
+ this.m_helpAboutMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.m_toolStrip = new System.Windows.Forms.ToolStrip();
+ this.m_toggleDottedLinesButton = new System.Windows.Forms.ToolStripButton();
+ this.m_toggleDirectionalLinesButton = new System.Windows.Forms.ToolStripButton();
+ this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
+ this.m_automapBar = new Trizbort.AutomapBar();
+ this.m_canvas = new Trizbort.Canvas();
+ this.m_menuStrip.SuspendLayout();
+ this.m_toolStrip.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // m_menuStrip
+ //
+ this.m_menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.m_fileMenu,
+ this.m_editMenu,
+ this.m_viewMenu,
+ this.automappingToolStripMenuItem,
+ this.m_projectMenu,
+ this.m_helpMenu});
+ this.m_menuStrip.Location = new System.Drawing.Point(0, 0);
+ this.m_menuStrip.Name = "m_menuStrip";
+ this.m_menuStrip.Size = new System.Drawing.Size(624, 24);
+ this.m_menuStrip.TabIndex = 1;
+ //
+ // m_fileMenu
+ //
+ this.m_fileMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.m_fileNewMenuItem,
+ this.toolStripSeparator1,
+ this.m_fileOpenMenuItem,
+ this.toolStripSeparator9,
+ this.m_fileSaveMenuItem,
+ this.m_fileSaveAsMenuItem,
+ this.toolStripSeparator10,
+ this.m_fileExportMenu,
+ this.toolStripSeparator12,
+ this.m_fileRecentMapsMenuItem,
+ this.toolStripMenuItem7,
+ this.m_fileExitMenuItem});
+ this.m_fileMenu.Name = "m_fileMenu";
+ this.m_fileMenu.Size = new System.Drawing.Size(37, 20);
+ this.m_fileMenu.Text = "&File";
+ this.m_fileMenu.DropDownOpening += new System.EventHandler(this.FileMenu_DropDownOpening);
+ //
+ // m_fileNewMenuItem
+ //
+ this.m_fileNewMenuItem.Name = "m_fileNewMenuItem";
+ this.m_fileNewMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N)));
+ this.m_fileNewMenuItem.Size = new System.Drawing.Size(182, 22);
+ this.m_fileNewMenuItem.Text = "&New Map";
+ this.m_fileNewMenuItem.Click += new System.EventHandler(this.FileNewMenuItem_Click);
+ //
+ // toolStripSeparator1
+ //
+ this.toolStripSeparator1.Name = "toolStripSeparator1";
+ this.toolStripSeparator1.Size = new System.Drawing.Size(179, 6);
+ //
+ // m_fileOpenMenuItem
+ //
+ this.m_fileOpenMenuItem.Name = "m_fileOpenMenuItem";
+ this.m_fileOpenMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
+ this.m_fileOpenMenuItem.Size = new System.Drawing.Size(182, 22);
+ this.m_fileOpenMenuItem.Text = "&Open Map...";
+ this.m_fileOpenMenuItem.Click += new System.EventHandler(this.FileOpenMenuItem_Click);
+ //
+ // toolStripSeparator9
+ //
+ this.toolStripSeparator9.Name = "toolStripSeparator9";
+ this.toolStripSeparator9.Size = new System.Drawing.Size(179, 6);
+ //
+ // m_fileSaveMenuItem
+ //
+ this.m_fileSaveMenuItem.Name = "m_fileSaveMenuItem";
+ this.m_fileSaveMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
+ this.m_fileSaveMenuItem.Size = new System.Drawing.Size(182, 22);
+ this.m_fileSaveMenuItem.Text = "&Save Map";
+ this.m_fileSaveMenuItem.Click += new System.EventHandler(this.FileSaveMenuItem_Click);
+ //
+ // m_fileSaveAsMenuItem
+ //
+ this.m_fileSaveAsMenuItem.Name = "m_fileSaveAsMenuItem";
+ this.m_fileSaveAsMenuItem.Size = new System.Drawing.Size(182, 22);
+ this.m_fileSaveAsMenuItem.Text = "Save Map &As...";
+ this.m_fileSaveAsMenuItem.Click += new System.EventHandler(this.FileSaveAsMenuItem_Click);
+ //
+ // toolStripSeparator10
+ //
+ this.toolStripSeparator10.Name = "toolStripSeparator10";
+ this.toolStripSeparator10.Size = new System.Drawing.Size(179, 6);
+ //
+ // m_fileExportMenu
+ //
+ this.m_fileExportMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.m_fileExportPDFMenuItem,
+ this.m_fileExportImageMenuItem,
+ this.toolStripMenuItem9,
+ this.m_fileExportInform7MenuItem,
+ this.tADSToolStripMenuItem,
+ this.toolStripMenuItem10,
+ this.inform6ToolStripMenuItem});
+ this.m_fileExportMenu.Name = "m_fileExportMenu";
+ this.m_fileExportMenu.Size = new System.Drawing.Size(182, 22);
+ this.m_fileExportMenu.Text = "&Export";
+ //
+ // m_fileExportPDFMenuItem
+ //
+ this.m_fileExportPDFMenuItem.Name = "m_fileExportPDFMenuItem";
+ this.m_fileExportPDFMenuItem.Size = new System.Drawing.Size(128, 22);
+ this.m_fileExportPDFMenuItem.Text = "&PDF...";
+ this.m_fileExportPDFMenuItem.Click += new System.EventHandler(this.FileExportPDFMenuItem_Click);
+ //
+ // m_fileExportImageMenuItem
+ //
+ this.m_fileExportImageMenuItem.Name = "m_fileExportImageMenuItem";
+ this.m_fileExportImageMenuItem.Size = new System.Drawing.Size(128, 22);
+ this.m_fileExportImageMenuItem.Text = "&Image...";
+ this.m_fileExportImageMenuItem.Click += new System.EventHandler(this.FileExportImageMenuItem_Click);
+ //
+ // toolStripMenuItem9
+ //
+ this.toolStripMenuItem9.Name = "toolStripMenuItem9";
+ this.toolStripMenuItem9.Size = new System.Drawing.Size(125, 6);
+ //
+ // m_fileExportInform7MenuItem
+ //
+ this.m_fileExportInform7MenuItem.Name = "m_fileExportInform7MenuItem";
+ this.m_fileExportInform7MenuItem.Size = new System.Drawing.Size(128, 22);
+ this.m_fileExportInform7MenuItem.Text = "Inform &7...";
+ this.m_fileExportInform7MenuItem.Click += new System.EventHandler(this.FileExportInform7MenuItem_Click);
+ //
+ // tADSToolStripMenuItem
+ //
+ this.tADSToolStripMenuItem.Name = "tADSToolStripMenuItem";
+ this.tADSToolStripMenuItem.Size = new System.Drawing.Size(128, 22);
+ this.tADSToolStripMenuItem.Text = "&TADS...";
+ this.tADSToolStripMenuItem.Click += new System.EventHandler(this.FileExportTadsMenuItem_Click);
+ //
+ // toolStripMenuItem10
+ //
+ this.toolStripMenuItem10.Name = "toolStripMenuItem10";
+ this.toolStripMenuItem10.Size = new System.Drawing.Size(125, 6);
+ //
+ // inform6ToolStripMenuItem
+ //
+ this.inform6ToolStripMenuItem.Name = "inform6ToolStripMenuItem";
+ this.inform6ToolStripMenuItem.Size = new System.Drawing.Size(128, 22);
+ this.inform6ToolStripMenuItem.Text = "Inform &6...";
+ this.inform6ToolStripMenuItem.Click += new System.EventHandler(this.FileExportInform6MenuItem_Click);
+ //
+ // toolStripSeparator12
+ //
+ this.toolStripSeparator12.Name = "toolStripSeparator12";
+ this.toolStripSeparator12.Size = new System.Drawing.Size(179, 6);
+ //
+ // m_fileRecentMapsMenuItem
+ //
+ this.m_fileRecentMapsMenuItem.Name = "m_fileRecentMapsMenuItem";
+ this.m_fileRecentMapsMenuItem.Size = new System.Drawing.Size(182, 22);
+ this.m_fileRecentMapsMenuItem.Text = "&Recent Maps";
+ //
+ // toolStripMenuItem7
+ //
+ this.toolStripMenuItem7.Name = "toolStripMenuItem7";
+ this.toolStripMenuItem7.Size = new System.Drawing.Size(179, 6);
+ //
+ // m_fileExitMenuItem
+ //
+ this.m_fileExitMenuItem.Name = "m_fileExitMenuItem";
+ this.m_fileExitMenuItem.Size = new System.Drawing.Size(182, 22);
+ this.m_fileExitMenuItem.Text = "E&xit";
+ this.m_fileExitMenuItem.Click += new System.EventHandler(this.FileExitMenuItem_Click);
+ //
+ // m_editMenu
+ //
+ this.m_editMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.m_editAddRoomMenuItem,
+ this.toolStripSeparator6,
+ this.m_editRenameMenuItem,
+ this.m_editIsDarkMenuItem,
+ this.toolStripSeparator2,
+ this.m_lineStylesMenuItem,
+ this.m_reverseLineMenuItem,
+ this.toolStripSeparator8,
+ this.m_editSelectAllMenuItem,
+ this.m_editSelectNoneMenuItem,
+ this.toolStripMenuItem8,
+ this.m_editDeleteMenuItem,
+ this.toolStripSeparator3,
+ this.m_editPropertiesMenuItem});
+ this.m_editMenu.Name = "m_editMenu";
+ this.m_editMenu.Size = new System.Drawing.Size(39, 20);
+ this.m_editMenu.Text = "&Edit";
+ //
+ // m_editAddRoomMenuItem
+ //
+ this.m_editAddRoomMenuItem.Name = "m_editAddRoomMenuItem";
+ this.m_editAddRoomMenuItem.ShortcutKeyDisplayString = "R";
+ this.m_editAddRoomMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.m_editAddRoomMenuItem.Text = "&Add Room";
+ this.m_editAddRoomMenuItem.Click += new System.EventHandler(this.EditAddRoomMenuItem_Click);
+ //
+ // toolStripSeparator6
+ //
+ this.toolStripSeparator6.Name = "toolStripSeparator6";
+ this.toolStripSeparator6.Size = new System.Drawing.Size(177, 6);
+ //
+ // m_editRenameMenuItem
+ //
+ this.m_editRenameMenuItem.Name = "m_editRenameMenuItem";
+ this.m_editRenameMenuItem.ShortcutKeyDisplayString = "";
+ this.m_editRenameMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F2;
+ this.m_editRenameMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.m_editRenameMenuItem.Text = "Re&name";
+ this.m_editRenameMenuItem.Click += new System.EventHandler(this.EditRenameMenuItem_Click);
+ //
+ // m_editIsDarkMenuItem
+ //
+ this.m_editIsDarkMenuItem.Name = "m_editIsDarkMenuItem";
+ this.m_editIsDarkMenuItem.ShortcutKeyDisplayString = "K";
+ this.m_editIsDarkMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.m_editIsDarkMenuItem.Text = "Is Dar&k Room";
+ this.m_editIsDarkMenuItem.Click += new System.EventHandler(this.EditIsDarkMenuItem_Click);
+ //
+ // toolStripSeparator2
+ //
+ this.toolStripSeparator2.Name = "toolStripSeparator2";
+ this.toolStripSeparator2.Size = new System.Drawing.Size(177, 6);
+ //
+ // m_lineStylesMenuItem
+ //
+ this.m_lineStylesMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.m_plainLinesMenuItem,
+ this.toolStripMenuItem3,
+ this.m_toggleDottedLinesMenuItem,
+ this.m_toggleDirectionalLinesMenuItem,
+ this.toolStripMenuItem1,
+ this.m_upLinesMenuItem,
+ this.m_downLinesMenuItem,
+ this.toolStripMenuItem2,
+ this.m_inLinesMenuItem,
+ this.m_outLinesMenuItem});
+ this.m_lineStylesMenuItem.Name = "m_lineStylesMenuItem";
+ this.m_lineStylesMenuItem.ShortcutKeyDisplayString = "";
+ this.m_lineStylesMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.m_lineStylesMenuItem.Text = "&Line Styles";
+ //
+ // m_plainLinesMenuItem
+ //
+ this.m_plainLinesMenuItem.Name = "m_plainLinesMenuItem";
+ this.m_plainLinesMenuItem.ShortcutKeyDisplayString = "P";
+ this.m_plainLinesMenuItem.Size = new System.Drawing.Size(172, 22);
+ this.m_plainLinesMenuItem.Text = "Plain";
+ this.m_plainLinesMenuItem.Click += new System.EventHandler(this.PlainLinesMenuItem_Click);
+ //
+ // toolStripMenuItem3
+ //
+ this.toolStripMenuItem3.Name = "toolStripMenuItem3";
+ this.toolStripMenuItem3.Size = new System.Drawing.Size(169, 6);
+ //
+ // m_toggleDottedLinesMenuItem
+ //
+ this.m_toggleDottedLinesMenuItem.Name = "m_toggleDottedLinesMenuItem";
+ this.m_toggleDottedLinesMenuItem.ShortcutKeyDisplayString = "T";
+ this.m_toggleDottedLinesMenuItem.Size = new System.Drawing.Size(172, 22);
+ this.m_toggleDottedLinesMenuItem.Text = "Dotted";
+ this.m_toggleDottedLinesMenuItem.Click += new System.EventHandler(this.ToggleDottedLines_Click);
+ //
+ // m_toggleDirectionalLinesMenuItem
+ //
+ this.m_toggleDirectionalLinesMenuItem.Name = "m_toggleDirectionalLinesMenuItem";
+ this.m_toggleDirectionalLinesMenuItem.ShortcutKeyDisplayString = "A";
+ this.m_toggleDirectionalLinesMenuItem.Size = new System.Drawing.Size(172, 22);
+ this.m_toggleDirectionalLinesMenuItem.Text = "One Way Arrow";
+ this.m_toggleDirectionalLinesMenuItem.Click += new System.EventHandler(this.ToggleDirectionalLines_Click);
+ //
+ // toolStripMenuItem1
+ //
+ this.toolStripMenuItem1.Name = "toolStripMenuItem1";
+ this.toolStripMenuItem1.Size = new System.Drawing.Size(169, 6);
+ //
+ // m_upLinesMenuItem
+ //
+ this.m_upLinesMenuItem.Name = "m_upLinesMenuItem";
+ this.m_upLinesMenuItem.ShortcutKeyDisplayString = "U";
+ this.m_upLinesMenuItem.Size = new System.Drawing.Size(172, 22);
+ this.m_upLinesMenuItem.Text = "Up";
+ this.m_upLinesMenuItem.Click += new System.EventHandler(this.UpLinesMenuItem_Click);
+ //
+ // m_downLinesMenuItem
+ //
+ this.m_downLinesMenuItem.Name = "m_downLinesMenuItem";
+ this.m_downLinesMenuItem.ShortcutKeyDisplayString = "D";
+ this.m_downLinesMenuItem.Size = new System.Drawing.Size(172, 22);
+ this.m_downLinesMenuItem.Text = "Down";
+ this.m_downLinesMenuItem.Click += new System.EventHandler(this.DownLinesMenuItem_Click);
+ //
+ // toolStripMenuItem2
+ //
+ this.toolStripMenuItem2.Name = "toolStripMenuItem2";
+ this.toolStripMenuItem2.Size = new System.Drawing.Size(169, 6);
+ //
+ // m_inLinesMenuItem
+ //
+ this.m_inLinesMenuItem.Name = "m_inLinesMenuItem";
+ this.m_inLinesMenuItem.ShortcutKeyDisplayString = "I";
+ this.m_inLinesMenuItem.Size = new System.Drawing.Size(172, 22);
+ this.m_inLinesMenuItem.Text = "In";
+ this.m_inLinesMenuItem.Click += new System.EventHandler(this.InLinesMenuItem_Click);
+ //
+ // m_outLinesMenuItem
+ //
+ this.m_outLinesMenuItem.Name = "m_outLinesMenuItem";
+ this.m_outLinesMenuItem.ShortcutKeyDisplayString = "O";
+ this.m_outLinesMenuItem.Size = new System.Drawing.Size(172, 22);
+ this.m_outLinesMenuItem.Text = "Out";
+ this.m_outLinesMenuItem.Click += new System.EventHandler(this.OutLinesMenuItem_Click);
+ //
+ // m_reverseLineMenuItem
+ //
+ this.m_reverseLineMenuItem.Name = "m_reverseLineMenuItem";
+ this.m_reverseLineMenuItem.ShortcutKeyDisplayString = "V";
+ this.m_reverseLineMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.m_reverseLineMenuItem.Text = "Reverse Line";
+ this.m_reverseLineMenuItem.Click += new System.EventHandler(this.ReverseLineMenuItem_Click);
+ //
+ // toolStripSeparator8
+ //
+ this.toolStripSeparator8.Name = "toolStripSeparator8";
+ this.toolStripSeparator8.Size = new System.Drawing.Size(177, 6);
+ //
+ // m_editSelectAllMenuItem
+ //
+ this.m_editSelectAllMenuItem.Name = "m_editSelectAllMenuItem";
+ this.m_editSelectAllMenuItem.ShortcutKeyDisplayString = "Ctrl + A";
+ this.m_editSelectAllMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.m_editSelectAllMenuItem.Text = "Select All";
+ this.m_editSelectAllMenuItem.Click += new System.EventHandler(this.EditSelectAllMenuItem_Click);
+ //
+ // m_editSelectNoneMenuItem
+ //
+ this.m_editSelectNoneMenuItem.Name = "m_editSelectNoneMenuItem";
+ this.m_editSelectNoneMenuItem.ShortcutKeyDisplayString = "Escape";
+ this.m_editSelectNoneMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.m_editSelectNoneMenuItem.Text = "Select None";
+ this.m_editSelectNoneMenuItem.Click += new System.EventHandler(this.EditSelectNoneMenuItem_Click);
+ //
+ // toolStripMenuItem8
+ //
+ this.toolStripMenuItem8.Name = "toolStripMenuItem8";
+ this.toolStripMenuItem8.Size = new System.Drawing.Size(177, 6);
+ //
+ // m_editDeleteMenuItem
+ //
+ this.m_editDeleteMenuItem.Name = "m_editDeleteMenuItem";
+ this.m_editDeleteMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Delete;
+ this.m_editDeleteMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.m_editDeleteMenuItem.Text = "&Delete";
+ this.m_editDeleteMenuItem.Click += new System.EventHandler(this.EditDeleteMenuItem_Click);
+ //
+ // toolStripSeparator3
+ //
+ this.toolStripSeparator3.Name = "toolStripSeparator3";
+ this.toolStripSeparator3.Size = new System.Drawing.Size(177, 6);
+ //
+ // m_editPropertiesMenuItem
+ //
+ this.m_editPropertiesMenuItem.Name = "m_editPropertiesMenuItem";
+ this.m_editPropertiesMenuItem.ShortcutKeyDisplayString = "Enter";
+ this.m_editPropertiesMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.m_editPropertiesMenuItem.Text = "P&roperties";
+ this.m_editPropertiesMenuItem.Click += new System.EventHandler(this.EditPropertiesMenuItem_Click);
+ //
+ // m_viewMenu
+ //
+ this.m_viewMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.m_viewZoomMenu,
+ this.m_viewEntireMapMenuItem,
+ this.m_viewResetMenuItem,
+ this.toolStripMenuItem6,
+ this.m_viewMinimapMenuItem});
+ this.m_viewMenu.Name = "m_viewMenu";
+ this.m_viewMenu.Size = new System.Drawing.Size(44, 20);
+ this.m_viewMenu.Text = "&View";
+ //
+ // m_viewZoomMenu
+ //
+ this.m_viewZoomMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.m_viewZoomInMenuItem,
+ this.m_viewZoomOutMenuItem,
+ this.toolStripSeparator7,
+ this.m_viewZoomFiftyPercentMenuItem,
+ this.m_viewZoomOneHundredPercentMenuItem,
+ this.m_viewZoomTwoHundredPercentMenuItem});
+ this.m_viewZoomMenu.Name = "m_viewZoomMenu";
+ this.m_viewZoomMenu.Size = new System.Drawing.Size(204, 22);
+ this.m_viewZoomMenu.Text = "&Zoom";
+ //
+ // m_viewZoomInMenuItem
+ //
+ this.m_viewZoomInMenuItem.Name = "m_viewZoomInMenuItem";
+ this.m_viewZoomInMenuItem.ShortcutKeyDisplayString = "+ / Mouse Wheel";
+ this.m_viewZoomInMenuItem.Size = new System.Drawing.Size(189, 22);
+ this.m_viewZoomInMenuItem.Text = "&In";
+ this.m_viewZoomInMenuItem.Click += new System.EventHandler(this.ViewZoomInMenuItem_Click);
+ //
+ // m_viewZoomOutMenuItem
+ //
+ this.m_viewZoomOutMenuItem.Name = "m_viewZoomOutMenuItem";
+ this.m_viewZoomOutMenuItem.ShortcutKeyDisplayString = "- / Mouse Wheel";
+ this.m_viewZoomOutMenuItem.Size = new System.Drawing.Size(189, 22);
+ this.m_viewZoomOutMenuItem.Text = "&Out";
+ this.m_viewZoomOutMenuItem.Click += new System.EventHandler(this.ViewZoomOutMenuItem_Click);
+ //
+ // toolStripSeparator7
+ //
+ this.toolStripSeparator7.Name = "toolStripSeparator7";
+ this.toolStripSeparator7.Size = new System.Drawing.Size(186, 6);
+ //
+ // m_viewZoomFiftyPercentMenuItem
+ //
+ this.m_viewZoomFiftyPercentMenuItem.Name = "m_viewZoomFiftyPercentMenuItem";
+ this.m_viewZoomFiftyPercentMenuItem.Size = new System.Drawing.Size(189, 22);
+ this.m_viewZoomFiftyPercentMenuItem.Text = "&50%";
+ this.m_viewZoomFiftyPercentMenuItem.Click += new System.EventHandler(this.ViewZoomFiftyPercentMenuItem_Click);
+ //
+ // m_viewZoomOneHundredPercentMenuItem
+ //
+ this.m_viewZoomOneHundredPercentMenuItem.Name = "m_viewZoomOneHundredPercentMenuItem";
+ this.m_viewZoomOneHundredPercentMenuItem.Size = new System.Drawing.Size(189, 22);
+ this.m_viewZoomOneHundredPercentMenuItem.Text = "&100%";
+ this.m_viewZoomOneHundredPercentMenuItem.Click += new System.EventHandler(this.ViewZoomOneHundredPercentMenuItem_Click);
+ //
+ // m_viewZoomTwoHundredPercentMenuItem
+ //
+ this.m_viewZoomTwoHundredPercentMenuItem.Name = "m_viewZoomTwoHundredPercentMenuItem";
+ this.m_viewZoomTwoHundredPercentMenuItem.Size = new System.Drawing.Size(189, 22);
+ this.m_viewZoomTwoHundredPercentMenuItem.Text = "&200%";
+ this.m_viewZoomTwoHundredPercentMenuItem.Click += new System.EventHandler(this.ViewZoomTwoHundredPercentMenuItem_Click);
+ //
+ // m_viewEntireMapMenuItem
+ //
+ this.m_viewEntireMapMenuItem.Name = "m_viewEntireMapMenuItem";
+ this.m_viewEntireMapMenuItem.ShortcutKeyDisplayString = "Ctrl + Home";
+ this.m_viewEntireMapMenuItem.Size = new System.Drawing.Size(204, 22);
+ this.m_viewEntireMapMenuItem.Text = "&Entire Map";
+ this.m_viewEntireMapMenuItem.Click += new System.EventHandler(this.ViewEntireMapMenuItem_Click);
+ //
+ // m_viewResetMenuItem
+ //
+ this.m_viewResetMenuItem.Name = "m_viewResetMenuItem";
+ this.m_viewResetMenuItem.ShortcutKeyDisplayString = "Home";
+ this.m_viewResetMenuItem.Size = new System.Drawing.Size(204, 22);
+ this.m_viewResetMenuItem.Text = "&Reset";
+ this.m_viewResetMenuItem.Click += new System.EventHandler(this.ViewResetMenuItem_Click);
+ //
+ // toolStripMenuItem6
+ //
+ this.toolStripMenuItem6.Name = "toolStripMenuItem6";
+ this.toolStripMenuItem6.Size = new System.Drawing.Size(201, 6);
+ //
+ // m_viewMinimapMenuItem
+ //
+ this.m_viewMinimapMenuItem.Name = "m_viewMinimapMenuItem";
+ this.m_viewMinimapMenuItem.Size = new System.Drawing.Size(204, 22);
+ this.m_viewMinimapMenuItem.Text = "&Mini Map";
+ this.m_viewMinimapMenuItem.Click += new System.EventHandler(this.ViewMinimapMenuItem_Click);
+ //
+ // automappingToolStripMenuItem
+ //
+ this.automappingToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.m_automapStartMenuItem,
+ this.m_automapStopMenuItem});
+ this.automappingToolStripMenuItem.Name = "automappingToolStripMenuItem";
+ this.automappingToolStripMenuItem.Size = new System.Drawing.Size(69, 20);
+ this.automappingToolStripMenuItem.Text = "&Automap";
+ //
+ // m_automapStartMenuItem
+ //
+ this.m_automapStartMenuItem.Name = "m_automapStartMenuItem";
+ this.m_automapStartMenuItem.Size = new System.Drawing.Size(107, 22);
+ this.m_automapStartMenuItem.Text = "&Start...";
+ this.m_automapStartMenuItem.Click += new System.EventHandler(this.AutomapStartMenuItem_Click);
+ //
+ // m_automapStopMenuItem
+ //
+ this.m_automapStopMenuItem.Name = "m_automapStopMenuItem";
+ this.m_automapStopMenuItem.Size = new System.Drawing.Size(107, 22);
+ this.m_automapStopMenuItem.Text = "S&top";
+ this.m_automapStopMenuItem.Click += new System.EventHandler(this.AutomapStopMenuItem_Click);
+ //
+ // m_projectMenu
+ //
+ this.m_projectMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.m_projectSettingsMenuItem,
+ this.m_appSettingsMenuItem,
+ this.toolStripSeparator11,
+ this.m_projectResetToDefaultSettingsMenuItem});
+ this.m_projectMenu.Name = "m_projectMenu";
+ this.m_projectMenu.Size = new System.Drawing.Size(48, 20);
+ this.m_projectMenu.Text = "&Tools";
+ //
+ // m_projectSettingsMenuItem
+ //
+ this.m_projectSettingsMenuItem.Name = "m_projectSettingsMenuItem";
+ this.m_projectSettingsMenuItem.Size = new System.Drawing.Size(199, 22);
+ this.m_projectSettingsMenuItem.Text = "Map &Settings...";
+ this.m_projectSettingsMenuItem.Click += new System.EventHandler(this.ProjectSettingsMenuItem_Click);
+ //
+ // m_appSettingsMenuItem
+ //
+ this.m_appSettingsMenuItem.Name = "m_appSettingsMenuItem";
+ this.m_appSettingsMenuItem.Size = new System.Drawing.Size(199, 22);
+ this.m_appSettingsMenuItem.Text = "App Settings...";
+ this.m_appSettingsMenuItem.Click += new System.EventHandler(this.ApplicationSettingsMenuItem_Click);
+ //
+ // toolStripSeparator11
+ //
+ this.toolStripSeparator11.Name = "toolStripSeparator11";
+ this.toolStripSeparator11.Size = new System.Drawing.Size(196, 6);
+ //
+ // m_projectResetToDefaultSettingsMenuItem
+ //
+ this.m_projectResetToDefaultSettingsMenuItem.Name = "m_projectResetToDefaultSettingsMenuItem";
+ this.m_projectResetToDefaultSettingsMenuItem.Size = new System.Drawing.Size(199, 22);
+ this.m_projectResetToDefaultSettingsMenuItem.Text = "&Restore Default Settings";
+ this.m_projectResetToDefaultSettingsMenuItem.Click += new System.EventHandler(this.ProjectResetToDefaultSettingsMenuItem_Click);
+ //
+ // m_helpMenu
+ //
+ this.m_helpMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.m_onlineHelpMenuItem,
+ this.m_checkForUpdatesMenuItem,
+ this.toolStripMenuItem4,
+ this.m_helpAboutMenuItem});
+ this.m_helpMenu.Name = "m_helpMenu";
+ this.m_helpMenu.Size = new System.Drawing.Size(44, 20);
+ this.m_helpMenu.Text = "&Help";
+ //
+ // m_onlineHelpMenuItem
+ //
+ this.m_onlineHelpMenuItem.Name = "m_onlineHelpMenuItem";
+ this.m_onlineHelpMenuItem.Size = new System.Drawing.Size(171, 22);
+ this.m_onlineHelpMenuItem.Text = "Online Help";
+ this.m_onlineHelpMenuItem.Click += new System.EventHandler(this.HelpAndSupportMenuItem_Click);
+ //
+ // m_checkForUpdatesMenuItem
+ //
+ this.m_checkForUpdatesMenuItem.Name = "m_checkForUpdatesMenuItem";
+ this.m_checkForUpdatesMenuItem.Size = new System.Drawing.Size(171, 22);
+ this.m_checkForUpdatesMenuItem.Text = "Check for &Updates";
+ this.m_checkForUpdatesMenuItem.Click += new System.EventHandler(this.CheckForUpdatesMenuItem_Click);
+ //
+ // toolStripMenuItem4
+ //
+ this.toolStripMenuItem4.Name = "toolStripMenuItem4";
+ this.toolStripMenuItem4.Size = new System.Drawing.Size(168, 6);
+ //
+ // m_helpAboutMenuItem
+ //
+ this.m_helpAboutMenuItem.Name = "m_helpAboutMenuItem";
+ this.m_helpAboutMenuItem.Size = new System.Drawing.Size(171, 22);
+ this.m_helpAboutMenuItem.Text = "&About";
+ this.m_helpAboutMenuItem.Click += new System.EventHandler(this.HelpAboutMenuItem_Click);
+ //
+ // m_toolStrip
+ //
+ this.m_toolStrip.AutoSize = false;
+ this.m_toolStrip.Dock = System.Windows.Forms.DockStyle.Left;
+ this.m_toolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
+ this.m_toolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.m_toggleDottedLinesButton,
+ this.m_toggleDirectionalLinesButton});
+ this.m_toolStrip.Location = new System.Drawing.Point(0, 24);
+ this.m_toolStrip.Name = "m_toolStrip";
+ this.m_toolStrip.Padding = new System.Windows.Forms.Padding(1, 0, 1, 0);
+ this.m_toolStrip.Size = new System.Drawing.Size(38, 420);
+ this.m_toolStrip.TabIndex = 2;
+ //
+ // m_toggleDottedLinesButton
+ //
+ this.m_toggleDottedLinesButton.AutoSize = false;
+ this.m_toggleDottedLinesButton.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("m_toggleDottedLinesButton.BackgroundImage")));
+ this.m_toggleDottedLinesButton.CheckOnClick = true;
+ this.m_toggleDottedLinesButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
+ this.m_toggleDottedLinesButton.Image = global::Trizbort.Properties.Resources.LineStyle;
+ this.m_toggleDottedLinesButton.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
+ this.m_toggleDottedLinesButton.ImageTransparentColor = System.Drawing.Color.Magenta;
+ this.m_toggleDottedLinesButton.Name = "m_toggleDottedLinesButton";
+ this.m_toggleDottedLinesButton.Size = new System.Drawing.Size(32, 32);
+ this.m_toggleDottedLinesButton.Text = "Toggle Dotted Lines (T)";
+ this.m_toggleDottedLinesButton.Click += new System.EventHandler(this.ToggleDottedLines_Click);
+ //
+ // m_toggleDirectionalLinesButton
+ //
+ this.m_toggleDirectionalLinesButton.AutoSize = false;
+ this.m_toggleDirectionalLinesButton.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("m_toggleDirectionalLinesButton.BackgroundImage")));
+ this.m_toggleDirectionalLinesButton.CheckOnClick = true;
+ this.m_toggleDirectionalLinesButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
+ this.m_toggleDirectionalLinesButton.Image = global::Trizbort.Properties.Resources.LineDirection;
+ this.m_toggleDirectionalLinesButton.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
+ this.m_toggleDirectionalLinesButton.ImageTransparentColor = System.Drawing.Color.Magenta;
+ this.m_toggleDirectionalLinesButton.Name = "m_toggleDirectionalLinesButton";
+ this.m_toggleDirectionalLinesButton.Size = new System.Drawing.Size(32, 32);
+ this.m_toggleDirectionalLinesButton.Text = "Toggle One Way Arrow Lines (A)";
+ this.m_toggleDirectionalLinesButton.Click += new System.EventHandler(this.ToggleDirectionalLines_Click);
+ //
+ // toolStripSeparator4
+ //
+ this.toolStripSeparator4.Name = "toolStripSeparator4";
+ this.toolStripSeparator4.Size = new System.Drawing.Size(6, 6);
+ //
+ // m_automapBar
+ //
+ this.m_automapBar.BackColor = System.Drawing.SystemColors.Info;
+ this.m_automapBar.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.m_automapBar.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.m_automapBar.ForeColor = System.Drawing.SystemColors.InfoText;
+ this.m_automapBar.Location = new System.Drawing.Point(38, 415);
+ this.m_automapBar.MaximumSize = new System.Drawing.Size(4096, 29);
+ this.m_automapBar.MinimumSize = new System.Drawing.Size(2, 29);
+ this.m_automapBar.Name = "m_automapBar";
+ this.m_automapBar.Size = new System.Drawing.Size(586, 29);
+ this.m_automapBar.Status = "(Status)";
+ this.m_automapBar.TabIndex = 4;
+ //
+ // m_canvas
+ //
+ this.m_canvas.BackColor = System.Drawing.Color.White;
+ this.m_canvas.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.m_canvas.Location = new System.Drawing.Point(38, 24);
+ this.m_canvas.MinimapVisible = true;
+ this.m_canvas.Name = "m_canvas";
+ this.m_canvas.Size = new System.Drawing.Size(586, 420);
+ this.m_canvas.TabIndex = 3;
+ //
+ // MainForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(624, 444);
+ this.Controls.Add(this.m_automapBar);
+ this.Controls.Add(this.m_canvas);
+ this.Controls.Add(this.m_toolStrip);
+ this.Controls.Add(this.m_menuStrip);
+ this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
+ this.MainMenuStrip = this.m_menuStrip;
+ this.Name = "MainForm";
+ this.Text = "Trizbort - Interactive Fiction Mapper";
+ this.Load += new System.EventHandler(this.MainForm_Load);
+ this.m_menuStrip.ResumeLayout(false);
+ this.m_menuStrip.PerformLayout();
+ this.m_toolStrip.ResumeLayout(false);
+ this.m_toolStrip.PerformLayout();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.MenuStrip m_menuStrip;
+ private System.Windows.Forms.ToolStripMenuItem m_fileMenu;
+ private System.Windows.Forms.ToolStripMenuItem m_fileExitMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem m_projectMenu;
+ private System.Windows.Forms.ToolStripMenuItem m_projectSettingsMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem m_fileNewMenuItem;
+ private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
+ private System.Windows.Forms.ToolStripMenuItem m_editMenu;
+ private System.Windows.Forms.ToolStripMenuItem m_editAddRoomMenuItem;
+ private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
+ private System.Windows.Forms.ToolStripMenuItem m_editDeleteMenuItem;
+ private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
+ private System.Windows.Forms.ToolStripMenuItem m_editPropertiesMenuItem;
+ private System.Windows.Forms.ToolStrip m_toolStrip;
+ private System.Windows.Forms.ToolStripButton m_toggleDottedLinesButton;
+ private System.Windows.Forms.ToolStripButton m_toggleDirectionalLinesButton;
+ private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
+ private System.Windows.Forms.ToolStripSeparator toolStripSeparator6;
+ private System.Windows.Forms.ToolStripMenuItem m_lineStylesMenuItem;
+ private Canvas m_canvas;
+ private System.Windows.Forms.ToolStripMenuItem m_viewMenu;
+ private System.Windows.Forms.ToolStripMenuItem m_viewZoomMenu;
+ private System.Windows.Forms.ToolStripMenuItem m_viewZoomInMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem m_viewZoomOutMenuItem;
+ private System.Windows.Forms.ToolStripSeparator toolStripSeparator7;
+ private System.Windows.Forms.ToolStripMenuItem m_viewZoomFiftyPercentMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem m_viewZoomOneHundredPercentMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem m_viewZoomTwoHundredPercentMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem m_viewResetMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem m_editRenameMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem m_editIsDarkMenuItem;
+ private System.Windows.Forms.ToolStripSeparator toolStripSeparator8;
+ private System.Windows.Forms.ToolStripMenuItem m_fileOpenMenuItem;
+ private System.Windows.Forms.ToolStripSeparator toolStripSeparator9;
+ private System.Windows.Forms.ToolStripMenuItem m_fileSaveMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem m_fileSaveAsMenuItem;
+ private System.Windows.Forms.ToolStripSeparator toolStripSeparator10;
+ private System.Windows.Forms.ToolStripSeparator toolStripSeparator11;
+ private System.Windows.Forms.ToolStripMenuItem m_projectResetToDefaultSettingsMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem m_fileExportMenu;
+ private System.Windows.Forms.ToolStripMenuItem m_fileExportPDFMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem m_fileExportImageMenuItem;
+ private System.Windows.Forms.ToolStripSeparator toolStripSeparator12;
+ private System.Windows.Forms.ToolStripMenuItem m_helpMenu;
+ private System.Windows.Forms.ToolStripMenuItem m_helpAboutMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem m_plainLinesMenuItem;
+ private System.Windows.Forms.ToolStripSeparator toolStripMenuItem3;
+ private System.Windows.Forms.ToolStripMenuItem m_toggleDottedLinesMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem m_toggleDirectionalLinesMenuItem;
+ private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
+ private System.Windows.Forms.ToolStripMenuItem m_upLinesMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem m_downLinesMenuItem;
+ private System.Windows.Forms.ToolStripSeparator toolStripMenuItem2;
+ private System.Windows.Forms.ToolStripMenuItem m_inLinesMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem m_outLinesMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem m_reverseLineMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem m_onlineHelpMenuItem;
+ private System.Windows.Forms.ToolStripSeparator toolStripMenuItem4;
+ private System.Windows.Forms.ToolStripMenuItem m_checkForUpdatesMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem automappingToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem m_automapStartMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem m_automapStopMenuItem;
+ private AutomapBar m_automapBar;
+ private System.Windows.Forms.ToolStripSeparator toolStripMenuItem6;
+ private System.Windows.Forms.ToolStripMenuItem m_viewMinimapMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem m_fileExportInform7MenuItem;
+ private System.Windows.Forms.ToolStripMenuItem m_fileRecentMapsMenuItem;
+ private System.Windows.Forms.ToolStripSeparator toolStripMenuItem7;
+ private System.Windows.Forms.ToolStripMenuItem m_editSelectAllMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem m_editSelectNoneMenuItem;
+ private System.Windows.Forms.ToolStripSeparator toolStripMenuItem8;
+ private System.Windows.Forms.ToolStripMenuItem m_viewEntireMapMenuItem;
+ private System.Windows.Forms.ToolStripSeparator toolStripMenuItem9;
+ private System.Windows.Forms.ToolStripMenuItem tADSToolStripMenuItem;
+ private System.Windows.Forms.ToolStripSeparator toolStripMenuItem10;
+ private System.Windows.Forms.ToolStripMenuItem inform6ToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem m_appSettingsMenuItem;
+ }
+}
+
diff --git a/MainForm.cs b/MainForm.cs
index 158deb7..01e7729 100644
--- a/MainForm.cs
+++ b/MainForm.cs
@@ -1,799 +1,804 @@
-/*
- Copyright (c) 2010 by Genstein
-
- This file is (or was originally) part of Trizbort, the Interactive Fiction Mapper.
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
-*/
-
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Drawing;
-using System.Drawing.Imaging;
-using System.Windows.Forms;
-using System.Text;
-using System.IO;
-using System.Runtime.InteropServices;
-using System.Diagnostics;
-using System.Threading;
-using PdfSharp.Drawing;
-using PdfSharp.Pdf;
-using Trizbort.Export;
-
-namespace Trizbort
-{
- internal partial class MainForm : Form
- {
- public MainForm()
- {
- InitializeComponent();
-
- m_caption = Text;
-
- Application.Idle += OnIdle;
- m_lastUpdateUITime = DateTime.MinValue;
-
- m_automapBar.StopClick += delegate(object sender, EventArgs e) { m_canvas.StopAutomapping(); };
- }
-
- private void MainForm_Load(object sender, EventArgs e)
- {
- m_canvas.MinimapVisible = Settings.ShowMiniMap;
-
- var args = Environment.GetCommandLineArgs();
- if (args.Length > 1 && File.Exists(args[1]))
- {
- try
- {
- BeginInvoke((MethodInvoker)delegate
- {
- OpenProject(args[1]);
- });
- }
- catch (Exception)
- {
- }
- }
- NewVersionDialog.CheckForUpdatesAsync(this, false);
- }
-
- public Canvas Canvas
- {
- get { return m_canvas; }
- }
-
- private void FileNewMenuItem_Click(object sender, EventArgs e)
- {
- if (!CheckLoseProject())
- return;
-
- Project.Current = new Project();
- Settings.Reset();
- }
-
- protected override void OnClosing(CancelEventArgs e)
- {
- if (!CheckLoseProject())
- {
- e.Cancel = true;
- return;
- }
-
- Settings.SaveApplicationSettings();
- m_canvas.StopAutomapping();
-
- base.OnClosing(e);
- }
-
-
- private bool CheckLoseProject()
- {
- if (Project.Current.IsDirty)
- {
- // see if the user would like to save
- var result = MessageBox.Show(this, string.Format("Do you want to save changes to {0}?", Project.Current.Name), Text, MessageBoxButtons.YesNoCancel);
- switch (result)
- {
- case DialogResult.Yes:
- // user would like to save
- if (!SaveProject())
- {
- // didn't actually save; treat as cancel
- return false;
- }
-
- // user saved; carry on
- return true;
-
- case DialogResult.No:
- // user wouldn't like to save; carry on
- return true;
-
- default:
- // user cancelled; cancel
- return false;
- }
- }
-
- // project doesn't need saving; carry on
- return true;
- }
-
- private bool OpenProject()
- {
- if (!CheckLoseProject())
- return false;
-
- using (var dialog = new OpenFileDialog())
- {
- dialog.InitialDirectory = PathHelper.SafeGetDirectoryName(Settings.LastProjectFileName);
- dialog.Filter = string.Format("{0}|All Files|*.*||", Project.FilterString);
- if (dialog.ShowDialog() == DialogResult.OK)
- {
- Settings.LastProjectFileName = dialog.FileName;
- return OpenProject(dialog.FileName);
- }
- }
-
- return false;
- }
-
- private bool OpenProject(string fileName)
- {
- var project = new Project();
- project.FileName = fileName;
- if (project.Load())
- {
- Project.Current = project;
- //AboutMap();
- Settings.RecentProjects.Add(fileName);
- return true;
- }
-
- return false;
- }
-
- private void AboutMap()
- {
- var project = Project.Current;
- if (!string.IsNullOrEmpty(project.Title) || !string.IsNullOrEmpty(project.Author) || !string.IsNullOrEmpty(project.Description))
- {
- var builder = new StringBuilder();
- if (!string.IsNullOrEmpty(project.Title))
- {
- builder.AppendLine(project.Title);
- }
- if (!string.IsNullOrEmpty(project.Author))
- {
- if (builder.Length > 0)
- {
- builder.AppendLine();
- }
- builder.AppendLine(string.Format("by {0}", project.Author));
- }
- if (!string.IsNullOrEmpty(project.Description))
- {
- if (builder.Length > 0)
- {
- builder.AppendLine();
- }
- builder.AppendLine(project.Description);
- }
- MessageBox.Show(builder.ToString(), Application.ProductName, MessageBoxButtons.OK);
- }
- }
-
- private bool SaveProject()
- {
- if (!Project.Current.HasFileName)
- {
- return SaveAsProject();
- }
-
- if (Project.Current.Save())
- {
- Settings.RecentProjects.Add(Project.Current.FileName);
- return true;
- }
- return false;
- }
-
- private bool SaveAsProject()
- {
- using (var dialog = new SaveFileDialog())
- {
- if (!string.IsNullOrEmpty(Project.Current.FileName))
- {
- dialog.FileName = Project.Current.FileName;
- }
- else
- {
- dialog.InitialDirectory = PathHelper.SafeGetDirectoryName(Settings.LastProjectFileName);
- }
- dialog.Filter = string.Format("{0}|All Files|*.*||", Project.FilterString);
- if (dialog.ShowDialog() == DialogResult.OK)
- {
- Settings.LastProjectFileName = dialog.FileName;
- Project.Current.FileName = dialog.FileName;
- if (Project.Current.Save())
- {
- Settings.RecentProjects.Add(Project.Current.FileName);
- return true;
- }
- }
- }
-
- return false;
- }
-
- private void FileOpenMenuItem_Click(object sender, EventArgs e)
- {
- OpenProject();
- }
-
- private void FileSaveMenuItem_Click(object sender, EventArgs e)
- {
- SaveProject();
- }
-
- private void FileSaveAsMenuItem_Click(object sender, EventArgs e)
- {
- SaveAsProject();
- }
-
- private void FileExportPDFMenuItem_Click(object sender, EventArgs e)
- {
- using (var dialog = new SaveFileDialog())
- {
- dialog.Filter = "PDF Files|*.pdf|All Files|*.*||";
- dialog.Title = "Export PDF";
- dialog.InitialDirectory = PathHelper.SafeGetDirectoryName(Settings.LastExportImageFileName);
- if (dialog.ShowDialog() == DialogResult.OK)
- {
- try
- {
- Settings.LastExportImageFileName = dialog.FileName;
-
- var doc = new PdfDocument();
- doc.Info.Title = Project.Current.Title;
- doc.Info.Author = Project.Current.Author;
- doc.Info.Creator = Application.ProductName;
- doc.Info.CreationDate = DateTime.Now;
- doc.Info.Subject = Project.Current.Description;
- var page = doc.AddPage();
-
- var size = m_canvas.ComputeCanvasBounds(true).Size;
- page.Width = new XUnit(size.X);
- page.Height = new XUnit(size.Y);
- using (var graphics = XGraphics.FromPdfPage(page))
- {
- m_canvas.Draw(graphics, true, size.X, size.Y);
- }
- doc.Save(dialog.FileName);
- }
- catch (Exception ex)
- {
- MessageBox.Show(Program.MainForm, string.Format("There was a problem exporting the map:\n\n{0}", ex.Message), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- }
- }
-
- private void FileExportImageMenuItem_Click(object sender, EventArgs e)
- {
- using (var dialog = new SaveFileDialog())
- {
- dialog.Filter = "PNG Images|*.png|JPEG Images|*.jpg|BMP Images|*.bmp|Enhanced Metafiles (EMF)|*.emf|All Files|*.*||";
- dialog.Title = "Export Image";
- dialog.InitialDirectory = PathHelper.SafeGetDirectoryName(Settings.LastExportImageFileName);
- if (dialog.ShowDialog() == DialogResult.OK)
- {
- Settings.LastExportImageFileName = dialog.InitialDirectory;
-
- var format = ImageFormat.Png;
- var ext = Path.GetExtension(dialog.FileName);
- if (StringComparer.InvariantCultureIgnoreCase.Compare(ext, ".jpg") == 0
- || StringComparer.InvariantCultureIgnoreCase.Compare(ext, ".jpeg") == 0)
- {
- format = ImageFormat.Jpeg;
- }
- else if (StringComparer.InvariantCultureIgnoreCase.Compare(ext, ".bmp") == 0)
- {
- format = ImageFormat.Bmp;
- }
- else if (StringComparer.InvariantCultureIgnoreCase.Compare(ext, ".emf") == 0)
- {
- format = ImageFormat.Emf;
- }
-
- var size = m_canvas.ComputeCanvasBounds(true).Size * m_canvas.ZoomFactor;
- size.X = Numeric.Clamp(size.X, 16, 8192);
- size.Y = Numeric.Clamp(size.Y, 16, 8192);
-
- try
- {
- if (format == ImageFormat.Emf)
- {
- // export as a metafile
- using (var nativeGraphics = Graphics.FromHwnd(m_canvas.Handle))
- {
- using (var stream = new MemoryStream())
- {
- try
- {
- var dc = nativeGraphics.GetHdc();
- using (var metafile = new Metafile(stream, dc))
- {
- using (var imageGraphics = Graphics.FromImage(metafile))
- {
- using (var graphics = XGraphics.FromGraphics(imageGraphics, new XSize(size.X, size.Y)))
- {
- m_canvas.Draw(graphics, true, size.X, size.Y);
- }
- }
- var handle = metafile.GetHenhmetafile();
- var copy = CopyEnhMetaFile(handle, dialog.FileName);
- DeleteEnhMetaFile(copy);
- }
- }
- finally
- {
- nativeGraphics.ReleaseHdc();
- }
- }
- }
- }
- else
- {
- // export as an image
- using (var bitmap = new Bitmap((int)Math.Ceiling(size.X), (int)Math.Ceiling(size.Y)))
- {
- using (var imageGraphics = Graphics.FromImage(bitmap))
- {
- using (var graphics = XGraphics.FromGraphics(imageGraphics, new XSize(size.X, size.Y)))
- {
- m_canvas.Draw(graphics, true, size.X, size.Y);
- }
- }
- bitmap.Save(dialog.FileName, format);
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(Program.MainForm, string.Format("There was a problem exporting the map:\n\n{0}", ex.Message), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- }
- }
-
- private void FileExportInform7MenuItem_Click(object sender, EventArgs e)
- {
- var fileName = Settings.LastExportInform7FileName;
- if (ExportCode(ref fileName))
- {
- Settings.LastExportInform7FileName = fileName;
- }
- }
-
- private void FileExportInform6MenuItem_Click(object sender, EventArgs e)
- {
- var fileName = Settings.LastExportInform6FileName;
- if (ExportCode(ref fileName))
- {
- Settings.LastExportInform6FileName = fileName;
- }
- }
-
- private void FileExportTadsMenuItem_Click(object sender, EventArgs e)
- {
- var fileName = Settings.LastExportTadsFileName;
- if (ExportCode(ref fileName))
- {
- Settings.LastExportTadsFileName = fileName;
- }
- }
-
- private bool ExportCode(ref string lastExportFileName) where T : CodeExporter, new()
- {
- using (var exporter = new T())
- {
- using (var dialog = new SaveFileDialog())
- {
- // compose filter string for file dialog
- var filterString = string.Empty;
- var filters = exporter.FileDialogFilters;
- foreach (var filter in filters)
- {
- if (!string.IsNullOrEmpty(filterString))
- {
- filterString += "|";
- }
- filterString += string.Format("{0}|*{1}", filter.Key, filter.Value);
- }
-
- if (!string.IsNullOrEmpty(filterString))
- {
- filterString += "|";
- }
- filterString += "All Files|*.*||";
- dialog.Filter = filterString;
-
- // set default filter by extension
- var extension = PathHelper.SafeGetExtension(lastExportFileName);
- for (var filterIndex = 0; filterIndex < filters.Count; ++filterIndex)
- {
- if (StringComparer.InvariantCultureIgnoreCase.Compare(extension, filters[filterIndex].Value) == 0)
- {
- dialog.FilterIndex = filterIndex + 1; // 1 based index
- break;
- }
- }
-
- // show dialog
- dialog.Title = exporter.FileDialogTitle;
- dialog.InitialDirectory = PathHelper.SafeGetDirectoryName(lastExportFileName);
- if (dialog.ShowDialog() == DialogResult.OK)
- {
- try
- {
- // export source code
- exporter.Export(dialog.FileName);
- lastExportFileName = dialog.FileName;
- return true;
- }
- catch (Exception ex)
- {
- MessageBox.Show(Program.MainForm, string.Format("There was a problem exporting the map:\n\n{0}", ex.Message), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- }
- }
-
- return false;
- }
-
- private void FileExitMenuItem_Click(object sender, EventArgs e)
- {
- Close();
- }
-
- private void EditAddRoomMenuItem_Click(object sender, EventArgs e)
- {
- m_canvas.AddRoom(false);
- }
-
- private void EditDeleteMenuItem_Click(object sender, EventArgs e)
- {
- m_canvas.DeleteSelection();
- }
-
- private void EditPropertiesMenuItem_Click(object sender, EventArgs e)
- {
- if (m_canvas.HasSingleSelectedElement && m_canvas.SelectedElement.HasDialog)
- {
- m_canvas.SelectedElement.ShowDialog();
- }
- }
-
- private void PlainLinesMenuItem_Click(object sender, EventArgs e)
- {
- m_canvas.ApplyNewPlainConnectionSettings();
- }
-
- private void ToggleDottedLines_Click(object sender, EventArgs e)
- {
- switch (m_canvas.NewConnectionStyle)
- {
- case ConnectionStyle.Solid:
- m_canvas.NewConnectionStyle = ConnectionStyle.Dashed;
- break;
- case ConnectionStyle.Dashed:
- m_canvas.NewConnectionStyle = ConnectionStyle.Solid;
- break;
- }
- m_canvas.ApplyConnectionStyle(m_canvas.NewConnectionStyle);
- }
-
- private void ToggleDirectionalLines_Click(object sender, EventArgs e)
- {
- switch (m_canvas.NewConnectionFlow)
- {
- case ConnectionFlow.TwoWay:
- m_canvas.NewConnectionFlow = ConnectionFlow.OneWay;
- break;
- case ConnectionFlow.OneWay:
- m_canvas.NewConnectionFlow = ConnectionFlow.TwoWay;
- break;
- }
- m_canvas.ApplyConnectionFlow(m_canvas.NewConnectionFlow);
- }
-
- private void UpLinesMenuItem_Click(object sender, EventArgs e)
- {
- m_canvas.NewConnectionLabel = ConnectionLabel.Up;
- m_canvas.ApplyConnectionLabel(m_canvas.NewConnectionLabel);
- }
-
- private void DownLinesMenuItem_Click(object sender, EventArgs e)
- {
- m_canvas.NewConnectionLabel = ConnectionLabel.Down;
- m_canvas.ApplyConnectionLabel(m_canvas.NewConnectionLabel);
- }
-
- private void InLinesMenuItem_Click(object sender, EventArgs e)
- {
- m_canvas.NewConnectionLabel = ConnectionLabel.In;
- m_canvas.ApplyConnectionLabel(m_canvas.NewConnectionLabel);
- }
-
- private void OutLinesMenuItem_Click(object sender, EventArgs e)
- {
- m_canvas.NewConnectionLabel = ConnectionLabel.Out;
- m_canvas.ApplyConnectionLabel(m_canvas.NewConnectionLabel);
- }
-
- private void ReverseLineMenuItem_Click(object sender, EventArgs e)
- {
- m_canvas.ReverseLineDirection();
- }
-
- private void OnIdle(object sender, EventArgs e)
- {
- var now = DateTime.Now;
- if (now - m_lastUpdateUITime > IdleProcessingEveryNSeconds)
- {
- m_lastUpdateUITime = now;
- UpdateCommandUI();
- }
- }
-
- private void UpdateCommandUI()
- {
- // caption
- Text = string.Format("{0}{1} - {2}", Project.Current.Name, Project.Current.IsDirty ? "*" : string.Empty, m_caption);
-
- // line drawing options
- m_toggleDottedLinesButton.Checked = m_canvas.NewConnectionStyle == ConnectionStyle.Dashed;
- m_toggleDottedLinesMenuItem.Checked = m_toggleDottedLinesButton.Checked;
- m_toggleDirectionalLinesButton.Checked = m_canvas.NewConnectionFlow == ConnectionFlow.OneWay;
- m_toggleDirectionalLinesMenuItem.Checked = m_toggleDirectionalLinesButton.Checked;
- m_plainLinesMenuItem.Checked = !m_toggleDirectionalLinesMenuItem.Checked && !m_toggleDottedLinesMenuItem.Checked && m_canvas.NewConnectionLabel == ConnectionLabel.None;
- m_upLinesMenuItem.Checked = m_canvas.NewConnectionLabel == ConnectionLabel.Up;
- m_downLinesMenuItem.Checked = m_canvas.NewConnectionLabel == ConnectionLabel.Down;
- m_inLinesMenuItem.Checked = m_canvas.NewConnectionLabel == ConnectionLabel.In;
- m_outLinesMenuItem.Checked = m_canvas.NewConnectionLabel == ConnectionLabel.Out;
-
- // selection-specific commands
- bool hasSelectedElement = m_canvas.SelectedElement != null;
- m_editDeleteMenuItem.Enabled = hasSelectedElement;
- m_editPropertiesMenuItem.Enabled = m_canvas.HasSingleSelectedElement;
- m_editIsDarkMenuItem.Enabled = hasSelectedElement;
- m_editSelectNoneMenuItem.Enabled = hasSelectedElement;
- m_editSelectAllMenuItem.Enabled = m_canvas.SelectedElementCount < Project.Current.Elements.Count;
- m_editRenameMenuItem.Enabled = m_canvas.HasSingleSelectedElement && (m_canvas.SelectedElement is Room);
- m_editIsDarkMenuItem.Checked = m_canvas.HasSingleSelectedElement && (m_canvas.SelectedElement is Room) && ((Room)m_canvas.SelectedElement).IsDark;
- m_reverseLineMenuItem.Enabled = m_canvas.HasSelectedElement();
-
- // automapping
- m_automapStartMenuItem.Enabled = !m_canvas.IsAutomapping;
- m_automapStopMenuItem.Enabled = m_canvas.IsAutomapping;
- m_automapBar.Visible = m_canvas.IsAutomapping;
- m_automapBar.Status = m_canvas.AutomappingStatus;
-
- // minimap
- m_viewMinimapMenuItem.Checked = m_canvas.MinimapVisible;
-
- UpdateToolStripImages();
- m_canvas.UpdateScrollBars();
-
- Debug.WriteLine(m_canvas.Focused ? "Focused!" : "NOT FOCUSED");
- }
-
- private void FileRecentProject_Click(object sender, EventArgs e)
- {
- if (!CheckLoseProject())
- {
- return;
- }
-
- var fileName = (string)((ToolStripMenuItem)sender).Tag;
- OpenProject(fileName);
- }
-
- private void UpdateToolStripImages()
- {
- foreach (ToolStripItem item in m_toolStrip.Items)
- {
- if (!(item is ToolStripButton))
- continue;
-
- var button = (ToolStripButton)item;
- button.BackgroundImage = button.Checked ? Properties.Resources.ToolStripBackground2 : Properties.Resources.ToolStripBackground;
- }
- }
-
- private void ViewResetMenuItem_Click(object sender, EventArgs e)
- {
- m_canvas.ResetZoomOrigin();
- }
-
- private void ViewZoomInMenuItem_Click(object sender, EventArgs e)
- {
- m_canvas.ZoomIn();
- }
-
- private void ViewZoomOutMenuItem_Click(object sender, EventArgs e)
- {
- m_canvas.ZoomOut();
- }
-
- private void ViewZoomFiftyPercentMenuItem_Click(object sender, EventArgs e)
- {
- m_canvas.ZoomFactor = 0.5f;
- }
-
- private void ViewZoomOneHundredPercentMenuItem_Click(object sender, EventArgs e)
- {
- m_canvas.ZoomFactor = 1.0f;
- }
-
- private void ViewZoomTwoHundredPercentMenuItem_Click(object sender, EventArgs e)
- {
- m_canvas.ZoomFactor = 2.0f;
- }
-
- private void EditRenameMenuItem_Click(object sender, EventArgs e)
- {
- if (m_canvas.HasSingleSelectedElement && m_canvas.SelectedElement.HasDialog)
- {
- m_canvas.SelectedElement.ShowDialog();
- }
- }
-
- private void EditIsDarkMenuItem_Click(object sender, EventArgs e)
- {
- foreach (var element in m_canvas.SelectedElements)
- {
- if (element is Room)
- {
- var room = (Room)element;
- room.IsDark = !room.IsDark;
- }
- }
- }
-
- private void ProjectSettingsMenuItem_Click(object sender, EventArgs e)
- {
- Settings.ShowDialog();
- }
-
- private void ProjectResetToDefaultSettingsMenuItem_Click(object sender, EventArgs e)
- {
- if (MessageBox.Show("Restore default settings?\n\nThis will revert any changes to settings in this project.", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
- {
- Settings.Reset();
- }
- }
-
- private void HelpAndSupportMenuItem_Click(object sender, EventArgs e)
- {
- try
- {
- Process.Start("http://trizbort.genstein.net/?help");
- }
- catch (Exception)
- {
- NewVersionDialog.CannotLaunchWebSite();
- }
- }
-
- private void CheckForUpdatesMenuItem_Click(object sender, EventArgs e)
- {
- NewVersionDialog.CheckForUpdatesAsync(this, true);
- }
-
- private void HelpAboutMenuItem_Click(object sender, EventArgs e)
- {
- using (var dialog = new AboutDialog())
- {
- dialog.ShowDialog();
- }
- }
-
- private void AutomapStartMenuItem_Click(object sender, EventArgs e)
- {
- using (var dialog = new AutomapDialog())
- {
- if (dialog.ShowDialog() == DialogResult.OK)
- {
- m_canvas.StartAutomapping(dialog.Data);
- }
- }
- }
-
- private void AutomapStopMenuItem_Click(object sender, EventArgs e)
- {
- m_canvas.StopAutomapping();
- }
-
- private void ViewMinimapMenuItem_Click(object sender, EventArgs e)
- {
- m_canvas.MinimapVisible = !m_canvas.MinimapVisible;
- Settings.ShowMiniMap = m_canvas.MinimapVisible;
- }
-
- private void FileMenu_DropDownOpening(object sender, EventArgs e)
- {
- // MRU list
- var existingItems = new List();
- foreach (ToolStripItem existingItem in m_fileRecentMapsMenuItem.DropDownItems)
- {
- existingItems.Add(existingItem);
- }
- foreach (var existingItem in existingItems)
- {
- existingItem.Click -= FileRecentProject_Click;
- existingItem.Dispose();
- }
- if (Settings.RecentProjects.Count == 0)
- {
- m_fileRecentMapsMenuItem.Enabled = false;
- }
- else
- {
- m_fileRecentMapsMenuItem.Enabled = true;
- var index = 1;
- foreach (var recentProject in Settings.RecentProjects)
- {
- var menuItem = new ToolStripMenuItem(string.Format("&{0} {1}", index++, recentProject));
- menuItem.Tag = recentProject;
- menuItem.Click += FileRecentProject_Click;
- m_fileRecentMapsMenuItem.DropDownItems.Add(menuItem);
- }
- }
- }
-
- private void EditSelectAllMenuItem_Click(object sender, EventArgs e)
- {
- m_canvas.SelectAll();
- }
-
- private void EditSelectNoneMenuItem_Click(object sender, EventArgs e)
- {
- m_canvas.SelectedElement = null;
- }
-
- private void ViewEntireMapMenuItem_Click(object sender, EventArgs e)
- {
- m_canvas.ZoomToFit();
- }
-
- [DllImport("gdi32.dll")]
- private static extern IntPtr CopyEnhMetaFile(IntPtr hemfSrc, string lpszFile);
-
- [DllImport("gdi32.dll")]
- private static extern int DeleteEnhMetaFile(IntPtr hemf);
-
- private string m_caption;
- private DateTime m_lastUpdateUITime;
- private static readonly TimeSpan IdleProcessingEveryNSeconds = TimeSpan.FromSeconds(0.2);
- }
-}
+/*
+ Copyright (c) 2010 by Genstein
+
+ This file is (or was originally) part of Trizbort, the Interactive Fiction Mapper.
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+*/
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.Windows.Forms;
+using System.Text;
+using System.IO;
+using System.Runtime.InteropServices;
+using System.Diagnostics;
+using System.Threading;
+using PdfSharp.Drawing;
+using PdfSharp.Pdf;
+using Trizbort.Export;
+
+namespace Trizbort
+{
+ internal partial class MainForm : Form
+ {
+ public MainForm()
+ {
+ InitializeComponent();
+
+ m_caption = Text;
+
+ Application.Idle += OnIdle;
+ m_lastUpdateUITime = DateTime.MinValue;
+
+ m_automapBar.StopClick += delegate(object sender, EventArgs e) { m_canvas.StopAutomapping(); };
+ }
+
+ private void MainForm_Load(object sender, EventArgs e)
+ {
+ m_canvas.MinimapVisible = Settings.ShowMiniMap;
+
+ var args = Environment.GetCommandLineArgs();
+ if (args.Length > 1 && File.Exists(args[1]))
+ {
+ try
+ {
+ BeginInvoke((MethodInvoker)delegate
+ {
+ OpenProject(args[1]);
+ });
+ }
+ catch (Exception)
+ {
+ }
+ }
+ NewVersionDialog.CheckForUpdatesAsync(this, false);
+ }
+
+ public Canvas Canvas
+ {
+ get { return m_canvas; }
+ }
+
+ private void FileNewMenuItem_Click(object sender, EventArgs e)
+ {
+ if (!CheckLoseProject())
+ return;
+
+ Project.Current = new Project();
+ Settings.Reset();
+ }
+
+ protected override void OnClosing(CancelEventArgs e)
+ {
+ if (!CheckLoseProject())
+ {
+ e.Cancel = true;
+ return;
+ }
+
+ Settings.SaveApplicationSettings();
+ m_canvas.StopAutomapping();
+
+ base.OnClosing(e);
+ }
+
+
+ private bool CheckLoseProject()
+ {
+ if (Project.Current.IsDirty)
+ {
+ // see if the user would like to save
+ var result = MessageBox.Show(this, string.Format("Do you want to save changes to {0}?", Project.Current.Name), Text, MessageBoxButtons.YesNoCancel);
+ switch (result)
+ {
+ case DialogResult.Yes:
+ // user would like to save
+ if (!SaveProject())
+ {
+ // didn't actually save; treat as cancel
+ return false;
+ }
+
+ // user saved; carry on
+ return true;
+
+ case DialogResult.No:
+ // user wouldn't like to save; carry on
+ return true;
+
+ default:
+ // user cancelled; cancel
+ return false;
+ }
+ }
+
+ // project doesn't need saving; carry on
+ return true;
+ }
+
+ private bool OpenProject()
+ {
+ if (!CheckLoseProject())
+ return false;
+
+ using (var dialog = new OpenFileDialog())
+ {
+ dialog.InitialDirectory = PathHelper.SafeGetDirectoryName(Settings.LastProjectFileName);
+ dialog.Filter = string.Format("{0}|All Files|*.*||", Project.FilterString);
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ Settings.LastProjectFileName = dialog.FileName;
+ return OpenProject(dialog.FileName);
+ }
+ }
+
+ return false;
+ }
+
+ private bool OpenProject(string fileName)
+ {
+ var project = new Project();
+ project.FileName = fileName;
+ if (project.Load())
+ {
+ Project.Current = project;
+ //AboutMap();
+ Settings.RecentProjects.Add(fileName);
+ return true;
+ }
+
+ return false;
+ }
+
+ private void AboutMap()
+ {
+ var project = Project.Current;
+ if (!string.IsNullOrEmpty(project.Title) || !string.IsNullOrEmpty(project.Author) || !string.IsNullOrEmpty(project.Description))
+ {
+ var builder = new StringBuilder();
+ if (!string.IsNullOrEmpty(project.Title))
+ {
+ builder.AppendLine(project.Title);
+ }
+ if (!string.IsNullOrEmpty(project.Author))
+ {
+ if (builder.Length > 0)
+ {
+ builder.AppendLine();
+ }
+ builder.AppendLine(string.Format("by {0}", project.Author));
+ }
+ if (!string.IsNullOrEmpty(project.Description))
+ {
+ if (builder.Length > 0)
+ {
+ builder.AppendLine();
+ }
+ builder.AppendLine(project.Description);
+ }
+ MessageBox.Show(builder.ToString(), Application.ProductName, MessageBoxButtons.OK);
+ }
+ }
+
+ private bool SaveProject()
+ {
+ if (!Project.Current.HasFileName)
+ {
+ return SaveAsProject();
+ }
+
+ if (Project.Current.Save())
+ {
+ Settings.RecentProjects.Add(Project.Current.FileName);
+ return true;
+ }
+ return false;
+ }
+
+ private bool SaveAsProject()
+ {
+ using (var dialog = new SaveFileDialog())
+ {
+ if (!string.IsNullOrEmpty(Project.Current.FileName))
+ {
+ dialog.FileName = Project.Current.FileName;
+ }
+ else
+ {
+ dialog.InitialDirectory = PathHelper.SafeGetDirectoryName(Settings.LastProjectFileName);
+ }
+ dialog.Filter = string.Format("{0}|All Files|*.*||", Project.FilterString);
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ Settings.LastProjectFileName = dialog.FileName;
+ Project.Current.FileName = dialog.FileName;
+ if (Project.Current.Save())
+ {
+ Settings.RecentProjects.Add(Project.Current.FileName);
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ private void FileOpenMenuItem_Click(object sender, EventArgs e)
+ {
+ OpenProject();
+ }
+
+ private void FileSaveMenuItem_Click(object sender, EventArgs e)
+ {
+ SaveProject();
+ }
+
+ private void FileSaveAsMenuItem_Click(object sender, EventArgs e)
+ {
+ SaveAsProject();
+ }
+
+ private void FileExportPDFMenuItem_Click(object sender, EventArgs e)
+ {
+ using (var dialog = new SaveFileDialog())
+ {
+ dialog.Filter = "PDF Files|*.pdf|All Files|*.*||";
+ dialog.Title = "Export PDF";
+ dialog.InitialDirectory = PathHelper.SafeGetDirectoryName(Settings.LastExportImageFileName);
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ try
+ {
+ Settings.LastExportImageFileName = dialog.FileName;
+
+ var doc = new PdfDocument();
+ doc.Info.Title = Project.Current.Title;
+ doc.Info.Author = Project.Current.Author;
+ doc.Info.Creator = Application.ProductName;
+ doc.Info.CreationDate = DateTime.Now;
+ doc.Info.Subject = Project.Current.Description;
+ var page = doc.AddPage();
+
+ var size = m_canvas.ComputeCanvasBounds(true).Size;
+ page.Width = new XUnit(size.X);
+ page.Height = new XUnit(size.Y);
+ using (var graphics = XGraphics.FromPdfPage(page))
+ {
+ m_canvas.Draw(graphics, true, size.X, size.Y);
+ }
+ doc.Save(dialog.FileName);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(Program.MainForm, string.Format("There was a problem exporting the map:\n\n{0}", ex.Message), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+
+ private void FileExportImageMenuItem_Click(object sender, EventArgs e)
+ {
+ using (var dialog = new SaveFileDialog())
+ {
+ dialog.Filter = "PNG Images|*.png|JPEG Images|*.jpg|BMP Images|*.bmp|Enhanced Metafiles (EMF)|*.emf|All Files|*.*||";
+ dialog.Title = "Export Image";
+ dialog.InitialDirectory = PathHelper.SafeGetDirectoryName(Settings.LastExportImageFileName);
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ Settings.LastExportImageFileName = dialog.InitialDirectory;
+
+ var format = ImageFormat.Png;
+ var ext = Path.GetExtension(dialog.FileName);
+ if (StringComparer.InvariantCultureIgnoreCase.Compare(ext, ".jpg") == 0
+ || StringComparer.InvariantCultureIgnoreCase.Compare(ext, ".jpeg") == 0)
+ {
+ format = ImageFormat.Jpeg;
+ }
+ else if (StringComparer.InvariantCultureIgnoreCase.Compare(ext, ".bmp") == 0)
+ {
+ format = ImageFormat.Bmp;
+ }
+ else if (StringComparer.InvariantCultureIgnoreCase.Compare(ext, ".emf") == 0)
+ {
+ format = ImageFormat.Emf;
+ }
+
+ var size = m_canvas.ComputeCanvasBounds(true).Size * m_canvas.ZoomFactor;
+ size.X = Numeric.Clamp(size.X, 16, 8192);
+ size.Y = Numeric.Clamp(size.Y, 16, 8192);
+
+ try
+ {
+ if (format == ImageFormat.Emf)
+ {
+ // export as a metafile
+ using (var nativeGraphics = Graphics.FromHwnd(m_canvas.Handle))
+ {
+ using (var stream = new MemoryStream())
+ {
+ try
+ {
+ var dc = nativeGraphics.GetHdc();
+ using (var metafile = new Metafile(stream, dc))
+ {
+ using (var imageGraphics = Graphics.FromImage(metafile))
+ {
+ using (var graphics = XGraphics.FromGraphics(imageGraphics, new XSize(size.X, size.Y)))
+ {
+ m_canvas.Draw(graphics, true, size.X, size.Y);
+ }
+ }
+ var handle = metafile.GetHenhmetafile();
+ var copy = CopyEnhMetaFile(handle, dialog.FileName);
+ DeleteEnhMetaFile(copy);
+ }
+ }
+ finally
+ {
+ nativeGraphics.ReleaseHdc();
+ }
+ }
+ }
+ }
+ else
+ {
+ // export as an image
+ using (var bitmap = new Bitmap((int)Math.Ceiling(size.X), (int)Math.Ceiling(size.Y)))
+ {
+ using (var imageGraphics = Graphics.FromImage(bitmap))
+ {
+ using (var graphics = XGraphics.FromGraphics(imageGraphics, new XSize(size.X, size.Y)))
+ {
+ m_canvas.Draw(graphics, true, size.X, size.Y);
+ }
+ }
+ bitmap.Save(dialog.FileName, format);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(Program.MainForm, string.Format("There was a problem exporting the map:\n\n{0}", ex.Message), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+
+ private void FileExportInform7MenuItem_Click(object sender, EventArgs e)
+ {
+ var fileName = Settings.LastExportInform7FileName;
+ if (ExportCode(ref fileName))
+ {
+ Settings.LastExportInform7FileName = fileName;
+ }
+ }
+
+ private void FileExportInform6MenuItem_Click(object sender, EventArgs e)
+ {
+ var fileName = Settings.LastExportInform6FileName;
+ if (ExportCode(ref fileName))
+ {
+ Settings.LastExportInform6FileName = fileName;
+ }
+ }
+
+ private void FileExportTadsMenuItem_Click(object sender, EventArgs e)
+ {
+ var fileName = Settings.LastExportTadsFileName;
+ if (ExportCode(ref fileName))
+ {
+ Settings.LastExportTadsFileName = fileName;
+ }
+ }
+
+ private bool ExportCode(ref string lastExportFileName) where T : CodeExporter, new()
+ {
+ using (var exporter = new T())
+ {
+ using (var dialog = new SaveFileDialog())
+ {
+ // compose filter string for file dialog
+ var filterString = string.Empty;
+ var filters = exporter.FileDialogFilters;
+ foreach (var filter in filters)
+ {
+ if (!string.IsNullOrEmpty(filterString))
+ {
+ filterString += "|";
+ }
+ filterString += string.Format("{0}|*{1}", filter.Key, filter.Value);
+ }
+
+ if (!string.IsNullOrEmpty(filterString))
+ {
+ filterString += "|";
+ }
+ filterString += "All Files|*.*||";
+ dialog.Filter = filterString;
+
+ // set default filter by extension
+ var extension = PathHelper.SafeGetExtension(lastExportFileName);
+ for (var filterIndex = 0; filterIndex < filters.Count; ++filterIndex)
+ {
+ if (StringComparer.InvariantCultureIgnoreCase.Compare(extension, filters[filterIndex].Value) == 0)
+ {
+ dialog.FilterIndex = filterIndex + 1; // 1 based index
+ break;
+ }
+ }
+
+ // show dialog
+ dialog.Title = exporter.FileDialogTitle;
+ dialog.InitialDirectory = PathHelper.SafeGetDirectoryName(lastExportFileName);
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ try
+ {
+ // export source code
+ exporter.Export(dialog.FileName);
+ lastExportFileName = dialog.FileName;
+ return true;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(Program.MainForm, string.Format("There was a problem exporting the map:\n\n{0}", ex.Message), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+
+ private void FileExitMenuItem_Click(object sender, EventArgs e)
+ {
+ Close();
+ }
+
+ private void EditAddRoomMenuItem_Click(object sender, EventArgs e)
+ {
+ m_canvas.AddRoom(false);
+ }
+
+ private void EditDeleteMenuItem_Click(object sender, EventArgs e)
+ {
+ m_canvas.DeleteSelection();
+ }
+
+ private void EditPropertiesMenuItem_Click(object sender, EventArgs e)
+ {
+ if (m_canvas.HasSingleSelectedElement && m_canvas.SelectedElement.HasDialog)
+ {
+ m_canvas.SelectedElement.ShowDialog();
+ }
+ }
+
+ private void PlainLinesMenuItem_Click(object sender, EventArgs e)
+ {
+ m_canvas.ApplyNewPlainConnectionSettings();
+ }
+
+ private void ToggleDottedLines_Click(object sender, EventArgs e)
+ {
+ switch (m_canvas.NewConnectionStyle)
+ {
+ case ConnectionStyle.Solid:
+ m_canvas.NewConnectionStyle = ConnectionStyle.Dashed;
+ break;
+ case ConnectionStyle.Dashed:
+ m_canvas.NewConnectionStyle = ConnectionStyle.Solid;
+ break;
+ }
+ m_canvas.ApplyConnectionStyle(m_canvas.NewConnectionStyle);
+ }
+
+ private void ToggleDirectionalLines_Click(object sender, EventArgs e)
+ {
+ switch (m_canvas.NewConnectionFlow)
+ {
+ case ConnectionFlow.TwoWay:
+ m_canvas.NewConnectionFlow = ConnectionFlow.OneWay;
+ break;
+ case ConnectionFlow.OneWay:
+ m_canvas.NewConnectionFlow = ConnectionFlow.TwoWay;
+ break;
+ }
+ m_canvas.ApplyConnectionFlow(m_canvas.NewConnectionFlow);
+ }
+
+ private void UpLinesMenuItem_Click(object sender, EventArgs e)
+ {
+ m_canvas.NewConnectionLabel = ConnectionLabel.Up;
+ m_canvas.ApplyConnectionLabel(m_canvas.NewConnectionLabel);
+ }
+
+ private void DownLinesMenuItem_Click(object sender, EventArgs e)
+ {
+ m_canvas.NewConnectionLabel = ConnectionLabel.Down;
+ m_canvas.ApplyConnectionLabel(m_canvas.NewConnectionLabel);
+ }
+
+ private void InLinesMenuItem_Click(object sender, EventArgs e)
+ {
+ m_canvas.NewConnectionLabel = ConnectionLabel.In;
+ m_canvas.ApplyConnectionLabel(m_canvas.NewConnectionLabel);
+ }
+
+ private void OutLinesMenuItem_Click(object sender, EventArgs e)
+ {
+ m_canvas.NewConnectionLabel = ConnectionLabel.Out;
+ m_canvas.ApplyConnectionLabel(m_canvas.NewConnectionLabel);
+ }
+
+ private void ReverseLineMenuItem_Click(object sender, EventArgs e)
+ {
+ m_canvas.ReverseLineDirection();
+ }
+
+ private void OnIdle(object sender, EventArgs e)
+ {
+ var now = DateTime.Now;
+ if (now - m_lastUpdateUITime > IdleProcessingEveryNSeconds)
+ {
+ m_lastUpdateUITime = now;
+ UpdateCommandUI();
+ }
+ }
+
+ private void UpdateCommandUI()
+ {
+ // caption
+ Text = string.Format("{0}{1} - {2}", Project.Current.Name, Project.Current.IsDirty ? "*" : string.Empty, m_caption);
+
+ // line drawing options
+ m_toggleDottedLinesButton.Checked = m_canvas.NewConnectionStyle == ConnectionStyle.Dashed;
+ m_toggleDottedLinesMenuItem.Checked = m_toggleDottedLinesButton.Checked;
+ m_toggleDirectionalLinesButton.Checked = m_canvas.NewConnectionFlow == ConnectionFlow.OneWay;
+ m_toggleDirectionalLinesMenuItem.Checked = m_toggleDirectionalLinesButton.Checked;
+ m_plainLinesMenuItem.Checked = !m_toggleDirectionalLinesMenuItem.Checked && !m_toggleDottedLinesMenuItem.Checked && m_canvas.NewConnectionLabel == ConnectionLabel.None;
+ m_upLinesMenuItem.Checked = m_canvas.NewConnectionLabel == ConnectionLabel.Up;
+ m_downLinesMenuItem.Checked = m_canvas.NewConnectionLabel == ConnectionLabel.Down;
+ m_inLinesMenuItem.Checked = m_canvas.NewConnectionLabel == ConnectionLabel.In;
+ m_outLinesMenuItem.Checked = m_canvas.NewConnectionLabel == ConnectionLabel.Out;
+
+ // selection-specific commands
+ bool hasSelectedElement = m_canvas.SelectedElement != null;
+ m_editDeleteMenuItem.Enabled = hasSelectedElement;
+ m_editPropertiesMenuItem.Enabled = m_canvas.HasSingleSelectedElement;
+ m_editIsDarkMenuItem.Enabled = hasSelectedElement;
+ m_editSelectNoneMenuItem.Enabled = hasSelectedElement;
+ m_editSelectAllMenuItem.Enabled = m_canvas.SelectedElementCount < Project.Current.Elements.Count;
+ m_editRenameMenuItem.Enabled = m_canvas.HasSingleSelectedElement && (m_canvas.SelectedElement is Room);
+ m_editIsDarkMenuItem.Checked = m_canvas.HasSingleSelectedElement && (m_canvas.SelectedElement is Room) && ((Room)m_canvas.SelectedElement).IsDark;
+ m_reverseLineMenuItem.Enabled = m_canvas.HasSelectedElement();
+
+ // automapping
+ m_automapStartMenuItem.Enabled = !m_canvas.IsAutomapping;
+ m_automapStopMenuItem.Enabled = m_canvas.IsAutomapping;
+ m_automapBar.Visible = m_canvas.IsAutomapping;
+ m_automapBar.Status = m_canvas.AutomappingStatus;
+
+ // minimap
+ m_viewMinimapMenuItem.Checked = m_canvas.MinimapVisible;
+
+ UpdateToolStripImages();
+ m_canvas.UpdateScrollBars();
+
+ Debug.WriteLine(m_canvas.Focused ? "Focused!" : "NOT FOCUSED");
+ }
+
+ private void FileRecentProject_Click(object sender, EventArgs e)
+ {
+ if (!CheckLoseProject())
+ {
+ return;
+ }
+
+ var fileName = (string)((ToolStripMenuItem)sender).Tag;
+ OpenProject(fileName);
+ }
+
+ private void UpdateToolStripImages()
+ {
+ foreach (ToolStripItem item in m_toolStrip.Items)
+ {
+ if (!(item is ToolStripButton))
+ continue;
+
+ var button = (ToolStripButton)item;
+ button.BackgroundImage = button.Checked ? Properties.Resources.ToolStripBackground2 : Properties.Resources.ToolStripBackground;
+ }
+ }
+
+ private void ViewResetMenuItem_Click(object sender, EventArgs e)
+ {
+ m_canvas.ResetZoomOrigin();
+ }
+
+ private void ViewZoomInMenuItem_Click(object sender, EventArgs e)
+ {
+ m_canvas.ZoomIn();
+ }
+
+ private void ViewZoomOutMenuItem_Click(object sender, EventArgs e)
+ {
+ m_canvas.ZoomOut();
+ }
+
+ private void ViewZoomFiftyPercentMenuItem_Click(object sender, EventArgs e)
+ {
+ m_canvas.ZoomFactor = 0.5f;
+ }
+
+ private void ViewZoomOneHundredPercentMenuItem_Click(object sender, EventArgs e)
+ {
+ m_canvas.ZoomFactor = 1.0f;
+ }
+
+ private void ViewZoomTwoHundredPercentMenuItem_Click(object sender, EventArgs e)
+ {
+ m_canvas.ZoomFactor = 2.0f;
+ }
+
+ private void EditRenameMenuItem_Click(object sender, EventArgs e)
+ {
+ if (m_canvas.HasSingleSelectedElement && m_canvas.SelectedElement.HasDialog)
+ {
+ m_canvas.SelectedElement.ShowDialog();
+ }
+ }
+
+ private void EditIsDarkMenuItem_Click(object sender, EventArgs e)
+ {
+ foreach (var element in m_canvas.SelectedElements)
+ {
+ if (element is Room)
+ {
+ var room = (Room)element;
+ room.IsDark = !room.IsDark;
+ }
+ }
+ }
+
+ private void ProjectSettingsMenuItem_Click(object sender, EventArgs e)
+ {
+ Settings.ShowMapDialog();
+ }
+
+ private void ApplicationSettingsMenuItem_Click(object sender, EventArgs e)
+ {
+ Settings.ShowAppDialog();
+ }
+
+ private void ProjectResetToDefaultSettingsMenuItem_Click(object sender, EventArgs e)
+ {
+ if (MessageBox.Show("Restore default settings?\n\nThis will revert any changes to settings in this project.", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
+ {
+ Settings.Reset();
+ }
+ }
+
+ private void HelpAndSupportMenuItem_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ Process.Start("http://trizbort.genstein.net/?help");
+ }
+ catch (Exception)
+ {
+ NewVersionDialog.CannotLaunchWebSite();
+ }
+ }
+
+ private void CheckForUpdatesMenuItem_Click(object sender, EventArgs e)
+ {
+ NewVersionDialog.CheckForUpdatesAsync(this, true);
+ }
+
+ private void HelpAboutMenuItem_Click(object sender, EventArgs e)
+ {
+ using (var dialog = new AboutDialog())
+ {
+ dialog.ShowDialog();
+ }
+ }
+
+ private void AutomapStartMenuItem_Click(object sender, EventArgs e)
+ {
+ using (var dialog = new AutomapDialog())
+ {
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ m_canvas.StartAutomapping(dialog.Data);
+ }
+ }
+ }
+
+ private void AutomapStopMenuItem_Click(object sender, EventArgs e)
+ {
+ m_canvas.StopAutomapping();
+ }
+
+ private void ViewMinimapMenuItem_Click(object sender, EventArgs e)
+ {
+ m_canvas.MinimapVisible = !m_canvas.MinimapVisible;
+ Settings.ShowMiniMap = m_canvas.MinimapVisible;
+ }
+
+ private void FileMenu_DropDownOpening(object sender, EventArgs e)
+ {
+ // MRU list
+ var existingItems = new List();
+ foreach (ToolStripItem existingItem in m_fileRecentMapsMenuItem.DropDownItems)
+ {
+ existingItems.Add(existingItem);
+ }
+ foreach (var existingItem in existingItems)
+ {
+ existingItem.Click -= FileRecentProject_Click;
+ existingItem.Dispose();
+ }
+ if (Settings.RecentProjects.Count == 0)
+ {
+ m_fileRecentMapsMenuItem.Enabled = false;
+ }
+ else
+ {
+ m_fileRecentMapsMenuItem.Enabled = true;
+ var index = 1;
+ foreach (var recentProject in Settings.RecentProjects)
+ {
+ var menuItem = new ToolStripMenuItem(string.Format("&{0} {1}", index++, recentProject));
+ menuItem.Tag = recentProject;
+ menuItem.Click += FileRecentProject_Click;
+ m_fileRecentMapsMenuItem.DropDownItems.Add(menuItem);
+ }
+ }
+ }
+
+ private void EditSelectAllMenuItem_Click(object sender, EventArgs e)
+ {
+ m_canvas.SelectAll();
+ }
+
+ private void EditSelectNoneMenuItem_Click(object sender, EventArgs e)
+ {
+ m_canvas.SelectedElement = null;
+ }
+
+ private void ViewEntireMapMenuItem_Click(object sender, EventArgs e)
+ {
+ m_canvas.ZoomToFit();
+ }
+
+ [DllImport("gdi32.dll")]
+ private static extern IntPtr CopyEnhMetaFile(IntPtr hemfSrc, string lpszFile);
+
+ [DllImport("gdi32.dll")]
+ private static extern int DeleteEnhMetaFile(IntPtr hemf);
+
+ private string m_caption;
+ private DateTime m_lastUpdateUITime;
+ private static readonly TimeSpan IdleProcessingEveryNSeconds = TimeSpan.FromSeconds(0.2);
+ }
+}
diff --git a/Settings.cs b/Settings.cs
index dd35760..2169b45 100644
--- a/Settings.cs
+++ b/Settings.cs
@@ -1,926 +1,960 @@
-/*
- Copyright (c) 2010 by Genstein
-
- This file is (or was originally) part of Trizbort, the Interactive Fiction Mapper.
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
-*/
-
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Windows.Forms;
-using System.Globalization;
-using System.Text;
-using System.IO;
-using System.Xml;
-
-namespace Trizbort
-{
- internal static class Settings
- {
- static Settings()
- {
- Reset();
- ResetApplicationSettings();
- LoadApplicationSettings();
- }
-
- static void ResetApplicationSettings()
- {
- s_dontCareAboutVersion = new Version(0, 0, 0, 0);
- s_automap = AutomapSettings.Default;
- s_infiniteScrollBounds = false;
- s_showMinimap = true;
- s_recentProjects.Clear();
- // TODO: add other application settings here
- }
-
- static void LoadApplicationSettings()
- {
- try
- {
- if (File.Exists(ApplicationSettingsPath))
- {
- var doc = new XmlDocument();
- doc.Load(ApplicationSettingsPath);
- var root = new XmlElementReader(doc.DocumentElement);
- if (root.Name == "settings")
- {
- var versionText = root["dontCareAboutVersion"].Text;
- if (!string.IsNullOrEmpty(versionText))
- {
- s_dontCareAboutVersion = new Version(versionText);
- }
- s_infiniteScrollBounds = root["infiniteScrollBounds"].ToBool(s_infiniteScrollBounds);
- s_showMinimap = root["showMiniMap"].ToBool(s_showMinimap);
-
- s_lastProjectFileName = root["lastProjectFileName"].Text;
- s_lastExportImageFileName = root["lastExportedImageFileName"].Text;
- s_lastExportInform7FileName = root["lastExportedInform7FileName"].Text;
- s_lastExportInform6FileName = root["lastExportedInform6FileName"].Text;
- s_lastExportTadsFileName = root["lastExportedTadsFileName"].Text;
-
- var recentProjects = root["recentProjects"];
- var fileName = string.Empty;
- var index = 0;
- do
- {
- fileName = recentProjects[string.Format("fileName{0}", index++)].Text;
- if (!string.IsNullOrEmpty(fileName))
- {
- s_recentProjects.Append(fileName);
- }
- } while (!string.IsNullOrEmpty(fileName));
-
- var automap = root["automap"];
- s_automap.FileName = automap["transcriptFileName"].ToText(s_automap.FileName);
- s_automap.VerboseTranscript = automap["verboseTranscript"].ToBool(s_automap.VerboseTranscript);
- s_automap.AssumeRoomsWithSameNameAreSameRoom = automap["assumeRoomsWithSameNameAreSameRoom"].ToBool(s_automap.AssumeRoomsWithSameNameAreSameRoom);
- s_automap.GuessExits = automap["guessExits"].ToBool(s_automap.GuessExits);
- s_automap.AddObjectCommand = automap["addObjectCommand"].ToText(s_automap.AddObjectCommand);
- }
- }
- }
- catch (Exception)
- {
- }
- }
-
- static string ApplicationSettingsPath
- {
- get
- {
- return Path.Combine(Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Genstein"), "Trizbort"), "Settings.xml");
- }
- }
-
- public static void SaveApplicationSettings()
- {
- try
- {
- Directory.CreateDirectory(Path.GetDirectoryName(ApplicationSettingsPath));
- using (var scribe = XmlScribe.Create(ApplicationSettingsPath))
- {
- scribe.StartElement("settings");
- scribe.Element("dontCareAboutVersion", s_dontCareAboutVersion.ToString());
- scribe.Element("infiniteScrollBounds", s_infiniteScrollBounds);
- scribe.Element("showMiniMap", s_showMinimap);
-
- scribe.Element("lastProjectFileName", s_lastProjectFileName);
- scribe.Element("lastExportedImageFileName", s_lastExportImageFileName);
- scribe.Element("lastExportedInform7FileName", s_lastExportInform7FileName);
- scribe.Element("lastExportedInform6FileName", s_lastExportInform6FileName);
- scribe.Element("lastExportedTadsFileName", s_lastExportTadsFileName);
-
- scribe.StartElement("recentProjects");
- var index = 0;
- foreach (var fileName in s_recentProjects)
- {
- scribe.Element(string.Format("fileName{0}", index++), fileName);
- }
- scribe.EndElement();
-
- scribe.StartElement("automap");
- scribe.Element("transcriptFileName", s_automap.FileName);
- scribe.Element("verboseTranscript", s_automap.VerboseTranscript);
- scribe.Element("assumeRoomsWithSameNameAreSameRoom", s_automap.AssumeRoomsWithSameNameAreSameRoom);
- scribe.Element("guessExits", s_automap.GuessExits);
- scribe.Element("addObjectCommand", s_automap.AddObjectCommand);
- scribe.EndElement();
- }
- }
- catch (Exception)
- {
- }
- }
-
- public static ColorSettings Color
- {
- get { return s_colorSettings; }
- }
-
- public static Font LargeFont
- {
- get { return s_largeFont; }
- set
- {
- if (s_largeFont != value)
- {
- s_largeFont = value;
- RaiseChanged();
- }
- }
- }
-
- public static Font SmallFont
- {
- get { return s_smallFont; }
- set
- {
- if (s_smallFont != value)
- {
- s_smallFont = value;
- RaiseChanged();
- }
- }
- }
-
- public static Font LineFont
- {
- get { return s_lineFont; }
- set
- {
- if (s_lineFont != value)
- {
- s_lineFont = value;
- RaiseChanged();
- }
- }
- }
-
- public static bool HandDrawn
- {
- get { return s_handDrawn; }
- set
- {
- if (s_handDrawn != value)
- {
- s_handDrawn = value;
- RaiseChanged();
- }
- }
- }
-
- public static bool HandDrawnUnchecked
- {
- get { return s_handDrawn; }
- set { s_handDrawn = value; }
- }
-
- public static float LineWidth
- {
- get { return s_lineWidth; }
- set
- {
- if (s_lineWidth != value)
- {
- s_lineWidth = value;
- RaiseChanged();
- }
- }
- }
-
- public static bool SnapToGrid
- {
- get { return s_snapToGrid; }
- set
- {
- if (s_snapToGrid != value)
- {
- s_snapToGrid = value;
- RaiseChanged();
- }
- }
- }
-
- public static float GridSize
- {
- get { return s_gridSize; }
- set
- {
- if (s_gridSize != value)
- {
- s_gridSize = value;
- RaiseChanged();
- }
- }
- }
-
- public static bool IsGridVisible
- {
- get { return s_isGridVisible; }
- set
- {
- if (s_isGridVisible != value)
- {
- s_isGridVisible = value;
- RaiseChanged();
- }
- }
- }
-
- public static bool ShowOrigin
- {
- get { return s_showOrigin; }
- set
- {
- if (s_showOrigin != value)
- {
- s_showOrigin = value;
- RaiseChanged();
- }
- }
- }
-
- public static float DarknessStripeSize
- {
- get { return s_darknessStripeSize; }
- set
- {
- if (s_darknessStripeSize != value)
- {
- s_darknessStripeSize = value;
- RaiseChanged();
- }
- }
- }
-
- public static float ObjectListOffsetFromRoom
- {
- get { return s_objectListOffsetFromRoom; }
- set
- {
- if (s_objectListOffsetFromRoom != value)
- {
- s_objectListOffsetFromRoom = value;
- RaiseChanged();
- }
- }
- }
-
- public static float HandleSize
- {
- get { return s_handleSize; }
- set
- {
- if (s_handleSize != value)
- {
- s_handleSize = value;
- RaiseChanged();
- }
- }
- }
-
- public static float SnapToElementSize
- {
- get { return s_snapToElementSize; }
- set
- {
- if (s_snapToElementSize != value)
- {
- s_snapToElementSize = value;
- RaiseChanged();
- }
- }
- }
-
- public static float DragDistanceToInitiateNewConnection
- {
- get { return s_dragDistanceToInitiateNewConnection; }
- set
- {
- if (s_dragDistanceToInitiateNewConnection != value)
- {
- s_dragDistanceToInitiateNewConnection = value;
- RaiseChanged();
- }
- }
- }
-
- public static float ConnectionStalkLength
- {
- get { return s_connectionStalkLength; }
- set
- {
- if (s_connectionStalkLength != value)
- {
- s_connectionStalkLength = value;
- RaiseChanged();
- }
- }
- }
-
- public static float PreferredDistanceBetweenRooms
- {
- get { return s_preferredDistanceBetweenRooms; }
- set
- {
- if (s_preferredDistanceBetweenRooms != value)
- {
- s_preferredDistanceBetweenRooms = value;
- RaiseChanged();
- }
- }
- }
-
- public static float TextOffsetFromConnection
- {
- get { return s_textOffsetFromConnection; }
- set
- {
- if (s_textOffsetFromConnection != value)
- {
- s_textOffsetFromConnection = value;
- RaiseChanged();
- }
- }
- }
-
- public static float ConnectionArrowSize
- {
- get { return s_connectionArrowSize; }
- set
- {
- if (s_connectionArrowSize != value)
- {
- s_connectionArrowSize = value;
- RaiseChanged();
- }
- }
- }
-
- ///
- /// Get/set the modifier keys required, along with a numeric keypad key,
- /// to create new rooms from the currently selected room.
- ///
- public static Keys KeypadNavigationCreationModifier
- {
- get { return s_keypadNavigationCreationModifier; }
- set
- {
- if (s_keypadNavigationCreationModifier != value)
- {
- s_keypadNavigationCreationModifier = value;
- RaiseChanged();
- }
- }
- }
-
- ///
- /// Get/set the modifier keys required, along with a numeric keypad key,
- /// to mark "unexplored" connections from the currently selected room.
- ///
- public static Keys KeypadNavigationUnexploredModifier
- {
- get { return s_keypadNavigationUnexploredModifier; }
- set
- {
- if (s_keypadNavigationUnexploredModifier != value)
- {
- s_keypadNavigationUnexploredModifier = value;
- RaiseChanged();
- }
- }
- }
-
- public static float Snap(float value)
- {
- float offset = 0;
- while (value < GridSize)
- {
- value += GridSize;
- offset += GridSize;
- }
-
- var mod = value % GridSize;
- if (SnapToGrid && mod != 0)
- {
- if (mod < GridSize / 2)
- {
- value -= mod;
- }
- else
- {
- value = value + GridSize - mod;
- }
- }
-
- return value - offset;
- }
-
- public static Vector Snap(Vector pos)
- {
- if (SnapToGrid)
- {
- pos.X = Snap(pos.X);
- pos.Y = Snap(pos.Y);
- }
- return pos;
- }
-
- public static event EventHandler Changed;
-
- private static void RaiseChanged()
- {
- var changed = Changed;
- if (changed != null)
- {
- changed(null, EventArgs.Empty);
- }
- }
-
- public static void ShowDialog()
- {
- using (var dialog = new SettingsDialog())
- {
- for (int index = 0; index < Colors.Count; ++index)
- {
- dialog.Color[index] = Color[index];
- }
-
- dialog.Title = Project.Current.Title;
- dialog.Author = Project.Current.Author;
- dialog.Description = Project.Current.Description;
- dialog.History = Project.Current.History;
- dialog.LargeFont = LargeFont;
- dialog.SmallFont = SmallFont;
- dialog.LineFont = LineFont;
- dialog.HandDrawn = HandDrawn;
- dialog.LineWidth = LineWidth;
- dialog.SnapToGrid = SnapToGrid;
- dialog.GridSize = GridSize;
- dialog.IsGridVisible = IsGridVisible;
- dialog.ShowOrigin = ShowOrigin;
- dialog.DarknessStripeSize = DarknessStripeSize;
- dialog.ObjectListOffsetFromRoom = ObjectListOffsetFromRoom;
- dialog.ConnectionStalkLength = ConnectionStalkLength;
- dialog.PreferredDistanceBetweenRooms = PreferredDistanceBetweenRooms;
- dialog.TextOffsetFromConnection = TextOffsetFromConnection;
- dialog.HandleSize = HandleSize;
- dialog.SnapToElementSize = SnapToElementSize;
- dialog.ConnectionArrowSize = ConnectionArrowSize;
- if (dialog.ShowDialog() == DialogResult.OK)
- {
- for (int index = 0; index < Colors.Count; ++index)
- {
- Color[index] = dialog.Color[index];
- }
- Project.Current.Title = dialog.Title;
- Project.Current.Author = dialog.Author;
- Project.Current.Description = dialog.Description;
- Project.Current.History = dialog.History;
- LargeFont = dialog.LargeFont;
- SmallFont = dialog.SmallFont;
- LineFont = dialog.LineFont;
- HandDrawn = dialog.HandDrawn;
- LineWidth = dialog.LineWidth;
- SnapToGrid = dialog.SnapToGrid;
- GridSize = dialog.GridSize;
- IsGridVisible = dialog.IsGridVisible;
- ShowOrigin = dialog.ShowOrigin;
- DarknessStripeSize = dialog.DarknessStripeSize;
- ObjectListOffsetFromRoom = dialog.ObjectListOffsetFromRoom;
- ConnectionStalkLength = dialog.ConnectionStalkLength;
- PreferredDistanceBetweenRooms = dialog.PreferredDistanceBetweenRooms;
- TextOffsetFromConnection = dialog.TextOffsetFromConnection;
- HandleSize = dialog.HandleSize;
- SnapToElementSize = dialog.SnapToElementSize;
- ConnectionArrowSize = dialog.ConnectionArrowSize;
- }
- }
- }
-
- public static void Reset()
- {
- Color[Colors.Canvas] = System.Drawing.Color.White;
- Color[Colors.Fill] = System.Drawing.Color.White;
- Color[Colors.Border] = System.Drawing.Color.MidnightBlue;
- Color[Colors.Line] = System.Drawing.Color.MidnightBlue;
- Color[Colors.HoverLine] = System.Drawing.Color.DarkOrange;
- Color[Colors.SelectedLine] = System.Drawing.Color.SteelBlue;
- Color[Colors.LargeText] = System.Drawing.Color.MidnightBlue;
- Color[Colors.SmallText] = System.Drawing.Color.MidnightBlue;
- Color[Colors.LineText] = System.Drawing.Color.MidnightBlue;
- Color[Colors.Grid] = Drawing.Mix(System.Drawing.Color.White, System.Drawing.Color.Black, 25, 1);
-
- LargeFont = new Font("Comic Sans MS", 13.0f, FontStyle.Regular, GraphicsUnit.World);
- SmallFont = new Font("Comic Sans MS", 11.0f, FontStyle.Regular, GraphicsUnit.World);
- LineFont = new Font("Comic Sans MS", 9.0f, FontStyle.Regular, GraphicsUnit.World);
-
- LineWidth = 2.0f;
- HandDrawn = true;
-
- SnapToGrid = true;
- IsGridVisible = true;
- GridSize = 32.0f;
- ShowOrigin = true;
-
- DarknessStripeSize = 24.0f;
- ObjectListOffsetFromRoom = 4.0f;
-
- ConnectionStalkLength = 32.0f;
- PreferredDistanceBetweenRooms = ConnectionStalkLength * 2;
- TextOffsetFromConnection = 4.0f;
- HandleSize = 12.0f;
- SnapToElementSize = 16.0f;
- DragDistanceToInitiateNewConnection = 32f;
- ConnectionArrowSize = 12.0f;
-
- KeypadNavigationCreationModifier = Keys.Control;
- KeypadNavigationUnexploredModifier = Keys.Alt;
- }
-
- public static void Save(XmlScribe scribe)
- {
- // save colors
- scribe.StartElement("colors");
- for (int index = 0; index < Colors.Count; ++index)
- {
- string colorName;
- if (Colors.ToName(index, out colorName))
- {
- scribe.Element(colorName, Color[index]);
- }
- }
- scribe.EndElement();
-
- // save fonts
- scribe.StartElement("fonts");
- SaveFont(scribe, s_largeFont, "room");
- SaveFont(scribe, s_smallFont, "object");
- SaveFont(scribe, s_lineFont, "line");
- scribe.EndElement();
-
- scribe.StartElement("grid");
- scribe.Element("snapTo", s_snapToGrid);
- scribe.Element("visible", s_isGridVisible);
- scribe.Element("showOrigin", s_showOrigin);
- scribe.Element("size", s_gridSize);
- scribe.EndElement();
-
- scribe.StartElement("lines");
- scribe.Element("width", s_lineWidth);
- scribe.Element("handDrawn", s_handDrawn);
- scribe.Element("arrowSize", s_connectionArrowSize);
- scribe.Element("textOffset", s_textOffsetFromConnection);
- scribe.EndElement();
-
- scribe.StartElement("rooms");
- scribe.Element("darknessStripeSize", s_darknessStripeSize);
- scribe.Element("objectListOffset", s_objectListOffsetFromRoom);
- scribe.Element("connectionStalkLength", s_connectionStalkLength);
- scribe.Element("preferredDistanceBetweenRooms", s_preferredDistanceBetweenRooms);
- scribe.EndElement();
-
- scribe.StartElement("ui");
- scribe.Element("handleSize", s_handleSize);
- scribe.Element("snapToElementSize", s_snapToElementSize);
- scribe.EndElement();
-
- scribe.StartElement("keypadNavigation");
- scribe.Element("creationModifier", ModifierKeysToString(s_keypadNavigationCreationModifier));
- scribe.Element("unexploredModifier", ModifierKeysToString(s_keypadNavigationUnexploredModifier));
- scribe.EndElement();
-
- SaveApplicationSettings();
- }
-
- private static string ModifierKeysToString(Keys key)
- {
- var builder = new StringBuilder();
- if ((key & Keys.Shift) == Keys.Shift)
- {
- if (builder.Length != 0)
- builder.Append("|");
- builder.Append("shift");
- }
- if ((key & Keys.Control) == Keys.Control)
- {
- if (builder.Length != 0)
- builder.Append("|");
- builder.Append("control");
- }
- if ((key & Keys.Alt) == Keys.Alt)
- {
- if (builder.Length != 0)
- builder.Append("|");
- builder.Append("alt");
- }
- if (builder.Length == 0)
- {
- builder.Append("none");
- }
- return builder.ToString();
- }
-
- private static Keys StringToModifierKeys(string text, Keys defaultValue)
- {
- if (string.IsNullOrEmpty(text))
- {
- return defaultValue;
- }
-
- Keys value = Keys.None;
- foreach (var part in text.Split('|'))
- {
- if (StringComparer.InvariantCultureIgnoreCase.Compare(part, "shift") == 0)
- {
- value |= Keys.Shift;
- }
- else if (StringComparer.InvariantCultureIgnoreCase.Compare(part, "control") == 0)
- {
- value |= Keys.Control;
- }
- else if (StringComparer.InvariantCultureIgnoreCase.Compare(part, "alt") == 0)
- {
- value |= Keys.Alt;
- }
- // Note that "none" is also an allowed value.
- }
- return value;
- }
-
- private static void SaveFont(XmlScribe scribe, Font font, string name)
- {
- scribe.StartElement(name);
- scribe.Attribute("size", font.Size);
- if ((font.Style & FontStyle.Bold) == FontStyle.Bold)
- {
- scribe.Attribute("bold", true);
- }
- if ((font.Style & FontStyle.Italic) == FontStyle.Italic)
- {
- scribe.Attribute("italic", true);
- }
- if ((font.Style & FontStyle.Underline) == FontStyle.Underline)
- {
- scribe.Attribute("underline", true);
- }
- if ((font.Style & FontStyle.Strikeout) == FontStyle.Strikeout)
- {
- scribe.Attribute("strikeout", true);
- }
- scribe.Value(Drawing.FontName(font));
- scribe.EndElement();
- }
-
- public static void Load(XmlElementReader element)
- {
- var colors = element["colors"];
- foreach (var color in colors.Children)
- {
- int index;
- if (Colors.FromName(color.Name, out index))
- {
- Color[index] = color.ToColor(Color[index]);
- }
- }
-
- var fonts = element["fonts"];
- foreach (var font in fonts.Children)
- {
- var style = FontStyle.Regular;
- if (font.Attribute("bold").ToBool())
- {
- style |= FontStyle.Bold;
- }
- if (font.Attribute("italic").ToBool())
- {
- style |= FontStyle.Italic;
- }
- if (font.Attribute("underline").ToBool())
- {
- style |= FontStyle.Underline;
- }
- if (font.Attribute("strikeout").ToBool())
- {
- style |= FontStyle.Strikeout;
- }
- if (font.Name == "room")
- {
- LargeFont = new Font(font.ToText(LargeFont.Name), Numeric.Clamp(font.Attribute("size").ToFloat(LargeFont.Size), MinFontSize, MaxFontSize), style, GraphicsUnit.World);
- }
- else if (font.Name == "object")
- {
- SmallFont = new Font(font.ToText(SmallFont.Name), Numeric.Clamp(font.Attribute("size").ToFloat(SmallFont.Size), MinFontSize, MaxFontSize), style, GraphicsUnit.World);
- }
- else if (font.Name == "line")
- {
- LineFont = new Font(font.ToText(SmallFont.Name), Numeric.Clamp(font.Attribute("size").ToFloat(LineFont.Size), MinFontSize, MaxFontSize), style, GraphicsUnit.World);
- }
- }
-
- SnapToGrid = element["grid"]["snapTo"].ToBool(s_snapToGrid);
- IsGridVisible = element["grid"]["visible"].ToBool(s_isGridVisible);
- GridSize = element["grid"]["size"].ToFloat(s_gridSize);
- ShowOrigin = element["grid"]["showOrigin"].ToBool(s_showOrigin);
-
- LineWidth = element["lines"]["width"].ToFloat(s_lineWidth);
- HandDrawn = element["lines"]["handDrawn"].ToBool(s_handDrawn);
- ConnectionArrowSize = element["lines"]["arrowSize"].ToFloat(s_connectionArrowSize);
- TextOffsetFromConnection = element["lines"]["textOffset"].ToFloat(s_textOffsetFromConnection);
-
- DarknessStripeSize = element["rooms"]["darknessStripeSize"].ToFloat(s_darknessStripeSize);
- ObjectListOffsetFromRoom = element["rooms"]["objectListOffset"].ToFloat(s_objectListOffsetFromRoom);
- ConnectionStalkLength = element["rooms"]["connectionStalkLength"].ToFloat(s_connectionStalkLength);
- PreferredDistanceBetweenRooms = element["rooms"]["preferredDistanceBetweenRooms"].ToFloat(s_connectionStalkLength * 2); // introduced in v1.2, hence default based on existing setting
-
- HandleSize = element["ui"]["handleSize"].ToFloat(s_handleSize);
- SnapToElementSize = element["ui"]["snapToElementSize"].ToFloat(s_snapToElementSize);
-
- KeypadNavigationCreationModifier = StringToModifierKeys(element["keypadNavigation"]["creationModifier"].Text, s_keypadNavigationCreationModifier);
- KeypadNavigationUnexploredModifier = StringToModifierKeys(element["keypadNavigation"]["unexploredModifier"].Text, s_keypadNavigationUnexploredModifier);
- }
-
- public class ColorSettings
- {
- public Color this[int index]
- {
- get { return Settings.s_color[index]; }
- set
- {
- if (Settings.s_color[index] != value)
- {
- Settings.s_color[index] = value;
- Settings.RaiseChanged();
- }
- }
- }
- }
-
- public static bool DebugShowFPS
- {
- get;
- set;
- }
-
- public static bool DebugDisableTextRendering
- {
- get;
- set;
- }
-
- public static bool DebugDisableLineRendering
- {
- get;
- set;
- }
-
- public static bool DebugDisableElementRendering
- {
- get;
- set;
- }
-
- public static bool DebugDisableGridPolyline
- {
- get;
- set;
- }
-
- public static Version DontCareAboutVersion
- {
- get { return s_dontCareAboutVersion; }
- set { s_dontCareAboutVersion = value; }
- }
-
- public static AutomapSettings Automap
- {
- get { return s_automap; }
- set { s_automap = value; }
- }
-
- public static bool InfiniteScrollBounds
- {
- get { return s_infiniteScrollBounds; }
- set { s_infiniteScrollBounds = value; }
- }
-
- public static bool ShowMiniMap
- {
- get { return s_showMinimap; }
- set { s_showMinimap = value; }
- }
-
- public static string LastProjectFileName
- {
- get { return s_lastProjectFileName; }
- set { s_lastProjectFileName = value; }
- }
-
- public static string LastExportImageFileName
- {
- get { return s_lastExportImageFileName; }
- set { s_lastExportImageFileName = value; }
- }
-
- public static string LastExportInform7FileName
- {
- get { return s_lastExportInform7FileName; }
- set { s_lastExportInform7FileName = value; }
- }
-
- public static string LastExportInform6FileName
- {
- get { return s_lastExportInform6FileName; }
- set { s_lastExportInform6FileName = value; }
- }
-
- public static string LastExportTadsFileName
- {
- get { return s_lastExportTadsFileName; }
- set { s_lastExportTadsFileName = value; }
- }
-
- public static MruList RecentProjects
- {
- get { return s_recentProjects; }
- }
-
- private static readonly float MinFontSize = 2;
- private static readonly float MaxFontSize = 256;
-
- // per-map settings, saved with the map
- private static Color[] s_color = new Color[Colors.Count];
- private static ColorSettings s_colorSettings = new ColorSettings();
- private static Font s_largeFont;
- private static Font s_smallFont;
- private static Font s_lineFont;
- private static float s_lineWidth;
- private static bool s_handDrawn;
- private static bool s_snapToGrid;
- private static bool s_isGridVisible;
- private static bool s_showOrigin;
- private static float s_gridSize;
- private static float s_darknessStripeSize;
- private static float s_objectListOffsetFromRoom;
- private static float s_connectionStalkLength;
- private static float s_preferredDistanceBetweenRooms;
- private static float s_textOffsetFromConnection;
- private static float s_handleSize;
- private static float s_snapToElementSize;
- private static float s_dragDistanceToInitiateNewConnection;
- private static float s_connectionArrowSize;
- private static Keys s_keypadNavigationCreationModifier;
- private static Keys s_keypadNavigationUnexploredModifier;
-
- // application settings, saved for the user
- private static Version s_dontCareAboutVersion;
- private static AutomapSettings s_automap;
- private static bool s_infiniteScrollBounds;
- private static bool s_showMinimap;
- private static string s_lastProjectFileName;
- private static string s_lastExportImageFileName;
- private static string s_lastExportInform7FileName;
- private static string s_lastExportInform6FileName;
- private static string s_lastExportTadsFileName;
- private static MruList s_recentProjects = new MruList();
- }
-}
+/*
+ Copyright (c) 2010 by Genstein
+
+ This file is (or was originally) part of Trizbort, the Interactive Fiction Mapper.
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+*/
+
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Windows.Forms;
+using System.Globalization;
+using System.Text;
+using System.IO;
+using System.Xml;
+
+namespace Trizbort
+{
+ internal static class Settings
+ {
+ static Settings()
+ {
+ Reset();
+ ResetApplicationSettings();
+ LoadApplicationSettings();
+ }
+
+ static void ResetApplicationSettings()
+ {
+ s_dontCareAboutVersion = new Version(0, 0, 0, 0);
+ s_automap = AutomapSettings.Default;
+ s_infiniteScrollBounds = false;
+ s_showMinimap = true;
+ s_recentProjects.Clear();
+ s_invertMouseWheel = false;
+ s_dragButton = 0;
+ // TODO: add other application settings here
+ }
+
+ static void LoadApplicationSettings()
+ {
+ try
+ {
+ if (File.Exists(ApplicationSettingsPath))
+ {
+ var doc = new XmlDocument();
+ doc.Load(ApplicationSettingsPath);
+ var root = new XmlElementReader(doc.DocumentElement);
+ if (root.Name == "settings")
+ {
+ var versionText = root["dontCareAboutVersion"].Text;
+ if (!string.IsNullOrEmpty(versionText))
+ {
+ s_dontCareAboutVersion = new Version(versionText);
+ }
+ s_dragButton = root["dragButton"].ToInt(s_dragButton);
+ s_invertMouseWheel = root["invertMouseWheel"].ToBool(s_invertMouseWheel);
+ s_infiniteScrollBounds = root["infiniteScrollBounds"].ToBool(s_infiniteScrollBounds);
+ s_showMinimap = root["showMiniMap"].ToBool(s_showMinimap);
+
+ s_lastProjectFileName = root["lastProjectFileName"].Text;
+ s_lastExportImageFileName = root["lastExportedImageFileName"].Text;
+ s_lastExportInform7FileName = root["lastExportedInform7FileName"].Text;
+ s_lastExportInform6FileName = root["lastExportedInform6FileName"].Text;
+ s_lastExportTadsFileName = root["lastExportedTadsFileName"].Text;
+
+ var recentProjects = root["recentProjects"];
+ var fileName = string.Empty;
+ var index = 0;
+ do
+ {
+ fileName = recentProjects[string.Format("fileName{0}", index++)].Text;
+ if (!string.IsNullOrEmpty(fileName))
+ {
+ s_recentProjects.Append(fileName);
+ }
+ } while (!string.IsNullOrEmpty(fileName));
+
+ var automap = root["automap"];
+ s_automap.FileName = automap["transcriptFileName"].ToText(s_automap.FileName);
+ s_automap.VerboseTranscript = automap["verboseTranscript"].ToBool(s_automap.VerboseTranscript);
+ s_automap.AssumeRoomsWithSameNameAreSameRoom = automap["assumeRoomsWithSameNameAreSameRoom"].ToBool(s_automap.AssumeRoomsWithSameNameAreSameRoom);
+ s_automap.GuessExits = automap["guessExits"].ToBool(s_automap.GuessExits);
+ s_automap.AddObjectCommand = automap["addObjectCommand"].ToText(s_automap.AddObjectCommand);
+ }
+ }
+ }
+ catch (Exception)
+ {
+ }
+ }
+
+ static string ApplicationSettingsPath
+ {
+ get
+ {
+ return Path.Combine(Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Genstein"), "Trizbort"), "Settings.xml");
+ }
+ }
+
+ public static void SaveApplicationSettings()
+ {
+ try
+ {
+ Directory.CreateDirectory(Path.GetDirectoryName(ApplicationSettingsPath));
+ using (var scribe = XmlScribe.Create(ApplicationSettingsPath))
+ {
+ scribe.StartElement("settings");
+ scribe.Element("dontCareAboutVersion", s_dontCareAboutVersion.ToString());
+ scribe.Element("dragButton", s_dragButton);
+ scribe.Element("invertMouseWheel", s_invertMouseWheel);
+ scribe.Element("infiniteScrollBounds", s_infiniteScrollBounds);
+ scribe.Element("showMiniMap", s_showMinimap);
+
+ scribe.Element("lastProjectFileName", s_lastProjectFileName);
+ scribe.Element("lastExportedImageFileName", s_lastExportImageFileName);
+ scribe.Element("lastExportedInform7FileName", s_lastExportInform7FileName);
+ scribe.Element("lastExportedInform6FileName", s_lastExportInform6FileName);
+ scribe.Element("lastExportedTadsFileName", s_lastExportTadsFileName);
+
+ scribe.StartElement("recentProjects");
+ var index = 0;
+ foreach (var fileName in s_recentProjects)
+ {
+ scribe.Element(string.Format("fileName{0}", index++), fileName);
+ }
+ scribe.EndElement();
+
+ scribe.StartElement("automap");
+ scribe.Element("transcriptFileName", s_automap.FileName);
+ scribe.Element("verboseTranscript", s_automap.VerboseTranscript);
+ scribe.Element("assumeRoomsWithSameNameAreSameRoom", s_automap.AssumeRoomsWithSameNameAreSameRoom);
+ scribe.Element("guessExits", s_automap.GuessExits);
+ scribe.Element("addObjectCommand", s_automap.AddObjectCommand);
+ scribe.EndElement();
+ }
+ }
+ catch (Exception)
+ {
+ }
+ }
+
+ public static ColorSettings Color
+ {
+ get { return s_colorSettings; }
+ }
+
+ public static Font LargeFont
+ {
+ get { return s_largeFont; }
+ set
+ {
+ if (s_largeFont != value)
+ {
+ s_largeFont = value;
+ RaiseChanged();
+ }
+ }
+ }
+
+ public static Font SmallFont
+ {
+ get { return s_smallFont; }
+ set
+ {
+ if (s_smallFont != value)
+ {
+ s_smallFont = value;
+ RaiseChanged();
+ }
+ }
+ }
+
+ public static Font LineFont
+ {
+ get { return s_lineFont; }
+ set
+ {
+ if (s_lineFont != value)
+ {
+ s_lineFont = value;
+ RaiseChanged();
+ }
+ }
+ }
+
+ public static bool HandDrawn
+ {
+ get { return s_handDrawn; }
+ set
+ {
+ if (s_handDrawn != value)
+ {
+ s_handDrawn = value;
+ RaiseChanged();
+ }
+ }
+ }
+
+ public static bool HandDrawnUnchecked
+ {
+ get { return s_handDrawn; }
+ set { s_handDrawn = value; }
+ }
+
+ public static float LineWidth
+ {
+ get { return s_lineWidth; }
+ set
+ {
+ if (s_lineWidth != value)
+ {
+ s_lineWidth = value;
+ RaiseChanged();
+ }
+ }
+ }
+
+ public static bool SnapToGrid
+ {
+ get { return s_snapToGrid; }
+ set
+ {
+ if (s_snapToGrid != value)
+ {
+ s_snapToGrid = value;
+ RaiseChanged();
+ }
+ }
+ }
+
+ public static float GridSize
+ {
+ get { return s_gridSize; }
+ set
+ {
+ if (s_gridSize != value)
+ {
+ s_gridSize = value;
+ RaiseChanged();
+ }
+ }
+ }
+
+ public static bool IsGridVisible
+ {
+ get { return s_isGridVisible; }
+ set
+ {
+ if (s_isGridVisible != value)
+ {
+ s_isGridVisible = value;
+ RaiseChanged();
+ }
+ }
+ }
+
+ public static bool ShowOrigin
+ {
+ get { return s_showOrigin; }
+ set
+ {
+ if (s_showOrigin != value)
+ {
+ s_showOrigin = value;
+ RaiseChanged();
+ }
+ }
+ }
+
+ public static float DarknessStripeSize
+ {
+ get { return s_darknessStripeSize; }
+ set
+ {
+ if (s_darknessStripeSize != value)
+ {
+ s_darknessStripeSize = value;
+ RaiseChanged();
+ }
+ }
+ }
+
+ public static float ObjectListOffsetFromRoom
+ {
+ get { return s_objectListOffsetFromRoom; }
+ set
+ {
+ if (s_objectListOffsetFromRoom != value)
+ {
+ s_objectListOffsetFromRoom = value;
+ RaiseChanged();
+ }
+ }
+ }
+
+ public static float HandleSize
+ {
+ get { return s_handleSize; }
+ set
+ {
+ if (s_handleSize != value)
+ {
+ s_handleSize = value;
+ RaiseChanged();
+ }
+ }
+ }
+
+ public static float SnapToElementSize
+ {
+ get { return s_snapToElementSize; }
+ set
+ {
+ if (s_snapToElementSize != value)
+ {
+ s_snapToElementSize = value;
+ RaiseChanged();
+ }
+ }
+ }
+
+ public static float DragDistanceToInitiateNewConnection
+ {
+ get { return s_dragDistanceToInitiateNewConnection; }
+ set
+ {
+ if (s_dragDistanceToInitiateNewConnection != value)
+ {
+ s_dragDistanceToInitiateNewConnection = value;
+ RaiseChanged();
+ }
+ }
+ }
+
+ public static float ConnectionStalkLength
+ {
+ get { return s_connectionStalkLength; }
+ set
+ {
+ if (s_connectionStalkLength != value)
+ {
+ s_connectionStalkLength = value;
+ RaiseChanged();
+ }
+ }
+ }
+
+ public static float PreferredDistanceBetweenRooms
+ {
+ get { return s_preferredDistanceBetweenRooms; }
+ set
+ {
+ if (s_preferredDistanceBetweenRooms != value)
+ {
+ s_preferredDistanceBetweenRooms = value;
+ RaiseChanged();
+ }
+ }
+ }
+
+ public static float TextOffsetFromConnection
+ {
+ get { return s_textOffsetFromConnection; }
+ set
+ {
+ if (s_textOffsetFromConnection != value)
+ {
+ s_textOffsetFromConnection = value;
+ RaiseChanged();
+ }
+ }
+ }
+
+ public static float ConnectionArrowSize
+ {
+ get { return s_connectionArrowSize; }
+ set
+ {
+ if (s_connectionArrowSize != value)
+ {
+ s_connectionArrowSize = value;
+ RaiseChanged();
+ }
+ }
+ }
+
+ ///
+ /// Get/set the modifier keys required, along with a numeric keypad key,
+ /// to create new rooms from the currently selected room.
+ ///
+ public static Keys KeypadNavigationCreationModifier
+ {
+ get { return s_keypadNavigationCreationModifier; }
+ set
+ {
+ if (s_keypadNavigationCreationModifier != value)
+ {
+ s_keypadNavigationCreationModifier = value;
+ RaiseChanged();
+ }
+ }
+ }
+
+ ///
+ /// Get/set the modifier keys required, along with a numeric keypad key,
+ /// to mark "unexplored" connections from the currently selected room.
+ ///
+ public static Keys KeypadNavigationUnexploredModifier
+ {
+ get { return s_keypadNavigationUnexploredModifier; }
+ set
+ {
+ if (s_keypadNavigationUnexploredModifier != value)
+ {
+ s_keypadNavigationUnexploredModifier = value;
+ RaiseChanged();
+ }
+ }
+ }
+
+ public static float Snap(float value)
+ {
+ float offset = 0;
+ while (value < GridSize)
+ {
+ value += GridSize;
+ offset += GridSize;
+ }
+
+ var mod = value % GridSize;
+ if (SnapToGrid && mod != 0)
+ {
+ if (mod < GridSize / 2)
+ {
+ value -= mod;
+ }
+ else
+ {
+ value = value + GridSize - mod;
+ }
+ }
+
+ return value - offset;
+ }
+
+ public static Vector Snap(Vector pos)
+ {
+ if (SnapToGrid)
+ {
+ pos.X = Snap(pos.X);
+ pos.Y = Snap(pos.Y);
+ }
+ return pos;
+ }
+
+ public static event EventHandler Changed;
+
+ private static void RaiseChanged()
+ {
+ var changed = Changed;
+ if (changed != null)
+ {
+ changed(null, EventArgs.Empty);
+ }
+ }
+
+ public static void ShowAppDialog()
+ {
+ using (var dialog = new AppSettingsDialog())
+ {
+ dialog.InvertMouseWheel = InvertMouseWheel;
+ dialog.MouseDragButton = MouseDragButton;
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ InvertMouseWheel = dialog.InvertMouseWheel;
+ MouseDragButton = dialog.MouseDragButton;
+ }
+ }
+ }
+
+ public static void ShowMapDialog()
+ {
+ using (var dialog = new SettingsDialog())
+ {
+ for (int index = 0; index < Colors.Count; ++index)
+ {
+ dialog.Color[index] = Color[index];
+ }
+
+ dialog.Title = Project.Current.Title;
+ dialog.Author = Project.Current.Author;
+ dialog.Description = Project.Current.Description;
+ dialog.History = Project.Current.History;
+ dialog.LargeFont = LargeFont;
+ dialog.SmallFont = SmallFont;
+ dialog.LineFont = LineFont;
+ dialog.HandDrawn = HandDrawn;
+ dialog.LineWidth = LineWidth;
+ dialog.SnapToGrid = SnapToGrid;
+ dialog.GridSize = GridSize;
+ dialog.IsGridVisible = IsGridVisible;
+ dialog.ShowOrigin = ShowOrigin;
+ dialog.DarknessStripeSize = DarknessStripeSize;
+ dialog.ObjectListOffsetFromRoom = ObjectListOffsetFromRoom;
+ dialog.ConnectionStalkLength = ConnectionStalkLength;
+ dialog.PreferredDistanceBetweenRooms = PreferredDistanceBetweenRooms;
+ dialog.TextOffsetFromConnection = TextOffsetFromConnection;
+ dialog.HandleSize = HandleSize;
+ dialog.SnapToElementSize = SnapToElementSize;
+ dialog.ConnectionArrowSize = ConnectionArrowSize;
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ for (int index = 0; index < Colors.Count; ++index)
+ {
+ Color[index] = dialog.Color[index];
+ }
+ Project.Current.Title = dialog.Title;
+ Project.Current.Author = dialog.Author;
+ Project.Current.Description = dialog.Description;
+ Project.Current.History = dialog.History;
+ LargeFont = dialog.LargeFont;
+ SmallFont = dialog.SmallFont;
+ LineFont = dialog.LineFont;
+ HandDrawn = dialog.HandDrawn;
+ LineWidth = dialog.LineWidth;
+ SnapToGrid = dialog.SnapToGrid;
+ GridSize = dialog.GridSize;
+ IsGridVisible = dialog.IsGridVisible;
+ ShowOrigin = dialog.ShowOrigin;
+ DarknessStripeSize = dialog.DarknessStripeSize;
+ ObjectListOffsetFromRoom = dialog.ObjectListOffsetFromRoom;
+ ConnectionStalkLength = dialog.ConnectionStalkLength;
+ PreferredDistanceBetweenRooms = dialog.PreferredDistanceBetweenRooms;
+ TextOffsetFromConnection = dialog.TextOffsetFromConnection;
+ HandleSize = dialog.HandleSize;
+ SnapToElementSize = dialog.SnapToElementSize;
+ ConnectionArrowSize = dialog.ConnectionArrowSize;
+ }
+ }
+ }
+
+ public static void Reset()
+ {
+ Color[Colors.Canvas] = System.Drawing.Color.White;
+ Color[Colors.Fill] = System.Drawing.Color.White;
+ Color[Colors.Border] = System.Drawing.Color.MidnightBlue;
+ Color[Colors.Line] = System.Drawing.Color.MidnightBlue;
+ Color[Colors.HoverLine] = System.Drawing.Color.DarkOrange;
+ Color[Colors.SelectedLine] = System.Drawing.Color.SteelBlue;
+ Color[Colors.LargeText] = System.Drawing.Color.MidnightBlue;
+ Color[Colors.SmallText] = System.Drawing.Color.MidnightBlue;
+ Color[Colors.LineText] = System.Drawing.Color.MidnightBlue;
+ Color[Colors.Grid] = Drawing.Mix(System.Drawing.Color.White, System.Drawing.Color.Black, 25, 1);
+
+ LargeFont = new Font("Comic Sans MS", 13.0f, FontStyle.Regular, GraphicsUnit.World);
+ SmallFont = new Font("Comic Sans MS", 11.0f, FontStyle.Regular, GraphicsUnit.World);
+ LineFont = new Font("Comic Sans MS", 9.0f, FontStyle.Regular, GraphicsUnit.World);
+
+ LineWidth = 2.0f;
+ HandDrawn = true;
+
+ SnapToGrid = true;
+ IsGridVisible = true;
+ GridSize = 32.0f;
+ ShowOrigin = true;
+
+ DarknessStripeSize = 24.0f;
+ ObjectListOffsetFromRoom = 4.0f;
+
+ ConnectionStalkLength = 32.0f;
+ PreferredDistanceBetweenRooms = ConnectionStalkLength * 2;
+ TextOffsetFromConnection = 4.0f;
+ HandleSize = 12.0f;
+ SnapToElementSize = 16.0f;
+ DragDistanceToInitiateNewConnection = 32f;
+ ConnectionArrowSize = 12.0f;
+
+ KeypadNavigationCreationModifier = Keys.Control;
+ KeypadNavigationUnexploredModifier = Keys.Alt;
+ }
+
+ public static void Save(XmlScribe scribe)
+ {
+ // save colors
+ scribe.StartElement("colors");
+ for (int index = 0; index < Colors.Count; ++index)
+ {
+ string colorName;
+ if (Colors.ToName(index, out colorName))
+ {
+ scribe.Element(colorName, Color[index]);
+ }
+ }
+ scribe.EndElement();
+
+ // save fonts
+ scribe.StartElement("fonts");
+ SaveFont(scribe, s_largeFont, "room");
+ SaveFont(scribe, s_smallFont, "object");
+ SaveFont(scribe, s_lineFont, "line");
+ scribe.EndElement();
+
+ scribe.StartElement("grid");
+ scribe.Element("snapTo", s_snapToGrid);
+ scribe.Element("visible", s_isGridVisible);
+ scribe.Element("showOrigin", s_showOrigin);
+ scribe.Element("size", s_gridSize);
+ scribe.EndElement();
+
+ scribe.StartElement("lines");
+ scribe.Element("width", s_lineWidth);
+ scribe.Element("handDrawn", s_handDrawn);
+ scribe.Element("arrowSize", s_connectionArrowSize);
+ scribe.Element("textOffset", s_textOffsetFromConnection);
+ scribe.EndElement();
+
+ scribe.StartElement("rooms");
+ scribe.Element("darknessStripeSize", s_darknessStripeSize);
+ scribe.Element("objectListOffset", s_objectListOffsetFromRoom);
+ scribe.Element("connectionStalkLength", s_connectionStalkLength);
+ scribe.Element("preferredDistanceBetweenRooms", s_preferredDistanceBetweenRooms);
+ scribe.EndElement();
+
+ scribe.StartElement("ui");
+ scribe.Element("handleSize", s_handleSize);
+ scribe.Element("snapToElementSize", s_snapToElementSize);
+ scribe.EndElement();
+
+ scribe.StartElement("keypadNavigation");
+ scribe.Element("creationModifier", ModifierKeysToString(s_keypadNavigationCreationModifier));
+ scribe.Element("unexploredModifier", ModifierKeysToString(s_keypadNavigationUnexploredModifier));
+ scribe.EndElement();
+
+ SaveApplicationSettings();
+ }
+
+ private static string ModifierKeysToString(Keys key)
+ {
+ var builder = new StringBuilder();
+ if ((key & Keys.Shift) == Keys.Shift)
+ {
+ if (builder.Length != 0)
+ builder.Append("|");
+ builder.Append("shift");
+ }
+ if ((key & Keys.Control) == Keys.Control)
+ {
+ if (builder.Length != 0)
+ builder.Append("|");
+ builder.Append("control");
+ }
+ if ((key & Keys.Alt) == Keys.Alt)
+ {
+ if (builder.Length != 0)
+ builder.Append("|");
+ builder.Append("alt");
+ }
+ if (builder.Length == 0)
+ {
+ builder.Append("none");
+ }
+ return builder.ToString();
+ }
+
+ private static Keys StringToModifierKeys(string text, Keys defaultValue)
+ {
+ if (string.IsNullOrEmpty(text))
+ {
+ return defaultValue;
+ }
+
+ Keys value = Keys.None;
+ foreach (var part in text.Split('|'))
+ {
+ if (StringComparer.InvariantCultureIgnoreCase.Compare(part, "shift") == 0)
+ {
+ value |= Keys.Shift;
+ }
+ else if (StringComparer.InvariantCultureIgnoreCase.Compare(part, "control") == 0)
+ {
+ value |= Keys.Control;
+ }
+ else if (StringComparer.InvariantCultureIgnoreCase.Compare(part, "alt") == 0)
+ {
+ value |= Keys.Alt;
+ }
+ // Note that "none" is also an allowed value.
+ }
+ return value;
+ }
+
+ private static void SaveFont(XmlScribe scribe, Font font, string name)
+ {
+ scribe.StartElement(name);
+ scribe.Attribute("size", font.Size);
+ if ((font.Style & FontStyle.Bold) == FontStyle.Bold)
+ {
+ scribe.Attribute("bold", true);
+ }
+ if ((font.Style & FontStyle.Italic) == FontStyle.Italic)
+ {
+ scribe.Attribute("italic", true);
+ }
+ if ((font.Style & FontStyle.Underline) == FontStyle.Underline)
+ {
+ scribe.Attribute("underline", true);
+ }
+ if ((font.Style & FontStyle.Strikeout) == FontStyle.Strikeout)
+ {
+ scribe.Attribute("strikeout", true);
+ }
+ scribe.Value(Drawing.FontName(font));
+ scribe.EndElement();
+ }
+
+ public static void Load(XmlElementReader element)
+ {
+ var colors = element["colors"];
+ foreach (var color in colors.Children)
+ {
+ int index;
+ if (Colors.FromName(color.Name, out index))
+ {
+ Color[index] = color.ToColor(Color[index]);
+ }
+ }
+
+ var fonts = element["fonts"];
+ foreach (var font in fonts.Children)
+ {
+ var style = FontStyle.Regular;
+ if (font.Attribute("bold").ToBool())
+ {
+ style |= FontStyle.Bold;
+ }
+ if (font.Attribute("italic").ToBool())
+ {
+ style |= FontStyle.Italic;
+ }
+ if (font.Attribute("underline").ToBool())
+ {
+ style |= FontStyle.Underline;
+ }
+ if (font.Attribute("strikeout").ToBool())
+ {
+ style |= FontStyle.Strikeout;
+ }
+ if (font.Name == "room")
+ {
+ LargeFont = new Font(font.ToText(LargeFont.Name), Numeric.Clamp(font.Attribute("size").ToFloat(LargeFont.Size), MinFontSize, MaxFontSize), style, GraphicsUnit.World);
+ }
+ else if (font.Name == "object")
+ {
+ SmallFont = new Font(font.ToText(SmallFont.Name), Numeric.Clamp(font.Attribute("size").ToFloat(SmallFont.Size), MinFontSize, MaxFontSize), style, GraphicsUnit.World);
+ }
+ else if (font.Name == "line")
+ {
+ LineFont = new Font(font.ToText(SmallFont.Name), Numeric.Clamp(font.Attribute("size").ToFloat(LineFont.Size), MinFontSize, MaxFontSize), style, GraphicsUnit.World);
+ }
+ }
+
+ SnapToGrid = element["grid"]["snapTo"].ToBool(s_snapToGrid);
+ IsGridVisible = element["grid"]["visible"].ToBool(s_isGridVisible);
+ GridSize = element["grid"]["size"].ToFloat(s_gridSize);
+ ShowOrigin = element["grid"]["showOrigin"].ToBool(s_showOrigin);
+
+ LineWidth = element["lines"]["width"].ToFloat(s_lineWidth);
+ HandDrawn = element["lines"]["handDrawn"].ToBool(s_handDrawn);
+ ConnectionArrowSize = element["lines"]["arrowSize"].ToFloat(s_connectionArrowSize);
+ TextOffsetFromConnection = element["lines"]["textOffset"].ToFloat(s_textOffsetFromConnection);
+
+ DarknessStripeSize = element["rooms"]["darknessStripeSize"].ToFloat(s_darknessStripeSize);
+ ObjectListOffsetFromRoom = element["rooms"]["objectListOffset"].ToFloat(s_objectListOffsetFromRoom);
+ ConnectionStalkLength = element["rooms"]["connectionStalkLength"].ToFloat(s_connectionStalkLength);
+ PreferredDistanceBetweenRooms = element["rooms"]["preferredDistanceBetweenRooms"].ToFloat(s_connectionStalkLength * 2); // introduced in v1.2, hence default based on existing setting
+
+ HandleSize = element["ui"]["handleSize"].ToFloat(s_handleSize);
+ SnapToElementSize = element["ui"]["snapToElementSize"].ToFloat(s_snapToElementSize);
+
+ KeypadNavigationCreationModifier = StringToModifierKeys(element["keypadNavigation"]["creationModifier"].Text, s_keypadNavigationCreationModifier);
+ KeypadNavigationUnexploredModifier = StringToModifierKeys(element["keypadNavigation"]["unexploredModifier"].Text, s_keypadNavigationUnexploredModifier);
+ }
+
+ public class ColorSettings
+ {
+ public Color this[int index]
+ {
+ get { return Settings.s_color[index]; }
+ set
+ {
+ if (Settings.s_color[index] != value)
+ {
+ Settings.s_color[index] = value;
+ Settings.RaiseChanged();
+ }
+ }
+ }
+ }
+
+ public static bool DebugShowFPS
+ {
+ get;
+ set;
+ }
+
+ public static bool DebugDisableTextRendering
+ {
+ get;
+ set;
+ }
+
+ public static bool DebugDisableLineRendering
+ {
+ get;
+ set;
+ }
+
+ public static bool DebugDisableElementRendering
+ {
+ get;
+ set;
+ }
+
+ public static bool DebugDisableGridPolyline
+ {
+ get;
+ set;
+ }
+
+ public static Version DontCareAboutVersion
+ {
+ get { return s_dontCareAboutVersion; }
+ set { s_dontCareAboutVersion = value; }
+ }
+
+ public static AutomapSettings Automap
+ {
+ get { return s_automap; }
+ set { s_automap = value; }
+ }
+
+ public static int MouseDragButton
+ {
+ get { return s_dragButton; }
+ set { s_dragButton = value; }
+ }
+
+ public static bool InvertMouseWheel
+ {
+ get { return s_invertMouseWheel; }
+ set { s_invertMouseWheel = value; }
+ }
+
+ public static bool InfiniteScrollBounds
+ {
+ get { return s_infiniteScrollBounds; }
+ set { s_infiniteScrollBounds = value; }
+ }
+
+ public static bool ShowMiniMap
+ {
+ get { return s_showMinimap; }
+ set { s_showMinimap = value; }
+ }
+
+ public static string LastProjectFileName
+ {
+ get { return s_lastProjectFileName; }
+ set { s_lastProjectFileName = value; }
+ }
+
+ public static string LastExportImageFileName
+ {
+ get { return s_lastExportImageFileName; }
+ set { s_lastExportImageFileName = value; }
+ }
+
+ public static string LastExportInform7FileName
+ {
+ get { return s_lastExportInform7FileName; }
+ set { s_lastExportInform7FileName = value; }
+ }
+
+ public static string LastExportInform6FileName
+ {
+ get { return s_lastExportInform6FileName; }
+ set { s_lastExportInform6FileName = value; }
+ }
+
+ public static string LastExportTadsFileName
+ {
+ get { return s_lastExportTadsFileName; }
+ set { s_lastExportTadsFileName = value; }
+ }
+
+ public static MruList RecentProjects
+ {
+ get { return s_recentProjects; }
+ }
+
+ private static readonly float MinFontSize = 2;
+ private static readonly float MaxFontSize = 256;
+
+ // per-map settings, saved with the map
+ private static Color[] s_color = new Color[Colors.Count];
+ private static ColorSettings s_colorSettings = new ColorSettings();
+ private static Font s_largeFont;
+ private static Font s_smallFont;
+ private static Font s_lineFont;
+ private static float s_lineWidth;
+ private static bool s_handDrawn;
+ private static bool s_snapToGrid;
+ private static bool s_isGridVisible;
+ private static bool s_showOrigin;
+ private static float s_gridSize;
+ private static float s_darknessStripeSize;
+ private static float s_objectListOffsetFromRoom;
+ private static float s_connectionStalkLength;
+ private static float s_preferredDistanceBetweenRooms;
+ private static float s_textOffsetFromConnection;
+ private static float s_handleSize;
+ private static float s_snapToElementSize;
+ private static float s_dragDistanceToInitiateNewConnection;
+ private static float s_connectionArrowSize;
+ private static Keys s_keypadNavigationCreationModifier;
+ private static Keys s_keypadNavigationUnexploredModifier;
+
+ // application settings, saved for the user
+ private static Version s_dontCareAboutVersion;
+ private static AutomapSettings s_automap;
+ private static int s_dragButton;
+ private static bool s_invertMouseWheel;
+ private static bool s_infiniteScrollBounds;
+ private static bool s_showMinimap;
+ private static string s_lastProjectFileName;
+ private static string s_lastExportImageFileName;
+ private static string s_lastExportInform7FileName;
+ private static string s_lastExportInform6FileName;
+ private static string s_lastExportTadsFileName;
+ private static MruList s_recentProjects = new MruList();
+ }
+}
diff --git a/Trizbort.csproj b/Trizbort.csproj
index a85992c..44c10a5 100644
--- a/Trizbort.csproj
+++ b/Trizbort.csproj
@@ -1,270 +1,279 @@
-
-
-
- Debug
- x86
- x86
- 9.0.30729
- 2.0
- {F462E085-AFBE-46EC-936E-AEF63C83A796}
- WinExe
- Properties
- Trizbort
- Trizbort
- v2.0
- 512
- Map.ico
-
-
-
-
- 3.5
- publish\
- true
- Disk
- false
- Foreground
- 7
- Days
- false
- false
- true
- 0
- 1.0.0.%2a
- false
- false
- true
-
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
- false
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
- false
-
-
-
- False
- .\PdfSharp.dll
-
-
-
-
-
-
-
-
-
- Form
-
-
- AboutDialog.cs
-
-
-
- UserControl
-
-
- AutomapBar.cs
-
-
- Form
-
-
- AutomapDialog.cs
-
-
-
- UserControl
-
-
- UserControl
-
-
- Canvas.cs
-
-
-
-
-
- Form
-
-
- ConnectionPropertiesDialog.cs
-
-
- Form
-
-
- DisambiguateRoomsDialog.cs
-
-
-
-
-
-
-
-
-
-
-
-
-
- UserControl
-
-
- Minimap.cs
-
-
-
-
- Form
-
-
- NewVersionDialog.cs
-
-
-
-
-
-
-
-
-
-
-
- Form
-
-
- MainForm.cs
-
-
-
-
-
-
- AboutDialog.cs
-
-
- AutomapBar.cs
-
-
- AutomapDialog.cs
-
-
- Canvas.cs
-
-
- ConnectionPropertiesDialog.cs
-
-
- DisambiguateRoomsDialog.cs
-
-
- MainForm.cs
-
-
- Minimap.cs
-
-
- NewVersionDialog.cs
-
-
- ResXFileCodeGenerator
- Resources.Designer.cs
- Designer
-
-
- RoomPropertiesDialog.cs
-
-
- SettingsDialog.cs
-
-
- True
- Resources.resx
- True
-
-
-
-
-
-
-
- Form
-
-
- RoomPropertiesDialog.cs
-
-
-
- Form
-
-
- SettingsDialog.cs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- False
- Microsoft .NET Framework 4 %28x86 and x64%29
- true
-
-
- False
- .NET Framework 3.5 SP1 Client Profile
- false
-
-
- False
- .NET Framework 3.5 SP1
- false
-
-
- False
- Windows Installer 3.1
- true
-
-
-
-
+
+
+
+ Debug
+ x86
+ x86
+ 9.0.30729
+ 2.0
+ {F462E085-AFBE-46EC-936E-AEF63C83A796}
+ WinExe
+ Properties
+ Trizbort
+ Trizbort
+ v2.0
+ 512
+ Map.ico
+
+
+
+
+ 3.5
+ false
+
+ publish\
+ true
+ Disk
+ false
+ Foreground
+ 7
+ Days
+ false
+ false
+ true
+ 0
+ 1.0.0.%2a
+ false
+ true
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+ false
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+ false
+
+
+
+ False
+ .\PdfSharp.dll
+
+
+
+
+
+
+
+
+
+ Form
+
+
+ AboutDialog.cs
+
+
+ Form
+
+
+ AppSettingsDialog.cs
+
+
+
+ UserControl
+
+
+ AutomapBar.cs
+
+
+ Form
+
+
+ AutomapDialog.cs
+
+
+
+ UserControl
+
+
+ UserControl
+
+
+ Canvas.cs
+
+
+
+
+
+ Form
+
+
+ ConnectionPropertiesDialog.cs
+
+
+ Form
+
+
+ DisambiguateRoomsDialog.cs
+
+
+
+
+
+
+
+
+
+
+
+
+
+ UserControl
+
+
+ Minimap.cs
+
+
+
+
+ Form
+
+
+ NewVersionDialog.cs
+
+
+
+
+
+
+
+
+
+
+
+ Form
+
+
+ MainForm.cs
+
+
+
+
+
+
+ AboutDialog.cs
+
+
+ AppSettingsDialog.cs
+
+
+ AutomapBar.cs
+
+
+ AutomapDialog.cs
+
+
+ Canvas.cs
+
+
+ ConnectionPropertiesDialog.cs
+
+
+ DisambiguateRoomsDialog.cs
+
+
+ MainForm.cs
+
+
+ Minimap.cs
+
+
+ NewVersionDialog.cs
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+ Designer
+
+
+ RoomPropertiesDialog.cs
+
+
+ SettingsDialog.cs
+
+
+ True
+ Resources.resx
+ True
+
+
+
+
+
+
+
+ Form
+
+
+ RoomPropertiesDialog.cs
+
+
+
+ Form
+
+
+ SettingsDialog.cs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ False
+ Microsoft .NET Framework 4 %28x86 and x64%29
+ true
+
+
+ False
+ .NET Framework 3.5 SP1 Client Profile
+ false
+
+
+ False
+ .NET Framework 3.5 SP1
+ false
+
+
+ False
+ Windows Installer 3.1
+ true
+
+
+
+
\ No newline at end of file