diff --git a/src/Controls/SubtitleListView.cs b/src/Controls/SubtitleListView.cs index 5a3d48e5e..f8f53e5bb 100644 --- a/src/Controls/SubtitleListView.cs +++ b/src/Controls/SubtitleListView.cs @@ -14,12 +14,15 @@ namespace Nikse.SubtitleEdit.Controls public const int ColumnIndexDuration = 3; public const int ColumnIndexText = 4; public const int ColumnIndexTextAlternate = 5; + public int ColumnIndexExtra = 5; private int _firstVisibleIndex = -1; private string _lineSeparatorString = " || "; public string SubtitleFontName = "Tahoma"; public bool SubtitleFontBold = false; public int SubtitleFontSize = 8; + public bool IsAlternateTextColumnVisible { get; private set; } + public bool IsExtraColumnVisible { get; private set; } public int FirstVisibleIndex { @@ -62,36 +65,40 @@ namespace Nikse.SubtitleEdit.Controls GridLines = true; } - public void AddAlternateTextColumn(string text) + public void ShowAlternateTextColumn(string text) { - if (!IsColumTextAlternateActive) + if (!IsAlternateTextColumnVisible) { - Columns.Add(new ColumnHeader { Text = text, Width = -2 }); + ColumnIndexExtra = ColumnIndexTextAlternate + 1; + if (IsExtraColumnVisible) + { + Columns.Insert(ColumnIndexTextAlternate, new ColumnHeader { Text = text, Width = -2 }); + } + else + { + Columns.Add(new ColumnHeader { Text = text, Width = -2 }); + } int length = Columns[ColumnIndexNumber].Width + Columns[ColumnIndexStart].Width + Columns[ColumnIndexEnd].Width + Columns[ColumnIndexDuration].Width; int lengthAvailable = this.Width - length; Columns[ColumnIndexText].Width = (lengthAvailable / 2) - 15; Columns[ColumnIndexTextAlternate].Width = -2; + + IsAlternateTextColumnVisible = true; } } - public void RemoveAlternateTextColumn() + public void HideAlternateTextColumn() { - if (IsColumTextAlternateActive) + if (IsAlternateTextColumnVisible) { + IsAlternateTextColumnVisible = false; Columns.RemoveAt(ColumnIndexTextAlternate); + ColumnIndexExtra = ColumnIndexTextAlternate; SubtitleListView_Resize(null, null); } } - public bool IsColumTextAlternateActive - { - get - { - return Columns.Count - 1 >= ColumnIndexTextAlternate; - } - } - void SubtitleListView_Resize(object sender, EventArgs e) { int width = 0; @@ -303,6 +310,85 @@ namespace Nikse.SubtitleEdit.Controls Items[index].SubItems[ColumnIndexText].Text = text.Replace(Environment.NewLine, _lineSeparatorString); } + public void SetTimeAndText(int index, Paragraph paragraph) + { + if (index >= 0 && index < Items.Count) + { + ListViewItem item = Items[index]; + item.SubItems[ColumnIndexStart].Text = paragraph.StartTime.ToString(); + item.SubItems[ColumnIndexEnd].Text = paragraph.EndTime.ToString(); + item.SubItems[ColumnIndexDuration].Text = string.Format("{0},{1:000}", paragraph.Duration.Seconds, paragraph.Duration.Milliseconds); + Items[index].SubItems[ColumnIndexText].Text = paragraph.Text.Replace(Environment.NewLine, _lineSeparatorString); + } + } + + public void ShowExtraColumn(string title) + { + if (!IsExtraColumnVisible) + { + if (IsAlternateTextColumnVisible) + ColumnIndexExtra = ColumnIndexTextAlternate + 1; + else + ColumnIndexExtra = ColumnIndexTextAlternate; + + Columns.Add(new ColumnHeader { Text = title, Width = 80 }); + + int length = Columns[ColumnIndexNumber].Width + Columns[ColumnIndexStart].Width + Columns[ColumnIndexEnd].Width + Columns[ColumnIndexDuration].Width; + int lengthAvailable = this.Width - length; + + if (IsAlternateTextColumnVisible) + { + int part = lengthAvailable / 5; + Columns[ColumnIndexText].Width = part * 2; + Columns[ColumnIndexTextAlternate].Width = part * 2; + Columns[ColumnIndexTextAlternate].Width = part; + } + else + { + int part = lengthAvailable / 6; + Columns[ColumnIndexText].Width = part * 4; + Columns[ColumnIndexTextAlternate].Width = part * 2; + } + IsExtraColumnVisible = true; + } + } + + public void HideExtraColumn() + { + if (IsExtraColumnVisible) + { + IsExtraColumnVisible = false; + Columns.RemoveAt(ColumnIndexExtra); + SubtitleListView_Resize(null, null); + } + } + + public void SetExtraText(int index, string text, Color color) + { + if (index >= 0 && index < Items.Count) + { + if (IsAlternateTextColumnVisible) + ColumnIndexExtra = ColumnIndexTextAlternate + 1; + else + ColumnIndexExtra = ColumnIndexTextAlternate; + if (!IsExtraColumnVisible) + { + ShowExtraColumn(string.Empty); + } + if (Items[index].SubItems.Count <= ColumnIndexExtra) + Items[index].SubItems.Add(new ListViewItem.ListViewSubItem()); + if (Items[index].SubItems.Count <= ColumnIndexExtra) + Items[index].SubItems.Add(new ListViewItem.ListViewSubItem()); + Items[index].SubItems[ColumnIndexExtra].Text = text; + + + Items[index].UseItemStyleForSubItems = false; + Items[index].SubItems[ColumnIndexExtra].BackColor = Color.AntiqueWhite; + Items[index].SubItems[ColumnIndexExtra].ForeColor = color; + + } + } + public void SetAlternateText(int index, string text) { if (index >= 0 && index < Items.Count && Columns.Count >= ColumnIndexTextAlternate + 1) @@ -406,7 +492,7 @@ namespace Nikse.SubtitleEdit.Controls Columns[ColumnIndexNumber].Width = 45; Columns[ColumnIndexEnd].Width = 80; Columns[ColumnIndexDuration].Width = 55; - if (IsColumTextAlternateActive) + if (IsAlternateTextColumnVisible) { Columns[ColumnIndexText].Width = 250; Columns[ColumnIndexTextAlternate].Width = -2; diff --git a/src/Forms/EffectTypewriter.cs b/src/Forms/EffectTypewriter.cs index 2037767a2..f1bd20969 100644 --- a/src/Forms/EffectTypewriter.cs +++ b/src/Forms/EffectTypewriter.cs @@ -21,7 +21,6 @@ namespace Nikse.SubtitleEdit.Forms buttonPreview.Text = Configuration.Settings.Language.General.Preview; buttonOK.Text = Configuration.Settings.Language.General.OK; buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - } public List TypewriterParagraphs diff --git a/src/Forms/Main.Designer.cs b/src/Forms/Main.Designer.cs index dd25ee17b..1b9cf2745 100644 --- a/src/Forms/Main.Designer.cs +++ b/src/Forms/Main.Designer.cs @@ -33,6 +33,7 @@ this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.labelStatus = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripSelected = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusNetworking = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStrip1 = new System.Windows.Forms.ToolStrip(); this.toolStripButtonFileNew = new System.Windows.Forms.ToolStripButton(); this.toolStripButtonFileOpen = new System.Windows.Forms.ToolStripButton(); @@ -138,12 +139,19 @@ this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.changeLanguageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemNetworking = new System.Windows.Forms.ToolStripMenuItem(); + this.startServerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.joinSessionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.chatToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.showSessionKeyLogToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.leaveSessionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.helpToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.tabControlSubtitle = new System.Windows.Forms.TabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.labelCharactersPerSecond = new System.Windows.Forms.Label(); this.labelAutoDuration = new System.Windows.Forms.Label(); this.panelSingleLine = new System.Windows.Forms.Panel(); this.labelTextLineTotal = new System.Windows.Forms.Label(); @@ -217,7 +225,7 @@ this.panelVideoPlayer = new System.Windows.Forms.Panel(); this.labelSubtitle = new System.Windows.Forms.Label(); this.mediaPlayer = new Nikse.SubtitleEdit.Controls.VideoPlayerContainer(); - this.checkBoxSyncListViewWithVideWhilePlaying = new System.Windows.Forms.CheckBox(); + this.checkBoxSyncListViewWithVideoWhilePlaying = new System.Windows.Forms.CheckBox(); this.labelVideoInfo = new System.Windows.Forms.Label(); this.trackBarWaveFormPosition = new System.Windows.Forms.TrackBar(); this.panelWaveFormControls = new System.Windows.Forms.Panel(); @@ -284,7 +292,7 @@ this.buttonAdjustSecForward1 = new System.Windows.Forms.Button(); this.numericUpDownSecAdjust1 = new System.Windows.Forms.NumericUpDown(); this.buttonAdjustSecBack1 = new System.Windows.Forms.Button(); - this.label4 = new System.Windows.Forms.Label(); + this.labelVideoPosition2 = new System.Windows.Forms.Label(); this.buttonAdjustGoToPosAndPause = new System.Windows.Forms.Button(); this.buttonAdjustPlayBefore = new System.Windows.Forms.Button(); this.timeUpDownVideoPositionAdjust = new Nikse.SubtitleEdit.Controls.TimeUpDown(); @@ -301,7 +309,6 @@ this.mergeWithNextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator11 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripMenuItemWaveFormPlaySelection = new System.Windows.Forms.ToolStripMenuItem(); - this.labelCharactersPerSecond = new System.Windows.Forms.Label(); this.statusStrip1.SuspendLayout(); this.toolStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout(); @@ -336,7 +343,8 @@ this.statusStrip1.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.labelStatus, - this.toolStripSelected}); + this.toolStripSelected, + this.toolStripStatusNetworking}); this.statusStrip1.Location = new System.Drawing.Point(0, 658); this.statusStrip1.Name = "statusStrip1"; this.statusStrip1.Size = new System.Drawing.Size(1502, 25); @@ -354,11 +362,22 @@ // this.toolStripSelected.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; this.toolStripSelected.Name = "toolStripSelected"; - this.toolStripSelected.Size = new System.Drawing.Size(787, 20); + this.toolStripSelected.Size = new System.Drawing.Size(570, 20); this.toolStripSelected.Spring = true; this.toolStripSelected.Text = "toolStripSelected"; this.toolStripSelected.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // + // toolStripStatusNetworking + // + this.toolStripStatusNetworking.Image = global::Nikse.SubtitleEdit.Properties.Resources.connect; + this.toolStripStatusNetworking.Name = "toolStripStatusNetworking"; + this.toolStripStatusNetworking.Padding = new System.Windows.Forms.Padding(50, 0, 0, 0); + this.toolStripStatusNetworking.Size = new System.Drawing.Size(217, 20); + this.toolStripStatusNetworking.Text = "toolStripStatusNetworking"; + this.toolStripStatusNetworking.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.toolStripStatusNetworking.TextImageRelation = System.Windows.Forms.TextImageRelation.TextBeforeImage; + this.toolStripStatusNetworking.Click += new System.EventHandler(this.toolStripStatusNetworking_Click); + // // toolStrip1 // this.toolStrip1.AutoSize = false; @@ -652,6 +671,7 @@ this.toolStripMenuItemSyncronization, this.toolStripMenuItemAutoTranslate, this.optionsToolStripMenuItem, + this.toolStripMenuItemNetworking, this.helpToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; @@ -1277,6 +1297,54 @@ this.changeLanguageToolStripMenuItem.Text = "Change language..."; this.changeLanguageToolStripMenuItem.Click += new System.EventHandler(this.ChangeLanguageToolStripMenuItemClick); // + // toolStripMenuItemNetworking + // + this.toolStripMenuItemNetworking.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.startServerToolStripMenuItem, + this.joinSessionToolStripMenuItem, + this.chatToolStripMenuItem, + this.showSessionKeyLogToolStripMenuItem, + this.leaveSessionToolStripMenuItem}); + this.toolStripMenuItemNetworking.Name = "toolStripMenuItemNetworking"; + this.toolStripMenuItemNetworking.Size = new System.Drawing.Size(82, 20); + this.toolStripMenuItemNetworking.Text = "Networking"; + this.toolStripMenuItemNetworking.DropDownOpening += new System.EventHandler(this.toolStripMenuItemNetworking_DropDownOpening); + // + // startServerToolStripMenuItem + // + this.startServerToolStripMenuItem.Name = "startServerToolStripMenuItem"; + this.startServerToolStripMenuItem.Size = new System.Drawing.Size(215, 22); + this.startServerToolStripMenuItem.Text = "Start new session"; + this.startServerToolStripMenuItem.Click += new System.EventHandler(this.startServerToolStripMenuItem_Click); + // + // joinSessionToolStripMenuItem + // + this.joinSessionToolStripMenuItem.Name = "joinSessionToolStripMenuItem"; + this.joinSessionToolStripMenuItem.Size = new System.Drawing.Size(215, 22); + this.joinSessionToolStripMenuItem.Text = "Join session"; + this.joinSessionToolStripMenuItem.Click += new System.EventHandler(this.joinSessionToolStripMenuItem_Click); + // + // chatToolStripMenuItem + // + this.chatToolStripMenuItem.Name = "chatToolStripMenuItem"; + this.chatToolStripMenuItem.Size = new System.Drawing.Size(215, 22); + this.chatToolStripMenuItem.Text = "Chat"; + this.chatToolStripMenuItem.Click += new System.EventHandler(this.chatToolStripMenuItem_Click); + // + // showSessionKeyLogToolStripMenuItem + // + this.showSessionKeyLogToolStripMenuItem.Name = "showSessionKeyLogToolStripMenuItem"; + this.showSessionKeyLogToolStripMenuItem.Size = new System.Drawing.Size(215, 22); + this.showSessionKeyLogToolStripMenuItem.Text = "Show session info and log"; + this.showSessionKeyLogToolStripMenuItem.Click += new System.EventHandler(this.showSessionKeyLogToolStripMenuItem_Click); + // + // leaveSessionToolStripMenuItem + // + this.leaveSessionToolStripMenuItem.Name = "leaveSessionToolStripMenuItem"; + this.leaveSessionToolStripMenuItem.Size = new System.Drawing.Size(215, 22); + this.leaveSessionToolStripMenuItem.Text = "Leave session"; + this.leaveSessionToolStripMenuItem.Click += new System.EventHandler(this.leaveSessionToolStripMenuItem_Click); + // // helpToolStripMenuItem // this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -1290,14 +1358,14 @@ // this.helpToolStripMenuItem1.Name = "helpToolStripMenuItem1"; this.helpToolStripMenuItem1.ShortcutKeys = System.Windows.Forms.Keys.F1; - this.helpToolStripMenuItem1.Size = new System.Drawing.Size(118, 22); + this.helpToolStripMenuItem1.Size = new System.Drawing.Size(152, 22); this.helpToolStripMenuItem1.Text = "Help"; this.helpToolStripMenuItem1.Click += new System.EventHandler(this.HelpToolStripMenuItem1Click); // // aboutToolStripMenuItem // this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem"; - this.aboutToolStripMenuItem.Size = new System.Drawing.Size(118, 22); + this.aboutToolStripMenuItem.Size = new System.Drawing.Size(152, 22); this.aboutToolStripMenuItem.Text = "About"; this.aboutToolStripMenuItem.Click += new System.EventHandler(this.AboutToolStripMenuItemClick); // @@ -1356,6 +1424,16 @@ this.groupBox1.TabIndex = 1; this.groupBox1.TabStop = false; // + // labelCharactersPerSecond + // + this.labelCharactersPerSecond.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.labelCharactersPerSecond.Location = new System.Drawing.Point(1170, 12); + this.labelCharactersPerSecond.Name = "labelCharactersPerSecond"; + this.labelCharactersPerSecond.Size = new System.Drawing.Size(177, 13); + this.labelCharactersPerSecond.TabIndex = 31; + this.labelCharactersPerSecond.Text = "labelCharactersPerSecond"; + this.labelCharactersPerSecond.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // // labelAutoDuration // this.labelAutoDuration.AutoSize = true; @@ -1471,9 +1549,9 @@ // // buttonAutoBreak // - this.buttonAutoBreak.Location = new System.Drawing.Point(136, 75); + this.buttonAutoBreak.Location = new System.Drawing.Point(139, 75); this.buttonAutoBreak.Name = "buttonAutoBreak"; - this.buttonAutoBreak.Size = new System.Drawing.Size(57, 21); + this.buttonAutoBreak.Size = new System.Drawing.Size(64, 21); this.buttonAutoBreak.TabIndex = 4; this.buttonAutoBreak.Text = "Auto br"; this.buttonAutoBreak.UseVisualStyleBackColor = true; @@ -1481,9 +1559,9 @@ // // buttonPrevious // - this.buttonPrevious.Location = new System.Drawing.Point(6, 75); + this.buttonPrevious.Location = new System.Drawing.Point(7, 75); this.buttonPrevious.Name = "buttonPrevious"; - this.buttonPrevious.Size = new System.Drawing.Size(57, 21); + this.buttonPrevious.Size = new System.Drawing.Size(64, 21); this.buttonPrevious.TabIndex = 2; this.buttonPrevious.Text = "< Prev "; this.buttonPrevious.UseVisualStyleBackColor = true; @@ -1491,9 +1569,9 @@ // // buttonNext // - this.buttonNext.Location = new System.Drawing.Point(69, 75); + this.buttonNext.Location = new System.Drawing.Point(73, 75); this.buttonNext.Name = "buttonNext"; - this.buttonNext.Size = new System.Drawing.Size(57, 21); + this.buttonNext.Size = new System.Drawing.Size(64, 21); this.buttonNext.TabIndex = 3; this.buttonNext.Text = "Next >"; this.buttonNext.UseVisualStyleBackColor = true; @@ -1955,7 +2033,7 @@ this.groupBoxVideo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.groupBoxVideo.Controls.Add(this.panelVideoPlayer); - this.groupBoxVideo.Controls.Add(this.checkBoxSyncListViewWithVideWhilePlaying); + this.groupBoxVideo.Controls.Add(this.checkBoxSyncListViewWithVideoWhilePlaying); this.groupBoxVideo.Controls.Add(this.labelVideoInfo); this.groupBoxVideo.Controls.Add(this.trackBarWaveFormPosition); this.groupBoxVideo.Controls.Add(this.panelWaveFormControls); @@ -2008,15 +2086,15 @@ this.mediaPlayer.DragDrop += new System.Windows.Forms.DragEventHandler(this.mediaPlayer_DragDrop); this.mediaPlayer.DragEnter += new System.Windows.Forms.DragEventHandler(this.mediaPlayer_DragEnter); // - // checkBoxSyncListViewWithVideWhilePlaying + // checkBoxSyncListViewWithVideoWhilePlaying // - this.checkBoxSyncListViewWithVideWhilePlaying.AutoSize = true; - this.checkBoxSyncListViewWithVideWhilePlaying.Location = new System.Drawing.Point(561, 11); - this.checkBoxSyncListViewWithVideWhilePlaying.Name = "checkBoxSyncListViewWithVideWhilePlaying"; - this.checkBoxSyncListViewWithVideWhilePlaying.Size = new System.Drawing.Size(207, 17); - this.checkBoxSyncListViewWithVideWhilePlaying.TabIndex = 1; - this.checkBoxSyncListViewWithVideWhilePlaying.Text = "Sync listview with movie when playing"; - this.checkBoxSyncListViewWithVideWhilePlaying.UseVisualStyleBackColor = true; + this.checkBoxSyncListViewWithVideoWhilePlaying.AutoSize = true; + this.checkBoxSyncListViewWithVideoWhilePlaying.Location = new System.Drawing.Point(561, 11); + this.checkBoxSyncListViewWithVideoWhilePlaying.Name = "checkBoxSyncListViewWithVideoWhilePlaying"; + this.checkBoxSyncListViewWithVideoWhilePlaying.Size = new System.Drawing.Size(207, 17); + this.checkBoxSyncListViewWithVideoWhilePlaying.TabIndex = 1; + this.checkBoxSyncListViewWithVideoWhilePlaying.Text = "Sync listview with movie when playing"; + this.checkBoxSyncListViewWithVideoWhilePlaying.UseVisualStyleBackColor = true; // // labelVideoInfo // @@ -2640,7 +2718,7 @@ this.tabPageAdjust.Controls.Add(this.buttonAdjustSecForward1); this.tabPageAdjust.Controls.Add(this.numericUpDownSecAdjust1); this.tabPageAdjust.Controls.Add(this.buttonAdjustSecBack1); - this.tabPageAdjust.Controls.Add(this.label4); + this.tabPageAdjust.Controls.Add(this.labelVideoPosition2); this.tabPageAdjust.Controls.Add(this.buttonAdjustGoToPosAndPause); this.tabPageAdjust.Controls.Add(this.buttonAdjustPlayBefore); this.tabPageAdjust.Controls.Add(this.timeUpDownVideoPositionAdjust); @@ -2827,14 +2905,14 @@ this.buttonAdjustSecBack1.UseVisualStyleBackColor = true; this.buttonAdjustSecBack1.Click += new System.EventHandler(this.buttonAdjustSecBack_Click); // - // label4 + // labelVideoPosition2 // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(9, 219); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(77, 13); - this.label4.TabIndex = 12; - this.label4.Text = "Video position:"; + this.labelVideoPosition2.AutoSize = true; + this.labelVideoPosition2.Location = new System.Drawing.Point(9, 219); + this.labelVideoPosition2.Name = "labelVideoPosition2"; + this.labelVideoPosition2.Size = new System.Drawing.Size(77, 13); + this.labelVideoPosition2.TabIndex = 12; + this.labelVideoPosition2.Text = "Video position:"; // // buttonAdjustGoToPosAndPause // @@ -2950,16 +3028,6 @@ this.toolStripMenuItemWaveFormPlaySelection.Text = "Play selection"; this.toolStripMenuItemWaveFormPlaySelection.Click += new System.EventHandler(this.toolStripMenuItemWaveFormPlaySelection_Click); // - // labelCharactersPerSecond - // - this.labelCharactersPerSecond.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.labelCharactersPerSecond.Location = new System.Drawing.Point(1170, 12); - this.labelCharactersPerSecond.Name = "labelCharactersPerSecond"; - this.labelCharactersPerSecond.Size = new System.Drawing.Size(177, 13); - this.labelCharactersPerSecond.TabIndex = 31; - this.labelCharactersPerSecond.Text = "labelCharactersPerSecond"; - this.labelCharactersPerSecond.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // // Main // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -3239,7 +3307,7 @@ private System.Windows.Forms.NumericUpDown numericUpDownSec1; private System.Windows.Forms.Button buttonForward1; private System.Windows.Forms.Label labelCreateTip; - private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label labelVideoPosition2; private Controls.TimeUpDown timeUpDownVideoPositionAdjust; private System.Windows.Forms.Button buttonAdjustSecForward1; private System.Windows.Forms.NumericUpDown numericUpDownSecAdjust1; @@ -3250,7 +3318,7 @@ private System.Windows.Forms.Button buttonAdjustSecForward2; private System.Windows.Forms.NumericUpDown numericUpDownSecAdjust2; private System.Windows.Forms.Button buttonAdjustSecBack2; - private System.Windows.Forms.CheckBox checkBoxSyncListViewWithVideWhilePlaying; + private System.Windows.Forms.CheckBox checkBoxSyncListViewWithVideoWhilePlaying; private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label6; @@ -3301,6 +3369,13 @@ private System.Windows.Forms.ToolStripMenuItem colorToolStripMenuItem1; private System.Windows.Forms.ToolStripMenuItem fontNameToolStripMenuItem; private System.Windows.Forms.Label labelCharactersPerSecond; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemNetworking; + private System.Windows.Forms.ToolStripMenuItem startServerToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem joinSessionToolStripMenuItem; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusNetworking; + private System.Windows.Forms.ToolStripMenuItem leaveSessionToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem showSessionKeyLogToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem chatToolStripMenuItem; } } diff --git a/src/Forms/Main.cs b/src/Forms/Main.cs index e5053d028..379aab751 100644 --- a/src/Forms/Main.cs +++ b/src/Forms/Main.cs @@ -7,14 +7,14 @@ using System.Text; using System.Text.RegularExpressions; using System.Web; using System.Windows.Forms; -using System.Xml; using Nikse.SubtitleEdit.Controls; using Nikse.SubtitleEdit.Logic; +using Nikse.SubtitleEdit.Logic.BluRaySup; using Nikse.SubtitleEdit.Logic.Enums; using Nikse.SubtitleEdit.Logic.SubtitleFormats; using Nikse.SubtitleEdit.Logic.VideoPlayers; using Nikse.SubtitleEdit.Logic.VobSub; -using Nikse.SubtitleEdit.Logic.BluRaySup; +using Nikse.SubtitleEdit.Logic.Networking; namespace Nikse.SubtitleEdit.Forms { @@ -72,6 +72,8 @@ namespace Nikse.SubtitleEdit.Forms System.Windows.Forms.Timer _timerAutoSave = new Timer(); string _textAutoSave; + NikseWebServiceSession _networkSession; + NetworkChat _networkChat = null; private bool AutoRepeatContinueOn { @@ -92,7 +94,7 @@ namespace Nikse.SubtitleEdit.Forms if (versionInfo.Length >= 3 && versionInfo[2] != "0") _title += "." + versionInfo[2]; } - return _title; + return _title + " Beta"; } } @@ -139,6 +141,7 @@ namespace Nikse.SubtitleEdit.Forms SetLanguage(Configuration.Settings.General.Language); + toolStripStatusNetworking.Visible = false; labelTextLineLengths.Text = string.Empty; labelCharactersPerSecond.Text = string.Empty; labelTextLineTotal.Text = string.Empty; @@ -149,6 +152,7 @@ namespace Nikse.SubtitleEdit.Forms timeUpDownStartTime.TimeCode = new TimeCode(0, 0, 0, 0); checkBoxAutoRepeatOn.Checked = Configuration.Settings.General.AutoRepeatOn; checkBoxAutoContinue.Checked = Configuration.Settings.General.AutoContinueOn; + checkBoxSyncListViewWithVideoWhilePlaying.Checked = Configuration.Settings.General.SyncListViewWithVideoWhilePlaying; SetFormatToSubRip(); @@ -617,7 +621,7 @@ namespace Nikse.SubtitleEdit.Forms tabPageTranslate.Text = _language.VideoControls.Translate; tabPageCreate.Text = _language.VideoControls.Create; tabPageAdjust.Text = _language.VideoControls.Adjust; - checkBoxSyncListViewWithVideWhilePlaying.Text = _language.VideoControls.SelectCurrentElementWhilePlaying; + checkBoxSyncListViewWithVideoWhilePlaying.Text = _language.VideoControls.SelectCurrentElementWhilePlaying; if (_videoFileName == null) labelVideoInfo.Text = Configuration.Settings.Language.General.NoVideoLoaded; @@ -646,6 +650,7 @@ namespace Nikse.SubtitleEdit.Forms buttonForward1.Text = _language.VideoControls.SecondsForwardShort; buttonForward2.Text = _language.VideoControls.SecondsForwardShort; labelVideoPosition.Text = _language.VideoControls.VideoPosition; + labelVideoPosition2.Text = _language.VideoControls.VideoPosition; labelCreateTip.Text = _language.VideoControls.CreateTip; buttonSetStartAndOffsetRest.Text = _language.VideoControls.SetstartTimeAndOffsetOfRest; @@ -1910,9 +1915,11 @@ namespace Nikse.SubtitleEdit.Forms { int line = _findHelper.SelectedIndex; int pos = _findHelper.SelectedPosition; + bool success = _findHelper.Success; _findHelper = replaceDialog.GetFindDialogHelper(_subtitleListViewIndex); _findHelper.SelectedIndex = line; _findHelper.SelectedPosition = pos; + _findHelper.Success = success; } int replaceCount = 0; bool searchStringFound = true; @@ -2009,7 +2016,12 @@ namespace Nikse.SubtitleEdit.Forms else if (!replaceDialog.FindOnly) // replace once only { string msg = string.Empty; - if (textBoxListViewText.SelectionLength == _findHelper.FindTextLength) + if (_findHelper.FindType == FindType.RegEx && _findHelper.Success) + { + textBoxListViewText.SelectedText = _findHelper.ReplaceText; + msg = _language.OneReplacementMade + " "; + } + else if (textBoxListViewText.SelectionLength == _findHelper.FindTextLength) { textBoxListViewText.SelectedText = _findHelper.ReplaceText; msg = _language.OneReplacementMade + " "; @@ -2543,7 +2555,7 @@ namespace Nikse.SubtitleEdit.Forms } ShowSource(); - SubtitleListview1.AddAlternateTextColumn(Configuration.Settings.Language.General.OriginalText); + SubtitleListview1.ShowAlternateTextColumn(Configuration.Settings.Language.General.OriginalText); SubtitleListview1.Fill(_subtitle, _subtitleAlternate); RestoreSubtitleListviewIndexes(); @@ -2629,7 +2641,7 @@ namespace Nikse.SubtitleEdit.Forms startIndex = result.IndexOf(key, startIndex + key.Length); } ShowSource(); - SubtitleListview1.AddAlternateTextColumn(Configuration.Settings.Language.General.OriginalText); + SubtitleListview1.ShowAlternateTextColumn(Configuration.Settings.Language.General.OriginalText); SubtitleListview1.Fill(_subtitle, _subtitleAlternate); ShowStatus(_language.TranslationFromSwedishToDanishComplete); SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex); @@ -2845,10 +2857,10 @@ namespace Nikse.SubtitleEdit.Forms mergeAfterToolStripMenuItem.Visible = true; mergeBeforeToolStripMenuItem.Visible = true; splitLineToolStripMenuItem.Visible = true; - typeEffectToolStripMenuItem.Visible = true; toolStripSeparator7.Visible = true; - karokeeEffectToolStripMenuItem.Visible = true; - toolStripSeparatorAdvancedFunctions.Visible = true; + typeEffectToolStripMenuItem.Visible = _networkSession == null; + karokeeEffectToolStripMenuItem.Visible = _networkSession == null; + toolStripSeparatorAdvancedFunctions.Visible = _networkSession == null; showSelectedLinesEarlierlaterToolStripMenuItem.Visible = true; visualSyncSelectedLinesToolStripMenuItem.Visible = true; googleTranslateSelectedLinesToolStripMenuItem.Visible = true; @@ -2977,24 +2989,35 @@ namespace Nikse.SubtitleEdit.Forms indexes.Add(item.Index); int firstIndex = SubtitleListview1.SelectedItems[0].Index; - int startNumber = _subtitle.Paragraphs[0].Number; - indexes.Reverse(); - foreach (int i in indexes) + if (_networkSession != null) { - _subtitle.Paragraphs.RemoveAt(i); + _networkSession.TimerStop(); + NetworkGetSendUpdates(indexes, 0, null); } - _subtitle.Renumber(startNumber); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - if (SubtitleListview1.FirstVisibleIndex == 0) - SubtitleListview1.FirstVisibleIndex = - 1; - if (SubtitleListview1.Items.Count > firstIndex) + else { - SubtitleListview1.SelectIndexAndEnsureVisible(firstIndex); + int startNumber = _subtitle.Paragraphs[0].Number; + indexes.Reverse(); + foreach (int i in indexes) + { + _subtitle.Paragraphs.RemoveAt(i); + if (_networkSession != null && _networkSession.LastSubtitle != null && i < _networkSession.LastSubtitle.Paragraphs.Count) + _networkSession.LastSubtitle.Paragraphs.RemoveAt(i); + } + _subtitle.Renumber(startNumber); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + if (SubtitleListview1.FirstVisibleIndex == 0) + SubtitleListview1.FirstVisibleIndex = -1; + if (SubtitleListview1.Items.Count > firstIndex) + { + SubtitleListview1.SelectIndexAndEnsureVisible(firstIndex); + } + else if (SubtitleListview1.Items.Count > 0) + { + SubtitleListview1.SelectIndexAndEnsureVisible(SubtitleListview1.Items.Count - 1); + } } - else if (SubtitleListview1.Items.Count > 0) - { - SubtitleListview1.SelectIndexAndEnsureVisible(SubtitleListview1.Items.Count-1); - } + ShowStatus(statusText); ShowSource(); _change = true; @@ -3010,7 +3033,7 @@ namespace Nikse.SubtitleEdit.Forms } private void InsertBefore() - { + { MakeHistoryForUndo(_language.BeforeInsertLine); int startNumber = 1; @@ -3043,11 +3066,18 @@ namespace Nikse.SubtitleEdit.Forms newParagraph.EndTime.TotalMilliseconds = 3000; } - _subtitle.Paragraphs.Insert(firstSelectedIndex, newParagraph); - - _subtitleListViewIndex = -1; - _subtitle.Renumber(startNumber); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + if (_networkSession != null) + { + _networkSession.TimerStop(); + NetworkGetSendUpdates(new List(), firstSelectedIndex, newParagraph); + } + else + { + _subtitle.Paragraphs.Insert(firstSelectedIndex, newParagraph); + _subtitleListViewIndex = -1; + _subtitle.Renumber(startNumber); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + } SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex); ShowSource(); ShowStatus(_language.LineInserted); @@ -3097,10 +3127,17 @@ namespace Nikse.SubtitleEdit.Forms newParagraph.EndTime.TotalMilliseconds = 3000; } - _subtitle.Paragraphs.Insert(firstSelectedIndex, newParagraph); - - _subtitle.Renumber(startNumber); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + if (_networkSession != null) + { + _networkSession.TimerStop(); + NetworkGetSendUpdates(new List(), firstSelectedIndex, newParagraph); + } + else + { + _subtitle.Paragraphs.Insert(firstSelectedIndex, newParagraph); + _subtitle.Renumber(startNumber); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + } SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex); ShowSource(); ShowStatus(_language.LineInserted); @@ -3353,8 +3390,6 @@ namespace Nikse.SubtitleEdit.Forms currentParagraph.EndTime.TotalMilliseconds = middle; newParagraph.StartTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds + 1; - _subtitle.Paragraphs.Insert(firstSelectedIndex + 1, newParagraph); - string[] lines = currentParagraph.Text.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (lines.Length == 2) @@ -3373,8 +3408,17 @@ namespace Nikse.SubtitleEdit.Forms } } - _subtitle.Renumber(startNumber); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + if (_networkSession != null) + { + _networkSession.TimerStop(); + NetworkGetSendUpdates(new List(), firstSelectedIndex, newParagraph); + } + else + { + _subtitle.Paragraphs.Insert(firstSelectedIndex + 1, newParagraph); + _subtitle.Renumber(startNumber); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + } SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex); ShowSource(); ShowStatus(_language.LineSplitted); @@ -3403,16 +3447,24 @@ namespace Nikse.SubtitleEdit.Forms prevParagraph.Text += Environment.NewLine + currentParagraph.Text.Replace(Environment.NewLine, " "); prevParagraph.Text = Utilities.AutoBreakLine(prevParagraph.Text); - // prevParagraph.EndTime.TotalMilliseconds = prevParagraph.EndTime.TotalMilliseconds + currentParagraph.Duration.TotalMilliseconds; prevParagraph.EndTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds; - _subtitle.Paragraphs.Remove(currentParagraph); - - _subtitle.Renumber(startNumber); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - SubtitleListview1.Items[firstSelectedIndex-1].Selected = true; - SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex-1); + if (_networkSession != null) + { + _networkSession.TimerStop(); + List deleteIndices = new List(); + deleteIndices.Add(_subtitle.GetIndex(currentParagraph)); + NetworkGetSendUpdates(deleteIndices, 0, null); + } + else + { + _subtitle.Paragraphs.Remove(currentParagraph); + _subtitle.Renumber(startNumber); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + SubtitleListview1.Items[firstSelectedIndex-1].Selected = true; + } + SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex - 1); ShowSource(); ShowStatus(_language.LinesMerged); SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; @@ -3444,13 +3496,23 @@ namespace Nikse.SubtitleEdit.Forms //currentParagraph.EndTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds + nextParagraph.Duration.TotalMilliseconds; //nextParagraph.EndTime; currentParagraph.EndTime.TotalMilliseconds = nextParagraph.EndTime.TotalMilliseconds; - _subtitle.Paragraphs.Remove(nextParagraph); - - _subtitle.Renumber(startNumber); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex); + if (_networkSession != null) + { + _networkSession.TimerStop(); + _networkSession.UpdateLine(_subtitle.GetIndex(currentParagraph), currentParagraph); + List deleteIndices = new List(); + deleteIndices.Add(_subtitle.GetIndex(nextParagraph)); + NetworkGetSendUpdates(deleteIndices, 0, null); + } + else + { + _subtitle.Paragraphs.Remove(nextParagraph); + _subtitle.Renumber(startNumber); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + } ShowSource(); ShowStatus(_language.LinesMerged); + SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex); SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; RefreshSelectedParagraph(); _change = true; @@ -3582,6 +3644,18 @@ namespace Nikse.SubtitleEdit.Forms } else { + if (_networkSession != null) + { + try + { + _networkSession.TimerStop(); + _networkSession.Leave(); + } + catch + { + } + } + if (Configuration.Settings.General.StartRememberPositionAndSize && WindowState != FormWindowState.Minimized) { Configuration.Settings.General.StartPosition = Left + ";" + Top; @@ -3594,6 +3668,7 @@ namespace Nikse.SubtitleEdit.Forms Configuration.Settings.General.AutoRepeatOn = checkBoxAutoRepeatOn.Checked; Configuration.Settings.General.AutoContinueOn = checkBoxAutoContinue.Checked; + Configuration.Settings.General.SyncListViewWithVideoWhilePlaying = checkBoxSyncListViewWithVideoWhilePlaying.Checked; if (!string.IsNullOrEmpty(_fileName)) Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex); @@ -4404,6 +4479,7 @@ namespace Nikse.SubtitleEdit.Forms { if (mediaPlayer.VideoPlayer != null) { + _endSeconds = -1; mediaPlayer.TooglePlayPause(); e.SuppressKeyPress = true; } @@ -5018,7 +5094,7 @@ namespace Nikse.SubtitleEdit.Forms toolStripSeparatorInsertUnicodeCharacter.Visible = true; } - if (SubtitleListview1.IsColumTextAlternateActive) + if (SubtitleListview1.IsAlternateTextColumnVisible) { toolStripMenuItemTranslationMode.ShortcutKeys = Keys.None; toolStripMenuItemTranslationMode.ShortcutKeyDisplayString = string.Empty; @@ -5195,9 +5271,9 @@ namespace Nikse.SubtitleEdit.Forms private void toolStripMenuItemTranslationMode_Click(object sender, EventArgs e) { - if (SubtitleListview1.IsColumTextAlternateActive) + if (SubtitleListview1.IsAlternateTextColumnVisible) { - SubtitleListview1.RemoveAlternateTextColumn(); + SubtitleListview1.HideAlternateTextColumn(); _subtitleAlternate = new Subtitle(); } else @@ -5244,7 +5320,7 @@ namespace Nikse.SubtitleEdit.Forms _subtitleAlternate.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate); - SubtitleListview1.AddAlternateTextColumn(Configuration.Settings.Language.General.OriginalText); + SubtitleListview1.ShowAlternateTextColumn(Configuration.Settings.Language.General.OriginalText); SubtitleListview1.Fill(_subtitle, _subtitleAlternate); } @@ -5445,7 +5521,7 @@ namespace Nikse.SubtitleEdit.Forms panelVideoPlayer.Width = w; // this.Width - (panelVideoPlayer.Left + 34); labelVideoInfo.TextAlign = ContentAlignment.TopLeft; - labelVideoInfo.Left = checkBoxSyncListViewWithVideWhilePlaying.Left + checkBoxSyncListViewWithVideWhilePlaying.Width + 10; + labelVideoInfo.Left = checkBoxSyncListViewWithVideoWhilePlaying.Left + checkBoxSyncListViewWithVideoWhilePlaying.Width + 10; } } else if (AudioWaveForm.Visible) @@ -5453,7 +5529,7 @@ namespace Nikse.SubtitleEdit.Forms AudioWaveForm.Left = tabControlButtons.Left + tabControlButtons.Width + 5; AudioWaveForm.Width = this.Width - (AudioWaveForm.Left + 34); } - checkBoxSyncListViewWithVideWhilePlaying.Left = tabControlButtons.Left + tabControlButtons.Width + 5; + checkBoxSyncListViewWithVideoWhilePlaying.Left = tabControlButtons.Left + tabControlButtons.Width + 5; panelWaveFormControls.Left = AudioWaveForm.Left; trackBarWaveFormPosition.Left = panelWaveFormControls.Left + panelWaveFormControls.Width + 5; trackBarWaveFormPosition.Width = AudioWaveForm.Left + AudioWaveForm.Width - trackBarWaveFormPosition.Left + 5; @@ -5866,7 +5942,7 @@ namespace Nikse.SubtitleEdit.Forms // mediaPlayer.RefreshProgressBar(); // Utilities.ShowSubtitle(_subtitle.Paragraphs, labelSubtitle, mediaPlayer.VideoPlayer); - if (AutoRepeatContinueOn && !checkBoxSyncListViewWithVideWhilePlaying.Checked) + if (AutoRepeatContinueOn) // && (_endSeconds == -1 && !checkBoxSyncListViewWithVideoWhilePlaying.Checked)) { if (_endSeconds >= 0 && mediaPlayer.CurrentPosition > _endSeconds && checkBoxAutoRepeatOn.Checked) { @@ -5904,7 +5980,7 @@ namespace Nikse.SubtitleEdit.Forms timeUpDownVideoPositionAdjust.TimeCode = new TimeCode(TimeSpan.FromMilliseconds(mediaPlayer.CurrentPosition * 1000.0)); mediaPlayer.RefreshProgressBar(); int index = Utilities.ShowSubtitle(_subtitle.Paragraphs, labelSubtitle, mediaPlayer.VideoPlayer); - if (index != -1 && checkBoxSyncListViewWithVideWhilePlaying.Checked) + if (index != -1 && checkBoxSyncListViewWithVideoWhilePlaying.Checked) { if ((DateTime.Now.Ticks - _lastTextKeyDownTicks) > 10000 * 700) // only if last typed char was entered > 700 milliseconds { @@ -6019,6 +6095,7 @@ namespace Nikse.SubtitleEdit.Forms private void buttonStop_Click_1(object sender, EventArgs e) { + _endSeconds = -1; timerAutoContinue.Stop(); mediaPlayer.Pause(); labelStatus.Text = string.Empty; @@ -6083,7 +6160,7 @@ namespace Nikse.SubtitleEdit.Forms if (toolStripButtonToogleVideo.Checked && !AudioWaveForm.Visible) { labelVideoInfo.TextAlign = ContentAlignment.TopLeft; - labelVideoInfo.Left = checkBoxSyncListViewWithVideWhilePlaying.Left + checkBoxSyncListViewWithVideWhilePlaying.Width + 10; + labelVideoInfo.Left = checkBoxSyncListViewWithVideoWhilePlaying.Left + checkBoxSyncListViewWithVideoWhilePlaying.Width + 10; } Refresh(); @@ -6279,7 +6356,7 @@ namespace Nikse.SubtitleEdit.Forms private void AudioWaveForm_Click(object sender, EventArgs e) { if (AudioWaveForm.WavePeaks == null) - { + { if (string.IsNullOrEmpty(_videoFileName)) { buttonOpenVideo_Click(sender, e); @@ -6789,5 +6866,375 @@ namespace Nikse.SubtitleEdit.Forms } } - } + public void SetSubtitle(Subtitle subtitle, string message) + { + _subtitle = subtitle; + SubtitleListview1.Fill(subtitle); + _change = true; + ShowStatus(message); + } + + + private void startServerToolStripMenuItem_Click(object sender, EventArgs e) + { + _networkSession = new NikseWebServiceSession(_subtitle, _subtitleAlternate, TimerWebServiceTick, OnUpdateUserLogEntries); + NetworkStart networkNew = new NetworkStart(); + networkNew.Initialize(_networkSession, _fileName); + if (networkNew.ShowDialog(this) == DialogResult.OK) + { + _networkSession.Log(_networkSession.CurrentUser.UserName + ": Started session " + _networkSession.SessionId + " at " + DateTime.Now.ToLongTimeString()); + toolStripStatusNetworking.Visible = true; + toolStripStatusNetworking.Text = "Network mode"; + EnableDisableControlsNotWorkingInNetworkMode(false); + SubtitleListview1.ShowExtraColumn("User/action"); + } + else + { + _networkSession = null; + } + } + + private void joinSessionToolStripMenuItem_Click(object sender, EventArgs e) + { + _networkSession = new NikseWebServiceSession(_subtitle, _subtitleAlternate, TimerWebServiceTick, OnUpdateUserLogEntries); + NetworkJoin networkJoin = new NetworkJoin(); + networkJoin.Initialize(_networkSession); + + if (networkJoin.ShowDialog(this) == DialogResult.OK) + { + _subtitle = _networkSession.Subtitle; + _subtitleAlternate = _networkSession.OriginalSubtitle; + if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + SubtitleListview1.ShowAlternateTextColumn(Configuration.Settings.Language.General.OriginalText); + _fileName = networkJoin.FileName; + Text = Title + " - " + _fileName; + this.Text = Title; + toolStripStatusNetworking.Visible = true; + toolStripStatusNetworking.Text = "Network mode"; + EnableDisableControlsNotWorkingInNetworkMode(false); + _networkSession.Log(_networkSession.CurrentUser.UserName + ": Joined session " + _networkSession.SessionId + " at " + DateTime.Now.ToLongTimeString()); + SubtitleListview1.ShowExtraColumn("User/action"); + _subtitleListViewIndex = -1; + _oldSelectedParagraph = null; + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + SubtitleListview1.SelectIndexAndEnsureVisible(0); + _change = true; + } + else + { + _networkSession = null; + } + } + + private void EnableDisableControlsNotWorkingInNetworkMode(bool enabled) + { + //Top menu + newToolStripMenuItem.Enabled = enabled; + openToolStripMenuItem.Enabled = enabled; + reopenToolStripMenuItem.Enabled = enabled; + toolStripMenuItemOpenContainingFolder.Enabled = enabled; + toolStripMenuItemCompare.Enabled = enabled; + toolStripMenuItemImportDvdSubtitles.Enabled = enabled; + toolStripMenuItemSubIdx.Enabled = enabled; + toolStripMenuItemImportBluRaySup.Enabled = enabled; + matroskaImportStripMenuItem.Enabled = enabled; + toolStripMenuItemManualAnsi.Enabled = enabled; + toolStripMenuItemImportText.Enabled = enabled; + toolStripMenuItemImportTimeCodes.Enabled = enabled; + + showHistoryforUndoToolStripMenuItem.Enabled = enabled; + multipleReplaceToolStripMenuItem.Enabled = enabled; + + toolsToolStripMenuItem.Enabled = enabled; + + toolStripMenuItemSyncronization.Enabled = enabled; + + toolStripMenuItemAutoTranslate.Enabled = enabled; + + //Toolbar + toolStripButtonFileNew.Enabled = enabled; + toolStripButtonFileOpen.Enabled = enabled; + toolStripButtonVisualSync.Enabled = enabled; + + // textbox source + textBoxSource.ReadOnly = !enabled; + } + + internal void TimerWebServiceTick(object sender, EventArgs e) + { + if (_networkSession == null) + return; + + List insertIndices = new List(); + List deleteIndices = new List(); + + NetworkGetSendUpdates(deleteIndices, 0, null); + } + + private void NetworkGetSendUpdates(List deleteIndices, int insertIndex, Paragraph insertParagraph) + { + _networkSession.TimerStop(); + + bool doReFill = false; + bool updateListViewStatus = false; + SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; + string message; + var updates = _networkSession.GetUpdates(out message); + if (message == "OK") + { + foreach (var update in updates) + { + if (update.User.Ip != _networkSession.CurrentUser.Ip || update.User.UserName != _networkSession.CurrentUser.UserName) + { + if (update.Action == "USR") + { + _networkSession.Users.Add(update.User); + if (_networkChat != null && !_networkChat.IsDisposed) + { + _networkChat.AddUser(update.User); + } + _networkSession.Log("New user: " + update.User.UserName + " (" + update.User.Ip + ")"); + } + else if (update.Action == "MSG") + { + _networkSession.ChatLog.Add(new NikseWebServiceSession.ChatEntry() { User = update.User, Message = update.Text }); + if (_networkChat == null || _networkChat.IsDisposed) + { + _networkChat = new NetworkChat(); + _networkChat.Initialize(_networkSession); + _networkChat.Show(this); + } + else + { + _networkChat.AddChatMessage(update.User, update.Text); + } + _networkSession.Log("Message: " + update.User.UserName + " (" + update.User.Ip + "): " + update.Text); + } + else if (update.Action == "DEL") + { + doReFill = true; + _subtitle.Paragraphs.RemoveAt(update.Index); + if (_networkSession.LastSubtitle != null) + _networkSession.LastSubtitle.Paragraphs.RemoveAt(update.Index); + _networkSession.Log("Delete: " + update.User.UserName + " (" + update.User.Ip + "): Index=" + update.Index.ToString()); + _networkSession.AdjustUpdateLogToDelete(update.Index); + _change = true; + + if (deleteIndices.Count > 0) + { + for (int i = deleteIndices.Count - 1; i >= 0; i--) + { + int index = deleteIndices[i]; + if (index == update.Index) + deleteIndices.RemoveAt(i); + else if (index > update.Index) + deleteIndices[i] = index - 1; + } + } + + if (insertIndex > update.Index) + insertIndex--; + } + else if (update.Action == "INS") + { + doReFill = true; + Paragraph p = new Paragraph(update.Text, update.StartMilliseconds, update.EndMilliseconds); + _subtitle.Paragraphs.Insert(update.Index, p); + if (_networkSession.LastSubtitle != null) + _networkSession.LastSubtitle.Paragraphs.Insert(update.Index, new Paragraph(p)); + _networkSession.Log("Insert: " + update.User.UserName + " (" + update.User.Ip + "): Index=" + update.Index.ToString() + ", Text=" + update.Text.Replace(Environment.NewLine, Configuration.Settings.General.ListViewLineSeparatorString)); + _networkSession.AddToWsUserLog(update.User, update.Index, update.Action, false); + updateListViewStatus = true; + _networkSession.AdjustUpdateLogToInsert(update.Index); + _change = true; + + if (deleteIndices.Count > 0) + { + for (int i = deleteIndices.Count - 1; i >= 0; i--) + { + int index = deleteIndices[i]; + if (index > update.Index) + deleteIndices[i] = index +1; + } + } + if (insertIndex > update.Index) + insertIndex++; + } + else if (update.Action == "UPD") + { + updateListViewStatus = true; + Paragraph p = _subtitle.GetParagraphOrDefault(update.Index); + if (p != null) + { + p.StartTime.TotalMilliseconds = update.StartMilliseconds; + p.EndTime.TotalMilliseconds = update.EndMilliseconds; + p.Text = update.Text; + SubtitleListview1.SetTimeAndText(update.Index, p); + _networkSession.AddToWsUserLog(update.User, update.Index, update.Action, true); + updateListViewStatus = true; + } + if (_networkSession.LastSubtitle != null) + { + p = _networkSession.LastSubtitle.GetParagraphOrDefault(update.Index); + if (p != null) + { + p.StartTime.TotalMilliseconds = update.StartMilliseconds; + p.EndTime.TotalMilliseconds = update.EndMilliseconds; + p.Text = update.Text; + } + } + _change = true; + } + else if (update.Action == "BYE") + { + if (_networkChat != null && !_networkChat.IsDisposed) + _networkChat.RemoveUser(update.User); + + SeNetworkService.SeUser removeUser = null; + foreach (var user in _networkSession.Users) + { + if (user.UserName == update.User.UserName) + { + removeUser = user; + break; + } + } + if (removeUser != null) + _networkSession.Users.Remove(removeUser); + + _networkSession.Log("Bye: " + update.User.UserName + " (" + update.User.Ip + ")"); + } + else + { + _networkSession.Log("UNKNOWN ACTION: " + update.Action + " by " + update.User.UserName + " (" + update.User.Ip + ")"); + } + } + } + if (deleteIndices.Count > 0) + { + deleteIndices.Sort(); + deleteIndices.Reverse(); + foreach (int i in deleteIndices) + { + _subtitle.Paragraphs.RemoveAt(i); + if (_networkSession != null && _networkSession.LastSubtitle != null && i < _networkSession.LastSubtitle.Paragraphs.Count) + _networkSession.LastSubtitle.Paragraphs.RemoveAt(i); + } + + _networkSession.DeleteLines(deleteIndices); + doReFill = true; + } + if (insertIndex >= 0 && insertParagraph != null) + { + _subtitle.Paragraphs.Insert(insertIndex, insertParagraph); + if (_networkSession != null && _networkSession.LastSubtitle != null && insertIndex < _networkSession.LastSubtitle.Paragraphs.Count) + _networkSession.LastSubtitle.Paragraphs.Insert(insertIndex, insertParagraph); + _networkSession.InsertLine(insertIndex, insertParagraph); + doReFill = true; + } + + _networkSession.CheckForAndSubmitUpdates(updates); // updates only (no inserts/deletes) + } + else + { + MessageBox.Show(message); + leaveSessionToolStripMenuItem_Click(null, null); + SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; + return; + } + if (doReFill) + { + _subtitle.Renumber(1); + SubtitleListview1.Fill(_subtitle); + UpdateListviewwithUserLogEntries(); + if (_oldSelectedParagraph != null) + { + Paragraph p = _subtitle.GetFirstAlike(_oldSelectedParagraph); + if (p != null) + { + _subtitleListViewIndex = _subtitle.GetIndex(p); + SubtitleListview1.SelectIndexAndEnsureVisible(_subtitleListViewIndex); + } + } + } + else if (updateListViewStatus) + { + UpdateListviewwithUserLogEntries(); + } + _networkSession.LastSubtitle = new Subtitle(_subtitle); + SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; + _networkSession.TimerStart(); + } + + private void UpdateListviewwithUserLogEntries() + { + SubtitleListview1.BeginUpdate(); + foreach (UpdateLogEntry entry in _networkSession.UpdateLog) + SubtitleListview1.SetExtraText(entry.Index, entry.ToString(), Utilities.GetColorFromUserName(entry.UserName)); + SubtitleListview1.EndUpdate(); + } + + private void leaveSessionToolStripMenuItem_Click(object sender, EventArgs e) + { + if (_networkSession != null) + { + _networkSession.TimerStop(); + _networkSession.Leave(); + } + if (_networkChat != null && !_networkChat.IsDisposed) + { + _networkChat.Close(); + _networkChat = null; + } + _networkSession = null; + EnableDisableControlsNotWorkingInNetworkMode(true); + toolStripStatusNetworking.Visible = false; + SubtitleListview1.HideExtraColumn(); + _networkChat = null; + } + + private void toolStripMenuItemNetworking_DropDownOpening(object sender, EventArgs e) + { + startServerToolStripMenuItem.Visible = _networkSession == null; + joinSessionToolStripMenuItem.Visible = _networkSession == null; + showSessionKeyLogToolStripMenuItem.Visible = _networkSession != null; + leaveSessionToolStripMenuItem.Visible = _networkSession != null; + chatToolStripMenuItem.Visible = _networkSession != null; + } + + internal void OnUpdateUserLogEntries(object sender, EventArgs e) + { + UpdateListviewwithUserLogEntries(); + } + + private void toolStripStatusNetworking_Click(object sender, EventArgs e) + { + showSessionKeyLogToolStripMenuItem_Click(null, null); + } + + private void showSessionKeyLogToolStripMenuItem_Click(object sender, EventArgs e) + { + NetworkLogAndInfo networkLog = new NetworkLogAndInfo(); + networkLog.Initialize(_networkSession); + networkLog.ShowDialog(this); + } + + private void chatToolStripMenuItem_Click(object sender, EventArgs e) + { + if (_networkSession != null) + { + if (_networkChat == null || _networkChat.IsDisposed) + { + _networkChat = new NetworkChat(); + _networkChat.Initialize(_networkSession); + _networkChat.Show(this); + } + else + { + _networkChat.WindowState = FormWindowState.Normal; + } + } + } + + } } \ No newline at end of file diff --git a/src/Forms/Main.resx b/src/Forms/Main.resx index 4c96b714f..9e4eafbdd 100644 --- a/src/Forms/Main.resx +++ b/src/Forms/Main.resx @@ -291,47 +291,47 @@ iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAlySURBVFhH1VcJVJNXGo1TrTsokLDpBEERAgjIIpsEERGE - iEIwQEIICcEIAgKuiAYstCJqK2gRcUppqxWFoowoLi2olUWigGVAGSkDlTq2FatFhbLcvmfV2lar9vTM - OfOfc8+/5Hvv3u9+33v5fwbj//FwWvX5+P+Z7qkxrSOnRpaFs8NKs3VCS1rNZSUwlhTBLLwYYxcXf8kU - HtljKCld6rRq718vyjDiiPsMaTG845VD6zIbsSu/C5VH7+NyBVBf2Y+ystt4O68dYWHV/SbhR8AWlS76 - S5yxsVGNMJEUHrQIK0L62y04vq8bH+28isRVJZBKd4I7R4EAfyWysy/g7OFv0NkANFXfx6ylpTAXFZ7Q - jSwd8+eFcCuGm4kP3PGQld0v2PkV8nddBd8vFXqTXMC0Ffax2Uv62Y5C6Dr5/qirS6DnDFcXGf5V2YWb - XwIblTW9ptwPBu2Fx9T+lAgTYf4+x6XFPft3diIpqgCWlgJMc+YOctyXfmPlzi+3c3bd7uDAWe7g6rbJ - 2i2ghDNPdn2agwDml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ND4luux5K5X0HJwXbjw93JBfKQAcpEfmExmH5PJ + 0H4lERdDGCevKQ16niZvjBjbAznD4zcveu2ha0xmoK7W6Lu2Dg5fe/iHwdF2BvzmOyNOHgi+9xwYGrJv + 6ejo0E3rsBcKadtqd7irJJrU/C30FpOGI5nXB4++VydkeJLBlHAkwQQCTTqLCSYT6KmrqXlqT5p0c/r0 + aZ2u83xga20Kn7lOiAnnY67LTFhzjOiGhI79YxFdB0Vkg6kcokpv5IeiNmz0D1VBDC9yS/+Qxj0ipqSG + BGYEMwnsCJxef+01P01N9S9YLFa33Sx7WJkbw9dzNuKXCjB1ig5Y6upxJG7Uc13YEOo4PzLACvc7zqCp + Ujnw3XEFakIZ0keZUwvpCkezfkxuQ4kJ3AkWEPgTJGqqqTUxmep9tlbmsLYwBp/nDnMTfWixNE48cu/Z + Glyt/05twtGMBf/u+CBg69VsH71HllHrqYBJBLSh9AlMCawJHAjcCOYTLCQQURHjx49q1NViQp/JvDVl + stZdPXJNnnMIaBmefcxiMWY856e/kefDCUY/yoDWn5ZhKsF0AgsCKwLqCJ12tCT2Y8aM8Z2izazQYGkU + scaOpTF0/Isb8bkKfx5MQR2hPUHrSZ2hH6n0q4iCXtNeoVtw+juNowk8OX4CWVnn/d52HkoAAAAASUVO RK5CYII= diff --git a/src/Forms/MultipleReplace.cs b/src/Forms/MultipleReplace.cs index e5f6fa5c5..01f917ea2 100644 --- a/src/Forms/MultipleReplace.cs +++ b/src/Forms/MultipleReplace.cs @@ -128,10 +128,21 @@ namespace Nikse.SubtitleEdit.Forms else if (searchType == Configuration.Settings.Language.MultipleReplace.RegularExpression) { Regex regex = new Regex(findWhat); - if (regex.IsMatch(newText)) + var match = regex.Match(newText); + if (match.Success) { hit = true; - newText = regex.Replace(newText, replaceWith); + + string groupName = Utilities.GetRegExGroup(findWhat); + if (groupName != null && match.Groups[groupName] != null && match.Groups[groupName].Success) + { + newText = newText.Remove(match.Groups[groupName].Index, match.Groups[groupName].Length); + newText = newText.Insert(match.Groups[groupName].Index, replaceWith); + } + else + { + newText = regex.Replace(newText, replaceWith); + } } } else diff --git a/src/Forms/NetworkChat.Designer.cs b/src/Forms/NetworkChat.Designer.cs new file mode 100644 index 000000000..00650bc9f --- /dev/null +++ b/src/Forms/NetworkChat.Designer.cs @@ -0,0 +1,162 @@ +namespace Nikse.SubtitleEdit.Forms +{ + partial class NetworkChat + { + /// + /// 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() + { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(NetworkChat)); + this.listViewChat = new System.Windows.Forms.ListView(); + this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.imageListUsers = new System.Windows.Forms.ImageList(this.components); + this.listViewUsers = new System.Windows.Forms.ListView(); + this.columnHeaderNick = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.textBoxChat = new System.Windows.Forms.TextBox(); + this.buttonSendChat = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // listViewChat + // + this.listViewChat.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.listViewChat.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader1, + this.columnHeader4}); + this.listViewChat.Location = new System.Drawing.Point(3, 107); + this.listViewChat.Name = "listViewChat"; + this.listViewChat.Size = new System.Drawing.Size(274, 239); + this.listViewChat.SmallImageList = this.imageListUsers; + this.listViewChat.TabIndex = 3; + this.listViewChat.UseCompatibleStateImageBehavior = false; + this.listViewChat.View = System.Windows.Forms.View.Details; + // + // columnHeader1 + // + this.columnHeader1.Text = "Username"; + this.columnHeader1.Width = 82; + // + // columnHeader4 + // + this.columnHeader4.Text = "Text"; + this.columnHeader4.Width = 188; + // + // imageListUsers + // + this.imageListUsers.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageListUsers.ImageStream"))); + this.imageListUsers.TransparentColor = System.Drawing.Color.Transparent; + this.imageListUsers.Images.SetKeyName(0, "person.jpg"); + this.imageListUsers.Images.SetKeyName(1, "person2.jpg"); + this.imageListUsers.Images.SetKeyName(2, "Person3.jpg"); + this.imageListUsers.Images.SetKeyName(3, "Person4.jpg"); + this.imageListUsers.Images.SetKeyName(4, "Person5.jpg"); + this.imageListUsers.Images.SetKeyName(5, "Person6.jpg"); + this.imageListUsers.Images.SetKeyName(6, "Person7.jpg"); + this.imageListUsers.Images.SetKeyName(7, "Person8.jpg"); + // + // listViewUsers + // + this.listViewUsers.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listViewUsers.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeaderNick, + this.columnHeader2}); + this.listViewUsers.Location = new System.Drawing.Point(2, 2); + this.listViewUsers.Name = "listViewUsers"; + this.listViewUsers.Size = new System.Drawing.Size(275, 103); + this.listViewUsers.SmallImageList = this.imageListUsers; + this.listViewUsers.TabIndex = 2; + this.listViewUsers.UseCompatibleStateImageBehavior = false; + this.listViewUsers.View = System.Windows.Forms.View.Details; + // + // columnHeaderNick + // + this.columnHeaderNick.Text = "Username"; + this.columnHeaderNick.Width = 178; + // + // columnHeader2 + // + this.columnHeader2.Text = "IP"; + this.columnHeader2.Width = 93; + // + // textBoxChat + // + this.textBoxChat.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxChat.Location = new System.Drawing.Point(3, 352); + this.textBoxChat.Multiline = true; + this.textBoxChat.Name = "textBoxChat"; + this.textBoxChat.Size = new System.Drawing.Size(188, 46); + this.textBoxChat.TabIndex = 0; + this.textBoxChat.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBoxChat_KeyDown); + // + // buttonSendChat + // + this.buttonSendChat.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonSendChat.Location = new System.Drawing.Point(197, 375); + this.buttonSendChat.Name = "buttonSendChat"; + this.buttonSendChat.Size = new System.Drawing.Size(75, 23); + this.buttonSendChat.TabIndex = 1; + this.buttonSendChat.Text = "Send message"; + this.buttonSendChat.UseVisualStyleBackColor = true; + this.buttonSendChat.Click += new System.EventHandler(this.buttonSendChat_Click); + // + // NetworkChat + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(281, 402); + this.Controls.Add(this.listViewChat); + this.Controls.Add(this.listViewUsers); + this.Controls.Add(this.textBoxChat); + this.Controls.Add(this.buttonSendChat); + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimumSize = new System.Drawing.Size(200, 300); + this.Name = "NetworkChat"; + this.ShowIcon = false; + this.Text = "NetworkChat"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ListView listViewChat; + private System.Windows.Forms.ColumnHeader columnHeader1; + private System.Windows.Forms.ColumnHeader columnHeader4; + private System.Windows.Forms.ListView listViewUsers; + private System.Windows.Forms.ColumnHeader columnHeaderNick; + private System.Windows.Forms.ColumnHeader columnHeader2; + private System.Windows.Forms.TextBox textBoxChat; + private System.Windows.Forms.Button buttonSendChat; + private System.Windows.Forms.ImageList imageListUsers; + } +} \ No newline at end of file diff --git a/src/Forms/NetworkChat.cs b/src/Forms/NetworkChat.cs new file mode 100644 index 000000000..31f826a7f --- /dev/null +++ b/src/Forms/NetworkChat.cs @@ -0,0 +1,95 @@ +using System; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Logic; +using Nikse.SubtitleEdit.Logic.Networking; + +namespace Nikse.SubtitleEdit.Forms +{ + public partial class NetworkChat : Form + { + Logic.Networking.NikseWebServiceSession _networkSession; + + public NetworkChat() + { + InitializeComponent(); + } + + internal void Initialize(Nikse.SubtitleEdit.Logic.Networking.NikseWebServiceSession networkSession) + { + _networkSession = networkSession; + Text = "Chat - " + _networkSession.CurrentUser.UserName; + + listViewUsers.Items.Clear(); + foreach (var user in _networkSession.Users) + { + AddUser(user); + } + + listViewChat.Items.Clear(); + foreach (var message in _networkSession.ChatLog) + { + AddChatMessage(message.User, message.Message); + listViewChat.EnsureVisible(listViewChat.Items.Count - 1); + } + } + + private void buttonSendChat_Click(object sender, EventArgs e) + { + if (textBoxChat.Text.Trim().Length > 0) + { + _networkSession.SendChatMessage(textBoxChat.Text.Trim()); + AddChatMessage(_networkSession.CurrentUser, textBoxChat.Text.Trim()); + listViewChat.EnsureVisible(listViewChat.Items.Count - 1); + _networkSession.ChatLog.Add(new NikseWebServiceSession.ChatEntry() { User = _networkSession.CurrentUser, Message = textBoxChat.Text.Trim() }); + } + textBoxChat.Text = string.Empty; + textBoxChat.Focus(); + } + + public void AddChatMessage(SeNetworkService.SeUser user, string message) + { + ListViewItem item = new ListViewItem(user.UserName); + item.Tag = _networkSession.CurrentUser; + item.ForeColor = Utilities.GetColorFromUserName(user.UserName); + item.ImageIndex = Utilities.GetNumber0To7FromUserName(user.UserName); + item.SubItems.Add(new ListViewItem.ListViewSubItem(item, message)); + listViewChat.Items.Add(item); + } + + private void textBoxChat_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter && e.Modifiers == Keys.None) + { + e.SuppressKeyPress = true; + buttonSendChat_Click(null, null); + } + } + + internal void AddUser(SeNetworkService.SeUser user) + { + ListViewItem item = new ListViewItem(user.UserName); + item.Tag = user; + item.ForeColor = Utilities.GetColorFromUserName(user.UserName); + if (DateTime.Now.Month == 12 && DateTime.Now.Day >= 23 && DateTime.Now.Day <= 25) + item.ImageIndex = 7; + else + item.ImageIndex = Utilities.GetNumber0To7FromUserName(user.UserName); + item.SubItems.Add(new ListViewItem.ListViewSubItem(item, user.Ip)); + listViewUsers.Items.Add(item); + } + + internal void RemoveUser(SeNetworkService.SeUser user) + { + ListViewItem removeItem = null; + foreach (ListViewItem item in listViewUsers.Items) + { + if ((item.Tag as SeNetworkService.SeUser).UserName == user.UserName) + { + removeItem = item; + } + } + if (removeItem != null) + listViewUsers.Items.Remove(removeItem); + } + } +} diff --git a/src/Forms/NetworkChat.resx b/src/Forms/NetworkChat.resx new file mode 100644 index 000000000..818e1de96 --- /dev/null +++ b/src/Forms/NetworkChat.resx @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 17, 17 + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w + LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 + ZW0uV2luZG93cy5Gb3Jtcy5Jb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A + ASgDAAFAAwABMAMAAQEBAAEBBQABgAEBFgAD//8AggAL + + + \ No newline at end of file diff --git a/src/Forms/NetworkJoin.Designer.cs b/src/Forms/NetworkJoin.Designer.cs new file mode 100644 index 000000000..c2fd0d0e2 --- /dev/null +++ b/src/Forms/NetworkJoin.Designer.cs @@ -0,0 +1,178 @@ +namespace Nikse.SubtitleEdit.Forms +{ + partial class NetworkJoin + { + /// + /// 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() + { + this.labelStatus = new System.Windows.Forms.Label(); + this.labelInfo = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.comboBoxWebServiceUrl = new System.Windows.Forms.ComboBox(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.textBoxUserName = new System.Windows.Forms.TextBox(); + this.buttonConnect = new System.Windows.Forms.Button(); + this.labelGoToLine = new System.Windows.Forms.Label(); + this.textBoxSessionKey = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // labelStatus + // + this.labelStatus.AutoSize = true; + this.labelStatus.Location = new System.Drawing.Point(35, 205); + this.labelStatus.Name = "labelStatus"; + this.labelStatus.Size = new System.Drawing.Size(59, 13); + this.labelStatus.TabIndex = 18; + this.labelStatus.Text = "labelStatus"; + // + // labelInfo + // + this.labelInfo.AutoSize = true; + this.labelInfo.Location = new System.Drawing.Point(12, 9); + this.labelInfo.Name = "labelInfo"; + this.labelInfo.Size = new System.Drawing.Size(200, 26); + this.labelInfo.TabIndex = 17; + this.labelInfo.Text = "Start new session where multiple persons\r\ncan edit in same subtitle file.\r\n"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.label1.Location = new System.Drawing.Point(9, 138); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(81, 13); + this.label1.TabIndex = 16; + this.label1.Text = "Web service url"; + // + // comboBoxWebServiceUrl + // + this.comboBoxWebServiceUrl.FormattingEnabled = true; + this.comboBoxWebServiceUrl.Items.AddRange(new object[] { + "http://www.nikse.dk/se/SeService.asmx", + "http://nikse555.brinkster.net/SeService.asmx"}); + this.comboBoxWebServiceUrl.Location = new System.Drawing.Point(96, 131); + this.comboBoxWebServiceUrl.Name = "comboBoxWebServiceUrl"; + this.comboBoxWebServiceUrl.Size = new System.Drawing.Size(290, 21); + this.comboBoxWebServiceUrl.TabIndex = 2; + // + // buttonCancel + // + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(311, 173); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 21); + this.buttonCancel.TabIndex = 4; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // textBoxUserName + // + this.textBoxUserName.Location = new System.Drawing.Point(96, 79); + this.textBoxUserName.Name = "textBoxUserName"; + this.textBoxUserName.Size = new System.Drawing.Size(290, 20); + this.textBoxUserName.TabIndex = 0; + // + // buttonConnect + // + this.buttonConnect.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonConnect.Location = new System.Drawing.Point(230, 173); + this.buttonConnect.Name = "buttonConnect"; + this.buttonConnect.Size = new System.Drawing.Size(75, 21); + this.buttonConnect.TabIndex = 3; + this.buttonConnect.Text = "&Join"; + this.buttonConnect.UseVisualStyleBackColor = true; + this.buttonConnect.Click += new System.EventHandler(this.buttonConnect_Click); + // + // labelGoToLine + // + this.labelGoToLine.AutoSize = true; + this.labelGoToLine.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.labelGoToLine.Location = new System.Drawing.Point(35, 82); + this.labelGoToLine.Name = "labelGoToLine"; + this.labelGoToLine.Size = new System.Drawing.Size(55, 13); + this.labelGoToLine.TabIndex = 11; + this.labelGoToLine.Text = "Username"; + // + // textBoxSessionKey + // + this.textBoxSessionKey.Location = new System.Drawing.Point(96, 105); + this.textBoxSessionKey.Name = "textBoxSessionKey"; + this.textBoxSessionKey.Size = new System.Drawing.Size(290, 20); + this.textBoxSessionKey.TabIndex = 1; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.label2.Location = new System.Drawing.Point(35, 108); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(25, 13); + this.label2.TabIndex = 19; + this.label2.Text = "Key"; + // + // NetworkJoin + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(408, 242); + this.Controls.Add(this.textBoxSessionKey); + this.Controls.Add(this.label2); + this.Controls.Add(this.labelStatus); + this.Controls.Add(this.labelInfo); + this.Controls.Add(this.label1); + this.Controls.Add(this.comboBoxWebServiceUrl); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.textBoxUserName); + this.Controls.Add(this.buttonConnect); + this.Controls.Add(this.labelGoToLine); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "NetworkJoin"; + this.Text = "Join network session"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.NetworkJoin_KeyDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label labelStatus; + private System.Windows.Forms.Label labelInfo; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ComboBox comboBoxWebServiceUrl; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.TextBox textBoxUserName; + private System.Windows.Forms.Button buttonConnect; + private System.Windows.Forms.Label labelGoToLine; + private System.Windows.Forms.TextBox textBoxSessionKey; + private System.Windows.Forms.Label label2; + } +} \ No newline at end of file diff --git a/src/Forms/NetworkJoin.cs b/src/Forms/NetworkJoin.cs new file mode 100644 index 000000000..8b46b44b6 --- /dev/null +++ b/src/Forms/NetworkJoin.cs @@ -0,0 +1,83 @@ +using System; +using System.Net; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Logic; + +namespace Nikse.SubtitleEdit.Forms +{ + public partial class NetworkJoin : Form + { + + Logic.Networking.NikseWebServiceSession _networkSession; + public string FileName { get; set;} + + public NetworkJoin() + { + InitializeComponent(); + labelStatus.Text = string.Empty; + } + + internal void Initialize(Logic.Networking.NikseWebServiceSession networkSession) + { + _networkSession = networkSession; + + textBoxSessionKey.Text = Configuration.Settings.NetworkSettings.SessionKey; + if (textBoxSessionKey.Text.Trim().Length < 2) + textBoxSessionKey.Text = Guid.NewGuid().ToString().Replace("-", string.Empty); + + comboBoxWebServiceUrl.Text = Configuration.Settings.NetworkSettings.WebServiceUrl; + textBoxUserName.Text = Configuration.Settings.NetworkSettings.UserName; + if (textBoxUserName.Text.Trim().Length < 2) + textBoxUserName.Text = Dns.GetHostName(); + } + + private void buttonConnect_Click(object sender, EventArgs e) + { + Configuration.Settings.NetworkSettings.SessionKey = textBoxSessionKey.Text; + Configuration.Settings.NetworkSettings.WebServiceUrl = comboBoxWebServiceUrl.Text; + Configuration.Settings.NetworkSettings.UserName = textBoxUserName.Text; + + buttonConnect.Enabled = false; + buttonCancel.Enabled = false; + textBoxUserName.Enabled = false; + comboBoxWebServiceUrl.Enabled = false; + labelStatus.Text = string.Format("Connecting to {0}...", comboBoxWebServiceUrl.Text); + Refresh(); + + try + { + string message; + _networkSession.Join(comboBoxWebServiceUrl.Text, textBoxUserName.Text, textBoxSessionKey.Text, out message); + if (message == "OK") + { + DialogResult = DialogResult.OK; + return; + } + else + { + MessageBox.Show(message); + } + } + catch (Exception exception) + { + MessageBox.Show(exception.Message); + } + buttonConnect.Enabled = true; + buttonCancel.Enabled = true; + textBoxUserName.Enabled = true; + comboBoxWebServiceUrl.Enabled = true; + labelStatus.Text = string.Empty; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void NetworkJoin_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + DialogResult = DialogResult.Cancel; + } + } +} diff --git a/src/Forms/NetworkJoin.resx b/src/Forms/NetworkJoin.resx new file mode 100644 index 000000000..5ea0895e3 --- /dev/null +++ b/src/Forms/NetworkJoin.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/src/Forms/NetworkLogAndInfo.Designer.cs b/src/Forms/NetworkLogAndInfo.Designer.cs new file mode 100644 index 000000000..f7a5f0cf5 --- /dev/null +++ b/src/Forms/NetworkLogAndInfo.Designer.cs @@ -0,0 +1,168 @@ +namespace Nikse.SubtitleEdit.Forms +{ + partial class NetworkLogAndInfo + { + /// + /// 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() + { + this.textBoxSessionKey = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.labelLog = new System.Windows.Forms.Label(); + this.textBoxLog = new System.Windows.Forms.TextBox(); + this.buttonConnect = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.textBoxUserName = new System.Windows.Forms.TextBox(); + this.labelGoToLine = new System.Windows.Forms.Label(); + this.textBoxWebServiceUrl = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // textBoxSessionKey + // + this.textBoxSessionKey.Location = new System.Drawing.Point(157, 16); + this.textBoxSessionKey.Name = "textBoxSessionKey"; + this.textBoxSessionKey.ReadOnly = true; + this.textBoxSessionKey.Size = new System.Drawing.Size(290, 20); + this.textBoxSessionKey.TabIndex = 1; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.label2.Location = new System.Drawing.Point(87, 19); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(64, 13); + this.label2.TabIndex = 21; + this.label2.Text = "Session key"; + // + // labelLog + // + this.labelLog.AutoSize = true; + this.labelLog.Location = new System.Drawing.Point(9, 109); + this.labelLog.Name = "labelLog"; + this.labelLog.Size = new System.Drawing.Size(28, 13); + this.labelLog.TabIndex = 24; + this.labelLog.Text = "Log:"; + // + // textBoxLog + // + this.textBoxLog.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.textBoxLog.Location = new System.Drawing.Point(12, 125); + this.textBoxLog.Multiline = true; + this.textBoxLog.Name = "textBoxLog"; + this.textBoxLog.ReadOnly = true; + this.textBoxLog.Size = new System.Drawing.Size(543, 179); + this.textBoxLog.TabIndex = 4; + // + // buttonConnect + // + this.buttonConnect.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonConnect.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonConnect.Location = new System.Drawing.Point(480, 310); + this.buttonConnect.Name = "buttonConnect"; + this.buttonConnect.Size = new System.Drawing.Size(75, 21); + this.buttonConnect.TabIndex = 0; + this.buttonConnect.Text = "&OK"; + this.buttonConnect.UseVisualStyleBackColor = true; + this.buttonConnect.Click += new System.EventHandler(this.buttonConnect_Click); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.label1.Location = new System.Drawing.Point(70, 71); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(81, 13); + this.label1.TabIndex = 29; + this.label1.Text = "Web service url"; + // + // textBoxUserName + // + this.textBoxUserName.Location = new System.Drawing.Point(157, 42); + this.textBoxUserName.Name = "textBoxUserName"; + this.textBoxUserName.ReadOnly = true; + this.textBoxUserName.Size = new System.Drawing.Size(290, 20); + this.textBoxUserName.TabIndex = 2; + // + // labelGoToLine + // + this.labelGoToLine.AutoSize = true; + this.labelGoToLine.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.labelGoToLine.Location = new System.Drawing.Point(96, 45); + this.labelGoToLine.Name = "labelGoToLine"; + this.labelGoToLine.Size = new System.Drawing.Size(55, 13); + this.labelGoToLine.TabIndex = 28; + this.labelGoToLine.Text = "Username"; + // + // textBoxWebServiceUrl + // + this.textBoxWebServiceUrl.Location = new System.Drawing.Point(157, 68); + this.textBoxWebServiceUrl.Name = "textBoxWebServiceUrl"; + this.textBoxWebServiceUrl.ReadOnly = true; + this.textBoxWebServiceUrl.Size = new System.Drawing.Size(290, 20); + this.textBoxWebServiceUrl.TabIndex = 3; + // + // NetworkLogAndInfo + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(565, 337); + this.Controls.Add(this.textBoxWebServiceUrl); + this.Controls.Add(this.label1); + this.Controls.Add(this.textBoxUserName); + this.Controls.Add(this.labelGoToLine); + this.Controls.Add(this.buttonConnect); + this.Controls.Add(this.labelLog); + this.Controls.Add(this.textBoxLog); + this.Controls.Add(this.textBoxSessionKey); + this.Controls.Add(this.label2); + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(500, 350); + this.Name = "NetworkLogAndInfo"; + this.ShowIcon = false; + this.Text = "Network session info and log"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.NetworkLogAndInfo_KeyDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox textBoxSessionKey; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label labelLog; + private System.Windows.Forms.TextBox textBoxLog; + private System.Windows.Forms.Button buttonConnect; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox textBoxUserName; + private System.Windows.Forms.Label labelGoToLine; + private System.Windows.Forms.TextBox textBoxWebServiceUrl; + } +} \ No newline at end of file diff --git a/src/Forms/NetworkLogAndInfo.cs b/src/Forms/NetworkLogAndInfo.cs new file mode 100644 index 000000000..be4e0fe68 --- /dev/null +++ b/src/Forms/NetworkLogAndInfo.cs @@ -0,0 +1,32 @@ +using System; +using System.Windows.Forms; + +namespace Nikse.SubtitleEdit.Forms +{ + public partial class NetworkLogAndInfo : Form + { + public NetworkLogAndInfo() + { + InitializeComponent(); + } + + internal void Initialize(Logic.Networking.NikseWebServiceSession _networkSession) + { + textBoxSessionKey.Text = _networkSession.SessionId; + textBoxUserName.Text = _networkSession.CurrentUser.UserName; + textBoxWebServiceUrl.Text = _networkSession.WebServiceUrl; + textBoxLog.Text = _networkSession.GetLog(); + } + + private void buttonConnect_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.OK; + } + + private void NetworkLogAndInfo_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + DialogResult = DialogResult.Cancel; + } + } +} diff --git a/src/Forms/NetworkLogAndInfo.resx b/src/Forms/NetworkLogAndInfo.resx new file mode 100644 index 000000000..5ea0895e3 --- /dev/null +++ b/src/Forms/NetworkLogAndInfo.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/src/Forms/NetworkStart.Designer.cs b/src/Forms/NetworkStart.Designer.cs new file mode 100644 index 000000000..b6f3b4ee0 --- /dev/null +++ b/src/Forms/NetworkStart.Designer.cs @@ -0,0 +1,177 @@ +namespace Nikse.SubtitleEdit.Forms +{ + partial class NetworkStart + { + /// + /// 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() + { + this.buttonCancel = new System.Windows.Forms.Button(); + this.textBoxUserName = new System.Windows.Forms.TextBox(); + this.buttonConnect = new System.Windows.Forms.Button(); + this.labelGoToLine = new System.Windows.Forms.Label(); + this.comboBoxWebServiceUrl = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); + this.labelInfo = new System.Windows.Forms.Label(); + this.labelStatus = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.textBoxSessionKey = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // buttonCancel + // + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(312, 147); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 21); + this.buttonCancel.TabIndex = 4; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // textBoxUserName + // + this.textBoxUserName.Location = new System.Drawing.Point(97, 83); + this.textBoxUserName.Name = "textBoxUserName"; + this.textBoxUserName.Size = new System.Drawing.Size(290, 20); + this.textBoxUserName.TabIndex = 1; + // + // buttonConnect + // + this.buttonConnect.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonConnect.Location = new System.Drawing.Point(231, 147); + this.buttonConnect.Name = "buttonConnect"; + this.buttonConnect.Size = new System.Drawing.Size(75, 21); + this.buttonConnect.TabIndex = 3; + this.buttonConnect.Text = "&Start"; + this.buttonConnect.UseVisualStyleBackColor = true; + this.buttonConnect.Click += new System.EventHandler(this.buttonOK_Click); + // + // labelGoToLine + // + this.labelGoToLine.AutoSize = true; + this.labelGoToLine.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.labelGoToLine.Location = new System.Drawing.Point(36, 86); + this.labelGoToLine.Name = "labelGoToLine"; + this.labelGoToLine.Size = new System.Drawing.Size(55, 13); + this.labelGoToLine.TabIndex = 3; + this.labelGoToLine.Text = "Username"; + // + // comboBoxWebServiceUrl + // + this.comboBoxWebServiceUrl.FormattingEnabled = true; + this.comboBoxWebServiceUrl.Items.AddRange(new object[] { + "http://www.nikse.dk/se/SeService.asmx", + "http://nikse555.brinkster.net/SeService.asmx"}); + this.comboBoxWebServiceUrl.Location = new System.Drawing.Point(97, 109); + this.comboBoxWebServiceUrl.Name = "comboBoxWebServiceUrl"; + this.comboBoxWebServiceUrl.Size = new System.Drawing.Size(290, 21); + this.comboBoxWebServiceUrl.TabIndex = 2; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.label1.Location = new System.Drawing.Point(10, 112); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(81, 13); + this.label1.TabIndex = 8; + this.label1.Text = "Web service url"; + // + // labelInfo + // + this.labelInfo.AutoSize = true; + this.labelInfo.Location = new System.Drawing.Point(13, 13); + this.labelInfo.Name = "labelInfo"; + this.labelInfo.Size = new System.Drawing.Size(200, 26); + this.labelInfo.TabIndex = 9; + this.labelInfo.Text = "Start new session where multiple persons\r\ncan edit in same subtitle file.\r\n"; + // + // labelStatus + // + this.labelStatus.AutoSize = true; + this.labelStatus.Location = new System.Drawing.Point(36, 179); + this.labelStatus.Name = "labelStatus"; + this.labelStatus.Size = new System.Drawing.Size(59, 13); + this.labelStatus.TabIndex = 10; + this.labelStatus.Text = "labelStatus"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.label2.Location = new System.Drawing.Point(26, 60); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(65, 13); + this.label2.TabIndex = 11; + this.label2.Text = "Session Key"; + // + // textBoxSessionKey + // + this.textBoxSessionKey.Location = new System.Drawing.Point(97, 57); + this.textBoxSessionKey.Name = "textBoxSessionKey"; + this.textBoxSessionKey.Size = new System.Drawing.Size(290, 20); + this.textBoxSessionKey.TabIndex = 0; + // + // NetworkStart + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(414, 201); + this.Controls.Add(this.textBoxSessionKey); + this.Controls.Add(this.label2); + this.Controls.Add(this.labelStatus); + this.Controls.Add(this.labelInfo); + this.Controls.Add(this.label1); + this.Controls.Add(this.comboBoxWebServiceUrl); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.textBoxUserName); + this.Controls.Add(this.buttonConnect); + this.Controls.Add(this.labelGoToLine); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "NetworkStart"; + this.Text = "Start network session"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.NetworkNew_KeyDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.TextBox textBoxUserName; + private System.Windows.Forms.Button buttonConnect; + private System.Windows.Forms.Label labelGoToLine; + private System.Windows.Forms.ComboBox comboBoxWebServiceUrl; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label labelInfo; + private System.Windows.Forms.Label labelStatus; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox textBoxSessionKey; + } +} \ No newline at end of file diff --git a/src/Forms/NetworkStart.cs b/src/Forms/NetworkStart.cs new file mode 100644 index 000000000..86afccdb3 --- /dev/null +++ b/src/Forms/NetworkStart.cs @@ -0,0 +1,86 @@ +using System; +using System.Net; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Logic; + +namespace Nikse.SubtitleEdit.Forms +{ + public partial class NetworkStart : Form + { + + Logic.Networking.NikseWebServiceSession _networkSession; + string _fileName; + + public NetworkStart() + { + InitializeComponent(); + labelStatus.Text = string.Empty; + } + + internal void Initialize(Logic.Networking.NikseWebServiceSession networkSession, string fileName) + { + _networkSession = networkSession; + _fileName = fileName; + + textBoxSessionKey.Text = Configuration.Settings.NetworkSettings.SessionKey; + if (textBoxSessionKey.Text.Trim().Length < 2) + textBoxSessionKey.Text = Guid.NewGuid().ToString().Replace("-", string.Empty); + + comboBoxWebServiceUrl.Text = Configuration.Settings.NetworkSettings.WebServiceUrl; + textBoxUserName.Text = Configuration.Settings.NetworkSettings.UserName; + if (textBoxUserName.Text.Trim().Length < 2) + textBoxUserName.Text = Dns.GetHostName(); + } + + private void buttonOK_Click(object sender, EventArgs e) + { + Configuration.Settings.NetworkSettings.SessionKey = textBoxSessionKey.Text; + Configuration.Settings.NetworkSettings.WebServiceUrl = comboBoxWebServiceUrl.Text; + Configuration.Settings.NetworkSettings.UserName = textBoxUserName.Text; + + buttonConnect.Enabled = false; + buttonCancel.Enabled = false; + textBoxSessionKey.Enabled = false; + textBoxUserName.Enabled = false; + comboBoxWebServiceUrl.Enabled = false; + labelStatus.Text = string.Format("Connecting to {0}...", comboBoxWebServiceUrl.Text); + Refresh(); + + try + { + string message; + _networkSession.StartServer(comboBoxWebServiceUrl.Text, textBoxSessionKey.Text, textBoxUserName.Text, _fileName, out message); + if (message != "OK") + { + MessageBox.Show(message); + } + else + { + DialogResult = DialogResult.OK; + return; + } + } + catch (Exception exception) + { + MessageBox.Show(exception.Message); + } + buttonConnect.Enabled = true; + buttonCancel.Enabled = true; + textBoxSessionKey.Enabled = false; + textBoxUserName.Enabled = true; + comboBoxWebServiceUrl.Enabled = true; + labelStatus.Text = string.Empty; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void NetworkNew_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + DialogResult = DialogResult.Cancel; + } + } +} diff --git a/src/Forms/NetworkStart.resx b/src/Forms/NetworkStart.resx new file mode 100644 index 000000000..5ea0895e3 --- /dev/null +++ b/src/Forms/NetworkStart.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/src/Icons/connect.png b/src/Icons/connect.png new file mode 100644 index 000000000..024138eb3 Binary files /dev/null and b/src/Icons/connect.png differ diff --git a/src/Logic/FindReplaceDialogHelper.cs b/src/Logic/FindReplaceDialogHelper.cs index 7f75a69ba..9537f7749 100644 --- a/src/Logic/FindReplaceDialogHelper.cs +++ b/src/Logic/FindReplaceDialogHelper.cs @@ -11,6 +11,7 @@ namespace Nikse.SubtitleEdit.Logic readonly Regex _regEx; int _findTextLenght; + public bool Success { get; set; } public FindType FindType { get; set; } public int SelectedIndex { get; set; } public int SelectedPosition { get; set; } @@ -80,6 +81,12 @@ namespace Nikse.SubtitleEdit.Logic Match match = _regEx.Match(text, startIndex); if (match.Success) { + string groupName = Utilities.GetRegExGroup(_findText); + if (groupName != null && match.Groups[groupName] != null && match.Groups[groupName].Success) + { + _findTextLenght = match.Groups[groupName].Length; + return match.Groups[groupName].Index; + } _findTextLenght = match.Length; return match.Index; } @@ -91,6 +98,7 @@ namespace Nikse.SubtitleEdit.Logic public bool FindNext(Subtitle subtitle, int startIndex, int position) { + Success = false; int index = 0; if (position < 0) position = 0; @@ -103,6 +111,7 @@ namespace Nikse.SubtitleEdit.Logic { SelectedIndex = index; SelectedPosition = pos; + Success = true; return true; } position = 0; @@ -137,6 +146,7 @@ namespace Nikse.SubtitleEdit.Logic public bool FindNext(TextBox textBox, int startIndex) { + Success = false; startIndex++; if (startIndex < textBox.Text.Length) { @@ -145,8 +155,18 @@ namespace Nikse.SubtitleEdit.Logic Match match = _regEx.Match(textBox.Text, startIndex); if (match.Success) { - _findTextLenght = match.Length; - SelectedIndex = match.Index; + string groupName = Utilities.GetRegExGroup(_findText); + if (groupName != null && match.Groups[groupName] != null && match.Groups[groupName].Success) + { + _findTextLenght = match.Groups[groupName].Length; + SelectedIndex = match.Groups[groupName].Index; + } + else + { + _findTextLenght = match.Length; + SelectedIndex = match.Index; + } + Success = true; } return match.Success; } diff --git a/src/Logic/Language.cs b/src/Logic/Language.cs index 7bcaf1726..33332eacc 100644 --- a/src/Logic/Language.cs +++ b/src/Logic/Language.cs @@ -38,6 +38,10 @@ namespace Nikse.SubtitleEdit.Logic public LanguageStructure.MatroskaSubtitleChooser MatroskaSubtitleChooser; public LanguageStructure.MergeShortLines MergedShortLines; public LanguageStructure.MultipleReplace MultipleReplace; + public LanguageStructure.NetworkChat NetworkChat; + public LanguageStructure.NetworkJoin NetworkJoin; + public LanguageStructure.NetworkLogAndInfo NetworkLogAndInfo; + public LanguageStructure.NetworkStart NetworkStart; public LanguageStructure.RemoveTextFromHearImpaired RemoveTextFromHearImpaired; public LanguageStructure.ReplaceDialog ReplaceDialog; public LanguageStructure.SetMinimumDisplayTimeBetweenParagraphs SetMinimumDisplayTimeBetweenParagraphs; @@ -886,6 +890,26 @@ namespace Nikse.SubtitleEdit.Logic SearchType = "Search type", }; + NetworkChat = new LanguageStructure.NetworkChat + { + Title = "", + }; + + NetworkJoin = new LanguageStructure.NetworkJoin + { + Title = "", + }; + + NetworkLogAndInfo = new LanguageStructure.NetworkLogAndInfo + { + Title = "", + }; + + NetworkStart = new LanguageStructure.NetworkStart + { + Title = "", + }; + RemoveTextFromHearImpaired = new LanguageStructure.RemoveTextFromHearImpaired { Title = "Remove text for hearing impaired", diff --git a/src/Logic/LanguageStructure.cs b/src/Logic/LanguageStructure.cs index aca2c4ae6..549b0f3fa 100644 --- a/src/Logic/LanguageStructure.cs +++ b/src/Logic/LanguageStructure.cs @@ -826,6 +826,27 @@ public string Enabled { get; set; } public string SearchType { get; set; } } + + public class NetworkChat + { + public string Title { get; set; } + } + + public class NetworkJoin + { + public string Title { get; set; } + } + + public class NetworkLogAndInfo + { + public string Title { get; set; } + } + + public class NetworkStart + { + public string Title { get; set; } + } + public class RemoveTextFromHearImpaired { public string Title { get; set; } diff --git a/src/Logic/Networking/NikseWebServiceSession.cs b/src/Logic/Networking/NikseWebServiceSession.cs new file mode 100644 index 000000000..dfe49198c --- /dev/null +++ b/src/Logic/Networking/NikseWebServiceSession.cs @@ -0,0 +1,286 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Nikse.SubtitleEdit.Logic.Networking +{ + public class NikseWebServiceSession + { + public class ChatEntry + { + public SeNetworkService.SeUser User { get; set; } + public string Message { get; set; } + } + + public event EventHandler OnUpdateTimerTick; + public event EventHandler OnUpdateUserLogEntries; + + System.Windows.Forms.Timer _timerWebService; + public List UpdateLog = new List(); + public List ChatLog = new List(); + SeNetworkService.SeService _seWs; + DateTime _seWsLastUpdate = DateTime.Now.AddYears(-1); + public SeNetworkService.SeUser CurrentUser { get; set; } + public Subtitle LastSubtitle = null; + public Subtitle Subtitle; + public Subtitle OriginalSubtitle; + public string SessionId; + public string FileName; + public List Users; + public StringBuilder _log; + + public string WebServiceUrl + { + get + { + return _seWs.Url; + } + } + + public NikseWebServiceSession(Subtitle subtitle, Subtitle originalSubtitle, EventHandler onUpdateTimerTick, EventHandler onUpdateUserLogEntries) + { + Subtitle = subtitle; + OriginalSubtitle = originalSubtitle; + _timerWebService = new System.Windows.Forms.Timer(); + _timerWebService.Interval = 5000; + _timerWebService.Tick += new EventHandler(TimerWebServiceTick); + _log = new StringBuilder(); + OnUpdateTimerTick = onUpdateTimerTick; + OnUpdateUserLogEntries = onUpdateUserLogEntries; + } + + public void StartServer(string webServiceUrl, string sessionKey, string userName, string fileName, out string message) + { + SessionId = sessionKey; + var list = new List(); + foreach (Paragraph p in Subtitle.Paragraphs) + { + list.Add(new SeNetworkService.SeSequence() + { + StartMilliseconds = (int)p.StartTime.TotalMilliseconds, + EndMilliseconds = (int)p.EndTime.TotalMilliseconds, + Text = p.Text + }); + } + + var originalSubtitle = new List(); + if (OriginalSubtitle != null) + { + foreach (Paragraph p in OriginalSubtitle.Paragraphs) + { + originalSubtitle.Add(new SeNetworkService.SeSequence() + { + StartMilliseconds = (int)p.StartTime.TotalMilliseconds, + EndMilliseconds = (int)p.EndTime.TotalMilliseconds, + Text = p.Text + }); + } + } + + _seWs = new SeNetworkService.SeService(); + _seWs.Url = webServiceUrl; + _seWs.Proxy = Utilities.GetProxy(); + SeNetworkService.SeUser user = _seWs.Start(sessionKey, userName, list.ToArray(), originalSubtitle.ToArray(), fileName, out message); + CurrentUser = user; + Users = new List(); + Users.Add(user); + if (message == "OK") + _timerWebService.Start(); + } + + public bool Join(string webServiceUrl, string userName, string sessionKey, out string message) + { + SessionId = sessionKey; + _seWs = new SeNetworkService.SeService(); + _seWs.Url = webServiceUrl; + _seWs.Proxy = Utilities.GetProxy(); + Users = new List(); + var users = _seWs.Join(sessionKey, userName, out message); + if (message != "OK") + return false; + + string tempFileName; + DateTime updateTime; + Subtitle = new Subtitle(); + foreach (var sequence in _seWs.GetSubtitle(sessionKey, out tempFileName, out updateTime)) + Subtitle.Paragraphs.Add(new Paragraph(sequence.Text, sequence.StartMilliseconds, sequence.EndMilliseconds)); + FileName = tempFileName; + + OriginalSubtitle = new Subtitle(); + var sequences = _seWs.GetOriginalSubtitle(sessionKey); + if (sequences != null) + { + foreach (var sequence in sequences) + OriginalSubtitle.Paragraphs.Add(new Paragraph(sequence.Text, sequence.StartMilliseconds, sequence.EndMilliseconds)); + } + + SessionId = sessionKey; + CurrentUser = users[users.Length - 1]; // me + foreach (var user in users) + Users.Add(user); + ReloadFromWs(); + _timerWebService.Start(); + return true; + } + + void TimerWebServiceTick(object sender, EventArgs e) + { + if (OnUpdateTimerTick != null) + OnUpdateTimerTick.Invoke(sender, e); + } + + public void TimerStop() + { + _timerWebService.Stop(); + } + + public void TimerStart() + { + _timerWebService.Start(); + } + + public IEnumerable GetUpdates(out string message) + { + DateTime newUpdateTime; + var updates = _seWs.GetUpdates(SessionId, CurrentUser.UserName, _seWsLastUpdate, out message, out newUpdateTime); + _seWsLastUpdate = newUpdateTime; + return updates; + } + + private void ReloadFromWs() + { + if (_seWs != null) + { + Subtitle = new Logic.Subtitle(); + var sequences = _seWs.GetSubtitle(SessionId, out FileName, out _seWsLastUpdate); + foreach (var sequence in sequences) + { + Paragraph p = new Paragraph(sequence.Text, sequence.StartMilliseconds, sequence.EndMilliseconds); + Subtitle.Paragraphs.Add(p); + } + Subtitle.Renumber(1); + LastSubtitle = new Subtitle(Subtitle); + } + } + + public void Log(string text) + { + string timestamp = DateTime.Now.ToLongTimeString(); + _log.AppendLine(timestamp + ": " + text.TrimEnd() .Replace(Environment.NewLine, Configuration.Settings.General.ListViewLineSeparatorString)); + } + + public string GetLog() + { + return _log.ToString(); + } + + public void SendChatMessage(string message) + { + _seWs.SendMessage(SessionId, message, CurrentUser); + } + + internal void UpdateLine(int index, Paragraph paragraph) + { + _seWs.UpdateLine(SessionId, index, new SeNetworkService.SeSequence() + { + StartMilliseconds = (int)paragraph.StartTime.TotalMilliseconds, + EndMilliseconds = (int)paragraph.EndTime.TotalMilliseconds, + Text = paragraph.Text + }, CurrentUser); + AddToWsUserLog(CurrentUser, index, "UPD", true); + } + + public void CheckForAndSubmitUpdates(IEnumerable updates) + { + // check for changes in text/time codes (not insert/delete) + if (LastSubtitle != null) + { + for (int i = 0; i < Subtitle.Paragraphs.Count; i++) + { + Paragraph last = LastSubtitle.GetParagraphOrDefault(i); + Paragraph current = Subtitle.GetParagraphOrDefault(i); + if (last != null && current != null) + { + if (last.StartTime.TotalMilliseconds != current.StartTime.TotalMilliseconds || + last.EndTime.TotalMilliseconds != current.EndTime.TotalMilliseconds || + last.Text != current.Text) + { + UpdateLine(i, current); + } + } + } + } + } + + public void AddToWsUserLog(SeNetworkService.SeUser user, int pos, string action, bool updateUI) + { + for (int i = 0; i < UpdateLog.Count; i++) + { + if (UpdateLog[i].Index == pos) + { + UpdateLog.RemoveAt(i); + break; + } + } + + UpdateLog.Add(new UpdateLogEntry(0, user.UserName, pos, action)); + if (updateUI && OnUpdateUserLogEntries != null) + OnUpdateUserLogEntries.Invoke(null, null); + } + + + internal void Leave() + { + try + { + _seWs.Leave(SessionId, CurrentUser.UserName); + } + catch + { + } + } + + internal void DeleteLines(List indices) + { + _seWs.DeleteLines(SessionId, indices.ToArray(), CurrentUser); + StringBuilder sb = new StringBuilder(); + foreach (int index in indices) + { + sb.Append(index + ", "); + AdjustUpdateLogToDelete(index); + } + Log("Delete line: " + sb.ToString().Trim().TrimEnd(',')); + } + + internal void InsertLine(int index, Paragraph newParagraph) + { + _seWs.InsertLine(SessionId, index, (int)newParagraph.StartTime.TotalMilliseconds, (int)newParagraph.EndTime.TotalMilliseconds, newParagraph.Text, CurrentUser); + Log("Insert line at " + index.ToString() + ": " + newParagraph.ToString()); + } + + internal void AdjustUpdateLogToInsert(int index) + { + foreach (var logEntry in UpdateLog) + { + if (logEntry.Index >= index) + logEntry.Index++; + } + } + + internal void AdjustUpdateLogToDelete(int index) + { + UpdateLogEntry removeThis = null; + foreach (var logEntry in UpdateLog) + { + if (logEntry.Index == index) + removeThis = logEntry; + else if (logEntry.Index > index) + logEntry.Index--; + } + if (removeThis != null) + UpdateLog.Remove(removeThis); + } + + + } +} diff --git a/src/Logic/Networking/UpdateLogEntry.cs b/src/Logic/Networking/UpdateLogEntry.cs new file mode 100644 index 000000000..f5790d4e3 --- /dev/null +++ b/src/Logic/Networking/UpdateLogEntry.cs @@ -0,0 +1,28 @@ +using System; + +namespace Nikse.SubtitleEdit.Logic.Networking +{ + public class UpdateLogEntry + { + public int Id { get; set; } + public string UserName { get; set; } + public int Index { get; set; } + public DateTime OccuredAt { get; set; } + public string Action { get; set; } + + public UpdateLogEntry(int id, string userName, int index, string action) + { + Id = id; + UserName = userName; + Index = index; + OccuredAt = DateTime.Now; + Action = action; + } + + public override string ToString() + { + return string.Format("{0:00}:{1:00}:{2:00} {3}: {4}", OccuredAt.Hour, OccuredAt.Minute, OccuredAt.Second, UserName, Action); + } + + } +} diff --git a/src/Logic/OCR/OcrFixEngine.cs b/src/Logic/OCR/OcrFixEngine.cs index 95c84b73a..d354d9dc1 100644 --- a/src/Logic/OCR/OcrFixEngine.cs +++ b/src/Logic/OCR/OcrFixEngine.cs @@ -320,6 +320,8 @@ namespace Nikse.SubtitleEdit.Logic.OCR // uppercase I or 1 inside lowercase word (will be replaced by lowercase L) word = FixIor1InsideLowerCaseWord(word); + word = FixLowerCaseLInsideUpperCaseWord(word); // eg. SCARLETTl => SCARLETTI + // Retry word replace list foreach (string from in _wordReplaceList.Keys) { @@ -340,6 +342,17 @@ namespace Nikse.SubtitleEdit.Logic.OCR if (startEndEndsWithNumber.IsMatch(word)) return word; + if (word.Contains("1") || + word.Contains("2") || + word.Contains("3") || + word.Contains("4") || + word.Contains("5") || + word.Contains("6") || + word.Contains("7") || + word.Contains("8") || + word.Contains("9")) + return word; + var hexNumber = new Regex(@"^#?[\dABDEFabcdef]+$"); if (hexNumber.IsMatch(word)) return word; @@ -392,6 +405,16 @@ namespace Nikse.SubtitleEdit.Logic.OCR if (startEndEndsWithNumber.IsMatch(word)) return word; + if (word.Contains("2") || + word.Contains("3") || + word.Contains("4") || + word.Contains("5") || + word.Contains("6") || + word.Contains("7") || + word.Contains("8") || + word.Contains("9")) + return word; + var hexNumber = new Regex(@"^#?[\dABDEFabcdef]+$"); if (hexNumber.IsMatch(word)) return word; @@ -418,6 +441,18 @@ namespace Nikse.SubtitleEdit.Logic.OCR return word; } + public static string FixLowerCaseLInsideUpperCaseWord(string word) + { + if (word.Length > 3 && word.Replace("l", string.Empty).ToUpper() == word.Replace("l", string.Empty)) + { + if (!word.Contains("<") && !word.Contains(">") && !word.Contains("'")) + { + word = word.Replace("l", "I"); + } + } + return word; + } + private string FixCommenOcrLineErrors(string input, string lastLine) { input = FixOcrErrorsViaHardcodedRules(input, lastLine); diff --git a/src/Logic/Settings.cs b/src/Logic/Settings.cs index 97b03fc27..9afb82869 100644 --- a/src/Logic/Settings.cs +++ b/src/Logic/Settings.cs @@ -232,6 +232,7 @@ namespace Nikse.SubtitleEdit.Logic public int DefaultAdjustMilliseconds { get; set; } public bool AutoRepeatOn { get; set; } public bool AutoContinueOn { get; set; } + public bool SyncListViewWithVideoWhilePlaying { get; set; } public int AutoBackupSeconds { get; set; } public GeneralSettings() @@ -275,6 +276,7 @@ namespace Nikse.SubtitleEdit.Logic DefaultAdjustMilliseconds = 1000; AutoRepeatOn = true; AutoContinueOn = false; + SyncListViewWithVideoWhilePlaying = false; AutoBackupSeconds = 0; } } @@ -333,6 +335,20 @@ namespace Nikse.SubtitleEdit.Logic public string SearchType { get; set; } } + public class NetworkSettings + { + public string UserName { get; set; } + public string WebServiceUrl { get; set; } + public string SessionKey { get; set; } + + public NetworkSettings() + { + UserName = string.Empty; + SessionKey = "DemoSession"; // TODO - leave blank or use guid + WebServiceUrl = "http://www.nikse.dk/se/SeService.asmx"; + } + } + public class Settings { public RecentFilesSettings RecentFiles { get; set; } @@ -344,6 +360,7 @@ namespace Nikse.SubtitleEdit.Logic public FixCommonErrorsSettings CommonErrors { get; set; } public VobSubOcrSettings VobSubOcr { get; set; } public VideoControlsSettings VideoControls { get; set; } + public NetworkSettings NetworkSettings { get; set; } [XmlArrayItem("MultipleSearchAndReplaceItem")] public List MultipleSearchAndReplaceList { get; set; } @@ -362,6 +379,7 @@ namespace Nikse.SubtitleEdit.Logic CommonErrors = new FixCommonErrorsSettings(); VobSubOcr = new VobSubOcrSettings(); VideoControls = new VideoControlsSettings(); + NetworkSettings = new Logic.NetworkSettings(); MultipleSearchAndReplaceList = new List(); Language = new Language(); } @@ -430,6 +448,8 @@ namespace Nikse.SubtitleEdit.Logic settings.VobSubOcr = new VobSubOcrSettings(); if (settings.MultipleSearchAndReplaceList == null) settings.MultipleSearchAndReplaceList = new List(); + if (settings.NetworkSettings == null) + settings.NetworkSettings = new NetworkSettings(); return settings; } @@ -582,6 +602,9 @@ namespace Nikse.SubtitleEdit.Logic subNode = node.SelectSingleNode("AutoRepeatOn"); if (subNode != null) settings.General.AutoRepeatOn = Convert.ToBoolean(subNode.InnerText); + subNode = node.SelectSingleNode("SyncListViewWithVideoWhilePlaying"); + if (subNode != null) + settings.General.SyncListViewWithVideoWhilePlaying = Convert.ToBoolean(subNode.InnerText); subNode = node.SelectSingleNode("AutoContinueOn"); if (subNode != null) settings.General.AutoContinueOn = Convert.ToBoolean(subNode.InnerText); @@ -766,6 +789,20 @@ namespace Nikse.SubtitleEdit.Logic if (subNode != null) settings.VideoControls.WaveFormTextColor = Color.FromArgb(int.Parse(subNode.InnerText)); + settings.NetworkSettings = new NetworkSettings(); + node = doc.DocumentElement.SelectSingleNode("NetworkSettings"); + if (node != null) + { + subNode = node.SelectSingleNode("SessionKey"); + if (subNode != null) + settings.NetworkSettings.SessionKey = subNode.InnerText; + subNode = node.SelectSingleNode("UserName"); + if (subNode != null) + settings.NetworkSettings.UserName = subNode.InnerText; + subNode = node.SelectSingleNode("WebServiceUrl"); + if (subNode != null) + settings.NetworkSettings.WebServiceUrl = subNode.InnerText; + } settings.VobSubOcr = new Nikse.SubtitleEdit.Logic.VobSubOcrSettings(); node = doc.DocumentElement.SelectSingleNode("VobSubOcr"); @@ -870,6 +907,7 @@ namespace Nikse.SubtitleEdit.Logic textWriter.WriteElementString("DefaultAdjustMilliseconds", settings.General.DefaultAdjustMilliseconds.ToString()); textWriter.WriteElementString("AutoRepeatOn", settings.General.AutoRepeatOn.ToString()); textWriter.WriteElementString("AutoContinueOn", settings.General.AutoContinueOn.ToString()); + textWriter.WriteElementString("SyncListViewWithVideoWhilePlaying", settings.General.SyncListViewWithVideoWhilePlaying.ToString()); textWriter.WriteElementString("AutoBackupSeconds", settings.General.AutoBackupSeconds.ToString()); textWriter.WriteEndElement(); @@ -936,7 +974,6 @@ namespace Nikse.SubtitleEdit.Logic textWriter.WriteElementString("CustomSearchText", settings.VideoControls.CustomSearchText); textWriter.WriteElementString("CustomSearchUrl", settings.VideoControls.CustomSearchUrl); textWriter.WriteElementString("LastActiveTab", settings.VideoControls.LastActiveTab); - textWriter.WriteElementString("WaveFormDrawGrid", settings.VideoControls.WaveFormDrawGrid.ToString()); textWriter.WriteElementString("WaveFormGridColor", settings.VideoControls.WaveFormGridColor.ToArgb().ToString()); textWriter.WriteElementString("WaveFormColor", settings.VideoControls.WaveFormColor.ToArgb().ToString()); @@ -945,6 +982,12 @@ namespace Nikse.SubtitleEdit.Logic textWriter.WriteElementString("WaveFormTextColor", settings.VideoControls.WaveFormTextColor.ToArgb().ToString()); textWriter.WriteEndElement(); + textWriter.WriteStartElement("NetworkSettings", ""); + textWriter.WriteElementString("SessionKey", settings.NetworkSettings.SessionKey); + textWriter.WriteElementString("UserName", settings.NetworkSettings.UserName); + textWriter.WriteElementString("WebServiceUrl", settings.NetworkSettings.WebServiceUrl); + textWriter.WriteEndElement(); + textWriter.WriteStartElement("VobSubOcr", ""); textWriter.WriteElementString("XOrMorePixelsMakesSpace", settings.VobSubOcr.XOrMorePixelsMakesSpace.ToString()); textWriter.WriteElementString("AllowDifferenceInPercent", settings.VobSubOcr.AllowDifferenceInPercent.ToString()); diff --git a/src/Logic/Subtitle.cs b/src/Logic/Subtitle.cs index f83d5764f..e6e32a6b7 100644 --- a/src/Logic/Subtitle.cs +++ b/src/Logic/Subtitle.cs @@ -301,6 +301,18 @@ namespace Nikse.SubtitleEdit.Logic return _paragraphs.IndexOf(p); } + internal Paragraph GetFirstAlike(Paragraph p) + { + foreach (Paragraph item in _paragraphs) + { + if (p.StartTime.TotalMilliseconds == item.StartTime.TotalMilliseconds && + p.EndTime.TotalMilliseconds == item.EndTime.TotalMilliseconds && + p.Text == item.Text) + return item; + } + return null; + } + internal Paragraph GetFirstParagraphByLineNumber(int number) { foreach (Paragraph p in _paragraphs) diff --git a/src/Logic/Utilities.cs b/src/Logic/Utilities.cs index 12d20e747..1abc09452 100644 --- a/src/Logic/Utilities.cs +++ b/src/Logic/Utilities.cs @@ -12,6 +12,7 @@ using Nikse.SubtitleEdit.Controls; using Nikse.SubtitleEdit.Forms; using Nikse.SubtitleEdit.Logic.SubtitleFormats; using Nikse.SubtitleEdit.Logic.VideoPlayers; +using System.Drawing; namespace Nikse.SubtitleEdit.Logic { @@ -289,6 +290,38 @@ namespace Nikse.SubtitleEdit.Logic int splitPos = -1; int mid = s.Length / 2; + // try to find " - " with uppercase letter after (dialogue) + if (splitPos == -1 && s.Contains(" - ")) + { + for (int j = 0; j < 40; j++) + { + if (mid + j + 4 < s.Length) + { + if (s[mid + j] == '-' && s[mid + j + 1] == ' ' && s[mid + j- 1] == ' ') + { + string rest = s.Substring(mid + j + 1).TrimStart(); + if (rest.Length > 0 && (rest.Substring(0, 1) == rest.Substring(0, 1).ToUpper())) + { + splitPos = mid + j; + break; + } + } + } + if (mid - (j + 1) > 4) + { + if (s[mid - j] == '-' && s[mid - j + 1] == ' ' && s[mid - j - 1] == ' ') + { + string rest = s.Substring(mid - j + 1).TrimStart(); + if (rest.Length > 0 && (rest.Substring(0, 1) == rest.Substring(0, 1).ToUpper())) + { + splitPos = mid - j; + break; + } + } + } + } + } + if (splitPos == -1) { for (int j = 0; j < 15; j++) @@ -757,6 +790,10 @@ namespace Nikse.SubtitleEdit.Logic if (count > bestCount) return "vi"; // Vietnamese + count = GetCount(text, "是的", "是啊", "好吧", "好的", "亲爱的", "早上好"); + if (count > bestCount) + return "zh"; // Chinese (simplified) - not tested... + return string.Empty; } @@ -1330,5 +1367,72 @@ namespace Nikse.SubtitleEdit.Logic return s; } + internal static Color GetColorFromUserName(string userName) + { + if (string.IsNullOrEmpty(userName)) + return System.Drawing.Color.Pink; + + byte[] buffer = System.Text.Encoding.UTF8.GetBytes(userName); + long number = 0; + foreach (byte b in buffer) + number += b; + + switch (number % 20) + { + case 0: return Color.Red; + case 1: return Color.Blue; + case 2: return Color.Green; + case 3: return Color.DarkCyan; + case 4: return Color.DarkGreen; + case 5: return Color.DarkBlue; + case 6: return Color.DarkTurquoise; + case 7: return Color.DarkViolet; + case 8: return Color.DeepPink; + case 9: return Color.DodgerBlue; + case 10: return Color.ForestGreen; + case 11: return Color.Fuchsia; + case 12: return Color.DarkOrange; + case 13: return Color.GreenYellow; + case 14: return Color.IndianRed; + case 15: return Color.Indigo; + case 16: return Color.LawnGreen; + case 17: return Color.LightBlue; + case 18: return Color.DarkGoldenrod; + case 19: return Color.Magenta; + case 20: return Color.Maroon; + default: + return Color.Black; + } + } + + internal static int GetNumber0To7FromUserName(string userName) + { + if (string.IsNullOrEmpty(userName)) + return 0; + + byte[] buffer = System.Text.Encoding.UTF8.GetBytes(userName); + long number = 0; + foreach (byte b in buffer) + number += b; + + return (int)(number % 8); + } + + internal static string GetRegExGroup( string regEx) + { + int start = regEx.IndexOf("(?<"); + if (start >= 0 && regEx.IndexOf(")", start) > start) + { + int end = regEx.IndexOf(">", start); + if (end > start) + { + start += 3; + string group = regEx.Substring(start, end - start); + return group; + } + } + return null; + } + } } \ No newline at end of file diff --git a/src/Properties/AssemblyInfo.cs b/src/Properties/AssemblyInfo.cs index 2657c85b8..0b67e5574 100644 --- a/src/Properties/AssemblyInfo.cs +++ b/src/Properties/AssemblyInfo.cs @@ -31,4 +31,4 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("3.0.0.*")] +[assembly: AssemblyVersion("3.0.1.*")] diff --git a/src/Properties/Resources.Designer.cs b/src/Properties/Resources.Designer.cs index dda11ea47..c21d0ea50 100644 --- a/src/Properties/Resources.Designer.cs +++ b/src/Properties/Resources.Designer.cs @@ -22,7 +22,7 @@ namespace Nikse.SubtitleEdit.Properties { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { + public class Resources { private static global::System.Resources.ResourceManager resourceMan; @@ -36,7 +36,7 @@ namespace Nikse.SubtitleEdit.Properties { /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { + public static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Nikse.SubtitleEdit.Properties.Resources", typeof(Resources).Assembly); @@ -51,7 +51,7 @@ namespace Nikse.SubtitleEdit.Properties { /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { + public static global::System.Globalization.CultureInfo Culture { get { return resourceCulture; } @@ -60,7 +60,14 @@ namespace Nikse.SubtitleEdit.Properties { } } - internal static System.Drawing.Bitmap Donate { + public static System.Drawing.Bitmap connect { + get { + object obj = ResourceManager.GetObject("connect", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + public static System.Drawing.Bitmap Donate { get { object obj = ResourceManager.GetObject("Donate", resourceCulture); return ((System.Drawing.Bitmap)(obj)); diff --git a/src/Properties/Resources.resx b/src/Properties/Resources.resx index 27beb8fdd..05271ff9e 100644 --- a/src/Properties/Resources.resx +++ b/src/Properties/Resources.resx @@ -117,8 +117,12 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + ..\Icons\Donate.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Icons\connect.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/src/Properties/Settings.Designer.cs b/src/Properties/Settings.Designer.cs index 2d58d0f87..d85c246f0 100644 --- a/src/Properties/Settings.Designer.cs +++ b/src/Properties/Settings.Designer.cs @@ -32,5 +32,15 @@ namespace Nikse.SubtitleEdit.Properties { return ((string)(this["SubtitleEdit_MicrosoftTranslationService_SoapService"])); } } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.WebServiceUrl)] + [global::System.Configuration.DefaultSettingValueAttribute("http://localhost:2782/se/SeService.asmx")] + public string SubtitleEdit_SeNetworkService_SeService { + get { + return ((string)(this["SubtitleEdit_SeNetworkService_SeService"])); + } + } } } diff --git a/src/Properties/Settings.settings b/src/Properties/Settings.settings index 82e872cd0..15090ed1f 100644 --- a/src/Properties/Settings.settings +++ b/src/Properties/Settings.settings @@ -5,5 +5,8 @@ http://api.microsofttranslator.com/V2/soap.svc + + http://localhost:2782/se/SeService.asmx + \ No newline at end of file diff --git a/src/SubtitleEdit.csproj b/src/SubtitleEdit.csproj index 1c2bb5917..038f987a0 100644 --- a/src/SubtitleEdit.csproj +++ b/src/SubtitleEdit.csproj @@ -219,6 +219,30 @@ GetDictionaries.cs + + Form + + + NetworkChat.cs + + + Form + + + NetworkJoin.cs + + + Form + + + NetworkLogAndInfo.cs + + + Form + + + NetworkStart.cs + Form @@ -419,6 +443,12 @@ + + Code + + + Code + @@ -437,6 +467,7 @@ + @@ -505,6 +536,11 @@ True Reference.map + + True + True + Reference.map + TimeUpDown.cs Designer @@ -568,6 +604,18 @@ GetDictionaries.cs Designer + + NetworkChat.cs + + + NetworkJoin.cs + + + NetworkLogAndInfo.cs + + + NetworkStart.cs + SetSyncPoint.cs @@ -683,6 +731,7 @@ + Reference.map @@ -707,8 +756,24 @@ Reference.map + + MSDiscoCodeGenerator + Reference.cs + + + Reference.map + + + + Reference.map + + + Reference.map + + + @@ -766,6 +831,7 @@ + PreserveNewest @@ -887,6 +953,17 @@ Settings SubtitleEdit_MicrosoftTranslationService_SoapService + + Dynamic + Web References\SeNetworkService\ + http://localhost:2782/se/SeService.asmx + + + + + Settings + SubtitleEdit_SeNetworkService_SeService + diff --git a/src/Web References/SeNetworkService/Reference.cs b/src/Web References/SeNetworkService/Reference.cs new file mode 100644 index 000000000..75775103d --- /dev/null +++ b/src/Web References/SeNetworkService/Reference.cs @@ -0,0 +1,956 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.1 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +// +// This source code was auto-generated by Microsoft.VSDesigner, Version 4.0.30319.1. +// +#pragma warning disable 1591 + +namespace Nikse.SubtitleEdit.SeNetworkService { + using System; + using System.Web.Services; + using System.Diagnostics; + using System.Web.Services.Protocols; + using System.ComponentModel; + using System.Xml.Serialization; + + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Web.Services.WebServiceBindingAttribute(Name="SeServiceSoap", Namespace="http://tempuri.org/")] + public partial class SeService : System.Web.Services.Protocols.SoapHttpClientProtocol { + + private System.Threading.SendOrPostCallback StartOperationCompleted; + + private System.Threading.SendOrPostCallback JoinOperationCompleted; + + private System.Threading.SendOrPostCallback LeaveOperationCompleted; + + private System.Threading.SendOrPostCallback DeleteLinesOperationCompleted; + + private System.Threading.SendOrPostCallback InsertLineOperationCompleted; + + private System.Threading.SendOrPostCallback UpdateLineOperationCompleted; + + private System.Threading.SendOrPostCallback SendMessageOperationCompleted; + + private System.Threading.SendOrPostCallback GetUpdatesOperationCompleted; + + private System.Threading.SendOrPostCallback GetSubtitleOperationCompleted; + + private System.Threading.SendOrPostCallback GetOriginalSubtitleOperationCompleted; + + private bool useDefaultCredentialsSetExplicitly; + + /// + public SeService() { + this.Url = global::Nikse.SubtitleEdit.Properties.Settings.Default.SubtitleEdit_SeNetworkService_SeService; + if ((this.IsLocalFileSystemWebService(this.Url) == true)) { + this.UseDefaultCredentials = true; + this.useDefaultCredentialsSetExplicitly = false; + } + else { + this.useDefaultCredentialsSetExplicitly = true; + } + } + + public new string Url { + get { + return base.Url; + } + set { + if ((((this.IsLocalFileSystemWebService(base.Url) == true) + && (this.useDefaultCredentialsSetExplicitly == false)) + && (this.IsLocalFileSystemWebService(value) == false))) { + base.UseDefaultCredentials = false; + } + base.Url = value; + } + } + + public new bool UseDefaultCredentials { + get { + return base.UseDefaultCredentials; + } + set { + base.UseDefaultCredentials = value; + this.useDefaultCredentialsSetExplicitly = true; + } + } + + /// + public event StartCompletedEventHandler StartCompleted; + + /// + public event JoinCompletedEventHandler JoinCompleted; + + /// + public event LeaveCompletedEventHandler LeaveCompleted; + + /// + public event DeleteLinesCompletedEventHandler DeleteLinesCompleted; + + /// + public event InsertLineCompletedEventHandler InsertLineCompleted; + + /// + public event UpdateLineCompletedEventHandler UpdateLineCompleted; + + /// + public event SendMessageCompletedEventHandler SendMessageCompleted; + + /// + public event GetUpdatesCompletedEventHandler GetUpdatesCompleted; + + /// + public event GetSubtitleCompletedEventHandler GetSubtitleCompleted; + + /// + public event GetOriginalSubtitleCompletedEventHandler GetOriginalSubtitleCompleted; + + /// + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/Start", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public SeUser Start(string sessionKey, string userName, SeSequence[] subtitle, SeSequence[] originalSubtitle, string fileName, out string message) { + object[] results = this.Invoke("Start", new object[] { + sessionKey, + userName, + subtitle, + originalSubtitle, + fileName}); + message = ((string)(results[1])); + return ((SeUser)(results[0])); + } + + /// + public void StartAsync(string sessionKey, string userName, SeSequence[] subtitle, SeSequence[] originalSubtitle, string fileName) { + this.StartAsync(sessionKey, userName, subtitle, originalSubtitle, fileName, null); + } + + /// + public void StartAsync(string sessionKey, string userName, SeSequence[] subtitle, SeSequence[] originalSubtitle, string fileName, object userState) { + if ((this.StartOperationCompleted == null)) { + this.StartOperationCompleted = new System.Threading.SendOrPostCallback(this.OnStartOperationCompleted); + } + this.InvokeAsync("Start", new object[] { + sessionKey, + userName, + subtitle, + originalSubtitle, + fileName}, this.StartOperationCompleted, userState); + } + + private void OnStartOperationCompleted(object arg) { + if ((this.StartCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.StartCompleted(this, new StartCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/Join", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public SeUser[] Join(string sessionId, string userName, out string message) { + object[] results = this.Invoke("Join", new object[] { + sessionId, + userName}); + message = ((string)(results[1])); + return ((SeUser[])(results[0])); + } + + /// + public void JoinAsync(string sessionId, string userName) { + this.JoinAsync(sessionId, userName, null); + } + + /// + public void JoinAsync(string sessionId, string userName, object userState) { + if ((this.JoinOperationCompleted == null)) { + this.JoinOperationCompleted = new System.Threading.SendOrPostCallback(this.OnJoinOperationCompleted); + } + this.InvokeAsync("Join", new object[] { + sessionId, + userName}, this.JoinOperationCompleted, userState); + } + + private void OnJoinOperationCompleted(object arg) { + if ((this.JoinCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.JoinCompleted(this, new JoinCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/Leave", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public void Leave(string sessionId, string userName) { + this.Invoke("Leave", new object[] { + sessionId, + userName}); + } + + /// + public void LeaveAsync(string sessionId, string userName) { + this.LeaveAsync(sessionId, userName, null); + } + + /// + public void LeaveAsync(string sessionId, string userName, object userState) { + if ((this.LeaveOperationCompleted == null)) { + this.LeaveOperationCompleted = new System.Threading.SendOrPostCallback(this.OnLeaveOperationCompleted); + } + this.InvokeAsync("Leave", new object[] { + sessionId, + userName}, this.LeaveOperationCompleted, userState); + } + + private void OnLeaveOperationCompleted(object arg) { + if ((this.LeaveCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.LeaveCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/DeleteLines", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public bool DeleteLines(string sessionId, int[] indices, SeUser user) { + object[] results = this.Invoke("DeleteLines", new object[] { + sessionId, + indices, + user}); + return ((bool)(results[0])); + } + + /// + public void DeleteLinesAsync(string sessionId, int[] indices, SeUser user) { + this.DeleteLinesAsync(sessionId, indices, user, null); + } + + /// + public void DeleteLinesAsync(string sessionId, int[] indices, SeUser user, object userState) { + if ((this.DeleteLinesOperationCompleted == null)) { + this.DeleteLinesOperationCompleted = new System.Threading.SendOrPostCallback(this.OnDeleteLinesOperationCompleted); + } + this.InvokeAsync("DeleteLines", new object[] { + sessionId, + indices, + user}, this.DeleteLinesOperationCompleted, userState); + } + + private void OnDeleteLinesOperationCompleted(object arg) { + if ((this.DeleteLinesCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.DeleteLinesCompleted(this, new DeleteLinesCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/InsertLine", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public bool InsertLine(string sessionId, int index, int startMilliseconds, int endMilliseconds, string text, SeUser user) { + object[] results = this.Invoke("InsertLine", new object[] { + sessionId, + index, + startMilliseconds, + endMilliseconds, + text, + user}); + return ((bool)(results[0])); + } + + /// + public void InsertLineAsync(string sessionId, int index, int startMilliseconds, int endMilliseconds, string text, SeUser user) { + this.InsertLineAsync(sessionId, index, startMilliseconds, endMilliseconds, text, user, null); + } + + /// + public void InsertLineAsync(string sessionId, int index, int startMilliseconds, int endMilliseconds, string text, SeUser user, object userState) { + if ((this.InsertLineOperationCompleted == null)) { + this.InsertLineOperationCompleted = new System.Threading.SendOrPostCallback(this.OnInsertLineOperationCompleted); + } + this.InvokeAsync("InsertLine", new object[] { + sessionId, + index, + startMilliseconds, + endMilliseconds, + text, + user}, this.InsertLineOperationCompleted, userState); + } + + private void OnInsertLineOperationCompleted(object arg) { + if ((this.InsertLineCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.InsertLineCompleted(this, new InsertLineCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/UpdateLine", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public bool UpdateLine(string sessionId, int index, SeSequence sequence, SeUser user) { + object[] results = this.Invoke("UpdateLine", new object[] { + sessionId, + index, + sequence, + user}); + return ((bool)(results[0])); + } + + /// + public void UpdateLineAsync(string sessionId, int index, SeSequence sequence, SeUser user) { + this.UpdateLineAsync(sessionId, index, sequence, user, null); + } + + /// + public void UpdateLineAsync(string sessionId, int index, SeSequence sequence, SeUser user, object userState) { + if ((this.UpdateLineOperationCompleted == null)) { + this.UpdateLineOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUpdateLineOperationCompleted); + } + this.InvokeAsync("UpdateLine", new object[] { + sessionId, + index, + sequence, + user}, this.UpdateLineOperationCompleted, userState); + } + + private void OnUpdateLineOperationCompleted(object arg) { + if ((this.UpdateLineCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.UpdateLineCompleted(this, new UpdateLineCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/SendMessage", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public bool SendMessage(string sessionId, string text, SeUser user) { + object[] results = this.Invoke("SendMessage", new object[] { + sessionId, + text, + user}); + return ((bool)(results[0])); + } + + /// + public void SendMessageAsync(string sessionId, string text, SeUser user) { + this.SendMessageAsync(sessionId, text, user, null); + } + + /// + public void SendMessageAsync(string sessionId, string text, SeUser user, object userState) { + if ((this.SendMessageOperationCompleted == null)) { + this.SendMessageOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSendMessageOperationCompleted); + } + this.InvokeAsync("SendMessage", new object[] { + sessionId, + text, + user}, this.SendMessageOperationCompleted, userState); + } + + private void OnSendMessageOperationCompleted(object arg) { + if ((this.SendMessageCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.SendMessageCompleted(this, new SendMessageCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/GetUpdates", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public SeUpdate[] GetUpdates(string sessionId, string userName, System.DateTime lastUpdateTime, out string message, out System.DateTime newUpdateTime) { + object[] results = this.Invoke("GetUpdates", new object[] { + sessionId, + userName, + lastUpdateTime}); + message = ((string)(results[1])); + newUpdateTime = ((System.DateTime)(results[2])); + return ((SeUpdate[])(results[0])); + } + + /// + public void GetUpdatesAsync(string sessionId, string userName, System.DateTime lastUpdateTime) { + this.GetUpdatesAsync(sessionId, userName, lastUpdateTime, null); + } + + /// + public void GetUpdatesAsync(string sessionId, string userName, System.DateTime lastUpdateTime, object userState) { + if ((this.GetUpdatesOperationCompleted == null)) { + this.GetUpdatesOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetUpdatesOperationCompleted); + } + this.InvokeAsync("GetUpdates", new object[] { + sessionId, + userName, + lastUpdateTime}, this.GetUpdatesOperationCompleted, userState); + } + + private void OnGetUpdatesOperationCompleted(object arg) { + if ((this.GetUpdatesCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.GetUpdatesCompleted(this, new GetUpdatesCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/GetSubtitle", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public SeSequence[] GetSubtitle(string sessionId, out string fileName, out System.DateTime updateTime) { + object[] results = this.Invoke("GetSubtitle", new object[] { + sessionId}); + fileName = ((string)(results[1])); + updateTime = ((System.DateTime)(results[2])); + return ((SeSequence[])(results[0])); + } + + /// + public void GetSubtitleAsync(string sessionId) { + this.GetSubtitleAsync(sessionId, null); + } + + /// + public void GetSubtitleAsync(string sessionId, object userState) { + if ((this.GetSubtitleOperationCompleted == null)) { + this.GetSubtitleOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetSubtitleOperationCompleted); + } + this.InvokeAsync("GetSubtitle", new object[] { + sessionId}, this.GetSubtitleOperationCompleted, userState); + } + + private void OnGetSubtitleOperationCompleted(object arg) { + if ((this.GetSubtitleCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.GetSubtitleCompleted(this, new GetSubtitleCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/GetOriginalSubtitle", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public SeSequence[] GetOriginalSubtitle(string sessionId) { + object[] results = this.Invoke("GetOriginalSubtitle", new object[] { + sessionId}); + return ((SeSequence[])(results[0])); + } + + /// + public void GetOriginalSubtitleAsync(string sessionId) { + this.GetOriginalSubtitleAsync(sessionId, null); + } + + /// + public void GetOriginalSubtitleAsync(string sessionId, object userState) { + if ((this.GetOriginalSubtitleOperationCompleted == null)) { + this.GetOriginalSubtitleOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetOriginalSubtitleOperationCompleted); + } + this.InvokeAsync("GetOriginalSubtitle", new object[] { + sessionId}, this.GetOriginalSubtitleOperationCompleted, userState); + } + + private void OnGetOriginalSubtitleOperationCompleted(object arg) { + if ((this.GetOriginalSubtitleCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.GetOriginalSubtitleCompleted(this, new GetOriginalSubtitleCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// + public new void CancelAsync(object userState) { + base.CancelAsync(userState); + } + + private bool IsLocalFileSystemWebService(string url) { + if (((url == null) + || (url == string.Empty))) { + return false; + } + System.Uri wsUri = new System.Uri(url); + if (((wsUri.Port >= 1024) + && (string.Compare(wsUri.Host, "localHost", System.StringComparison.OrdinalIgnoreCase) == 0))) { + return true; + } + return false; + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.1")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://tempuri.org/")] + public partial class SeSequence { + + private int indexField; + + private int startMillisecondsField; + + private int endMillisecondsField; + + private string textField; + + /// + public int Index { + get { + return this.indexField; + } + set { + this.indexField = value; + } + } + + /// + public int StartMilliseconds { + get { + return this.startMillisecondsField; + } + set { + this.startMillisecondsField = value; + } + } + + /// + public int EndMilliseconds { + get { + return this.endMillisecondsField; + } + set { + this.endMillisecondsField = value; + } + } + + /// + public string Text { + get { + return this.textField; + } + set { + this.textField = value; + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.1")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://tempuri.org/")] + public partial class SeUpdate { + + private System.DateTime timeField; + + private SeUser userField; + + private int indexField; + + private int startMillisecondsField; + + private int endMillisecondsField; + + private string textField; + + private string actionField; + + /// + public System.DateTime Time { + get { + return this.timeField; + } + set { + this.timeField = value; + } + } + + /// + public SeUser User { + get { + return this.userField; + } + set { + this.userField = value; + } + } + + /// + public int Index { + get { + return this.indexField; + } + set { + this.indexField = value; + } + } + + /// + public int StartMilliseconds { + get { + return this.startMillisecondsField; + } + set { + this.startMillisecondsField = value; + } + } + + /// + public int EndMilliseconds { + get { + return this.endMillisecondsField; + } + set { + this.endMillisecondsField = value; + } + } + + /// + public string Text { + get { + return this.textField; + } + set { + this.textField = value; + } + } + + /// + public string Action { + get { + return this.actionField; + } + set { + this.actionField = value; + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.1")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://tempuri.org/")] + public partial class SeUser { + + private string userNameField; + + private string ipField; + + private System.DateTime lastActivityField; + + /// + public string UserName { + get { + return this.userNameField; + } + set { + this.userNameField = value; + } + } + + /// + public string Ip { + get { + return this.ipField; + } + set { + this.ipField = value; + } + } + + /// + public System.DateTime LastActivity { + get { + return this.lastActivityField; + } + set { + this.lastActivityField = value; + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")] + public delegate void StartCompletedEventHandler(object sender, StartCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class StartCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal StartCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// + public SeUser Result { + get { + this.RaiseExceptionIfNecessary(); + return ((SeUser)(this.results[0])); + } + } + + /// + public string message { + get { + this.RaiseExceptionIfNecessary(); + return ((string)(this.results[1])); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")] + public delegate void JoinCompletedEventHandler(object sender, JoinCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class JoinCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal JoinCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// + public SeUser[] Result { + get { + this.RaiseExceptionIfNecessary(); + return ((SeUser[])(this.results[0])); + } + } + + /// + public string message { + get { + this.RaiseExceptionIfNecessary(); + return ((string)(this.results[1])); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")] + public delegate void LeaveCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")] + public delegate void DeleteLinesCompletedEventHandler(object sender, DeleteLinesCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class DeleteLinesCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal DeleteLinesCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// + public bool Result { + get { + this.RaiseExceptionIfNecessary(); + return ((bool)(this.results[0])); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")] + public delegate void InsertLineCompletedEventHandler(object sender, InsertLineCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class InsertLineCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal InsertLineCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// + public bool Result { + get { + this.RaiseExceptionIfNecessary(); + return ((bool)(this.results[0])); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")] + public delegate void UpdateLineCompletedEventHandler(object sender, UpdateLineCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class UpdateLineCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal UpdateLineCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// + public bool Result { + get { + this.RaiseExceptionIfNecessary(); + return ((bool)(this.results[0])); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")] + public delegate void SendMessageCompletedEventHandler(object sender, SendMessageCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class SendMessageCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal SendMessageCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// + public bool Result { + get { + this.RaiseExceptionIfNecessary(); + return ((bool)(this.results[0])); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")] + public delegate void GetUpdatesCompletedEventHandler(object sender, GetUpdatesCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class GetUpdatesCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal GetUpdatesCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// + public SeUpdate[] Result { + get { + this.RaiseExceptionIfNecessary(); + return ((SeUpdate[])(this.results[0])); + } + } + + /// + public string message { + get { + this.RaiseExceptionIfNecessary(); + return ((string)(this.results[1])); + } + } + + /// + public System.DateTime newUpdateTime { + get { + this.RaiseExceptionIfNecessary(); + return ((System.DateTime)(this.results[2])); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")] + public delegate void GetSubtitleCompletedEventHandler(object sender, GetSubtitleCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class GetSubtitleCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal GetSubtitleCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// + public SeSequence[] Result { + get { + this.RaiseExceptionIfNecessary(); + return ((SeSequence[])(this.results[0])); + } + } + + /// + public string fileName { + get { + this.RaiseExceptionIfNecessary(); + return ((string)(this.results[1])); + } + } + + /// + public System.DateTime updateTime { + get { + this.RaiseExceptionIfNecessary(); + return ((System.DateTime)(this.results[2])); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")] + public delegate void GetOriginalSubtitleCompletedEventHandler(object sender, GetOriginalSubtitleCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class GetOriginalSubtitleCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal GetOriginalSubtitleCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// + public SeSequence[] Result { + get { + this.RaiseExceptionIfNecessary(); + return ((SeSequence[])(this.results[0])); + } + } + } +} + +#pragma warning restore 1591 \ No newline at end of file diff --git a/src/Web References/SeNetworkService/Reference.map b/src/Web References/SeNetworkService/Reference.map new file mode 100644 index 000000000..1e0d2be34 --- /dev/null +++ b/src/Web References/SeNetworkService/Reference.map @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/Web References/SeNetworkService/SeSequence.datasource b/src/Web References/SeNetworkService/SeSequence.datasource new file mode 100644 index 000000000..43e5c99e7 --- /dev/null +++ b/src/Web References/SeNetworkService/SeSequence.datasource @@ -0,0 +1,10 @@ + + + + Nikse.SubtitleEdit.SeNetworkService.SeSequence, Web References.SeNetworkService.Reference.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/src/Web References/SeNetworkService/SeService.disco b/src/Web References/SeNetworkService/SeService.disco new file mode 100644 index 000000000..52c06b987 --- /dev/null +++ b/src/Web References/SeNetworkService/SeService.disco @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/Web References/SeNetworkService/SeService.wsdl b/src/Web References/SeNetworkService/SeService.wsdl new file mode 100644 index 000000000..6c2e55f6b --- /dev/null +++ b/src/Web References/SeNetworkService/SeService.wsdl @@ -0,0 +1,511 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Web References/SeNetworkService/SeUpdate.datasource b/src/Web References/SeNetworkService/SeUpdate.datasource new file mode 100644 index 000000000..b852c093a --- /dev/null +++ b/src/Web References/SeNetworkService/SeUpdate.datasource @@ -0,0 +1,10 @@ + + + + Nikse.SubtitleEdit.SeNetworkService.SeUpdate, Web References.SeNetworkService.Reference.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/src/Web References/SeNetworkService/SeUser.datasource b/src/Web References/SeNetworkService/SeUser.datasource new file mode 100644 index 000000000..c4d33982e --- /dev/null +++ b/src/Web References/SeNetworkService/SeUser.datasource @@ -0,0 +1,10 @@ + + + + Nikse.SubtitleEdit.SeNetworkService.SeUser, Web References.SeNetworkService.Reference.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/src/app.config b/src/app.config index 5faf54583..b2d6ca5c9 100644 --- a/src/app.config +++ b/src/app.config @@ -11,6 +11,9 @@ serializeAs="String"> http://api.microsofttranslator.com/V2/soap.svc + + http://localhost:2782/se/SeService.asmx + \ No newline at end of file