コード例 #1
0
        public FlightDisplayViewModel(IVariableCache store)
        {
            ElevatorTrim = new SliderModel(store.ElevatorTrimElement()).WithLabel("Elevator");

            Flaps = new ConstrainedSliderModel(store.FlapsElement(), Orientation.Vertical, true)
                    .WithLabel("Flaps");
            ParkingBreak    = new ToggleButtonModel("Parking Break", store.ParkingBreakElement());
            GearRetractable = store.IsGearRetractable();
            GearDown        = new ToggleButtonModel("Landing Gear", store.GearDownElement());

            SimulationRate = new DoubleUpDownDisplayModel(store.SimulationRateElement())
                             .WithLabel("Time Factor", Dock.Left);

            AutoPilotActive    = new ToggleButtonModel("Auto Pilot Active", store.AutopilotElement());
            AutoPilotAvialable = store.AutopilotAvailable();
            HeadingBug         = new DoubleUpDownDisplayModel(store.AutopilotHeadingElement());
            AltitudeBug        = new DoubleUpDownDisplayModel(store.AutopilotAltitudeLockElement());
            VSIBug             = new DoubleUpDownDisplayModel(store.AutopilotVerticalSpeedElement());
            AirspeedBug        = new DoubleUpDownDisplayModel(store.AutopilotAirSpeedElement());

            AltitudeHold = new ToggleButtonModel("Alt Hold", store.AutopilotAltitudeHoldElement());
            VSIHold      = new ToggleButtonModel("VSI Hold", store.AutopilotVsiHoldElement());
            AirspeedHold = new ToggleButtonModel("Airspeed Hold", store.AutopilotAirspeedHoldElement());

            WingLeveler = new ToggleButtonModel("Wings Level", store.AutopilotWingLevelerElement());
            HeadingMode = new ToggleButtonModel("Hdg Lock", store.AutopilotHeadingLockElement());
            NavMode     = new ToggleButtonModel("Nav Lock", store.AutopilotNav1LockElement());
        }
コード例 #2
0
        public void TestIfResolutionChangingWorks()
        {
            IDisplayModel displayModel = DisplayFactory.GetDisplayModel();
            Display       primary      = displayModel.GetPrimaryDisplay();

            var newResolution = new Size(800, 600);

            Assert.IsTrue(primary.SetResolution(newResolution));

            Assert.AreEqual(newResolution, primary.Resolution);
        }
コード例 #3
0
        public void TestIfActiveAndDeActiveWorks()
        {
            IDisplayModel displayModel = DisplayFactory.GetDisplayModel();
            Display       primary      = displayModel.GetPrimaryDisplay();

            Assert.IsTrue(primary.IsActive);

            primary.SetDeactive();

            Assert.IsFalse(primary.IsActive);

            primary.SetActive();

            Assert.IsTrue(primary.IsActive);
        }
コード例 #4
0
        public void TestRotation()
        {
            IDisplayModel displayModel = DisplayFactory.GetDisplayModel();
            Display       primary      = displayModel.GetPrimaryDisplay();

            var currentOrientation = primary.Rotation;

            // yeah, the orientation is default currently.
            Assert.AreEqual(DisplayRotation.Default, currentOrientation);

            // set the rotation to 180.
            Assert.IsTrue(primary.SetRotation(DisplayRotation.Rotated180));

            // see if the change worked
            Assert.AreEqual(DisplayRotation.Rotated180, primary.Rotation);
        }
コード例 #5
0
        /// <summary>
        /// Selects correct display model, based on Windows version.
        /// </summary>
        /// <returns></returns>
        public static IDisplayModel GetDisplayModel()
        {
            lock(Lock)
            {
                if (_displayModel != null)
                    return _displayModel;

                // TODO: This needs to be rethink through.
                // WHAT OPERATING SYSTEMS WE EXACTLY SUPPORT
                // AND DOES THE Win7DISPLAYMODEL ALSO SUPPORT WIN8?
                // OR DO WE NEED TO CREATE ANOTHER DISPLAYMODEL?!

                // ALSO, ARE WE AIMING FOR THREAD-SAFETY?!
                var osVersion = Environment.OSVersion;
                var isWin7 = (osVersion.Version.Major == 6 && osVersion.Version.Minor == 1);
                _displayModel = isWin7 ? (IDisplayModel) new Win7DisplayModel() : new XPDisplayModel();

                return _displayModel;
            }
        }
コード例 #6
0
ファイル: DisplayFactory.cs プロジェクト: warfu/Winotate
        /// <summary>
        /// Selects correct display model, based on Windows version.
        /// </summary>
        /// <returns></returns>
        public static IDisplayModel GetDisplayModel()
        {
            lock (Lock)
            {
                if (_displayModel != null)
                {
                    return(_displayModel);
                }

                // TODO: This needs to be rethink through.
                // WHAT OPERATING SYSTEMS WE EXACTLY SUPPORT
                // AND DOES THE Win7DISPLAYMODEL ALSO SUPPORT WIN8?
                // OR DO WE NEED TO CREATE ANOTHER DISPLAYMODEL?!

                // ALSO, ARE WE AIMING FOR THREAD-SAFETY?!
                var osVersion = Environment.OSVersion;
                var isWin7    = (osVersion.Version.Major == 6 && osVersion.Version.Minor == 1);
                _displayModel = isWin7 ? (IDisplayModel) new Win7DisplayModel() : new XPDisplayModel();

                return(_displayModel);
            }
        }
コード例 #7
0
 public LabeledDisplayModel(IDisplayModel item, string title, Dock position)
 {
     Item     = item;
     Title    = title;
     Position = position;
 }
コード例 #8
0
 public static IDisplayModel WithLabel(this IDisplayModel model, string label, Dock location = Dock.Top) =>
 new LabeledDisplayModel(model, label, location);
コード例 #9
0
        public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            string displayPrefix = bindingContext.ModelName;

            if (displayPrefix == "model" || (bindingContext.ModelMetadata.PropertyName == null && !displayPrefix.Contains('.') && !displayPrefix.Contains('[') && !displayPrefix.Contains('$')))
            {
                displayPrefix = "display";
            }
            ValueProviderResult attemptedTransformer = bindingContext.ValueProvider.GetValue(displayPrefix + ".$$");

            if (displayPrefix == "display" && attemptedTransformer == null)
            {
                attemptedTransformer = bindingContext.ValueProvider.GetValue("$$");
            }
            if (attemptedTransformer != null && attemptedTransformer.AttemptedValue != null)
            {
                Type displayModelType = BasicHtmlHelper.DecodeDisplayInfo(attemptedTransformer.AttemptedValue, bindingContext.ValueProvider);

                if (displayModelType != null && displayModelType.IsClass)
                {
                    object[] displayModelContext = null;

                    if (displayModelType.GetInterface("IDisplayModel") != null)
                    {
                        displayModelContext = new object[] { bindingContext.ModelName, controllerContext.HttpContext.Items };
                    }
                    else if (displayModelType.GetInterface("IDisplayModelBuilder") != null)
                    {
                        object displayModelBuilder = displayModelType.GetConstructor(new Type[0]).Invoke(new object[0]);
                        IDisplayModelBuilder displayModelFarmInterface = displayModelBuilder as IDisplayModelBuilder;
                        if (displayModelFarmInterface != null)
                        {
                            displayModelContext = displayModelFarmInterface.DisplayModelContext;
                            displayModelType    = displayModelFarmInterface.DisplayModelType;
                            if (displayModelType.GetInterface("IDisplayModel") == null)
                            {
                                displayModelType = null;
                            }
                        }
                    }
                    else
                    {
                        displayModelType = null;
                    }
                    if (displayModelType != null)
                    {
                        IDisplayModel displayModel = BindDisplayModel(controllerContext, bindingContext, displayModelType) as IDisplayModel;
                        if (displayModel != null)
                        {
                            try
                            {
                                IUpdateModelState msUpdater = displayModel as IUpdateModelState;
                                if (msUpdater != null)
                                {
                                    msUpdater.GetCurrState(displayPrefix, -1, bindingContext.ModelState);
                                }
                                return(UpdateModel(controllerContext, bindingContext,
                                                   displayModel.ExportToModel(bindingContext.ModelType, displayModelContext)));
                            }
                            catch (Exception ex)
                            {
                                bindingContext.ModelState.AddModelError(bindingContext.ModelName, string.Format(ex.Message, bindingContext.ModelMetadata.GetDisplayName()));
                                return(null);
                            }
                        }
                    }
                }
            }
            object res = null;

            try
            {
                res = base.BindModel(controllerContext, bindingContext);
            }
            catch { }
            return
                (UpdateModel(controllerContext, bindingContext,
                             res));
        }