/// <summary> /// SaveConnectionsCommandCF /// </summary> private void SaveConnectionsCommandCF() { MdiChild tw = GetTopMDIWindow(); if (tw == null) { _logger.Info("Nothing to save!!"); return; } string configFileName = LST.SaveFileDialog("Cmc Datein (*.cmc)|*.cmc;|Alle Dateien (*.*)|*.*\""); if (String.IsNullOrEmpty(configFileName)) { return; } RecentFileList.InsertFile(configFileName); Filepath = configFileName; _IsFileLoaded = true; _IsFileNamed = true; ((UserControlTCPMDIChild)tw.Content).SetNewConnectionName(Path.GetFileName(configFileName)); tw.Title = Path.GetFileName(configFileName); if (((UserControlTCPMDIChild)tw.Content).IsConnected) { tw.Title += " (!)"; } else { tw.Title += " ( )"; } Connection.Save(((UserControlTCPMDIChild)tw.Content).MyConnection, configFileName); _logger.Info(String.Format("Save Connection File {0}", configFileName)); }
private void OpenSolution(string solutionFilePath) { _settings.CurrentSolution = solutionFilePath; _solution = new SolutionVm(solutionFilePath, null, _settings.Config); _testsTreeView.ItemsSource = _solution.TestSuits; RecentFileList.InsertFile(solutionFilePath); }
/// <summary> /// DeleteListCommandCF /// </summary> private void DeleteListCommandCF() { foreach (var v in RecentFileList.RecentFiles) { RecentFileList.RemoveFile(v); } }
public FileController(CompositionContainer container, IMessageService messageService, IFileDialogService fileDialogService, IShellService shellService, FileService fileService) { this.container = container; this.messageService = messageService; this.fileDialogService = fileDialogService; this.shellService = shellService; this.fileService = fileService; this.documentTypes = new List<IDocumentType>(); this.newDocumentCommand = new DelegateCommand(NewDocumentCommand, CanNewDocumentCommand); this.closeDocumentCommand = new DelegateCommand(CloseDocumentCommand, CanCloseDocumentCommand); this.saveDocumentCommand = new DelegateCommand(SaveDocumentCommand, CanSaveDocumentCommand); this.saveAllDocumentCommand = new DelegateCommand(SaveAllDocumentCommand, CanSaveAllDocumentCommand); this.newSolutionCommand = new DelegateCommand(NewSolutionCommand); this.openSolutionCommand = new DelegateCommand(OpenSolutionCommand); this.closeSolutionCommand = new DelegateCommand(CloseSolutionCommand, CanCloseSolutionCommand); this.showSolutionCommand = new DelegateCommand(ShowSolutionCommand, CanShowSolutionCommand); this.fileService.NewDocumentCommand = this.newDocumentCommand; this.fileService.CloseDocumentCommand = this.closeDocumentCommand; this.fileService.SaveDocumentCommand = this.saveDocumentCommand; this.fileService.SaveAllDocumentCommand = this.saveAllDocumentCommand; this.fileService.NewSolutionCommand = this.newSolutionCommand; this.fileService.OpenSolutionCommand = this.openSolutionCommand; this.fileService.CloseSolutionCommand = this.closeSolutionCommand; this.fileService.ShowSolutionCommand = this.showSolutionCommand; this.recentSolutionList = Settings.Default.RecentSolutionList; if (this.recentSolutionList == null) { this.recentSolutionList = new RecentFileList(); } this.fileService.RecentSolutionList = recentSolutionList; AddWeakEventListener(fileService, FileServicePropertyChanged); }
public Form1() { document = new Document(); option = new Option(); view1 = new View(document,option); view1.Parent = this; view1.Dock = DockStyle.Fill; view1.Show(); fnameBar = new FnameBar(document,option); fnameBar.Parent = this; fnameBar.Dock = DockStyle.Top; fnameBar.Show(); InitializeComponent(); // Windows �t�H�[�� �f�U�C�i �T�|�[�g�ɕK�v�ł��B // MRU���X�g��lj� mru = new csdiff.RecentFileList(); mru.Install( this, miFileMRU, statusBar1 ); mru.MenuClick += new MRUEventHandler(this.OnMRUClick); // �c�[���o�[�̗L����Ԃ�X�V���邽�߂ɃA�C�h���C�x���g��n���h�� Application.Idle += new EventHandler(application_Idle); // �w���v�t�@�C���̃t���p�X�����(�A�v���P�[�V�����̂���t�H���_) helpProvider1.HelpNamespace = Path.Combine(Application.StartupPath,helpProvider1.HelpNamespace); }
/// <summary> /// LoadConnectionsCommandCF /// </summary> private void LoadConnectionsCommandCF() { double AcParentWindoHeight = ActualHeight; double AcParentWindoWidth = ActualWidth; string configFileName = LST.OpenFileDialog("Cmc Datein (*.cmc)|*.cmc;|Alle Dateien (*.*)|*.*\""); if (String.IsNullOrEmpty(configFileName)) { return; } RecentFileList.InsertFile(configFileName); Filepath = configFileName; _IsFileLoaded = true; _IsFileNamed = true; Connection newConnection = Connection.Load(configFileName); _logger.Info(String.Format("Load Connection File {0}", configFileName)); MdiChild MdiChild = new MdiChild() { Title = String.Format("{0} ( )", Path.GetFileName(configFileName)), Height = (AcParentWindoHeight - MainMenu.ActualHeight - MainToolBar.ActualHeight) * 0.6, Width = AcParentWindoWidth * 0.6, Content = new UserControlTCPMDIChild(newConnection, this) }; ((UserControlTCPMDIChild)MdiChild.Content).TheMdiChild = MdiChild; MainMdiContainer.Children.Add(MdiChild); }
public MainSettingsTab(Style settingsStyle) { Resources.Add("settingsStyle", settingsStyle); InitializeComponent(); List <CultureInfo> cultures = new List <CultureInfo>(); foreach (var cult in supportedCulture) { cultures.Add(CultureInfo.CreateSpecificCulture(cult)); } cultures.Sort((x, y) => x.DisplayName.CompareTo(y.DisplayName)); foreach (var cultureInfo in cultures) { Culture.Items.Add(cultureInfo); if (cultureInfo.TextInfo.CultureName == CultureInfo.CurrentUICulture.TextInfo.CultureName) { Culture.SelectedItem = cultureInfo; } } RecentFileListLengthBox.Text = RecentFileList.GetSingleton().ListLength.ToString(); initialized = true; }
public void AddFiles() { var recentFileList = new RecentFileList() { MaxFilesNumber = 3 }; AssertHelper.ExpectedException <ArgumentException>(() => recentFileList.AddFile(null !)); // Add files to an empty list recentFileList.AddFile("Doc3"); AssertHelper.SequenceEqual(new[] { "Doc3" }, recentFileList.RecentFiles.Select(f => f.Path)); recentFileList.AddFile("Doc2"); AssertHelper.SequenceEqual(new[] { "Doc2", "Doc3" }, recentFileList.RecentFiles.Select(f => f.Path)); recentFileList.AddFile("Doc1"); AssertHelper.SequenceEqual(new[] { "Doc1", "Doc2", "Doc3" }, recentFileList.RecentFiles.Select(f => f.Path)); // Add a file to a full list recentFileList.AddFile("Doc4"); AssertHelper.SequenceEqual(new[] { "Doc4", "Doc1", "Doc2" }, recentFileList.RecentFiles.Select(f => f.Path)); // Add a file that already exists in the list recentFileList.AddFile("Doc2"); AssertHelper.SequenceEqual(new[] { "Doc2", "Doc4", "Doc1" }, recentFileList.RecentFiles.Select(f => f.Path)); }
public void Load() { var recentFileList = new RecentFileList() { MaxFilesNumber = 3 }; recentFileList.AddFile("Doc3"); recentFileList.AddFile("Doc2"); recentFileList.AddFile("Doc1"); AssertHelper.ExpectedException <ArgumentNullException>(() => recentFileList.Load(null !)); // Load an empty recent file list recentFileList.Load(new RecentFile[] { }); Assert.IsFalse(recentFileList.RecentFiles.Any()); recentFileList.Load(new[] { new RecentFile("NewDoc1") { IsPinned = true }, new RecentFile("NewDoc2"), new RecentFile("NewDoc3"), new RecentFile("NewDoc4") }); AssertHelper.SequenceEqual(new[] { "NewDoc1", "NewDoc2", "NewDoc3" }, recentFileList.RecentFiles.Select(f => f.Path)); AssertHelper.SequenceEqual(new[] { true, false, false }, recentFileList.RecentFiles.Select(f => f.IsPinned)); }
/// <summary> /// Initializes the OpenGL viewport and other important components. /// </summary> /// <param name="ctrl">The GLControl to initialize the viewport with</param> /// <param name="host">The host of the GLControl</param> /// <param name="grid">The PropertyGrid to associate with this ViewModel</param> /// <param name="fileList">The RecentFileList to associate with this ViewModel</param> public void CreateGraphicsContext(GLControl ctrl, WindowsFormsHost host, RecentFileList fileList) { // There's a bug where some cultures (French, etc) use a ',' instead of a '.' for decimals. // For example, 3.14 in US English becomes 3,14 in French. This forces the app's culture info // to US English, and thus to use '.' as the decimal separator. CultureInfo.CurrentCulture = new CultureInfo("en-US"); Renderer = new Renderer(ctrl, host); SelectedTriangles = new TriangleSelectionViewModel(); m_renderer.SelectedTris += m_renderer_SelectedTris; m_renderer.RegroupTris += m_renderer_RegroupTris; m_renderer.RecategorizeTris += m_renderer_RecategorizeTris; m_renderer.FocusCamera += m_renderer_FocusCamera; m_undoRedoManager = new UndoRedoManager(); m_recentFileList = fileList; m_recentFileList.MenuClick += (s, e) => Open(e.Filepath); CurrentFile = ""; }
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs args) { base.OnPropertyChanged(args); if (args.Property != DataContextProperty || !(args.NewValue is MainWindowViewModel model)) { return; } _viewModel = model; _viewModel.InsertRecentFile += (o, e) => { if (e.Data != null) { RecentFileList.InsertFile(e.Data); } }; _viewModel.SetGlobalCursor += (o, e) => Mouse.OverrideCursor = e.Data; // These no longer use interactions in XAML due to the conversion needed for the command parameter PreviewDragEnter += OnPreviewDragEnter; Drop += OnDrop; }
public FileController(IMessageService messageService, IFileDialogService fileDialogService, IShellService shellService, FileService fileService, ExportFactory <SaveChangesViewModel> saveChangesViewModelFactory) { this.messageService = messageService; this.fileDialogService = fileDialogService; this.shellService = shellService; this.fileService = fileService; this.saveChangesViewModelFactory = saveChangesViewModelFactory; documentTypes = new List <IDocumentType>(); newCommand = new DelegateCommand(NewCommand); openCommand = new DelegateCommand(OpenCommand); closeCommand = new DelegateCommand(CloseCommand, CanCloseCommand); saveCommand = new DelegateCommand(SaveCommand, CanSaveCommand); saveAsCommand = new DelegateCommand(SaveAsCommand, CanSaveAsCommand); this.fileService.NewCommand = newCommand; this.fileService.OpenCommand = openCommand; this.fileService.CloseCommand = closeCommand; this.fileService.SaveCommand = saveCommand; this.fileService.SaveAsCommand = saveAsCommand; recentFileList = Settings.Default.RecentFileList; if (recentFileList == null) { recentFileList = new RecentFileList(); } this.fileService.RecentFileList = recentFileList; PropertyChangedEventManager.AddHandler(fileService, FileServicePropertyChanged, ""); }
public FileController(IMessageService messageService, ISystemService systemService, IFileDialogService fileDialogService, ISettingsService settingsService, IShellService shellService, FileService fileService, ExportFactory<SaveChangesViewModel> saveChangesViewModelFactory, IRichTextDocumentType richTextDocumentType, IXpsExportDocumentType xpsExportDocumentType) { this.messageService = messageService; this.systemService = systemService; this.fileDialogService = fileDialogService; this.shellService = shellService; this.fileService = fileService; this.saveChangesViewModelFactory = saveChangesViewModelFactory; documentTypes = new() { richTextDocumentType, xpsExportDocumentType }; newCommand = new DelegateCommand(NewCommand); openCommand = new DelegateCommand(OpenCommand); closeCommand = new DelegateCommand(CloseCommand, CanCloseCommand); saveCommand = new DelegateCommand(SaveCommand, CanSaveCommand); saveAsCommand = new DelegateCommand(SaveAsCommand, CanSaveAsCommand); settings = settingsService.Get<AppSettings>(); this.fileService.NewCommand = newCommand; this.fileService.OpenCommand = openCommand; this.fileService.CloseCommand = closeCommand; this.fileService.SaveCommand = saveCommand; this.fileService.SaveAsCommand = saveAsCommand; recentFileList = settings.RecentFileList ?? new RecentFileList(); this.fileService.RecentFileList = recentFileList; fileService.PropertyChanged += FileServicePropertyChanged; }
public void WriteXmlTest() { var recentFileList = new RecentFileList(); IXmlSerializable serializable = recentFileList; serializable.WriteXml(null); }
public void GetSchemaTest() { var recentFileList = new RecentFileList(); IXmlSerializable serializable = recentFileList; Assert.IsNull(serializable.GetSchema()); }
/// <summary> /// Controller constructor /// </summary> /// <param name="mainForm">The form to use as the main form of the application</param> public Controller(MainForm mainForm) { _files = new List <PixelariaFile>(); // Initialize the factories FrameFactory = new DefaultFrameFactory(this); // Initialize the validators and exporters DefaultValidator defValidator = new DefaultValidator(this); AnimationValidator = defValidator; AnimationSheetValidator = defValidator; DefaultImporter = new DefaultPngImporter(); // Initialize the Settings singleton Settings.GetSettings(Path.GetDirectoryName(Application.LocalUserAppDataPath) + "\\settings.ini"); CurrentRecentFileList = new RecentFileList(10); if (mainForm != null) { mainForm.Controller = this; // Initialize the basic fields _mainForm = mainForm; _mainForm.UpdateRecentFilesList(); // Start with a new empty bundle ShowNewBundle(); } }
public MainWindowVM(IWinSimple win, RecentFileList recentFileList) { _layoutFileName = Path.Combine(AppDataDirectoryPath, Assembly.GetEntryAssembly().GetName().Name + ".ColLayout"); _callingWin = win; _workspace = new LogAnalysisWorkspace(); YalvRegistry.Instance.SetActualLogAnalysisWorkspace(_workspace); _yalvLogViewModel = new YalvViewModel(); CommandCancelProcessing = YalvLogViewModel.CommandCancelProcessing; if (CreateAppDataDir()) { _yalvLogViewModel.LogEntryRows.LoadColumnsLayout(_layoutFileName); } RecentFileList = recentFileList; CommandExit = new RelayCommand <object>((p) => CommandExitExecute(p), p => true); CommandOpenFile = new RelayCommand <object>((p) => CommandOpenFileExecute(p), CommandOpenFileCanExecute); CommandExport = new RelayCommand <object>((p) => CommandExportExecute(p), p => true); CommandOpenSqliteDatabase = new RelayCommand <object>((p) => CommandOpenSqliteDatabaseExecute(p), p => true); CommandOpenLogAnalysisSession = new RelayCommand <object>((p) => CommandOpenLogAnalysisSessionExecute(p), p => true); }
public FileLogEntryController(Invoker dispatcher = null, Func<string, LogEntryParser, ILogFileWatcher<LogEntry>> createLogFileWatcher = null, IPersist persist = null) { Entries = new ObservableCollection<LogEntryViewModel>(); this.watcherFactory = createLogFileWatcher??CreateLogFileWatcher; wrappedDispatcher = dispatcher ?? new WrappedDispatcher().Invoke; Counter = new LogEntryCounter(Entries); this.recentFileList = new RecentFileList(persist?? new XmlPersister(ApplicationAttributes.Get(),9)); }
public void RecentSolutionListTest() { FileService fileService = Container.GetExportedValue<FileService>(); RecentFileList recentSolutionList = new RecentFileList(); recentSolutionList.AddFile("TestFile"); AssertHelper.PropertyChangedEvent(fileService, x => x.RecentSolutionList, () => fileService.RecentSolutionList = recentSolutionList); Assert.AreEqual(recentSolutionList, fileService.RecentSolutionList); }
public void RecentFileList() { FileService fileService = Container.GetExportedValue <FileService>(); RecentFileList recentFileList = new RecentFileList(); AssertHelper.PropertyChangedEvent(fileService, x => x.RecentFileList, () => fileService.RecentFileList = recentFileList); Assert.AreEqual(recentFileList, fileService.RecentFileList); }
public void RecentFileList() { var fileService = Container.GetExportedValue <FileService>(); var recentFileList = new RecentFileList(); fileService.RecentFileList = recentFileList; Assert.AreEqual(recentFileList, fileService.RecentFileList); }
public void RecentFileList() { var fileService = Get <FileService>(); var recentFileList = new RecentFileList(); fileService.RecentFileList = recentFileList; Assert.AreEqual(recentFileList, fileService.RecentFileList); }
public static void RemoveRecentFile(string file) { RecentFileList data = RecentFileList.Data; data.elements.RemoveAll((path) => path.Equals(file, System.StringComparison.InvariantCultureIgnoreCase)); RecentFileList.Data = data; RecentFileList.Save(); }
public void SetUp() { do { _registryKey = "Software\\" + Path.GetRandomFileName(); } while (Registry.CurrentUser.OpenSubKey(_registryKey) != null); Control = new RecentFileList(); Control.UseRegistryPersister(_registryKey); }
public void SaveSettings() { foreach (AutoFilterCollection AFC in MainBigList.Where(x => x is AutoFilterCollection)) { AFC.SaveSettings(); } RecentFileList.Save(); Properties.Settings.Default.Save(); }
public void SetUp() { do { _filePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); } while (File.Exists(_filePath)); Control = new RecentFileList(); Control.UseXmlPersister(_filePath); }
public void OpenFiles(string folderPath) { // TO-DO: Check if the folder has the appropriate data (i.e. check for the files) RecentFileList.InsertFile(folderPath); LoadAbilities(); LoadPokemonTypes(); //LoadMoves(); LoadPokemon(); }
public void LoadTest_Empty() { var recentFileList = new RecentFileList(); recentFileList.MaxFilesNumber = 3; recentFileList.AddFile("Doc3"); recentFileList.AddFile("Doc2"); recentFileList.AddFile("Doc1"); recentFileList.Load(new RecentFile[] { }); Assert.IsFalse(recentFileList.RecentFiles.Any()); }
public MainWindow() { InitializeComponent(); TLCGenSplashScreenHelper.SplashScreen = new TLCGenSplashScreenView(); TLCGenSplashScreenHelper.Show(); TLCGenSplashScreenHelper.ShowText("TLCGen wordt gestart..."); DispatcherHelper.Initialize(); MainToolBarTray.DataContextChanged += (s, e) => { if (!(e.NewValue is MainWindowViewModel vm)) { return; } foreach (var pl in vm.ApplicationParts) { if ((pl.Item1 & TLCGenPluginElems.ToolBarControl) != TLCGenPluginElems.ToolBarControl) { continue; } var tb = new ToolBar(); if (pl.Item2 is ITLCGenToolBar tlcGenToolBar) { tb.Items.Add(tlcGenToolBar.ToolBarView); } MainToolBarTray.ToolBars.Add(tb); } }; RecentFileList.MenuClick += (sender, args) => { if (DataContext == null) { return; } var mymvm = DataContext as MainWindowViewModel; mymvm?.LoadController(args.Filepath); }; var mvm = new ViewModels.MainWindowViewModel(); DataContext = mvm; mvm.FileSaved += (sender, s) => RecentFileList.InsertFile(s); mvm.FileOpened += (sender, s) => RecentFileList.InsertFile(s); mvm.FileOpenFailed += (sender, s) => RecentFileList.RemoveFile(s); mvm.CheckCommandLineArgs(); TLCGenSplashScreenHelper.Hide(); }
public void SetUp() { string path; do { path = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); } while (File.Exists(path)); this.filePath = path; this.control = new RecentFileList(); this.control.UseXmlPersister(this.filePath); }
private void RecentFileListLengthBox_TextChanged(object sender, TextChangedEventArgs e) { int l; if (int.TryParse(RecentFileListLengthBox.Text, out l)) { RecentFileList.GetSingleton().ChangeListLength(l); } else { RecentFileListLengthBox.Text = RecentFileList.GetSingleton().ListLength.ToString(); } }
void Play() { if (SelectedDB is Release) { RecentFileList.Add(SelectedDB as Release); } else if (SelectedDB is Game) { RecentFileList.Add((SelectedDB as Game).PreferredRelease); } SelectedDB.Play(); }
public void SetMaxFilesNumberTest() { var recentFileList = new RecentFileList(); recentFileList.AddFile("Doc4"); recentFileList.AddFile("Doc3"); recentFileList.AddFile("Doc2"); recentFileList.AddFile("Doc1"); Assert.IsTrue(recentFileList.RecentFiles.Select(f => f.Path).SequenceEqual(new[] { "Doc1", "Doc2", "Doc3", "Doc4" })); // Set a lower number than items are in the list => expect that the list is truncated. recentFileList.MaxFilesNumber = 3; Assert.AreEqual(3, recentFileList.MaxFilesNumber); Assert.IsTrue(recentFileList.RecentFiles.Select(f => f.Path).SequenceEqual(new[] { "Doc1", "Doc2", "Doc3" })); }
public void XmlSerializingTest_Empty() { var serializer = new XmlSerializer(typeof(RecentFileList)); using (var stream = new MemoryStream()) { var recentFileList1 = new RecentFileList(); serializer.Serialize(stream, recentFileList1); stream.Position = 0; var recentFileList2 = (RecentFileList)serializer.Deserialize(stream); Assert.AreEqual(recentFileList1.RecentFiles.Count, recentFileList2.RecentFiles.Count); Assert.IsTrue(recentFileList1.RecentFiles.Select(f => f.Path).SequenceEqual(recentFileList2.RecentFiles.Select(f => f.Path))); } }