Пример #1
0
        private void mnuFileOpen_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.DefaultExt  = "lua";
            dialog.Filter      = "Lua script files (*.lua)|*.lua";
            dialog.Multiselect = true;
            if (dialog.ShowDialog().Value)
            {
                if (FreshWorkspace)
                {
                    tabMain.Items.Clear();
                }
                foreach (string fileName in dialog.FileNames)
                {
                    LuaTabPage tabPage = new LuaTabPage();
                    tabPage.FilePath = fileName;
                    tabPage.Text     = File.ReadAllText(fileName);
                    tabPage.IsSaved  = true;
                    tabMain.Items.Add(tabPage.TabItem);
                    tabPage.TabItem.IsSelected = true;
                    tabPage.TabItem.MouseUp   += tabMain_MouseUp;
                }
            }
        }
Пример #2
0
        private void FileClose(LuaTabPage tabPage)
        {
            bool close;

            if (tabPage.IsSaved || tabPage.FilePath == null && tabPage.Text == "")
            {
                close = true;
            }
            else
            {
                switch (MessageBox.Show("Do you want to save changes to " + tabPage.FileName + "?", "Confirmation", MessageBoxButton.YesNoCancel, MessageBoxImage.Question))
                {
                case MessageBoxResult.Yes:
                    close = FileSave(tabPage);
                    break;

                case MessageBoxResult.No:
                    close = true;
                    break;

                default:
                    close = false;
                    break;
                }
            }

            if (close)
            {
                tabMain.Items.Remove(tabPage.TabItem);
                if (tabMain.Items.Count == 0)
                {
                    FileNew();
                }
            }
        }
Пример #3
0
        private void EnableTimer_Tick(object sender, EventArgs e)
        {
            LuaTabPage tabPage = (tabMain.SelectedItem as TabItem).Tag as LuaTabPage;

            mnuEditUndo.IsEnabled = cmnuEditUndo.IsEnabled = btnEditUndo.IsEnabled = tabPage.TextBox.CanUndo;
            mnuEditRedo.IsEnabled = cmnuEditRedo.IsEnabled = btnEditRedo.IsEnabled = tabPage.TextBox.CanRedo;
            mnuEditCut.IsEnabled  = cmnuEditCut.IsEnabled = btnEditCut.IsEnabled = tabPage.TextBox.SelectionLength > 0;
            mnuEditCopy.IsEnabled = cmnuEditCopy.IsEnabled = btnEditCopy.IsEnabled = tabPage.TextBox.SelectionLength > 0;
            mnuViewCloseAllRenderWindows.IsEnabled = WindowRenderer.AllWindows.Count > 0;
        }
Пример #4
0
 private bool FileSave(LuaTabPage tabPage)
 {
     if (tabPage.FilePath == null)
     {
         return(FileSaveAs(tabPage));
     }
     else
     {
         tabPage.IsSaved = true;
         File.WriteAllText(tabPage.FilePath, tabPage.Text);
         return(true);
     }
 }
Пример #5
0
        private void FileNew()
        {
            int index = 1;

            while (tabMain.Items.Cast <TabItem>().Any(tabItem => (tabItem.Tag as LuaTabPage).FileName == LuaTabPage.GenerateNewFilename(index)))
            {
                index++;
            }

            LuaTabPage tabPage = new LuaTabPage();

            tabPage.FileName = LuaTabPage.GenerateNewFilename(index);
            tabMain.Items.Add(tabPage.TabItem);
            tabPage.TabItem.IsSelected = true;
            tabPage.TabItem.MouseUp   += tabMain_MouseUp;
        }
Пример #6
0
        private void mnuScriptRun_Click(object sender, RoutedEventArgs e)
        {
            mnuScriptRun.IsEnabled  = btnScriptRun.IsEnabled = false;
            mnuScriptStop.IsEnabled = btnScriptStop.IsEnabled = true;

            LuaTabPage tabPage = (tabMain.SelectedItem as TabItem).Tag as LuaTabPage;

            if (tabPage.FilePath != null)
            {
                FileSave(tabPage);
            }
            Script = new LuaScript(propMain.SelectedObject as RenderProperties, tabPage.FileName, tabPage.FilePath);
            Script.Run(tabPage.Text);

            mnuScriptRun.IsEnabled  = btnScriptRun.IsEnabled = true;
            mnuScriptStop.IsEnabled = btnScriptStop.IsEnabled = false;
        }
Пример #7
0
        private bool FileSaveAs(LuaTabPage tabPage)
        {
            SaveFileDialog dialog = new SaveFileDialog();

            dialog.DefaultExt = "lua";
            dialog.Filter     = "Lua script files (*.lua)|*.lua";
            dialog.FileName   = tabPage.FileName;
            if (dialog.ShowDialog().Value)
            {
                tabPage.FilePath = dialog.FileName;
                tabPage.IsSaved  = true;
                File.WriteAllText(tabPage.FilePath, tabPage.Text);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #8
0
        private void mnuEditSelectAll_Click(object sender, RoutedEventArgs e)
        {
            LuaTabPage tabPage = (tabMain.SelectedItem as TabItem).Tag as LuaTabPage;

            tabPage.TextBox.SelectAll();
        }