Exemplo n.º 1
0
 public void CloseSave()
 {
     if (SavePath != null)
     {
         DialogResult CloseNot = formSave.ShowDialog();
         if (CloseNot == DialogResult.OK)
         {
             SaveNoDialog();
             SavePath = null;
             ObjectCollection.Instance.Reset(false);
         }
         else
         if (CloseNot == DialogResult.Cancel)
         {
             return;
         }
         else
         {
             SavePath = null;
             ObjectCollection.Instance.Reset(false);
         }
         return;
     }
     if (StartLoad != null)
     {
         StartLoad.Invoke(this, new EventArgs());
         if (ObjectCollection.Instance.rays.Count + ObjectCollection.Instance.objects.Count != 0)
         {
             DialogResult CloseNot = formSave.ShowDialog();
             if (CloseNot == DialogResult.OK)
             {
                 SaveNoDialog();
                 SavePath = null;
                 ObjectCollection.Instance.Reset(false);
             }
             else
             if (CloseNot == DialogResult.Cancel)
             {
                 return;
             }
             else
             {
                 SavePath = null;
                 ObjectCollection.Instance.Reset(false);
             }
             return;
         }
         FinishLoad.Invoke(this, new EventArgs());
     }
 }
Exemplo n.º 2
0
 void Save(string file_path)
 {
     #region Open File
     if ((StartLoad == null) || (FinishLoad == null))
     {
         throw new InitializedListLookupFailed();
     }
     if (file_path.Contains(".obs") == false)
     {
         file_path = file_path + ".obs";
     }
     StartLoad.Invoke(this, new EventArgs());
     FileStream   save;
     StreamWriter saver;
     try
     {
         save  = new FileStream(file_path, FileMode.Create);
         saver = new StreamWriter(save);
     }
     catch (Exception ee)
     {
         MessageBox.Show(ee.Message);
         return;
     }
     #endregion
     #region Write Data
     saver.WriteLine("[rays]");
     foreach (Ray x in ObjectCollection.Instance.rays)
     {
         saver.WriteLine(x.GenerateSaveString());
     }
     saver.WriteLine("[objects]");
     foreach (ObjectProto x in ObjectCollection.Instance.objects)
     {
         saver.WriteLine(x.GenerateSaveString());
     }
     saver.WriteLine("[EndSave]");
     saver.Close();
     FinishLoad.Invoke(this, new EventArgs());
     #endregion
 }
Exemplo n.º 3
0
 protected virtual void OnStartLoad(EventArgs e)
 {
     //Console.WriteLine("TextureManager now loading...");
     StartLoad?.Invoke(this, e);
 }
Exemplo n.º 4
0
 public DistributedLoad3D Translate(Vector3D vector)
 {
     return(new DistributedLoad3D(StartLoad.Translate(vector), EndLoad.Translate(vector)));
 }
Exemplo n.º 5
0
 public DistributedLoad3D RotateAroundZAxisAtCenter(Angle rotation, Point2D center)
 {
     return(new DistributedLoad3D(StartLoad.RotateAboutZAxisAndCenter(rotation, center),
                                  EndLoad.RotateAboutZAxisAndCenter(rotation, center)));
 }
Exemplo n.º 6
0
        void Load(string file_path)
        {
            #region Open File
            if ((StartLoad == null) || (FinishLoad == null))
            {
                throw new InitializedListLookupFailed();
            }
            StartLoad.Invoke(this, new EventArgs());
            List <Ray>         Rays    = new List <Ray>();
            List <ObjectProto> Objects = new List <ObjectProto>();
            if (File.Exists(file_path) == false)
            {
                System.Windows.Forms.MessageBox.Show(OpticalBuilderLib.Configuration.STranslation.T["FileNotFound"] + '!');
                FinishLoad.Invoke(this, new EventArgs());
            }
            FileStream   read   = new FileStream(file_path, FileMode.Open);
            StreamReader reader = new StreamReader(read);
            #endregion
            #region Read Data
            if (reader.ReadLine() != "[rays]")
            {
                Exception e = new ErrorWhileReading();
                System.Windows.Forms.MessageBox.Show((new ErrorWhileReading()).Message);
#pragma warning disable 0162
                FinishLoad.Invoke(this, new EventArgs());
#pragma warning restore 0162
                return;
            }
            string str = reader.ReadLine();
            while (str != "[objects]")
            {
                try
                {
                    Rays.Add(new Ray(str));
                }
                catch (Exception e)
                {
                    System.Windows.Forms.MessageBox.Show(e.Message);
                    FinishLoad.Invoke(this, new EventArgs());
                    return;
                }
                str = reader.ReadLine();
            }
            str = reader.ReadLine();
            while (str != "[EndSave]")
            {
                try
                {
                    Objects.Add(ConstructObject(str.Split('^')[0], str));
                }
                catch (Exception e)
                {
                    System.Windows.Forms.MessageBox.Show(e.Message);
                    if (e is ErrorWhileReading)
                    {
                        FinishLoad.Invoke(this, new EventArgs());
                    }
                    return;
                }
                str = reader.ReadLine();
            }
            ObjectCollection.Instance.rays    = Rays;
            ObjectCollection.Instance.objects = Objects;
            reader.Close();
            FinishLoad.Invoke(this, new EventArgs());
            ObjectCollection.Instance.RaiseObjectsChange();
            Form1.form.SelectedItem = null;
            Form1.form.groupBox1.ReloadList(this, new EventArgs());
            Form1.form.groupBox1.Instance_OnSelectedChange(this, new SelectedChangeArgs(null));
            #endregion
        }