示例#1
0
文件: IO_Save.CS 项目: HumMod/editor
  { public static void Save()
    {
        TabData Data = TabManager.GetSelectedTabData();

        Save(Data);
        State.RefreshSaves();
    }
示例#2
0
  { public static void SaveAs()
    {
        TabData Data = TabManager.GetSelectedTabData();

        SaveFileDialog Dlg = new SaveFileDialog();

        Dlg.Title    = AppMain.AppName + " - Save As";
        Dlg.Filter   = "DESolver Files (*.DES) |*.DES| All Files (*.*) |*.*";
        Dlg.FileName = Data.Filename;

        DialogResult Result = Dlg.ShowDialog();

        if (Result != DialogResult.OK)
        {
            return;
        }

        IO_Writer.Write(Dlg.FileName, Data.Box.Text);
        TabManager.NewFilename(Data.Filename, Dlg.FileName);

        Data.Box.Modified = false;
        State.RefreshSaves();

        FileTree.This.RefreshTree();
    }
示例#3
0
文件: IO_Open.CS 项目: HumMod/editor
    public static void Open(String Filename)
    {
        String Content = IO_Reader.Read(Filename);

        TabManager.Add(Filename, Content);
        State.FilesOpen();
    }
示例#4
0
 public static void Paste()
 {
     if (TabManager.HasTabs())
     {
         RichTextBox Box = TabManager.GetBox();
         Box.Paste();
     }
 }
示例#5
0
 public static void Copy()
 {
     if (TabManager.HasTabs())
     {
         RichTextBox Box = TabManager.GetBox();
         Box.Copy();
     }
 }
示例#6
0
 public static void RefreshColorHighlighter()
 {
     if (TabManager.HasTabs())
     {
         RichTextBox Box = TabManager.GetBox();
         ColorHighlighter.Parse(Box);
     }
 }
示例#7
0
 public static void SelectAll()
 {
     if (TabManager.HasTabs())
     {
         RichTextBox Box = TabManager.GetBox();
         Box.SelectAll();
     }
 }
示例#8
0
    public PanelRight(Form ParentArg)
    {
        Parent = ParentArg;
        This   = this;

        Dock = DockStyle.Fill;

        TabManager.Attach(this);
    }
示例#9
0
    public static void PrintPreview()
    {
        DocumentName = TabManager.GetFilename();
        Content      = TabManager.GetText();

        PrintDoc.DocumentName = DocumentName;
        Print_HeaderFooter_Manager.Init();

        PreviewDlg.ShowDialog();
    }
示例#10
0
    public static void HeaderFooter()
    {
        DocumentName = TabManager.GetFilename();
        Content      = TabManager.GetText();

        PrintDoc.DocumentName = DocumentName;

        Print_HeaderFooter_Dialog Dlg = new Print_HeaderFooter_Dialog();

        Dlg.ShowDialog();
    }
示例#11
0
  { public static void Insert(String Text)
    {
        if (TabManager.HasTabs())
        {
            RichTextBox Box = TabManager.GetBox();

            /* If text is selected, it is replaced. If
             * no text is selected, new text is inserted
             * at the insertion point or caret.           */

            Box.SelectedText = Text;
        }
    }
示例#12
0
文件: State.CS 项目: HumMod/editor
 public static void RefreshSaves()
 {
     if (TabManager.SelectedDocHasChanges())
     {
         SelectedDocHasChanges();
     }
     else if (TabManager.SomeDocHasChanges())
     {
         SomeDocHasChanges();
     }
     else
     {
         NoDocHasChanges();
     }
 }
示例#13
0
文件: IO_New.CS 项目: HumMod/editor
    public static void Call()
    {
        Index++;

        String Filename = "No Name " + Index.ToString();
        String Content  = "";

        if (GeneralRegistry.GetUseTemplateFile())
        {
            Content = IO_Reader.Read(GeneralRegistry.GetTemplateFile());
        }

        TabManager.Add(Filename, Content);
        State.FilesOpen();
    }
示例#14
0
    public static void Print()
    {
        DocumentName = TabManager.GetFilename();
        Content      = TabManager.GetText();

        PrintDoc.DocumentName = DocumentName;
        Print_HeaderFooter_Manager.Init();

        DialogResult OK = PrintDlg.ShowDialog();

        if (OK == DialogResult.OK)
        {
            PrintDoc.Print();
        }
    }
示例#15
0
  { public static void CloseAll()
    {
        ArrayList Datas = TabManager.GetAllTabData();

        foreach (TabData Data in Datas)
        {
            DialogResult OK = IO_Save.SaveAskIfChanged(Data);

            if (OK == DialogResult.Cancel)
            {
                return;
            }
        }

        TabManager.RemoveAll();
        State.NoFilesOpen();
    }
示例#16
0
  { public static void SaveAll()
    {
        ArrayList Datas = TabManager.GetAllTabData();

        foreach (TabData Data in Datas)
        {
            DialogResult OK = IO_Save.Save(Data);

            if (OK == DialogResult.Cancel)
            {
                State.RefreshSaves();
                return;
            }
        }

        State.RefreshSaves();
    }
示例#17
0
文件: IO_Close.CS 项目: HumMod/editor
  { public static void Close()
    {
        TabData Data = TabManager.GetSelectedTabData();

        DialogResult OK = IO_Save.SaveAskIfChanged(Data);

        if (OK == DialogResult.Cancel)
        {
            return;
        }

        TabManager.Remove();

        if (!TabManager.HasTabs())
        {
            State.NoFilesOpen();
        }
    }
示例#18
0
    public static void PageSetup()
    {
        DocumentName = TabManager.GetFilename();
        Content      = TabManager.GetText();

        PrintDoc.DocumentName = DocumentName;

        PrintDoc.DefaultPageSettings.Margins   = Print_Registry.GetMargins();
        PrintDoc.DefaultPageSettings.Landscape = Print_Registry.GetLandscape();

        DialogResult OK = SetupDlg.ShowDialog();

        if (OK != DialogResult.OK)
        {
            return;
        }

        Print_Registry.SetMargins(PrintDoc.DefaultPageSettings.Margins);
        Print_Registry.SetLandscape(PrintDoc.DefaultPageSettings.Landscape);
    }
示例#19
0
    public static int Find(String Text, int Index, RichTextBoxFinds Flags)
    {
        if (TabManager.HasTabs())
        {
            RichTextBox Box = TabManager.GetBox();

            Index = Box.Find(Text, Index, Flags);

            if (Index != -1)
            {
                Box.SelectionStart  = Index;
                Box.SelectionLength = Text.Length;
                Box.HideSelection   = false;
            }
        }
        else
        {
            Index = -1;
        }

        return(Index);
    }
示例#20
0
文件: IO_Save.CS 项目: HumMod/editor
    private static DialogResult NoName(TabData Data)
    {
        String Msg = "";

        Msg += "Rename and save this document '";
        Msg += Data.Filename;
        Msg += "'?";

        DialogResult OK = MsgBox.YesNoCancel(Msg);

        if (OK == DialogResult.Cancel)
        {
            return(DialogResult.Cancel);
        }

        if (OK == DialogResult.Yes)
        {
            SaveFileDialog Dlg = new SaveFileDialog();

            Dlg.Title    = AppMain.AppName + " - Save As";
            Dlg.Filter   = "DESolver Files (*.DES) |*.DES| All Files (*.*) |*.*";
            Dlg.FileName = Data.Filename;

            DialogResult Result = Dlg.ShowDialog();

            if (Result != DialogResult.OK)
            {
                return(Result);
            }

            BasicSave(Data);
            TabManager.NewFilename(Data.Filename, Dlg.FileName);
            return(DialogResult.Yes);
        }

        return(DialogResult.No);
    }
示例#21
0
    protected override void OnClosing(CancelEventArgs CEA)
    {
        base.OnClosing(CEA);

        FileTree.This.Save();
        PanelLeft.Closing();

        if (TabManager.HasTabs())
        {
            IO_SaveAll.SaveAll();
        }

        if (Options_Registry.IsChecked)
        {
            RegistryManager.DeleteAccount();
            return;
        }

        if (WindowState == FormWindowState.Normal)
        {
            WindowStateManager.SetState((int)FormWindowState.Normal);

            Rectangle Rect = new Rectangle();

            Rect.Width  = Size.Width;
            Rect.Height = Size.Height;
            Rect.X      = Location.X;
            Rect.Y      = Location.Y;

            WindowLocationManager.SetLocation(Rect);
        }

        else if (WindowState == FormWindowState.Maximized)
        {
            WindowStateManager.SetState((int)FormWindowState.Maximized);
        }
    }
示例#22
0
 public static void Init()
 {
     Filename   = TabManager.GetFilename();
     TimeStamp  = DateTime.Now.ToString();
     PageNumber = 0;
 }
示例#23
0
    private static void OnPrintPage(object Obj, PrintPageEventArgs EA)
    {
        Graphics Grfx      = EA.Graphics;
        Font     PrintFont = FontManager.GetPrinting();

        Rectangle PrintArea = new Rectangle();

        PrintArea = EA.MarginBounds;

        float FontHeight = PrintFont.GetHeight(Grfx);

        Print_HeaderFooter_Manager.Refresh();

        if (Print_HeaderFooter_Manager.HasHeader())
        {
            Rectangle Rect = new Rectangle();

            Rect.X      = PrintArea.X;
            Rect.Y      = PrintArea.Y;
            Rect.Width  = PrintArea.Width;
            Rect.Height = (int)(2 * FontHeight);

            PrintArea.Y      = PrintArea.Y + Rect.Height;
            PrintArea.Height = PrintArea.Height - Rect.Height;

            StringFormat StrFmt = new StringFormat();

            StrFmt.LineAlignment = StringAlignment.Near;

            StrFmt.Alignment = StringAlignment.Near;
            Grfx.DrawString(Print_HeaderFooter_Manager.Get_TopLeft(),
                            PrintFont, Brushes.Black, Rect, StrFmt);

            StrFmt.Alignment = StringAlignment.Far;
            Grfx.DrawString(Print_HeaderFooter_Manager.Get_TopRight(),
                            PrintFont, Brushes.Black, Rect, StrFmt);
        }


        if (Print_HeaderFooter_Manager.HasFooter())
        {
            Rectangle Rect = new Rectangle();

            Rect.Height = (int)(2 * FontHeight);
            Rect.X      = PrintArea.X;
            Rect.Y      = PrintArea.Bottom - Rect.Height;
            Rect.Width  = PrintArea.Width;

            PrintArea.Height = PrintArea.Height - Rect.Height;

            StringFormat StrFmt = new StringFormat();

            StrFmt.LineAlignment = StringAlignment.Far;

            StrFmt.Alignment = StringAlignment.Near;
            Grfx.DrawString(Print_HeaderFooter_Manager.Get_BottomLeft(),
                            PrintFont, Brushes.Black, Rect, StrFmt);

            StrFmt.Alignment = StringAlignment.Far;
            Grfx.DrawString(Print_HeaderFooter_Manager.Get_BottomRight(),
                            PrintFont, Brushes.Black, Rect, StrFmt);
        }

        int TotalLines = (int)Math.Floor(PrintArea.Height / FontHeight);

        PrintArea.Height = (int)(TotalLines * FontHeight);

        StringFormat PageFmt = new StringFormat();

        PageFmt.Trimming     = StringTrimming.EllipsisCharacter;
        PageFmt.FormatFlags |= StringFormatFlags.NoWrap;

        int Chars;
        int Lines;

        Grfx.MeasureString(Content, PrintFont, PrintArea.Size,
                           PageFmt, out Chars, out Lines);

        Grfx.DrawString(Content, PrintFont, Brushes.Black,
                        PrintArea, PageFmt);

        Content = Content.Substring(Chars);

        if (Content.Length == 0)
        {
            Content = TabManager.GetText();
        }
        else
        {
            EA.HasMorePages = true;
        }
    }