void Connect()
        {
            try
            {
                if ((String)cmbPorts.SelectedItem != "Simulator")
                {
                    if (bicycle != null)
                    {
                        bicycle.Disconnect();
                    }
                    bicycle = new Bicycle(cmbPorts.SelectedItem.ToString());
                }
                else
                {
                    if (bicycle != null)
                    {
                        bicycle.Disconnect();
                    }
                    bicycle = new Simulator(300);
                }

                bicycle.ResetDevice();
                bicycle.RequestCommandMode();
                bicycle.RequestTime("0705");
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
예제 #2
0
 /// <summary>
 /// Creates a new instance
 /// </summary>
 public BicycleComponentsCollection(IBicycle parent)
 {
     this._parent         = parent;
     parent.FrameChanged += this.HandleValueChange;
     parent.ForkChanged  += this.HandleValueChange;
     parent.Wheels.AsNotifiable().CollectionChanged += this.HandleCollectionChange;
     parent.HandleBarChanged += this.HandleValueChange;
 }
예제 #3
0
        private static void TouringBike()
        {
            AbstractRoadBike roadBike = new Touring(BikeColor.Gold, new NarrowWheel(12));
            BikeBuilder      builder  = new RoadBikeBuilder(roadBike);
            BikeDirector     director = new RoadBikeDirector();
            IBicycle         bicycle  = director.Build(builder);

            Console.WriteLine(bicycle);
        }
예제 #4
0
        static void BuilderDemo()
        {
            AbstractMoutainBike moutainBike = new DownHill(new WideWheel(24), BikeColor.Red);
            BikeBuilder         builder     = new MountainBikeBuilder(moutainBike);
            BikeDirector        director    = new MountainBikeDirector();
            IBicycle            bicycle     = director.Build(builder);

            Console.WriteLine(bicycle);
        }
        private static void BuilderPatterDemo()
        {
            AbstractMountainBike mountainBike = new Downhill(BikeColor.Green, new Widewheel(24));
            BikeBuilder          builder      = new MountainBikeBuilder(mountainBike); //builde object
            BikeDirector         director     = new MountainBikeDirector();            // diector object
            IBicycle             bicycle      = director.Build(builder);               // interface object

            Console.WriteLine(bicycle);
        }
예제 #6
0
        private static void BuilderPatternDemo()
        {
            AbstractMountainBike mountainBike = new Downhill(BikeColor.Gold, new WideWheel(32));
            BikeBuilder          builder      = new MountainBikeBuilder(mountainBike);
            BikeDirector         director     = new MountainBikeDirector();
            IBicycle             bicycle      = director.Build(builder);

            Console.WriteLine(bicycle);
        }
예제 #7
0
        private static void VintageBike()
        {
            AbstractRoadBike vintageRoadBike = new Vintage(BikeColor.Ocean, new NarrowWheel(10));
            BikeBuilder      builder         = new RoadBikeBuilder(vintageRoadBike);
            BikeDirector     director        = new RoadBikeDirector();
            IBicycle         bicycle         = director.Build(builder);

            Console.WriteLine(bicycle);
        }
예제 #8
0
        public void PrepareForSale(IBicycle bicycle)
        {
            Registration reg = new Registration(bicycle);

            reg.AllocateBikeNumber();
            Documentation.PrintBrochure(bicycle);

            bicycle.CleanFrame();
            bicycle.AirTire();
            bicycle.TestRide();
        }
예제 #9
0
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.Model == null))
     {
         IBicycle modelCasted = item.As <IBicycle>();
         if ((modelCasted != null))
         {
             this._parent.Model = modelCasted;
             return;
         }
     }
 }
예제 #10
0
        //Builder Design Pattern Demo Method
        private static void BuilderPatternDemo()
        {
            /*Object instance of AbstractMountainBike created using its child class Downhill.
             * Its constructor takes 2 arguments*/
            AbstractMountainBike mountainBike = new
                                                Downhill(BikeColor.Green, new WideWheel(24));

            /*Both BikeBuilder and BikeDirector object instances are created.
             * Build passes the object above into its constructor*/
            BikeBuilder  builder  = new MountainBikeBuilder(mountainBike);
            BikeDirector director = new MountainBikeDirector();

            /*Interface object of IBicycle is assigned the value of the Build method called from the
             * BikeDirector object above. Its output is displayed on the console*/
            IBicycle bicycle = director.Build(builder);

            Console.WriteLine(bicycle);
        }
예제 #11
0
 public static void PrintBrochure(IBicycle bicycle)
 {
     Console.WriteLine("printing brochure...");
 }
 public CustomGripOption(IBicycle bicycle)
     : base(bicycle)
 {
 }
 public WhiteTiresOption(IBicycle bicycle)
     : base(bicycle)
 {
 }
 public GoldFrameOption(IBicycle bicycle)
     : base(bicycle)
 {
 }
예제 #15
0
 public WhiteTires(IBicycle bicycle)
     : base(bicycle)
 {
 }
 public static void PrintBrochure(IBicycle bicycle)
 {
     Console.WriteLine("Printing Brochure");
 }
예제 #17
0
 public BicycleAsCar(IBicycle bicycle)
 {
     this.bicycle = bicycle;
 }
예제 #18
0
 public GoldFrame(IBicycle bicycle)
     : base(bicycle)
 {
 }
 public WhiteTireOptions(IBicycle bicycle)
     : base(bicycle)
 {
 }
 /*Constructor that takes 1 parameter. Also passes the value to its parent through the base declaration
  * Below this is a constructor*/
 public AbstractBikeOption(IBicycle bicycle)
     : base(BikeColor.Chrome, bicycle.GetWheel)
 {
     this.decoratedBike = bicycle;
 }
예제 #21
0
 public BicyclesController(IBicycle ibicycle, ICategory icategory)
 {
     allbicycle  = ibicycle;
     allcategory = icategory;
 }
예제 #22
0
 public LeatherSeat(IBicycle bicycle)
     : base(bicycle)
 {
 }
예제 #23
0
 public CustomGrip(IBicycle bicycle)
     : base(bicycle)
 {
 }
 public Registration(IBicycle bicycle)
 {
     this._bicycle = bicycle;
 }
예제 #25
0
 public AbstractBikeOption(IBicycle bicycle)
     : base(bicycle.Wheel, BikeColor.Black)
 {
     this.decoratedBike = bicycle
 }
 public LeatherSheetOption(IBicycle bicycle)
     : base(bicycle)
 {
 }
예제 #27
0
 public HomeController(IBicycle bicycleRep)
 {
     _bicycleRep = bicycleRep;
 }
예제 #28
0
 public ShopCartController(IBicycle bicycleRep, ShopCart shopCart)
 {
     _bicycleRep = bicycleRep;
     _shopCart   = shopCart;
 }