Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/29/10 01:44:57 (15 years ago)
Author:
swagner
Message:

Adapted HL 3.3 plugins according to changes in MainForm (#857)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimizer/3.3/FileManager.cs

    r2708 r2713  
    3232    #endregion
    3333
    34     private static Dictionary<IObjectView, FileInfo> files;
     34    private static Dictionary<IContentView, FileInfo> files;
    3535    private static NewItemDialog newItemDialog;
    3636    private static OpenFileDialog openFileDialog;
     
    4040
    4141    static FileManager() {
    42       files = new Dictionary<IObjectView, FileInfo>();
     42      files = new Dictionary<IContentView, FileInfo>();
    4343      newItemDialog = null;
    4444      openFileDialog = null;
     
    5656          MessageBox.Show("There is no view for the new item. It cannot be displayed. ", "No View Available", MessageBoxButtons.OK, MessageBoxIcon.Error);
    5757        } else {
    58           if (view is IObjectView) {
     58          if (view is IContentView) {
    5959            view.Caption = "Item" + newDocumentsCounter.ToString() + ".hl";
    6060            newDocumentsCounter++;
     
    8282
    8383    public static void Save() {
    84       IObjectView activeView = MainFormManager.MainForm.ActiveView as IObjectView;
    85       if ((activeView != null) && (CreatableAttribute.IsCreatable(activeView.Object.GetType()))) {
     84      IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView;
     85      if ((activeView != null) && (CreatableAttribute.IsCreatable(activeView.Content.GetType()))) {
    8686        Save(activeView);
    8787      }
    8888    }
    89     private static void Save(IObjectView view) {
     89    private static void Save(IContentView view) {
    9090      if ((!files.ContainsKey(view)) || (!File.Exists(files[view].Filename))) {
    9191        SaveAs(view);
     
    9999
    100100    public static void SaveAs() {
    101       IObjectView activeView = MainFormManager.MainForm.ActiveView as IObjectView;
    102       if ((activeView != null) && (CreatableAttribute.IsCreatable(activeView.Object.GetType()))) {
     101      IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView;
     102      if ((activeView != null) && (CreatableAttribute.IsCreatable(activeView.Content.GetType()))) {
    103103        SaveAs(activeView);
    104104      }
    105105    }
    106     public static void SaveAs(IObjectView view) {
     106    public static void SaveAs(IContentView view) {
    107107      if (saveFileDialog == null) {
    108108        saveFileDialog = new SaveFileDialog();
     
    135135    public static void SaveAll() {
    136136      var views = from v in MainFormManager.MainForm.Views
    137                   where v is IObjectView
    138                   where CreatableAttribute.IsCreatable(((IObjectView)v).Object.GetType())
    139                   select v as IObjectView;
    140 
    141       foreach (IObjectView view in views) {
     137                  where v is IContentView
     138                  where CreatableAttribute.IsCreatable(((IContentView)v).Content.GetType())
     139                  select v as IContentView;
     140
     141      foreach (IContentView view in views) {
    142142        Save(view);
    143143      }
     
    146146    // NOTE: This event is fired by the main form. It is registered in HeuristicLabOptimizerApplication.
    147147    internal static void ViewClosed(object sender, ViewEventArgs e) {
    148       IObjectView view = e.View as IObjectView;
     148      IContentView view = e.View as IContentView;
    149149      if (view != null) files.Remove(view);
    150150    }
     
    159159    }
    160160
    161     private static void SaveItemAsync(IObjectView view, string filename, int compression) {
     161    private static void SaveItemAsync(IContentView view, string filename, int compression) {
    162162      ThreadPool.QueueUserWorkItem(
    163163        new WaitCallback(
     
    166166              DisableView(view);
    167167              SetWaitingCursor();
    168               XmlGenerator.Serialize(view.Object, filename, compression);
     168              XmlGenerator.Serialize(view.Content, filename, compression);
    169169              Invoke(delegate() {
    170170                view.Caption = Path.GetFileName(filename);
     
    191191              IItem item = (IItem)XmlParser.Deserialize(filename);
    192192              Invoke(delegate() {
    193                 IObjectView view = MainFormManager.CreateDefaultView(item) as IObjectView;
     193                IContentView view = MainFormManager.CreateDefaultView(item) as IContentView;
    194194                if (view == null) {
    195195                  MessageBox.Show("There is no view for the loaded item. It cannot be displayed. ", "No View Available", MessageBoxButtons.OK, MessageBoxIcon.Error);
Note: See TracChangeset for help on using the changeset viewer.