예제 #1
0
        private void Init()
        {
            SelectedSnippet = AllSnippets.FirstOrDefault();

            AllSnippetsView        = CollectionViewSource.GetDefaultView(AllSnippets);
            AllSnippetsView.Filter = AllSnippetsView_Filter;
            AllSnippetsView.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
            AllSnippetsView.GroupDescriptions.Add(new PropertyGroupDescription("Language"));
        }
예제 #2
0
 private void DeleteSnippet() //nur verfügbar, wenn SelectedSnippet != null ist
 {
     if (MessageBox.Show("Wollen sie den Snippet Eintrag wirklich löschen?", "Warnung", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
     {
         AllSnippets.Remove(AllSnippets.FirstOrDefault(x => x.ID == SelectedSnippet.ID));
         DataContext.Instance.Snippets = new List <Snippet>();
         AllSnippets.ToList().ForEach(x => DataContext.Instance.Snippets.Add(x.Snippet_Model));
         SelectedSnippet = AllSnippets.FirstOrDefault();
     }
 }
 public ReadComponents(IReadOnlyList <Component> components, string directory, IReadOnlyList <Snippet> shared)
 {
     Guard.AgainstNull(components, nameof(components));
     Guard.AgainstNullAndEmpty(directory, nameof(directory));
     Guard.AgainstNull(shared, nameof(shared));
     Shared          = shared;
     Components      = components;
     Directory       = directory;
     AllSnippets     = Components.SelectMany(_ => _.Snippets).Concat(shared).Distinct().ToList();
     SnippetsInError = AllSnippets.Where(_ => _.IsInError).Distinct().ToList();
     Lookup          = AllSnippets.ToDictionary();
 }
예제 #4
0
        public MainWorkspaceViewModel()
        {
            if (IsInDesignMode)
            {
                List <Language> Languages = new List <Language>();
                List <Snippet>  Snippets  = new List <Snippet>();

                //Languages
                Guid gl_01 = Guid.NewGuid(); Language l_01 = new Language(); l_01.ID = gl_01; l_01.Name = "VB"; Languages.Add(l_01);
                Guid gl_02 = Guid.NewGuid(); Language l_02 = new Language(); l_02.ID = gl_02; l_02.Name = "C#"; Languages.Add(l_02);


                //SnippetEnitries

                Guid gse_01 = Guid.NewGuid(); SnippetEnitry se_01 = new SnippetEnitry(); se_01.Name = "MainWindow.cs"; se_01.SnippetText = "private Tag s = new Tag();"; se_01.LanguageID = gl_02;
                Guid gse_05 = Guid.NewGuid(); SnippetEnitry se_05 = new SnippetEnitry(); se_05.Name = "Program.cs"; se_05.SnippetText = "for (int i = 0; i < 10; i++)\n{\n\n}"; se_05.LanguageID = gl_02;
                Guid gse_02 = Guid.NewGuid(); SnippetEnitry se_02 = new SnippetEnitry(); se_02.Name = "OverviewViewModel.vb"; se_02.SnippetText = "CollectionView.Filter = AdressOf Filter;"; se_02.LanguageID = gl_01;
                Guid gse_03 = Guid.NewGuid(); SnippetEnitry se_03 = new SnippetEnitry(); se_03.Name = "SnippetViewModel.cs"; se_03.SnippetText = "RaisePropertyChanged();"; se_03.LanguageID = gl_02;
                Guid gse_04 = Guid.NewGuid(); SnippetEnitry se_04 = new SnippetEnitry(); se_04.Name = "Calculator.vb"; se_04.SnippetText = "Dim i As Integer /ni += 1"; se_04.LanguageID = gl_01;


                //Snippets
                Guid gs_01 = Guid.NewGuid(); Snippet s_01 = new Snippet(); s_01.CreatedAt = DateTime.Parse("23.05.2014"); s_01.CreatedBy = "flori2212"; s_01.LanguageID = gl_02; s_01.ID = gs_01; s_01.Name = "ViewModel mit Daten füllen"; s_01.SnippetEnitries.Add(se_02); s_01.SnippetEnitries.Add(se_03); s_01.Tags = "Csharp, VisualBasi´c, Codebehind";
                Guid gs_02 = Guid.NewGuid(); Snippet s_02 = new Snippet(); s_02.CreatedAt = DateTime.Parse("02.12.2016"); s_02.CreatedBy = "Nofear23M"; s_02.LanguageID = gl_01; s_02.ID = gs_02; s_02.Name = "Rechner programmieren"; s_02.SnippetEnitries.Add(se_04); s_02.Tags = "Codebehind, ViewModel";
                Guid gs_03 = Guid.NewGuid(); Snippet s_03 = new Snippet(); s_03.CreatedAt = DateTime.Parse("12.01.2017"); s_03.CreatedBy = "Asusdk"; s_03.LanguageID = gl_02; s_03.ID = gs_03; s_03.Name = "Schleifen und anderes"; s_03.SnippetEnitries.Add(se_05); s_03.SnippetEnitries.Add(se_01); s_03.Tags = "ViewModel";
                Guid gs_04 = Guid.NewGuid(); Snippet s_04 = new Snippet(); s_04.CreatedAt = DateTime.Parse("30.08.2019"); s_04.CreatedBy = "MichaHo"; s_04.LanguageID = gl_01; s_04.ID = gs_04; s_04.Name = "Allgemeine Kenntnisse"; s_04.SnippetEnitries.Add(se_04); s_04.SnippetEnitries.Add(se_02); s_04.SnippetEnitries.Add(se_01); s_04.Tags = "Codebehind, ViewModel, XAML";
                Snippets.Add(s_01); Snippets.Add(s_02); Snippets.Add(s_03); Snippets.Add(s_04);
                List <LanguageViewModel> languageVM = new List <LanguageViewModel>(); Languages.ForEach(x => languageVM.Add(new LanguageViewModel(x)));


                Snippets.ForEach(x => AllSnippets.Add(new SnippetViewModel(x, languageVM)));
                IsFileOpen   = true;
                OpenFileName = "sdfsfs";
            }
            else
            {
                AllSnippets = new ObservableCollection <SnippetViewModel>();
            }


            Init();
        }