private async void btnSaveStockpile_Click(object sender, EventArgs e) { Stockpile sks = new Stockpile(dgvStockpile); var ghForm = UI_CanvasForm.GetExtraForm("Glitch Harvester"); try { UICore.SetHotkeyTimer(false); //We do this here and invoke because our unlock runs at the end of the awaited method, but there's a chance an error occurs //Thus, we want this to happen within the try block SyncObjectSingleton.FormExecute(() => { UICore.LockInterface(false, true); S.GET <UI_SaveProgress_Form>().Dock = DockStyle.Fill; ghForm?.OpenSubForm(S.GET <UI_SaveProgress_Form>()); }); await Task.Run(() => { saveStockpile(sks, StockpileManager_UISide.CurrentStockpile.Filename); }); } finally { SyncObjectSingleton.FormExecute(() => { ghForm?.CloseSubForm(); UICore.UnlockInterface(); UICore.SetHotkeyTimer(true); }); } }
public UI_CoreForm() { InitializeComponent(); thisForm = this; this.FormClosing += UI_CoreForm_FormClosing; cfForm = new UI_CanvasForm { TopLevel = false, Dock = DockStyle.Fill, }; this.Controls.Add(cfForm); cfForm.Location = new Point(0, pnSideBar.Size.Height); cfForm.Show(); cfForm.BringToFront(); //For Horizontal tab-style menu in coreform //xPadding = (Width - cfForm.Width); //coreYPadding = pnTopBar.Height; //yPadding = (Height - cfForm.Height) - coreYPadding; //For Vertical tab-style menu in coreform yPadding = (Height - cfForm.Height); corePadding = pnSideBar.Width; xPadding = (Width - cfForm.Width) - corePadding; //UICore.SetRTCColor(UICore.GeneralColor); }
public static void loadTileForm(UI_CanvasForm targetForm, CanvasGrid canvasGrid) { targetForm.ResizeCanvas(targetForm, canvasGrid); for (int x = 0; x < canvasGrid.x; x++) { for (int y = 0; y < canvasGrid.y; y++) { if (canvasGrid.gridComponent[x, y] != null) { targetForm.Text = canvasGrid.GridName; bool DisplayHeader = (canvasGrid.gridComponentDisplayHeader[x, y].HasValue ? canvasGrid.gridComponentDisplayHeader[x, y].Value : false); var size = canvasGrid.gridComponentSize[x, y]; UI_ComponentFormTile tileForm = getTileForm(canvasGrid.gridComponent[x, y], size?.Width, size?.Height, DisplayHeader); tileForm.TopLevel = false; targetForm.Controls.Add(tileForm); tileForm.Location = getTileLocation(x, y); tileForm.Show(); } } } targetForm.MinimumSize = targetForm.Size; }
public async void btnSaveStockpileAs_Click(object sender, EventArgs e) { if (dgvStockpile.Rows.Count == 0) { MessageBox.Show("You cannot save the Stockpile because it is empty"); return; } var ghForm = UI_CanvasForm.GetExtraForm("Glitch Harvester"); try { UICore.SetHotkeyTimer(false); string path = ""; SaveFileDialog saveFileDialog1 = new SaveFileDialog { DefaultExt = "sks", Title = "Save Stockpile File", Filter = "SKS files|*.sks", RestoreDirectory = true }; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { path = saveFileDialog1.FileName; } else { return; } Stockpile sks = new Stockpile(dgvStockpile); //We do this here and invoke because our unlock runs at the end of the awaited method, but there's a chance an error occurs //Thus, we want this to happen within the try block SyncObjectSingleton.FormExecute(() => { UICore.LockInterface(false, true); S.GET <UI_SaveProgress_Form>().Dock = DockStyle.Fill; ghForm?.OpenSubForm(S.GET <UI_SaveProgress_Form>()); }); await Task.Run(() => { saveStockpile(sks, path); }); } finally { SyncObjectSingleton.FormExecute(() => { ghForm?.CloseSubForm(); UICore.UnlockInterface(); UICore.SetHotkeyTimer(true); }); } }
public UI_CanvasForm(bool extraForm = false) { InitializeComponent(); if (!extraForm) { thisForm = this; spacerSize = pnScale.Location.X; tileSize = pnScale.Size.Width; Controls.Remove(pnScale); } }
public static void loadTileFormExtraWindow(CanvasGrid canvasGrid, string WindowHeader = "RTC Extra Form") { UI_CanvasForm extraForm = new UI_CanvasForm(true); extraForm.Controls.Clear(); extraForms.Add(extraForm); extraForm.FormBorderStyle = FormBorderStyle.FixedSingle; extraForm.MaximizeBox = false; extraForm.Text = WindowHeader; loadTileForm(extraForm, canvasGrid); extraForm.Show(); }
private async void loadSavestateList(bool import = false, string fileName = null) { if (fileName == null) { OpenFileDialog ofd = new OpenFileDialog { DefaultExt = "ssk", Title = "Open Savestate Keys File", Filter = "SSK files|*.ssk", RestoreDirectory = true }; if (ofd.ShowDialog() == DialogResult.OK) { fileName = ofd.FileName; } else { return; } } if (!File.Exists(fileName)) { MessageBox.Show("The Savestate Keys file wasn't found"); return; } var ghForm = UI_CanvasForm.GetExtraForm("Glitch Harvester"); try { //We do this here and invoke because our unlock runs at the end of the awaited method, but there's a chance an error occurs //Thus, we want this to happen within the try block SyncObjectSingleton.FormExecute(() => { UICore.LockInterface(false, true); S.GET <UI_SaveProgress_Form>().Dock = DockStyle.Fill; ghForm?.OpenSubForm(S.GET <UI_SaveProgress_Form>()); }); await Task.Run(() => { loadSSK(import, fileName); }); } finally { SyncObjectSingleton.FormExecute(() => { ghForm?.CloseSubForm(); UICore.UnlockInterface(); }); } }
private async void LoadStockpile(string filename) { if (UnsavedEdits && MessageBox.Show("You have unsaved edits in the Glitch Harvester Stockpile. \n\n Are you sure you want to load without saving?", "Unsaved edits in Stockpile", MessageBoxButtons.YesNo) == DialogResult.No) { return; } var ghForm = UI_CanvasForm.GetExtraForm("Glitch Harvester"); try { //We do this here and invoke because our unlock runs at the end of the awaited method, but there's a chance an error occurs //Thus, we want this to happen within the try block SyncObjectSingleton.FormExecute(() => { UICore.LockInterface(false, true); S.GET <UI_SaveProgress_Form>().Dock = DockStyle.Fill; ghForm?.OpenSubForm(S.GET <UI_SaveProgress_Form>()); }); await Task.Run(() => { if (Stockpile.Load(dgvStockpile, filename)) { SyncObjectSingleton.FormExecute(() => { btnSaveStockpile.Enabled = true; RefreshNoteIcons(); }); } SyncObjectSingleton.FormExecute(() => { S.GET <RTC_StockpilePlayer_Form>().dgvStockpile.Rows.Clear(); dgvStockpile.ClearSelection(); StockpileManager_UISide.StockpileChanged(); UnsavedEdits = false; }); }); } finally { SyncObjectSingleton.FormExecute(() => { ghForm?.CloseSubForm(); UICore.UnlockInterface(); }); } }
public UI_CanvasForm(bool extraForm = false) { InitializeComponent(); UICore.SetRTCColor(UICore.GeneralColor, this); if (!extraForm) { mainForm = this; spacerSize = pnScale.Location.X; tileSize = pnScale.Size.Width; Controls.Remove(pnScale); } }
public UI_ShadowPanel(UI_CanvasForm _parentForm, string _type) { InitializeComponent(); parentForm = _parentForm; UpdateBackground(); if (_type != null) { var subFormType = Type.GetType("RTCV.UI." + _type); //remove that and replace with componentform loader subForm = (Form)Activator.CreateInstance(subFormType); } UpdateSubForm(); }
//public void BlockView() => (this as IBlockable)?.BlockView(); //public void UnblockView() => (this as IBlockable)?.UnblockView(); public static void loadTileFormExtraWindow(CanvasGrid canvasGrid, string WindowHeader, bool silent = false) { UI_CanvasForm extraForm; if (allExtraForms.ContainsKey(WindowHeader)) { extraForm = allExtraForms[WindowHeader]; foreach (Control ctr in extraForm?.Controls) { if (ctr is UI_ComponentFormTile cft) { cft.ReAnchorToPanel(); } } } else { extraForm = new UI_CanvasForm(true); allExtraForms[WindowHeader] = extraForm; extraForms.Add(extraForm); } extraForm.Controls.Clear(); extraForm.Text = WindowHeader; UICore.registerFormEvents(extraForm); UICore.registerHotkeyBlacklistControls(extraForm); loadTileForm(extraForm, canvasGrid); if (canvasGrid.isResizable) { extraForm.MaximizeBox = true; extraForm.FormBorderStyle = FormBorderStyle.Sizable; } else { extraForm.MaximizeBox = false; extraForm.FormBorderStyle = FormBorderStyle.FixedSingle; } if (!silent) { extraForm.Show(); extraForm.Focus(); } }
public void Load() { //Deploys and loads all the grids in the multigrid object for (int i = 0; i < grids.Count(); i++) { if (i == 0) { UI_CanvasForm.loadTileFormMain(grids[i]); } else { UI_CanvasForm.loadTileFormExtraWindow(grids[i]); } } }
private async void btnSaveSavestateList_Click(object sender, EventArgs e) { string filename; SaveFileDialog saveFileDialog1 = new SaveFileDialog { DefaultExt = "ssk", Title = "Savestate Keys File", Filter = "SSK files|*.ssk", RestoreDirectory = true }; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { filename = saveFileDialog1.FileName; } else { return; } var ghForm = UI_CanvasForm.GetExtraForm("Glitch Harvester"); try { //We do this here and invoke because our unlock runs at the end of the awaited method, but there's a chance an error occurs //Thus, we want this to happen within the try block SyncObjectSingleton.FormExecute(() => { UICore.LockInterface(false, true); S.GET <UI_SaveProgress_Form>().Dock = DockStyle.Fill; ghForm?.OpenSubForm(S.GET <UI_SaveProgress_Form>()); }); await Task.Run(() => { saveSSK(filename); }); } finally { SyncObjectSingleton.FormExecute(() => { ghForm?.CloseSubForm(); UICore.UnlockInterface(); }); } }
private async void btnImportStockpile_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog { DefaultExt = "*", Title = "Select stockpile to import", Filter = "Any file|*.sks", RestoreDirectory = true }; if (ofd.ShowDialog() == DialogResult.OK) { var ghForm = UI_CanvasForm.GetExtraForm("Glitch Harvester"); try { UICore.SetHotkeyTimer(false); //We do this here and invoke because our unlock runs at the end of the awaited method, but there's a chance an error occurs //Thus, we want this to happen within the try block SyncObjectSingleton.FormExecute(() => { UICore.LockInterface(false, true); S.GET <UI_SaveProgress_Form>().Dock = DockStyle.Fill; ghForm?.OpenSubForm(S.GET <UI_SaveProgress_Form>()); }); await Task.Run(() => { if (Stockpile.Import(ofd.FileName, dgvStockpile)) { UnsavedEdits = true; } }); } finally { SyncObjectSingleton.FormExecute(() => { ghForm?.CloseSubForm(); UICore.UnlockInterface(); UICore.SetHotkeyTimer(true); RefreshNoteIcons(); }); } } }
public UI_ShadowPanel(UI_CanvasForm _parentForm, ISubForm reqForm) { InitializeComponent(); blockerForm = new Form { ControlBox = false, MinimizeBox = false, FormBorderStyle = System.Windows.Forms.FormBorderStyle.None, Text = "", Size = Size, BackColor = Color.DarkSlateBlue, Opacity = 0.2f }; UICore.SetRTCColor(UICore.GeneralColor, this); parentForm = _parentForm; UpdateBackground(); subForm = (Form)reqForm; UpdateSubForm(); }
public UI_CoreForm() { InitializeComponent(); thisForm = this; cfForm = new UI_CanvasForm(); cfForm.TopLevel = false; cfForm.Dock = DockStyle.Fill; this.Controls.Add(cfForm); cfForm.Location = new Point(0, pnTopBar.Size.Height); cfForm.Show(); cfForm.BringToFront(); //For Horizontal tab-style menu in coreform //xPadding = (Width - cfForm.Width); //coreYPadding = pnTopBar.Height; //yPadding = (Height - cfForm.Height) - coreYPadding; //For Vertical tab-style menu in coreform yPadding = (Height - cfForm.Height); corePadding = pnTopBar.Width; xPadding = (Width - cfForm.Width) - corePadding; }
internal void LoadToNewWindow() { UI_CanvasForm.loadTileFormExtraWindow(this); }
internal void LoadToMain() { UI_CanvasForm.loadTileFormMain(this); }
internal void LoadToNewWindow(string GridID = null, bool silent = false) { UI_CanvasForm.loadTileFormExtraWindow(this, GridID, silent); }
public void ResizeCanvas(UI_CanvasForm targetForm, CanvasGrid canvasGrid) { this.SetSize(getTilePos(canvasGrid.x), getTilePos(canvasGrid.y)); }