diff --git a/renderdocui/Properties/Resources.Designer.cs b/renderdocui/Properties/Resources.Designer.cs index 3321aeb07..4c5b7249a 100644 --- a/renderdocui/Properties/Resources.Designer.cs +++ b/renderdocui/Properties/Resources.Designer.cs @@ -220,6 +220,16 @@ namespace renderdocui.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap down_arrow { + get { + object obj = ResourceManager.GetObject("down_arrow", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -580,6 +590,16 @@ namespace renderdocui.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap up_arrow { + get { + object obj = ResourceManager.GetObject("up_arrow", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/renderdocui/Properties/Resources.resx b/renderdocui/Properties/Resources.resx index ebf9081f0..dd9138ebd 100644 --- a/renderdocui/Properties/Resources.resx +++ b/renderdocui/Properties/Resources.resx @@ -286,4 +286,10 @@ ..\Resources\page_white_code.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\down_arrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\up_arrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/renderdocui/Resources/down_arrow.png b/renderdocui/Resources/down_arrow.png new file mode 100644 index 000000000..482dd7895 Binary files /dev/null and b/renderdocui/Resources/down_arrow.png differ diff --git a/renderdocui/Resources/up_arrow.png b/renderdocui/Resources/up_arrow.png new file mode 100644 index 000000000..04e1d194e Binary files /dev/null and b/renderdocui/Resources/up_arrow.png differ diff --git a/renderdocui/Windows/Dialogs/OrderedListEditor.Designer.cs b/renderdocui/Windows/Dialogs/OrderedListEditor.Designer.cs new file mode 100644 index 000000000..962b74446 --- /dev/null +++ b/renderdocui/Windows/Dialogs/OrderedListEditor.Designer.cs @@ -0,0 +1,199 @@ +namespace renderdocui.Windows.Dialogs +{ + partial class OrderedListEditor + { + /// + /// 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.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + this.items = new System.Windows.Forms.DataGridView(); + this.number = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.name = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.browse = new System.Windows.Forms.DataGridViewImageColumn(); + this.moveup = new System.Windows.Forms.DataGridViewImageColumn(); + this.movedown = new System.Windows.Forms.DataGridViewImageColumn(); + this.itemFolderBrowser = new System.Windows.Forms.FolderBrowserDialog(); + this.itemFileBrowser = new System.Windows.Forms.OpenFileDialog(); + this.cancel = new System.Windows.Forms.Button(); + this.ok = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.items)).BeginInit(); + this.SuspendLayout(); + // + // items + // + this.items.AllowUserToResizeColumns = false; + this.items.AllowUserToResizeRows = false; + this.items.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.items.BackgroundColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.items.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; + this.items.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.items.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.number, + this.name, + this.browse, + this.moveup, + this.movedown}); + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.items.DefaultCellStyle = dataGridViewCellStyle2; + this.items.Location = new System.Drawing.Point(12, 12); + this.items.MultiSelect = false; + this.items.Name = "items"; + dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.items.RowHeadersDefaultCellStyle = dataGridViewCellStyle3; + this.items.RowHeadersVisible = false; + this.items.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.items.Size = new System.Drawing.Size(464, 326); + this.items.TabIndex = 5; + this.items.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.items_CellContentClick); + this.items.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.items_CellFormatting); + this.items.CellMouseMove += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.items_CellMouseMove); + // + // number + // + this.number.HeaderText = "#"; + this.number.MinimumWidth = 10; + this.number.Name = "number"; + this.number.ReadOnly = true; + this.number.Width = 32; + // + // name + // + this.name.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.name.HeaderText = "Item name (changed at runtime)"; + this.name.Name = "name"; + // + // browse + // + this.browse.HeaderText = ""; + this.browse.Image = global::renderdocui.Properties.Resources.folder_page; + this.browse.MinimumWidth = 15; + this.browse.Name = "browse"; + this.browse.ReadOnly = true; + this.browse.Resizable = System.Windows.Forms.DataGridViewTriState.False; + this.browse.Width = 32; + // + // moveup + // + this.moveup.HeaderText = ""; + this.moveup.Image = global::renderdocui.Properties.Resources.up_arrow; + this.moveup.MinimumWidth = 15; + this.moveup.Name = "moveup"; + this.moveup.ReadOnly = true; + this.moveup.Resizable = System.Windows.Forms.DataGridViewTriState.False; + this.moveup.Width = 32; + // + // movedown + // + this.movedown.HeaderText = ""; + this.movedown.Image = global::renderdocui.Properties.Resources.down_arrow; + this.movedown.MinimumWidth = 15; + this.movedown.Name = "movedown"; + this.movedown.ReadOnly = true; + this.movedown.Resizable = System.Windows.Forms.DataGridViewTriState.False; + this.movedown.Width = 32; + // + // itemFolderBrowser + // + this.itemFolderBrowser.RootFolder = System.Environment.SpecialFolder.MyComputer; + // + // cancel + // + this.cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.cancel.Location = new System.Drawing.Point(401, 344); + this.cancel.Name = "cancel"; + this.cancel.Size = new System.Drawing.Size(75, 23); + this.cancel.TabIndex = 6; + this.cancel.Text = "Cancel"; + this.cancel.UseVisualStyleBackColor = true; + // + // ok + // + this.ok.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.ok.DialogResult = System.Windows.Forms.DialogResult.OK; + this.ok.Location = new System.Drawing.Point(320, 344); + this.ok.Name = "ok"; + this.ok.Size = new System.Drawing.Size(75, 23); + this.ok.TabIndex = 7; + this.ok.Text = "OK"; + this.ok.UseVisualStyleBackColor = true; + // + // OrderedListEditor + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(488, 379); + this.Controls.Add(this.ok); + this.Controls.Add(this.cancel); + this.Controls.Add(this.items); + this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.Name = "OrderedListEditor"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Window Title (changed at runtime)"; + ((System.ComponentModel.ISupportInitialize)(this.items)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.DataGridView items; + private System.Windows.Forms.DataGridViewTextBoxColumn number; + private System.Windows.Forms.DataGridViewTextBoxColumn name; + private System.Windows.Forms.DataGridViewImageColumn browse; + private System.Windows.Forms.DataGridViewImageColumn moveup; + private System.Windows.Forms.DataGridViewImageColumn movedown; + private System.Windows.Forms.FolderBrowserDialog itemFolderBrowser; + private System.Windows.Forms.OpenFileDialog itemFileBrowser; + private System.Windows.Forms.Button cancel; + private System.Windows.Forms.Button ok; + + } +} \ No newline at end of file diff --git a/renderdocui/Windows/Dialogs/OrderedListEditor.cs b/renderdocui/Windows/Dialogs/OrderedListEditor.cs new file mode 100644 index 000000000..0db60dfb4 --- /dev/null +++ b/renderdocui/Windows/Dialogs/OrderedListEditor.cs @@ -0,0 +1,245 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2015-2016 Baldur Karlsson + * Copyright (c) 2014 Crytek + * + * 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.Data; +using System.Drawing; +using System.Linq; +using System.Threading; +using System.Text; +using System.Windows.Forms; +using renderdocui.Code; +using renderdoc; + +namespace renderdocui.Windows.Dialogs +{ + // this window lists the remote hosts the user has configured, and queries for any open connections + // on any of them that indicate an application with renderdoc hooks that's running. + public partial class OrderedListEditor : Form + { + public enum Browsing + { + None, + Folder, + File, + }; + + private Browsing browseMode = Browsing.Folder; + + public OrderedListEditor(Core core, string windowName, string itemName, Browsing browse) + { + InitializeComponent(); + + Icon = global::renderdocui.Properties.Resources.icon; + + items.Font = core.Config.PreferredFont; + + Text = windowName; + items.Columns[1].HeaderText = itemName; + + if (browse == Browsing.None) + items.Columns.RemoveAt(BrowserColumnIndex); + + browseMode = browse; + } + + private void SetItem(int row, String text) + { + items.Rows[row].SetValues(new object[] { null, text, null, null, null }); + } + + public void AddItem(String text) + { + items.Rows.Add(); + SetItem(items.RowCount - 2, text); + } + + public string[] GetItems() + { + string[] ret = new string[items.RowCount - 1]; + + for (int i = 0; i < items.RowCount - 1; i++) + ret[i] = items.Rows[i].Cells[1].Value.ToString(); + + return ret; + } + + private int ItemNumberColumnIndex + { + get + { + return 0; + } + } + + private int ItemNameColumnIndex + { + get + { + return 1; + } + } + + private int FirstButtonColumnIndex + { + get + { + return 2; + } + } + + private int BrowserColumnIndex + { + get + { + return browseMode == Browsing.None ? -1 : 2; + } + } + + private int MoveUpColumnIndex + { + get + { + return browseMode == Browsing.None ? 2 : 3; + } + } + + private int MoveDownColumnIndex + { + get + { + return browseMode == Browsing.None ? 3 : 4; + } + } + + private bool IsClickableCell(int row, int column) + { + if (column < FirstButtonColumnIndex) + return false; + + if (column == MoveUpColumnIndex && row == 0) + return false; + + if (column == MoveDownColumnIndex && row >= items.RowCount - 2) + return false; + + if (column != BrowserColumnIndex && row == items.RowCount - 1) + return false; + + return true; + } + + private void items_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) + { + if (e.ColumnIndex == ItemNumberColumnIndex) + { + e.Value = e.RowIndex + 1; + return; + } + else if (e.ColumnIndex == BrowserColumnIndex) + { + e.Value = global::renderdocui.Properties.Resources.folder_page; + return; + } + else if (e.ColumnIndex == MoveUpColumnIndex) + { + if (IsClickableCell(e.RowIndex, e.ColumnIndex)) + { + e.Value = global::renderdocui.Properties.Resources.up_arrow; + return; + } + } + else if (e.ColumnIndex == MoveDownColumnIndex) + { + if(IsClickableCell(e.RowIndex, e.ColumnIndex)) + { + e.Value = global::renderdocui.Properties.Resources.down_arrow; + return; + } + } + + if (e.ColumnIndex >= FirstButtonColumnIndex) + e.Value = new Bitmap(1, 1); + } + + private void items_CellMouseMove(object sender, DataGridViewCellMouseEventArgs e) + { + if (IsClickableCell(e.RowIndex, e.ColumnIndex)) + items.Cursor = Cursors.Hand; + else + items.Cursor = Cursors.Default; + } + + private void items_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + if (e.ColumnIndex == BrowserColumnIndex) + { + if(browseMode == Browsing.Folder) + { + var res = itemFolderBrowser.ShowDialog(); + + if (res == DialogResult.Yes || res == DialogResult.OK) + { + if (items.Rows[e.RowIndex].IsNewRow) + AddItem(itemFolderBrowser.SelectedPath); + else + SetItem(e.RowIndex, itemFolderBrowser.SelectedPath); + } + } + else if (browseMode == Browsing.File) + { + var res = itemFileBrowser.ShowDialog(); + + if (res == DialogResult.Yes || res == DialogResult.OK) + { + if (items.Rows[e.RowIndex].IsNewRow) + AddItem(itemFileBrowser.FileName); + else + SetItem(e.RowIndex, itemFileBrowser.FileName); + } + } + } + else if (e.ColumnIndex == MoveUpColumnIndex && e.RowIndex > 0 && e.RowIndex < items.RowCount - 1) + { + var row = items.Rows[e.RowIndex]; + items.Rows.RemoveAt(e.RowIndex); + items.Rows.Insert(e.RowIndex - 1, row); + items.ClearSelection(); + row.Selected = true; + } + else if (e.ColumnIndex == MoveDownColumnIndex && e.RowIndex < items.RowCount - 2) + { + var row = items.Rows[e.RowIndex]; + items.Rows.RemoveAt(e.RowIndex); + items.Rows.Insert(e.RowIndex + 1, row); + items.ClearSelection(); + row.Selected = true; + } + } + } +} diff --git a/renderdocui/Windows/Dialogs/OrderedListEditor.resx b/renderdocui/Windows/Dialogs/OrderedListEditor.resx new file mode 100644 index 000000000..37620634e --- /dev/null +++ b/renderdocui/Windows/Dialogs/OrderedListEditor.resx @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + + True + + + True + + + 17, 17 + + + 161, 17 + + \ No newline at end of file diff --git a/renderdocui/renderdocui.csproj b/renderdocui/renderdocui.csproj index ff950b968..fe6b3d45a 100644 --- a/renderdocui/renderdocui.csproj +++ b/renderdocui/renderdocui.csproj @@ -241,6 +241,12 @@ RemoteHostSelect.cs + + Form + + + OrderedListEditor.cs + Form @@ -394,6 +400,9 @@ PythonShell.cs + + OrderedListEditor.cs + RemoteHostSelect.cs @@ -512,6 +521,7 @@ false + @@ -541,6 +551,7 @@ +