Beispiel #1
0
        public SnippetsWindow(SnippetsAddin addin)
        {
            InitializeComponent();
            mmApp.SetThemeWindowOverride(this);


            Model = new SnippetsAddinModel()
            {
                Configuration = SnippetsAddinConfiguration.Current,
                Window        = addin.Model.Window,
                AppModel      = addin.Model.Window.Model,
                Addin         = addin
            };


            if (Model.Configuration.Snippets == null || Model.Configuration.Snippets.Count < 1)
            {
                Model.Configuration.Snippets = new System.Collections.ObjectModel.ObservableCollection <Snippet>();
                Model.Configuration.Snippets.Add(new Snippet
                {
                    Name        = "Copyright Notice",
                    ScriptMode  = ScriptModes.CSharpExpressions,
                    Shortcut    = "copynotice",
                    SnippetText = @"
---
&copy; My Company, {{DateTime.Now.ToString(""yyyy"")}};
"
                });
            }
            else
            {
                Model.Configuration.Snippets =
                    new ObservableCollection <Snippet>(Model.Configuration.Snippets.OrderBy(snip => snip.Name));
                if (Model.Configuration.Snippets.Count > 0)
                {
                    Model.ActiveSnippet = Model.Configuration.Snippets[0];
                }
            }

            Loaded   += SnippetsWindow_Loaded;
            Unloaded += SnippetsWindow_Unloaded;

            WebBrowserSnippet.Visibility = Visibility.Hidden;

            DataContext = Model;
        }
Beispiel #2
0
        public SnippetsWindow(SnippetsAddin addin)
        {
            Owner = mmApp.Model.Window;

            InitializeComponent();
            mmApp.SetThemeWindowOverride(this);

            Model = new SnippetsAddinModel()
            {
                Configuration = SnippetsAddinConfiguration.Current,
                Window        = addin.Model.Window,
                AppModel      = addin.Model.Window.Model,
                Addin         = addin
            };


            if (Model.Configuration.Snippets == null || Model.Configuration.Snippets.Count < 1)
            {
                AddFirstTimeSnippets();
            }
            else
            {
                Model.Configuration.Snippets =
                    new ObservableCollection <Snippet>(Model.Configuration.Snippets.OrderBy(snip => snip.Name));
                if (Model.Configuration.Snippets.Count > 0)
                {
                    Model.ActiveSnippet = Model.Configuration.Snippets[0];
                }
            }

            Loaded   += SnippetsWindow_Loaded;
            Unloaded += SnippetsWindow_Unloaded;

            WebBrowserSnippet.Visibility = Visibility.Hidden;

            DataContext = Model;
        }