/// <summary> /// Adds an item into a context within the overall memory cache of these items. The context must be obtained from the /// memory cache instance prior to use. This operation is thread safe - all operations are concurrency locked within the /// confines of the context. /// </summary> public CacheContextAdditionResult Add(ITRexSpatialMemoryCacheContext context, ITRexMemoryCacheItem element, long invalidationVersion) { lock (_contexts) { // If the invalidation version of a sub grid derivative being added to the cache does not match the current invalidation version // then prevent it being added to the cache, and return a negative result to indicate the refusal if (invalidationVersion != context.InvalidationVersion) { _log.LogInformation($"Sub grid derivative at {element.CacheOriginX}:{element.CacheOriginY} not added to cache context due to invalidation version mismatch ({invalidationVersion} vs {context.InvalidationVersion})"); return(CacheContextAdditionResult.RejectedDueToInvlidationVersionMismatch); } if (context.MarkedForRemoval) { context.Reanimate(); } var result = context.Add(element); if (result == CacheContextAdditionResult.Added) { // Perform some house keeping to keep the cache size in bounds ItemAddedToContext(element.IndicativeSizeInBytes()); while (_currentSizeInBytes > MaxSizeInBytes && !MRUList.IsEmpty()) { MRUList.EvictOneLRUItem(); } } return(result); } }
public void DeSerialize(string path) { if (System.IO.File.Exists(path)) { this.list = MRUList.DeSerialize(path); } }
protected MRU() { this.list = new MRUList(); // load initiates new list if the path is correct LoadMRU(); this.list.ShowMaxEntries = SettingsWrapper.Instance.NumberOfRecent; }
public void itShouldPutExistingItemToFirstSlotWhenAddedAgain() { var mruList = new MRUList <string>(); mruList.AddItem("a"); mruList.AddItem("b"); mruList.AddItem("c"); mruList.AddItem("a"); Assert.AreEqual(3, mruList.Items.Count); Assert.AreEqual("a", mruList.Items[0]); Assert.AreEqual("c", mruList.Items[1]); Assert.AreEqual("b", mruList.Items[2]); mruList.AddItem("b"); Assert.AreEqual(3, mruList.Items.Count); Assert.AreEqual("b", mruList.Items[0]); Assert.AreEqual("a", mruList.Items[1]); Assert.AreEqual("c", mruList.Items[2]); mruList.AddItem("c"); Assert.AreEqual(3, mruList.Items.Count); Assert.AreEqual("c", mruList.Items[0]); Assert.AreEqual("b", mruList.Items[1]); Assert.AreEqual("a", mruList.Items[2]); }
/// <summary> /// Update MRU list when user visit a configuration or created a new configuration /// </summary> public void VisitConfig(Guid projectGuid, SnapshotDebugConfig config) { MRUList <SnapshotDebugConfig> mruList = GetMRUList(projectGuid); mruList.VisitItem(config); ConfigListChanged?.Invoke(this, new Guid[] { projectGuid }); }
public AppSettings(Form1 MainForm) { this.MainForm = MainForm; RecentlyOpenedFiles = new MRUList(); OnSaving(); }
public MRUListViewModel(ShellViewModel shell, string registryPath, int capacity) { _shell = shell; _list = new MRUList(registryPath, capacity); _items = new ObservableCollection <ActionViewModel>(); _openCommand = new DelegateCommand <int>(Open); _clearCommand = new DelegateCommand(Clear); Load(); }
/// <summary> /// Class constructor /// </summary> public Profile() { // Set default session data MainWindowPosSz = new ViewPosSizeModel(100, 100, 1000, 700); IsWorkspaceAreaOptimized = false; LastActiveFile = string.Empty; _MruList = new MRUList(); }
private MRUList <SnapshotDebugConfig> GetMRUList(Guid projectGuid) { MRUList <SnapshotDebugConfig> mruList; if (!_mruDictionary.TryGetValue(projectGuid, out mruList)) { mruList = new MRUList <SnapshotDebugConfig>(); _mruDictionary[projectGuid] = mruList; } return(mruList); }
public static void RemoveFileFromMRUList(string filePath) { StringCollection MRUList = (StringCollection)Properties.Settings.Default["MRUList"]; if (MRUList == null) { MRUList = new StringCollection(); } MRUList.Remove(filePath); //remove it if it's already there Properties.Settings.Default["MRUList"] = MRUList; Properties.Settings.Default.Save(); }
public OleWoo() { InitializeComponent(); tcTypeLibs.ImageList = imgListMisc; _mrufiles = new MRUList(@"Software\benf.org\olewoo\MRU"); var args = Environment.GetCommandLineArgs().ToList(); args.RemoveAt(0); foreach (var arg in args) { OpenFile(System.IO.Path.GetFullPath(arg)); } }
private void AddFileToMRUList(string filePath) { StringCollection MRUList = (StringCollection)Properties.Settings.Default["MRUList"]; if (MRUList == null) { MRUList = new StringCollection(); } MRUList.Remove(filePath); //remove it if it's already there MRUList.Insert(0, filePath); //add it to the top of the list Properties.Settings.Default["MRUList"] = MRUList; Properties.Settings.Default.Save(); }
private void AddFileToMRUList(string filePath) { StringCollection MRUList = (StringCollection)Properties.Settings.Default["MRUList"]; if (MRUList == null) { MRUList = new StringCollection(); } MRUList.Remove(filePath); MRUList.Insert(0, filePath); Properties.Settings.Default["MRUList"] = MRUList; Properties.Settings.Default.Save(); LoadMRUMenu(); }
private void ExecuteSaveShower(object parameter) { IMessageBoxService _msgboxcommand = new MessageBoxService(); string _exefolder = ConfigFileManager.GetLocalExePath();// Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string _filename = _msgboxcommand.SaveFileDlg("Select Shower", "Logo Files(*." + Constants._showerfilenameext + ")| *." + Constants._showerfilenameext, null, _exefolder); _msgboxcommand = null; if (!string.IsNullOrEmpty(_filename)) { SerializeShower(_filename); } MenuItems = MRUList.AddFile(MenuItems, _filename, OpenShowerFile); }
public void itShouldAddItemsByFIFO() { var mruList = new MRUList <string>(); mruList.AddItem("a"); mruList.AddItem("b"); mruList.AddItem("c"); mruList.AddItem("d"); Assert.AreEqual(4, mruList.Items.Count); Assert.AreEqual("d", mruList.Items[0]); Assert.AreEqual("c", mruList.Items[1]); Assert.AreEqual("b", mruList.Items[2]); Assert.AreEqual("a", mruList.Items[3]); }
public void itShouldLimitByMaxItemsWhenGiven() { var maxItems = 3; var mruList = new MRUList <string>(maxItems); mruList.AddItem("a"); mruList.AddItem("b"); mruList.AddItem("c"); mruList.AddItem("d"); Assert.AreEqual(maxItems, mruList.Items.Count); Assert.AreEqual("d", mruList.Items[0]); Assert.AreEqual("c", mruList.Items[1]); Assert.AreEqual("b", mruList.Items[2]); }
public SettingsManager() { LoadAppSettings(); try { LoadUserSettings(); } catch { if (MRUSubHeading == null) { MRUSubHeading = new MRUList <SubHeading>(DEFAULT_MRU_SIZE); } } }
void LoadUserSettings() { //if (!File.Exists(UserSettingsFilePath)) // return; using (FileStream fs = File.OpenRead(UserSettingsFilePath)) using (var xs = new XorStream(fs)) using (var gzs = new GZipStream(xs, CompressionMode.Decompress)) { var reader = new RawDataReader(xs, Encoding.UTF8); byte[] sign = Encoding.UTF8.GetBytes(USER_SETTINGS_SIGNATURE); for (int i = 0; i < sign.Length; ++i) { if (sign[i] != reader.ReadByte()) { throw new CorruptedFileException(UserSettingsFilePath); } } IsMaximized = reader.ReadBoolean(); int x = reader.ReadInt(); int y = reader.ReadInt(); int w = reader.ReadInt(); int h = reader.ReadInt(); FrameRectangle = new Rectangle(x, y, w, h); UseCountryCode = reader.ReadBoolean(); int mruSize = reader.ReadInt(); int mruCount = reader.ReadInt(); MRUSubHeading = new MRUList <SubHeading>(mruSize); for (int i = 0; i < mruCount; ++i) { MRUSubHeading.Add(new SubHeading(reader.ReadULong())); } AutoDetectProxy = reader.ReadBoolean(); EnableProxy = reader.ReadBoolean(); ProxyHost = reader.ReadString(); ProxyPort = reader.ReadUShort(); } }
/// <summary>Save Connection to Recent Connections list</summary> private void saveRecentConnection() { ConnectionData cd = new ConnectionData(); cd.ServerPort = Port; cd.UserName = User; cd.Workspace = Workspace; MRUList _recentConnections = (MRUList)Preferences.LocalSettings["RecentConnections"]; if (_recentConnections == null) { _recentConnections = new MRUList(5); } _recentConnections.Add(cd); Preferences.LocalSettings["RecentConnections"] = _recentConnections; }
public ShowerVM() { StaticData.CreateNozzledata(); StaticData.CreateNozzleList(); _nozzletypes = StaticData.NozzleTypes; _nozzles = new FullyObservableCollection <NozzleControl>(); Nozzles.CollectionChanged += Nozzles_CollectionChanged; Nozzles.ItemPropertyChanged += Nozzles_ItemPropertyChanged; RecalcThermalLoad(); OpenNozzleSettings = new RelayCommand(ExecuteOpenNozzles, CanExecuteOpen); CopyToClipboardCommand = new RelayCommand(ExecuteCopyToClipboard, CanExecute); IncrSpacing = new RelayCommand(ExecuteIncrSpacing, CanExecuteResize); DecrSpacing = new RelayCommand(ExecuteDecrSpacing, CanExecuteResize); IncrNozzleToYankee = new RelayCommand(ExecuteIncrNozzleToYankee, CanExecuteResizeGroup); DecrNozzleToYankee = new RelayCommand(ExecuteDecrNozzleToYankee, CanExecuteResizeGroup); IncrNozzleRotation = new RelayCommand(ExecuteIncrNozzleRotation, CanExecuteResizeGroup); DecrNozzleRotation = new RelayCommand(ExecuteDecrNozzleRotation, CanExecuteResizeGroup); IncrNozzleAngle = new RelayCommand(ExecuteIncrNozzleAngle, CanExecuteResizeGroup); DecrNozzleAngle = new RelayCommand(ExecuteDecrNozzleAngle, CanExecuteResizeGroup); OpenDefaults = new RelayCommand(ExecuteOpenDefaults, CanExecute); OpenAbout = new RelayCommand(ExecuteOpenAbout, CanExecute); OpenDesigner = new RelayCommand(ExecuteOpenDesigner, CanExecute); SaveShower = new RelayCommand(ExecuteSaveShower, CanExecute); NewShower = new RelayCommand(ExecuteNewShower, CanExecuteNew); OpenShower = new RelayCommand(ExecuteOpenShower, CanExecute); OpenShowerFile = new RelayCommand(ExecuteOpenShowerFile, CanExecute); OpenHelp = new RelayCommand(ExecuteOpenHelp, CanExecute); MenuItems = MRUList.InitialiseMRU(OpenShowerFile); if (!(Application.Current.Resources[Constants.eulaccepted].ToString() == "true")) { ExecuteOpenAbout(null); } }
public AppState(int maxItems) { MRUConfigList = new MRUList <string>(maxItems); }
public void Serialize(string path) { MRUList.Serialize(path, this.list); }
public AppSettings() { RecentlyOpenedFiles = new MRUList(); }
//CollectionPanel collectionPanel = null; // deactivated for now, will come in a later release //InteractiveHelpPanel interactiveHelpPanel = null; // I put this into a separate function because VS messed it up too often! void InitializeMyComponent() { this.SuspendLayout(); // Creating Docking Containers dockContainer.BringToFront(); dockContainer.Parent = this; EditorManager.ApplicationLayout.DockingArea = dockContainer; // Create Engine Panel enginePanel1 = new Editor.EnginePanel(EditorManager.ApplicationLayout.DockingArea); enginePanel1.ShowDockable(); // TEMP //interactiveHelpPanel = new InteractiveHelpPanel(); //interactiveHelpPanel.ShowDockable(); // create dockable undo redo history panel undoHistoryPanel = new UndoHistoryPanel(EditorManager.ApplicationLayout.DockingArea); undoHistoryPanel.ShowDockable(); // TEMP shapeCreatorPanel = new ShapeCreatorPanel(EditorManager.ApplicationLayout.DockingArea); shapeCreatorPanel.ShowDockable(); shapeCreatorPanel.SelectedCreatorObjectChanged += new EventHandler(shapeCreatorPanel_SelectedCreatorObjectChanged); // AssetBrowserPanel assetBrowserPanel = new AssetBrowserPanel(EditorManager.ApplicationLayout.DockingArea); assetBrowserPanel.ShowDockable(); // deactivated for now, will come in a later release //collectionPanel = new CollectionPanel(EditorManager.ApplicationLayout.DockingArea); //collectionPanel.ShowDockable(); // Create Dockable Property Panel propertyPanel1 = new Editor.PropertyPanel(EditorManager.ApplicationLayout.DockingArea); propertyPanel1.ShowDockable(); // Create Dockable ShapeTree Panel shapeTreePanel = new ShapeTreePanel(EditorManager.ApplicationLayout.DockingArea); shapeTreePanel.ShowDockable(); // Create Shape Search Panel shapeSearchPanel = new ShapeSearchPanel(EditorManager.ApplicationLayout.DockingArea); shapeSearchPanel.ShowDockable(); shapeDuplicatesPanel = new FindDuplicatesPanel(EditorManager.ApplicationLayout.DockingArea); shapeDuplicatesPanel.ShowDockable(); visibilityResultPanel = new VisibilityResultPanel(EditorManager.ApplicationLayout.DockingArea); visibilityResultPanel.ShowDockable(); actionRecorderPanel = new ActionRecorderPanel(EditorManager.ApplicationLayout.DockingArea); actionRecorderPanel.ShowDockable(); // Script Panel ScriptPanel scriptPanel = new VisionScriptPanel(EditorManager.ApplicationLayout.DockingArea); scriptPanel.ShowDockable(); ScriptPanel.Instance = scriptPanel; // Component Panel ConfigureShapeComponentsPanel.PanelInstance.ShowDockable(); try { resourceViewerPanel = new ResourceViewerPanel(EditorManager.ApplicationLayout.DockingArea); resourceViewerPanel.ShowDockable(); EditorManager.EngineManager.LogWindow = resourceViewerPanel; vResourceViewer.Classes.ResourceInfo.OnSelectedResourceChanged += new EventHandler(ResourceInfo_OnSelectedResourceChanged); vResourceViewerBase80.Controls.MasterPanel.OnAutomatedResourcePreview += new EventHandler(ResourceInfo_OnAutomatedResourcePreview); resourceViewerPanel.VisibleChanged += new EventHandler(resourceViewerPanel_VisibleChanged); EditorManager.EditorConsole = resourceViewerPanel; // it implements IEditorConsole } catch (Exception ex) { EditorManager.DumpException(ex); } this.ResumeLayout(true); // set the references in the EditorManager EditorManager.GUI.MainMenu = this.mainMenu; EditorManager.GUI.MainToolBar = this.mainToolBar; EditorManager.GUI.EnginePanelToolBar = this.enginePanel1.Toolbar; // Create the MRU lists mruList_RecentProjects = new MRUList(RecentProjects); mruList_RecentProjects.MRUEvent += new MRUListEventHandler(this.Menu_File_Recent_Project_Click); mruList_RecentProjects.LoadFromRegistry(@"Software\Havok\VisionSDK\vEngineEditor\RecentProjects"); mruList_RecentScenes = new MRUList(RecentScenes); mruList_RecentScenes.MRUEvent += new MRUListEventHandler(this.Menu_File_Recent_Scene_Click); mruList_RecentScenes.LoadFromRegistry(@"Software\Havok\VisionSDK\vEngineEditor\RecentScenes"); // Check for a tablet CSharpFramework.Contexts.WintabTabletContext tablet = new CSharpFramework.Contexts.WintabTabletContext(); if (tablet.IsAvailable && tablet.IsActive) EditorManager.Tablet = tablet; else EditorManager.Tablet = new NullTabletContext(); // default lighting tool VLux.VLuxLightingTool vLuxTool = new VLux.VLuxLightingTool(); EditorManager.SupportedLightingTools.Add(vLuxTool); }
public AppState() { MRUConfigList = new MRUList <string>(7); }
private void OpenSelectedShowerFile(string _filename) { if (!string.IsNullOrEmpty(_filename) && File.Exists(_filename)) { try { Shower _shower = DeSerializeShower(_filename); if (_shower != null) { YankeeSpeed = _shower.YankeeSpeed; YankeeWidth = _shower.YankeeWidth; YankeeDiameter = _shower.YankeeDiameter; DwellDistance = _shower.DwellDistance; OperatingPressure = _shower.OperatingPressure; ShowerTemperature = _shower.ShowerTemperature; CoverageColour = _shower.CoverageColour; Nozzles.Clear(); int ctr = 0; NozzleControl nc; foreach (SerializedNozzle _sernozzle in _shower.Nozzles) { ctr++; nc = new NozzleControl { NozzleID = ctr, NozzleOrificeID = _sernozzle.NozzleOrificeID, NozzleSpacing = _sernozzle.NozzleSpacing, NozzleToYankee = _sernozzle.NozzleToYankee, SprayRotation = _sernozzle.SprayRotation, SprayAngle = _sernozzle.SprayAngle, NozzlePressure = _sernozzle.NozzlePressure, NozzleTypeName = _sernozzle.NozzleTypeName, NozzleSprayWidth = _sernozzle.NozzleSprayWidth, MaximumSprayAngle = _sernozzle.MaximumSprayAngle, NozzleFlow = _sernozzle.NozzleFlow, SprayPattern = _sernozzle.SprayPattern, NozzleTypes = NozzleTypes }; Nozzles.Add(nc); } NumberNozzles = ctr; MenuItems = MRUList.AddFile(MenuItems, _filename, OpenShowerFile); } else { //MenuItems = MRUList.RemoveFile(MenuItems, _filename); MessageBox.Show("The shower file appears to be corrupted and cannot be loaded.", "Unable to load shower file", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); } } catch { //MenuItems = MRUList.RemoveFile(MenuItems, _filename); MessageBox.Show("The shower file appears to be corrupted and cannot be loaded.", "Unable to load shower file", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); } } else { MenuItems = MRUList.RemoveFile(MenuItems, _filename); } }