public void LayoutReturnsParent() { var parent = new object(); var configuration = new LayoutConfiguration<object>(parent); var layout = MockRepository.GenerateMock<ILayoutDefinition>(); Assert.That(configuration.Layout(layout), Is.EqualTo(parent)); }
public StationGenerator(Tier tier, Instance instance, LayoutConfiguration layoutConfiguration, Tile[,] tiles, Dictionary <Tuple <double, double>, Elevator> elevatorPositions, Dictionary <Elevator, List <Waypoint> > elevatorWaypoints, SemaphoreGenerator semaphoreGenerator, Func <int> obtainNextOStationActivationID, Func <int> obtainNextIStationActivationID) { this.tier = tier; this.instance = instance; this.lc = layoutConfiguration; this.tiles = tiles; this.elevatorPositions = elevatorPositions; this.elevatorWaypoints = elevatorWaypoints; this.semaphoreGenerator = semaphoreGenerator; this.obtainNextOStationActivationID = obtainNextOStationActivationID; this.obtainNextIStationActivationID = obtainNextIStationActivationID; }
static bool Prefix() { if (!ModPrefs.GetBool("MPMod", "ForceLargePlayspace")) { return(true); } var layout = new LayoutConfiguration(); layout.sizeInMeters = new Vector2(10f, 10f); GameObject.FindObjectOfType <Room>().LoadLayout(layout); return(false); }
void Awake() { if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); Read(); } else { Destroy(this); } }
/// <summary> /// Generates an instance with the given layout and configuration attached. /// </summary> /// <param name="layoutConfiguration">The layout configuration defining all the instance characteristics.</param> /// <param name="rand">A randomizer that is used during generation.</param> /// <param name="settingConfig">The configuration for the setting to emulate that will be attached for executing the simulation afterwards.</param> /// <param name="controlConfig">The configuration for the controlling mechanisms that will be attached for executing the simulation afterwards.</param> /// <param name="logAction">An optional action for logging.</param> /// <returns>The generated instance.</returns> public static Instance GenerateLayout( LayoutConfiguration layoutConfiguration, IRandomizer rand, SettingConfiguration settingConfig, ControlConfiguration controlConfig, Action <string> logAction = null) { LayoutGenerator layoutGenerator = new LayoutGenerator(layoutConfiguration, rand, settingConfig, controlConfig, logAction); Instance instance = layoutGenerator.GenerateLayout(); InitializeInstance(instance); return(instance); }
public void ApplyToRegistersLayout() { var configuration = new LayoutConfiguration<object>(new object()); var appender = MockRepository.GenerateMock<AppenderSkeleton>(); var layoutDefinition = MockRepository.GenerateMock<ILayoutDefinition>(); var layout = MockRepository.GenerateMock<ILayout>(); layoutDefinition.Stub(x => x.CreateLayout()).Return(layout); configuration.Layout(layoutDefinition); configuration.ApplyTo(appender); appender.AssertWasCalled(a => a.Layout = layout); }
void ResetToDefaults() { if (MessageService.AskQuestion("${res:ICSharpCode.SharpDevelop.Commands.ChooseLayoutCommand.ResetToDefaultsQuestion}")) { foreach (LayoutConfiguration config in LayoutConfiguration.Layouts) { string configPath = LayoutConfiguration.ConfigLayoutPath; string dataPath = LayoutConfiguration.DataLayoutPath; if (File.Exists(Path.Combine(dataPath, config.FileName)) && File.Exists(Path.Combine(configPath, config.FileName))) { try { File.Delete(Path.Combine(configPath, config.FileName)); } catch (Exception) {} } } LayoutConfiguration.ReloadDefaultLayout(); } }
void ResetToDefaults() { if (MessageService.AskQuestion("${res:ICSharpCode.SharpDevelop.Commands.ChooseLayoutCommand.ResetToDefaultsQuestion}")) { foreach (LayoutConfiguration config in LayoutConfiguration.Layouts) { string configPath = Path.Combine(PropertyService.ConfigDirectory, "layouts"); string dataPath = Path.Combine(PropertyService.DataDirectory, "resources" + Path.DirectorySeparatorChar + "layouts"); if (File.Exists(Path.Combine(dataPath, config.FileName)) && File.Exists(Path.Combine(configPath, config.FileName))) { try { File.Delete(Path.Combine(configPath, config.FileName)); } catch (Exception) {} } } LayoutConfiguration.ReloadDefaultLayout(); } }
/// <nodoc /> public SimpleFrontEndEngineAbstraction(PathTable pathTable, IFileSystem filesystem, IConfiguration configuration = null) { m_pathTable = pathTable; m_fileSystem = filesystem; m_environmentVariables.Add("BUILDXL_IS_ELEVATED", CurrentProcess.IsElevated.ToString()); m_customMountsTable = ConstructMountsTable(configuration, pathTable.StringTable); var testRoot = AbsolutePath.Create(pathTable, Path.GetDirectoryName(AssemblyHelper.GetAssemblyLocation(GetType().Assembly))); Layout = new LayoutConfiguration() { ObjectDirectory = testRoot.Combine(pathTable, "obj_test"), RedirectedDirectory = testRoot.Combine(pathTable, "redirected_test"), FrontEndDirectory = testRoot.Combine(pathTable, "frontend"), TempDirectory = testRoot.Combine(pathTable, "tmp_test"), }; }
/// <summary> /// Generates the nano default layout. /// </summary> /// <param name="rand">A randomizer that is used during generation.</param> /// <param name="settingConfig">The configuration for the setting to emulate that will be attached for executing the simulation afterwards.</param> /// <param name="controlConfig">The configuration for the controlling mechanisms that will be attached for executing the simulation afterwards.</param> /// <returns>The generated instance.</returns> public static Instance GenerateMaTiLayoutNano(IRandomizer rand, SettingConfiguration settingConfig, ControlConfiguration controlConfig) { LayoutConfiguration layoutConfiguration = GenerateMaTiLayoutConfiguration(); layoutConfiguration.BotCount = 8; layoutConfiguration.NameLayout = "MaTiNano"; layoutConfiguration.NrHorizontalAisles = 4; layoutConfiguration.NrVerticalAisles = 4; layoutConfiguration.NPickStationWest = 0; layoutConfiguration.NPickStationEast = 2; layoutConfiguration.NPickStationSouth = 0; layoutConfiguration.NPickStationNorth = 0; layoutConfiguration.NReplenishmentStationWest = 2; layoutConfiguration.NReplenishmentStationEast = 0; layoutConfiguration.NReplenishmentStationSouth = 0; layoutConfiguration.NReplenishmentStationNorth = 0; return(GenerateLayout(layoutConfiguration, rand, settingConfig, controlConfig)); }
public override void Run() { if (editingLayout) { return; } ComboBox comboBox = ((ToolBarComboBox)Owner).ComboBox; string dataPath = Path.Combine(PropertyService.DataDirectory, "resources" + Path.DirectorySeparatorChar + "layouts"); string configPath = Path.Combine(PropertyService.ConfigDirectory, "layouts"); if (!Directory.Exists(configPath)) { Directory.CreateDirectory(configPath); } if (oldItem != editIndex && oldItem != resetIndex) { WorkbenchSingleton.Workbench.WorkbenchLayout.StoreConfiguration(); } if (comboBox.SelectedIndex == editIndex) { editingLayout = true; ShowLayoutEditor(); OnOwnerChanged(EventArgs.Empty); comboBox.SelectedIndex = oldItem; editingLayout = false; } else if (comboBox.SelectedIndex == resetIndex) { ResetToDefaults(); comboBox.SelectedIndex = oldItem; } else { LayoutConfiguration config = (LayoutConfiguration)LayoutConfiguration.Layouts[comboBox.SelectedIndex]; LayoutConfiguration.CurrentLayoutName = config.Name; } oldItem = comboBox.SelectedIndex; }
public void Update(int index, LayoutConfiguration layoutConfiguration) { var layoutModel = new LayoutModel(layoutConfiguration, 0); var actionCount = layoutModel.NumberOfItems(layoutConfiguration.SectionIndexForActions); TitleLabel.TextColor = UIColor.Black; if (index == 0) { TitleLabel.Text = layoutConfiguration.FirstNameOfActionItem; ImageView.Image = UIImageExtensions.FromBundle(BundleAssets.ButtonCamera); } else if (index == 1) { TitleLabel.Text = layoutConfiguration.SecondNameOfActionItem; ImageView.Image = UIImageExtensions.FromBundle(BundleAssets.ButtonPhotoLibrary); } var isFirst = index == 0; var isLast = index == actionCount - 1; switch (layoutConfiguration.ScrollDirection) { case UICollectionViewScrollDirection.Horizontal: TopOffset.Constant = isFirst ? 10 : 5; BottomOffset.Constant = isLast ? 10 : 5; LeadingOffset.Constant = 5; TrailingOffset.Constant = 5; break; case UICollectionViewScrollDirection.Vertical: TopOffset.Constant = 5; BottomOffset.Constant = 5; LeadingOffset.Constant = isFirst ? 10 : 5; TrailingOffset.Constant = isLast ? 10 : 5; break; default: throw new ArgumentOutOfRangeException(); } }
public override void Run() { if (editingLayout) { return; } LoggingService.Debug("ChooseLayoutCommand.Run()"); var comboBox = (System.Windows.Controls.ComboBox)base.ComboBox; string dataPath = LayoutConfiguration.DataLayoutPath; string configPath = LayoutConfiguration.ConfigLayoutPath; if (!Directory.Exists(configPath)) { Directory.CreateDirectory(configPath); } if (oldItem != editIndex && oldItem != resetIndex) { WorkbenchSingleton.Workbench.WorkbenchLayout.StoreConfiguration(); } if (comboBox.SelectedIndex == editIndex) { editingLayout = true; ShowLayoutEditor(); OnOwnerChanged(EventArgs.Empty); editingLayout = false; } else if (comboBox.SelectedIndex == resetIndex) { ResetToDefaults(); } else { LayoutConfiguration config = (LayoutConfiguration)LayoutConfiguration.Layouts[comboBox.SelectedIndex]; LayoutConfiguration.CurrentLayoutName = config.Name; } oldItem = comboBox.SelectedIndex; }
public LayoutConfigurationData(string name, LayoutConfiguration configuration) { Name = name; Configuration = configuration; }
/// <summary> /// Initializes a new instance of the base <see cref="AppenderDefinition{T}"/> class. /// </summary> protected AppenderDefinition() { _layout = new LayoutConfiguration <T>((T)this); _filters = new List <FilterConfiguration <T> >(); _errorHandler = new ErrorHandlerConfiguration <T>((T)this); }
/// <summary> /// Reads an instance from a file. /// </summary> /// <param name="instancePath">The path to either the instance or a layout configuration.</param> /// <param name="settingConfigPath">The path to the file specifying the setting.</param> /// <param name="controlConfigPath">The path to the file supplying the configuration for all controlling mechanisms.</param> /// <param name="overrideVisualizationAttached">Indicates whether a visualization shall be attached.</param> /// <param name="visualizationOnly">If this is enabled most of the initialization will be skipped.</param> /// <param name="logAction">A action that will be used for logging some lines.</param> /// <returns></returns> public static Instance ReadInstance( string instancePath, string settingConfigPath, string controlConfigPath, bool overrideVisualizationAttached = false, bool visualizationOnly = false, Action <string> logAction = null) { // Test for layout / instance file XmlDocument doc = new XmlDocument(); doc.Load(instancePath); string rootName = doc.SelectSingleNode("/*").Name; bool layoutConfigurationGiven = false; if (rootName == nameof(Instance)) { layoutConfigurationGiven = false; } else if (rootName == nameof(LayoutConfiguration)) { layoutConfigurationGiven = true; } else { throw new ArgumentException("No valid instance or layout file given!"); } logAction?.Invoke(rootName + " recognized!"); // --> Read configurations SettingConfiguration settingConfig = null; ControlConfiguration controlConfig = null; LayoutConfiguration layoutConfig = null; if (!visualizationOnly) { // Read the setting configuration logAction?.Invoke("Parsing setting config ..."); using (StreamReader sr = new StreamReader(settingConfigPath)) { // Deserialize the xml-file settingConfig = (SettingConfiguration)_settingConfigSerializer.Deserialize(sr); // If it contains a path to a word-file that is not leading to a wordlist file try the default wordlist locations if (settingConfig.InventoryConfiguration.ColoredWordConfiguration != null && !File.Exists(settingConfig.InventoryConfiguration.ColoredWordConfiguration.WordFile)) { settingConfig.InventoryConfiguration.ColoredWordConfiguration.WordFile = IOHelper.FindResourceFile(settingConfig.InventoryConfiguration.ColoredWordConfiguration.WordFile, instancePath); } // If it contains a path to an order-file that is not leading to a orderlist file try the default orderlist locations if (settingConfig.InventoryConfiguration.FixedInventoryConfiguration != null && !string.IsNullOrWhiteSpace(settingConfig.InventoryConfiguration.FixedInventoryConfiguration.OrderFile) && !File.Exists(settingConfig.InventoryConfiguration.FixedInventoryConfiguration.OrderFile)) { settingConfig.InventoryConfiguration.FixedInventoryConfiguration.OrderFile = IOHelper.FindResourceFile(settingConfig.InventoryConfiguration.FixedInventoryConfiguration.OrderFile, instancePath); } // If it contains a path to an simple-item-file that is not leading to a generator config file try the default locations if (settingConfig.InventoryConfiguration.SimpleItemConfiguration != null && !string.IsNullOrWhiteSpace(settingConfig.InventoryConfiguration.SimpleItemConfiguration.GeneratorConfigFile) && !File.Exists(settingConfig.InventoryConfiguration.SimpleItemConfiguration.GeneratorConfigFile)) { settingConfig.InventoryConfiguration.SimpleItemConfiguration.GeneratorConfigFile = IOHelper.FindResourceFile(settingConfig.InventoryConfiguration.SimpleItemConfiguration.GeneratorConfigFile, instancePath); } } // Read the control configuration logAction?.Invoke("Parsing control config ..."); using (StreamReader sr = new StreamReader(controlConfigPath)) // Deserialize the xml-file controlConfig = (ControlConfiguration)_controlConfigSerializer.Deserialize(sr); } // --> Init or generate instance Instance instance = null; if (layoutConfigurationGiven) { // Read the layout configuration logAction?.Invoke("Parsing layout config ..."); using (StreamReader sr = new StreamReader(instancePath)) // Deserialize the xml-file layoutConfig = (LayoutConfiguration)_layoutConfigSerializer.Deserialize(sr); // Apply override config, if available if (settingConfig != null && settingConfig.OverrideConfig != null) { layoutConfig.ApplyOverrideConfig(settingConfig.OverrideConfig); } // Generate instance logAction?.Invoke("Generating instance..."); instance = InstanceGenerator.GenerateLayout(layoutConfig, new RandomizerSimple(0), settingConfig, controlConfig, logAction); } else { // Init the instance object instance = new Instance(); } // Check whether the config is required if (!visualizationOnly) { // Submit config first to the instance object instance.SettingConfig = settingConfig; instance.ControllerConfig = controlConfig; } else { // Add default config (none required though) instance.SettingConfig = new SettingConfiguration(); instance.SettingConfig.VisualizationOnly = true; instance.ControllerConfig = new ControlConfiguration(); } // If a visualization is already present set it to true instance.SettingConfig.VisualizationAttached = overrideVisualizationAttached; // --> Parse the instance from a file, if no layout was given but a specific instance if (!layoutConfigurationGiven) { // Read the instance logAction?.Invoke("Parsing instance ..."); using (StreamReader sr = new StreamReader(instancePath)) { // Deserialize the xml-file DTOInstance dtoInstance = (DTOInstance)_instanceSerializer.Deserialize(sr); // Submit the data to an instance object dtoInstance.Submit(instance); } } // Return it return(instance); }
/// <summary> /// Writes the layout configuration to a file. /// </summary> /// <param name="path">The file.</param> /// <param name="config">The layout configuration.</param> public static void WriteLayout(string path, LayoutConfiguration config) { // Serialize it using (TextWriter writer = new StreamWriter(path)) _layoutConfigSerializer.Serialize(writer, config); }
void ShowLayoutEditor() { using (Form frm = new Form()) { frm.Text = StringParser.Parse("${res:ICSharpCode.SharpDevelop.Commands.ChooseLayoutCommand.EditLayouts.Title}"); StringListEditor ed = new StringListEditor(); ed.Dock = DockStyle.Fill; ed.ManualOrder = false; ed.BrowseForDirectory = false; ed.TitleText = StringParser.Parse("${res:ICSharpCode.SharpDevelop.Commands.ChooseLayoutCommand.EditLayouts.Label}"); ed.AddButtonText = StringParser.Parse("${res:ICSharpCode.SharpDevelop.Commands.ChooseLayoutCommand.EditLayouts.AddLayout}"); ed.LoadList(CustomLayoutNames); FlowLayoutPanel p = new FlowLayoutPanel(); p.Dock = DockStyle.Bottom; p.FlowDirection = FlowDirection.RightToLeft; Button btn = new Button(); p.Height = btn.Height + 8; btn.DialogResult = DialogResult.Cancel; btn.Text = ResourceService.GetString("Global.CancelButtonText"); frm.CancelButton = btn; p.Controls.Add(btn); btn = new Button(); btn.DialogResult = DialogResult.OK; btn.Text = ResourceService.GetString("Global.OKButtonText"); frm.AcceptButton = btn; p.Controls.Add(btn); frm.Controls.Add(ed); frm.Controls.Add(p); frm.FormBorderStyle = FormBorderStyle.FixedDialog; frm.MaximizeBox = false; frm.MinimizeBox = false; frm.ClientSize = new System.Drawing.Size(400, 300); frm.StartPosition = FormStartPosition.CenterParent; frm.ShowInTaskbar = false; if (frm.ShowDialog(WorkbenchSingleton.MainWin32Window) == DialogResult.OK) { IList <string> oldNames = new List <string>(CustomLayoutNames); IList <string> newNames = ed.GetList(); // add newly added layouts foreach (string newLayoutName in newNames) { if (!oldNames.Contains(newLayoutName)) { oldNames.Add(newLayoutName); LayoutConfiguration.CreateCustom(newLayoutName); } } // remove deleted layouts LayoutConfiguration.Layouts.RemoveAll(delegate(LayoutConfiguration lc) { return(lc.Custom && !newNames.Contains(lc.Name)); }); LayoutConfiguration.SaveCustomLayoutConfiguration(); } } }
public ImagePickerLayout(LayoutConfiguration configuration) { Configuration = configuration; }
public void OnApplicationQuit() { instance = null; }
public static CameraCollectionViewCell GetCameraCell(this UICollectionView collectionView, LayoutConfiguration layout) { return(collectionView.CellForItem(NSIndexPath.FromItemSection(0, layout.SectionIndexForCamera)) as CameraCollectionViewCell); }
private static bool ShouldHighlightItem(int section, LayoutConfiguration layoutConfiguration) { return(layoutConfiguration.SectionIndexForCamera != section); }
public override void Invoke(Touch touch) { if (Parent?.Configuration?.Layout == null) { throw new Exception("Scroll has no parent or parent doesn't have layout."); } LayoutConfiguration layout = Parent.Configuration.Layout; int indent = layout.LayoutOffset; Limit = layout.OffsetLimit; bool vertical = layout.Direction == Direction.Up || layout.Direction == Direction.Down; bool forward = layout.Direction == Direction.Right || layout.Direction == Direction.Down; if (touch.State == TouchState.Begin) { BeginIndent = indent; } if (touch.State == TouchState.End || (Configuration.UseMoving && touch.State == TouchState.Moving)) { int newIndent; int indentDelta; if (RememberTouchPosition) { indentDelta = vertical ? touch.AbsoluteY - touch.Session.BeginTouch.AbsoluteY : touch.AbsoluteX - touch.Session.BeginTouch.AbsoluteX; newIndent = BeginIndent + (forward ? -indentDelta : indentDelta); } else { indentDelta = vertical ? touch.AbsoluteY - touch.Session.PreviousTouch.AbsoluteY : touch.AbsoluteX - touch.Session.PreviousTouch.AbsoluteX; newIndent = indent + (forward ? -indentDelta : indentDelta); } if (newIndent != indent || touch.State == TouchState.End) { VisualObject first = layout.Objects.FirstOrDefault(); VisualObject last = layout.Objects.LastOrDefault(); if (first == null) { return; } if (touch.State == TouchState.End || !AllowToPull) { if (newIndent < 0) { newIndent = 0; } else if (newIndent > Limit) { newIndent = Limit; } } if (Parent.Configuration.Layout.LayoutOffset != newIndent) { Parent.LayoutOffset(newIndent); Action <ScrollBackground, int> callback = ScrollBackgroundCallback; if (callback != null) { callback.Invoke(this, newIndent); } else { Parent.Update().Apply().Draw(); } } } } }