示例#1
0
        public void OpenProgram(string fullpath)
        {
            var openedProgram = OpenedDocuments.FirstOrDefault(op => op.ProgramFullPath == fullpath);

            if (openedProgram != null)
            {
                DocumentOpened?.Invoke(this, new DocumentOpenEventArgs(openedProgram));
                return;
            }

            var programforOpening =
                RecentPrograms.FirstOrDefault(p => p.ProgramFullPath == fullpath);

            if (programforOpening == null)
            {
                programforOpening = ProgramViewModel.Create(fullpath, this, TvcStudioSettings);
                RecentPrograms.Add(programforOpening);
            }

            if (programforOpening.ProgramState == ProgramState.NotFound)
            {
                TraceEngine.TraceError($"{programforOpening.ProgramFullPath} beolvasása sikertelen, a file nem található!");
                return;
            }

            openedProgram = programforOpening.GetDocumentViewModel();
            openedProgram.DocumentClosedEvent += OnDocumentClose;
            OpenedDocuments.Add(openedProgram);
            programforOpening.ProgramState = ProgramState.Opened;
            DocumentOpened?.Invoke(this, new DocumentOpenEventArgs(openedProgram));
        }
示例#2
0
        public void ReadXml(XmlReader reader)
        {
            if (reader.ReadToDescendant(@"RecentPrograms"))
            {
                reader.ReadStartElement();
                while (reader.Name == @"TVCProgram")
                {
                    string fullpath       = reader.GetAttribute(@"ProgramPath");
                    string isOpenedString = reader.GetAttribute(@"ProgramIsOpened");
                    if (!string.IsNullOrEmpty(fullpath) && !string.IsNullOrEmpty(isOpenedString))
                    {
                        bool wasOpened = bool.Parse(isOpenedString);

                        if (wasOpened)
                        {
                            OpenProgram(fullpath);
                        }
                        else
                        {
                            ProgramViewModel program = ProgramViewModel.Create(fullpath, this, TvcStudioSettings);
                            RecentPrograms.Add(program);
                        }
                    }
                    reader.ReadStartElement();
                }
            }
        }