void OpenFolderImpl(DirectoryInfo folder) { var userPrefs = new PersistedUserPreferences(); var fileNameHandler = new FileNameHandler(userPrefs); OpenFolderImpl(n => fileNameHandler.FileMatch(n, includeSmalls: false), folder, fileNameHandler, userPrefs.ShelfName); userPrefs.Save(); }
void buttonUndo_Click(object sender, EventArgs e) { if (_shelvedFiles.Count == 0) { return; } if (_shelvedFiles.Count == 1) { buttonUndo.Enabled = false; } var userPrefs = new PersistedUserPreferences(); var shelvedFile = _shelvedFiles.Pop(); var host = new ImageHost( new FileNameHandler(userPrefs), userPrefs.ShelfName, new FileInfo(shelvedFile.Item1) ) { Parent = _currentFiles }; host.ShelvePicture(); var nextNode = _currentFiles.First; while (nextNode != null && string.Compare(nextNode.Value.FileInfo.Name, host.FileInfo.Name, StringComparison.InvariantCultureIgnoreCase) < 0 ) { nextNode = nextNode.Next; } NodesTuple displayLocation; if (nextNode == null) { _currentFiles.AddLast(host); displayLocation = _currentFiles.Count == 1 ? new NodesTuple(_currentFiles.First, _currentFiles.First) : new NodesTuple(_currentFiles.Last.Previous, _currentFiles.Last); } else { var newNode = _currentFiles.AddBefore(nextNode, host); if (shelvedFile.Item2 == Side.Right && newNode.Previous != null) { displayLocation = new NodesTuple(newNode.Previous, newNode); } else { displayLocation = new NodesTuple(newNode, newNode.Next); } } _fileIndex = LoadPictures(displayLocation, 0, 0, noRelease: true); }
public FormImportPictures() { InitializeComponent(); var userprefs = new PersistedUserPreferences(); textStartFolder.Text = userprefs.FolderImportStart; textEndFolder.Text = userprefs.FolderImportEnd; textIncludeFiles.Text = userprefs.IncludeFiles; textExcludeFolders.Text = userprefs.ExcludeFolders; comboMaxPicsPerFile.Text = userprefs.MaxPicturesPerFile.ToString(); ChkConfirmOverwrite.CheckState = userprefs.ConfirmFileOverwrite ? CheckState.Checked : CheckState.Unchecked; textTemplate.Text = userprefs.NewDocumentTemplate; }
public void ImportPictures() { var userprefs = new PersistedUserPreferences(); var fw = new FolderNavigator( userprefs.FolderImportStart, userprefs.FolderImportEnd, new FileNameHandler(userprefs), new StatusBarProgressIndicator(Application) // new FormProgress() ); fw.StartingFolder += Fw_StartingFolder; fw.FoundAFile += Fw_FoundAFile; fw.EndingFolder += Fw_EndingFolder; fw.Run(); }
void CreateNewAlbumDocument(DirectoryInfo directoryInfo) { var userPrefs = new PersistedUserPreferences(); var newDocFile = new FileInfo(Path.Combine(directoryInfo.FullName, $"{directoryInfo.Name}.docx")); if (newDocFile.Exists) { newDocFile = new FileInfo(Path.Combine(directoryInfo.FullName, $"{directoryInfo.Name}.{DateTime.Now:yyyyMMdd.HHmmss}.docx")); } var newdoc = Application.Documents.Add(Template: userPrefs.NewDocumentTemplate, NewTemplate: false, DocumentType: Word.WdNewDocumentType.wdNewBlankDocument); newdoc.SaveAs(newDocFile.FullName); }
public void TestReadSaveRereadUserPreferences() { int margin; { var prefs = new PersistedUserPreferences(); margin = prefs.Margin; prefs.Margin = margin + 1; Assert.AreEqual(margin + 1, prefs.Margin, "Set Value"); prefs.Save(); } { var prefs = new PersistedUserPreferences(true); Assert.AreEqual(margin + 1, prefs.Margin, "Reread Value"); prefs.Margin = margin; prefs.Save(); } { var prefs = new PersistedUserPreferences(true); Assert.AreEqual(margin, prefs.Margin, "Reset Value"); } }
void buttonSave_Click(object sender, EventArgs e) { var userprefs = new PersistedUserPreferences { FolderImportStart = textStartFolder.Text, FolderImportEnd = textEndFolder.Text, IncludeFiles = textIncludeFiles.Text, ExcludeFolders = textExcludeFolders.Text, NewDocumentTemplate = textTemplate.Text }; int maxPics; userprefs.MaxPicturesPerFile = int.TryParse(comboMaxPicsPerFile.SelectedItem?.ToString(), NumberStyles.Integer, CultureInfo.InvariantCulture, out maxPics) ? maxPics : -1; userprefs.ConfirmFileOverwrite = ChkConfirmOverwrite.CheckState == CheckState.Checked; userprefs.Save(); Close(); }
void AlbumRibbon_Load(object sender, RibbonUIEventArgs e) { PerformLayout(); var userPrefs = new PersistedUserPreferences(); DropDownIntSetter(dropDownMargin, userPrefs.Margin); DropDownIntSetter(dropDownSpacing, userPrefs.Spacing); _arrangeButtonSet = new RibbonToggleButtonSet( EnumerateControls <RibbonToggleButton>(ctrl => ctrl.Name.IsMatch("buttonArrange"))) { Enabled = true }; _hAlignButtonSet = new RibbonToggleButtonSet(EnumerateControls <RibbonToggleButton>(ctrl => ctrl.Name.IsMatch("hAlign"))); _vAlignButtonSet = new RibbonToggleButtonSet(EnumerateControls <RibbonToggleButton>(ctrl => ctrl.Name.IsMatch("vAlign"))); _buttonsActingOnOneOrMoreShapes = new RibbonControlSet(EnumerateControls(FilterOnTag(ShapeToolRequiredCount.OneOrMore))); _buttonsActingOnTwoShapes = new RibbonControlSet(EnumerateControls(FilterOnTag(ShapeToolRequiredCount.Two))); _buttonsActingOnTwoOrMoreShapes = new RibbonControlSet(EnumerateControls(FilterOnTag(ShapeToolRequiredCount.TwoOrMore))); _buttonsActingOnThreeOrMoreShapes = new RibbonControlSet(EnumerateControls(FilterOnTag(ShapeToolRequiredCount.ThreeOrMore))); _buttonsActingOnOneOrMoreShapes.Enabled = false; _buttonsActingOnTwoShapes.Enabled = false; _buttonsActingOnTwoOrMoreShapes.Enabled = false; _buttonsActingOnThreeOrMoreShapes.Enabled = false; }
static void Main(string[] args) { var form = new FormImportPictures(); if (form.ShowDialog() != DialogResult.OK) { Console.WriteLine("User has canceled"); return; } Console.WriteLine("Processing settings..."); var userPrefs = new PersistedUserPreferences(); Func <string, string> largeFileNameMaker = s => new Regex(@"(.*\.)(small|right)\.(jpg|jpeg)$", RegexOptions.IgnoreCase).Replace(s, "$1.$3"); Func <string, string> smallFileNameMaker = s => new Regex(@"\.(jpg|jpeg)$", RegexOptions.IgnoreCase).Replace(largeFileNameMaker(s), ".small.$1"); Func <string, string> rightFileNameMaker = s => new Regex(@"\.(jpg|jpeg)$", RegexOptions.IgnoreCase).Replace(largeFileNameMaker(s), ".right.$1"); var fileNameMaker = new FileNameHandler( userPrefs.IncludeFiles, userPrefs.ExcludeFolders, @"\.small\.((jpeg)|(jpg))$", smallFileNameMaker, rightFileNameMaker, largeFileNameMaker ); var folderWalker = new FolderNavigator( userPrefs.FolderImportStart, userPrefs.FolderImportEnd, fileNameMaker, null ); folderWalker.StartingFolder += FolderWalker_StartingFolder; folderWalker.EndingFolder += FolderWalker_EndingFolder; folderWalker.FoundAFile += FolderWalker_FoundAFile; folderWalker.Run(); }
public void TestReadUserPreferences() { var prefs = new PersistedUserPreferences(); }