/// <summary> /// Saves a map as a new mini-map. /// </summary> /// <param name="mapID">The map ID to save.</param> /// <param name="folder">The name of the folder to save to.</param> public static void SaveMiniMap(MapID mapID, string folder) { var tb = ToolBar.GetToolBar(ToolBarVisibility.Map); var tbItems = tb.Items; tbItems["Map Preview"].PerformClick(); }
static void ControlSettings_Click(object sender, EventArgs e) { var tb = ToolBar.GetToolBar(ToolBarVisibility.Map); if (tb == null) { return; } MapHelper.SaveMapAs(tb.DisplayObject as EditorMap); }
/// <summary> /// Automatically saves an image of the map in it's mini-map format. /// </summary> void SaveMapPreview() { var tb = ToolBar.GetToolBar(ToolBarVisibility.Map); if (tb == null) { return; } var map = tb.DisplayObject as Map; if (map == null) { return; } var filePath = ContentPaths.Dev.Grhs.Join("MiniMap\\" + map.ID + EngineSettings.ImageFileSuffix); var mp = new MapPreviewer(); mp.CreatePreview(map, ToolManager.MapDrawingExtensions, filePath); }
void ControlSettings_Click(object sender, EventArgs e) { var tb = ToolBar.GetToolBar(ToolBarVisibility.Map); if (tb == null) { return; } var map = tb.DisplayObject as Map; if (map == null) { return; } var filePath = Path.GetFullPath(map.ID + ".png"); var mp = new MapPreviewer(); mp.CreatePreview(map, ToolManager.MapDrawingExtensions, filePath); MessageBox.Show("Saved map preview to file:" + Environment.NewLine + filePath, "Preview saved", MessageBoxButtons.OK); }
/// <summary> /// Resets all of the <see cref="Tool"/>s in this object back to the state defined by the currently loaded settings. /// <see cref="Tool"/>s in this object that have no settings specified in the loaded file will have their values /// reset to default. /// </summary> public void ResetTools() { // Remove everything from the ToolBars first foreach (var tb in ToolBar.ToolBars) { try { tb.Items.Clear(); } catch (Exception ex) { // Log but ignore when there is an error clearing for some reason const string errmsg = "Unexpected error while trying to clear ToolBar `{0}`. Exception: {1}"; if (log.IsErrorEnabled) { log.ErrorFormat(errmsg, tb, ex); } Debug.Fail(string.Format(errmsg, tb, ex)); continue; } } // Apply the settings to all the tools foreach (var tool in _tools.Values) { ApplyToolSettings(tool); } // Re-order the tools one ToolBar at a time foreach (var kvp in _toolBarOrder) { // Get the ToolBar var tb = ToolBar.GetToolBar(kvp.Key); if (tb == null) { const string errmsg = "Could not find ToolBar using ToolBarVisibility `{0}`."; if (log.IsErrorEnabled) { log.ErrorFormat(errmsg, kvp.Key); } Debug.Fail(string.Format(errmsg, kvp.Key)); continue; } // Loop through the control keys in reverse since we will be pushing everything to the head. This will result // in the tools not in our ordering list to appear at the tail. foreach (var key in kvp.Value.Reverse()) { if (StringComparer.Ordinal.Equals(_separatorClassName, key)) { // If it is a separator, then add the new separator tb.InsertSeparator(0); } else { // Find the Tool with the same key and, if found, push it to the head Tool toolForKey; if (_tools.TryGetValue(key, out toolForKey)) { if (toolForKey.ToolBarControl != null) { toolForKey.ToolBarControl.MoveToHead(); } } else { const string errmsg = "Could not find tool with key `{0}`."; if (log.IsWarnEnabled) { log.WarnFormat(errmsg, key); } Debug.Fail(string.Format(errmsg, key)); } } } } }