예제 #1
0
        public static Image CutImage(Image source, Size destSize, HorizonOptions horizonOption, VerticalOptions verticalOption)
        {
            int x = 0, y = 0;

            switch (horizonOption)
            {
                case HorizonOptions.Left:
                    x = 0;
                    break;
                case HorizonOptions.Center:
                    x = (source.Width - destSize.Width) / 2;
                    break;
                case HorizonOptions.Right:
                    x = source.Width - destSize.Width;
                    break;
            }

            switch (verticalOption)
            {
                case VerticalOptions.Top:
                    y = 0;
                    break;
                case VerticalOptions.Middle:
                    y = (source.Height - destSize.Height) / 2;
                    break;
                case VerticalOptions.Bottom:
                    y = source.Height - destSize.Height;
                    break;
            }

            return CutImage(source, new Point(x, y), destSize);
        }
예제 #2
0
        public Bubble()
        {
            HorizontalOptions = LayoutOptions.Center;
            VerticalOptions   = LayoutOptions.Center;
            Clicked          += Bubble_Clicked;

            #region
            members = new Dictionary <string, Variable>
            {
                { "Width", new FVariable {
                      ongetvalue = () => new Gnumber(Width),
                      onsetvalue = (value) => { WidthRequest = Convert.ToDouble(value); return(0); }
                  } },
                { "Height", new FVariable
                  {
                      ongetvalue = () => new Gnumber(Height),
                      onsetvalue = (value) => { HeightRequest = Convert.ToDouble(value); return(0); }
                  } },
                { "Horizontal", new FVariable
                  {
                      ongetvalue = () => new Gstring(HorizontalOptions.ToString()),
                      onsetvalue = (value) => {
                          if (value.ToString() == "center")
                          {
                              HorizontalOptions = LayoutOptions.Center;
                          }
                          else if (value.ToString() == "left")
                          {
                              HorizontalOptions = LayoutOptions.Start;
                          }
                          else if (value.ToString() == "right")
                          {
                              HorizontalOptions = LayoutOptions.End;
                          }
                          else if (value.ToString() == "stretch")
                          {
                              HorizontalOptions = LayoutOptions.Fill;
                          }
                          return(0);
                      }
                  } },
                { "Vertical", new FVariable {
                      ongetvalue = () => new Gstring(VerticalOptions.ToString()),
                      onsetvalue = (value) =>
                      {
                          if (value.ToString() == "center")
                          {
                              VerticalOptions = LayoutOptions.Center;
                          }
                          else if (value.ToString() == "bottom")
                          {
                              VerticalOptions = LayoutOptions.End;
                          }
                          else if (value.ToString() == "stretch")
                          {
                              VerticalOptions = LayoutOptions.Fill;
                          }
                          else if (value.ToString() == "top")
                          {
                              VerticalOptions = LayoutOptions.Start;
                          }
                          return(0);
                      }
                  } },
                { "Margin", new FVariable {
                      ongetvalue = () => new Glist {
                          new Variable(Margin.Left), new Variable(Margin.Top), new Variable(Margin.Right), new Variable(Margin.Bottom)
                      },
                      onsetvalue = (value) =>
                      {
                          var list = value.IGetCSValue() as Glist;
                          Margin = new Thickness(
                              Convert.ToDouble(list[0].value), Convert.ToDouble(list[1].value), Convert.ToDouble(list[2].value), Convert.ToDouble(list[3].value)
                              );
                          return(0);
                      }
                  } },
                { "Visibility", new FVariable {
                      ongetvalue = () =>
                      {
                          string s = "null";
                          switch (IsVisible)
                          {
                          case true:
                              s = "visiable";
                              break;

                          case false:
                              s = "gone";
                              break;
                          }
                          return(new Gstring(s));
                      },
                      onsetvalue = (value) =>
                      {
                          if (value.ToString() == "gone")
                          {
                              IsVisible = false;
                          }
                          else if (value.ToString() == "hidden")
                          {
                              IsVisible = false;
                          }
                          else if (value.ToString() == "visible")
                          {
                              IsVisible = true;
                          }
                          return(0);
                      }
                  } },
                { "Text", new FVariable {
                      ongetvalue = () => new Gstring(Text.ToString()),
                      onsetvalue = (value) =>
                      {
                          Text = value.ToString();
                          return(0);
                      }
                  } },
                { "FontSize", new FVariable {
                      ongetvalue = () => new Gnumber(FontSize),
                      onsetvalue = (value) =>
                      {
                          FontSize = Convert.ToDouble(value);
                          return(0);
                      }
                  } },
                { "Padding", new FVariable {
                      ongetvalue = () => new Glist {
                          new Variable(Padding.Left), new Variable(Padding.Top), new Variable(Padding.Right), new Variable(Padding.Bottom)
                      },
                      onsetvalue = (value) =>
                      {
                          var list = value.IGetCSValue() as Glist;
                          Padding = new Thickness(
                              Convert.ToDouble(list[0].value), Convert.ToDouble(list[1].value), Convert.ToDouble(list[2].value), Convert.ToDouble(list[3].value)
                              );
                          return(0);
                      }
                  } },
                { "Background", new FVariable {
                      ongetvalue = () => new Gstring(BackgroundColor.ToString()),
                      onsetvalue = (value) =>
                      {
                          BackgroundColor = (Color) new ColorTypeConverter().ConvertFromInvariantString(value.ToString());
                          return(0);
                      }
                  } },
                { "Foreground", new FVariable {
                      ongetvalue = () => new Gstring(TextColor.ToString()),
                      onsetvalue = (value) =>
                      {
                          TextColor = (Color) new ColorTypeConverter().ConvertFromInvariantString(value.ToString());
                          return(0);
                      }
                  } },
                { "Clickevent", new FVariable
                  {
                      ongetvalue   = () => event_click as IOBJ
                      , onsetvalue = (value) =>
                      {
                          event_click = value;
                          return(0);
                      }
                  } }
            };
            parent = new GTXAM.Control(this);
            #endregion
        }
예제 #3
0
파일: GridFlat.cs 프로젝트: freeman888/GI
        public GridFlat()
        {
            HorizontalOptions = LayoutOptions.FillAndExpand;
            VerticalOptions   = LayoutOptions.FillAndExpand;

            #region
            members = new Dictionary <string, Variable>
            {
                { "Width", new FVariable {
                      ongetvalue = () => new Gnumber(Width),
                      onsetvalue = (value) => { WidthRequest = Convert.ToDouble(value); return(0); }
                  } },
                { "Height", new FVariable
                  {
                      ongetvalue = () => new Gnumber(Height),
                      onsetvalue = (value) => { HeightRequest = Convert.ToDouble(value); return(0); }
                  } },
                { "Horizontal", new FVariable
                  {
                      ongetvalue = () => new Gstring(HorizontalOptions.ToString()),
                      onsetvalue = (value) => {
                          if (value.ToString() == "center")
                          {
                              HorizontalOptions = LayoutOptions.Center;
                          }
                          else if (value.ToString() == "left")
                          {
                              HorizontalOptions = LayoutOptions.Start;
                          }
                          else if (value.ToString() == "right")
                          {
                              HorizontalOptions = LayoutOptions.End;
                          }
                          else if (value.ToString() == "stretch")
                          {
                              HorizontalOptions = LayoutOptions.Fill;
                          }
                          return(0);
                      }
                  } },
                { "Vertical", new FVariable {
                      ongetvalue = () => new Gstring(VerticalOptions.ToString()),
                      onsetvalue = (value) =>
                      {
                          if (value.ToString() == "center")
                          {
                              VerticalOptions = LayoutOptions.Center;
                          }
                          else if (value.ToString() == "bottom")
                          {
                              VerticalOptions = LayoutOptions.End;
                          }
                          else if (value.ToString() == "stretch")
                          {
                              VerticalOptions = LayoutOptions.Fill;
                          }
                          else if (value.ToString() == "top")
                          {
                              VerticalOptions = LayoutOptions.Start;
                          }
                          return(0);
                      }
                  } },
                { "Margin", new FVariable {
                      ongetvalue = () => new Glist {
                          new Variable(Margin.Left), new Variable(Margin.Top), new Variable(Margin.Right), new Variable(Margin.Bottom)
                      },
                      onsetvalue = (value) =>
                      {
                          var list = value.IGetCSValue() as Glist;
                          Margin = new Thickness(
                              Convert.ToDouble(list[0].value), Convert.ToDouble(list[1].value), Convert.ToDouble(list[2].value), Convert.ToDouble(list[3].value)
                              );
                          return(0);
                      }
                  } },
                { "Visibility", new FVariable {
                      ongetvalue = () =>
                      {
                          string s = "null";
                          switch (IsVisible)
                          {
                          case true:
                              s = "visiable";
                              break;

                          case false:
                              s = "gone";
                              break;
                          }
                          return(new Gstring(s));
                      },
                      onsetvalue = (value) =>
                      {
                          if (value.ToString() == "gone")
                          {
                              IsVisible = false;
                          }
                          else if (value.ToString() == "hidden")
                          {
                              IsVisible = false;
                          }
                          else if (value.ToString() == "visible")
                          {
                              IsVisible = true;
                          }
                          return(0);
                      }
                  } },



                { "Background", new FVariable {
                      ongetvalue = () => new Gstring(BackgroundColor.ToString()),
                      onsetvalue = (value) =>
                      {
                          BackgroundColor = (Color) new ColorTypeConverter().ConvertFromInvariantString(value.ToString());
                          return(0);
                      }
                  } },

                { "Add", new Variable(new MFunction(add, this)) },
                { "AddRow", new Variable(new MFunction(addrow, this)) },
                { "AddColumn", new Variable(new MFunction(addcolume, this)) }
            };

            parent = new GTXAM.Control(this);
            #endregion
        }
예제 #4
0
        public Image()
        {
            HorizontalOptions = LayoutOptions.Center;
            VerticalOptions   = LayoutOptions.Center;

            #region
            members = new Dictionary <string, Variable>
            {
                { "Width", new FVariable {
                      ongetvalue = () => new Gnumber(Width),
                      onsetvalue = (value) => { WidthRequest = Convert.ToDouble(value); return(0); }
                  } },
                { "Height", new FVariable
                  {
                      ongetvalue = () => new Gnumber(Height),
                      onsetvalue = (value) => { HeightRequest = Convert.ToDouble(value); return(0); }
                  } },
                { "Horizontal", new FVariable
                  {
                      ongetvalue = () => new Gstring(HorizontalOptions.ToString()),
                      onsetvalue = (value) => {
                          if (value.ToString() == "center")
                          {
                              HorizontalOptions = LayoutOptions.Center;
                          }
                          else if (value.ToString() == "left")
                          {
                              HorizontalOptions = LayoutOptions.Start;
                          }
                          else if (value.ToString() == "right")
                          {
                              HorizontalOptions = LayoutOptions.End;
                          }
                          else if (value.ToString() == "stretch")
                          {
                              HorizontalOptions = LayoutOptions.Fill;
                          }
                          return(0);
                      }
                  } },
                { "Vertical", new FVariable {
                      ongetvalue = () => new Gstring(VerticalOptions.ToString()),
                      onsetvalue = (value) =>
                      {
                          if (value.ToString() == "center")
                          {
                              VerticalOptions = LayoutOptions.Center;
                          }
                          else if (value.ToString() == "bottom")
                          {
                              VerticalOptions = LayoutOptions.End;
                          }
                          else if (value.ToString() == "stretch")
                          {
                              VerticalOptions = LayoutOptions.Fill;
                          }
                          else if (value.ToString() == "top")
                          {
                              VerticalOptions = LayoutOptions.Start;
                          }
                          return(0);
                      }
                  } },
                { "Margin", new FVariable {
                      ongetvalue = () => new Glist {
                          new Variable(Margin.Left), new Variable(Margin.Top), new Variable(Margin.Right), new Variable(Margin.Bottom)
                      },
                      onsetvalue = (value) =>
                      {
                          var list = value.IGetCSValue() as Glist;
                          Margin = new Thickness(
                              Convert.ToDouble(list[0].value), Convert.ToDouble(list[1].value), Convert.ToDouble(list[2].value), Convert.ToDouble(list[3].value)
                              );
                          return(0);
                      }
                  } },
                { "Visibility", new FVariable {
                      ongetvalue = () =>
                      {
                          string s = "null";
                          switch (IsVisible)
                          {
                          case true:
                              s = "visiable";
                              break;

                          case false:
                              s = "gone";
                              break;
                          }
                          return(new Gstring(s));
                      },
                      onsetvalue = (value) =>
                      {
                          if (value.ToString() == "gone")
                          {
                              IsVisible = false;
                          }
                          else if (value.ToString() == "hidden")
                          {
                              IsVisible = false;
                          }
                          else if (value.ToString() == "visible")
                          {
                              IsVisible = true;
                          }
                          return(0);
                      }
                  } },
                { "Source", new FVariable {
                      onsetvalue = (value) =>
                      {
                          try
                          {
                              Source = ImageSource.FromStream(() => value.IGetCSValue() as Stream);
                          }
                          catch (Exception e)
                          {
                              Debug.WriteLine(e.ToString());
                          }
                          return(0);
                      }
                  } },
            };
            parent = new GTXAM.Control(this);
            #endregion
        }
예제 #5
0
        public WebView()
        {
            HorizontalOptions = LayoutOptions.Fill;
            VerticalOptions   = LayoutOptions.Fill;

            #region
            members = new Dictionary <string, Variable>
            {
                { "Width", new FVariable {
                      ongetvalue = () => new Gnumber(Width),
                      onsetvalue = (value) => { WidthRequest = Convert.ToDouble(value); return(0); }
                  } },
                { "Height", new FVariable
                  {
                      ongetvalue = () => new Gnumber(Height),
                      onsetvalue = (value) => { HeightRequest = Convert.ToDouble(value); return(0); }
                  } },
                { "Horizontal", new FVariable
                  {
                      ongetvalue = () => new Gstring(HorizontalOptions.ToString()),
                      onsetvalue = (value) => {
                          if (value.ToString() == "center")
                          {
                              HorizontalOptions = LayoutOptions.Center;
                          }
                          else if (value.ToString() == "left")
                          {
                              HorizontalOptions = LayoutOptions.Start;
                          }
                          else if (value.ToString() == "right")
                          {
                              HorizontalOptions = LayoutOptions.End;
                          }
                          else if (value.ToString() == "stretch")
                          {
                              HorizontalOptions = LayoutOptions.Fill;
                          }
                          return(0);
                      }
                  } },
                { "Vertical", new FVariable {
                      ongetvalue = () => new Gstring(VerticalOptions.ToString()),
                      onsetvalue = (value) =>
                      {
                          if (value.ToString() == "center")
                          {
                              VerticalOptions = LayoutOptions.Center;
                          }
                          else if (value.ToString() == "bottom")
                          {
                              VerticalOptions = LayoutOptions.End;
                          }
                          else if (value.ToString() == "stretch")
                          {
                              VerticalOptions = LayoutOptions.Fill;
                          }
                          else if (value.ToString() == "top")
                          {
                              VerticalOptions = LayoutOptions.Start;
                          }
                          return(0);
                      }
                  } },
                { "Margin", new FVariable {
                      ongetvalue = () => new Glist {
                          new Variable(Margin.Left), new Variable(Margin.Top), new Variable(Margin.Right), new Variable(Margin.Bottom)
                      },
                      onsetvalue = (value) =>
                      {
                          var list = value.IGetCSValue() as Glist;
                          Margin = new Thickness(
                              Convert.ToDouble(list[0].value), Convert.ToDouble(list[1].value), Convert.ToDouble(list[2].value), Convert.ToDouble(list[3].value)
                              );
                          return(0);
                      }
                  } },
                { "Visibility", new FVariable {
                      ongetvalue = () =>
                      {
                          string s = "null";
                          switch (IsVisible)
                          {
                          case true:
                              s = "visiable";
                              break;

                          case false:
                              s = "gone";
                              break;
                          }
                          return(new Gstring(s));
                      },
                      onsetvalue = (value) =>
                      {
                          if (value.ToString() == "gone")
                          {
                              IsVisible = false;
                          }
                          else if (value.ToString() == "hidden")
                          {
                              IsVisible = false;
                          }
                          else if (value.ToString() == "visible")
                          {
                              IsVisible = true;
                          }
                          return(0);
                      }
                  } },
                { "Url", new FVariable {
                      ongetvalue = () => new Gstring(this.Source.ToString()),
                      onsetvalue = (value) =>
                      {
                          var path = value.ToString();
                          if (GIInfo.Platform == "Mac_Xamarin")
                          {
                              path = path.Replace("\\", "/");
                          }
                          Source = new UrlWebViewSource {
                              Url = path
                          };
                          return(0);
                      }
                  } },
                {
                    "InvokeJS", new Variable(new MFunction(invokejs, this))
                }
            };
            parent = new GTXAM.Control(this);
            #endregion
        }
예제 #6
0
        public ScrollFlat()
        {
            HorizontalOptions = LayoutOptions.FillAndExpand;
            VerticalOptions   = LayoutOptions.FillAndExpand;

            #region
            members = new Dictionary <string, Variable>
            {
                { "Width", new FVariable {
                      ongetvalue = () => new Gnumber(Width),
                      onsetvalue = (value) => { WidthRequest = Convert.ToDouble(value); return(0); }
                  } },
                { "Height", new FVariable
                  {
                      ongetvalue = () => new Gnumber(Height),
                      onsetvalue = (value) => { HeightRequest = Convert.ToDouble(value); return(0); }
                  } },
                { "Horizontal", new FVariable
                  {
                      ongetvalue = () => new Gstring(HorizontalOptions.ToString()),
                      onsetvalue = (value) => {
                          if (value.ToString() == "center")
                          {
                              HorizontalOptions = LayoutOptions.Center;
                          }
                          else if (value.ToString() == "left")
                          {
                              HorizontalOptions = LayoutOptions.Start;
                          }
                          else if (value.ToString() == "right")
                          {
                              HorizontalOptions = LayoutOptions.End;
                          }
                          else if (value.ToString() == "stretch")
                          {
                              HorizontalOptions = LayoutOptions.Fill;
                          }
                          return(0);
                      }
                  } },
                { "Vertical", new FVariable {
                      ongetvalue = () => new Gstring(VerticalOptions.ToString()),
                      onsetvalue = (value) =>
                      {
                          if (value.ToString() == "center")
                          {
                              VerticalOptions = LayoutOptions.Center;
                          }
                          else if (value.ToString() == "bottom")
                          {
                              VerticalOptions = LayoutOptions.End;
                          }
                          else if (value.ToString() == "stretch")
                          {
                              VerticalOptions = LayoutOptions.Fill;
                          }
                          else if (value.ToString() == "top")
                          {
                              VerticalOptions = LayoutOptions.Start;
                          }
                          return(0);
                      }
                  } },
                { "Margin", new FVariable {
                      ongetvalue = () => new Glist {
                          new Variable(Margin.Left), new Variable(Margin.Top), new Variable(Margin.Right), new Variable(Margin.Bottom)
                      },
                      onsetvalue = (value) =>
                      {
                          var list = value.IGetCSValue() as Glist;
                          Margin = new Thickness(
                              Convert.ToDouble(list[0].value), Convert.ToDouble(list[1].value), Convert.ToDouble(list[2].value), Convert.ToDouble(list[3].value)
                              );
                          return(0);
                      }
                  } },
                { "Visibility", new FVariable {
                      ongetvalue = () =>
                      {
                          string s = "null";
                          switch (IsVisible)
                          {
                          case true:
                              s = "visiable";
                              break;

                          case false:
                              s = "gone";
                              break;
                          }
                          return(new Gstring(s));
                      },
                      onsetvalue = (value) =>
                      {
                          if (value.ToString() == "gone")
                          {
                              IsVisible = false;
                          }
                          else if (value.ToString() == "hidden")
                          {
                              IsVisible = false;
                          }
                          else if (value.ToString() == "visible")
                          {
                              IsVisible = true;
                          }
                          return(0);
                      }
                  } },


                { "Padding", new FVariable {
                      ongetvalue = () => new Glist {
                          new Variable(Padding.Left), new Variable(Padding.Top), new Variable(Padding.Right), new Variable(Padding.Bottom)
                      },
                      onsetvalue = (value) =>
                      {
                          var list = value.IGetCSValue() as Glist;
                          Padding = new Thickness(
                              Convert.ToDouble(list[0].value), Convert.ToDouble(list[1].value), Convert.ToDouble(list[2].value), Convert.ToDouble(list[3].value)
                              );
                          return(0);
                      }
                  } },
                { "Background", new FVariable {
                      ongetvalue = () => new Gstring(BackgroundColor.ToString()),
                      onsetvalue = (value) =>
                      {
                          BackgroundColor = (Color) new ColorTypeConverter().ConvertFromInvariantString(value.ToString());
                          return(0);
                      }
                  } },

                { "ScrollPosition", new FVariable
                  {
                      ongetvalue = () =>
                      {
                          return(new Glist
                            {
                                new Variable(ScrollX),
                                new Variable(ScrollY)
                            });
                      },
                      onsetvalue = (value) =>
                      {
                          if (value.IGetType() == "List")
                          {
                              var list = value.IGetCSValue() as Glist;
                              var ho   = Convert.ToDouble(list[0].value);
                              var vo   = Convert.ToDouble(list[1].value);
                              ScrollToAsync(ho, vo, true);
                          }
                          else
                          {
                              string s_info = value.ToString();
                              switch (s_info)
                              {
                              case "bottom":
                                  ScrollToAsync(Content, ScrollToPosition.End, true);
                                  return(0);

                              case "end":
                                  ScrollToAsync(Content, ScrollToPosition.End, true);
                                  return(0);

                              case "home":
                                  ScrollToAsync(Content, ScrollToPosition.Start, true);
                                  return(0);

                              case "leftend":
                                  ScrollToAsync(Content, ScrollToPosition.End, true);
                                  return(0);

                              case "rightend":
                                  ScrollToAsync(Content, ScrollToPosition.End, true);
                                  return(0);

                              case "top":
                                  ScrollToAsync(Content, ScrollToPosition.Start, true);
                                  return(0);

                              default:
                                  break;
                              }
                          }
                          return(0);
                      }
                  } },
                { "SetContent", new Variable(new MFunction(setcontent, this)) }
            };
            parent = new GTXAM.Control(this);
            #endregion
        }