Exemplo n.º 1
0
        /// <summary>
        /// During development, Main() acts as the ConsoleBootLoader, making it easy to debug the game.
        /// When game development is complete, comment out the content Main() to remove the overhead
        /// </summary>
        public static void Main() {
#if dev
            var joystickLeft = new AnalogJoystick(xAxisPin: Pins.GPIO_PIN_A0, yAxisPin: Pins.GPIO_PIN_A1);
            var joystickRight = new AnalogJoystick(xAxisPin: Pins.GPIO_PIN_A2, yAxisPin: Pins.GPIO_PIN_A3);
            var matrix = new Max72197221(chipSelect: Pins.GPIO_PIN_D8);
            var speaker = new PWM(Pins.GPIO_PIN_D5);
            var resourceLoader = new SDResourceLoader();
            var buttonLeft = new PushButton(Pins.GPIO_PIN_D0, Port.InterruptMode.InterruptEdgeLevelLow, null, Port.ResistorMode.PullUp);
            var buttonRight = new PushButton(Pins.GPIO_PIN_D1, Port.InterruptMode.InterruptEdgeLevelLow, null, Port.ResistorMode.PullUp);
            var args = new object[(int)CartridgeVersionInfo.LoaderArgumentsVersion100.Size];

            var index = 0;
            args[index++] = CartridgeVersionInfo.CurrentVersion;
            args[index++] = joystickLeft;
            args[index++] = joystickRight;
            args[index++] = matrix;
            args[index++] = speaker;
            args[index++] = resourceLoader;
            args[index++] = buttonLeft;
            args[index] = buttonRight;

            matrix.Shutdown(Max72197221.ShutdownRegister.NormalOperation);
            matrix.SetDecodeMode(Max72197221.DecodeModeRegister.NoDecodeMode);
            matrix.SetDigitScanLimit(7);
            matrix.SetIntensity(8);

            Run(args);
#endif
        }
Exemplo n.º 2
0
 /// <summary>
 /// Lisää esineen.
 /// </summary>
 /// <param name="item">Lisättävä esine.</param>
 /// <param name="kuva">Esineen ikoni, joka näkyy valikossa.</param>
 public void AddItem(GameObject item, Image kuva)
 {
     PushButton icon = new PushButton(kuva);
     icon.BorderColor = Color.Black;
     Add(icon);
     icon.Clicked += delegate() { SelectItem(item); };
 }
Exemplo n.º 3
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            if (_button == null) _button = commandData.Application.GetRibbonItem<PushButton>(RibbonConstants.Tab, RibbonConstants.Panel, CommandConstants.Name);
            if (_pane == null)
            {
                // if the pane isn't registered then disable show/hide
                if (!commandData.Application.PaneExists(DockConstants.Id, out _pane))
                {
                    _button.Enabled = false;
                    return Result.Succeeded;
                }
            }
            if (_state)
            {
                // showing so hide
                _pane.Hide();
                _button.ItemText = CommandConstants.Show;
                _button.LargeImage = ImageUtil.GetEmbeddedImage(Assembly, "Redbolts.DockableUITest.Images.ShowDock.png");
            }
            else
            {
                //hidden so show
                _pane.Show();
                _button.ItemText = CommandConstants.Hide;
                _button.LargeImage = ImageUtil.GetEmbeddedImage(Assembly, "Redbolts.DockableUITest.Images.HideDock.png");
            }
            _state = !_state;

            return Result.Succeeded;
        }
Exemplo n.º 4
0
        public MainPage()
        {
            this.InitializeComponent();
            Unloaded += MainPage_Unloaded;

            led = new MulticolorLed(redPinNumber: 18, greenPinNumber: 23, bluePinNumber: 24);

            button = new PushButton(5);
            button.Pressed += ButtonPressed;
            button.Click += ChangeColor;
            button.Released += ButtonReleased;
        }
Exemplo n.º 5
0
        public MainPage()
        {
            this.InitializeComponent();
            Unloaded += MainPage_Unloaded;

            led = new MulticolorLed(redPinNumber: 27, greenPinNumber: 22, bluePinNumber: 23);

            button = new PushButton(5, type: ButtonType.PullDown);
            button.Pressed += ButtonPressed;
            button.Click += ChangeColor;
            button.Released += ButtonReleased;
        }
Exemplo n.º 6
0
        public void Initialize()
        {
            PushButtons.Clear();
            Levels.ClearWidgets();

            foreach (var d in Main.LevelsFactory.UserDescriptors.Values)
            {
                var button = new PushButton();
                PushButtons.Add(d, button);
                Levels.AddWidget(d.Infos.Id.ToString(), button);
            }
        }
Exemplo n.º 7
0
        public Result OnStartup(UIControlledApplication application)
        {
            try
            {
                SetupDynamoPaths(application);

                SubscribeAssemblyResolvingEvent();

                ControlledApplication = application.ControlledApplication;

                TransactionManager.SetupManager(new AutomaticTransactionStrategy());
                ElementBinder.IsEnabled = true;

                //TAF load english_us TODO add a way to localize
                res = Resource_en_us.ResourceManager;

                // Create new ribbon panel
                RibbonPanel ribbonPanel =
                    application.CreateRibbonPanel(res.GetString("App_Description"));

                DynamoButton =
                    (PushButton)
                        ribbonPanel.AddItem(
                            new PushButtonData(
                                "Dynamo 0.7",
                                res.GetString("App_Name"),
                                assemblyName,
                                "Dynamo.Applications.DynamoRevit"));


                Bitmap dynamoIcon = Resources.logo_square_32x32;

                BitmapSource bitmapSource =
                    Imaging.CreateBitmapSourceFromHBitmap(
                        dynamoIcon.GetHbitmap(),
                        IntPtr.Zero,
                        Int32Rect.Empty,
                        BitmapSizeOptions.FromEmptyOptions());

                DynamoButton.LargeImage = bitmapSource;
                DynamoButton.Image = bitmapSource;

                RegisterAdditionalUpdaters(application);

                return Result.Succeeded;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return Result.Failed;
            }
        }
        private void btnStartMonitor_Click( object sender, RoutedEventArgs e )
        {
            if( this.button != null )
            {
                this.button.Pushed -= this.OnButtonPushed;
                this.button.Released -= this.OnButtonReleased;
                this.button.Dispose();
            }

            this.button = new PushButton( this.viewModel.PinNumber );
            this.button.Pushed += this.OnButtonPushed;
            this.button.Released += this.OnButtonReleased;

            this.tsIsOn.Visibility = Visibility.Visible;
        }
Exemplo n.º 9
0
        public MainPage()
        {
            this.InitializeComponent();
            this.Unloaded += MainPage_Unloaded;

            led = new MulticolorLed(redPinNumber: 18, greenPinNumber: 23, bluePinNumber: 24);

            button = new PushButton(pinNumber: 26);
            button.RaiseEventsOnUIThread = true;
            button.Click += Button_Click;

            distanceSensor = new Sr04UltrasonicDistanceSensor(triggerPinNumber: 12, echoPinNumber: 16, mode: ReadingMode.Manual);

            var motorDriver = new L298nMotorDriver(motor1Pin1: 27, motor1Pin2: 22, motor2Pin1: 5, motor2Pin2: 6);
            motors = motorDriver.AsLeftRightMotors();

            rnd = new Random(unchecked((int)(DateTime.Now.Ticks)));

            moveTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(MOVE_INTERVAL_SEC) };
            moveTimer.Tick += MoveTimer_Tick;
        }
Exemplo n.º 10
0
 /// <summary>
 /// Lisää esineen.
 /// </summary>
 /// <param name="item">Lisättävä esine.</param>
 /// <param name="kuva">Esineen ikoni, joka näkyy valikossa.</param>
 public void AddItem(PhysicsObject item, Image kuva)
 {
     Image isokuva = new Image(kuva.Width * 3, kuva.Height * 3, Color.White);
     for (int x = 0; x < kuva.Width; x++)
     {
         for (int y = 0; y < kuva.Height; y++)
         {
             isokuva[x * 3, y * 3] = kuva[x, y];
             isokuva[x * 3+1, y * 3] = kuva[x, y];
             isokuva[x * 3+2, y * 3] = kuva[x, y];
             isokuva[x * 3, y * 3+1] = kuva[x, y];
             isokuva[x * 3+1, y * 3+1] = kuva[x, y];
             isokuva[x * 3+2, y * 3+1] = kuva[x, y];
             isokuva[x * 3, y * 3+2] = kuva[x, y];
             isokuva[x * 3+1, y * 3+2] = kuva[x, y];
             isokuva[x * 3+2, y * 3+2] = kuva[x, y];
         }
     }
     PushButton icon = new PushButton(isokuva);
     Add(icon);
     icon.Clicked += delegate() { SelectItem(item); };
 }
Exemplo n.º 11
0
        /// <summary>
        /// Simple push button for "Hello World"
        /// </summary>
        public void AddPushButton(RibbonPanel panel)
        {
            // Set the information about the command we will be assigning to the button

            PushButtonData pushButtonDataHello
                = new PushButtonData(
                      "PushButtonHello",
                      "Hello World",
                      _introLabPath,
                      _introLabName + ".HelloWorld"); // could also use typeof(HelloWorld).FullName here

            // Add a button to the panel

            PushButton pushButtonHello = panel.AddItem(pushButtonDataHello) as PushButton;

            // Add an icon
            // Make sure you reference WindowsBase and PresentationCore, and import System.Windows.Media.Imaging namespace.

            pushButtonHello.LargeImage = NewBitmapImage("ImgHelloWorld.png");

            // Add a tooltip

            pushButtonHello.ToolTip = "simple push button";
        }
Exemplo n.º 12
0
        /// <summary>
        /// Implement this method to execute some tasks when Autodesk Revit starts.
        /// </summary>
        /// <param name="application">A handle to the application being started.</param>
        /// <returns>
        /// Indicates if the external application completes its work successfully.
        /// </returns>
        public Result OnStartup(UIControlledApplication application)
        {
            string dir  = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string path = Path.Combine(dir, ExtensionsFile);
            List <ExtensionModuleData> modules = ExtensionXMLReader.ReadFile(path);

            RibbonPanel     ribbonSamplePanel = application.CreateRibbonPanel("Extension SDK");
            SplitButtonData splitButtonData   = new SplitButtonData("ExtensionSDK", "SDK");
            SplitButton     splitButton       = ribbonSamplePanel.AddItem(splitButtonData) as SplitButton;
            string          imgPath           = Path.Combine(dir, ExtensionsImage);

            foreach (ExtensionModuleData module in modules)
            {
                if (System.IO.File.Exists(module.Path))
                {
                    PushButton pushButton = splitButton.AddPushButton(new PushButtonData(module.Name, module.Description, module.Path, module.Namespace + ".DirectRevitAccess"));

                    string imgModulePath = (File.Exists(module.Img)) ? module.Img : imgPath;
                    pushButton.LargeImage = new BitmapImage(new Uri(imgModulePath));
                }
            }

            return(Result.Succeeded);
        }
Exemplo n.º 13
0
        public static void CreatePanel(UIControlledApplication uiApp)
        {
            RibbonPanel Panel = uiApp.CreateRibbonPanel(CCRibbon.tabName, PName);

            TextBoxData tbd = new TextBoxData(TBName);
            TextBox     tb  = Panel.AddItem(tbd) as TextBox;

            tb.Width         = 350;
            tb.EnterPressed += EnterPressed;

            ComboBoxData cbd = new ComboBoxData("Update Type");
            ComboBox     box = Panel.AddItem(cbd) as ComboBox;

            box.AddItem(new ComboBoxMemberData("Run Command", "Run Command"));
            box.AddItem(new ComboBoxMemberData("Masterformat", "Masterformat"));
            box.AddItem(new ComboBoxMemberData("Occupant Load Factor", "Occupant Load Factor"));
            box.AddItem(new ComboBoxMemberData("Command Training", "Command Training"));
            PushButtonData OLFButtonData = new PushButtonData(
                "Update OLF",
                "Update OLF",
                @dllpath,
                "CC_Plugin.SetOLF");
            PushButton PBOccLoadFactor = Panel.AddItem(OLFButtonData) as PushButton;
        }
Exemplo n.º 14
0
        public Result OnStartup(UIControlledApplication application)
        {
            // Create a custom ribbon tab
            String tabName = "VantageTCG";

            application.CreateRibbonTab(tabName);

            // Create a ribbon panel; First arg adds panel to custom tab
            RibbonPanel ribbonPanel = application.CreateRibbonPanel(tabName, "Tools");

            // Button details and its link to the command
            string         thisAssemblyPath = Assembly.GetExecutingAssembly().Location;
            PushButtonData buttonData       = new PushButtonData("cmdName",
                                                                 "New Button Name", thisAssemblyPath, typeof(ExecuteCommand).FullName);

            // Does the same as the above
            // PushButtonData buttonData = new PushButtonData("cmdDeleteViews",
            //     "Delete Views", thisAssemblyPath, "RevitWarnings.DeleteViews");

            // Creates a Button
            PushButton pushButton = ribbonPanel.AddItem(buttonData) as PushButton;

            pushButton.ToolTip = "How to use the button";

            // Adds picture for button
            string filename   = @"\Views.png";
            string currentDir = AssemblyDirectory;
            //Uri uriImage = new Uri(@"%APPDATA%\Autodesk\Revit\Addins\2015\Views.png");
            //Uri uriImage = new Uri(@"C:\Users\rorymulcahey\AppData\Roaming\Autodesk\Revit\Addins\2015\Views.png");
            Uri         uriImage   = new Uri(currentDir + filename);
            BitmapImage largeImage = new BitmapImage(uriImage);

            pushButton.LargeImage = largeImage;

            return(Result.Succeeded); // must return
        }
Exemplo n.º 15
0
        public Result OnStartup(UIControlledApplication application)
        {
            application.CreateRibbonTab("MYAPP");
            RibbonPanel myPanel  = application.CreateRibbonPanel("MYAPP", "ARC");
            RibbonPanel myPanel2 = application.CreateRibbonPanel("MYAPP", "NEEDS");

            string         thisAssemblyPath = Assembly.GetExecutingAssembly().Location;
            PushButtonData pushButtonData   = new PushButtonData("CreateColumn", "结构柱", thisAssemblyPath, "Code.CreateColumn");
            PushButtonData pushButtonData2  = new PushButtonData("PipeCut", "墙套管剪切", thisAssemblyPath, "Code.WallCutPipe");
            PushButton     pushButton       = myPanel.AddItem(pushButtonData) as PushButton;
            PushButton     pushButton2      = myPanel.AddItem(pushButtonData2) as PushButton;

            pushButton.ToolTip = "框选详图线创建结构柱。";

            Uri         uriImage    = new Uri(@"G:\Resource\01icon\_1.png");
            Uri         uriImage2   = new Uri(@"G:\Resource\01icon\_2.png");
            BitmapImage largeImage  = new BitmapImage(uriImage);
            BitmapImage largeImage2 = new BitmapImage(uriImage2);

            pushButton.LargeImage  = largeImage;
            pushButton2.LargeImage = largeImage2;

            return(Result.Succeeded);
        }
Exemplo n.º 16
0
        private DemoStackPanels()
        {
            var btn_prev = new PushButton()
            {
                Margin = new Thickness(10, 5), Text = "Prev"
            };

            btn_prev.Click += new EventHandler(btn_prev_Click);

            var btn_next = new PushButton()
            {
                Margin = new Thickness(10, 5), Text = "Next"
            };

            btn_next.Click += new EventHandler(btn_next_Click);
            btn_next.HorizontalAlignment = HorizontalAlignment.Center;

            var hstack = new StackPanel()
            {
                HorizontalOrientation = true
            };

            hstack.Background = Colors.Blue;
            hstack.Children.Add(btn_prev);

            var vstack = new StackPanel();

            vstack.Background = Colors.Pink;
            hstack.Children.Add(vstack);

            hstack.Children.Add(btn_next);

            vstack.Children.Add(
                new PushButton()
            {
                Margin = new Thickness(10, 5)
            }
                );

            {
                var ctr = new StackPanel()
                {
                    HorizontalOrientation = true
                };
                ctr.Background = Colors.DarkGreen;
                vstack.Children.Add(ctr);

                for (int i = 0; i < 3; i++)
                {
                    var btn = new PushButton()
                    {
                        Text = i.ToString()
                    };
                    btn.Margin = new Thickness(5);
                    ctr.Children.Add(btn);
                }
            }

            vstack.Children.Add(
                new PushButton()
            {
                Margin = new Thickness(10, 5)
            }
                );

            this.Content = hstack;
        }
Exemplo n.º 17
0
        private DemoSliders()
        {
            var btn_prev = new PushButton()
            {
                Margin = new Thickness(10, 5), Text = "Prev"
            };

            btn_prev.Click += new EventHandler(btn_prev_Click);
            btn_prev.HorizontalAlignment = MicroWPF.HorizontalAlignment.Left;
            btn_prev.VerticalAlignment   = MicroWPF.VerticalAlignment.Bottom;

            var btn_next = new PushButton()
            {
                Margin = new Thickness(10, 5), Text = "Next"
            };

            btn_next.Click += new EventHandler(btn_next_Click);
            btn_next.HorizontalAlignment = HorizontalAlignment.Right;
            btn_next.VerticalAlignment   = MicroWPF.VerticalAlignment.Bottom;

            var grid = new Grid();

            grid.Name   = "GRID";
            grid.Margin = new Thickness(20);

            grid.AddColumnDefinition(1, GridUnitType.Star);
            grid.AddColumnDefinition(1, GridUnitType.Star);
            grid.AddColumnDefinition(2, GridUnitType.Star);

            grid.AddRowDefinition(1, GridUnitType.Star);
            grid.AddRowDefinition(1, GridUnitType.Star);
            grid.AddRowDefinition(1, GridUnitType.Star);

            {
                var vslider = new Slider();
                vslider.Max    = 100;
                vslider.Width  = 20;
                vslider.Height = 200;
                grid.SetRowCol(vslider, 0, 0, 3, 1);
                grid.Children.Add(vslider);
            }
            {
                var vslider = new Slider();
                vslider.Max    = 100;
                vslider.Width  = 20;
                vslider.Height = 200;
                grid.SetRowCol(vslider, 0, 1, 3, 1);
                grid.Children.Add(vslider);
            }
            {
                var hslider = new Slider();
                hslider.Max    = 100;
                hslider.Width  = 200;
                hslider.Height = 20;
                grid.SetRowCol(hslider, 0, 2);
                grid.Children.Add(hslider);
            }
            {
                var hslider = new Slider();
                hslider.Max    = 100;
                hslider.Width  = 200;
                hslider.Height = 20;
                grid.SetRowCol(hslider, 1, 2);
                grid.Children.Add(hslider);
            }
            {
                grid.SetRowCol(btn_prev, 2, 2);
                grid.Children.Add(btn_prev);
            }
            {
                grid.SetRowCol(btn_next, 2, 2);
                grid.Children.Add(btn_next);
            }

            this.Content = grid;
        }
Exemplo n.º 18
0
        void Initialize()
        {
            Window.Instance.KeyEvent += OnKeyEvent;

            image          = new ImageView();
            image.Size2D   = new Size2D(500, 200);
            image.Position = new Position(750, 275, 0);
            image.PositionUsesPivotPoint = true;
            image.PivotPoint             = PivotPoint.TopLeft;
            image.ParentOrigin           = ParentOrigin.TopLeft;
            image.SetImage(DirectoryInfo.Resource + "tizen_image.jpg");
            Window.Instance.GetDefaultLayer().Add(image);

            _opacityButton     = CreateButton("OpacityAnimation");
            _orientationButton = CreateButton("OrientationAnimation");
            _pixelAreaButton   = CreateButton("pixelAreaAnimation");

            _opacityButton.Clicked     += ButtonClick;
            _orientationButton.Clicked += ButtonClick;
            _pixelAreaButton.Clicked   += ButtonClick;

            TableView tableView = new TableView(1, 3);

            tableView.Size2D       = new Size2D(1300, 330);
            tableView.PivotPoint   = PivotPoint.TopLeft;
            tableView.ParentOrigin = ParentOrigin.TopLeft;
            tableView.Position2D   = new Position2D(400, 800);

            tableView.AddChild(_orientationButton, new TableView.CellPosition(0, 0));
            tableView.AddChild(_opacityButton, new TableView.CellPosition(0, 1));
            tableView.AddChild(_pixelAreaButton, new TableView.CellPosition(0, 2));

            Window.Instance.GetDefaultLayer().Add(tableView);

            opacityAnimation     = new Animation();
            orientationAnimation = new Animation();
            pixelAreaAnimation   = new Animation();

            opacityAnimation = new Animation(1500);
            opacityAnimation.AnimateTo(image, "Opacity", 0.5f, 0, 400);
            opacityAnimation.AnimateTo(image, "Opacity", 0.0f, 400, 800);
            opacityAnimation.AnimateTo(image, "Opacity", 0.7f, 800, 1250);
            opacityAnimation.AnimateTo(image, "Opacity", 1.0f, 1250, 1500);
            opacityAnimation.EndAction = Animation.EndActions.StopFinal;

            orientationAnimation = new Animation();
            orientationAnimation.AnimateTo(image, "Orientation", new Rotation(new Radian(new Degree(200.0f)), PositionAxis.X), 0, 400);
            orientationAnimation.AnimateTo(image, "Orientation", new Rotation(new Radian(new Degree(60.0f)), PositionAxis.Y), 400, 800);
            orientationAnimation.AnimateTo(image, "Orientation", new Rotation(new Radian(new Degree(30.0f)), PositionAxis.Z), 800, 1000);
            orientationAnimation.AnimateTo(image, "Orientation", new Rotation(new Radian(0.0f), PositionAxis.X), 1000, 1400);
            orientationAnimation.AnimateTo(image, "Orientation", new Rotation(new Radian(0.0f), PositionAxis.Y), 1400, 1800);
            orientationAnimation.AnimateTo(image, "Orientation", new Rotation(new Radian(0.0f), PositionAxis.Z), 1800, 2200);
            orientationAnimation.EndAction = Animation.EndActions.StopFinal;

            pixelAreaAnimation = new Animation(2000);
            RelativeVector4 vec1 = new RelativeVector4(0.0f, 0.0f, 1.0f, 0.3f);
            RelativeVector4 vec2 = new RelativeVector4(0.6f, 0.0f, 1.0f, 0.4f);
            RelativeVector4 vec3 = new RelativeVector4(0.0f, 0.0f, 1.0f, 1.0f);

            pixelAreaAnimation.AnimateTo(image, "pixelArea", vec1, 0, 500);
            pixelAreaAnimation.AnimateTo(image, "pixelArea", vec2, 500, 1000);
            pixelAreaAnimation.AnimateTo(image, "pixelArea", vec3, 1500, 2000);
            pixelAreaAnimation.EndAction = Animation.EndActions.StopFinal;
        }
Exemplo n.º 19
0
        private DemoGridSpan()
        {
            var grid = new Grid();

            grid.Margin = new Thickness(20, 10);
            grid.Width  = 400;
            grid.Height = 220;
            grid.HorizontalAlignment = MicroWPF.HorizontalAlignment.Center;
            grid.VerticalAlignment   = MicroWPF.VerticalAlignment.Center;

            grid.AddColumnDefinition(1, GridUnitType.Star);
            grid.AddColumnDefinition(2, GridUnitType.Star);
            grid.AddColumnDefinition(3, GridUnitType.Star);
            grid.AddColumnDefinition(1, GridUnitType.Star);

            grid.AddRowDefinition(1, GridUnitType.Star);
            grid.AddRowDefinition(2, GridUnitType.Star);
            grid.AddRowDefinition(3, GridUnitType.Star);
            grid.AddRowDefinition(1, GridUnitType.Star);

            var btn_prev = new PushButton()
            {
                Text = "Prev"
            };

            btn_prev.Click += new EventHandler(btn_prev_Click);
            btn_prev.HorizontalAlignment = HorizontalAlignment.Left;
            grid.SetRowCol(btn_prev, 0, 0, 1, 2);

            var btn_next = new PushButton()
            {
                Text = "Next"
            };

            btn_next.Click += new EventHandler(btn_next_Click);
            grid.SetRowCol(btn_next, 0, 2, 1, 2);
            grid.Children.Add(btn_next);

            var btn_dlg = new PushButton()
            {
                Margin = new Thickness(10, 5), HorizontalAlignment = HorizontalAlignment.Stretch
            };

            btn_dlg.Text   = "Dialog";
            btn_dlg.Click += new EventHandler(btn_dlg_Click);
            grid.SetRowCol(btn_dlg, 1, 0, 3, 2);
            grid.Children.Add(btn_dlg);

            var vstack2 = new StackPanel()
            {
                Name = "V2", Background = Colors.Red
            };

            vstack2.Children.Add(new TextBlock()
            {
                Font = 21,
                Text = "Betty the cat!",
                HorizontalAlignment = MicroWPF.HorizontalAlignment.Left,
                Background          = Colors.DarkOrange,
                Foreground          = Colors.Lime,
                Margin = new Thickness(20, 20),
            });
            grid.Children.Add(vstack2);
            grid.SetRowCol(vstack2, 1, 2, 1, 2);

            {
                var toggle = new ToggleSwitch()
                {
                    VerticalAlignment = MicroWPF.VerticalAlignment.Center, Font = 31
                };
                grid.SetRowCol(toggle, 2, 2);
                grid.Children.Add(toggle);
            }
            {
                var toggle = new ToggleSwitch()
                {
                    VerticalAlignment = MicroWPF.VerticalAlignment.Center, Font = 20
                };
                grid.SetRowCol(toggle, 3, 2);
                grid.Children.Add(toggle);
            }

            this.Content = grid;
        }
Exemplo n.º 20
0
        public static void CreateAlignIcons(RibbonPanel rPanel)
        {
            string location = Assembly.GetExecutingAssembly().Location;

            //adding buttons

            //Button 1

            PushButtonData pushButtonData1 = new PushButtonData("alignLeftButton", "Align Left", location, "AlignTag.AlignLeft");
            PushButton     pB1             = rPanel.AddItem(pushButtonData1) as PushButton;

            pB1.ToolTip = "Align Tags or Elements Left";
            BitmapImage pb1LargeImage = new BitmapImage(new Uri("pack://application:,,,/AEW_Ribbon;component/Resources/AlignLeftLarge.png"));
            BitmapImage pb1Image      = new BitmapImage(new Uri("pack://application:,,,/AEW_Ribbon;component/Resources/AlignLeftSmall.png"));

            // Button 2
            PushButtonData pushButtonData2 = new PushButtonData("alignRightButton", "Align Right", location, "AlignTag.AlignRight");
            PushButton     pB2             = rPanel.AddItem(pushButtonData2) as PushButton;

            pB2.ToolTip = "Align Tags or Elements Right";
            BitmapImage pb2LargeImage = new BitmapImage(new Uri("pack://application:,,,/AEW_Ribbon;component/Resources/AlignRightLarge.png"));
            BitmapImage pb2Image      = new BitmapImage(new Uri("pack://application:,,,/AEW_Ribbon;component/Resources/AlignRightSmall.png"));

            // Button 3

            PushButtonData pushButtonData3 = new PushButtonData("alignTopButton", "Align Top", location, "AlignTag.AlignTop");
            PushButton     pB3             = rPanel.AddItem(pushButtonData3) as PushButton;

            pB3.ToolTip = "Align Tags or Elements Top";
            BitmapImage pb3LargeImage = new BitmapImage(new Uri("pack://application:,,,/AEW_Ribbon;component/Resources/AlignTopLarge.png"));
            BitmapImage pb3Image      = new BitmapImage(new Uri("pack://application:,,,/AEW_Ribbon;component/Resources/AlignTopSmall.png"));

            //Button 4
            PushButtonData pushButtonData4 = new PushButtonData("alignBottomButton", "Align Bottom", location, "AlignTag.AlignBottom");
            PushButton     pB4             = rPanel.AddItem(pushButtonData4) as PushButton;

            pB4.ToolTip = "Align Tags or Elements Bottom";
            BitmapImage pb4LargeImage = new BitmapImage(new Uri("pack://application:,,,/AEW_Ribbon;component/Resources/AlignBottomLarge.png"));
            BitmapImage pb4Image      = new BitmapImage(new Uri("pack://application:,,,/AEW_Ribbon;component/Resources/AlignBottomSmall.png"));

            // Button 5
            PushButtonData pushButtonData5 = new PushButtonData("alignCenterButton", "Align Center", location, "AlignTag.AlignCenter");
            PushButton     pB5             = rPanel.AddItem(pushButtonData5) as PushButton;

            pB5.ToolTip = "Align Tags or Elements Center";
            BitmapImage pb5LargeImage = new BitmapImage(new Uri("pack://application:,,,/AEW_Ribbon;component/Resources/AlignCenterLarge.png"));
            BitmapImage pb5Image      = new BitmapImage(new Uri("pack://application:,,,/AEW_Ribbon;component/Resources/AlignCenterSmall.png"));

            // Button 6
            PushButtonData pushButtonData6 = new PushButtonData("alignMiddleButton", "Align Middle", location, "AlignTag.AlignMiddle");
            PushButton     pB6             = rPanel.AddItem(pushButtonData6) as PushButton;

            pB6.ToolTip = "Align Tags or Elements Middle";
            BitmapImage pb6LargeImage = new BitmapImage(new Uri("pack://application:,,,/AEW_Ribbon;component/Resources/AlignMiddleLarge.png"));
            BitmapImage pb6Image      = new BitmapImage(new Uri("pack://application:,,,/AEW_Ribbon;component/Resources/AlignMiddleSmall.png"));

            // Button 7
            PushButtonData pushButtonData7 = new PushButtonData("distributeHorizontallyButton", "Distribute\nHorizontally", location, "AlignTag.DistributeHorizontally");
            PushButton     pB7             = rPanel.AddItem(pushButtonData7) as PushButton;

            pB7.ToolTip = "Distribute Tags or Elements Horizontally";
            BitmapImage pb7LargeImage = new BitmapImage(new Uri("pack://application:,,,/AEW_Ribbon;component/Resources/DistributeHorizontallyLarge.png"));
            BitmapImage pb7Image      = new BitmapImage(new Uri("pack://application:,,,/AEW_Ribbon;component/Resources/DistributeHorizontallySmall.png"));

            // Button 8
            PushButtonData pushButtonData8 = new PushButtonData("distributeVerticallyButton", "Distribute\nVertically", location, "AlignTag.DistributeVertically");
            PushButton     pB8             = rPanel.AddItem(pushButtonData8) as PushButton;

            pB8.ToolTip = "Distribute Tags or Elements Vertically";
            BitmapImage pb8LargeImage = new BitmapImage(new Uri("pack://application:,,,/AEW_Ribbon;component/Resources/DistributeVerticallyLarge.png"));
            BitmapImage pb8Image      = new BitmapImage(new Uri("pack://application:,,,/AEW_Ribbon;component/Resources/DistributeVerticallySmall.png"));

            // Button 9
            PushButtonData pushButtonData9 = new PushButtonData("ArrangeButton", "Arrange\nTags", location, "AlignTag.Arrange");
            PushButton     pB9             = rPanel.AddItem(pushButtonData9) as PushButton;

            pB9.ToolTip = "Arrange Tags around the view";
            BitmapImage pb9LargeImage = new BitmapImage(new Uri("pack://application:,,,/AEW_Ribbon;component/Resources/ArrangeLarge.png"));
            BitmapImage pb9Image      = new BitmapImage(new Uri("pack://application:,,,/AEW_Ribbon;component/Resources/ArrangeSmall.png"));

            // Button 10
            PushButtonData pushButtonData10 = new PushButtonData("UntangleVerticallyButton", "Untangle\nVertically", location, "AlignTag.UntangleVertically");
            PushButton     pB10             = rPanel.AddItem(pushButtonData10) as PushButton;

            pB10.ToolTip = "Untangle Vertically Tags or Elements ";
            BitmapImage pb10LargeImage = new BitmapImage(new Uri("pack://application:,,,/AEW_Ribbon;component/Resources/UntangleVerticallyLarge.png"));
            BitmapImage pb10Image      = new BitmapImage(new Uri("pack://application:,,,/AEW_Ribbon;component/Resources/UntangleVerticallySmall.png"));

            // Button 11
            PushButtonData pushButtonData11 = new PushButtonData("UntangleHorizontallyButton", "Untangle\nHorizontally", location, "AlignTag.UntangleHorizontally");
            PushButton     pB11             = rPanel.AddItem(pushButtonData11) as PushButton;

            pB11.ToolTip = "Untangle Horizontally Tags or Elements ";
            BitmapImage pb11LargeImage = new BitmapImage(new Uri("pack://application:,,,/AEW_Ribbon;component/Resources/UntangleHorizontallyLarge.png"));
            BitmapImage pb11Image      = new BitmapImage(new Uri("pack://application:,,,/AEW_Ribbon;component/Resources/UntangleHorizontallySmall.png"));

            rPanel.AddStackedItems((RibbonItemData)pushButtonData1, (RibbonItemData)pushButtonData5, (RibbonItemData)pushButtonData2);
            rPanel.AddStackedItems((RibbonItemData)pushButtonData3, (RibbonItemData)pushButtonData6, (RibbonItemData)pushButtonData4);
            rPanel.AddStackedItems((RibbonItemData)pushButtonData7, (RibbonItemData)pushButtonData8, (RibbonItemData)pushButtonData9);
            rPanel.AddStackedItems((RibbonItemData)pushButtonData10, (RibbonItemData)pushButtonData11);
        }
Exemplo n.º 21
0
        private void Apply(
      PushButton field
      )
        {
            Document document = field.Document;
              Widget widget = field.Widgets[0];

              Appearance appearance = widget.Appearance;
              if(appearance == null)
              {widget.Appearance = appearance = new Appearance(document);}

              FormXObject normalAppearanceState;
              {
            SizeF size = widget.Box.Size;
            normalAppearanceState = new FormXObject(document, size);
            PrimitiveComposer composer = new PrimitiveComposer(normalAppearanceState);

            float lineWidth = 1;
            RectangleF frame = new RectangleF(lineWidth / 2, lineWidth / 2, size.Width - lineWidth, size.Height - lineWidth);
            if(GraphicsVisibile)
            {
              composer.BeginLocalState();
              composer.SetLineWidth(lineWidth);
              composer.SetFillColor(BackColor);
              composer.SetStrokeColor(ForeColor);
              composer.DrawRectangle(frame, 5);
              composer.FillStroke();
              composer.End();
            }

            string title = (string)field.Value;
            if(title != null)
            {
              BlockComposer blockComposer = new BlockComposer(composer);
              blockComposer.Begin(frame,XAlignmentEnum.Center,YAlignmentEnum.Middle);
              composer.SetFillColor(ForeColor);
              composer.SetFont(
            new StandardType1Font(
              document,
              StandardType1Font.FamilyEnum.Helvetica,
              true,
              false
              ),
            size.Height * 0.5
            );
              blockComposer.ShowText(title);
              blockComposer.End();
            }

            composer.Flush();
              }
              appearance.Normal[null] = normalAppearanceState;
        }
Exemplo n.º 22
0
    public override void Begin()
    {
        #if DEBUG
        SetWindowSize(1024, 768);
        showDebug = true;
        IsFullScreen = false;
        #else
        SetWindowTopmost(topmost);
        #endif
        Level.Background.Color = Color.White;

        IsMouseVisible = true;

        // Escape disabled for the "kiosk"-mode. Use Alt+F4 to quit.
        //Keyboard.Listen(Key.Escape, Jypeli.ButtonState.Pressed, ConfirmExit, "Lopeta peli");
        Keyboard.Listen(Key.P, Jypeli.ButtonState.Pressed, PauseProcess, "Pistä tauolle");
        Keyboard.Listen(Key.T, Jypeli.ButtonState.Pressed, ToggleTopmost, "Tuo päällimmäiseksi");
        Keyboard.Listen(Key.L, Jypeli.ButtonState.Pressed, LoopAction, "Luuppaa, eli toista toimintoa");
        Keyboard.Listen(Key.D, Jypeli.ButtonState.Pressed, ShowDebug, "Näytä Debug -viestit");
        Exiting += StopThread;

        /* Read settings from ini-file */
        ReadGameInfoAndSettings();
        if (!CheckExecutablePaths())
            return;

        taskQueue = new Queue<Tuple<GameRecord, Task>>();

        /* Set up the UI */
        GameObject logo = new GameObject(LoadImage("logo"));
        Add(logo);

        // Create buttons
        int totalBtnCnt = 1 + tools.Count + 7;
        int iBtn = 3;
        double step = Screen.Height / totalBtnCnt+2;

        logo.Y = step * (totalBtnCnt / 2 - 2);

        playGameButton = new PushButton(400, 50, "Pelaa uusinta versiota pelistä");
        playGameButton.Y = step * (totalBtnCnt / 2 - ++iBtn);
        playGameButton.Clicked += PlayGamePressed;
        Add(playGameButton);

        foreach (var tool in tools)
        {
            ContentTool loopToolRef = tool;
            PushButton createContentButton = new PushButton(400, 50, "Tee uusi " + tool.ContentDescription + " peliin");
            createContentButton.Clicked += () => CreateContentPressed(loopToolRef);
            createContentButton.Y = step * (totalBtnCnt / 2 - ++iBtn);
            Add(createContentButton);
            createContentButtons.Add(createContentButton);
        }

        // Optional
        if (SettingsFromIni.VCSExePath!="" && File.Exists(SettingsFromIni.VCSExePath))
        {
            modifyCodeButton = new PushButton(400, 50, "Muuta pelin ohjelmakoodia");
            modifyCodeButton.Y = step * (totalBtnCnt / 2 - ++iBtn);
            modifyCodeButton.Clicked += ModifyCodePressed;
            Add(modifyCodeButton);
        }

        addContentButton = new PushButton(400, 50, "Lisää tekemäsi sisältö peliin");
        addContentButton.Y = step * (totalBtnCnt / 2 - ++iBtn);
        addContentButton.Clicked += AddContentPressed;
        Add(addContentButton);

        taskQueue.Enqueue(new Tuple<GameRecord, Task>(WorkshopGame.Clone() as GameRecord, Task.Checkout));
        StartThreadedTaskListProcessor();

        EnableButtons(true);
    }
        private void Initialize()
        {
            // Change the background color of Window to White
            Window window = Window.Instance;

            window.BackgroundColor = Color.White;
            // Create first new view
            View view = new View();

            view.Name = "CustomLayoutView";
            //view.ParentOrigin = ParentOrigin.Center;
            //view.PivotPoint = PivotPoint.Center;
            //view.PositionUsesPivotPoint = true;
            // Set our Custom Layout on the first view
            var layout = new CustomLayout();

            view.Layout                   = layout;
            view.WidthSpecification       = ChildLayoutData.WrapContent;
            view.HeightSpecificationFixed = 350;
            view.BackgroundColor          = Color.Blue;

            // Create second View
            View littleView = new View();

            littleView.Name = "LittleView";
            // Set our Custom Layout on the little view
            var layout2 = new CustomLayout();

            littleView.Layout = layout2;
            littleView.SetProperty(LayoutItemWrapper.ChildProperty.WIDTH_SPECIFICATION, new PropertyValue(-2));
            littleView.SetProperty(LayoutItemWrapper.ChildProperty.HEIGHT_SPECIFICATION, new PropertyValue(-2));
            littleView.BackgroundColor = Color.Red;
            littleView.Position2D      = new Position2D(50, 50);
            // Add second View to a Layer
            _layer2 = new Layer();
            window.AddLayer(_layer2);
            _layer2.Add(littleView);

            // Create single single ImageView in it's own Layer
            _layer = new Layer();
            window.AddLayer(_layer);
            //_layer.Add(CreateChildImageView(TestImages.s_images[1], new Size2D(100, 100)));
            _layer.Add(view);
            // Initially single ImageView is not on top.
            _layer2.Raise();
            // Add an ImageView directly to window
            window.Add(CreateChildImageView(TestImages.s_images[2], new Size2D(200, 200)));
            // Add child image-views to the created view
            foreach (String image in TestImages.s_images)
            {
                view.Add(CreateChildImageView(image, new Size2D(100, 100)));
                littleView.Add(CreateChildImageView(image, new Size2D(50, 50)));
            }
            // Example info
            TextLabel label = new TextLabel("Blue icon in a layer");

            label.ParentOrigin = ParentOrigin.TopCenter;
            label.Position2D   = new Position2D(-50, 0);
            window.Add(label);
            // Add button to Raise or Lower the single ImageView
            PushButton button = new PushButton();

            button.LabelText              = "Raise Layer";
            button.ParentOrigin           = ParentOrigin.BottomCenter;
            button.PivotPoint             = PivotPoint.BottomCenter;
            button.PositionUsesPivotPoint = true;
            window.Add(button);

            button.Focusable = true;
            button.KeyEvent += Button_KeyEvent;
            FocusManager.Instance.SetCurrentFocusView(button);
        }
        /// <summary>
        /// Script Layout Sample Application initialization.
        /// </summary>
        private void Initialize()
        {
            //Window.Instance.BackgroundColor = new Color(0.9f, 0.9f, 0.9f, 1.0f);
            Window.Instance.BackgroundColor = Color.Black;
            //Window.Instance.BackgroundColor = Color.White;
            View focusIndicator = new View();

            FocusManager.Instance.FocusIndicator = focusIndicator;
            themePath = defaultThemePath;

            // Applies a new theme to the application.
            // This will be merged on top of the default Toolkit theme.
            // If the application theme file doesn't style all controls that the
            // application uses, then the default Toolkit theme will be used
            // instead for those controls.
            StyleManager.Get().ApplyTheme(defaultThemePath);
            //Create the title
            guide                        = new TextLabel();
            guide.StyleName              = "Title";
            guide.HorizontalAlignment    = HorizontalAlignment.Center;
            guide.VerticalAlignment      = VerticalAlignment.Center;
            guide.PositionUsesPivotPoint = true;
            guide.ParentOrigin           = ParentOrigin.TopLeft;
            guide.PivotPoint             = PivotPoint.TopLeft;
            guide.Size2D                 = new Size2D(1920, 96);
            guide.FontFamily             = "Samsung One 600";
            guide.Position2D             = new Position2D(0, 94);
            guide.MultiLine              = false;
            //guide.PointSize = 15.0f;
            guide.PointSize       = DeviceCheck.PointSize15;
            guide.Text            = "Script Sample \n";
            guide.TextColor       = Color.White;
            guide.BackgroundColor = Color.Black;//new Color(43.0f / 255.0f, 145.0f / 255.0f, 175.0f / 255.0f, 1.0f);
            Window.Instance.GetDefaultLayer().Add(guide);

            //The container of the RadioButtons, CheckBoxButtons, Sliders, and the big ImageView
            TableView content = new TableView(6, 6);

            //content.BackgroundColor = Color.Black;
            content.Position2D             = new Position2D(100, 275);
            content.Size2D                 = new Size2D(1000, 500);
            content.PositionUsesPivotPoint = true;
            content.ParentOrigin           = ParentOrigin.TopLeft;
            content.PivotPoint             = PivotPoint.TopLeft;
            content.CellPadding            = new Vector2(0, 5);
            for (uint i = 0; i < content.Rows; ++i)
            {
                content.SetFitHeight(i);
            }

            for (uint i = 0; i < content.Columns; ++i)
            {
                content.SetFitWidth(i);
            }

            Window.Instance.GetDefaultLayer().Add(content);
            string[] images = { smallImage1, smallImage2, smallImage3 };
            mRadioButtons = new RadioButton[3];
            for (uint i = 0; i <= 2; i++)
            {
                ImageView image = new ImageView(images[i]);
                image.Name   = "thumbnail" + (i + 1);
                image.Size2D = new Size2D(60, 60);

                mRadioButtons[i] = CreateRadioButton((i + 1).ToString());

                if (DeviceCheck.IsSREmul())
                {
                    mRadioButtons[i].StyleName = "RadioButton";
                }
                else
                {
                    mRadioButtons[i].StyleName = "TVRadioButton";
                }
                content.AddChild(mRadioButtons[i], new TableView.CellPosition(i, 0));
                content.AddChild(image, new TableView.CellPosition(i, 1));
                content.SetCellAlignment(new TableView.CellPosition(i, 0), HorizontalAlignmentType.Left, VerticalAlignmentType.Center);
                content.SetCellAlignment(new TableView.CellPosition(i, 1), HorizontalAlignmentType.Left, VerticalAlignmentType.Center);
            }

            mRadioButtons[0].Selected = true;
            //Set the focus to the first radioButton when the apps loaded
            FocusManager.Instance.SetCurrentFocusView(mRadioButtons[0]);

            string[] checkboxLabels = { "R", "G", "B" };
            mCheckButtons   = new CheckBoxButton[3];
            mChannelSliders = new Slider[3];
            for (uint i = 3; i <= 5; i++)
            {
                mCheckButtons[i - 3]          = CreateCheckBox(checkboxLabels[i - 3]);
                mCheckButtons[i - 3].Selected = true;
                mCheckButtons[i - 3].Name     = "channelActiveCheckBox" + (i - 2).ToString();
                mChannelSliders[i - 3]        = CreateSlider();
                mChannelSliders[i - 3].Name   = "ColorSlider" + (i - 2);
                mChannelSliders[i - 3].Size2D = new Size2D(800, 80);
                // Set the current value of mChannelSliders;
                mChannelSliders[i - 3].KeyEvent     += ChannelSliderKeyEvent;
                mChannelSliders[i - 3].ValueChanged += OnSliderChanged;

                // Set the style according to the target devices
                if (DeviceCheck.IsSREmul())
                {
                    mCheckButtons[i - 3].StyleName = "CheckBoxButton";
                }
                else
                {
                    mCheckButtons[i - 3].StyleName = "TVCheckBoxButton";
                }

                content.AddChild(mCheckButtons[i - 3], new TableView.CellPosition(i, 0));
                content.AddChild(mChannelSliders[i - 3], new TableView.CellPosition(i, 1));
                content.SetCellAlignment(new TableView.CellPosition(i, 0), HorizontalAlignmentType.Left, VerticalAlignmentType.Center);
                content.SetCellAlignment(new TableView.CellPosition(i, 1), HorizontalAlignmentType.Left, VerticalAlignmentType.Center);
            }

            mImagePlacement        = new ImageView(bigImage1);
            mImagePlacement.Size2D = new Size2D(500, 500);
            mImagePlacement.PositionUsesPivotPoint = true;
            mImagePlacement.PivotPoint             = PivotPoint.TopLeft;
            mImagePlacement.ParentOrigin           = ParentOrigin.TopLeft;
            mImagePlacement.Position2D             = new Position2D(1320, 230);
            Window.Instance.GetDefaultLayer().Add(mImagePlacement);

            defaultThemeButton            = CreateButton("DefaultTheme", "DefaultTheme", new Size2D(400, 80));
            defaultThemeButton.Position2D = new Position2D(373, 900);
            defaultThemeButton.Clicked   += OnThemeButtonClicked;
            Window.Instance.GetDefaultLayer().Add(defaultThemeButton);
            customThemeButton            = CreateButton("CustomTheme", "CustomTheme", new Size2D(400, 80));
            customThemeButton.Position2D = new Position2D(1146, 900);
            customThemeButton.Clicked   += OnThemeButtonClicked;
            Window.Instance.GetDefaultLayer().Add(customThemeButton);

            if (DeviceCheck.IsSREmul())
            {
                defaultThemeButton.StyleName = "PushButton";
                customThemeButton.StyleName  = "PushButton";
            }
            else
            {
                defaultThemeButton.StyleName = "TVPushButton";
                customThemeButton.StyleName  = "TVPushButton";
            }

            defaultThemeButton.RightFocusableView = customThemeButton;
            customThemeButton.LeftFocusableView   = defaultThemeButton;
            defaultThemeButton.UpFocusableView    = mCheckButtons[2];
            mCheckButtons[2].DownFocusableView    = defaultThemeButton;
            customThemeButton.UpFocusableView     = mChannelSliders[2];
            Window.Instance.KeyEvent += AppBack;
        }
Exemplo n.º 25
0
        public override void Create()
        {
            Window window = Window.Instance;

            view                        = new View();
            view.Name                   = "FlexExample";
            view.ParentOrigin           = ParentOrigin.TopLeft;
            view.PivotPoint             = PivotPoint.TopLeft;
            view.PositionUsesPivotPoint = true;
            view.WidthSpecification     = LayoutParamPolicies.MatchParent;
            int viewHeight = (int)(window.Size.Height * .90);

            view.HeightSpecification = viewHeight;

            view.PositionY = window.Size.Height - viewHeight;

            view.Padding = new Extents(190, 150, 100, 100);
            var layout = new FlexLayout();

            layout.WrapType       = FlexLayout.FlexWrapType.NoWrap;
            layout.ItemsAlignment = FlexLayout.AlignmentType.Center;
            view.Layout           = layout;
            view.LayoutDirection  = ViewLayoutDirectionType.LTR;

            // Add child image-views to the created view

            foreach (String image in TestImages.s_images)
            {
                ImageView imageView = LayoutingExample.CreateChildImageView(image, new Size2D(100, 100));
                view.Add(imageView);
            }

            window.Add(view);

            PushButton directionButton = new PushButton();

            LayoutingExample.SetUnselectedIcon(directionButton, "./res/images/icon-reverse.png");
            LayoutingExample.SetSelectedIcon(directionButton, "./res/images/icon-reverse-selected.png");
            directionButton.ParentOrigin           = new Vector3(0.2f, 1.0f, 0.5f);
            directionButton.PivotPoint             = PivotPoint.BottomCenter;
            directionButton.PositionUsesPivotPoint = true;
            directionButton.MinimumSize            = new Vector2(75, 75);
            directionButton.Clicked += (sender, e) =>
            {
                if (this.view.LayoutDirection == ViewLayoutDirectionType.LTR)
                {
                    this.view.LayoutDirection = ViewLayoutDirectionType.RTL;
                    LayoutingExample.SetUnselectedIcon(directionButton, "./res/images/icon-play.png");
                    LayoutingExample.SetSelectedIcon(directionButton, "./res/images/icon-play-selected.png");
                }
                else
                {
                    this.view.LayoutDirection = ViewLayoutDirectionType.LTR;
                    LayoutingExample.SetUnselectedIcon(directionButton, "./res/images/icon-reverse.png");
                    LayoutingExample.SetSelectedIcon(directionButton, "./res/images/icon-reverse-selected.png");
                }
                return(true);
            };

            window.Add(directionButton);
            buttons.Add(directionButton);


            PushButton wrapButton = new PushButton();

            LayoutingExample.SetUnselectedIcon(wrapButton, "./res/images/icon-w.png");
            LayoutingExample.SetSelectedIcon(wrapButton, "./res/images/icon-w-selected.png");
            wrapButton.ParentOrigin           = new Vector3(0.4f, 1.0f, 0.5f);
            wrapButton.PivotPoint             = PivotPoint.BottomCenter;
            wrapButton.PositionUsesPivotPoint = true;
            wrapButton.MinimumSize            = new Vector2(75, 75);
            wrapButton.Clicked += (sender, e) =>
            {
                FlexLayout flexLayout = (FlexLayout)this.view.Layout;
                if (flexLayout.WrapType == FlexLayout.FlexWrapType.Wrap)
                {
                    view.Padding              = new Extents(0, 0, 0, 0);
                    flexLayout.WrapType       = FlexLayout.FlexWrapType.NoWrap;
                    flexLayout.Alignment      = FlexLayout.AlignmentType.Center;
                    flexLayout.ItemsAlignment = FlexLayout.AlignmentType.Center;
                }
                else
                {
                    view.Padding              = new Extents(25, 25, 75, 75);
                    flexLayout.WrapType       = FlexLayout.FlexWrapType.Wrap;
                    flexLayout.Alignment      = FlexLayout.AlignmentType.FlexStart;
                    flexLayout.ItemsAlignment = FlexLayout.AlignmentType.FlexStart;
                }
                return(true);
            };

            window.Add(wrapButton);
            buttons.Add(wrapButton);

            PushButton justifyButton = new PushButton();

            LayoutingExample.SetUnselectedIcon(justifyButton, "./res/images/icon-item-view-layout-grid.png");
            LayoutingExample.SetSelectedIcon(justifyButton, "./res/images/icon-item-view-layout-grid-selected.png");
            justifyButton.ParentOrigin           = new Vector3(0.6f, 1.0f, 0.5f);
            justifyButton.PivotPoint             = PivotPoint.BottomCenter;
            justifyButton.PositionUsesPivotPoint = true;
            justifyButton.MinimumSize            = new Vector2(75, 75);
            justifyButton.Clicked += (sender, e) =>

            {
                FlexLayout flexLayout = (FlexLayout)this.view.Layout;

                if (flexLayout.Justification == FlexLayout.FlexJustification.FlexStart)
                {
                    flexLayout.Justification = FlexLayout.FlexJustification.Center;
                }
                else
                {
                    flexLayout.Justification = FlexLayout.FlexJustification.FlexStart;
                }

                return(true);
            };
            window.Add(justifyButton);
            buttons.Add(justifyButton);


            PushButton rotateButton = new PushButton();

            LayoutingExample.SetUnselectedIcon(rotateButton, "./res/images/icon-reset.png");
            LayoutingExample.SetSelectedIcon(rotateButton, "./res/images/icon-reset-selected.png");
            rotateButton.ParentOrigin           = new Vector3(0.8f, 1.0f, 0.5f);
            rotateButton.PivotPoint             = PivotPoint.BottomCenter;
            rotateButton.PositionUsesPivotPoint = true;
            rotateButton.MinimumSize            = new Vector2(75, 75);

            rotateButton.Clicked += (sender, e) =>
            {
                FlexLayout flexLayout = (FlexLayout)this.view.Layout;

                if (flexLayout.Direction == FlexLayout.FlexDirection.Row)
                {
                    flexLayout.Direction = FlexLayout.FlexDirection.Column;
                }
                else
                {
                    flexLayout.Direction = FlexLayout.FlexDirection.Row;
                }
                return(true);
            };
            window.Add(rotateButton);
            buttons.Add(rotateButton);
        }
Exemplo n.º 26
0
        void CreateRibbonItems(UIControlledApplication a)
        {
            // get the path of our dll
            string addInPath = GetType().Assembly.Location;
            string imgDir    = FindFolderInParents(Path.GetDirectoryName(addInPath), "Images");

            const string panelName = "Lab 6 Panel";

            const string cmd1     = "XtraCs.Lab1_1_HelloWorld";
            const string name1    = "HelloWorld";
            const string text1    = "Hello World";
            const string tooltip1 = "Run Lab1_1_HelloWorld command";
            const string img1     = "ImgHelloWorld.png";
            const string img31    = "ImgHelloWorldSmall.png";

            const string cmd2     = "XtraCs.Lab1_2_CommandArguments";
            const string name2    = "CommandArguments";
            const string text2    = "Command Arguments";
            const string tooltip2 = "Run Lab1_2_CommandArguments command";
            const string img2     = "ImgCommandArguments.png";
            const string img32    = "ImgCommandArgumentsSmall.png";

            const string name3    = "Lab1Commands";
            const string text3    = "Lab 1 Commands";
            const string tooltip3 = "Run a Lab 1 command";
            const string img33    = "ImgCommandSmall.png";

            // create a Ribbon Panel

            RibbonPanel panel = a.CreateRibbonPanel(panelName);

            // add a button for Lab1's Hello World command

            PushButtonData pbd = new PushButtonData(name1, text1, addInPath, cmd1);
            PushButton     pb1 = panel.AddItem(pbd) as PushButton;

            pb1.ToolTip    = tooltip1;
            pb1.LargeImage = new BitmapImage(new Uri(Path.Combine(imgDir, img1)));

            // add a vertical separation line in the panel
            panel.AddSeparator();

            // prepare data for creating stackable buttons
            PushButtonData pbd1 = new PushButtonData(name1 + " 2", text1, addInPath, cmd1);

            pbd1.ToolTip = tooltip1;
            pbd1.Image   = new BitmapImage(new Uri(Path.Combine(imgDir, img31)));

            PushButtonData pbd2 = new PushButtonData(name2, text2, addInPath, cmd2);

            pbd2.ToolTip = tooltip2;
            pbd2.Image   = new BitmapImage(new Uri(Path.Combine(imgDir, img32)));

            PulldownButtonData pbd3 = new PulldownButtonData(name3, text3);

            pbd3.ToolTip = tooltip3;
            pbd3.Image   = new BitmapImage(new Uri(Path.Combine(imgDir, img33)));

            // add stackable buttons
            IList <RibbonItem> ribbonItems = panel.AddStackedItems(pbd1, pbd2, pbd3);

            // add two push buttons as sub-items of the Lab 1 commands
            PulldownButton pb3 = ribbonItems[2] as PulldownButton;

            pbd = new PushButtonData(name1, text1, addInPath, cmd1);
            PushButton pb3_1 = pb3.AddPushButton(pbd);

            pb3_1.ToolTip    = tooltip1;
            pb3_1.LargeImage = new BitmapImage(new Uri(Path.Combine(imgDir, img1)));

            pbd = new PushButtonData(name2, text2, addInPath, cmd2);
            PushButton pb3_2 = pb3.AddPushButton(pbd);

            pb3_2.ToolTip    = tooltip2;
            pb3_2.LargeImage = new BitmapImage(new Uri(Path.Combine(imgDir, img2)));
        }
Exemplo n.º 27
0
        // Both OnStartup and OnShutdown must be implemented as public method
        public Result OnStartup(UIControlledApplication application)
        {
            // Registrere event:
            //application.ControlledApplication.FileExporting += new EventHandler<FileExportingEventArgs>(AskForParameterUpdates);
            // Create a custom ribbon tab
            String tabName = "RebarUtils";
            application.CreateRibbonTab(tabName);
            // Add a new ribbon panel
            RibbonPanel ribbonPanel = application.CreateRibbonPanel(tabName, "EiBre Rebar Utils");
            string thisAssemblyPath = Assembly.GetExecutingAssembly().Location;
            // buttons: Copy Rebar, Renumber Rebar, Tag all, cycle tag,  Visibility, Selection, Other

            //Pushbutton copy rebar
            PushButtonData pushDataCopyRebar = new PushButtonData("cmdCopyRebar", "Copy Rebar", thisAssemblyPath, "EiBreRebarUtils.CopyRebar");
            pushDataCopyRebar.ToolTip = "Copies rebar from line based elements such as beams, walls, slanted columns to other line based elements.";
            PushButton pushButtonCopyRebar = ribbonPanel.AddItem(pushDataCopyRebar) as PushButton;
            pushButtonCopyRebar.LargeImage = BitmapToImageSource(Properties.Resources.copyRebar);

            //Pushbutton for rebar renumbering
            //----------------------------------------------------------------
            PushButtonData pushDataRenumber = new PushButtonData("cmdRenumberRebar", "Renumber", thisAssemblyPath, "EiBreRebarUtils.RenumberRebar");
            pushDataRenumber.ToolTip = "Change a Rebar Number";
            PushButton pushButtonRenumber = ribbonPanel.AddItem(pushDataRenumber) as PushButton;
            pushButtonRenumber.LargeImage = BitmapToImageSource(Properties.Resources.renumber);

            // Create a push button to trigger the tag all rebars command.

            PushButtonData buttonData = new PushButtonData("cmdTagAllRebarsInHost",
               "Tag rebars \nin host", thisAssemblyPath, "EiBreRebarUtils.TagAllRebarsInHost");
            
            PushButton pushButton = ribbonPanel.AddItem(buttonData) as PushButton;
            pushButton.ToolTip = "Tag all rebars in a host, the bars must be visible in active view";
            pushButton.LargeImage = BitmapToImageSource(Properties.Resources.TagAllRebarsInHost);
                              

            // Create a push button to cycle tags
            //--------------------------------------------------------------
            PushButtonData buttonData5 = new PushButtonData("cmdCycleTag", "Cycle Tag\nLeader", thisAssemblyPath, "EiBreRebarUtils.CycleTagLeader");
            PushButton pushButton5 = ribbonPanel.AddItem(buttonData5) as PushButton;
            pushButton5.ToolTip = "Cycle between attached end, free end and no leader";
            pushButton5.LargeImage = BitmapToImageSource(Properties.Resources.CycleTagLeader);

            //PULLDOWN to edit Rebar visibility
            //-----------------------------------------------------------------
            PushButtonData pushData6 = new PushButtonData("cmdSetUnobscuredInView", "Set Unobscured", thisAssemblyPath, "EiBreRebarUtils.SetUnobscuredInView");
            pushData6.ToolTip = "Set selected rebars unboscured in view. Applies to all rebars in view if none is selected";

            PushButtonData pushData7 = new PushButtonData("cmdSetObscuredInView", "Set Obscured", thisAssemblyPath, "EiBreRebarUtils.SetObscuredInView");
            pushData7.ToolTip = "Set selected rebars oboscured in view. Applies to all rebars in view if none is selected";

            PushButtonData pushData8 = new PushButtonData("cmdSetSolidInView", "Set Solid", thisAssemblyPath, "EiBreRebarUtils.SetSolidInView");
            pushData8.ToolTip = "Set selected rebars solid in a 3D view. Applies to all rebars in view if none is selected";

            PushButtonData pushData9 = new PushButtonData("cmdSetNotSolidInView", "Set Not Solid", thisAssemblyPath, "EiBreRebarUtils.SetNotSolidInView");
            pushData9.ToolTip = "Set selected rebars NOT solid in a 3D view. Applies to all rebars in view if none is selected";

            PulldownButtonData pullDataVisibility = new PulldownButtonData("cmdRebarVisibility", "Rebar Visibility");
            PulldownButton pullDownButtonVisibility = ribbonPanel.AddItem(pullDataVisibility) as PulldownButton;

            pullDownButtonVisibility.LargeImage = BitmapToImageSource(Properties.Resources.visibility);
            pullDownButtonVisibility.AddPushButton(pushData6);
            pullDownButtonVisibility.AddPushButton(pushData7);
            pullDownButtonVisibility.AddPushButton(pushData8);
            pullDownButtonVisibility.AddPushButton(pushData9);


            //PULLDOWNGROUP Selection Tools
            //-----------------------------------------------------------------
            PulldownButtonData pullDataSelect = new PulldownButtonData("cmdRebarSelect", "Selection Tools");
            PulldownButton pullDownButtonSelect = ribbonPanel.AddItem(pullDataSelect) as PulldownButton;
            pullDownButtonSelect.LargeImage = BitmapToImageSource(Properties.Resources.select);
            //Create pushbutton data to select all tagged rebars in a view
            PushButtonData pushSelectedTagData = new PushButtonData("cmdSelectTaggedRebar", "Select tagged rebars", thisAssemblyPath, "EiBreRebarUtils.SelectTaggedRebars");
            pushSelectedTagData.ToolTip = "Selects all tagged Rebar elements in view";

            //Create pushbutton data to select all tagged rebars in a view
            PushButtonData pushUnselectedTagData = new PushButtonData("cmdSelectUntaggedRebar", "Select un-tagged rebars", thisAssemblyPath, "EiBreRebarUtils.SelectUntaggedRebars");
            pushUnselectedTagData.ToolTip = "Selects all un-tagged Rebar elements in view";
            
            PushButtonData pushData10 = new PushButtonData("cmdSelectRebar", "Rebar Filter", thisAssemblyPath, "EiBreRebarUtils.SelectRebar");
            pushData10.ToolTip = "Rebar Filter";
  
            PushButtonData pushData11 = new PushButtonData("cmdSelectWorkset", "Select Same Workset", thisAssemblyPath, "EiBreRebarUtils.SelectSameWorkset");
            pushData11.ToolTip = "When an element is selected, use this command to select all elements on the same workset visible in view. ";

            PushButtonData pushData12 = new PushButtonData("cmdSelectCategory", "Select Same Category", thisAssemblyPath, "EiBreRebarUtils.SelectSameCategory");
            pushData12.ToolTip = "When an element is selected, use this command to select all elements of the same Category visible in view.";

            PushButtonData pushSelectTopLayer = new PushButtonData("cmdSelectTopLayer", "Select Top Layer (OK)", thisAssemblyPath, "EiBreRebarUtils.SelectTopLayer");
            pushSelectTopLayer.ToolTip = "Select rebar that is completely inside the bounding box of the top half of a Rebar Host.";

            PushButtonData pushSelectBottomLayer = new PushButtonData("cmdSelectBottomLayer", "Select Bottom Layer (UK)", thisAssemblyPath, "EiBreRebarUtils.SelectBottomLayer");
            pushSelectBottomLayer.ToolTip = "Select rebar that is completely inside the bounding box of the bottom half of a Rebar Host.";

            pullDownButtonSelect.AddPushButton(pushSelectedTagData);
            pullDownButtonSelect.AddPushButton(pushUnselectedTagData);
            pullDownButtonSelect.AddPushButton(pushData10);
            pullDownButtonSelect.AddPushButton(pushData11);
            pullDownButtonSelect.AddPushButton(pushData12);
            pullDownButtonSelect.AddPushButton(pushSelectTopLayer);
            pullDownButtonSelect.AddPushButton(pushSelectBottomLayer);

            //Pushbutton RebarInBend
            PushButtonData pushDataRebarInBend = new PushButtonData("cmdRebarInBend", "Rebar in bend", thisAssemblyPath, "EiBreRebarUtils.RebarInBend");
            pushDataRebarInBend.ToolTip = "Pick a rebar set to add rebars in all bends with same diameter as the bent bar.";
            PushButton pushButtonRebarInBend = ribbonPanel.AddItem(pushDataRebarInBend) as PushButton;
            pushButtonRebarInBend.LargeImage = BitmapToImageSource(Properties.Resources.RebarInBend);

            //Pushbutton PickRebarToIsolateAndTag
            PushButtonData pushDataPickRebarToIsolateAndTag = new PushButtonData("cmdPickRebarToIsolateAndTag", "Pick and tag", thisAssemblyPath, "EiBreRebarUtils.PickRebarToIsolateAndTag");
            pushDataPickRebarToIsolateAndTag.ToolTip = "Pick a rebar from a rebar set and a dimension line to isolate the rebar, attach it to the dimension line and place a tag";
            PushButton pushButtonPickRebarToIsolateAndTag = ribbonPanel.AddItem(pushDataPickRebarToIsolateAndTag) as PushButton;
            pushButtonPickRebarToIsolateAndTag.LargeImage = BitmapToImageSource(Properties.Resources.PickRebarToIsolateAndTag);

            //Pushbutton RebarParameterFromText
            PushButtonData pushDataRebarParameterFromText = new PushButtonData("cmdRebarParameterFromText", "Parameters\nfrom text", thisAssemblyPath, "EiBreRebarUtils.RebarParameterFromText");
            pushDataRebarParameterFromText.ToolTip = "Set bar type (diameter), layout rule, spacing, partition and comment from a string. e.g. ø12c200-P UK";
            PushButton pushButtonRebarParameterFromText = ribbonPanel.AddItem(pushDataRebarParameterFromText) as PushButton;
            pushButtonRebarParameterFromText.LargeImage = BitmapToImageSource(Properties.Resources.RebarParameterFromText);
            
            //Pushbutton Schedule Mark Update
            PushButtonData pushDataScheduleMark = new PushButtonData("cmdSceduleMarkUpdate", "Schedule Mark Update", thisAssemblyPath, "EiBreRebarUtils.ScheduleMarkUpdate");
            pushDataScheduleMark.ToolTip = "Combine the value from Partition and Rebar Number to Schedule Mark.";

            //Pushbutton sum of geometry
            PushButtonData pushDataSum = new PushButtonData("cmdSumGeometry", "Sum of geometry", thisAssemblyPath, "EiBreRebarUtils.SumGeometry");
            pushDataSum.ToolTip = "Returns the sum of Length, Area and Volume of the selected elements.";

            //Pushbutton Move from internal to shared
            PushButtonData pushDataMoveInternalShared = new PushButtonData("cmdMoveFromInternalToShared", "Move from internal to shared", thisAssemblyPath, "EiBreRebarUtils.MoveFromInternalToShared");
            pushDataMoveInternalShared.ToolTip = "This command moves and rotates a link or any element from the internal coordinate system to the shared coordinate system. This is useful if you insert links Origin to Origin because Surevey Point to Survey Point doesn't exist.";
            //Create a pushbutton to remove dimension values
            PushButtonData pushDataRemoveDimVal = new PushButtonData("cmdRemoveDimensionValue", "Remove\ndim. value", thisAssemblyPath, "EiBreRebarUtils.RemoveDimensionValue");
            pushDataRemoveDimVal.ToolTip = "Removes the dimension values from dimension lines.";

            //Pushbutton CopyRebarNumberFromScheduleMark
            PushButtonData pushDataCopyRebarNumberFromScheduleMark = new PushButtonData("cmdCopyRebarNumberFromScheduleMark", "Copy Rebar Number from Shedule Mark", thisAssemblyPath, "EiBreRebarUtils.CopyRebarNumberFromScheduleMark");
            pushDataCopyRebarNumberFromScheduleMark.ToolTip = "This command asks the user to select a partition and tries to change all Rebar Number values to match the last part of Schedue Mark. All schedule marks must begin with the partition name, and there can only be one number extracted from Schedule Mark for each Rebar Number.";

            //Pushbutton TagToDim
            PushButtonData pushDataTagToDim = new PushButtonData("cmdTagToDim", "Connect tag to dimension", thisAssemblyPath, "EiBreRebarUtils.TagToDim");
            pushDataTagToDim.ToolTip = "Pick a tag and a dimension to attach the tag leader to the nearest endpoint of the dimesion.";

            //Pushbutton ActiveViewToOpenSheet
            PushButtonData pushDataActiveViewToOpenSheet = new PushButtonData("cmdActiveViewToOpenSheet", "Add active view to open sheet", thisAssemblyPath, "EiBreRebarUtils.ActiveViewToOpenSheet");
            pushDataActiveViewToOpenSheet.ToolTip = "Adds the active view to a open sheet. If more than one sheet is open you are prompted to choose one.";

            //Pushbutton DisallowJoin
            PushButtonData pushDataDisallowJoin = new PushButtonData("cmdDisallowJoin", "Disallow Join", thisAssemblyPath, "EiBreRebarUtils.DisallowJoin");
            pushDataDisallowJoin.ToolTip = "Pick walls and/or structural framing to disallow join in both ends. End the selection by clicking finish in top left corner.";
            //Pushbutton ColumnsCutFloors
            PushButtonData pushDataColumnsCutFloor = new PushButtonData("cmdColumnsCutFloor", "Columns Cut Floor", thisAssemblyPath, "EiBreRebarUtils.SwitchJoinOrder");
            pushDataColumnsCutFloor.ToolTip = "Pick floors to switch join order such that floors are cut by columns. End the selection by clicking finish in top left corner.";
            //Pushbutton PasteImageFromClipboard
            PushButtonData pushDataPasteImage = new PushButtonData("cmdPasteImageFromClipboard", "Paste Image From Clipboard", thisAssemblyPath, "EiBreRebarUtils.PasteImageFromClipboard");
            pushDataPasteImage.ToolTip = "Copy a image to clipboard and paste it. The image will be saved in a new folder in the same location as your central file. You will be prompted to pick a point which is the center poit of the image";
            //Pushbutton About
            PushButtonData pushDataAbout = new PushButtonData("cmdAbout", "About", thisAssemblyPath, "EiBreRebarUtils.About");
            pushDataAbout.ToolTip = "About..";

            //PULLDOWN BUTTON OTHER
            PulldownButtonData pullDataOther = new PulldownButtonData("cmdOther", "Other tools");
            PulldownButton pullDownButtonOther = ribbonPanel.AddItem(pullDataOther) as PulldownButton;

            pullDownButtonOther.AddPushButton(pushDataRemoveDimVal);
            pullDownButtonOther.AddPushButton(pushDataScheduleMark);
            pullDownButtonOther.AddPushButton(pushDataTagToDim);
            pullDownButtonOther.AddPushButton(pushDataSum);
            pullDownButtonOther.AddPushButton(pushDataMoveInternalShared);
            pullDownButtonOther.AddPushButton(pushDataActiveViewToOpenSheet);
            pullDownButtonOther.AddPushButton(pushDataDisallowJoin);
            pullDownButtonOther.AddPushButton(pushDataColumnsCutFloor);
            pullDownButtonOther.AddPushButton(pushDataPasteImage);
            pullDownButtonOther.AddSeparator();
            pullDownButtonOther.AddPushButton(pushDataAbout);
            

            pullDownButtonOther.LargeImage = BitmapToImageSource(Properties.Resources.other);

            return Result.Succeeded;
        }
Exemplo n.º 28
0
    public override void Begin()
    {
        SetWindowSize(1024, 768);

        pallo = new PhysicsObject(60 * SKAALAUS, 60 * SKAALAUS, Shape.Circle);
        pallo.Color = Color.Red;
        Add(pallo);
        AddCollisionHandler(pallo, PalloTormaa);

        pallonAani = LoadSoundEffect("justroll");
        tormaysAani = LoadSoundEffect("clonkroll");

        // Kaksi tilaa, demo, jossa pallo kiertää ympyrää vaihtaen vauhtiaan ja pelitila (toistaiseksi ilman mailoja)
        demoNappi = new PushButton(100, 50, "Demo");
        demoNappi.Clicked += PeliTaiDemoPaalle;
        demoNappi.X = Screen.Left + 75;
        demoNappi.Y = Screen.Top - 50;
        Add(demoNappi);

        if (demo)
        {
            demoNappi.Text = "Peli";

            kentta = new GameObject(500, 500);
            Add(kentta, -1);
            Timer.SingleShot(pallonNopeus, PalloPyorahtaa);
        }
        else
        {
            demoNappi.Text = "Demo";

            pallo.CanRotate = false;
            pallo.KineticFriction = 0.1;

            var reunanleveys = 20;
            PhysicsObject vasenLaita = PhysicsObject.CreateStaticObject(reunanleveys, 3660 * SKAALAUS + reunanleveys*2);
            vasenLaita.X = -1220 * SKAALAUS / 2 - reunanleveys/2;
            PhysicsObject oikeaLaita = PhysicsObject.CreateStaticObject(reunanleveys, 3660 * SKAALAUS + reunanleveys * 2);
            oikeaLaita.X = +1220 * SKAALAUS / 2 + reunanleveys / 2;
            PhysicsObject p1Maali = PhysicsObject.CreateStaticObject(1220 * SKAALAUS + 0, reunanleveys);
            p1Maali.Color = Color.Red;
            p1Maali.Y = -3660 * SKAALAUS / 2 - reunanleveys / 2;
            PhysicsObject p2Maali = PhysicsObject.CreateStaticObject(1220 * SKAALAUS + 0, reunanleveys);
            p2Maali.Color = Color.Blue;
            p2Maali.Y = 3660 * SKAALAUS / 2 + reunanleveys / 2;

            // Estä laitoja törmäilemästä keskenään
            vasenLaita.CollisionIgnoreGroup = 1;
            oikeaLaita.CollisionIgnoreGroup = 1;
            p1Maali.CollisionIgnoreGroup = 1;
            p2Maali.CollisionIgnoreGroup = 1;

            kentta = new GameObject(1220 * SKAALAUS + 0, 3660 * SKAALAUS + reunanleveys * 2);
            kentta.IsVisible = false;
            Add(kentta, -1);

            // Laidat ovat kimmoisia
            var kimmoisuus = 0.99;
            vasenLaita.Restitution = kimmoisuus;
            oikeaLaita.Restitution = kimmoisuus;
            p1Maali.Restitution = kimmoisuus;
            p2Maali.Restitution = kimmoisuus;
            pallo.Restitution = kimmoisuus;

            Add(vasenLaita); Add(oikeaLaita); Add(p1Maali); Add(p2Maali);

            var suunta = new Vector(10, 300);
            alkuNopeus = suunta.Magnitude;
            pallo.Hit(suunta);

            Timer.SingleShot(0.1, PalloLiikkuu);
        }

        Mouse.IsCursorVisible = true;
        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli");
    }
Exemplo n.º 29
0
        private DemoKnobs()
        {
            var btn_prev = new PushButton()
            {
                Margin = new Thickness(10, 5), Text = "Prev"
            };

            btn_prev.Click += new EventHandler(btn_prev_Click);

            //var btn_next = new WidgetButton() { Margin = new Thickness(10, 5), Text = "Next" };
            //btn_next.Click += new EventHandler(btn_next_Click);
            //btn_next.HAlign = HorizontalAlignment.Right;

            var grid = new Grid();

            grid.Name = "GRID";

            grid.AddColumnDefinition(1, GridUnitType.Star);
            grid.AddColumnDefinition(1, GridUnitType.Star);
            grid.AddColumnDefinition(1, GridUnitType.Star);

            grid.AddRowDefinition(3, GridUnitType.Star);
            grid.AddRowDefinition(1, GridUnitType.Star);

            {
                var dial = new DialKnob();
                dial.Max   = 100;
                dial.Width = 135;
                dial.HorizontalAlignment = HorizontalAlignment.Center;
                dial.VerticalAlignment   = VerticalAlignment.Center;
                grid.SetRowCol(dial, 0, 0);
                grid.Children.Add(dial);
            }
            {
                var dial = new DialKnob();
                dial.Max   = 100;
                dial.Width = 135;
                dial.HorizontalAlignment = HorizontalAlignment.Center;
                dial.VerticalAlignment   = VerticalAlignment.Center;
                grid.SetRowCol(dial, 0, 1);
                grid.Children.Add(dial);
            }
            {
                var dial = new DialKnob();
                dial.Max   = 100;
                dial.Width = 135;
                dial.HorizontalAlignment = HorizontalAlignment.Center;
                dial.VerticalAlignment   = VerticalAlignment.Center;
                grid.SetRowCol(dial, 0, 2);
                grid.Children.Add(dial);
            }
            {
                grid.SetRowCol(btn_prev, 1, 0);
                grid.Children.Add(btn_prev);
            }
            //{
            //    grid.SetRowCol(btn_next, 2, 1);
            //    grid.Children.Add(btn_next);
            //}

            this.Content = grid;
        }
Exemplo n.º 30
0
        public Autodesk.Revit.UI.Result OnStartup(UIControlledApplication application)
        {
            try
            {
                // Create new ribbon panel
                RibbonPanel ribbonPanel = application.CreateRibbonPanel("Visual Programming"); //MDJ todo - move hard-coded strings out to resource files

                //Create a push button in the ribbon panel

                PushButton pushButton = ribbonPanel.AddItem(new PushButtonData("Dynamo",
                                                                               "Dynamo", m_AssemblyName, "Dynamo.Applications.DynamoRevit")) as PushButton;

                System.Drawing.Bitmap dynamoIcon = Dynamo.Applications.Properties.Resources.Nodes_32_32;

                BitmapSource bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                    dynamoIcon.GetHbitmap(),
                    IntPtr.Zero,
                    System.Windows.Int32Rect.Empty,
                    System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());

                pushButton.LargeImage = bitmapSource;
                pushButton.Image      = bitmapSource;



                // MDJ = element level events and dyanmic model update

                // Register sfm updater with Revit
                //DynamoUpdater updater = new DynamoUpdater(application.ActiveAddInId);
                //UpdaterRegistry.RegisterUpdater(updater);
                //// Change Scope = any spatial field element
                //ElementClassFilter SpatialFieldFilter = new ElementClassFilter(typeof(SpatialFieldManager));
                ////ElementClassFilter SpatialFieldFilter = new ElementClassFilter(typeof(SpatialFieldManager));
                //// Change type = element addition
                //UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), SpatialFieldFilter,
                //Element.GetChangeTypeAny()); // Element.GetChangeTypeElementAddition()


                DynamoUpdater updater = new DynamoUpdater(application.ActiveAddInId);//, sphere.Id, view.Id);
                if (!UpdaterRegistry.IsUpdaterRegistered(updater.GetUpdaterId()))
                {
                    UpdaterRegistry.RegisterUpdater(updater);
                }
                ElementClassFilter    SpatialFieldFilter = new ElementClassFilter(typeof(SpatialFieldManager));
                ElementClassFilter    familyFilter       = new ElementClassFilter(typeof(FamilyInstance));
                ElementCategoryFilter massFilter         = new ElementCategoryFilter(BuiltInCategory.OST_Mass);
                IList <ElementFilter> filterList         = new List <ElementFilter>();
                filterList.Add(SpatialFieldFilter);
                filterList.Add(familyFilter);
                filterList.Add(massFilter);
                LogicalOrFilter filter = new LogicalOrFilter(filterList);

                UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), filter, Element.GetChangeTypeGeometry());
                UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), filter, Element.GetChangeTypeElementDeletion());



                return(Result.Succeeded);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return(Result.Failed);
            }
        }
        void Initialize()
        {
            Window.Instance.BackgroundColor = Color.Black;
            mWindowSize = Window.Instance.Size;

            // Applies a new theme to the application.
            // This will be merged on top of the default Toolkit theme.
            // If the application theme file doesn't style all controls that the
            // application uses, then the default Toolkit theme will be used
            // instead for those controls.
            StyleManager.Get().ApplyTheme(mCustomThemeUrl);

            // Create Title TextLabel
            mTitle = new TextLabel("Script");
            mTitle.HorizontalAlignment = HorizontalAlignment.Center;
            mTitle.VerticalAlignment   = VerticalAlignment.Center;
            // Set Text color to White
            mTitle.TextColor = Color.White;
            mTitle.PositionUsesPivotPoint = true;
            mTitle.ParentOrigin           = ParentOrigin.TopCenter;
            mTitle.PivotPoint             = PivotPoint.TopCenter;
            mTitle.Position2D             = new Position2D(0, mWindowSize.Height / 10);
            // Use Samsung One 600 font
            mTitle.FontFamily = "Samsung One 600";
            // Not use MultiLine of TextLabel
            mTitle.MultiLine = false;
            mTitle.PointSize = mLargePointSize;
            Window.Instance.GetDefaultLayer().Add(mTitle);

            // Create subTitle TextLabel
            mRadioButtonTitle = new TextLabel("Radio Button");
            mRadioButtonTitle.HorizontalAlignment = HorizontalAlignment.Center;
            mRadioButtonTitle.VerticalAlignment   = VerticalAlignment.Center;
            // Set Text color to White
            mRadioButtonTitle.TextColor = Color.White;
            mRadioButtonTitle.PositionUsesPivotPoint = true;
            mRadioButtonTitle.ParentOrigin           = ParentOrigin.TopCenter;
            mRadioButtonTitle.PivotPoint             = PivotPoint.TopLeft;
            mRadioButtonTitle.Position2D             = new Position2D(-150, 110);
            // Use Samsung One 600 font
            mRadioButtonTitle.FontFamily = "Samsung One 600";
            // Not use MultiLine of TextLabel
            mRadioButtonTitle.MultiLine = false;
            mRadioButtonTitle.PointSize = mMiddlePointSize;
            Window.Instance.GetDefaultLayer().Add(mRadioButtonTitle);

            // Create RadioButtons
            mRadioButtons = new RadioButton[2];
            for (int i = 0; i < 2; ++i)
            {
                // Create new RadioButton
                mRadioButtons[i] = new RadioButton();
                // Set RadioButton size
                mRadioButtons[i].Size2D = new Size2D(300, 65);
                mRadioButtons[i].PositionUsesPivotPoint = true;
                mRadioButtons[i].ParentOrigin           = ParentOrigin.Center;
                mRadioButtons[i].PivotPoint             = PivotPoint.CenterLeft;
                // Set RadioButton Position
                mRadioButtons[i].Position = new Position(-150, -20, 0) + new Position(160, 0, 0) * i;
                mRadioButtons[i].Label    = CreateTextVisual(ButtonText[i], mMiddlePointSize * 2.0f, Color.White);
                mRadioButtons[i].Scale    = new Vector3(0.5f, 0.5f, 0.5f);
                // Add click event callback function
                mRadioButtons[i].Clicked += OnRadioButtonClicked;

                Window.Instance.GetDefaultLayer().Add(mRadioButtons[i]);
            }

            mRadioButtons[0].Selected = true;

            // Create TextLabel for the CheckBox Button
            mCheckBoxButtonTitle = new TextLabel("CheckBox Button");
            mCheckBoxButtonTitle.HorizontalAlignment    = HorizontalAlignment.Center;
            mCheckBoxButtonTitle.VerticalAlignment      = VerticalAlignment.Center;
            mCheckBoxButtonTitle.TextColor              = Color.White;
            mCheckBoxButtonTitle.PositionUsesPivotPoint = true;
            mCheckBoxButtonTitle.ParentOrigin           = ParentOrigin.TopCenter;
            mCheckBoxButtonTitle.PivotPoint             = PivotPoint.TopLeft;
            mCheckBoxButtonTitle.Position2D             = new Position2D(-150, 190);
            mCheckBoxButtonTitle.FontFamily             = "Samsung One 600";
            mCheckBoxButtonTitle.MultiLine              = false;
            mCheckBoxButtonTitle.PointSize              = mMiddlePointSize;
            Window.Instance.GetDefaultLayer().Add(mCheckBoxButtonTitle);

            // Create CheckBoxButton
            mCheckBoxButtons = new CheckBoxButton[2];
            for (int i = 0; i < 2; ++i)
            {
                // Create new CheckBox Button
                mCheckBoxButtons[i] = new CheckBoxButton();
                mCheckBoxButtons[i].PositionUsesPivotPoint = true;
                mCheckBoxButtons[i].ParentOrigin           = ParentOrigin.Center;
                mCheckBoxButtons[i].PivotPoint             = PivotPoint.CenterLeft;
                mCheckBoxButtons[i].Position      = new Position(-150, 60, 0) + new Position(160, 0, 0) * i;
                mCheckBoxButtons[i].Label         = CreateTextVisual(ButtonText[1], mMiddlePointSize + 1.0f, Color.White);
                mCheckBoxButtons[i].Scale         = new Vector3(0.8f, 0.8f, 0.8f);
                mCheckBoxButtons[i].StateChanged += OnCheckBoxButtonClicked;

                Window.Instance.GetDefaultLayer().Add(mCheckBoxButtons[i]);
            }

            // Create PushButton
            mPushButton = new PushButton();
            mPushButton.PositionUsesPivotPoint = true;
            mPushButton.ParentOrigin           = ParentOrigin.BottomCenter;
            mPushButton.PivotPoint             = PivotPoint.BottomCenter;
            mPushButton.Name   = "ChangeTheme";
            mPushButton.Size2D = new Size2D(230, 35);
            mPushButton.ClearBackground();
            mPushButton.Position = new Position(0, -50, 0);
            PropertyMap normalTextMap = CreateTextVisual("Change Theme", mMiddlePointSize, Color.White);

            mPushButton.Label    = normalTextMap;
            mPushButton.Clicked += OnPushButtonClicked;
            Window.Instance.GetDefaultLayer().Add(mPushButton);

            Window.Instance.KeyEvent += OnKey;
        }
Exemplo n.º 32
0
        public override void Create()
        {
            view                        = new View();
            view.Name                   = "MainLinearLayout";
            view.ParentOrigin           = ParentOrigin.Center;
            view.PivotPoint             = PivotPoint.Center;
            view.PositionUsesPivotPoint = true;
            view.WidthSpecification     = LayoutParamPolicies.MatchParent;
            view.HeightSpecification    = LayoutParamPolicies.MatchParent;

            var layout = new LinearLayout();

            layout.LinearAlignment = LinearLayout.Alignment.Center;
            view.Layout            = layout;
            view.LayoutDirection   = ViewLayoutDirectionType.LTR;

            ///////////////////////////////////////////////////////////////////////////////////////
            //  Custom transitions for Adding an ImageView
            //  ImageView positioned instantly
            //  A delayed opacity increases to 1.0f after siblings moved to make space
            ///////////////////////////////////////////////////////////////////////////////////////
            TransitionComponents instantPosition = new TransitionComponents();

            instantPosition.AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Linear);
            instantPosition.Delay         = 0;
            instantPosition.Duration      = 1;

            view.LayoutTransition = new LayoutTransition(TransitionCondition.Add,
                                                         AnimatableProperties.Position,
                                                         0.0,
                                                         instantPosition);

            TransitionComponents delayedInsertion = new TransitionComponents();

            delayedInsertion.AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Linear);
            delayedInsertion.Delay         = 100;
            delayedInsertion.Duration      = 200;

            view.LayoutTransition = new LayoutTransition(TransitionCondition.Add,
                                                         AnimatableProperties.Opacity,
                                                         1.0f,
                                                         delayedInsertion);

            ///////////////////////////////////////////////////////////////////////////////////////
            //  Custom transitions for siblings after ADDing an ImageView to the View
            //  Siblings are moved using AlphaFunction.BuiltinFunctions.EaseInOutSine
            ///////////////////////////////////////////////////////////////////////////////////////
            TransitionComponents slowEaseInOutSine = new TransitionComponents();

            slowEaseInOutSine.AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseInOutSine);
            slowEaseInOutSine.Duration      = 164;
            slowEaseInOutSine.Delay         = 0;

            view.LayoutTransition = new LayoutTransition(TransitionCondition.ChangeOnAdd,
                                                         AnimatableProperties.Position,
                                                         0.0,
                                                         slowEaseInOutSine);

            ///////////////////////////////////////////////////////////////////////////////////////
            //  Custom transitions for Removing an ImageView
            //  The opacity animates to .2f
            ///////////////////////////////////////////////////////////////////////////////////////
            TransitionComponents fadeOut = new TransitionComponents();

            fadeOut.AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Linear);
            fadeOut.Duration      = 600;
            fadeOut.Delay         = 0;
            float targetOpacityOut = .2f;

            view.LayoutTransition = new LayoutTransition(TransitionCondition.Remove,
                                                         AnimatableProperties.Opacity,
                                                         targetOpacityOut,
                                                         fadeOut);

            // Add child image-views to the created view
            var index = 0;

            foreach (String image in TestImages.s_images)
            {
                // Set a delayed custom transition for each Image View so each moves into place after it's
                // adjacent sibbling.
                TransitionComponents easeInOutSineDelayed = new TransitionComponents();
                easeInOutSineDelayed.AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseInOutSine);
                easeInOutSineDelayed.Delay         = ITEM_MOVE_DURATION * index;
                easeInOutSineDelayed.Duration      = ITEM_MOVE_DURATION * TestImages.s_images.Length;

                ImageView imageView = LayoutingExample.CreateChildImageView(image, new Size2D(80, 80));

                // Override LayoutChanged transition so different for each ImageView in the Linear layout.
                // In this case each moves with a increasing delay.
                imageView.LayoutTransition = new LayoutTransition(TransitionCondition.LayoutChanged,
                                                                  AnimatableProperties.Position,
                                                                  0.0,
                                                                  easeInOutSineDelayed);

                imageView.LayoutTransition = new LayoutTransition(TransitionCondition.ChangeOnRemove,
                                                                  AnimatableProperties.Position,
                                                                  0.0,
                                                                  easeInOutSineDelayed);

                imageView.TouchEvent += (sender, e) =>
                {
                    if (sender is ImageView && e.Touch.GetState(0) == PointStateType.Down)
                    {
                        ImageView touchedImageView = (ImageView)sender;
                        if (touchedImageView.Weight == 1.0f)
                        {
                            touchedImageView.Weight = 0.0f;
                        }
                        else
                        {
                            touchedImageView.Weight = 1.0f;
                        }
                    }
                    return(true);
                };

                view.Add(imageView);
                index++;
            }

            LayoutingExample.GetWindow().Add(view);

            PushButton directionButton = new PushButton();

            LayoutingExample.SetUnselectedIcon(directionButton, "./res/images/icon-reverse.png");
            LayoutingExample.SetSelectedIcon(directionButton, "./res/images/icon-reverse-selected.png");
            directionButton.Name                   = "directionButton";
            directionButton.ParentOrigin           = new Vector3(0.33f, 1.0f, 0.5f);
            directionButton.PivotPoint             = PivotPoint.BottomCenter;
            directionButton.PositionUsesPivotPoint = true;
            directionButton.MinimumSize            = new Vector2(75, 75);
            directionButton.Clicked               += (sender, e) =>
            {
                if (this.view.LayoutDirection == ViewLayoutDirectionType.LTR)
                {
                    this.view.LayoutDirection = ViewLayoutDirectionType.RTL;
                    LayoutingExample.SetUnselectedIcon(directionButton, "./res/images/icon-play.png");
                    LayoutingExample.SetUnselectedIcon(directionButton, "./res/images/icon-play-selected.png");
                }
                else
                {
                    this.view.LayoutDirection = ViewLayoutDirectionType.LTR;
                    LayoutingExample.SetUnselectedIcon(directionButton, "./res/images/icon-reverse.png");
                    LayoutingExample.SetSelectedIcon(directionButton, "./res/images/icon-reverse-selected.png");
                }
                return(true);
            };
            LayoutingExample.GetWindow().Add(directionButton);
            buttons.Add(directionButton);

            PushButton rotateButton = new PushButton();

            LayoutingExample.SetUnselectedIcon(rotateButton, "./res/images/icon-reset.png");
            LayoutingExample.SetSelectedIcon(rotateButton, "./res/images/icon-reset-selected.png");
            rotateButton.Name                   = "rotateButton";
            rotateButton.ParentOrigin           = new Vector3(0.66f, 1.0f, 0.5f);
            rotateButton.PivotPoint             = PivotPoint.BottomCenter;
            rotateButton.PositionUsesPivotPoint = true;
            rotateButton.MinimumSize            = new Vector2(75, 75);
            rotateButton.Clicked               += (sender, e) =>
            {
                LinearLayout linearLayout = (LinearLayout)this.view.Layout;
                if (linearLayout.LinearOrientation == LinearLayout.Orientation.Horizontal)
                {
                    linearLayout.LinearOrientation = LinearLayout.Orientation.Vertical;
                }
                else
                {
                    linearLayout.LinearOrientation = LinearLayout.Orientation.Horizontal;
                }
                return(true);
            };

            LayoutingExample.GetWindow().Add(rotateButton);
            buttons.Add(rotateButton);

            PushButton addItemButton = new PushButton();

            LayoutingExample.SetUnselectedIcon(addItemButton, "./res/images/icon-plus.png");
            LayoutingExample.SetSelectedIcon(addItemButton, "./res/images/icon-plus.png");
            addItemButton.Name                   = "addItemButton";
            addItemButton.ParentOrigin           = new Vector3(.9f, 1.0f, 0.5f);
            addItemButton.PivotPoint             = PivotPoint.BottomCenter;
            addItemButton.PositionUsesPivotPoint = true;
            addItemButton.MinimumSize            = new Vector2(75, 75);
            addItemButton.Clicked               += (sender, e) =>
            {
                Button button = sender as Button;
                if (!addedItem)
                {
                    ImageView            imageView            = LayoutingExample.CreateChildImageView(TestImages.s_images[0], new Size2D(80, 80));
                    TransitionComponents easeInOutSineDelayed = new TransitionComponents();
                    easeInOutSineDelayed.AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseInOutSine);
                    easeInOutSineDelayed.Delay         = ITEM_MOVE_DURATION * (index); // index was the last item added
                    easeInOutSineDelayed.Duration      = ITEM_MOVE_DURATION * (index + 1);
                    imageView.LayoutTransition         = new LayoutTransition(TransitionCondition.LayoutChanged,
                                                                              AnimatableProperties.Position,
                                                                              0.0,
                                                                              easeInOutSineDelayed);
                    imageView.Opacity = 0.0f;
                    imageView.Name    = "ImageViewBeingAdded-png";
                    view.Add(imageView);
                    LayoutingExample.SetUnselectedIcon(button, "./res/images/icon-minus.png");
                    addedItem = true;
                }
                else
                {
                    foreach (View item in view.Children)
                    {
                        if (item.Name == "ImageViewBeingAdded-png")
                        {
                            view.Remove(item);
                            addedItem = false;
                            LayoutingExample.SetUnselectedIcon(button, "./res/images/icon-plus.png");
                            break;
                        }
                    }
                }
                return(true);
            };

            LayoutingExample.GetWindow().Add(addItemButton);
            buttons.Add(addItemButton);
        }
Exemplo n.º 33
0
        /// <summary>
        /// Implement this method to implement the external application which should be called when
        /// Revit starts before a file or default template is actually loaded.
        /// <param name="application">An object that is passed to the external application
        /// which contains the controlled application.</param>
        /// <returns>Return the status of the external application.
        /// A result of Succeeded means that the external application successfully started.
        /// Cancelled can be used to signify that the user cancelled the external operation at
        /// some point.
        /// If false is returned then Revit should inform the user that the external application
        /// failed to load and the release the internal reference.</returns>
        public Autodesk.Revit.UI.Result OnStartup(UIControlledApplication application)
        {
            m_controlApp = application;

            #region Subscribe to related events

            // Doors are updated from the application level events.
            // That will insure that the doc is correct when it is saved.
            // Subscribe to related events.
            application.ControlledApplication.DocumentSaving   += new EventHandler <DocumentSavingEventArgs>(DocumentSavingHandler);
            application.ControlledApplication.DocumentSavingAs += new EventHandler <DocumentSavingAsEventArgs>(DocumentSavingAsHandler);

            #endregion

            #region create a custom Ribbon panel which contains three buttons

            // The location of this command assembly
            string currentCommandAssemblyPath = System.Reflection.Assembly.GetExecutingAssembly().Location;

            // The directory path of buttons' images
            string buttonImageDir = Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName
                                                                                    (Path.GetDirectoryName(currentCommandAssemblyPath))));

            // begin to create custom Ribbon panel and command buttons.
            // create a Ribbon panel.
            RibbonPanel doorPanel = application.CreateRibbonPanel("Door Swing");

            // the first button in the DoorSwing panel, use to invoke the InitializeCommand.
            PushButton initialCommandBut = doorPanel.AddItem(new PushButtonData("Customize Door Opening",
                                                                                "Customize Door Opening",
                                                                                currentCommandAssemblyPath,
                                                                                typeof(InitializeCommand).FullName))
                                           as PushButton;
            initialCommandBut.ToolTip    = "Customize the expression based on family's geometry and country's standard.";
            initialCommandBut.LargeImage = new BitmapImage(new Uri(Path.Combine(buttonImageDir, "InitialCommand_Large.bmp")));
            initialCommandBut.Image      = new BitmapImage(new Uri(Path.Combine(buttonImageDir, "InitialCommand_Small.bmp")));

            // the second button in the DoorSwing panel, use to invoke the UpdateParamsCommand.
            PushButton updateParamBut = doorPanel.AddItem(new PushButtonData("Update Door Properties",
                                                                             "Update Door Properties",
                                                                             currentCommandAssemblyPath,
                                                                             typeof(UpdateParamsCommand).FullName))
                                        as PushButton;
            updateParamBut.ToolTip    = "Update door properties based on geometry.";
            updateParamBut.LargeImage = new BitmapImage(new Uri(Path.Combine(buttonImageDir, "UpdateParameter_Large.bmp")));
            updateParamBut.Image      = new BitmapImage(new Uri(Path.Combine(buttonImageDir, "UpdateParameter_Small.bmp")));

            // the third button in the DoorSwing panel, use to invoke the UpdateGeometryCommand.
            PushButton updateGeoBut = doorPanel.AddItem(new PushButtonData("Update Door Geometry",
                                                                           "Update Door Geometry",
                                                                           currentCommandAssemblyPath,
                                                                           typeof(UpdateGeometryCommand).FullName))
                                      as PushButton;
            updateGeoBut.ToolTip    = "Update door geometry based on From/To room property.";
            updateGeoBut.LargeImage = new BitmapImage(new Uri(Path.Combine(buttonImageDir, "UpdateGeometry_Large.bmp")));
            updateGeoBut.Image      = new BitmapImage(new Uri(Path.Combine(buttonImageDir, "UpdateGeometry_Small.bmp")));

            #endregion

            return(Autodesk.Revit.UI.Result.Succeeded);
        }
Exemplo n.º 34
0
 public ToolbarCommand(string name, PushButton command)
 {
     CommandName = name;
     Command     = command;
 }
Exemplo n.º 35
0
        public void Initialize()
        {
            Window window = Window.Instance;

            window.BackgroundColor = Color.White;

            Tizen.Log.Debug("NUI", "### DP1");
            Layer layer = new Layer();

            layer.Behavior = Layer.LayerBehavior.Layer3D;
            window.AddLayer(layer);
            Tizen.Log.Debug("NUI", "### DP2");
            _container = new View();
            _container.ParentOrigin = ParentOrigin.Center;
            _container.PivotPoint   = PivotPoint.Center;
            _container.Size2D       = new Size2D(400, 400);
            Tizen.Log.Debug("NUI", "### DP3");
            _widgetButton                         = new PushButton();
            _widgetButton.LabelText               = "Widget";
            _widgetButton.ParentOrigin            = ParentOrigin.BottomLeft;
            _widgetButton.PivotPoint              = PivotPoint.BottomLeft;
            _widgetButton.PositionUsesAnchorPoint = true;
            _widgetButton.Size2D                  = new Size2D(200, 100);
            window.Add(_widgetButton);
            _widgetButton.Clicked += (obj, e) =>
            {
                _widgetView = _widgetViewManager.AddWidget("widget-efl.example", "", 450, 700, -1);
                //_widgetView.PositionUsesPivotPoint = true;
                //_widgetView.ParentOrigin = ParentOrigin.Center;
                _widgetView.PivotPoint = PivotPoint.TopLeft;
                _widgetView.PositionUsesAnchorPoint = true;
                _widgetView.BackgroundColor         = Color.Yellow;
                _widgetView.WidgetAdded            += (sender, eargs) =>
                {
                    _widgetButton.LabelText = "Quit";
                    window.Add(_widgetView);
                };
                _widgetView.WidgetDeleted += (sender, eargs) =>
                {
                    window.Remove(_widgetView);
                    _widgetButton.LabelText = "Button";
                };
                _instanceID = _widgetView.InstanceID;
                return(false);
            };

            _deletedButton                         = new PushButton();
            _deletedButton.LabelText               = "Buton";
            _deletedButton.ParentOrigin            = ParentOrigin.BottomRight;
            _deletedButton.PivotPoint              = PivotPoint.BottomRight;
            _deletedButton.PositionUsesAnchorPoint = true;
            _deletedButton.Size2D                  = new Size2D(200, 100);
            window.Add(_deletedButton);
            _deletedButton.Clicked += (obj, e) =>
            {
                OnTerminate();
                return(true);
            };

            layer.Add(_container);
            Tizen.Log.Debug("NUI", "### widget view manager create start");
            _widgetViewManager = new WidgetViewManager(this, "org.tizen.example.NUISamples.TizenTV");
            if (!_widgetViewManager)
            {
                Tizen.Log.Fatal("NUI", "### Widget is not enabled!");
            }

            Tizen.Log.Debug("NUI", "### widget view manager create sucess");
        }
Exemplo n.º 36
0
        private void Stream(ArrayList data, PushButton pushBt)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(PushButton)));

             data.Add(new Snoop.Data.String("Assembly name", pushBt.AssemblyName));
             data.Add(new Snoop.Data.String("Class name", pushBt.ClassName));
             data.Add(new Snoop.Data.Object("Image", pushBt.Image));
             data.Add(new Snoop.Data.String("Name", pushBt.Name));
        }
Exemplo n.º 37
0
        /// <summary>
        /// Called by buttons
        /// </summary>
        /// <param name="source">The clicked button</param>
        /// <returns>The consume flag</returns>
        private bool ButtonClick(object source)
        {
            // Get the source who trigger this event.
            PushButton button = source as PushButton;

            // Change textField's HorizontalAlignment.
            if (button.LabelText == "HorizontalAlignment")
            {
                // Begin : Texts place at the begin of horizontal direction.
                if (mButtonState[mCurruntButtonIndex] == 0)
                {
                    mTextField.HorizontalAlignment    = HorizontalAlignment.Center;
                    mButtonState[mCurruntButtonIndex] = 1;
                }
                // Center : Texts place at the center of horizontal direction.
                else if (mButtonState[mCurruntButtonIndex] == 1)
                {
                    mTextField.HorizontalAlignment    = HorizontalAlignment.End;
                    mButtonState[mCurruntButtonIndex] = 2;
                }
                // End : Texts place at the end of horizontal direction.
                else
                {
                    mTextField.HorizontalAlignment    = HorizontalAlignment.Begin;
                    mButtonState[mCurruntButtonIndex] = 0;
                }
            }
            // Change textField's VerticalAlignment.
            else if (button.LabelText == "VerticalAlignment")
            {
                // Top : Texts place at the top of vertical direction.
                if (mButtonState[mCurruntButtonIndex] == 0)
                {
                    mTextField.VerticalAlignment      = VerticalAlignment.Center;
                    mButtonState[mCurruntButtonIndex] = 1;
                }
                // Center : Texts place at the center of vertical direction.
                else if (mButtonState[mCurruntButtonIndex] == 1)
                {
                    mTextField.VerticalAlignment      = VerticalAlignment.Bottom;
                    mButtonState[mCurruntButtonIndex] = 2;
                }
                // Bottom : Texts place at the bottom of vertical direction.
                else
                {
                    mTextField.VerticalAlignment      = VerticalAlignment.Top;
                    mButtonState[mCurruntButtonIndex] = 0;
                }
            }
            // Change textField's text color.
            else if (button.LabelText == "Color")
            {
                // Judge the textColor is Black or not.
                // It true, change text color to blue.
                // It not, change text color to black.
                if (mButtonState[mCurruntButtonIndex] == 0)
                {
                    mTextField.TextColor = Color.Blue;
                    mTextField.Text      = mTextField.Text;
                    mButtonState[mCurruntButtonIndex] = 1;
                }
                else
                {
                    mTextField.TextColor = Color.Black;
                    mTextField.Text      = mTextField.Text;
                    mButtonState[mCurruntButtonIndex] = 0;
                }
            }
            // Change textField's text size.
            else if (button.LabelText == "Size")
            {
                if (mButtonState[mCurruntButtonIndex] == 0)
                {
                    mTextField.PointSize = mLargePointSize;
                    mButtonState[mCurruntButtonIndex] = 1;
                }
                else
                {
                    mTextField.PointSize = mMiddlePointSize;
                    mButtonState[mCurruntButtonIndex] = 0;
                }
            }
            // Change different language on textField.
            else if (button.LabelText == "Language")
            {
                mTextField.Text = LANGUAGES[mItemLanguage];
                mItemLanguage++;
                // If the index of LANGUAGES in end, move index to 0.
                if (mItemLanguage == mNumLanguage)
                {
                    mItemLanguage = 0;
                }
            }
            // Set the text on textField have shadow or not.
            else if (button.LabelText == "Shadow")
            {
                if (mButtonState[mCurruntButtonIndex] == 0)
                {
                    // The drop shadow offset
                    mTextField.ShadowOffset           = new Vector2(3.0f, 3.0f);
                    mTextField.ShadowColor            = Color.Black;
                    mTextField.Text                   = mTextField.Text;
                    mButtonState[mCurruntButtonIndex] = 1;
                }
                else
                {
                    // The drop shadow offset 0 indicates no shadow.
                    mTextField.ShadowOffset           = new Vector2(0, 0);
                    mTextField.Text                   = mTextField.Text;
                    mButtonState[mCurruntButtonIndex] = 0;
                }
            }
            // Set the text on textField have Underline or not.
            else if (button.LabelText == "Underline")
            {
                if (mButtonState[mCurruntButtonIndex] == 0)
                {
                    // Show the underline.
                    // Underline color is black
                    // Underline height is 3
                    PropertyMap underlineMap = new PropertyMap();
                    underlineMap.Insert("enable", new PropertyValue("true"));
                    underlineMap.Insert("color", new PropertyValue("black"));
                    underlineMap.Insert("height", new PropertyValue("3"));

                    // Set the underline property
                    mTextField.Underline = underlineMap;
                    mTextField.Text      = mTextField.Text;
                    mButtonState[mCurruntButtonIndex] = 1;
                }
                else
                {
                    // Hide the underline.
                    PropertyMap underlineMap = new PropertyMap();
                    underlineMap.Insert("enable", new PropertyValue("false"));

                    // Check the underline property
                    mTextField.Underline = underlineMap;
                    mTextField.Text      = mTextField.Text;
                    mButtonState[mCurruntButtonIndex] = 0;
                }
            }
            // Set textField text is bold or not.
            else if (button.LabelText == "Bold")
            {
                if (mButtonState[mCurruntButtonIndex] == 0)
                {
                    // The weight of text is bold.
                    PropertyMap fontStyle = new PropertyMap();
                    fontStyle.Add("weight", new PropertyValue("bold"));
                    mTextField.FontStyle = fontStyle;
                    mButtonState[mCurruntButtonIndex] = 1;
                }
                else
                {
                    // The weight of text is normal.
                    PropertyMap fontStyle = new PropertyMap();
                    fontStyle.Add("weight", new PropertyValue("normal"));
                    mTextField.FontStyle = fontStyle;
                    mButtonState[mCurruntButtonIndex] = 0;
                }
            }
            // Set textField text is condensed or not.
            else if (button.LabelText == "Condensed")
            {
                if (mButtonState[mCurruntButtonIndex] == 0)
                {
                    // The width of text is condensed.
                    PropertyMap fontStyle = new PropertyMap();
                    fontStyle.Add("width", new PropertyValue("condensed"));
                    mTextField.FontStyle = fontStyle;
                    mButtonState[mCurruntButtonIndex] = 1;
                }
                else
                {
                    // The width of text is normal.
                    PropertyMap fontStyle = new PropertyMap();
                    fontStyle.Add("width", new PropertyValue("normal"));
                    mTextField.FontStyle = fontStyle;
                    mButtonState[mCurruntButtonIndex] = 0;
                }
            }

            return(true);
        }
Exemplo n.º 38
0
        public Result OnStartup(UIControlledApplication application)
        {
            // Revit2015+ has disabled hardware acceleration for WPF to
            // avoid issues with rendering certain elements in the Revit UI.
            // Here we get it back, by setting the ProcessRenderMode to Default,
            // signifying that we want to use hardware rendering if it's
            // available.

            RenderOptions.ProcessRenderMode = RenderMode.Default;

            try
            {
                if (false == TryResolveDynamoCore())
                {
                    return(Result.Failed);
                }

                UIControlledApplication = application;
                ControlledApplication   = application.ControlledApplication;

                SubscribeAssemblyResolvingEvent();
                SubscribeApplicationEvents();

                TransactionManager.SetupManager(new AutomaticTransactionStrategy());
                ElementBinder.IsEnabled = true;

                // Create new ribbon panel
                var panels      = application.GetRibbonPanels();
                var ribbonPanel = panels.FirstOrDefault(p => p.Name.Contains(Resources.App_Description));
                if (null == ribbonPanel)
                {
                    ribbonPanel = application.CreateRibbonPanel(Resources.App_Description);
                }

                var fvi        = FileVersionInfo.GetVersionInfo(assemblyName);
                var dynVersion = String.Format(Resources.App_Name, fvi.FileMajorPart, fvi.FileMinorPart);

                DynamoButton =
                    (PushButton)
                    ribbonPanel.AddItem(
                        new PushButtonData(
                            dynVersion,
                            dynVersion,
                            assemblyName,
                            "Dynamo.Applications.DynamoRevit"));

                Bitmap dynamoIcon = Resources.logo_square_32x32;

                BitmapSource bitmapSource =
                    Imaging.CreateBitmapSourceFromHBitmap(
                        dynamoIcon.GetHbitmap(),
                        IntPtr.Zero,
                        Int32Rect.Empty,
                        BitmapSizeOptions.FromEmptyOptions());

                DynamoButton.LargeImage = bitmapSource;
                DynamoButton.Image      = bitmapSource;

                RegisterAdditionalUpdaters(application);

                return(Result.Succeeded);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return(Result.Failed);
            }
        }
        protected PushButton CreateButton(string name, string text, Size2D size = null)
        {
            PushButton button = new PushButton();

            if (null != size)
            {
                button.Size2D = size;
            }

            button.Focusable = true;
            button.Name      = name;
            // Create the label which will show when _pushbutton focused.
            PropertyMap _focusText = CreateTextVisual(text, Color.Black);

            // Create the label which will show when _pushbutton unfocused.
            PropertyMap _unfocusText = CreateTextVisual(text, Color.White);

            button.Label = _unfocusText;

            // Create normal background visual.
            PropertyMap normalMap = CreateImageVisual(normalImagePath);

            // Create focused background visual.
            PropertyMap focusMap = CreateImageVisual(focusImagePath);

            // Create pressed background visual.
            PropertyMap pressMap = CreateImageVisual(pressImagePath);

            button.SelectedVisual             = pressMap;
            button.SelectedBackgroundVisual   = pressMap;
            button.UnselectedBackgroundVisual = normalMap;

            button.FocusGained += (obj, e) =>
            {
                button.UnselectedBackgroundVisual = focusMap;
                button.UnselectedVisual           = focusMap;
                button.Label = _focusText;
            };

            // Chang background Visual and Label when focus lost.
            button.FocusLost += (obj, e) =>
            {
                button.UnselectedBackgroundVisual = normalMap;
                button.UnselectedVisual           = normalMap;
                button.Label = _unfocusText;
            };

            // Chang background Visual when pressed.
            button.KeyEvent += (obj, ee) =>
            {
                if ("Return" == ee.Key.KeyPressedName)
                {
                    if (Key.StateType.Down == ee.Key.State)
                    {
                        button.UnselectedBackgroundVisual = pressMap;
                        Tizen.Log.Fatal("NUI", "Press in pushButton sample!!!!!!!!!!!!!!!!");
                    }
                    else if (Key.StateType.Up == ee.Key.State)
                    {
                        button.UnselectedBackgroundVisual = focusMap;
                        Tizen.Log.Fatal("NUI", "Release in pushButton sample!!!!!!!!!!!!!!!!");
                    }
                }

                return(false);
            };

            return(button);
        }
Exemplo n.º 40
0
        public Result OnStartup(UIControlledApplication a)
        {
            //string thisAssemblyPath = AssemblyLoadEventArgs.getExecutingAssembly().Location;
            string thisAssemblyPath = Assembly.GetExecutingAssembly().Location;

            ////////////
            // 1st Panel
            RibbonPanel modelBuild = ribbonPanel(a, "Manicotti", "Create Model");
            //var globePath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "icon.PNG");
            // need to load image in <filename>/bin/Debug file for windows
            // need to load image to C:\users\<USERNAME>\AppData\Roaming\Autodesk\Revit\Addins\2020
            Uri         uriImage = new Uri("pack://application:,,,/Manicotti;component/Resources/ico/Model.ico", UriKind.Absolute);
            BitmapImage modelImg = new BitmapImage(uriImage);

            // Test button for floorplan split
            PushButtonData createAllButtonData = new PushButtonData("create_all", "Build up model\non all levels",
                                                                    thisAssemblyPath, "Manicotti.CmdCreateAll");

            createAllButtonData.AvailabilityClassName = "Manicotti.Util.ButtonControl";
            PushButton createAll = modelBuild.AddItem(createAllButtonData) as PushButton;

            createAll.ToolTip = "Split geometries and texts by their floors." +
                                " Try to create walls and columns on all levels. To test this demo, Link_floor.dwg must be linked. (act on Linked DWG)";
            createAll.LargeImage = modelImg;

            // Button list
            PushButtonData wall = new PushButtonData("create_wall", "Walls",
                                                     thisAssemblyPath, "Manicotti.CmdCreateWall");

            wall.ToolTip = "Extrude walls. To test the demo, Link_demo.dwg must be linked. (act on Linked DWG with WALL layer)";
            BitmapImage wallImg = new BitmapImage(new Uri("pack://application:,,,/Manicotti;component/Resources/ico/Wall.ico", UriKind.Absolute));

            wall.Image = wallImg;

            PushButtonData column = new PushButtonData("create_column", "Columns",
                                                       thisAssemblyPath, "Manicotti.CmdCreateColumn");

            column.ToolTip = "Extrude columns. To test the demo, Link_demo.dwg must be linked. (act on Linked DWG with COLUMN layer)";
            BitmapImage columnImg = new BitmapImage(new Uri("pack://application:,,,/Manicotti;component/Resources/ico/Column.ico", UriKind.Absolute));

            column.Image = columnImg;

            PushButtonData opening = new PushButtonData("create_opening", "Openings",
                                                        thisAssemblyPath, "Manicotti.CmdCreateOpening");

            opening.ToolTip = "Insert openings. To test the demo, Link_demo.dwg must be linked. (need layer DOOR, WINDOW & WALL)";
            BitmapImage openingImg = new BitmapImage(new Uri("pack://application:,,,/Manicotti;component/Resources/ico/Opening.ico", UriKind.Absolute));

            opening.Image = openingImg;

            IList <RibbonItem> stackedGeometry = modelBuild.AddStackedItems(wall, column, opening);


            ////////////
            // 2nd Panel
            RibbonPanel modelSetting = ribbonPanel(a, "Manicotti", "Settings");

            PushButtonData config = new PushButtonData("config", "Default Settings",
                                                       thisAssemblyPath, "Manicotti.Views.CmdConfig");

            wall.ToolTip = "Default and preferance settings. WIP";
            BitmapImage configImg = new BitmapImage(new Uri("pack://application:,,,/Manicotti;component/Resources/ico/Winform.ico", UriKind.Absolute));

            config.Image = configImg;

            PushButtonData load = new PushButtonData("load", "Reload Families",
                                                     thisAssemblyPath, "Manicotti.CmdPartAtom");

            load.ToolTip = "Reload the default families.";
            BitmapImage loadImg = new BitmapImage(new Uri("pack://application:,,,/Manicotti;component/Resources/ico/Reload.ico", UriKind.Absolute));

            load.Image = loadImg;

            PushButtonData info = new PushButtonData("info", "Pivot Table",
                                                     thisAssemblyPath, "Manicotti.Views.CmdFindAllFamilyInstance");

            info.ToolTip = "List of generated instances. WIP";
            BitmapImage infoImg = new BitmapImage(new Uri("pack://application:,,,/Manicotti;component/Resources/ico/Info.ico", UriKind.Absolute));

            info.Image = infoImg;

            IList <RibbonItem> stackedSetting = modelSetting.AddStackedItems(config, load, info);


            ////////////
            // 3rd Panel
            RibbonPanel modelSketch = ribbonPanel(a, "Manicotti", "Sketch");

            PushButtonData sketchDWG = new PushButtonData("sketchDWG", "Photocopy DWG",
                                                          thisAssemblyPath, "Manicotti.CmdSketchDWG");

            sketchDWG.ToolTip = "Extract geometries and texts. To test the demo, Link_test.dwg must be linked. (act on Linked DWG)";
            BitmapImage sketchdwgImg = new BitmapImage(new Uri("pack://application:,,,/Manicotti;component/Resources/ico/Sketchdwg.ico", UriKind.Absolute));

            sketchDWG.Image = sketchdwgImg;

            PushButtonData sketchLocation = new PushButtonData("sketchLocation", "Mark Location",
                                                               thisAssemblyPath, "Manicotti.CmdSketchLocation");

            sketchLocation.ToolTip = "Draw model lines based on component axis";
            BitmapImage sketchlocImg = new BitmapImage(new Uri("pack://application:,,,/Manicotti;component/Resources/ico/Sketchlocation.ico", UriKind.Absolute));

            sketchLocation.Image = sketchlocImg;

            IList <RibbonItem> stackedSketch = modelSketch.AddStackedItems(sketchDWG, sketchLocation);


            ////////////
            // 4th Panel
            RibbonPanel modelFix = ribbonPanel(a, "Manicotti", "Algorithm");
            PushButton  mesh     = modelFix.AddItem(new PushButtonData("mesh", "Patch\nAxis Grid",
                                                                       thisAssemblyPath, "Manicotti.CmdPatchBoundary")) as PushButton;

            mesh.ToolTip = "WIP. Patch all the space boundaries. To test the demo, Link_demo.dwg must be linked. (act on Linked DWG) ";
            BitmapImage meshImg = new BitmapImage(new Uri("pack://application:,,,/Manicotti;component/Resources/ico/Anchor.ico", UriKind.Absolute));

            mesh.LargeImage = meshImg;

            modelFix.Enabled = false;


            ////////////
            // 5th Panel
            RibbonPanel modelTest = ribbonPanel(a, "Manicotti", "Misc.");

            // Currently in progress and disabled
            modelTest.Enabled = false;

            PushButtonData region = new PushButtonData("detect_region", "Detect Region",
                                                       thisAssemblyPath, "Manicotti.RegionDetect");

            region.ToolTip = "Detect enclosed regions. (act on ModelLines with WALL linetype)";
            BitmapImage regionImg = new BitmapImage(new Uri("pack://application:,,,/Manicotti;component/Resources/ico/Room.ico", UriKind.Absolute));

            region.Image = regionImg;

            PushButtonData fusion = new PushButtonData("fusion", "Regen Axis",
                                                       thisAssemblyPath, "Manicotti.Fusion");

            fusion.ToolTip = "Space mesh regeneration. (act on Walls & Curtains). WIP";
            BitmapImage fusionImg = new BitmapImage(new Uri("pack://application:,,,/Manicotti;component/Resources/ico/Boundary.ico", UriKind.Absolute));

            fusion.Image = fusionImg;

            PushButtonData test = new PushButtonData("test", "Test\nButton",
                                                     thisAssemblyPath, "Manicotti.TestIntersect");

            test.ToolTip = "Default and preferance settings. WIP";
            BitmapImage testImg = new BitmapImage(new Uri("pack://application:,,,/Manicotti;component/Resources/ico/Error.ico", UriKind.Absolute));

            test.Image = testImg;

            IList <RibbonItem> stackedTest = modelTest.AddStackedItems(region, fusion, test);

            modelTest.Enabled = false;


            a.ApplicationClosing += a_ApplicationClosing;

            return(Result.Succeeded);
        }
Exemplo n.º 41
0
 public ToolbarCommand(string name, PushButton command, Bitmap bitmap)
 {
     CommandName = name;
     Command     = command;
     Bitmap      = bitmap;
 }
Exemplo n.º 42
0
        public Result OnStartup(UIControlledApplication application)
        {
            _instance    = this;
            _application = application;

            try
            {
                _serviceHost = new ServiceHost(typeof(SockeyeService), new Uri("net.pipe://localhost/mcneel/sockeyeserver/1/server"));
            }
            catch
            {
                TaskDialog.Show("Sockeye", "Failed to create Sockeye service host.");
                throw;
            }

            try
            {
                _serviceHost.AddServiceEndpoint(typeof(ISockeyeService), new NetNamedPipeBinding(), "pipe");
            }
            catch
            {
                TaskDialog.Show("Sockeye", "Failed to create Sockeye service end point.");
                throw;
            }

            try
            {
                ServiceDebugBehavior debugBehavior = _serviceHost.Description.Behaviors.Find <ServiceDebugBehavior>();
                if (null == debugBehavior)
                {
                    debugBehavior = new ServiceDebugBehavior();
                    debugBehavior.IncludeExceptionDetailInFaults = true;
                    _serviceHost.Description.Behaviors.Add(debugBehavior);
                }
                else
                {
                    debugBehavior.IncludeExceptionDetailInFaults = true;
                }
            }
            catch
            {
                TaskDialog.Show("Sockeye", "Failed to create Sockeye service debug behavior.");
                throw;
            }

            try
            {
                _serviceHost.Open();
            }
            catch
            {
                TaskDialog.Show("Sockeye", "Failed to open Sockeye service.");
                throw;
            }

            RibbonPanel ribbonPanel = application.CreateRibbonPanel(_assemblyTitle);

            PushButton pushButton = ribbonPanel.AddItem(new PushButtonData(
                                                            _assemblyTitle, _assemblyTitle, _assemblyLocation, "SockeyeServer.Commands.CmdAbout")) as PushButton;

            Bitmap logo = SockeyeServer.Properties.Resources.Logo_32_32;

            BitmapSource bitmapSource = Imaging.CreateBitmapSourceFromHBitmap(
                logo.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());

            pushButton.LargeImage = bitmapSource;
            pushButton.Image      = bitmapSource;

            return(Result.Succeeded);
        }
Exemplo n.º 43
0
 /// <summary>
 /// Utility for adding icons to the button.
 /// </summary>
 /// <param name="button">The push button.</param>
 /// <param name="icon">The icon.</param>
 private static void SetIconsForPushButton(PushButton button, System.Drawing.Icon icon)
 {
     button.LargeImage = GetStdIcon(icon);
     button.Image      = GetSmallIcon(icon);
 }
Exemplo n.º 44
0
        /// <summary>
        /// This method is used to create RibbonSample panel, and add wall related command buttons to it:
        /// 1. contains a SplitButton for user to create Non-Structural or Structural Wall;
        /// 2. contains a StackedBotton which is consisted with one PushButton and two Comboboxes,
        /// PushButon is used to reset all the RibbonItem, Comboboxes are use to select Level and WallShape
        /// 3. contains a RadioButtonGroup for user to select WallType.
        /// 4. Adds a Slide-Out Panel to existing panel with following functionalities:
        /// 5. a text box is added to set mark for new wall, mark is a instance parameter for wall,
        /// Eg: if user set text as "wall", then Mark for each new wall will be "wall1", "wall2", "wall3"....
        /// 6. a StackedButton which consisted of a PushButton (delete all the walls) and a PulldownButton (move all the walls in X or Y direction)
        /// </summary>
        /// <param name="application">An object that is passed to the external application
        /// which contains the controlled application.</param>
        private void CreateRibbonSamplePanel(UIControlledApplication application)
        {
            // create a Ribbon panel which contains three stackable buttons and one single push button.
            string      firstPanelName    = "Ribbon Sample";
            RibbonPanel ribbonSamplePanel = application.CreateRibbonPanel(firstPanelName);

            #region Create a SplitButton for user to create Non-Structural or Structural Wall
            SplitButtonData splitButtonData = new SplitButtonData("NewWallSplit", "Create Wall");
            SplitButton     splitButton     = ribbonSamplePanel.AddItem(splitButtonData) as SplitButton;
            PushButton      pushButton      = splitButton.AddPushButton(new PushButtonData("WallPush", "Wall", AddInPath, "Revit.SDK.Samples.Ribbon.CS.CreateWall"));
            pushButton.LargeImage   = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "CreateWall.png"), UriKind.Absolute));
            pushButton.Image        = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "CreateWall-S.png"), UriKind.Absolute));
            pushButton.ToolTip      = "Creates a partition wall in the building model.";
            pushButton.ToolTipImage = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "CreateWallTooltip.bmp"), UriKind.Absolute));
            pushButton            = splitButton.AddPushButton(new PushButtonData("StrWallPush", "Structure Wall", AddInPath, "Revit.SDK.Samples.Ribbon.CS.CreateStructureWall"));
            pushButton.LargeImage = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "StrcturalWall.png"), UriKind.Absolute));
            pushButton.Image      = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "StrcturalWall-S.png"), UriKind.Absolute));
            #endregion

            ribbonSamplePanel.AddSeparator();

            #region Add a StackedButton which is consisted of one PushButton and two Comboboxes
            PushButtonData     pushButtonData     = new PushButtonData("Reset", "Reset", AddInPath, "Revit.SDK.Samples.Ribbon.CS.ResetSetting");
            ComboBoxData       comboBoxDataLevel  = new ComboBoxData("LevelsSelector");
            ComboBoxData       comboBoxDataShape  = new ComboBoxData("WallShapeComboBox");
            IList <RibbonItem> ribbonItemsStacked = ribbonSamplePanel.AddStackedItems(pushButtonData, comboBoxDataLevel, comboBoxDataShape);
            ((PushButton)(ribbonItemsStacked[0])).Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "Reset.png"), UriKind.Absolute));
            //Add options to WallShapeComboBox
            Autodesk.Revit.UI.ComboBox comboboxWallShape  = (Autodesk.Revit.UI.ComboBox)(ribbonItemsStacked[2]);
            ComboBoxMemberData         comboBoxMemberData = new ComboBoxMemberData("RectangleWall", "RectangleWall");
            ComboBoxMember             comboboxMember     = comboboxWallShape.AddItem(comboBoxMemberData);
            comboboxMember.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "RectangleWall.png"), UriKind.Absolute));
            comboBoxMemberData   = new ComboBoxMemberData("CircleWall", "CircleWall");
            comboboxMember       = comboboxWallShape.AddItem(comboBoxMemberData);
            comboboxMember.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "CircleWall.png"), UriKind.Absolute));
            comboBoxMemberData   = new ComboBoxMemberData("TriangleWall", "TriangleWall");
            comboboxMember       = comboboxWallShape.AddItem(comboBoxMemberData);
            comboboxMember.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "TriangleWall.png"), UriKind.Absolute));
            comboBoxMemberData   = new ComboBoxMemberData("SquareWall", "SquareWall");
            comboboxMember       = comboboxWallShape.AddItem(comboBoxMemberData);
            comboboxMember.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "SquareWall.png"), UriKind.Absolute));
            #endregion

            ribbonSamplePanel.AddSeparator();

            #region Add a RadioButtonGroup for user to select WallType
            RadioButtonGroupData radioButtonGroupData = new RadioButtonGroupData("WallTypeSelector");
            RadioButtonGroup     radioButtonGroup     = (RadioButtonGroup)(ribbonSamplePanel.AddItem(radioButtonGroupData));
            ToggleButton         toggleButton         = radioButtonGroup.AddItem(new ToggleButtonData("Generic8", "Generic - 8\"", AddInPath, "Revit.SDK.Samples.Ribbon.CS.Dummy"));
            toggleButton.LargeImage = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "Generic8.png"), UriKind.Absolute));
            toggleButton.Image      = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "Generic8-S.png"), UriKind.Absolute));
            toggleButton            = radioButtonGroup.AddItem(new ToggleButtonData("ExteriorBrick", "Exterior - Brick", AddInPath, "Revit.SDK.Samples.Ribbon.CS.Dummy"));
            toggleButton.LargeImage = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "ExteriorBrick.png"), UriKind.Absolute));
            toggleButton.Image      = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "ExteriorBrick-S.png"), UriKind.Absolute));
            #endregion

            //slide-out panel:
            ribbonSamplePanel.AddSlideOut();

            #region add a Text box to set the mark for new wall
            TextBoxData testBoxData           = new TextBoxData("WallMark");
            Autodesk.Revit.UI.TextBox textBox = (Autodesk.Revit.UI.TextBox)(ribbonSamplePanel.AddItem(testBoxData));
            textBox.Value             = "new wall"; //default wall mark
            textBox.Image             = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "WallMark.png"), UriKind.Absolute));
            textBox.ToolTip           = "Set the mark for new wall";
            textBox.ShowImageAsButton = true;
            textBox.EnterPressed     += new EventHandler <Autodesk.Revit.UI.Events.TextBoxEnterPressedEventArgs>(SetTextBoxValue);
            #endregion

            ribbonSamplePanel.AddSeparator();

            #region Create a StackedButton which consisted of a PushButton (delete all the walls) and a PulldownButton (move all the walls in X or Y direction)
            PushButtonData deleteWallsButtonData = new PushButtonData("deleteWalls", "Delete Walls", AddInPath, "Revit.SDK.Samples.Ribbon.CS.DeleteWalls");
            deleteWallsButtonData.ToolTip = "Delete all the walls created by the Create Wall tool.";
            deleteWallsButtonData.Image   = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "DeleteWalls.png"), UriKind.Absolute));

            PulldownButtonData moveWallsButtonData = new PulldownButtonData("moveWalls", "Move Walls");
            moveWallsButtonData.ToolTip = "Move all the walls in X or Y direction";
            moveWallsButtonData.Image   = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "MoveWalls.png"), UriKind.Absolute));

            // create stackable buttons
            IList <RibbonItem> ribbonItems = ribbonSamplePanel.AddStackedItems(deleteWallsButtonData, moveWallsButtonData);

            // add two push buttons as sub-items of the moveWalls PulldownButton.
            PulldownButton moveWallItem = ribbonItems[1] as PulldownButton;

            PushButton moveX = moveWallItem.AddPushButton(new PushButtonData("XDirection", "X Direction", AddInPath, "Revit.SDK.Samples.Ribbon.CS.XMoveWalls"));
            moveX.ToolTip    = "move all walls 10 feet in X direction.";
            moveX.LargeImage = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "MoveWallsXLarge.png"), UriKind.Absolute));

            PushButton moveY = moveWallItem.AddPushButton(new PushButtonData("YDirection", "Y Direction", AddInPath, "Revit.SDK.Samples.Ribbon.CS.YMoveWalls"));
            moveY.ToolTip    = "move all walls 10 feet in Y direction.";
            moveY.LargeImage = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "MoveWallsYLarge.png"), UriKind.Absolute));
            #endregion

            ribbonSamplePanel.AddSeparator();

            application.ControlledApplication.DocumentCreated += new EventHandler <Autodesk.Revit.DB.Events.DocumentCreatedEventArgs>(DocumentCreated);
        }