// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; using System.Globalization; using System.Windows.Documents; namespace Tango.Scripting.Editors.Document { /// /// Specifies the mode for getting the next caret position. /// public enum CaretPositioningMode { /// /// Normal positioning (stop at every caret position) /// Normal, /// /// Stop only on word borders. /// WordBorder, /// /// Stop only at the beginning of words. This is used for Ctrl+Left/Ctrl+Right. /// WordStart, /// /// Stop only at the beginning of words, and anywhere in the middle of symbols. /// WordStartOrSymbol, /// /// Stop only on word borders, and anywhere in the middle of symbols. /// WordBorderOrSymbol } /// /// Static helper methods for working with text. /// public static partial class TextUtilities { #region GetControlCharacterName // the names of the first 32 ASCII characters = Unicode C0 block static readonly string[] c0Table = { "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI", "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US" }; // DEL (ASCII 127) and // the names of the control characters in the C1 block (Unicode 128 to 159) static readonly string[] delAndC1Table = { "DEL", "PAD", "HOP", "BPH", "NBH", "IND", "NEL", "SSA", "ESA", "HTS", "HTJ", "VTS", "PLD", "PLU", "RI", "SS2", "SS3", "DCS", "PU1", "PU2", "STS", "CCH", "MW", "SPA", "EPA", "SOS", "SGCI", "SCI", "CSI", "ST", "OSC", "PM", "APC" }; /// /// Gets the name of the control character. /// For unknown characters, the unicode codepoint is returned as 4-digit hexadecimal value. /// public static string GetControlCharacterName(char controlCharacter) { int num = (int)controlCharacter; if (num < c0Table.Length) return c0Table[num]; else if (num >= 127 && num <= 159) return delAndC1Table[num - 127]; else return num.ToString("x4", CultureInfo.InvariantCulture); } #endregion #region GetWhitespace /// /// Gets all whitespace (' ' and '\t', but no newlines) after offset. /// /// The text source. /// The offset where the whitespace starts. /// The segment containing the whitespace. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "Whitespace", Justification = "WPF uses 'Whitespace'")] public static ISegment GetWhitespaceAfter(ITextSource textSource, int offset) { if (textSource == null) throw new ArgumentNullException("textSource"); int pos; for (pos = offset; pos < textSource.TextLength; pos++) { char c = textSource.GetCharAt(pos); if (c != ' ' && c != '\t') break; } return new SimpleSegment(offset, pos - offset); } /// /// Gets all whitespace (' ' and '\t', but no newlines) before offset. /// /// The text source. /// The offset where the whitespace ends. /// The segment containing the whitespace. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "Whitespace", Justification = "WPF uses 'Whitespace'")] public static ISegment GetWhitespaceBefore(ITextSource textSource, int offset) { if (textSource == null) throw new ArgumentNullException("textSource"); int pos; for (pos = offset - 1; pos >= 0; pos--) { char c = textSource.GetCharAt(pos); if (c != ' ' && c != '\t') break; } pos++; // go back the one character that isn't whitespace return new SimpleSegment(pos, offset - pos); } /// /// Gets the leading whitespace segment on the document line. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "Whitespace", Justification = "WPF uses 'Whitespace'")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters", Justification = "Parameter cannot be ITextSource because it must belong to the DocumentLine")] public static ISegment GetLeadingWhitespace(TextDocument document, DocumentLine documentLine) { if (documentLine == null) throw new ArgumentNullException("documentLine"); return GetWhitespaceAfter(document, documentLine.Offset); } /// /// Gets the trailing whitespace segment on the document line. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "Whitespace", Justification = "WPF uses 'White
using MahApps.Metro.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Tango.MachineStudio.UI.ViewModels;

namespace Tango.MachineStudio.UI.Windows
{
    /// <summary>
    /// Interaction logic for ModuleWindow.xaml
    /// </summary>
    public partial class ModuleWindow : MetroWindow
    {
        public ModuleWindowVM ModuleContext
        {
            get { return (ModuleWindowVM)GetValue(ModuleContextProperty); }
            set { SetValue(ModuleContextProperty, value); }
        }
        public static readonly DependencyProperty ModuleContextProperty =
            DependencyProperty.Register("ModuleContext", typeof(ModuleWindowVM), typeof(ModuleWindow), new PropertyMetadata(null));

        public ModuleWindow()
        {
            InitializeComponent();
        }

        public ModuleWindow(MainViewVM mainViewVM, ModuleWindowVM moduleVM, FrameworkElement view) : this()
        {
            DataContext = mainViewVM;
            ModuleContext = moduleVM;
            grid.Children.Add(view);
        }
    }
}