CadEditor.UtilsGui.askToSave C# (CSharp) Метод

askToSave() публичный статический Метод

public static askToSave ( bool &dirty, SaveFunction saveToFile, ReturnComboBoxIndexFunction returnCbLevelIndex ) : bool
dirty bool
saveToFile SaveFunction
returnCbLevelIndex ReturnComboBoxIndexFunction
Результат bool
        public static bool askToSave(ref bool dirty, SaveFunction saveToFile, ReturnComboBoxIndexFunction returnCbLevelIndex)
        {
            if (!dirty)
                return true;
            DialogResult dr = MessageBox.Show("Level was changed. Do you want to save current level?", "Save", MessageBoxButtons.YesNoCancel);
            if (dr == DialogResult.Cancel)
            {
                if (returnCbLevelIndex != null)
                    returnCbLevelIndex();
                return false;
            }
            else if (dr == DialogResult.Yes)
            {
                if (!saveToFile())
                {
                    if (returnCbLevelIndex != null)
                        returnCbLevelIndex();
                    return false;
                }
                return true;
            }
            else
            {
                dirty = false;
                return true;
            }
        }

Usage Example

Пример #1
0
        private void cbLevel_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!UtilsGui.askToSave(ref dirty, saveToFile, returnCbLevelIndex))
            {
                return;
            }
            if (cbLayoutNo.SelectedIndex == -1)
            {
                return;
            }

            curActiveLayout = cbLayoutNo.SelectedIndex;
            curWidth        = ConfigScript.getLevelWidth(curActiveLayout);
            curHeight       = ConfigScript.getLevelHeight(curActiveLayout);

            drawMode          = MapDrawMode.Screens;
            curActiveBlock    = 0;
            activeBlock.Image = screenImages.Images[0];

            updatePanelsVisibility();
            cbLayoutNo.Items.Clear();
            foreach (var lr in ConfigScript.getLevelRecs())
            {
                cbLayoutNo.Items.Add(String.Format("0x{0:X} ({1}x{2})", lr.layoutAddr, lr.width, lr.height));
            }
            UtilsGui.setCbIndexWithoutUpdateLevel(cbLayoutNo, cbLevel_SelectedIndexChanged, curActiveLayout);
            reloadLevelLayer();
        }
All Usage Examples Of CadEditor.UtilsGui::askToSave