コード例 #1
0
 static Command RemoveRecentProject(IObservable <Optional <AbsoluteFilePath> > path)
 {
     return(path.Switch(p =>
                        Command.Create(
                            isEnabled: p.HasValue,
                            action: () => { var ignore = RecentProjects.Remove(p.Value); })));
 }
コード例 #2
0
        private void InitRecentProjects()
        {
            RecentProjects.Clear();

            XmlDocument doc  = new XmlDocument();
            var         path = App.LocalRPAStudioDir + @"\Config\RecentProjects.xml";

            doc.Load(path);
            var rootNode = doc.DocumentElement;

            var maxShowCount = Convert.ToInt32(rootNode.GetAttribute("MaxShowCount"));
            var projectNodes = rootNode.SelectNodes("Project");

            foreach (XmlNode dir in projectNodes)
            {
                var filePath    = (dir as XmlElement).GetAttribute("FilePath");
                var name        = (dir as XmlElement).GetAttribute("Name");
                var description = (dir as XmlElement).GetAttribute("Description");

                var item = new RecentProjectItem();
                item.ProjectFilePath    = filePath;
                item.ProjectName        = name;
                item.ProjectDescription = description;

                RecentProjects.Add(item);

                maxShowCount--;
                if (maxShowCount == 0)
                {
                    break;
                }
            }
        }
コード例 #3
0
 private void OnLoaded(IEditor <CampaignFile> editor)
 {
     if (editor.CurrentFile != null)
     {
         RecentProjects.Update(editor.CurrentFile);
     }
 }
コード例 #4
0
        private void LoadProject(string path, bool isNew = false)
        {
            List <AsyncTask> tasks = new List <AsyncTask>();

            tasks.Add(new LoadGlobalSettingsTask());
            tasks.Add(new LoadPackageCacheTask());
            LoadProjectTask task = new LoadProjectTask(path);

            task.PassThrough       = true;
            task.PassThroughSource = "Project";
            task.PassThroughTarget = "Project";
            tasks.Add(task);

            StartStudioTask startStudioTask = new StartStudioTask();

            tasks.Add(startStudioTask);

            ProcessTasksDialog dialog = new ProcessTasksDialog(ref tasks, "Loading Interpic Studio...");

            dialog.ShowDialog();
            if (!dialog.AllTasksCanceled)
            {
                task.Project.IsNew = isNew;
                RecentProjects.AddToRecents(task.Project.Name, task.Project.Path);
                startStudioTask.Studio.Show();
                Close();
            }
        }
コード例 #5
0
            public static void SaveRecentProjects(RecentProjects recentProjects, string xmlFile)
            {
                XmlSerializer saver = new XmlSerializer(typeof(RecentProjects));

                using (StreamWriter writer = new StreamWriter(xmlFile))
                    saver.Serialize(writer, recentProjects);
            }
コード例 #6
0
 private void FinalizeRecentMenu()
 {
     try {
         string recentFiles = AppConfig.RecentProjectsConfig;
         RecentProjects.SaveRecentProjects(_recentProjects, recentFiles);
     }
     catch { }
 }
コード例 #7
0
 public void AddRecentProject(string file)
 {
     RecentProjects.Remove(file);
     RecentProjects.Add(file);
     while (RecentProjects.Count > MAX_RECENT_PROJECTS)
     {
         RecentProjects.RemoveAt(MAX_RECENT_PROJECTS);
     }
 }
コード例 #8
0
        public ProjectLoaderViewModel()
        {
            foreach (AccessListEntry accessListEntry in StorageApplicationPermissions.MostRecentlyUsedList.Entries)
            {
                RecentProjects.Add(accessListEntry);
            }

            OpenProjectWithPickerCommand = new RelayCommand(async() => await OpenProjectWithPickerAsync());
            OpenRecentProjectCommand     = new RelayCommand <string>(async token => await OpenRecentProjectAsync(token));
        }
コード例 #9
0
        public bool TerminateProjects()     // ... when ending the program
        {
            StringCollection collection = new StringCollection();

            collection.AddRange(RecentProjects.ToArray());
            Properties.Settings.Default.RecentProjects = collection;
            Properties.Settings.Default.Save();

            return(abortOperation());
        }
コード例 #10
0
ファイル: AppState.cs プロジェクト: kengao2010/scada-1
        /// <summary>
        /// Adds the recent project to the list.
        /// </summary>
        public void AddRecentProject(string path)
        {
            RecentProjects.Remove(path);
            RecentProjects.Add(path);

            while (RecentProjects.Count > RecentProjectCount)
            {
                RecentProjects.RemoveAt(0);
            }
        }
コード例 #11
0
        private void RecentFilesUpdated()
        {
            recent.Items.Clear();

            foreach (FileInfo file in RecentProjects.Get())
            {
                string projectTitle = "<Could not read campaign title>";

                try
                {
                    projectTitle = Json.Load <CampaignFile>(file).Metadata.Title;
                }
                finally
                {
                    Button button;

                    recent.Items.Add(new StackLayout()
                    {
                        Style   = "no-padding vertical",
                        Spacing = 2,

                        Items =
                        {
                            (button  = new Button()
                            {
                                Text = $"{projectTitle} ({file.Directory.FullName})"
                            })
                        },

                        ContextMenu = new ContextMenu()
                        {
                            Items =
                            {
                                new ButtonMenuItem((sender, e) => RecentProjects.Remove(file))
                                {
                                    Text  = "Remove",
                                    Image = Resources.GetIcon("CloseRed.ico")
                                },
                                new ButtonMenuItem((sender, e) => RecentProjects.Clear())
                                {
                                    Text  = "Clear all",
                                    Image = Resources.GetIcon("CloseGray.ico")
                                }
                            }
                        }
                    });

                    button.Click += (sender, e) =>
                    {
                        RecentProjects.Update(file);
                        editor.LoadFile(file);
                    };
                }
            }
        }
コード例 #12
0
ファイル: LauncherViewModel.cs プロジェクト: sibeansa/xenko
 internal void LoadRecentProjects()
 {
     lock (RecentProjects)
     {
         RecentProjects.Clear();
         foreach (var mruFile in GameStudioSettings.GetMostRecentlyUsed())
         {
             RecentProjects.Add(new RecentProjectViewModel(this, mruFile));
         }
     }
 }
コード例 #13
0
        public string AddRecentProject(string path)
        {
            AddFileToList(this.RecentProjects, path);

            if (this.RecentProjects.Count > 10)
            {
                this.RecentProjects = RecentProjects.Take(10).ToList();
            }

            return(path);
        }
コード例 #14
0
        protected override void OnShown(EventArgs e)
        {
            base.OnShown(e);

            if (AppSettings.Instance.OpenLastProject && RecentProjects.Get().Length > 0)
            {
                mainView.LoadFile(RecentProjects.Get()[0]);
            }

            //Messages.PreviewMessage();
        }
コード例 #15
0
 private void saveProject()
 {
     if (!projectLoaded)
     {
         saveProjectAs();
     }
     else
     {
         saveProject(RecentProjects.First());
     }
 }
コード例 #16
0
        protected override void OnExecuted(EventArgs e)
        {
            if (editor.Modified && Messages.UnsavedChangesDialog(Constants.DIALOG_CAPTION_CLOSE_PROJECT) == DialogResult.No)
            {
                return;
            }

            RecentProjects.Update(editor.CurrentFile);

            editor.LoadFile(null as FileInfo);
        }
コード例 #17
0
ファイル: StartupPage.cs プロジェクト: jocamar/CaravelEditor
        public StartupPage()
        {
            InitializeComponent();

            RecentProjects.WrapContents  = true;
            RecentProjects.FlowDirection = FlowDirection.LeftToRight;
            this.Resize += new EventHandler((object sender, EventArgs e) =>
            {
                RecentProjects.Size = new Size(this.Size.Width - (50 + RecentProjects.Location.X), this.Size.Height - (100 + RecentProjects.Location.Y));
                RecentProjects.PerformLayout();
            });
        }
コード例 #18
0
        private void initializeProjects()
        {
            if (Properties.Settings.Default.RecentProjects != null)
            {
                RecentProjects = Properties.Settings.Default.RecentProjects.Cast <string>().ToList();
            }

            if (RecentProjects.Count() > 0)
            {
                loadProject(RecentProjects.First());
            }
        }
コード例 #19
0
 private void addToRecentProjecctList(string filename)
 {
     RecentProjects = RecentProjects.Reverse <string>().ToList();
     try { RecentProjects.Remove(filename); } catch { }
     if (RecentProjects.Count >= 10)
     {
         RecentProjects = RecentProjects.Skip(1).ToList();
     }
     RecentProjects.Add(filename);
     RecentProjects = RecentProjects.Reverse <string>().ToList();
     RaisePropertyChanged(RecentProjects_name);
 }
コード例 #20
0
        public void AddToRecentFilesIfNew(string file)
        {
            if (!RecentProjects.Contains(file))
            {
                RecentProjects.Add(file);
            }

            const int maxFileCount = 20;

            if (RecentProjects.Count > maxFileCount)
            {
                RecentProjects.RemoveRange(0, RecentProjects.Count - maxFileCount);
            }
        }
コード例 #21
0
        private void GetRecentConfigs()
        {
            var recentFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "recent.xml");

            if (File.Exists(recentFile))
            {
                _recentConfigs.Load(recentFile);
                var nodes = _recentConfigs.GetElementsByTagName("projectfile");
                foreach (XmlElement node in nodes)
                {
                    RecentProjects.Add(new KeyValuePair <string, string>(node.Attributes["path"].Value, node.Attributes["name"].Value));
                }
            }

            ExecuteOnRecentProjectsChanged();
        }
コード例 #22
0
        public void AddRecentProject(string path)
        {
            path = path.ToLower();

            if (RecentProjects.Contains(path))
            {
                RecentProjects.Remove(path);
            }

            RecentProjects.Add(path);

            if (RecentProjects.Count > 3)
            {
                RecentProjects.RemoveAt(0);
            }
        }
コード例 #23
0
        private void InitializeApplication()
        {
            _projectDefinition = ProjectDefinition.LoadDefaultProject();
            _patternProject    = new PatternProject();
            _recentProjects    = new RecentProjects(mnuReopen, mnuReopenRecentFile_Click);
            Reload_ProjectDefinition();

            // refresh presentation
            Refresh_Form(true);

            // recent projects list
            InitializeRecentMenu();

            // Modified
            SetModified(false);
        }
コード例 #24
0
        private void LoadRecentProjects()
        {
            List <RecentProject> recentProjects = RecentProjects.GetRecentProjects();

            if (recentProjects.Count > 0)
            {
                lbsRecentProjects.ItemsSource = recentProjects;
            }
            else
            {
                btnOpenRecentProject.IsEnabled = false;
                RecentProject empty = new RecentProject();
                empty.Name = "No recent projects found";
                empty.Path = string.Empty;
                lbsRecentProjects.Items.Add(empty);
            }
        }
コード例 #25
0
        public void AddToRecentFilesIfNew(string file)
        {
            var item = RecentProjects.FirstOrDefault(candidate => candidate.AbsoluteFileName == file);

            if (item == null)
            {
                item = new RecentProjectReference();
                item.AbsoluteFileName = file;
                RecentProjects.Add(item);
            }

            item.LastTimeOpened = DateTime.Now;

            const int maxFileCount = 20;

            RecentProjects = RecentProjects.OrderByDescending(contained => contained.LastTimeOpened).Take(maxFileCount).ToList();
        }
コード例 #26
0
        private void LoadRecentProjects(XmlElement recentFiles)
        {
            try
            {
                int     iChild, iRecentProject;
                string  path, pathLower;
                XmlNode file;
                int     numChildNodes = recentFiles.ChildNodes.Count;

                if (numChildNodes == 0)
                {
                    return;
                }

                //清空ArrayList中之前所有的文件
                RecentProjects.Clear();

                for (iChild = 0; iChild < numChildNodes; iChild++)
                {
                    file = recentFiles.ChildNodes[iChild];
                    path = Path.GetFullPath(file.InnerText); //获取绝对路径

                    //消除重复的条目
                    pathLower      = path.ToLower();
                    iRecentProject = 0;
                    while (iRecentProject < RecentProjects.Count && RecentProjects[iRecentProject].ToString().ToLower() != pathLower)
                    {
                        iRecentProject++;
                    }
                    //添加没有被删除的近期项目完整路径
                    if (iRecentProject == RecentProjects.Count && File.Exists(path))
                    {
                        RecentProjects.Add(path);
                    }
                }

                Program.frmMain.BuildRecentProjectsMenu();
            }
            catch (Exception ex)
            {
                m_ErrorMsg    += "在LoadRecentProjects方法中出现错误:" + ex.ToString();
                m_ErrorOccured = true;
                return;
            }
        }
コード例 #27
0
ファイル: AppData.cs プロジェクト: sndcode/C--MegaMan-Engine
        public void AddRecentProject(ProjectDocument project)
        {
            var path     = project.Project.GameFile.Absolute;
            var existing = RecentProjects.FirstOrDefault(p => p.AbsolutePath == path);

            if (existing != null)
            {
                RecentProjects.Remove(existing);
                RecentProjects.Insert(0, existing);
            }
            else
            {
                RecentProjects.Insert(0, new RecentProject()
                {
                    Name = project.Name, AbsolutePath = path
                });
            }
        }
コード例 #28
0
 private void InitializeRecentMenu()
 {
     try {
         string recentFiles = AppConfig.RecentProjectsConfig;
         if (File.Exists(recentFiles))
         {
             _recentProjects = RecentProjects.LoadRecentProjects(recentFiles);
         }
         else
         {
             _recentProjects = new RecentProjects(mnuReopen, mnuReopenRecentFile_Click);
         }
         _recentProjects.RootManuItem       = mnuReopen;
         _recentProjects.ReopenClickHandler = mnuReopenRecentFile_Click;
         _recentProjects.Rebuild();
     }
     catch { }
 }
コード例 #29
0
 private void btnOpenRecentProject_Click(object sender, RoutedEventArgs e)
 {
     if (lbsRecentProjects.SelectedItem != null)
     {
         RecentProject recentProject = (RecentProject)lbsRecentProjects.SelectedItem;
         if (File.Exists(recentProject.Path))
         {
             LoadProject(recentProject.Path);
         }
         else
         {
             List <RecentProject> projects = RecentProjects.GetRecentProjects();
             projects.Remove(recentProject);
             RecentProjects.WriteRecentProjects(projects);
             ErrorAlert.Show("Project doesn't exist");
             LoadRecentProjects();
         }
     }
 }
コード例 #30
0
ファイル: AppState.cs プロジェクト: kengao2010/scada-1
        /// <summary>
        /// Loads the state from the specified file.
        /// </summary>
        public bool Load(string fileName, out string errMsg)
        {
            try
            {
                SetToDefault();

                if (File.Exists(fileName))
                {
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.Load(fileName);
                    XmlElement rootElem = xmlDoc.DocumentElement;

                    if (rootElem.SelectSingleNode("MainFormState") is XmlNode mainFormStateNode)
                    {
                        MainFormState.LoadFromXml(mainFormStateNode);
                    }

                    ProjectDir = rootElem.GetChildAsString("ProjectDir");

                    if (rootElem.SelectSingleNode("RecentProjects") is XmlNode recentProjectsNode)
                    {
                        XmlNodeList pathNodeList = recentProjectsNode.SelectNodes("Path");
                        foreach (XmlNode pathNode in pathNodeList)
                        {
                            RecentProjects.Add(pathNode.InnerText);
                        }
                    }
                }

                errMsg = "";
                return(true);
            }
            catch (Exception ex)
            {
                errMsg = AppPhrases.LoadAppStateError + ":" + Environment.NewLine + ex.Message;
                return(false);
            }
        }