/// <summary> /// Method to move the item from the clipboard. /// </summary> /// <param name="destination"></param> public void MoveFromClipboard(List <int> destination) { if (clipboard_item != null) { Type type = clipboard_item.GetType(); bool accepted_type = (type != typeof(VirtualNewAction)) && (type != typeof(VirtualNewCondition)); if (accepted_type) { if (!actions.MoveTo(clipboard_item, destination)) { RestoreClipboard(); } } } }
private void button_Apply_Click(object sender, EventArgs e) { IScriptElement element = (IScriptElement)listBox_ScriptMessages.SelectedItem; if (element.GetType() == typeof(ScriptMessage)) { ScriptMessage message = (ScriptMessage)element; message.Content = richTextBox_ScriptMessage.Text.Replace("\n", "\r\n"); } ScriptDocument script = (ScriptDocument)listBox_ScriptFiles.SelectedItem; ScriptParser.Parse(script, _elements); richTextBox_ScriptFile.Select(0, 0); richTextBox_ScriptFile.ScrollToCaret(); richTextBox_ScriptFile.Text = script.TextBuffer; }
/// <summary> /// Method for element moving. /// </summary> /// <param name="target">Element to move.</param> /// <param name="path">Set of indexes for destination identification.</param> /// <returns>True if the movement was successful, false otherwise.</returns> public bool MoveTo(IScriptElement target, List <int> path) { int root; // Check for adding to the root category, append the element in this case. if (path.Count == 0) { root = data.Count - 1; } else { // Special root edit for the attempt to put the element into zeroth place (after element -1, which // is non-existent). root = Math.Max(path[0], 0); path.RemoveAt(0); } if (path.Count == 0) { Type type = data[root].GetType(); // Special check for an attempt to add an action to a condition array and vise-versa. if (!target.GetType().IsSubclassOf(type.BaseType)) { return(false); } // Another special check for an attempt to put the element after virtual elements. if ((type == typeof(VirtualNewAction)) || (type == typeof(VirtualNewCondition))) { IScriptElement item = data[root]; data.Remove(item); data.Add(target); data.Add(item); } else { data.Insert(root + 1, target); } return(true); } return(data[root].AddSubElement(target, path)); }
public void UpdateScriptMessage() { if (_changingMessageSelection) { return; } IScriptElement element = (IScriptElement)listBox_ScriptMessages.SelectedItem; if (element == null) { return; } if (element.GetType() == typeof(ScriptMessage)) { ScriptMessage message = (ScriptMessage)element; message.Content = richTextBox_ScriptMessage.Text.Replace("\n", "\r\n"); UpdatePreview(message); } ScriptDocument script = (ScriptDocument)listBox_ScriptFiles.SelectedItem; ScriptParser.Parse(script, _elements); _updatingMessage = true; Win32.LockWindow(this.Handle); int scrollPos = Win32.GetScrollPos(richTextBox_ScriptFile.Handle, 1); int pos = richTextBox_ScriptFile.SelectionStart; int len = richTextBox_ScriptFile.SelectionLength; richTextBox_ScriptFile.Text = script.TextBuffer; richTextBox_ScriptFile.SelectionStart = pos; richTextBox_ScriptFile.SelectionLength = len; Win32.SetScrollPos(richTextBox_ScriptFile.Handle, 1, scrollPos, true); Win32.PostMessage(richTextBox_ScriptFile.Handle, 0x115, 4 + 0x10000 * scrollPos, 0); Win32.LockWindow(IntPtr.Zero); _updatingMessage = false; }