Beispiel #1
0
            private void createActionButtons(Ints actions, Floats buttonXY)
            {
                if (ActionButtons == null)
                {
                    ActionButtons = new List <Button>();
                }

                int actionCount = actions.count();

                for (int i = 0; i < actionCount; i++)
                {
                    int cmdIndex = actions.get(i);
                    if (cmdIndex >= buttonCaptions.Length)
                    {
                        continue;
                    }

                    string cmdName = buttonCaptions[cmdIndex];

                    Button button = new Button()
                    {
                        Content = cmdName,
                        Tag     = cmdIndex,
                        Width   = cmdName.Length * 14 + 8,
                        Height  = 24
                    };
                    button.Click += new RoutedEventHandler(button_Click);
                    _owner.TempCanvas.Children.Add(button);
                    Canvas.SetLeft(button, buttonXY.get(2 * i) - button.Width / 2);
                    Canvas.SetTop(button, buttonXY.get(2 * i + 1) - button.Height / 2);
                    ActionButtons.Add(button);
                }
            }
Beispiel #2
0
            private bool createActionImages(Ints actions, Floats buttonXY)
            {
                int actionCount = actions.count();

                for (int i = 0; i < actionCount; i++)
                {
                    int         cmdIndex    = actions.get(i);
                    ImageSource imageSource = WPFImageSourceHelper.Instance.ActionImageSource(cmdIndex);

                    if (imageSource == null)
                    {
                        continue;
                    }

                    string cmdName = GetButtonCaption(cmdIndex);
                    System.Diagnostics.Trace.WriteLine(string.Format("{0},{1}", cmdIndex, cmdName));

                    Image image = new Image()
                    {
                        Source  = imageSource,
                        ToolTip = cmdName,
                        Tag     = cmdIndex,
                        Width   = imageSource.Width,
                        Height  = imageSource.Height
                    };
                    image.MouseDown += new MouseButtonEventHandler(button_Click);
                    _owner.TempCanvas.Children.Add(image);
                    Canvas.SetLeft(image, buttonXY.get(2 * i) - image.Width / 2);
                    Canvas.SetTop(image, buttonXY.get(2 * i + 1) - image.Height / 2);
                    ActionImages.Add(image);
                    ActionImages.Add(image);
                }

                return(actionCount == 0 || ActionImages.Count > 0);
            }
Beispiel #3
0
        //! 视图坐标转为模型坐标
        public bool DisplayToModel(Point pt)
        {
            Floats p   = new Floats((float)pt.X, (float)pt.Y);
            bool   ret = CoreView.displayToModel(p);

            pt.X = p.get(0);
            pt.Y = p.get(1);
            return(ret);
        }
Beispiel #4
0
        //! 视图坐标转为模型坐标
        public bool DisplayToModel(Rect rect)
        {
            Floats p = new Floats((float)rect.Left, (float)rect.Top,
                                  (float)rect.Right, (float)rect.Bottom);
            bool ret = CoreView.displayToModel(p);

            rect.X      = p.get(0);
            rect.Y      = p.get(1);
            rect.Width  = p.get(2) - rect.X;
            rect.Height = p.get(3) - rect.Y;

            return(ret);
        }
Beispiel #5
0
        public static string getDimensions(int mgView, float[] vars)
        {
            Floats v     = new Floats(vars.Length);
            Chars  types = new Chars(vars.Length);
            int    n     = DemoCmdsGate.getDimensions(mgView, v, types);

            if (n > 0)
            {
                StringBuilder buf = new StringBuilder(n);
                for (int i = 0; i < n; i++)
                {
                    buf.Append(v.get(i));
                    vars[i] = v.get(i);
                }
                return(buf.ToString());
            }
            return("");
        }
Beispiel #6
0
 private Rect ToBox(Floats box, bool ret)
 {
     return(!ret ? new Rect() : new Rect(box.get(0), box.get(1),
                                         box.get(2) - box.get(0), box.get(3) - box.get(1)));
 }