예제 #1
0
        private void OkButton_Click(object sender, EventArgs e)
        {
            //Validations
            var xmlfilepath = XmlFilePath.Text;

            if (!File.Exists(xmlfilepath))
            {
                if (MessageBox.Show("Xml Arrangement file path is not valid.", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel)
                {
                    XmlFilePath.Focus();
                    return;
                }
            }

            if (currentGameVersion != GameVersion.RS2012)
            {
                if (!routeMaskLeadRadio.Checked && !routeMaskRhythmRadio.Checked && !routeMaskBassRadio.Checked && (ArrangementType)arrangementTypeCombo.SelectedItem != ArrangementType.Vocal && (ArrangementType)arrangementTypeCombo.SelectedItem != ArrangementType.ShowLight)
                {
                    if (MessageBox.Show("You did not select a Gameplay Path for this arrangement.", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Cancel)
                    {
                        gbGameplayPath.Focus();
                        return;
                    }
                }
            }

            LoadArrangementData(xmlfilepath);
            DialogResult = DialogResult.OK;
            Close();
        }
예제 #2
0
파일: LRUpload.cs 프로젝트: rpwillis/mlg
 /// <summary>
 /// Finds the xml metadata file of the zip file in the extreaction ndirectory.  The file name could be one of the
 /// supplied list of xml files.  Throws a FileNotFoundException if the file is not found.
 /// </summary>
 /// <param name="fileParentDirectory">The extraction directory to look for the file in</param>
 /// <exception cref="FileNotFoundException"></exception>
 /// <returns>The full path of the xml metadata file</returns>
 private string GetXmlMetadataFile(string fileParentDirectory)
 {
     if (!String.IsNullOrEmpty(XmlFilePath))
     {
         string[] filePaths = XmlFilePath.Split(',');
         for (int i = 0; i < filePaths.Length; i++)
         {
             string fileFullPath = Path.Combine(fileParentDirectory, filePaths[i].Trim());
             if (File.Exists(fileFullPath))
             {
                 return(fileFullPath);
             }
         }
         throw new FileNotFoundException();
     }
     throw new FileNotFoundException();
 }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="mainId"></param>
        /// <param name="folderName"></param>
        public void Save()
        {
            if (XmlFilePath.EndsWith("元数据.xml"))
            {
                using (var fs = new FileStream(XmlFilePath, FileMode.Create))
                {
                    using (var sr = new StreamWriter(fs, CurrentEncoding))
                    {
                        var str = InfoEarthFrame.Common.XmlConvert.XmlSerialize <Metadata>(this);
                        sr.Write(str);
                    }
                }
            }

            //上传文件到FTP
            var ftp = ConfigContext.Current.FtpConfig["Package"];

            if (ftp == null)
            {
                throw new Exception("未找到名称为[Package]的Ftp配置项");
            }

            using (var client = new FtpHelper(ftp))
            {
                var workingDir = "Package\\" + this.MainId + "\\" + this.FolderName;
                client.UploadFiles(new List <string> {
                    XmlFile.FullName
                }, workingDir);
                XmlFtpPath = workingDir + "\\" + XmlFile.Name;
            }

            //缓存失效
            lock (LockObj)
            {
                var key = this.MainId + "/" + this.FolderName;
                Cache.Remove(key);
            }
        }
        private void OkButton_Click(object sender, EventArgs e)
        {
            //Validations
            var xmlfilepath = XmlFilePath.Text;

            if (!File.Exists(xmlfilepath))
            {
                if (MessageBox.Show("Xml Arrangement file path is not valid.", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel)
                {
                    XmlFilePath.Focus();
                    return;
                }
            }

            if (currentGameVersion != GameVersion.RS2012)
            {
                if (!routeMaskLeadRadio.Checked && !routeMaskRhythmRadio.Checked && !routeMaskBassRadio.Checked && (ArrangementType)arrangementTypeCombo.SelectedItem != ArrangementType.Vocal)
                {
                    if (MessageBox.Show("You did not select a Gameplay Path for this arrangement.", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Cancel)
                    {
                        gbGameplayPath.Focus();
                        return;
                    }
                }
            }

            //Song XML File
            Arrangement.SongXml.File = xmlfilepath;

            // SONG INFO
            if (!ReferenceEquals(xmlSong, null))
            {
                if (String.IsNullOrEmpty(parentControl.SongTitle))
                {
                    parentControl.SongTitle = xmlSong.Title ?? String.Empty;
                }
                if (String.IsNullOrEmpty(parentControl.SongTitleSort))
                {
                    parentControl.SongTitleSort = xmlSong.SongNameSort.GetValidSortName() ?? parentControl.SongTitle.GetValidSortName();
                }
                if (String.IsNullOrEmpty(parentControl.AverageTempo))
                {
                    parentControl.AverageTempo = Math.Round(xmlSong.AverageTempo).ToString() ?? String.Empty;
                }
                if (String.IsNullOrEmpty(parentControl.Artist))
                {
                    parentControl.Artist = xmlSong.ArtistName ?? String.Empty;
                }
                if (String.IsNullOrEmpty(parentControl.ArtistSort))
                {
                    parentControl.ArtistSort = xmlSong.ArtistNameSort.GetValidSortName() ?? parentControl.Artist.GetValidSortName();
                }
                if (String.IsNullOrEmpty(parentControl.Album))
                {
                    parentControl.Album = xmlSong.AlbumName ?? String.Empty;
                }
                if (String.IsNullOrEmpty(parentControl.AlbumYear))
                {
                    parentControl.AlbumYear = xmlSong.AlbumYear ?? String.Empty;
                }
                if (String.IsNullOrEmpty(parentControl.DLCName))
                {
                    parentControl.DLCName = parentControl.Artist.Acronym() + parentControl.SongTitleSort;
                }
            }

            //Arrangment Information
            Arrangement.Name            = (ArrangementName)arrangementNameCombo.SelectedItem;
            Arrangement.ArrangementType = (ArrangementType)arrangementTypeCombo.SelectedItem;
            Arrangement.ScrollSpeed     = scrollSpeedTrackBar.Value;
            Arrangement.PluckedType     = Picked.Checked ? PluckedType.Picked : PluckedType.NotPicked;
            Arrangement.BonusArr        = BonusCheckBox.Checked;
            Arrangement.Metronome       = MetronomeCb.Checked ? Metronome.Generate : Metronome.None;

            // Tuning
            TuningDefinition tuning = (TuningDefinition)tuningComboBox.SelectedItem;

            Arrangement.Tuning        = tuning.UIName;
            Arrangement.TuningStrings = tuning.Tuning;

            // TODO: Add capo selection to arrangement form
            if (!ReferenceEquals(xmlSong, null))
            {
                Arrangement.CapoFret = xmlSong.Capo;
            }
            UpdateCentOffset();

            //ToneSelector
            Arrangement.ToneBase = toneBaseCombo.SelectedItem.ToString();
            Arrangement.ToneA    = (toneACombo.SelectedItem != null) ? toneACombo.SelectedItem.ToString() : ""; //Only need if have more than one tone
            Arrangement.ToneB    = (toneBCombo.SelectedItem != null) ? toneBCombo.SelectedItem.ToString() : "";
            Arrangement.ToneC    = (toneCCombo.SelectedItem != null) ? toneCCombo.SelectedItem.ToString() : "";
            Arrangement.ToneD    = (toneDCombo.SelectedItem != null) ? toneDCombo.SelectedItem.ToString() : "";

            //Gameplay Path
            Arrangement.RouteMask = RouteMask;

            //Xml data cleanup
            xmlSong = null;

            // DLC IDs
            Guid guid;

            if (Guid.TryParse(PersistentId.Text, out guid) == false)
            {
                PersistentId.Focus();
            }
            else
            {
                Arrangement.Id = guid;
            }

            int masterId;

            if (int.TryParse(MasterId.Text, out masterId) == false)
            {
                MasterId.Focus();
            }
            else
            {
                Arrangement.MasterId = masterId;
            }

            DialogResult = DialogResult.OK;
            Close();
        }
예제 #5
0
        private void addArrangementButton_Click(object sender, EventArgs e)
        {
            //Validations
            var xmlfilepath = XmlFilePath.Text;

            if (!File.Exists(xmlfilepath))
            {
                XmlFilePath.Focus();
                return;
            }

            if (currentGameVersion == GameVersion.RS2014)
            {
                if (!routeMaskLeadRadio.Checked && !routeMaskRhythmRadio.Checked && !routeMaskBassRadio.Checked && (ArrangementType)arrangementTypeCombo.SelectedItem != ArrangementType.Vocal)
                {
                    if (MessageBox.Show("You not selected a Gameplay Path, this arrangement you show only in song list.", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Cancel)
                    {
                        gbGameplayPath.Focus();
                        return;
                    }
                }
            }

            //Song XML File
            arrangement.SongXml.File = xmlfilepath;

            //Arrangment Information
            arrangement.Name            = (ArrangementName)arrangementNameCombo.SelectedItem;
            arrangement.ArrangementType = (ArrangementType)arrangementTypeCombo.SelectedItem;

            // Tuning
            arrangement.Tuning      = tuningComboBox.SelectedItem.ToString();
            arrangement.TuningPitch = 440;
            var value = frequencyTB.Text;

            if (!String.IsNullOrEmpty(value))
            {
                double freq = 440;
                Double.TryParse(value, out freq);
                arrangement.TuningPitch = freq;
            }

            arrangement.ScrollSpeed = scrollSpeedTrackBar.Value;
            arrangement.PluckedType = Picked.Checked ? PluckedType.Picked : PluckedType.NotPicked;
            arrangement.BonusArr    = BonusCheckBox.Checked;

            //ToneSelector
            arrangement.ToneBase = toneBaseCombo.SelectedItem.ToString();
            arrangement.ToneA    = (toneBCombo.SelectedItem != null) ? toneBaseCombo.SelectedItem.ToString() : ""; //Only need if have more than one tone
            arrangement.ToneB    = (toneBCombo.SelectedItem != null) ? toneBCombo.SelectedItem.ToString() : "";
            arrangement.ToneC    = (toneCCombo.SelectedItem != null) ? toneCCombo.SelectedItem.ToString() : "";
            arrangement.ToneD    = (toneDCombo.SelectedItem != null) ? toneDCombo.SelectedItem.ToString() : "";

            //Gameplay Path
            arrangement.RouteMask = RouteMask;

            // DLC IDs
            Guid guid;

            if (Guid.TryParse(PersistentId.Text, out guid) == false)
            {
                PersistentId.Focus();
            }
            else
            {
                arrangement.Id = guid;
            }

            int masterId;

            if (int.TryParse(MasterId.Text, out masterId) == false)
            {
                MasterId.Focus();
            }
            else
            {
                arrangement.MasterId = masterId;
            }

            DialogResult = DialogResult.OK;
            Close();
        }
        public static void Example1()
        {
            TestModels.IModel modelFactory = TestModels.ModelFactory.Model2B();

            XmlFilePath       structureFile = modelFactory.Model();
            DelimitedFilePath dataFile      = modelFactory.Data();

            // Read in the model and the data.
            XElement model =
                XElement.Load(structureFile)
                .DefineAttributeData(dataFile);

            // Create the objective function.
            double ObjectiveFunction(double[] x)
            {
                XElement localModel = new XElement(model);

                localModel.SetConsumerPrices(x)
                .ShockProducerPrices()
                .CalculateMarketShares()
                .CalculateMarketEquilibrium();

                return(ObjectiveFunctionFactory.SumOfSquares(localModel));
            }

            // Set up the simplex solver.
            Simplex simplex =
                new Simplex(
                    objectiveFunction: ObjectiveFunction,
                    lowerBound: 0,
                    upperBound: 10,
                    //dimensions: model.DescendantsAndSelf().Count(),
                    dimensions: model.DescendantsAndSelf().Count(x => !x.HasElements),
                    iterations: 50000,
                    seed: 0,
                    textWriter: Console.Out
                    );

            // Find the minimum solution.
            Solution solution = simplex.Minimize();

            // Apply the final solution
            model.SetConsumerPrices(solution.Vector)
            .ShockProducerPrices()
            .CalculateMarketShares()
            .CalculateMarketEquilibrium();

            // Print the results
            PrintResults(model, solution);

            //// Set up the swarm solver.
            //PSO.Swarm swarm =
            //    new PSO.Swarm(
            //        objectiveFunction: x => objectiveFunction(x),
            //        lowerBound: 0,
            //        upperBound: 5,
            //        dimensions: model.DescendantsAndSelf().Count(x => !x.HasElements),
            //        iterations: 25000,
            //        particles: model.DescendantsAndSelf().Count(x => !x.HasElements) * 2,
            //        seed: 0,
            //        textWriter: Console.Out
            //    );

            //// Find the minimum solution.
            //Solution solution = PSO.MinimizeSwarmExtensions.Minimize(swarm);

            //// Apply the final solution
            //model.SetConsumerPrices(solution.Vector)
            //     .ShockProducerPrices()
            //     .CalculateMarketShares()
            //     .CalculateMarketEquilibrium();

            //// Print the results
            //PrintResults(model, solution);
        }