public void UnRegisterValueChange(int propCal, ValueChangedDelegate act) { if (_calDict.ContainsKey(propCal)) { _calDict[(int)propCal].UnRegisterValueChange(act); } }
public Level(float frequency, int k, int index , ValueChangedDelegate valueChanged = null) { this.Index = index; K = k; this.Frequency = frequency; ValueChanged = valueChanged; }
public void RemoveValueChangeListener(string key, ValueChangedDelegate callback) { if (valueChangeListeners.ContainsKey(key)) { valueChangeListeners[key].Remove(callback); } }
public void AddValueChangeListener(string key, ValueChangedDelegate callback) { if (valueChangeListeners.ContainsKey(key) == false) { valueChangeListeners.Add(key, new List <ValueChangedDelegate>()); } valueChangeListeners[key].Add(callback); }
protected virtual void NotifyPropertyChanged <T>(T value, ValueChangedDelegate <T> valueChangedDelegate, [CallerMemberName] String propertyName = "") { NotifyPropertyChanged(propertyName); if (DisableCallbacks == false) { valueChangedDelegate?.Invoke(value); } }
public void RegisterValueChange(int propCal, ValueChangedDelegate act) { var cal = GetCal(propCal); if (cal != null) { cal.RegisterValueChange(act); } }
protected virtual void SetAndNotify <T>(ref T variable, T newValue, ValueChangedDelegate <T> valueChangedDelegate = null, [CallerMemberName] String propertyName = "") { variable = newValue; NotifyPropertyChanged(propertyName); if (DisableCallbacks == false) { valueChangedDelegate?.Invoke(newValue); } }
public void AddListener(ValueChangedDelegate valueChangedDelegate) { if (OnValueChanged == null) { OnValueChanged += valueChangedDelegate; } else { Debug.LogErrorFormat("已经存在该类型:{0} 绑定的回调函数", valueChangedDelegate.GetType()); } }
public void RemoveListener(ValueChangedDelegate valueChangedDelegate) { if (OnValueChanged != null) { if (OnValueChanged.GetType() != valueChangedDelegate.GetType()) { Debug.LogErrorFormat("RemoveListener(): {0} != {1} ", OnValueChanged.GetType(), valueChangedDelegate.GetType()); return; } OnValueChanged -= valueChangedDelegate; } }
protected override void LoadDefaultSettings(Settings settings) { brushes = new Hashtable(); ValueChangedDelegate bc = new ValueChangedDelegate(brushChanged); foreach(string s in Enum.GetNames(typeof(SpecialType))) { brushes[s]=new SolidBrush(TilePanel.tileTypes[(int)Enum.Parse(typeof(SpecialType),s)]); settings.AddSetting(s,((SolidBrush)brushes[s]).Color,"Color of specified tile type","TileView",bc,false,null); } TilePanel.Colors=brushes; }
public override void LoadDefaultSettings() { brushes = new Hashtable(); ValueChangedDelegate bc = BrushChanged; var settings = Settings; foreach (string s in Enum.GetNames(typeof(SpecialType))) { brushes[s] = new SolidBrush(TilePanel.tileTypes[(int)Enum.Parse(typeof(SpecialType), s)]); settings.AddSetting( s, ((SolidBrush)brushes[s]).Color, "Color of specified tile type", "TileView", bc, false, null); } VolutarSettingService.LoadDefaultSettings(settings); TilePanel.Colors = brushes; }
/// <summary> /// adds a setting to this settings object /// </summary> /// <param name="name">property name</param> /// <param name="val">start value of the property</param> /// <param name="desc">property description</param> /// <param name="category">property category</param> /// <param name="update">event handler to recieve the PropertyValueChanged event</param> /// <param name="reflect">if true, an internal event handler will be created - the refObj must not be null and the name must be the name of a property of the type that refObj is</param> /// <param name="refObj">the object that will recieve the changed property values</param> public void AddSetting( string name, object val, string desc, string category, ValueChangedDelegate update, bool reflect, object refObj) { name = name.Replace(" ", ""); // take out all spaces Setting setting; if (!settings.ContainsKey(name)) { setting = new Setting(val, desc, category); settings[name] = setting; } else { setting = settings[name]; setting.Value = val; setting.Description = desc; } if (update != null) { setting.ValueChanged += update; } if (reflect && refObj != null) { propObj[name] = new PropObj(refObj, name); this[name].ValueChanged += reflectEvent; } }
public void OnValueChanged(ValueChangedDelegate callback) { this.OnValueChangedDelegate += callback; }
public IntSlider(int step, int min, int max, int value, ValueChangedDelegate changedDelegate = null) { state = new SliderState <int>(step, min, max, value); state.OnChanged = changedDelegate; }
public DoubleSlider(double step, double min, double max, double value, ValueChangedDelegate changedDelegate = null) { state = new SliderState <double>(step, min, max, value); state.OnChanged = changedDelegate; }
public override void LoadDefaultSettings() { var settings = Settings; _brushes = new Dictionary <string, SolidBrush>(); _pens = new Dictionary <string, Pen>(); _brushes.Add("GroundColor", new SolidBrush(Color.Orange)); _brushes.Add("ContentColor", new SolidBrush(Color.Green)); _brushes.Add("SelectTileColor", bottom.SelectColor); var northPen = new Pen(new SolidBrush(Color.Red), 4); _pens.Add("NorthColor", northPen); _pens.Add("NorthWidth", northPen); var westPen = new Pen(new SolidBrush(Color.Red), 4); _pens.Add("WestColor", westPen); _pens.Add("WestWidth", westPen); var selPen = new Pen(new SolidBrush(Color.Black), 2); _pens.Add("SelectColor", selPen); _pens.Add("SelectWidth", selPen); var gridPen = new Pen(new SolidBrush(Color.Black), 1); _pens.Add("GridColor", gridPen); _pens.Add("GridWidth", gridPen); var mousePen = new Pen(new SolidBrush(Color.Blue), 2); _pens.Add("MouseColor", mousePen); _pens.Add("MouseWidth", mousePen); ValueChangedDelegate bc = BrushChanged; ValueChangedDelegate pc = PenColorChanged; ValueChangedDelegate pw = PenWidthChanged; ValueChangedDelegate dh = DiamondHeight; settings.AddSetting("GroundColor", Color.Orange, "Color of the ground tile indicator", "Tile", bc, false, null); settings.AddSetting("NorthColor", Color.Red, "Color of the north tile indicator", "Tile", pc, false, null); settings.AddSetting("WestColor", Color.Red, "Color of the west tile indicator", "Tile", pc, false, null); settings.AddSetting("ContentColor", Color.Green, "Color of the content tile indicator", "Tile", bc, false, null); settings.AddSetting("NorthWidth", 4, "Width of the north tile indicator in pixels", "Tile", pw, false, null); settings.AddSetting("WestWidth", 4, "Width of the west tile indicator in pixels", "Tile", pw, false, null); settings.AddSetting("SelectColor", Color.Black, "Color of the selection line", "Select", pc, false, null); settings.AddSetting("SelectWidth", 2, "Width of the selection line in pixels", "Select", pw, false, null); settings.AddSetting("GridColor", Color.Black, "Color of the grid lines", "Grid", pc, false, null); settings.AddSetting("GridWidth", 1, "Width of the grid lines", "Grid", pw, false, null); settings.AddSetting("MouseWidth", 2, "Width of the mouse-over indicator", "Grid", pw, false, null); settings.AddSetting("MouseColor", Color.Blue, "Color of the mouse-over indicator", "Grid", pc, false, null); settings.AddSetting("SelectTileColor", Color.LightBlue, "Background color of the selected tile part", "Other", bc, false, null); settings.AddSetting("DiamondMinHeight", _topViewPanel.MinHeight, "Minimum height of the grid tiles", "Tile", dh, false, null); _topViewPanel.Brushes = _brushes; _topViewPanel.Pens = _pens; bottom.Brushes = _brushes; bottom.Pens = _pens; Invalidate(); }
public override void LoadDefaultSettings() { var brushes = _rmpPanel.MapBrushes; var pens = _rmpPanel.MapPens; var bc = new ValueChangedDelegate(BrushChanged); var pc = new ValueChangedDelegate(PenColorChanged); var pw = new ValueChangedDelegate(PenWidthChanged); var settings = Settings; var redPen = new Pen(new SolidBrush(Color.Red), 2); pens["UnselectedLinkColor"] = redPen; pens["UnselectedLinkWidth"] = redPen; settings.AddSetting( "UnselectedLinkColor", redPen.Color, "Color of unselected link lines", "Links", pc, false, null); settings.AddSetting( "UnselectedLinkWidth", 2, "Width of unselected link lines", "Links", pw, false, null); var bluePen = new Pen(new SolidBrush(Color.Blue), 2); pens["SelectedLinkColor"] = bluePen; pens["SelectedLinkWidth"] = bluePen; settings.AddSetting( "SelectedLinkColor", bluePen.Color, "Color of selected link lines", "Links", pc, false, null); settings.AddSetting( "SelectedLinkWidth", 2, "Width of selected link lines", "Links", pw, false, null); var wallPen = new Pen(new SolidBrush(Color.Black), 4); pens["WallColor"] = wallPen; pens["WallWidth"] = wallPen; settings.AddSetting( "WallColor", wallPen.Color, "Color of wall indicators", "View", pc, false, null); settings.AddSetting( "WallWidth", 4, "Width of wall indicators", "View", pw, false, null); var gridPen = new Pen(new SolidBrush(Color.Black), 1); pens["GridLineColor"] = gridPen; pens["GridLineWidth"] = gridPen; settings.AddSetting( "GridLineColor", gridPen.Color, "Color of grid lines", "View", pc, false, null); settings.AddSetting( "GridLineWidth", 1, "Width of grid lines", "View", pw, false, null); var selBrush = new SolidBrush(Color.Blue); brushes["SelectedNodeColor"] = selBrush; settings.AddSetting( "SelectedNodeColor", selBrush.Color, "Color of selected nodes", "Nodes", bc, false, null); var spawnBrush = new SolidBrush(Color.GreenYellow); brushes["SpawnNodeColor"] = spawnBrush; settings.AddSetting( "SpawnNodeColor", spawnBrush.Color, "Color of spawn nodes", "Nodes", bc, false, null); var nodeBrush = new SolidBrush(Color.Green); brushes["UnselectedNodeColor"] = nodeBrush; settings.AddSetting( "UnselectedNodeColor", nodeBrush.Color, "Color of unselected nodes", "Nodes", bc, false, null); var contentBrush = new SolidBrush(Color.DarkGray); brushes["ContentTiles"] = contentBrush; settings.AddSetting( "ContentTiles", contentBrush.Color, "Color of map tiles with a content tile", "Other", bc, false, null); connectNodesToolStripMenuItem.SelectedIndex = 0; }
private void loadDefaults() { RegistryKey swKey = Registry.CurrentUser.CreateSubKey("Software"); RegistryKey mvKey = swKey.CreateSubKey("MapView"); RegistryKey riKey = mvKey.CreateSubKey("MainView"); Left = (int)riKey.GetValue("Left", Left); Top = (int)riKey.GetValue("Top", Top); Width = (int)riKey.GetValue("Width", Width); Height = (int)riKey.GetValue("Height", Height); riKey.Close(); mvKey.Close(); swKey.Close(); var settings = new Settings(); // Color.FromArgb(175, 69, 100, 129) var eh = new ValueChangedDelegate(ChangeSetting); settings.AddSetting( "Animation", MapViewPanel.Updating, "If true the map will animate itself", "Main", eh, false, null); settings.AddSetting( "Doors", false, "If true the door tiles will animate themselves", "Main", eh, false, null); settings.AddSetting( "SaveWindowPositions", PathsEditor.SaveRegistry, "If true the window positions and sizes will be saved in the windows registry", "Main", eh, false, null); settings.AddSetting( "UseGrid", MapViewPanel.Instance.MapView.UseGrid, "If true a grid will show up at the current level of editing", "MapView", null, true, MapViewPanel.Instance.MapView); settings.AddSetting( "GridColor", MapViewPanel.Instance.MapView.GridColor, "Color of the grid in (a,r,g,b) format", "MapView", null, true, MapViewPanel.Instance.MapView); settings.AddSetting( "GridLineColor", MapViewPanel.Instance.MapView.GridLineColor, "Color of the lines that make up the grid", "MapView", null, true, MapViewPanel.Instance.MapView); settings.AddSetting( "GridLineWidth", MapViewPanel.Instance.MapView.GridLineWidth, "Width of the grid lines in pixels", "MapView", null, true, MapViewPanel.Instance.MapView); settings.AddSetting( "SelectGrayscale", MapViewPanel.Instance.MapView.SelectGrayscale, "If true the selection area will show up in gray", "MapView", null, true, MapViewPanel.Instance.MapView); // settings.AddSetting( // "SaveOnExit", // true, // "If true these settings will be saved on program exit", // "Main", // null, false, null); SetSettings(settings); }
public void UnRegisterValueChange(ValueChangedDelegate action) { onValueChanged -= action; }
public void ClearDelegates() { this.OnSetValueDelegate = null; this.OnValueChangedDelegate = null; }
protected override void LoadDefaultSettings(Settings settings) { //RegistryKey swKey = Registry.CurrentUser.CreateSubKey("Software"); //RegistryKey mvKey = swKey.CreateSubKey("MapView"); //RegistryKey riKey = mvKey.CreateSubKey("TopView"); //foreach (MenuItem mi in visibleHash.Keys) // mi.Checked = bool.Parse((string)riKey.GetValue("vis" + visibleHash[mi].ToString(), "true")); //riKey.Close(); //mvKey.Close(); //swKey.Close(); brushes = new Dictionary<string, SolidBrush>(); pens = new Dictionary<string, Pen>(); brushes.Add("GroundColor", new SolidBrush(Color.Orange)); brushes.Add("ContentColor", new SolidBrush(Color.Green)); brushes.Add("SelectTileColor", bottom.SelectColor); Pen northPen = new Pen(new SolidBrush(Color.Red), 4); pens.Add("NorthColor", northPen); pens.Add("NorthWidth", northPen); Pen westPen = new Pen(new SolidBrush(Color.Red), 4); pens.Add("WestColor", westPen); pens.Add("WestWidth", westPen); Pen selPen = new Pen(new SolidBrush(Color.Black), 2); pens.Add("SelectColor", selPen); pens.Add("SelectWidth", selPen); Pen gridPen = new Pen(new SolidBrush(Color.Black), 1); pens.Add("GridColor", gridPen); pens.Add("GridWidth", gridPen); Pen mousePen = new Pen(new SolidBrush(Color.Blue), 2); pens.Add("MouseColor", mousePen); pens.Add("MouseWidth", mousePen); ValueChangedDelegate bc = new ValueChangedDelegate(brushChanged); ValueChangedDelegate pc = new ValueChangedDelegate(penColorChanged); ValueChangedDelegate pw = new ValueChangedDelegate(penWidthChanged); ValueChangedDelegate dh = new ValueChangedDelegate(diamondHeight); settings.AddSetting("GroundColor", Color.Orange, "Color of the ground tile indicator", "Tile", bc, false, null); settings.AddSetting("NorthColor", Color.Red, "Color of the north tile indicator", "Tile", pc, false, null); settings.AddSetting("WestColor", Color.Red, "Color of the west tile indicator", "Tile", pc, false, null); settings.AddSetting("ContentColor", Color.Green, "Color of the content tile indicator", "Tile", bc, false, null); settings.AddSetting("NorthWidth", 4, "Width of the north tile indicator in pixels", "Tile", pw, false, null); settings.AddSetting("WestWidth", 4, "Width of the west tile indicator in pixels", "Tile", pw, false, null); settings.AddSetting("SelectColor", Color.Black, "Color of the selection line", "Select", pc, false, null); settings.AddSetting("SelectWidth", 2, "Width of the selection line in pixels", "Select", pw, false, null); settings.AddSetting("GridColor", Color.Black, "Color of the grid lines", "Grid", pc, false, null); settings.AddSetting("GridWidth", 1, "Width of the grid lines", "Grid", pw, false, null); settings.AddSetting("MouseWidth", 2, "Width of the mouse-over indicatior", "Grid", pw, false, null); settings.AddSetting("MouseColor", Color.Blue, "Color of the mouse-over indicator", "Grid", pc, false, null); settings.AddSetting("SelectTileColor", Color.Lavender, "Background color of the selected tile piece", "Other", bc, false, null); settings.AddSetting("DiamondMinHeight", topViewPanel.MinHeight, "Minimum height of the grid tiles", "Tile", dh, false, null); topViewPanel.Brushes = brushes; topViewPanel.Pens = pens; bottom.Brushes = brushes; bottom.Pens = pens; }
/// <summary> /// adds a setting to this settings object /// </summary> /// <param name="name">property name</param> /// <param name="val">start value of the property</param> /// <param name="desc">property description</param> /// <param name="category">property category</param> /// <param name="eh">event handler to recieve the PropertyValueChanged event</param> /// <param name="reflect">if true, an internal event handler will be created - the refObj must not be null and the name must be the name of a property of the type that refObj is</param> /// <param name="refObj">the object that will recieve the changed property values</param> public void AddSetting(string name,object val,string desc,string category,ValueChangedDelegate eh, bool reflect,object refObj) { //take out all spaces name = name.Replace(" ",""); settings[name]=new Setting(val,desc,category,eh); if(reflect && refObj!=null) { propObj[name]=new PropObj(refObj,name); this[name].ValueChanged+=new ValueChangedDelegate(reflectEvent); } }
private void loadDefaults() { RegistryKey swKey = Registry.CurrentUser.CreateSubKey("Software"); RegistryKey mvKey = swKey.CreateSubKey("MapView"); RegistryKey riKey = mvKey.CreateSubKey("MainView"); Left = (int)riKey.GetValue("Left", Left); Top = (int)riKey.GetValue("Top", Top); Width = (int)riKey.GetValue("Width", Width); Height = (int)riKey.GetValue("Height", Height); riKey.Close(); mvKey.Close(); swKey.Close(); Settings settings = new Settings(); //Color.FromArgb(175,69,100,129) ValueChangedDelegate eh = new ValueChangedDelegate(changeSetting); settings.AddSetting("Animation", MapViewPanel.Updating, "If true, the map will animate itself", "Main", eh, false, null); settings.AddSetting("Doors", false, "If true, the door tiles will animate themselves", "Main", eh, false, null); settings.AddSetting("SaveWindowPositions", PathsEditor.SaveRegistry, "If true, the window positions and sizes will be saved in the windows registry", "Main", eh, false, null); settings.AddSetting("UseGrid", MapViewPanel.Instance.View.UseGrid, "If true, a grid will show up at the current level of editing", "MapView", null, true, MapViewPanel.Instance.View); settings.AddSetting("GridColor", MapViewPanel.Instance.View.GridColor, "Color of the grid in (a,r,g,b) format", "MapView", null, true, MapViewPanel.Instance.View); settings.AddSetting("GridLineColor", MapViewPanel.Instance.View.GridLineColor, "Color of the lines that make up the grid", "MapView", null, true, MapViewPanel.Instance.View); settings.AddSetting("GridLineWidth", MapViewPanel.Instance.View.GridLineWidth, "Width of the grid lines in pixels", "MapView", null, true, MapViewPanel.Instance.View); settings.AddSetting("SelectGrayscale", MapViewPanel.Instance.View.SelectGrayscale, "If true, the selection area will show up in gray", "MapView", null, true, MapViewPanel.Instance.View); //settings.AddSetting("SaveOnExit",true,"If true, these settings will be saved on program exit","Main",null,false,null); settingsHash["MainWindow"] = settings; }
public Setting(object val,string desc,string category,ValueChangedDelegate update) { this.val=val; this.desc=desc; this.category=category; if(update!=null) ValueChanged+=update; if(converters==null) { converters = new Dictionary<Type,parseString>(); converters[typeof(int)]=new parseString(parseIntString); converters[typeof(System.Drawing.Color)]=new parseString(parseColorString); converters[typeof(bool)]=new parseString(parseBoolString); } }
protected virtual void SetAndNotifyWhenChanged <T>(ref T variable, T newValue, ValueChangedDelegate <T> valueChangedDelegate = null, [CallerMemberName] String propertyName = "") { if (EqualityComparer <T> .Default.Equals(variable, newValue)) { return; } variable = newValue; NotifyPropertyChanged(propertyName); if (DisableCallbacks == false) { valueChangedDelegate?.Invoke(newValue); } }
//private void loadDefaults() protected override void LoadDefaultSettings(Settings settings) { Dictionary<string, SolidBrush> brushes = rmpPanel.Brushes; Dictionary<string, Pen> pens = rmpPanel.Pens; ValueChangedDelegate bc = new ValueChangedDelegate(brushChanged); ValueChangedDelegate pc = new ValueChangedDelegate(penColorChanged); ValueChangedDelegate pw = new ValueChangedDelegate(penWidthChanged); Pen redPen = new Pen(new SolidBrush(Color.Red), 2); pens["UnselectedLinkColor"] = redPen; pens["UnselectedLinkWidth"] = redPen; settings.AddSetting("UnselectedLinkColor", redPen.Color, "Color of unselected link lines", "Links", pc, false, null); settings.AddSetting("UnselectedLinkWidth", 2, "Width of unselected link lines", "Links", pw, false, null); Pen bluePen = new Pen(new SolidBrush(Color.Blue), 2); pens["SelectedLinkColor"] = bluePen; pens["SelectedLinkWidth"] = bluePen; settings.AddSetting("SelectedLinkColor", bluePen.Color, "Color of selected link lines", "Links", pc, false, null); settings.AddSetting("SelectedLinkWidth", 2, "Width of selected link lines", "Links", pw, false, null); Pen wallPen = new Pen(new SolidBrush(Color.Black), 4); pens["WallColor"] = wallPen; pens["WallWidth"] = wallPen; settings.AddSetting("WallColor", wallPen.Color, "Color of wall indicators", "View", pc, false, null); settings.AddSetting("WallWidth", 4, "Width of wall indicators", "View", pw, false, null); Pen gridPen = new Pen(new SolidBrush(Color.Black), 1); pens["GridLineColor"] = gridPen; pens["GridLineWidth"] = gridPen; settings.AddSetting("GridLineColor", gridPen.Color, "Color of grid lines", "View", pc, false, null); settings.AddSetting("GridLineWidth", 1, "Width of grid lines", "View", pw, false, null); SolidBrush selBrush = new SolidBrush(Color.Blue); brushes["SelectedNodeColor"] = selBrush; settings.AddSetting("SelectedNodeColor", selBrush.Color, "Color of selected nodes", "Nodes", bc, false, null); SolidBrush spawnBrush = new SolidBrush(Color.GreenYellow); brushes["SpawnNodeColor"] = spawnBrush; settings.AddSetting("SpawnNodeColor", spawnBrush.Color, "Color of spawn nodes", "Nodes", bc, false, null); SolidBrush nodeBrush = new SolidBrush(Color.Green); brushes["UnselectedNodeColor"] = nodeBrush; settings.AddSetting("UnselectedNodeColor", nodeBrush.Color, "Color of unselected nodes", "Nodes", bc, false, null); SolidBrush contentBrush = new SolidBrush(Color.DarkGray); brushes["ContentTiles"] = contentBrush; settings.AddSetting("ContentTiles", contentBrush.Color, "Color of map tiles with a content tile", "Other", bc, false, null); }