Exemplo n.º 1
0
        private void SetupLineRightClickOptions(PropertyTree tree)
        {
            var vec   = _ownerline.GetVector();
            var len   = vec.Length;
            var angle = Angle.FromVector(vec);

            angle.Degrees += 90;

            var lineProp = tree.Add("Line Properties", 120);

            if (_ownerline.Type != LineType.Scenery)
            {
                var id = new NumberProperty(lineProp)
                {
                    Min              = 0,
                    Max              = int.MaxValue - 1,
                    NumberValue      = _ownerline.ID,
                    OnlyWholeNumbers = true,
                    IsDisabled       = true
                };
                id.ValueChanged += (o, e) =>
                {
                    ChangeID((int)id.NumberValue); //TODO: Add the ability to change line IDs
                };
                lineProp.Add("ID", id);
            }

            length = new NumberProperty(lineProp)
            {
                Min         = 0.0000001,
                Max         = double.MaxValue - 1,
                NumberValue = len,
            };
            length.ValueChanged += (o, e) =>
            {
                ChangeLength(length.NumberValue);
            };
            lineProp.Add("Length", length);

            angleProp = new NumberProperty(lineProp)
            {
                Min         = double.MinValue,
                Max         = double.MaxValue,
                NumberValue = angle.Degrees,
            };
            angleProp.ValueChanged += (o, e) =>
            {
                ChangeAngle(angleProp.NumberValue);
            };
            lineProp.Add("Angle", angleProp);

            if (_ownerline.Type != LineType.Scenery)
            {
                SetupBlueAndRedOptions(tree);
            }
            else
            {
                SetupSceneryOptions(tree, lineProp);
            }
        }
Exemplo n.º 2
0
        public override IEnumerator Execute(GameObject target, IAction[] actions, int index)
        {
            if (this.canvasGroup != null)
            {
                this.canvasGroup.interactable   = this.interactible.GetValue(target);
                this.canvasGroup.blocksRaycasts = this.blockRaycasts.GetValue(target);
                float targetAlpha = this.alpha.GetValue(target);

                if (this.duration > 0.0f)
                {
                    float currentAlpha = this.canvasGroup.alpha;
                    float startTime    = Time.unscaledTime;

                    WaitUntil waitUntil = new WaitUntil(() =>
                    {
                        float t = (Time.unscaledTime - startTime) / this.duration;
                        this.canvasGroup.alpha = Mathf.Lerp(
                            currentAlpha,
                            targetAlpha,
                            t
                            );

                        return(t > 1.0f);
                    });

                    yield return(waitUntil);
                }

                this.canvasGroup.alpha = targetAlpha;
            }

            yield return(0);
        }
    public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
    {
        var          token = JToken.Load(reader);
        var          name  = token["NameProperty"].ToString();
        PropertyBase prop  = null;

        // by example, it is up to you how you
        // create an instance of PropertyBase
        switch (name)
        {
        case "string": prop = new StringProperty();
            break;

        case "number": prop = new NumberProperty();
            break;

        case "array": prop = new ArrayProperty();
            break;
        }
        var ex = new ExampleModel
        {
            DifferentProperty = prop
        };

        serializer.Populate(reader, ex);
        return(ex);
    }
Exemplo n.º 4
0
 public void SyncToCoordinates(double RightAscension, double Declination)
 {
     if (AtPark)
     {
         throw new ASCOM.InvalidOperationException("SyncToCoordinates - Parked");
     }
     if ((RightAscension < 0) | (RightAscension > 24))
     {
         throw new InvalidValueException("RightAscension", RightAscension.ToString(), "0 to 24");
     }
     if ((Declination < -90) | (Declination > 90))
     {
         throw new InvalidValueException("Declination", RightAscension.ToString(), "-90 to 90");
     }
     TargetRightAscension = RightAscension;
     TargetDeclination    = Declination;
     if (IsConnected)
     {
         SwitchProperty OnCoordSetProperty = (SwitchProperty)device.GetProperty("MOUNT_ON_COORDINATES_SET");
         if (OnCoordSetProperty != null)
         {
             OnCoordSetProperty.SetSingleValue("SYNC", true);
             NumberProperty MountEquatorialProperty = (NumberProperty)device.GetProperty("MOUNT_EQUATORIAL_COORDINATES");
             if (MountEquatorialProperty != null)
             {
                 MountEquatorialProperty.SetSingleValue("RA", RightAscension);
                 MountEquatorialProperty.SetSingleValue("DEC", Declination);
                 return;
             }
             throw new ASCOM.InvalidOperationException("SyncToCoordinates - missing MOUNT_EQUATORIAL_COORDINATES property");
         }
         throw new ASCOM.InvalidOperationException("SyncToCoordinates - missing MOUNT_ON_COORDINATES_SET property");
     }
     throw new ASCOM.InvalidOperationException("SyncToCoordinates - not connected");
 }
Exemplo n.º 5
0
        private void SetupRedOptions(PropertyTree tree)
        {
            if (_ownerline is RedLine red)
            {
                var table      = tree.Add("Acceleration", 120);
                var multiplier = new NumberProperty(table)
                {
                    Min              = 1,
                    Max              = 255,
                    NumberValue      = red.Multiplier,
                    OnlyWholeNumbers = true,
                };
                multiplier.ValueChanged += (o, e) =>
                {
                    ChangeMultiplier((int)multiplier.NumberValue);
                };
                table.Add("Multiplier", multiplier);
                var multilines = new NumberProperty(table)
                {
                    Min = 1,
                    Max = 9999,
                    OnlyWholeNumbers = true,
                };
                multilines.NumberValue   = GetMultiLines(true).Count;
                multilines.ValueChanged += (o, e) =>
                {
                    Multiline((int)multilines.NumberValue);
                };
                table.Add("Multilines", multilines);

                var accelinverse = GwenHelper.AddPropertyCheckbox(
                    table,
                    "Inverse",
                    red.inv
                    );
                accelinverse.ValueChanged += (o, e) =>
                {
                    using (var trk = _editor.CreateTrackWriter())
                    {
                        var multi = GetMultiLines(false);
                        foreach (var l in multi)
                        {
                            var cpy = (StandardLine)l.Clone();
                            cpy.Position  = l.Position2;
                            cpy.Position2 = l.Position;
                            cpy.inv       = accelinverse.IsChecked;
                            UpdateLine(trk, l, cpy);
                        }

                        var owner = (StandardLine)_ownerline.Clone();
                        owner.Position  = _ownerline.Position2;
                        owner.Position2 = _ownerline.Position;
                        owner.inv       = accelinverse.IsChecked;
                        UpdateOwnerLine(trk, owner);
                    }
                };
            }
        }
Exemplo n.º 6
0
        private void Setup()
        {
            Dictionary <string, bool> trackfeatures;

            using (var trk = _editor.CreateTrackReader())
            {
                trackfeatures = trk.GetFeatures();
            }
            TabControl tabs = new TabControl(this)
            {
                Dock = Dock.Fill
            };
            var settings = tabs.AddPage("Settings");
            var song     = tabs.AddPage("Song");

            _tree = new PropertyTree(settings)
            {
                Dock = Dock.Fill,
            };
            var            table     = _tree.Add("Settings", 150);
            NumberProperty startzoom = new NumberProperty(null)
            {
                Min         = 1,
                NumberValue = _editor.StartZoom,
                Max         = Constants.MaxZoom,
            };

            startzoom.ValueChanged += (o, e) =>
            {
                _editor.StartZoom = (float)startzoom.NumberValue;
            };
            table.Add("Start Zoom", startzoom);
            var zerostart = GwenHelper.AddPropertyCheckbox(table, "Zero Start", _editor.ZeroStart);

            zerostart.ValueChanged += (o, e) =>
            {
                _editor.ZeroStart = zerostart.IsChecked;
            };
            table = _tree.Add("Info", 150);

            // var trackname = table.AddLabel("Track Name", _editor.Name);
            var physics = table.AddLabel("Physics", CheckFeature(trackfeatures, TrackFeatures.six_one) ? "6.1" : "6.2");

            table.AddLabel("Blue Lines", _editor.BlueLines.ToString());
            table.AddLabel("Red Lines", _editor.RedLines.ToString());
            table.AddLabel("Scenery Lines", _editor.GreenLines.ToString());
            table = _tree.Add("Features Used", 150);

            AddFeature(table, trackfeatures, "Red Multiplier", TrackFeatures.redmultiplier);
            AddFeature(table, trackfeatures, "Scenery Width", TrackFeatures.scenerywidth);
            AddFeature(table, trackfeatures, "Line Triggers", TrackFeatures.ignorable_trigger);

            PopulateSong(song);
            _tree.ExpandAll();
            // table.Add
        }
Exemplo n.º 7
0
        public override object Unpack(Property property)
        {
            NumberProperty np = property as NumberProperty;

            if (np == null)
            {
                return(0f);
            }
            return(MathEx.DegToRad(np.Value));
        }
Exemplo n.º 8
0
        public void ModifyNumberSame()
        {
            NumberProperty prop = new NumberProperty("test", 12.5f);

            AttachEvents(prop);

            prop.Value = 12.5f;

            Assert.AreEqual(EventFlags.None, _eventsFired);
        }
Exemplo n.º 9
0
        private static object UnpackNumber(Property property)
        {
            NumberProperty p = property as NumberProperty;

            if (p != null)
            {
                return(p.Value);
            }

            return(null);
        }
Exemplo n.º 10
0
        // EXECUTABLE: ----------------------------------------------------------------------------

        public override bool InstantExecute(GameObject target, IAction[] actions, int index)
        {
            if (this.duration <= 0.0f)
            {
                this.canvasGroup.alpha        = this.alpha.GetValue();
                this.canvasGroup.interactable = this.interactible.GetValue();
                return(true);
            }

            return(false);
        }
Exemplo n.º 11
0
        private void SetupSceneryOptions(PropertyTree tree, PropertyTable lineProp)
        {
            var width = new NumberProperty(lineProp)
            {
                Min         = 0.1,
                Max         = 25.5,
                NumberValue = _ownerline.Width,
            };

            width.ValueChanged += (o, e) =>
            {
                ChangeWidth(width.NumberValue);
            };
            lineProp.Add("Width", width);
        }
Exemplo n.º 12
0
        public void CopyConstructNumber()
        {
            NumberProperty prop = new NumberProperty("test", 12.5f);

            AttachEvents(prop);

            NumberProperty prop2 = new NumberProperty("new", prop);

            Assert.AreEqual("new", prop2.Name);
            Assert.AreEqual(prop.Value, prop2.Value);

            // Make sure events were not cloned.
            prop2.Name  = "test2";
            prop2.Value = 55f;
            Assert.AreEqual(EventFlags.None, _eventsFired);
        }
Exemplo n.º 13
0
        public void ParseNumber()
        {
            Property prop = new NumberProperty("test", 12.5f);

            AttachEvents(prop);

            prop.ValueChanged += (s, e) =>
            {
                Assert.AreSame(prop, s);
                Assert.AreEqual(55.5f, ((NumberProperty)prop).Value);
            };

            prop.Parse("55.5");

            Assert.AreEqual(55.5f, ((NumberProperty)prop).Value);
            Assert.AreEqual(EventFlags.ValueChanged | EventFlags.Modified, _eventsFired);
        }
Exemplo n.º 14
0
        public void ModifyNumber()
        {
            NumberProperty prop = new NumberProperty("test", 12.5f);

            AttachEvents(prop);

            prop.ValueChanged += (s, e) =>
            {
                Assert.AreSame(prop, s);
                Assert.AreEqual(55, prop.Value);
            };

            prop.Value = 55;

            Assert.AreEqual(55, prop.Value);
            Assert.AreEqual(EventFlags.ValueChanged | EventFlags.Modified, _eventsFired);
        }
Exemplo n.º 15
0
        public void CloneNumber()
        {
            Property prop = new NumberProperty("test", 12.5f);

            AttachEvents(prop);

            Property prop2 = prop.Clone() as Property;

            NumberProperty sp1 = prop as NumberProperty;
            NumberProperty sp2 = prop2 as NumberProperty;

            Assert.AreEqual(sp1.Name, sp2.Name);
            Assert.AreEqual(sp1.Value, sp2.Value);

            // Make sure events were not cloned.
            sp2.Name  = "test2";
            sp2.Value = 55;
            Assert.AreEqual(EventFlags.None, _eventsFired);
        }
Exemplo n.º 16
0
 public override int GetHashCode()
 {
     unchecked
     {
         int result = Number.GetHashCode();
         result = (result * 397) ^ (Text != null ? Text.GetHashCode() : 0);
         result = (result * 397) ^ Color.GetHashCode();
         result = (result * 397) ^ (FloatArray != null ? FloatArray.GetHashCode() : 0);
         result = (result * 397) ^ (FloatList != null ? FloatList.GetHashCode() : 0);
         result = (result * 397) ^ Enum.GetHashCode();
         result = (result * 397) ^ (Null != null ? Null.GetHashCode() : 0);
         result = (result * 397) ^ Position.GetHashCode();
         result = (result * 397) ^ (NestedClass != null ? NestedClass.GetHashCode() : 0);
         result = (result * 397) ^ NumberProperty.GetHashCode();
         result = (result * 397) ^ NumberPropertyReadonly.GetHashCode();
         result = (result * 397) ^ privateField.GetHashCode();
         return(result);
     }
 }
Exemplo n.º 17
0
        // EXECUTABLE: ----------------------------------------------------------------------------

        public override bool InstantExecute(GameObject target, IAction[] actions, int index)
        {
            if (this.light != null)
            {
                if (this.changeRange)
                {
                    this.light.range = this.range.GetValue();
                }
                if (this.changeIntensity)
                {
                    this.light.intensity = this.intensity.GetValue();
                }
                if (this.changeColor)
                {
                    this.light.color = this.color.GetValue();
                }
            }

            return(true);
        }
Exemplo n.º 18
0
        private Control CreateNumericControl(ObjectData obj, Field field)
        {
            TextBoxNumber num = new TextBoxNumber();

            if (field.FieldType == FieldType.Rating)
            {
                num.DecimalPlaces = 1;
                num.Maximum       = 10;
            }
            else
            {
                NumberProperty prop = (NumberProperty)field.Data;
                num.DecimalPlaces = prop.DecimalPlaces;

                double d = decimal.ToDouble(decimal.MaxValue);
                d = Math.Sqrt(d);
                decimal dm = Convert.ToDecimal(d);
                num.Maximum            = prop.Bounds ? prop.Maximum : dm;
                num.Minimum            = prop.Bounds ? prop.Minimum : decimal.Negate(dm);
                num.Increment          = prop.Increment;
                num.ThousandsSeparator = prop.Thousands;
                num.Prefix             = prop.Prefix;
                num.Suffix             = prop.Suffix;
            }

            object val = obj[field];

            if (field.IsEmptyData(val))
            {
                num.Text = string.Empty;
            }
            else
            {
                num.Value = Convert.ToDecimal(obj[field]);
            }

            /*num.StateCommon.Border.Rounding = 4;
             * num.StateCommon.Border.Width = 2;*/
            return(num);
        }
Exemplo n.º 19
0
        private void InitTable(PropertyTable table)
        {
            table.Add("text", "textbox").Tooltip = "Heyy tooltip";
            LabelProperty lab = new LabelProperty(null)
            {
                Value = "Uneditable label",
            };

            table.Add("Label", lab);
            table.Add("check", new CheckProperty(null));
            var cb = new ComboBoxProperty(table);

            cb.AddItem("Test");
            cb.AddItem("auto selected");
            cb.AddItem("val 3");
            cb.SetValue("auto selected");
            table.Add("combo", cb);
            NumberProperty num = new NumberProperty(table)
            {
                Min = -10, Max = 10, Value = "3"
            };

            table.Add("Number:", num);
        }
Exemplo n.º 20
0
		public virtual void Visit(NumberProperty property) { }
Exemplo n.º 21
0
        public void NumberToString()
        {
            Property prop = new NumberProperty("test", 12.5f);

            Assert.AreEqual("12.5", prop.ToString());
        }
Exemplo n.º 22
0
        public void StartExposure(double Duration, bool Light)
        {
            if (Duration < 0.0)
            {
                throw new InvalidValueException("StartExposure", Duration.ToString(), "0.0 upwards");
            }
            if (frameWidth * horizontalBin > ccdWidth)
            {
                throw new InvalidValueException("StartExposure " + frameWidth + "*" + horizontalBin, frameWidth.ToString(), ccdWidth.ToString());
            }
            if (frameHeight * verticalBin > ccdHeight)
            {
                throw new InvalidValueException("StartExposure " + frameHeight + "*" + verticalBin, frameHeight.ToString(), ccdHeight.ToString());
            }
            if (frameLeft * horizontalBin > ccdWidth)
            {
                throw new InvalidValueException("StartExposure " + frameLeft + "*" + horizontalBin, frameLeft.ToString(), ccdWidth.ToString());
            }
            if (frameTop * verticalBin > ccdHeight)
            {
                throw new InvalidValueException("StartExposure " + frameHeight + "*" + verticalBin, frameTop.ToString(), ccdHeight.ToString());
            }
            exposureDuration = Duration;
            exposureStart    = DateTime.Now;
            cameraImageReady = false;
            firstExposure    = false;
            NumberProperty n = (NumberProperty)device.GetProperty("CCD_BIN");

            if (n != null)
            {
                ((NumberItem)n.GetItem("HORIZONTAL")).Value = horizontalBin;
                ((NumberItem)n.GetItem("VERTICAL")).Value   = verticalBin;
                n.Change();
            }
            n = (NumberProperty)device.GetProperty("CCD_FRAME");
            if (n != null)
            {
                ((NumberItem)n.GetItem("LEFT")).Value   = frameLeft * horizontalBin;
                ((NumberItem)n.GetItem("TOP")).Value    = frameTop * verticalBin;
                ((NumberItem)n.GetItem("WIDTH")).Value  = frameWidth * horizontalBin;
                ((NumberItem)n.GetItem("HEIGHT")).Value = frameHeight * verticalBin;
                n.Change();
            }
            if (hasGain)
            {
                n = (NumberProperty)device.GetProperty("CCD_GAIN");
                n.SetSingleValue("GAIN", gain);
            }
            SwitchProperty s = (SwitchProperty)device.GetProperty("CCD_FRAME_TYPE");

            if (s != null)
            {
                if (Light)
                {
                    s.SetSingleValue("LIGHT", true);
                }
                else
                {
                    s.SetSingleValue("DARK", true);
                }
            }
            s = (SwitchProperty)device.GetProperty("CCD_IMAGE_FORMAT");
            if (s != null)
            {
                s.SetSingleValue("RAW", true);
            }
            n           = (NumberProperty)device.GetProperty("CCD_EXPOSURE");
            cameraState = CameraStates.cameraExposing;
            n.SetSingleValue("EXPOSURE", Duration);
            while (cameraState == CameraStates.cameraExposing)
            {
                Thread.Sleep(100);
            }
        }
Exemplo n.º 23
0
 set => SetValue(NumberProperty, value);
Exemplo n.º 24
0
 public void Visit(NumberProperty mapping)
 {
     Increment("number");
 }
Exemplo n.º 25
0
 set => this.SetValue(NumberProperty, value);
Exemplo n.º 26
0
        private void DrawContent(Graphics g)
        {
            int   width_names  = this.GetWidthNames(g);
            SizeF sizeCategory = g.MeasureString(this.headerText, this.fontHeader);
            float y            = sizeCategory.Height + 14;

            foreach (Field field in this.values.Keys)
            {
                float x_name  = 3;
                float x_value = width_names + 11;
                int   h_value = this.GetHeightValue(g, field);
                if (!field.IsPageField)
                {
                    StringFormat format = new StringFormat();
                    format.LineAlignment = StringAlignment.Center;
                    g.DrawString(field.Name, this.fontName, this.textBrush, new RectangleF(x_name, y, width_names + 1, h_value), format);
                    int w_value = Width - 6 - width_names;
                    switch (field.FieldType)
                    {
                    case FieldType.Boolean:
                        g.DrawImage(Resources.tick, new PointF(x_value, y + (h_value - 16) / 2));
                        break;

                    case FieldType.Date:
                        DateTime     dt    = (DateTime)this.values[field];
                        DateProperty dprop = field.Data as DateProperty;
                        string       date_format;
                        if (dprop.ViewTime)
                        {
                            date_format = "d MMM yyy H:mm:ss";
                        }
                        else
                        {
                            date_format = "d MMM yyy";
                        }

                        g.DrawString(dt.ToString(date_format), this.fontValue, this.textBrush, new RectangleF(x_value, y, w_value, h_value), format);
                        break;

                    case FieldType.Select:
                        int           val = (int)this.values[field];
                        List <string> sc  = (List <string>)field.Data;
                        if (val < sc.Count)
                        {
                            g.DrawString(sc[val], this.fontValue, this.textBrush, new RectangleF(x_value, y, w_value, h_value), format);
                        }

                        break;

                    case FieldType.Rating:
                        this.DrawContentRaiting(g, (decimal)this.values[field], new PointF(x_value, y + (h_value - 16) / 2));
                        break;

                    case FieldType.Reference:
                        ObjectData or      = (ObjectData)this.values[field];
                        PointF     pr      = new PointF(x_value, y);
                        SizeF      sizeRef = g.MeasureString(or.ToString(), this.fontValue);
                        float      dRef    = (h_value - sizeRef.Height) / 2;
                        g.DrawString(or.ToString(), this.fontValue, this.selectedBrush, new RectangleF(pr, new SizeF(w_value, h_value)), format);
                        pr.Y += dRef;
                        this.refs.Add(new ReferenceData(new RectangleF(pr, sizeRef), or, ReferenceType.ObjectData));
                        break;

                    case FieldType.Url:
                        string url = this.values[field].ToString();
                        pr = new PointF(x_value, y);
                        g.DrawString(url, this.fontValue, this.selectedBrush, new RectangleF(pr, new SizeF(w_value, h_value)), format);
                        SizeF sizeUrl = g.MeasureString(url, this.fontName);
                        this.refs.Add(new ReferenceData(new RectangleF(pr, sizeUrl), url, ReferenceType.Url));
                        break;

                    case FieldType.Number:
                        decimal        res      = (decimal)this.values[field];
                        NumberProperty num_prop = field.Data as NumberProperty;
                        g.DrawString(res.ToString(num_prop.Format), this.fontValue, this.textBrush, new RectangleF(x_value, y, w_value, h_value), format);
                        break;

                    default:
                        g.DrawString(this.values[field].ToString(), this.fontValue, this.textBrush, new RectangleF(x_value, y, w_value, h_value), format);
                        break;
                    }

                    y += h_value + 9;
                }
                else
                {
                    switch (field.FieldType)
                    {
                    case FieldType.Table:
                        TableData td         = (TableData)this.values[field];
                        SizeF     sizeHeader = g.MeasureString(field.Name, this.fontName);
                        SizeF     sizeRow    = g.MeasureString("A" /*td.First.Data.ToString()*/, this.fontValue);
                        SizeF     sizeTable  = new SizeF(Width - 6, sizeHeader.Height + 5 + (sizeRow.Height + 5) * td.RowCount + 1);

                        float y_t = y;
                        float x_t = x_name + 2;
                        foreach (ColumnProperty cp in td.Columns)
                        {
                            y_t = y + 3;

                            // заголовок
                            g.DrawString(cp.Name, this.fontName, this.textBrush, new PointF(x_t, y_t));
                            SizeF sizeCol = g.MeasureString(cp.Name, this.fontName);
                            y_t += sizeCol.Height + 5;
                            for (int r = 0; r < td.RowCount; r++)
                            {
                                object o = td[r][cp].Data;
                                if (o == null)
                                {
                                    continue;
                                }

                                PointF pf = new PointF(x_t, y_t);
                                SizeF  sizeN;
                                if (string.IsNullOrEmpty(o.ToString()))
                                {
                                    sizeN = g.MeasureString("A", this.fontValue);
                                }
                                else
                                {
                                    sizeN = g.MeasureString(o.ToString(), this.fontValue);
                                    if (o is ObjectData)
                                    {
                                        this.refs.Add(new ReferenceData(new RectangleF(pf, sizeN), o, ReferenceType.ObjectData));
                                        g.DrawString(o.ToString(), this.fontValue, this.selectedBrush, pf);
                                    }
                                    else
                                    {
                                        g.DrawString(o.ToString(), this.fontValue, this.textBrush, pf);
                                    }
                                }

                                if (sizeN.Width > sizeCol.Width)
                                {
                                    sizeCol.Width = sizeN.Width;
                                }

                                y_t += sizeN.Height + 5;
                            }

                            x_t += sizeCol.Width + 6;
                        }

                        break;

                    case FieldType.Memo:
                        string s    = (string)this.values[field];
                        SizeF  size = g.MeasureString(s, this.fontValue, Width - 6);
                        g.DrawString(s, this.fontValue, this.textBrush, new RectangleF(new PointF(x_name, y), size));
                        break;

                    case FieldType.List:
                        ListData sc = (ListData)this.values[field];
                        float    yc = y;
                        foreach (ObjectData sl in sc.Objects)
                        {
                            PointF pf = new PointF(x_name, yc);
                            g.DrawString(sl.ToString(), this.fontValue, this.selectedBrush, pf);
                            SizeF sizeList = g.MeasureString(sl.ToString(), this.fontValue);
                            yc += sizeList.Height;
                            this.refs.Add(new ReferenceData(new RectangleF(pf, sizeList), sl, ReferenceType.ObjectData));
                        }

                        break;

                    case FieldType.Image:
                        ImageData id = (ImageData)this.values[field];
                        float     xi = x_name;
                        float     yi = y;
                        foreach (string key in id.Images)
                        {
                            string         pathImages = MainForm.AppDir + @"\images";
                            ImageReference ir         = this.database.Images[key];
                            if (ir == null)
                            {
                                ir = ImageReference.CreateImageReference(key, pathImages);
                                if (ir != null)
                                {
                                    this.database.Images.Add(ir);
                                }
                            }
                            else
                            {
                                if (ir.CheckImages(pathImages))
                                {
                                    this.database.Images.Update(ir);
                                }

                                if (string.IsNullOrEmpty(ir.Copy))
                                {
                                    ir = null;
                                }
                            }

                            if (ir == null)
                            {
                                continue;
                            }

                            int w = WidthImage;
                            int h = HeightImage;

                            Image im = null;

                            if (File.Exists(ir.Thumbnail))
                            {
                                im = new Bitmap(ir.Thumbnail);
                                if (im.Width > im.Height)
                                {
                                    h = h * im.Height / im.Width;
                                }
                                else
                                {
                                    w = w * im.Width / im.Height;
                                }
                            }
                            else
                            {
                                Bitmap original = new Bitmap(ir.Image);
                                double k        = (double)original.Width / (double)original.Height;

                                if (k > 1)
                                {
                                    h = (int)Math.Round(WidthImage / k);
                                }
                                else if (k < 1)
                                {
                                    w = (int)Math.Round(HeightImage * k);
                                }

                                im = original.GetThumbnailImage(w, h, null, IntPtr.Zero);
                            }

                            int dx = 0;
                            int dy = 0;
                            if (w > h)
                            {
                                dy = (HeightImage - h) / 2;
                            }
                            else
                            {
                                dx = (WidthImage - w) / 2;
                            }

                            RectangleF rf = new RectangleF(xi + dx, yi + dy, w, h);
                            g.DrawImage(im, rf);
                            this.refs.Add(new ReferenceData(new RectangleF(rf.Location, rf.Size), ir.Image, ReferenceType.Image));
                            xi += WidthImage + DividerImage;
                            if (xi + WidthImage + DividerImage > Width)
                            {
                                xi  = x_name;
                                yi += HeightImage + DividerImage;
                            }
                        }

                        break;
                    }
                }
            }
        }
Exemplo n.º 27
0
        private Property parsePrimaryExpr()
        {
            Property prop;

            switch (currentToken)
            {
            case TOK_LPAR:
                next();
                prop = parseAdditiveExpr();
                expectRpar();
                return(prop);

            case TOK_LITERAL:
                prop = new StringProperty(currentTokenValue);
                break;

            case TOK_NCNAME:
                prop = new NCnameProperty(currentTokenValue);
                break;

            case TOK_FLOAT:
                prop = new NumberProperty(ParseDouble(currentTokenValue));
                break;

            case TOK_INTEGER:
                prop = new NumberProperty(Int32.Parse(currentTokenValue));
                break;

            case TOK_PERCENT:
                double pcval = ParseDouble(
                    currentTokenValue.Substring(0, currentTokenValue.Length - 1)) / 100.0;
                IPercentBase pcBase = this.propInfo.GetPercentBase();
                if (pcBase != null)
                {
                    if (pcBase.GetDimension() == 0)
                    {
                        prop = new NumberProperty(pcval * pcBase.GetBaseValue());
                    }
                    else if (pcBase.GetDimension() == 1)
                    {
                        prop = new LengthProperty(new PercentLength(pcval,
                                                                    pcBase));
                    }
                    else
                    {
                        throw new PropertyException("Illegal percent dimension value");
                    }
                }
                else
                {
                    prop = new NumberProperty(pcval);
                }
                break;

            case TOK_NUMERIC:
                int    numLen   = currentTokenValue.Length - currentUnitLength;
                string unitPart = currentTokenValue.Substring(numLen);
                double numPart  = ParseDouble(currentTokenValue.Substring(0, numLen));
                Length length   = null;
                if (unitPart.Equals(RELUNIT))
                {
                    length = new FixedLength(numPart, propInfo.currentFontSize());
                }
                else
                {
                    length = new FixedLength(numPart, unitPart);
                }
                if (length == null)
                {
                    throw new PropertyException("unrecognized unit name: " + currentTokenValue);
                }
                else
                {
                    prop = new LengthProperty(length);
                }
                break;

            case TOK_COLORSPEC:
                prop = new ColorTypeProperty(new ColorType(currentTokenValue));
                break;

            case TOK_FUNCTION_LPAR:
            {
                IFunction function =
                    (IFunction)functionTable[currentTokenValue];
                if (function == null)
                {
                    throw new PropertyException("no such function: "
                                                + currentTokenValue);
                }
                next();
                propInfo.pushFunction(function);
                prop = function.Eval(parseArgs(function.NumArgs), propInfo);
                propInfo.popFunction();
                return(prop);
            }

            default:
                throw new PropertyException("syntax error");
            }
            next();
            return(prop);
        }
Exemplo n.º 28
0
        private void Setup()
        {
            Dictionary <string, bool> trackfeatures;

            using (var trk = _editor.CreateTrackReader())
            {
                trackfeatures = trk.GetFeatures();
            }
            TabControl tabs = new TabControl(this)
            {
                Dock = Dock.Fill
            };
            var settings = tabs.AddPage("Settings");
            var song     = tabs.AddPage("Song");

            _tree = new PropertyTree(settings)
            {
                Dock = Dock.Fill,
            };
            var            table     = _tree.Add("Settings", 150);
            NumberProperty startzoom = new NumberProperty(null)
            {
                Min         = 1,
                NumberValue = _editor.StartZoom,
                Max         = Constants.MaxZoom,
            };

            startzoom.ValueChanged += (o, e) =>
            {
                _editor.StartZoom = (float)startzoom.NumberValue;
            };
            table.Add("Start Zoom", startzoom);
            var zerostart = GwenHelper.AddPropertyCheckbox(table, "Zero Start", _editor.ZeroStart);

            zerostart.ValueChanged += (o, e) =>
            {
                _editor.ZeroStart = zerostart.IsChecked;
            };

            NumberProperty ygravity = new NumberProperty(null)
            {
                Min = float.MinValue + 1,
                Max = float.MaxValue - 1,
            };

            ygravity.Value         = ((float)_editor.YGravity).ToString();
            ygravity.ValueChanged += (o, e) =>
            {
                _editor.YGravity = float.Parse(ygravity.Value);
            };
            table.Add("Y Gravity Multiplier", ygravity);
            NumberProperty xgravity = new NumberProperty(null)
            {
                Min = float.MinValue + 1,
                Max = float.MaxValue - 1,
            };

            xgravity.Value         = ((float)_editor.XGravity).ToString();
            xgravity.ValueChanged += (o, e) =>
            {
                _editor.XGravity = float.Parse(xgravity.Value);
            };
            table.Add("X Gravity Multiplier", xgravity);

            NumberProperty gravitywellsize = new NumberProperty(null)
            {
                Min = 0,
                Max = double.MaxValue - 1,
            };

            gravitywellsize.Value         = ((double)_editor.GravityWellSize).ToString();
            gravitywellsize.ValueChanged += (o, e) =>
            {
                _editor.GravityWellSize = double.Parse(gravitywellsize.Value);
            };
            table.Add("Gravity Well Size", gravitywellsize);

            //BG COLORS
            table = _tree.Add("Starting Background Color", 150);
            NumberProperty startbgred = new NumberProperty(null)
            {
                Min = 0, Max = 255
            };

            startbgred.Value         = _editor.StartingBGColorR.ToString(); //Put value out here because putting it in the number property makes it get set to 100 for some reason???
            startbgred.ValueChanged += (o, e) =>
            {
                _editor.StartingBGColorR = int.Parse(startbgred.Value);
            };
            table.Add("Background Red", startbgred);
            NumberProperty startbggreen = new NumberProperty(null)
            {
                Min = 0, Max = 255
            };

            startbggreen.Value         = _editor.StartingBGColorG.ToString(); //Put value out here because putting it in the number property makes it get set to 100 for some reason???
            startbggreen.ValueChanged += (o, e) =>
            {
                _editor.StartingBGColorG = int.Parse(startbggreen.Value);
            };
            table.Add("Background Green", startbggreen);
            NumberProperty startbgblue = new NumberProperty(null)
            {
                Min = 0, Max = 255
            };

            startbgblue.Value         = _editor.StartingBGColorB.ToString(); //Put value out here because putting it in the number property makes it get set to 100 for some reason???
            startbgblue.ValueChanged += (o, e) =>
            {
                _editor.StartingBGColorB = int.Parse(startbgblue.Value);
            };
            table.Add("Background Blue", startbgblue);
            //LINE COLORS
            table = _tree.Add("Starting Line Color", 150);
            NumberProperty startlinered = new NumberProperty(null)
            {
                Min = 0, Max = 255
            };

            startlinered.Value         = _editor.StartingLineColorR.ToString(); //Put value out here because putting it in the number property makes it get set to 100 for some reason???
            startlinered.ValueChanged += (o, e) =>
            {
                _editor.StartingLineColorR = int.Parse(startlinered.Value);
            };
            table.Add("Line Red", startlinered);
            NumberProperty startlinegreen = new NumberProperty(null)
            {
                Min = 0, Max = 255
            };

            startlinegreen.Value         = _editor.StartingLineColorG.ToString(); //Put value out here because putting it in the number property makes it get set to 100 for some reason???
            startlinegreen.ValueChanged += (o, e) =>
            {
                _editor.StartingLineColorG = int.Parse(startlinegreen.Value);
            };
            table.Add("Line Green", startlinegreen);
            NumberProperty startlineblue = new NumberProperty(null)
            {
                Min = 0, Max = 255
            };

            startlineblue.Value         = _editor.StartingLineColorB.ToString(); //Put value out here because putting it in the number property makes it get set to 100 for some reason???
            startlineblue.ValueChanged += (o, e) =>
            {
                _editor.StartingLineColorB = int.Parse(startlineblue.Value);
            };
            table.Add("Line Blue", startlineblue);



            table = _tree.Add("Info", 150);
            // var trackname = table.AddLabel("Track Name", _editor.Name);
            var physics = table.AddLabel("Physics", CheckFeature(trackfeatures, TrackFeatures.six_one) ? "6.1" : "6.2");

            table.AddLabel("Blue Lines", _editor.BlueLines.ToString());
            table.AddLabel("Red Lines", _editor.RedLines.ToString());
            table.AddLabel("Scenery Lines", _editor.GreenLines.ToString());
            table = _tree.Add("Features Used", 150);

            AddFeature(table, trackfeatures, "Red Multiplier", TrackFeatures.redmultiplier);
            AddFeature(table, trackfeatures, "Scenery Width", TrackFeatures.scenerywidth);
            AddFeature(table, trackfeatures, "Line Triggers", TrackFeatures.ignorable_trigger);

            table = _tree.Add("Physics Modifiers", 150);
            var remount = GwenHelper.AddPropertyCheckbox(table, "Remount", _editor.UseRemount);

            remount.ValueChanged += (o, e) =>
            {
                _editor.UseRemount = remount.IsChecked;
            };

            PopulateSong(song);
            _tree.ExpandAll();
            // table.Add
        }
Exemplo n.º 29
0
        private Property parsePrimaryExpr()
        {
            Property prop;
            switch (currentToken)
            {
                case TOK_LPAR:
                    next();
                    prop = parseAdditiveExpr();
                    expectRpar();
                    return prop;

                case TOK_LITERAL:
                    prop = new StringProperty(currentTokenValue);
                    break;

                case TOK_NCNAME:
                    prop = new NCnameProperty(currentTokenValue);
                    break;

                case TOK_FLOAT:
                    prop = new NumberProperty(ParseDouble(currentTokenValue));
                    break;

                case TOK_INTEGER:
                    prop = new NumberProperty(Int32.Parse(currentTokenValue));
                    break;

                case TOK_PERCENT:
                    double pcval = ParseDouble(
                        currentTokenValue.Substring(0, currentTokenValue.Length - 1)) / 100.0;
                    IPercentBase pcBase = this.propInfo.GetPercentBase();
                    if (pcBase != null)
                    {
                        if (pcBase.GetDimension() == 0)
                        {
                            prop = new NumberProperty(pcval * pcBase.GetBaseValue());
                        }
                        else if (pcBase.GetDimension() == 1)
                        {
                            prop = new LengthProperty(new PercentLength(pcval,
                                                                        pcBase));
                        }
                        else
                        {
                            throw new PropertyException("Illegal percent dimension value");
                        }
                    }
                    else
                    {
                        prop = new NumberProperty(pcval);
                    }
                    break;

                case TOK_NUMERIC:
                    int numLen = currentTokenValue.Length - currentUnitLength;
                    string unitPart = currentTokenValue.Substring(numLen);
                    double numPart = ParseDouble(currentTokenValue.Substring(0, numLen));
                    Length length = null;
                    if (unitPart.Equals(RELUNIT))
                    {
                        length = new FixedLength(numPart, propInfo.currentFontSize());
                    }
                    else
                    {
                        length = new FixedLength(numPart, unitPart);
                    }
                    if (length == null)
                    {
                        throw new PropertyException("unrecognized unit name: " + currentTokenValue);
                    }
                    else
                    {
                        prop = new LengthProperty(length);
                    }
                    break;

                case TOK_COLORSPEC:
                    prop = new ColorTypeProperty(new ColorType(currentTokenValue));
                    break;

                case TOK_FUNCTION_LPAR:
                    {
                        IFunction function =
                            (IFunction)functionTable[currentTokenValue];
                        if (function == null)
                        {
                            throw new PropertyException("no such function: "
                                + currentTokenValue);
                        }
                        next();
                        propInfo.pushFunction(function);
                        prop = function.Eval(parseArgs(function.NumArgs), propInfo);
                        propInfo.popFunction();
                        return prop;
                    }
                default:
                    throw new PropertyException("syntax error");
            }
            next();
            return prop;
        }
Exemplo n.º 30
0
        public void CreateNumberProperty()
        {
            NumberProperty prop = new NumberProperty("test", 12.5f);

            Assert.AreEqual(12.5f, prop.Value);
        }
Exemplo n.º 31
0
		public virtual void Visit(NumberProperty mapping)
		{
		}
Exemplo n.º 32
0
        private void SetupTriggers(PropertyTree tree)
        {
            if (_ownerline is StandardLine physline)
            {
                var table          = tree.Add("Triggers", 120);
                var currenttrigger = physline.Trigger;
                var triggerenabled = GwenHelper.AddPropertyCheckbox(
                    table,
                    "Enabled",
                    currenttrigger != null);

                var zoom = new NumberProperty(table)
                {
                    Min         = Constants.MinimumZoom,
                    Max         = Constants.MaxZoom,
                    NumberValue = 4
                };
                table.Add("Target Zoom", zoom);
                var frames = new NumberProperty(table)
                {
                    Min              = 0,
                    Max              = 40 * 60 * 2,//2 minutes is enough for a zoom trigger, you crazy nuts.
                    NumberValue      = 40,
                    OnlyWholeNumbers = true,
                };
                if (currenttrigger != null)
                {
                    zoom.NumberValue   = currenttrigger.ZoomTarget;
                    frames.NumberValue = currenttrigger.ZoomFrames;
                }
                table.Add("Frames", frames);
                zoom.ValueChanged += (o, e) =>
                {
                    using (var trk = _editor.CreateTrackWriter())
                    {
                        trk.DisableExtensionUpdating();
                        if (triggerenabled.IsChecked)
                        {
                            var cpy = (StandardLine)_ownerline.Clone();
                            cpy.Trigger.ZoomTarget = (float)zoom.NumberValue;
                            UpdateOwnerLine(trk, cpy);
                        }
                    }
                };
                frames.ValueChanged += (o, e) =>
                {
                    using (var trk = _editor.CreateTrackWriter())
                    {
                        trk.DisableExtensionUpdating();
                        if (triggerenabled.IsChecked)
                        {
                            var cpy = (StandardLine)_ownerline.Clone();
                            cpy.Trigger.ZoomFrames = (int)frames.NumberValue;
                            UpdateOwnerLine(trk, cpy);
                        }
                    }
                };
                triggerenabled.ValueChanged += (o, e) =>
                {
                    using (var trk = _editor.CreateTrackWriter())
                    {
                        trk.DisableExtensionUpdating();
                        var cpy = (StandardLine)_ownerline.Clone();
                        if (triggerenabled.IsChecked)
                        {
                            cpy.Trigger = new LineTrigger()
                            {
                                ZoomTrigger = true,
                                ZoomFrames  = (int)frames.NumberValue,
                                ZoomTarget  = (float)zoom.NumberValue
                            };

                            UpdateOwnerLine(trk, cpy);
                        }
                        else
                        {
                            cpy.Trigger = null;
                            UpdateOwnerLine(trk, cpy);
                        }
                    }
                };
            }
        }
Exemplo n.º 33
0
        private void SetupRedOptions(PropertyTree tree)
        {
            var vec   = _ownerline.GetVector();
            var len   = vec.Length;
            var angle = Angle.FromVector(vec);

            angle.Degrees += 90;
            var lineProp = tree.Add("Line Properties", 120);

            Console.WriteLine(_ownerline.GetType().ToString());

            if (!(_ownerline is SceneryLine scenery))
            {
                var id = new NumberProperty(lineProp)
                {
                    Min              = 0,
                    Max              = int.MaxValue - 1,
                    NumberValue      = _ownerline.ID,
                    OnlyWholeNumbers = true,
                };
                id.ValueChanged += (o, e) =>
                {
                    ChangeID((int)id.NumberValue);
                };
                lineProp.Add("ID", id);
            }

            _length = new NumberProperty(lineProp)
            {
                Min         = 0.0000001,
                Max         = double.MaxValue - 1,
                NumberValue = len,
            };
            _length.ValueChanged += (o, e) =>
            {
                ChangeLength(_length.NumberValue);
            };
            lineProp.Add("Length", _length);

            _angleProp = new NumberProperty(lineProp)
            {
                Min         = 0,
                Max         = 360,
                NumberValue = angle.Degrees,
            };
            _angleProp.ValueChanged += (o, e) =>
            {
                ChangeAngle(_angleProp.NumberValue);
            };
            lineProp.Add("Angle", _angleProp);

            if (!(_ownerline is SceneryLine))
            {
                var multilines = new NumberProperty(lineProp)
                {
                    Min = 1,
                    Max = int.MaxValue - 1,
                    OnlyWholeNumbers = true,
                };
                multilines.NumberValue   = GetMultiLines(true).Count;
                multilines.ValueChanged += (o, e) =>
                {
                    Multiline((int)multilines.NumberValue);
                };
                lineProp.Add("Multilines", multilines);
            }

            if (_ownerline is SceneryLine sceneryLine)
            {
                _width = new NumberProperty(lineProp)
                {
                    Min         = 0.1,
                    Max         = 25.5,
                    NumberValue = _ownerline.Width,
                };
                _width.ValueChanged += (o, e) =>
                {
                    ChangeWidth(_width.NumberValue);
                };
                lineProp.Add("Width", _width);
            }

            if (_ownerline is RedLine red)
            {
                var acceleration = tree.Add("Acceleration", 120);
                var multiplier   = new NumberProperty(acceleration)
                {
                    Min              = 1,
                    Max              = 255,
                    NumberValue      = red.Multiplier,
                    OnlyWholeNumbers = true,
                };
                multiplier.ValueChanged += (o, e) =>
                {
                    ChangeMultiplier((int)multiplier.NumberValue);
                };
                acceleration.Add("Multiplier", multiplier);

                var accelinverse = GwenHelper.AddPropertyCheckbox(
                    acceleration,
                    "Inverse",
                    red.inv
                    );
                accelinverse.ValueChanged += (o, e) =>
                {
                    using (var trk = _editor.CreateTrackWriter())
                    {
                        var multi = GetMultiLines(false);
                        foreach (var l in multi)
                        {
                            var cpy = (StandardLine)l.Clone();
                            cpy.Position  = l.Position2;
                            cpy.Position2 = l.Position;
                            cpy.inv       = accelinverse.IsChecked;
                            UpdateLine(trk, l, cpy);
                        }

                        var owner = (StandardLine)_ownerline.Clone();
                        owner.Position  = _ownerline.Position2;
                        owner.Position2 = _ownerline.Position;
                        owner.inv       = accelinverse.IsChecked;
                        UpdateOwnerLine(trk, owner);
                    }
                };
            }
        }