Beispiel #1
0
 private void saveAllToolStripMenuItem_Click(object sender, EventArgs e)
 {
     foreach (var item in MainForm.MainDockPanel.Contents)
     {
         ControlConfigUI control = item as ControlConfigUI;
         control?.SaveWorkspace();
     }
 }
Beispiel #2
0
        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ControlConfigUI control = MainForm.MainDockPanel.ActiveContent as ControlConfigUI;

            if (control == null)
            {
                control = MainForm.MainDockPanel.ActiveDocument as ControlConfigUI;
            }
            SaveAs(control);
        }
Beispiel #3
0
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ControlConfigUI control = MainForm.MainDockPanel.ActiveContent as ControlConfigUI;

            if (control == null)
            {
                return;
            }
            if (control.GetWorkspaceFilename() == control.GetDefaultWorkspaceFilename())
            {
                SaveAs(control);
            }
            else
            {
                control.SaveWorkspace();
            }
        }
Beispiel #4
0
        private void SaveAs(ControlConfigUI control)
        {
            EnterValueDialog dialog = new EnterValueDialog
            {
                Label = "Enter filename :"
            };

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                string defaultFilename = control.GetDefaultWorkspaceFilename();
                string newFilename     = Path.Combine(Path.GetDirectoryName(defaultFilename),
                                                      $"{Path.GetFileNameWithoutExtension(defaultFilename)}{dialog.GetEnteredValue()}{Path.GetExtension(defaultFilename)}");

                control.Text = Path.GetFileNameWithoutExtension(newFilename);
                control.Tag  = newFilename;

                control.SetWorkspaceFilename(newFilename);
                control.SaveWorkspace();
                FileSysTree.BuildTreeView();
            }
        }
Beispiel #5
0
        private void tvFileSystem_DoubleClick(object sender, EventArgs e)
        {
            FileInfo file = SelectedFile;

            if (file != null)
            {
                ControlConfigUI content = null;
                foreach (var item in MainForm.MainDockPanel.Contents)
                {
                    if (((DockContent)item).Tag?.ToString() == file.FullName)
                    {
                        content = ((ControlConfigUI)item);
                        break;
                    }
                }
                if (content == null)
                {
                    foreach (var item in ProgramUI.GetConfigs())
                    {
                        Type           serviceType   = Type.GetType(item.ToString());
                        IConfigService configService = Activator.CreateInstance(serviceType) as IConfigService;
                        if (Path.GetFileNameWithoutExtension(file.Name).IndexOf(configService.GetConfigPrefixFilename()) >= 0)
                        {
                            Type formType = Type.GetType(configService.GetFormFullName());
                            content = Activator.CreateInstance(formType) as ControlConfigUI;
                            break;
                        }
                    }
                }
                if (content != null)
                {
                    content.CreateWS(file);
                    content.Tag  = file.FullName;
                    content.Text = file.Name;
                    content.Show(MainForm.MainDockPanel, WeifenLuo.WinFormsUI.Docking.DockState.Document);
                }
            }
        }