Example #1
0
        /*public void UpdateFlame()
         * {
         *
         * }*/

        /*public FlameListboxItem(FlameBrowser fb, FLVM f)
         * {
         *  InitializeComponent();
         *  Fb = fb;
         *  F = f;
         *  //DisplayText.Content = f.Name;
         *  DataContext = F;
         * }*/

        public void UpdateFlame(FLVM f)
        {
            F = f;
            //DisplayText.Content = f.Name;
            DataContext = F;
            this.Focus();
        }
Example #2
0
        /*public FLVM GetCurrentFlame()
         * {
         *  return vm.SelectedFlame;
         * }*/

        public void AddFlame(FLVM f, bool select)
        {
            vm.Flames.Add(f);
            if (select)
            {
                SelectFlame(f);
            }
        }
Example #3
0
        public void RemoveFlame(FLVM f)
        {
            int index = vm.Flames.IndexOf(f);

            vm.Flames.Remove(f);

            if (vm.Flames.Count == 0)
            {
                AddFlame(new FLVM(), false /**/);
            }

            //FlameListBox.SelectedIndex = (index < FlameListBox.Items.Count) ? index : 0;
            SelectFlame(vm.Flames[(index < FlameListBox.Items.Count) ? index : FlameListBox.Items.Count - 1]);
        }
Example #4
0
 private void CopyClipboard_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Clipboard.SetText(FlameSerializer.SerializeFlame(FLVM.ToFlameModels(new List <FLVM>()
         {
             flamebrowser_main.vm.SelectedFlame
         })[0]).ToString());
         StatusMessageVM.Instance.Show("Flame copied to clipboard");
     }
     catch
     {
         StatusMessageVM.Instance.Show("Error while copying flame");
     }
 }
Example #5
0
 public void UpdateCurrentFlame(FLVM f)
 {
     if (FlameListBox.Items.Count == 0)
     {
         AddFlame(f, true);
     }
     else
     {
         if (FlameListBox.SelectedIndex == -1)
         {
             FlameListBox.SelectedIndex = 0;
         }
         vm.Flames[FlameListBox.SelectedIndex] = f;
         SelectFlame(f);
     }
 }
Example #6
0
        private void OpenFile_Click(object sender, RoutedEventArgs e)
        {
            bool needSave = false;

            foreach (FLVM f in flamebrowser_main.GetFlames())
            {
                if (!f.Saved)
                {
                    needSave = true;
                    break;
                }
            }
            if (needSave)//csak akkor kerdezunk ra, ha van valtozas legalabb egy flameben
            {
                if (MessageBox.Show(this, "This will erase your unsaved work, continue?", "Open Flame Collection", MessageBoxButton.OKCancel, MessageBoxImage.Question, MessageBoxResult.OK, MessageBoxOptions.None) == MessageBoxResult.Cancel)
                {
                    return;
                }
            }

            Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog
            {
                Title      = "Open flame collection",
                DefaultExt = ".flame",
                Filter     = "Flame files (.flame)|*.flame"
            };
            if (ofd.ShowDialog() == true)
            {
                try
                {
                    string         CollectionName = "Unnamed Flame Collection";
                    FlameBrowserVM fbvm           = new FlameBrowserVM(FLVM.FromFlameModels(FlameCollectionSerializer.LoadFile(ofd.FileName, out CollectionName)), /*ofd.FileName.Split('\\').Last().Split('.')[0]*/ CollectionName);
                    flamebrowser_main.UpdateAll(fbvm);
                    StatusMessageVM.Instance.Show("Flame opened successfully");
                    StatusMessageVM.Instance.SetPath(ofd.FileName);
                }
                catch
                {
                    StatusMessageVM.Instance.Show("Error while opening flame: " + ofd.FileName);
                    StatusMessageVM.Instance.SetPath("");
                }
            }
        }
Example #7
0
 public void SelectFlame(FLVM f)
 {
     vm.SelectedFlame = f;
     Map.Flame        = f;
 }
Example #8
0
        private void LaunchProc(ref Process proc, string exepath)
        {
            /*if (proc!=null)
             * {//mar fut a process -> beillesztjuk a flamet
             *  if (!proc.HasExited)
             *  {
             *      //proc.Handle
             *      //win api: setforeground és sendkeys:
             *      //ctrl+v vel atadas
             *      return;
             *  }
             * }*///elvetve


            //else: nem fut a process -> elinditjuk tmp fajllal
            Directory.CreateDirectory(System.IO.Path.GetTempPath() + @"Node Editor\");
            string path = System.IO.Path.GetTempPath() + @"Node Editor\" + "tmp.flame";//Guid.NewGuid().ToString()

            FlameCollectionSerializer.SaveFile(flamebrowser_main.vm.FlameCollectionName, FLVM.ToFlameModels(flamebrowser_main.GetFlames()), path);
            proc = new Process();
            proc.StartInfo.FileName         = exepath;
            proc.StartInfo.WorkingDirectory = System.IO.Path.GetTempPath() + @"Node Editor\";
            proc.StartInfo.Arguments        = "tmp.flame";
            //proc.StartInfo.UseShellExecute = false;
            //proc.StartInfo.RedirectStandardInput = true;
            proc.Start();
        }
Example #9
0
 private void SaveAll_Click(object sender, RoutedEventArgs e)
 {
     Microsoft.Win32.SaveFileDialog sfd = new Microsoft.Win32.SaveFileDialog
     {
         Title      = "Save flame collection",
         FileName   = flamebrowser_main.vm.FlameCollectionName,
         DefaultExt = ".flame",
         Filter     = "Flame files (.flame)|*.flame"
     };
     if (sfd.ShowDialog() == true)
     {
         try
         {
             FlameCollectionSerializer.SaveFile(flamebrowser_main.vm.FlameCollectionName, FLVM.ToFlameModels(flamebrowser_main.GetFlames()), sfd.FileName);
             foreach (FLVM f in flamebrowser_main.GetFlames())
             {//ezt ide tettem, mert szerializálóba nem lehetett a temporary fájl írások miatt
                 f.Saved = true;
             }
             StatusMessageVM.Instance.Show("Flame collection saved successfully");
             StatusMessageVM.Instance.SetPath(sfd.FileName);
         }
         catch
         {
             StatusMessageVM.Instance.Show("Error while saving flame: " + sfd.FileName);
         }
     }
 }
Example #10
0
 private void Save_Click(object sender, RoutedEventArgs e)
 {
     Microsoft.Win32.SaveFileDialog sfd = new Microsoft.Win32.SaveFileDialog
     {
         Title      = "Save current flame",
         FileName   = flamebrowser_main.vm.FlameCollectionName,
         DefaultExt = ".flame",
         Filter     = "Flame files (.flame)|*.flame"
     };
     if (sfd.ShowDialog() == true)
     {
         try
         {
             FlameCollectionSerializer.SaveFile(flamebrowser_main.vm.FlameCollectionName, FLVM.ToFlameModels(new List <FLVM>()
             {
                 nodemap_main.Flame
             }), sfd.FileName);
             //ezt ide tettem, mert szerializálóba nem lehetett a temporary fájl írások miatt
             nodemap_main.Flame.Saved = true;
             StatusMessageVM.Instance.Show("Flame saved successfully");
         }
         catch
         {
             StatusMessageVM.Instance.Show("Error while saving flame: " + sfd.FileName);
         }
     }
 }