/// <summary>Initializes a new instance of the <see cref="CommandFactory"/> class.</summary> /// <param name="messages">The message repository.</param> /// <param name="users">The user repository.</param> /// <param name="formatter">The message formatter.</param> public CommandFactory(MessageRepository messages, UserRepository users, MessageFormatter formatter) { MAP.Add("->", () => new PostCommand(messages)); MAP.Add("FOLLOWS", () => new FollowsCommand(users)); MAP.Add("WALL", () => new WallCommand(messages, users, formatter)); MAP.Add("", () => new ReadCommand(messages, formatter)); }
internal static MAP LoadGlobalSettings() { if (settings != null) { return(settings); } foreach (var pkg in App.Catalog <IPackageManager>().Default().EnumeratePackages()) { foreach (var e in pkg.GetMetadata(PackageSection.Settings)) { var name = Path.Combine(pkg.Directory.FullName, "data", e.String("file")); var map = ReadFile(name); if (settings == null) { settings = map; } else { try { foreach (var kv in map) { settings.Add(kv.Key, kv.Value); } } catch { } } } } return(settings); }
public string RunPrefKNN(int neighborCount, int topN = 10) { if (!ReadyForOrdinal) { GetReadyForOrdinal(); } StringBuilder log = new StringBuilder(); log.AppendLine(Utils.PrintHeading("PrefKNN")); // Prediction Utils.StartTimer(); DataMatrix R_predicted = PrefUserKNN.PredictRatings(PR_train, R_unknown, neighborCount, UserSimilaritiesOfPref); log.AppendLine(Utils.StopTimer()); // TopN Evaluation var topNItemsByUser = ItemRecommendationCore.GetTopNItemsByUser(R_predicted, topN); for (int n = 1; n <= topN; n++) { Utils.PrintValue("NCDG@" + n, NCDG.Evaluate(RelevantItemsByUser, topNItemsByUser, n).ToString("0.0000")); } for (int n = 1; n <= topN; n++) { log.AppendLine(Utils.PrintValue("MAP@" + n, MAP.Evaluate(RelevantItemsByUser, topNItemsByUser, n).ToString("0.0000"))); } return(log.ToString()); }
private void analyzeButton_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(tduPath.Text) || leMAP == null) { return; } try { Cursor = Cursors.WaitCursor; StatusBarLogManager.ShowEvent(this, _STATUS_ANALYSING); // Lance l'analyse Dictionary <string, long> currentFileList = MAP.ReportTDUFiles(tduPath.Text); // Tente l'association StringCollection failedFiles = new StringCollection(); idList = leMAP.LinkEntriesToFiles(currentFileList, laCle, failedFiles); // Met à jour la liste de fichiers _UpdateFileList(); Cursor = Cursors.Default; } catch (Exception ex) { MessageBoxes.ShowError(this, ex); } finally { // EVO 32 StatusBarLogManager.ShowEvent(this, _STATUS_END_ANALYSIS); } }
static void Main(string[] args) { Console.WriteLine("MAPUnpack for King's Field IV (The Ancient City)\n"); if (args.Length < 1) { Console.WriteLine("Usage:\n\tMAPUnpack.exe f.map\n"); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); return; } string unpackPath = Path.GetDirectoryName(args[0]) + "\\" + Path.GetFileNameWithoutExtension(args[0]) + "\\"; Directory.CreateDirectory(unpackPath); //Read MAP Console.WriteLine("Unpacking..."); MAP map = MAP.FromFile(args[0]); //Save MAP data Console.WriteLine("Writing Files..."); map.Save(unpackPath); //Finished Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }
private static Style ReadStyle(MAP dict) => new Style( dict.Color("color"), dict.Color("backColor"), dict.Color("adornmentColor"), dict.Adornments(), dict.FontStyles());
public void LoadMusic(uint sound_id, EventScript.ArgType argtype) { MAP.ClearAllPoint(); PlaySappyButton.Tag = sound_id; this.MusicName.Text = SongTableForm.GetSongName(sound_id); string errormessage = ""; if (argtype == EventScript.ArgType.SOUND) { errormessage = SongTableForm.GetErrorMessage(sound_id, "SFX"); } else if (argtype == EventScript.ArgType.MAPMUSIC) { errormessage = SongTableForm.GetErrorMessage(sound_id, "MAP"); } this.MusicName.ErrorMessage = errormessage; int width = 300; int height = 100; this.Tab.Width = width; this.Tab.Height = height; this.MAP.Width = width; this.MAP.Height = height; Tab.SelectedIndex = 2; this.Width = width; this.Height = height; }
private void refreshButton_Click(object sender, EventArgs e) { // Contrôle de la saisie ... if (string.IsNullOrEmpty(inputFilePath.Text)) { return; } // Récupération des infos try { Cursor = Cursors.WaitCursor; leMAP = TduFile.GetFile(inputFilePath.Text) as MAP; if (leMAP != null) { // Mise à jour des entrées _UpdateEntryList(true); } Cursor = Cursors.Default; } catch (Exception ex) { MessageBoxes.ShowError(this, ex); } }
public void ReloadSettings(SettingsScope scope) { switch (scope) { case SettingsScope.User: userSettings = ReadFile(UserSettingsFile); break; case SettingsScope.Workspace: var dir = view.Workspace; if (dir != null) { workspaceSettings = ReadFile(Path.Combine(dir.FullName, ".slot", FILE)); } break; case SettingsScope.Mode: break; } foreach (var b in bagMap.Values) { b.Fill(settings, userSettings, workspaceSettings); } }
public GridLayer(GridGeometry gridGeometry, MAP map) { this.gridGeometry = gridGeometry; this.map = map; matrix = new double?[CountY, CountX]; needRecoloring = true; }
public void DeletePoint(int id) { var forgeDatabase = Global.Instance.ForgeDatabase(); PUSHPIN pushpin = forgeDatabase.PushPins.Single(p => p.ID == id); if (pushpin.MapID != null && pushpin.MapID > 0) { var mapID = pushpin.MapID; MAP map = forgeDatabase.Maps.Single(m => m.ID == mapID); //MessageBox.Show(map.ID.ToString()); if (File.Exists(map.Path)) { File.Delete(map.Path); } forgeDatabase.PushPins.DeleteOnSubmit(pushpin); forgeDatabase.SubmitChanges(); forgeDatabase.Maps.DeleteOnSubmit(map); forgeDatabase.SubmitChanges(); PopulatePushPinCollection(); } else { forgeDatabase.PushPins.DeleteOnSubmit(pushpin); forgeDatabase.SubmitChanges(); PopulatePushPinCollection(); } }
private static void ProcessDictionary(object instance, Type type, MAP dict) { var props = type.GetProperties(BindingFlags.Public | BindingFlags.Instance); foreach (var pi in props) { if (!pi.CanWrite || pi.Name == "Item" || Attribute.IsDefined(pi, typeof(JsonIgnoreAttribute))) { continue; } var attr = Attribute.GetCustomAttribute(pi, typeof(JsonElementAttribute)); var name = pi.Name; if (attr != null) { name = attr.ToString(); } object value; if (!ObtainDictionaryValue(name, pi.PropertyType, dict, out value)) { continue; } pi.SetValue(instance, value); } }
public static T Map <T>(MAP dict) where T : new() { var ret = new T(); ProcessDictionary(ret, typeof(T), dict); return(ret); }
public void LoadScreen() { if (Tab.SelectedIndex != 0) {//地図ではない場合、非表示にはなるため、 MapPicture.OnLoadが呼ばれないらしい... Tab.SelectedIndex = 0; } Bitmap map = ImageUtil.Blank(320, 240); map = ImageUtil.DrawGrid(map, OptionForm.Color_Keyword_ForeColor(), 16); MAP.ClearAllPoint(); MAP.LoadMap(map); MAP.SetChipSize(1); Bitmap icon = ImageSystemIconForm.YubiTate(); U.MakeTransparent(icon); MAP.SetDefaultIcon(icon, -8, -14); if (!MAP.IsMapLoad()) { return; } int width = MAP.GetMapBitmapWidth(); int height = MAP.GetMapBitmapHeight() + this.MAP.CommandBar.Height * 2; this.Tab.Width = width; this.Tab.Height = height; this.MAP.Width = width; this.MAP.Height = height; Tab.SelectedIndex = 0; this.Width = width; this.Height = height; }
void NewMap() { mapFile = null; map = new MAP(); map.Terrains = new List <TERRAIN>(); ResetViewport(); }
public string RunNMFbasedOMF(int maxEpoch, double learnRate, double regularization, int factorCount, List <double> quantizer, int topN = 0) { if (!ReadyForNumerical) { GetReadyForNumerical(); } StringBuilder log = new StringBuilder(); log.AppendLine(Utils.PrintHeading("NMF based OMF")); // NMF Prediction // Get ratings from scorer, for both train and test // R_all contains indexes of all ratings both train and test DataMatrix R_all = new DataMatrix(R_unknown.UserCount, R_unknown.ItemCount); R_all.MergeNonOverlap(R_unknown); R_all.MergeNonOverlap(R_train.IndexesOfNonZeroElements()); Utils.StartTimer(); DataMatrix R_predictedByNMF = NMF.PredictRatings(R_train, R_all, maxEpoch, learnRate, regularization, factorCount); log.AppendLine(Utils.StopTimer()); // OMF Prediction log.AppendLine(Utils.PrintHeading("Ordinal Matrix Factorization with NMF as scorer")); Utils.StartTimer(); Dictionary <Tuple <int, int>, List <double> > OMFDistributionByUserItem; DataMatrix R_predicted; log.AppendLine(OMF.PredictRatings(R_train.Matrix, R_unknown.Matrix, R_predictedByNMF.Matrix, quantizer, out R_predicted, out OMFDistributionByUserItem)); log.AppendLine(Utils.StopTimer()); // Numerical Evaluation log.AppendLine(Utils.PrintValue("RMSE", RMSE.Evaluate(R_test, R_predicted).ToString("0.0000"))); log.AppendLine(Utils.PrintValue("MAE", MAE.Evaluate(R_test, R_predicted).ToString("0.0000"))); // TopN Evaluation if (topN != 0) { var topNItemsByUser = ItemRecommendationCore.GetTopNItemsByUser(R_predicted, topN); for (int n = 1; n <= topN; n++) { log.AppendLine(Utils.PrintValue("NCDG@" + n, NCDG.Evaluate(RelevantItemsByUser, topNItemsByUser, n).ToString("0.0000"))); } for (int n = 1; n <= topN; n++) { log.AppendLine(Utils.PrintValue("MAP@" + n, MAP.Evaluate(RelevantItemsByUser, topNItemsByUser, n).ToString("0.0000"))); } } // Save OMFDistribution to file if (!File.Exists(GetDataFileName("RatingOMF_"))) { Utils.IO <Dictionary <Tuple <int, int>, List <double> > > .SaveObject(OMFDistributionByUserItem, GetDataFileName("RatingOMF_")); } return(log.ToString()); }
public bool Read(string filename) { // binary reader //// deserialize from file BinaryReader reader = new BinaryReader(File.Open(filename, FileMode.Open)); int length = (int)reader.BaseStream.Length; //Console.WriteLine("binary read buffer"); byte[] loadbinbuf = reader.ReadBytes(length); reader.Close(); var loadbinBytebuf = new ByteBuffer(loadbinbuf); var loadbinMap = MAP.GetRootAsMAP(loadbinBytebuf); short [] MapData = loadbinMap.GetMapArray(); Console.WriteLine("LotId : " + loadbinMap.LotNum); Console.WriteLine("RefDie0 : " + loadbinMap.RefDie(0).Value.X.ToString() + "," + loadbinMap.RefDie(0).Value.Y.ToString()); Console.WriteLine("RefDie1 : " + loadbinMap.RefDie(1).Value.X.ToString() + "," + loadbinMap.RefDie(1).Value.Y.ToString()); Console.WriteLine("TargetDie0 : " + loadbinMap.TargetDie(0).Value.X.ToString() + "," + loadbinMap.TargetDie(0).Value.Y.ToString()); Console.WriteLine("TargetDie1 : " + loadbinMap.TargetDie(1).Value.X.ToString() + "," + loadbinMap.TargetDie(1).Value.Y.ToString()); for (int i = 0; i < loadbinMap.MapLength; i++) { Console.WriteLine(loadbinMap.Map(i).ToString()); } return(true); }
public string RunPrefNMF(int maxEpoch, double learnRate, double regularizationOfUser, double regularizationOfItem, int factorCount, int topN = 10) { if (!ReadyForOrdinal) { GetReadyForOrdinal(); } StringBuilder log = new StringBuilder(); log.AppendLine(Utils.PrintHeading("PrefNMF")); // Prediction Utils.StartTimer(); DataMatrix R_predicted = PrefNMF.PredictRatings(PR_train, R_unknown, maxEpoch, learnRate, regularizationOfUser, regularizationOfItem, factorCount); log.AppendLine(Utils.StopTimer()); // Evaluation var topNItemsByUser = ItemRecommendationCore.GetTopNItemsByUser(R_predicted, topN); for (int n = 1; n <= topN; n++) { Utils.PrintValue("NCDG@" + n, NCDG.Evaluate(RelevantItemsByUser, topNItemsByUser, n).ToString("0.0000")); } for (int n = 1; n <= topN; n++) { log.AppendLine(Utils.PrintValue("MAP@" + n, MAP.Evaluate(RelevantItemsByUser, topNItemsByUser, n).ToString("0.0000"))); } return(log.ToString()); }
private void btnAdd_Click(object sender, EventArgs e) { txtOutput.Clear(); MAP m; if (!dataContext.MAP.Any()) { m = new MAP() { NAME = "New map", DESCRIPTION = "Map of doom" }; dataContext.AddToMAP(m); } else { m = dataContext.MAP.First(); } HEX lastHex = (from h in dataContext.HEX select h).OrderByDescending(h => h.Y).FirstOrDefault(); HEX newHex = new HEX() { TERRAIN_ID = 1, HEIGHT = 0 }; if (lastHex == null) { newHex.X = 0; newHex.Y = 0; } else { newHex.X = 0; newHex.Y = lastHex.Y + 1; } m.HEXES.Add(newHex); dataContext.SaveChanges(); txtOutput.AppendText("Hex " + newHex.ID + " added"); }
void RiempiGrid() { string filterstock = QHS.IsNull("idinvkind"); string sqlCmd = " SELECT * " + " FROM ddt_inview " + " WHERE " + filter + " AND EXISTS (SELECT * FROM stock WHERE " + " ddt_inview.idddt_in = stock.idddt_in AND " + filterstock + " ) " + " ORDER BY ddt_inview.idddt_in asc "; DataTable ddt_in = Meta.Conn.SQLRunner(sqlCmd); if (ddt_in.Rows.Count != 0) { ddt_in.PrimaryKey = new DataColumn[] { ddt_in.Columns["idddt_in"] }; //Ora ha messo in ddt_in tutto ciò che da DB risulta 'da fatturare'. if (ddt_in.Select().Length > 0) { MetaData MAP; MAP = Meta.Dispatcher.Get("ddt_inview"); MAP.DescribeColumns(ddt_in, "default"); DataSet D = new DataSet(); D.Tables.Add(ddt_in); HelpForm.SetDataGrid(gridDettagli, ddt_in); gridDettagli.TableStyles.Clear(); HelpForm.SetGridStyle(gridDettagli, ddt_in); formatgrids format = new formatgrids(gridDettagli); format.AutosizeColumnWidth(); HelpForm.SetAllowMultiSelection(ddt_in, true); SelezionaTutto(); } } }
public void FailRemoveMapByInstanceWhenFPGIsEmpty() { var pal = new PAL(this.GetAssetPath(SharedConstants.FILENAME_PAL_SPACE)); var map = new MAP(this.GetAssetPath(SharedConstants.FILENAME_IMG_PLAYER_MAP)); var fpg = new FPG(pal); Assert.ThrowsException <InvalidOperationException>(() => fpg.Remove(map)); }
public bool Validate(byte[] buffer) { bool isPCX = PCX.Instance.Validate(buffer); bool isMAP = MAP.ValidateFormat(buffer); bool isFPG = FPG.ValidateFormat(buffer); return(!(isPCX || isMAP || isFPG)); }
/// <summary> /// Constructeur /// </summary> /// <param name="entryToModify"></param> /// <param name="fileToModify"></param> public SizeModifierForm(MAP.Entry entryToModify, MAP fileToModify) { theEntry = entryToModify; theFile = fileToModify; InitializeComponent(); initializeContents(); }
private void siBOK_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(cmbInRaster.Text.TrimEnd())) { XtraMessageBox.Show("输入文件不能为空!"); return; } else if (cBEBlue.SelectedIndex < 0) { XtraMessageBox.Show("请选择蓝光波段!"); return; } else if (cBERed.SelectedIndex < 0) { XtraMessageBox.Show("请选择红光波段!"); return; } else if (cBENIRed.SelectedIndex < 0) { XtraMessageBox.Show("请选择近红外波段!"); return; } else if (string.IsNullOrEmpty(txtOut.Text.TrimEnd())) { XtraMessageBox.Show("输出文件不能为空!"); return; } else { frmWaitDialog frmWait = new frmWaitDialog("提示", "正在计算......"); try { frmWait.Owner = this; frmWait.TopMost = false; VegetationIndex.Calculate(VegIndex.EVI, cmbInRaster.Text.TrimEnd(), txtOut.Text.TrimEnd() , cBERed.SelectedIndex, cBENIRed.SelectedIndex, cBEBlue.SelectedIndex); if (DialogResult.OK == XtraMessageBox.Show("计算完毕,是否加载结果文件?", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)) { MAP.AddRasterFileToMap(txtOut.Text.TrimEnd()); } this.Close(); } catch (Exception ex) { XtraMessageBox.Show(ex.Message, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); Log.WriteLog(typeof(frmEVI), ex); } finally { frmWait.Close(); } } }
public string RunPrefMRF(double regularization, double learnRate, int maxEpoch, List <double> quantizer, int topN = 10) { // Load OMFDistribution from file Dictionary <Tuple <int, int>, List <double> > OMFDistributionByUserItem; if (File.Exists(GetDataFileName("PrefOMF_"))) { OMFDistributionByUserItem = Utils.IO <Dictionary <Tuple <int, int>, List <double> > > .LoadObject(GetDataFileName("PrefOMF_")); } else { return("Abort, Run OMF first."); } if (!ReadyForOrdinal) { GetReadyForOrdinal(); } StringBuilder log = new StringBuilder(); log.AppendLine(Utils.PrintHeading("PrefMRF: PrefNMF based ORF")); // Prediction Utils.StartTimer(); DataMatrix R_predicted_expectations; DataMatrix R_predicted_mostlikely; // Convert PR_train into user-wise preferences DataMatrix R_train_positions = new DataMatrix(PR_train.GetPositionMatrix()); R_train_positions.Quantization(quantizer[0], quantizer[quantizer.Count - 1] - quantizer[0], quantizer); ORF orf = new ORF(); orf.PredictRatings(R_train_positions, R_unknown, StrongSimilarityIndicatorsByItemPref, OMFDistributionByUserItem, regularization, learnRate, maxEpoch, quantizer.Count, out R_predicted_expectations, out R_predicted_mostlikely); log.AppendLine(Utils.StopTimer()); // Evaluation var topNItemsByUser_expectations = ItemRecommendationCore.GetTopNItemsByUser(R_predicted_expectations, topN); for (int n = 1; n <= topN; n++) { log.AppendLine(Utils.PrintValue("NCDG@" + n, NCDG.Evaluate(RelevantItemsByUser, topNItemsByUser_expectations, n).ToString("0.0000"))); } for (int n = 1; n <= topN; n++) { log.AppendLine(Utils.PrintValue("MAP@" + n, MAP.Evaluate(RelevantItemsByUser, topNItemsByUser_expectations, n).ToString("0.0000"))); } return(log.ToString()); }
public override string GetEngineValues(string format, IFormatProvider provider, string delimeter) { string buf; buf = PowerAvailable.ToString(format, provider) + delimeter + HP.ToString(format, provider) + delimeter + equivalence_ratio.ToString(format, provider) + delimeter + MAP.ToString(format, provider) + delimeter + thruster.GetThrusterValues(engineNumber, delimeter); return(buf); }
MAP CreateTestMap(out byte[] bitmap) { var map = new MAP(this._palette, TEST_WIDTH, TEST_HEIGHT); bitmap = new byte[map.Count]; this.Random.NextBytes(bitmap); map.SetBitmapArray(bitmap); return(map); }
public void CreateDefaultInstance() { var map = new MAP(this._palette, TEST_WIDTH, TEST_HEIGHT); Assert.AreEqual(TEST_WIDTH, map.Width); Assert.AreEqual(TEST_HEIGHT, map.Height); Assert.AreEqual(MAP.MIN_GRAPH_ID, map.GraphId); Assert.IsTrue(string.IsNullOrEmpty(map.Description)); Assert.IsTrue(map.ControlPoints.Count == 0); }
private static bool ProcessDictionary(Type type, MAP dict, out object instance) { if (!TryCreateInstance <Object>(type, out instance)) { return(false); } ProcessDictionary(instance, type, dict); return(true); }
public void ContainsMap() { var pal = new PAL(this.GetAssetPath(SharedConstants.FILENAME_PAL_SPACE)); var map = new MAP(this.GetAssetPath(SharedConstants.FILENAME_IMG_PLAYER_MAP)); var fpg = new FPG(pal); fpg.Add(map); Assert.IsTrue(fpg.Contains(map)); }
public void FailContainsMap() { var pal = new PAL(this.GetAssetPath(SharedConstants.FILENAME_PAL_DIV)); var map = new MAP(this.GetAssetPath(SharedConstants.FILENAME_IMG_PLAYER_MAP)); var fpg = new FPG(pal); fpg.Add(map); // Force palette conversion. Assert.IsFalse(fpg.Contains(map)); }
public void DoThing() { MAP m = new MAP(); m.HEXES.Add(new HEX()); }
public static extern int FoldString( MAP dwMapFlags, [In] [MarshalAs(UnmanagedType.LPTStr)] string lpSrcStr, int cchSrc, [Out] [MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpDestStr, int cchDest);