From: Vásáry Dániel Date: Wed, 25 Oct 2017 16:39:26 +0000 (+0000) Subject: git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube... X-Git-Url: http://git.useribm.hu/?a=commitdiff_plain;h=9c7eed832153427a70c23856983702c1f156af52;p=mediacube.git git-tfs-id: [tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30671 --- diff --git a/client/Maestro/Configuration/configuration-nle.json b/client/Maestro/Configuration/configuration-nle.json index e58db075..c94c4bd2 100644 --- a/client/Maestro/Configuration/configuration-nle.json +++ b/client/Maestro/Configuration/configuration-nle.json @@ -1,6 +1,6 @@ { "title": "NLE", - "active": true, + "active": false, "startInTray": true, "enableCustomMetadataId": true, "player": { diff --git a/client/Maestro/Configuration/configuration-playout.json b/client/Maestro/Configuration/configuration-playout.json index abf37876..27f522f0 100644 --- a/client/Maestro/Configuration/configuration-playout.json +++ b/client/Maestro/Configuration/configuration-playout.json @@ -1,6 +1,6 @@ { "title": "Adáslebony", - "active": true, + "active": false, "startInTray": true, "enableCustomMetadataId": true, "player": { diff --git a/client/Maestro/Configuration/configuration-studio.json b/client/Maestro/Configuration/configuration-studio.json index 85c76159..6bd90e02 100644 --- a/client/Maestro/Configuration/configuration-studio.json +++ b/client/Maestro/Configuration/configuration-studio.json @@ -1,6 +1,6 @@ { "title": "Stúdió", - "active": true, + "active": false, "startInTray": true, "enableCustomMetadataId": true, "filter": "avi", diff --git a/client/Maestro/Configuration/configuration-sxs.json b/client/Maestro/Configuration/configuration-sxs.json index d70fab03..31e6ae47 100644 --- a/client/Maestro/Configuration/configuration-sxs.json +++ b/client/Maestro/Configuration/configuration-sxs.json @@ -1,6 +1,6 @@ { "title": "SxS", - "active": true, + "active": false, "startInTray": true, "enableCustomMetadataId": true, "player": { diff --git a/client/Maestro/MaestroForm.Designer.cs b/client/Maestro/MaestroForm.Designer.cs index 4c575d77..99f3fbe5 100644 --- a/client/Maestro/MaestroForm.Designer.cs +++ b/client/Maestro/MaestroForm.Designer.cs @@ -77,6 +77,7 @@ namespace Maestro { this.columnLabel = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.columnID = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.columnStatus = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.columnProgress = new Maestro.Commons.DataGridViewProgressColumn(); this.columnStarted = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.columnFinished = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.columnInput = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -621,6 +622,7 @@ namespace Maestro { this.columnLabel, this.columnID, this.columnStatus, + this.columnProgress, this.columnStarted, this.columnFinished, this.columnInput, @@ -688,6 +690,20 @@ namespace Maestro { this.columnStatus.Name = "columnStatus"; this.columnStatus.Width = 66; // + // columnProgress + // + this.columnProgress.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.columnProgress.DataPropertyName = "Progress"; + dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle7.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + dataGridViewCellStyle7.NullValue = null; + this.columnProgress.DefaultCellStyle = dataGridViewCellStyle7; + this.columnProgress.HeaderText = "Progress"; + this.columnProgress.Name = "columnProgress"; + this.columnProgress.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.columnProgress.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; + this.columnProgress.Width = 200; + // // columnStarted // this.columnStarted.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells; diff --git a/client/Maestro/MaestroForm.Metadata.cs b/client/Maestro/MaestroForm.Metadata.cs index e4d31870..47d46030 100644 --- a/client/Maestro/MaestroForm.Metadata.cs +++ b/client/Maestro/MaestroForm.Metadata.cs @@ -38,6 +38,8 @@ namespace Maestro { InitializeTrafficSelector(); InitializeMediaCubeApi(); textSelectedMetadata.ReadOnly = !Configuration.EnableCustomMetadataId; + UpdateDefineSegmentEnabled(); + UpdateEditArchiveMetadataEnabled(); } private void InitializeTrafficSelector() { diff --git a/client/Maestro/MaestroForm.Source.cs b/client/Maestro/MaestroForm.Source.cs index 1e23e206..06e16ef5 100644 --- a/client/Maestro/MaestroForm.Source.cs +++ b/client/Maestro/MaestroForm.Source.cs @@ -7,6 +7,7 @@ using OctopusClient; using System; using System.Collections.Generic; using System.Drawing; +using System.IO; using System.Linq; using System.Windows.Forms; using TrafficClient; @@ -18,11 +19,8 @@ namespace Maestro { public partial class MaestroForm { private ISource source; private SourceInfo selectedSource; - private string startingName; private List selectedSourceRows = new List(); - public SourceIDType SourceIDType { get; set; } - public SourceInfo SelectedSource { get { return selectedSource; @@ -30,7 +28,10 @@ namespace Maestro { set { selectedSource = value; textSelectedSource.Text = selectedSource.Name; + UpdateProcessorButtonsEnabled(); + UpdateDefineSegmentEnabled(); UpdateEditArchiveMetadataEnabled(); + UpdateLookupMetadataEnabled(); } } @@ -58,7 +59,7 @@ namespace Maestro { source.Startup(localAddress); bindingSource.DataSource = source; - dataGridSource.Columns.AddRange(new DataGridViewCheckBoxColumn()); + //dataGridSource.Columns.AddRange(new DataGridViewCheckBoxColumn()); dataGridSource.Columns.AddRange(source.Columns); } @@ -74,7 +75,7 @@ namespace Maestro { } private void OnFileInvolved(FileActionMsg m) { - UpdateSelectedSources(); + //UpdateSelectedSources(); } private void dataGridSource_CellMouseEnter(object sender, DataGridViewCellEventArgs e) { @@ -103,7 +104,7 @@ namespace Maestro { if (selectedrows == null) return; if (e.ColumnIndex == 0) { - UpdateSelectedSources(); + UpdateCheckStates(selectedrows); return; } if (IsPlayColumn(e.ColumnIndex)) { @@ -121,127 +122,71 @@ namespace Maestro { } } - private void UpdateSelectedSources() { - String name; - var selectedRows = dataGridSource.SelectedRows; - bool valueOfCheckBoxes = GetValueOfCheckBoxes(selectedRows); - int nameIndex = dataGridSource.Columns.Cast().Where(x => x.HeaderText == StringResources.NEV).SingleOrDefault().Index; - int checkBoxIndex = dataGridSource.Columns.Cast().Where(x => x.GetType() == typeof(DataGridViewCheckBoxColumn)).SingleOrDefault().Index; - foreach (DataGridViewRow actualRow in selectedRows) { - var cells = actualRow.Cells; - if (cells.Count <= 0) - return; - name = cells[nameIndex].Value as string; + private bool GetHasChecked(DataGridViewSelectedRowCollection selectedRows) { + foreach (DataGridViewRow row in selectedRows) { + DataGridViewCheckBoxCell checkBoxCell = row.Cells[0] as DataGridViewCheckBoxCell; + if (true.Equals(checkBoxCell.Value)) + return true; + } + return false; + } + + private void UpdateCheckStates(DataGridViewSelectedRowCollection rows) { + bool hasChecked = GetHasChecked(rows); + var nameColumn = dataGridSource.Columns.Cast().Where(x => x.HeaderText == StringResources.NEV).FirstOrDefault(); + if (nameColumn == null) + return; + int nameCellIndex = nameColumn.Index; + foreach (DataGridViewRow row in rows) { + String name = row.Cells[nameCellIndex].Value as string; if (String.IsNullOrEmpty(name)) - return; - DataGridViewCheckBoxCell checkBoxCell = cells[checkBoxIndex] as DataGridViewCheckBoxCell; - if (selectedRows.Count > 1) - checkBoxCell.Value = valueOfCheckBoxes; + continue; + DataGridViewCheckBoxCell checkBoxCell = row.Cells[0] as DataGridViewCheckBoxCell; + if (rows.Count > 1) + checkBoxCell.Value = !hasChecked; else checkBoxCell.Value = (checkBoxCell.Value == null || checkBoxCell.Value.Equals(false)) ? true : false; + if (checkBoxCell.Value.Equals(false)) - selectedSourceRows.Remove(actualRow); - else { - if (!selectedSourceRows.Contains(actualRow)) - selectedSourceRows.Add(actualRow); - } - SetTextSelectedSourceTextFromCheckBoxes(); - SetMetadataButtonEnabled((bool)checkBoxCell.Value); + selectedSourceRows.Remove(row); + else + selectedSourceRows.Add(row); } + SetSelectedSource(nameCellIndex); } - private bool GetValueOfCheckBoxes(DataGridViewSelectedRowCollection selectedRows) { - bool result = true; - int index = dataGridSource.Columns.Cast().Where(x => x.GetType() == typeof(DataGridViewCheckBoxColumn)).SingleOrDefault().Index; - foreach (DataGridViewRow actualRow in selectedRows) { - var cells = actualRow.Cells; - DataGridViewCheckBoxCell checkBoxCell = cells[index] as DataGridViewCheckBoxCell; - if (checkBoxCell.Value != null && checkBoxCell.Value.Equals(true)) - result = false; - else { result = true; return result; } - } - return result; + private string GetPrefix(string name) { + string[] byHyphen = name.Replace('_', '-').Replace('.', '-').Split('-'); + return byHyphen.Length > 0 ? byHyphen[0] : null; } - private void SetMetadataButtonEnabled(bool checkBox) { - SetStartingName(checkBox); - if (selectedSourceRows == null || selectedSourceRows.Count == 0) { - buttonMetadata.Enabled = false; - - //IsSelectedFileAnID(); - return; - } - if (selectedSourceRows.Count == 1) { - buttonMetadata.Enabled = true; - //IsSelectedFileAnID(); - return; - } - int index = dataGridSource.Columns.Cast().Where(x => x.HeaderText == StringResources.NEV).SingleOrDefault().Index; + private void SetSelectedSource(int nameCellIndex) { + string selectionPrefix = null; + string selectedNames = String.Empty; foreach (DataGridViewRow actual in selectedSourceRows) { - string name = actual.Cells[index].Value as string; - if (!name.StartsWith(String.Format("{0}-", startingName)) && - !name.StartsWith(String.Format("{0}_", startingName)) && - !name.StartsWith(String.Format("{0}.", startingName))) { - buttonMetadata.Enabled = false; - return; - } - } - buttonMetadata.Enabled = true; - //IsSelectedFileAnID(); - } - - private void SetStartingName(bool checkBox) { - if (!checkBox) - if (selectedSourceRows == null || selectedSourceRows.Count == 0) { - startingName = null; - return; - } - int index = dataGridSource.Columns.Cast().Where(x => x.HeaderText == StringResources.NEV).SingleOrDefault().Index; - string query = selectedSourceRows[0].Cells[index].Value as string; - int separatorPosition = query.IndexOf("-"); - int separatorPosition2 = query.IndexOf("_"); - int realseparatorPosition = 0; - if (separatorPosition < 0) - realseparatorPosition = separatorPosition2; - else if (separatorPosition2 < 0) - realseparatorPosition = separatorPosition; - else - realseparatorPosition = separatorPosition < separatorPosition2 ? separatorPosition : separatorPosition2; - int dotPosition = query.IndexOf("."); - if (realseparatorPosition > 0) { - startingName = realseparatorPosition < 0 ? query : query.Substring(0, realseparatorPosition); - } else { - if (dotPosition < 0) - startingName = realseparatorPosition < 0 ? query : query.Substring(0, realseparatorPosition); + string name = actual.Cells[nameCellIndex].Value as string; + selectedNames += name + " "; + string currentPrefix = GetPrefix(name); + if (selectionPrefix == null) + selectionPrefix = currentPrefix; else - startingName = query.Substring(0, dotPosition); + selectionPrefix = currentPrefix.Equals(selectionPrefix) ? selectionPrefix : null; } - - SourceIDType = GetSourceType(startingName); - UpdateDetectMetadataEnabled(); - } - - private void SetTextSelectedSourceTextFromCheckBoxes() { - String selectedNames = ""; - int index = dataGridSource.Columns.Cast().Where(x => x.HeaderText == StringResources.NEV).SingleOrDefault().Index; - foreach (DataGridViewRow actual in selectedSourceRows) - selectedNames += actual.Cells[index].Value + " "; SelectedSource = new SourceInfo() { - Name = selectedNames + Name = selectedNames, + FileInfo = GetSelectedSourceFileInfo(nameCellIndex), + Prefix = selectionPrefix }; - SetSelectedSourceFileInfo(SelectedSource); - ApplyProcessorButtonsLogicWithoutArchiveMetadataButton(); } - private void SetSelectedSourceFileInfo(SourceInfo selectedSource) { + private FileInfo GetSelectedSourceFileInfo(int nameCellIndex) { if (Configuration.Source.GetType() == typeof(NEXIOSource)) - selectedSource.FileInfo = null; - else if (selectedSourceRows.Count == 1) { - int index = dataGridSource.Columns.Cast().Where(x => x.HeaderText == StringResources.NEV).SingleOrDefault().Index; - string name = selectedSourceRows[0].Cells[index].Value as string; - Uri inputUri = new Uri(String.Format("{0}/{1}", Configuration.Source.Local.Address.LocalPath, name)); - selectedSource.FileInfo = new System.IO.FileInfo(inputUri.LocalPath); - } + return null; + if (selectedSourceRows.Count != 1) + return null; + string name = selectedSourceRows[0].Cells[nameCellIndex].Value as string; + Uri inputUri = new Uri(String.Format("{0}/{1}", Configuration.Source.Local.Address.LocalPath, name)); + return new FileInfo(inputUri.LocalPath); } private void dataGridSource_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { @@ -261,17 +206,17 @@ namespace Maestro { private void dataGridSource_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex < 0) return; - UpdateSelectedSources(); + UpdateCheckStates(dataGridSource.SelectedRows); } private void dataGridSource_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode != Keys.Space || dataGridSource.CurrentCell.GetType() == typeof(DataGridViewCheckBoxCell)) return; - UpdateSelectedSources(); + UpdateCheckStates(dataGridSource.SelectedRows); } private void buttonMetadata_Click(object sender, EventArgs e) { - switch (SourceIDType) { + switch (GetSourceType(SelectedSource?.Prefix)) { case SourceIDType.TrafficID: LookupTraffic(); break; @@ -285,16 +230,16 @@ namespace Maestro { TrafficAPI api = trafficIDSelector.trafficAPI; Cursor.Current = Cursors.WaitCursor; List result = null; - MetadataType metadataType = GetTrafficMetadataType(startingName); + MetadataType metadataType = GetTrafficMetadataType(SelectedSource?.Prefix); switch (metadataType) { case MetadataType.TrafficMaterial: - result = api.GetMaterials(startingName, false); + result = api.GetMaterials(SelectedSource?.Prefix, false); break; case MetadataType.TrafficPromo: - result = api.GetPromos(startingName, false); + result = api.GetPromos(SelectedSource?.Prefix, false); break; case MetadataType.TrafficAD: - result = api.GetADs(startingName, false); + result = api.GetADs(SelectedSource?.Prefix, false); break; } if (result == null || result.Count == 0) { @@ -317,7 +262,7 @@ namespace Maestro { private void LookupOctopus() { OctopusAPI api = octopusIDSelector.GetClient(); Cursor.Current = Cursors.WaitCursor; - IEnumerable stories = api.GetStoriesById(startingName); + IEnumerable stories = api.GetStoriesById(SelectedSource?.Prefix); if (stories == null || stories.Count() == 0) { LookupOctopusMOS(api); Cursor.Current = Cursors.Default; @@ -336,7 +281,7 @@ namespace Maestro { } private void LookupOctopusMOS(OctopusAPI api) { - IEnumerable mosIDs = api.GetMosObjectsByID(startingName); + IEnumerable mosIDs = api.GetMosObjectsByID(SelectedSource?.Prefix); if (mosIDs == null) { MessageBox.Show(this, StringResources.NINCS_TALALAT); return; @@ -357,8 +302,8 @@ namespace Maestro { box.ShowDialog(); } - private void UpdateDetectMetadataEnabled() { - buttonMetadata.Enabled = SourceIDType != SourceIDType.MediaCube; + private void UpdateLookupMetadataEnabled() { + buttonMetadata.Enabled = !String.IsNullOrEmpty(SelectedSource?.Prefix) && GetSourceType(SelectedSource?.Prefix) != SourceIDType.MediaCube; } } diff --git a/client/Maestro/MaestroForm.Target.cs b/client/Maestro/MaestroForm.Target.cs index a67fe8bb..5f3fce01 100644 --- a/client/Maestro/MaestroForm.Target.cs +++ b/client/Maestro/MaestroForm.Target.cs @@ -43,7 +43,7 @@ namespace Maestro { CreateTarget(target); } - ApplyProcessorButtonsLogic(); + UpdateProcessorButtonsEnabled(); segmentConverter = new SegmentConverter(); } @@ -210,24 +210,10 @@ namespace Maestro { } private void OnMetadataIDChanged(object sender, EventArgs e) { - ApplyProcessorButtonsLogic(); - ApplyMetaDataButtonLogic(); - } - - private void ApplyMetaDataButtonLogic() { - if (selectedSourceRows.Count <= 0) { - buttonMetadata.Enabled = false; - return; - } - if (selectedSourceRows.Count == 1) - buttonMetadata.Enabled = true; - else { - foreach (DataGridViewRow actualRow in selectedSourceRows) { - string actualName = (actualRow.DataBoundItem as ISourceItem).Name; - if (!actualName.StartsWith(startingName)) - buttonMetadata.Enabled = false; - } - } + UpdateProcessorButtonsEnabled(); + UpdateDefineSegmentEnabled(); + UpdateEditArchiveMetadataEnabled(); + UpdateLookupMetadataEnabled(); } private void ChangeProcessButtonsState(bool enabled) { @@ -237,16 +223,13 @@ namespace Maestro { c.Enabled = enabled; } - private void ApplyProcessorButtonsLogic() { + private void UpdateProcessorButtonsEnabled() { ClearSelectedProcessors(); if (!String.IsNullOrEmpty(textSelectedMetadata.Text) && !String.IsNullOrEmpty(textSelectedMetadata.Text)) { ChangeProcessButtonsState(true); } else { ChangeProcessButtonsState(false); } - - UpdateDefineSegmentEnabled(); - UpdateEditArchiveMetadataEnabled(); } public void OnTargetPanelsMouseClick(object sender, MouseEventArgs e) { @@ -270,16 +253,6 @@ namespace Maestro { ActivateTabOnTabControl2(0); } - private void ApplyProcessorButtonsLogicWithoutArchiveMetadataButton() { - ClearSelectedProcessors(); - if (!String.IsNullOrEmpty(textSelectedMetadata.Text) && !String.IsNullOrEmpty(textSelectedMetadata.Text)) { - ChangeProcessButtonsState(true); - } else { - ChangeProcessButtonsState(false); - } - - UpdateDefineSegmentEnabled(); - } } } diff --git a/client/Maestro/MaestroForm.cs b/client/Maestro/MaestroForm.cs index 3d67fd99..ea53ee2e 100644 --- a/client/Maestro/MaestroForm.cs +++ b/client/Maestro/MaestroForm.cs @@ -12,7 +12,6 @@ using System.Windows.Forms; using System.Threading; using TrafficClient; using OctopusClient; -using System.Linq; using System.IO; namespace Maestro { diff --git a/client/Maestro/Sources/FileSourceItem.cs b/client/Maestro/Sources/FileSourceItem.cs index b90f88c5..6aab995a 100644 --- a/client/Maestro/Sources/FileSourceItem.cs +++ b/client/Maestro/Sources/FileSourceItem.cs @@ -11,6 +11,7 @@ namespace Maestro.Sources { private FileInfo fileInfo; private Icon icon; private bool isHighlighted; + private bool isChecked; private static string[] sizes = { "", "KB", "MB", "GB", "TB" }; public event PropertyChangedEventHandler PropertyChanged; @@ -30,6 +31,18 @@ namespace Maestro.Sources { } } + public bool IsChecked { + get { + return isChecked; + } + set { + if (isChecked != value) { + isChecked = value; + NotifyPropertyChanged(); + } + } + } + public bool IsHighlighted { get { return isHighlighted; diff --git a/client/Maestro/Sources/FileSystemSource.cs b/client/Maestro/Sources/FileSystemSource.cs index 0d277666..632e17f8 100644 --- a/client/Maestro/Sources/FileSystemSource.cs +++ b/client/Maestro/Sources/FileSystemSource.cs @@ -31,6 +31,9 @@ namespace Maestro.Sources { public DataGridViewColumn[] Columns { get { DataGridViewColumn[] result = new DataGridViewColumn[] { + new DataGridViewCheckBoxColumn(){ + DataPropertyName = "IsChecked" + }, new DataGridViewImageColumn(){ DataPropertyName = "Icon", //HeaderText = StringResources.LEJATSZAS, diff --git a/client/Maestro/Sources/ISourceItem.cs b/client/Maestro/Sources/ISourceItem.cs index 749c2826..eb43f6cd 100644 --- a/client/Maestro/Sources/ISourceItem.cs +++ b/client/Maestro/Sources/ISourceItem.cs @@ -6,5 +6,7 @@ namespace Maestro.Sources { string Name { get; } DateTime Created { get; } bool IsHighlighted { get; set; } + bool IsChecked { get; set; } + } } \ No newline at end of file diff --git a/client/Maestro/Sources/NexioSourceItem.cs b/client/Maestro/Sources/NexioSourceItem.cs index 2b9fd6ea..19308822 100644 --- a/client/Maestro/Sources/NexioSourceItem.cs +++ b/client/Maestro/Sources/NexioSourceItem.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; namespace Maestro.Sources { public class NexioSourceItem : ISourceItem { private bool isHighlighted; + private bool isChecked; private string name; private DateTime created; private DateTime modified; @@ -28,6 +29,17 @@ namespace Maestro.Sources { } } + public bool IsChecked { + get { + return isChecked; + } + set { + if (isChecked != value) { + isChecked = value; + NotifyPropertyChanged(); + } + } + } public DateTime Created { get { diff --git a/client/Maestro/Sources/SourceInfo.cs b/client/Maestro/Sources/SourceInfo.cs index 6a0aa418..71f50e89 100644 --- a/client/Maestro/Sources/SourceInfo.cs +++ b/client/Maestro/Sources/SourceInfo.cs @@ -5,5 +5,6 @@ namespace Maestro.Metadata { public FileInfo FileInfo { get; set; } public string Tooltip { get; set; } public string Name { get; set; } + public string Prefix { get; set; } } } diff --git a/client/OctopusClient/OctopusIDSelector.Designer.cs b/client/OctopusClient/OctopusIDSelector.Designer.cs index 056baa0d..f5c9aa33 100644 --- a/client/OctopusClient/OctopusIDSelector.Designer.cs +++ b/client/OctopusClient/OctopusIDSelector.Designer.cs @@ -64,7 +64,7 @@ this.comboRudowns.TabIndex = 3; this.comboRudowns.SelectedValueChanged += new System.EventHandler(this.comboRudowns_SelectedValueChanged); // - // treeContent + // treeOctopus // this.treeOctopus.BackColor = System.Drawing.Color.White; this.treeOctopus.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -72,7 +72,7 @@ this.treeOctopus.Dock = System.Windows.Forms.DockStyle.Fill; this.treeOctopus.FullRowSelect = true; this.treeOctopus.Location = new System.Drawing.Point(10, 70); - this.treeOctopus.Name = "treeContent"; + this.treeOctopus.Name = "treeOctopus"; this.treeOctopus.Size = new System.Drawing.Size(251, 273); this.treeOctopus.TabIndex = 5; this.treeOctopus.KeyDown += new System.Windows.Forms.KeyEventHandler(this.treeContent_KeyDown); @@ -90,23 +90,23 @@ this.tabControl1.Selected += new System.Windows.Forms.TabControlEventHandler(this.tabControl1_Selected); this.tabControl1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tabControl1_KeyDown); // - // tabPage1 + // tpRundown // this.tpRundown.Controls.Add(this.dateScheduled); this.tpRundown.Controls.Add(this.comboRudowns); this.tpRundown.Location = new System.Drawing.Point(4, 22); - this.tpRundown.Name = "tabPage1"; + this.tpRundown.Name = "tpRundown"; this.tpRundown.Padding = new System.Windows.Forms.Padding(3); this.tpRundown.Size = new System.Drawing.Size(243, 34); this.tpRundown.TabIndex = 0; this.tpRundown.Text = "Rundown"; this.tpRundown.UseVisualStyleBackColor = true; // - // tabPage2 + // tpStoryFolder // this.tpStoryFolder.Controls.Add(this.comboStoryFolder); this.tpStoryFolder.Location = new System.Drawing.Point(4, 22); - this.tpStoryFolder.Name = "tabPage2"; + this.tpStoryFolder.Name = "tpStoryFolder"; this.tpStoryFolder.Padding = new System.Windows.Forms.Padding(3); this.tpStoryFolder.Size = new System.Drawing.Size(243, 34); this.tpStoryFolder.TabIndex = 1; diff --git a/client/OctopusClient/OctopusIDSelector.cs b/client/OctopusClient/OctopusIDSelector.cs index 276618f0..7bc36b06 100644 --- a/client/OctopusClient/OctopusIDSelector.cs +++ b/client/OctopusClient/OctopusIDSelector.cs @@ -5,12 +5,15 @@ using System.Windows.Forms; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; +using System.Runtime.InteropServices; namespace OctopusClient { public delegate void OnSelectedIDChanged(string ID); public delegate void ClearCheckBox(); public delegate void OctopusErrorReporterDelegate(DateTime time, String level, String message, Color color); + + public partial class OctopusIDSelector : UserControl { private static Logger logger = LogManager.GetCurrentClassLogger(); private string id; @@ -62,9 +65,11 @@ namespace OctopusClient { foreach (var story in stories) { string name = story.Name == null ? "" : story.Name; TreeNode actualNode = treeOctopus.Nodes.Add(story.ID, String.Format($"{story.ID} {story.Name}")); + HideCheckBox(treeOctopus, actualNode); MosObject[] mosObjects = story.MosObjects; - foreach (MosObject mosObject in mosObjects) + foreach (MosObject mosObject in mosObjects) { actualNode.Nodes.Add(mosObject.ID, mosObject.ID); + } } selectedRundownIndex = comboRudowns.SelectedIndex; } @@ -82,6 +87,7 @@ namespace OctopusClient { return; foreach (var story in stories) { TreeNode actualNode = treeOctopus.Nodes.Add(story.ID, String.Format($"{story.ID} {story.Name}")); + HideCheckBox(treeOctopus, actualNode); MosObject[] mosObjects = story.MosObjects; foreach (MosObject mosObject in mosObjects) actualNode.Nodes.Add(mosObject.ID, mosObject.ID); @@ -183,11 +189,18 @@ namespace OctopusClient { } private void treeContent_KeyDown(object sender, KeyEventArgs e) { - this.OnKeyDown(e); + //this.OnKeyDown(e); } private void OnTreeAfterCheck(object sender, TreeViewEventArgs e) { logger.Debug("Handling {0} {1}", e.Node.Name, e.Node.Text); + if (e.Node.Level == 0) { + if (e.Node.Checked) { + e.Node.Checked = false; + HideCheckBox(treeOctopus, e.Node); + } + return; + } if (!e.Node.Equals(selectedNode)) { ClearSelection(); selectedNode = e.Node; @@ -211,5 +224,42 @@ namespace OctopusClient { public OctopusAPI GetClient() { return client; } + + + private const int TVIF_STATE = 0x8; + private const int TVIS_STATEIMAGEMASK = 0xF000; + private const int TV_FIRST = 0x1100; + private const int TVM_SETITEM = TV_FIRST + 63; + + [StructLayout(LayoutKind.Sequential, Pack = 8, CharSet = CharSet.Auto)] + private struct TVITEM { + public int mask; + public IntPtr hItem; + public int state; + public int stateMask; + [MarshalAs(UnmanagedType.LPTStr)] + public string lpszText; + public int cchTextMax; + public int iImage; + public int iSelectedImage; + public int cChildren; + public IntPtr lParam; + } + + [DllImport("user32.dll", CharSet = CharSet.Auto)] + private static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, + ref TVITEM lParam); + + /// + /// Hides the checkbox for the specified node on a TreeView control. + /// + private void HideCheckBox(TreeView tvw, TreeNode node) { + TVITEM tvi = new TVITEM(); + tvi.hItem = node.Handle; + tvi.mask = TVIF_STATE; + tvi.stateMask = TVIS_STATEIMAGEMASK; + tvi.state = 0; + SendMessage(tvw.Handle, TVM_SETITEM, IntPtr.Zero, ref tvi); + } } } diff --git a/client/OctopusClient/OctopusIDSelector.resx b/client/OctopusClient/OctopusIDSelector.resx index f50ab11f..0518ece7 100644 --- a/client/OctopusClient/OctopusIDSelector.resx +++ b/client/OctopusClient/OctopusIDSelector.resx @@ -120,6 +120,12 @@ 17, 17 + + 17, 17 + + + 155, 17 + 155, 17