Exemplo n.º 1
0
 void EditorTabs_MouseUp(object sender, MouseButtonEventArgs e)
 {
     if (e.ChangedButton == MouseButton.Middle)
     {
         if (sender is TabItem)
         {
             IDEEditor editor = (sender as TabItem).Content as IDEEditor;
             if (editor != null)
             {
                 if (editor.IsDirty)
                 {
                     MessageBoxResult res = ModernDialog.ShowMessage("Save file changes before closing?", "Close?", MessageBoxButton.YesNoCancel);
                     if (res == MessageBoxResult.OK)
                     {
                         editor.Save();
                     }
                     else if (res == MessageBoxResult.Cancel)
                     {
                         return;
                     }
                 }
             }
             else
             {
                 //\todo should IFileEditor get a chance?
             }
             tabs.Items.Remove(sender);
         }
     }
 }
        public void onCloseTab(object sender, EventArgs e)
        {
            TabItem item = null;

            if (sender is TabItem)
            {
                item = sender as TabItem;
            }
            else
            {
                item = ((Grid)((Button)sender).Parent).Parent as TabItem;
            }
            if (item != null)
            {
                IDEEditor editor = item.Content as IDEEditor;
                if (editor != null)
                {
                    if (editor.IsDirty)
                    {
                        MessageBoxResult res = ModernDialog.ShowMessage("Save file changes before closing?", "Close?", MessageBoxButton.YesNoCancel);
                        if (res == MessageBoxResult.Yes)
                        {
                            editor.Save();
                        }
                        else if (res == MessageBoxResult.Cancel)
                        {
                            return;
                        }
                    }
                }
                else
                {
                    if (item.Content is Control && ((Control)item.Content).Tag is PluginLib.IExternalControlData)
                    {
                        PluginLib.IExternalControlData data = ((Control)item.Content).Tag as PluginLib.IExternalControlData;
                        if (data.IsDirty)
                        {
                            MessageBoxResult res = ModernDialog.ShowMessage("Save file changes before closing?", "Close?", MessageBoxButton.YesNoCancel);
                            if (res == MessageBoxResult.Yes)
                            {
                                data.SaveData();
                            }
                            else if (res == MessageBoxResult.Cancel)
                            {
                                return;
                            }
                        }
                    }
                }
                tabs.Items.Remove(item);
            }
        }
 void EditorTabs_MouseUp(object sender, MouseButtonEventArgs e)
 {
     if (e.ChangedButton == MouseButton.Middle)
     {
         if (sender is TabItem)
         {
             IDEEditor editor = (sender as TabItem).Content as IDEEditor;
             TabItem   item   = sender as TabItem;
             if (editor != null)
             {
                 if (editor.IsDirty)
                 {
                     MessageBoxResult res = ModernDialog.ShowMessage("Save file changes before closing?", "Close?", MessageBoxButton.YesNoCancel);
                     if (res == MessageBoxResult.OK)
                     {
                         editor.Save();
                     }
                     else if (res == MessageBoxResult.Cancel)
                     {
                         return;
                     }
                 }
             }
             else
             {
                 if (item.Content is Control && ((Control)item.Content).Tag is PluginLib.IExternalControlData)
                 {
                     PluginLib.IExternalControlData data = ((Control)item.Content).Tag as PluginLib.IExternalControlData;
                     if (data.IsDirty)
                     {
                         MessageBoxResult res = ModernDialog.ShowMessage("Save file changes before closing?", "Close?", MessageBoxButton.YesNoCancel);
                         if (res == MessageBoxResult.Yes)
                         {
                             data.SaveData();
                         }
                         else if (res == MessageBoxResult.Cancel)
                         {
                             return;
                         }
                     }
                 }
             }
             tabs.Items.Remove(sender);
         }
     }
 }
 public void SaveAll()
 {
     foreach (TabItem o in tabs.Items)
     {
         // Easy case
         IDEEditor editor = o.Content as IDEEditor;
         if (editor != null)
         {
             editor.Save();
         }
         else // Plugin editors
         {
             if (o.Content is Control && ((Control)o.Content).Tag is PluginLib.IExternalControlData)
             {
                 PluginLib.IExternalControlData data = ((Control)o.Content).Tag as PluginLib.IExternalControlData;
                 data.SaveData();
             }
         }
     }
 }
Exemplo n.º 5
0
        void onCloseTab(object sender, EventArgs e)
        {
            TabItem item = ((Grid)((Button)sender).Parent).Parent as TabItem;

            if (item != null)
            {
                IDEEditor editor = item.Content as IDEEditor;
                if (editor.IsDirty)
                {
                    MessageBoxResult res = ModernDialog.ShowMessage("Save file changes before closing?", "Close?", MessageBoxButton.YesNoCancel);
                    if (res == MessageBoxResult.OK)
                    {
                        editor.Save();
                    }
                    else if (res == MessageBoxResult.Cancel)
                    {
                        return;
                    }
                }
                tabs.Items.Remove(item);
            }
        }
Exemplo n.º 6
0
        void onCloseTab(object sender, EventArgs e)
        {
            TabItem item = ((Grid)((Button)sender).Parent).Parent as TabItem;

            if (item != null)
            {
                IDEEditor editor = item.Content as IDEEditor;
                if (editor != null)
                {
                    if (editor.IsDirty)
                    {
                        MessageBoxResult res = ModernDialog.ShowMessage("Save file changes before closing?", "Close?", MessageBoxButton.YesNoCancel);
                        if (res == MessageBoxResult.OK)
                        {
                            editor.Save();
                        }
                        else if (res == MessageBoxResult.Cancel)
                        {
                            return;
                        }
                    }
                }
                else
                {
                    string tagString = item.Tag.ToString(); //stored filepath in tag, above
                    foreach (PluginLib.IFileEditor fileEditor in PluginManager.inst().FileEditors)
                    {
                        if (fileEditor.CanEditFile(tagString, System.IO.Path.GetExtension(tagString)))
                        {
                            //\todo should the file editor have an opportunity to do something?
                            break;
                        }
                    }
                }
                tabs.Items.Remove(item);
            }
        }