Example #1
0
        public SegmentControl(UIColor[] colors)
            : base(new RectangleF(0, 0, BUTTON_WIDTH * colors.Length, BUTTON_WIDTH))
        {
            _segmentCount = colors.Length;

            for (int i = 0; i < colors.Length; i++)
            {
                ColorView view = new ColorView(new RectangleF(BUTTON_WIDTH * i, 0, BUTTON_WIDTH, BUTTON_WIDTH))
                {
                    BackgroundColor = colors[i]
                };

                view.ColorSelected += delegate(UIColor selectedColor) {
                    if (ColorSelected != null)
                    {
                        ColorSelected(selectedColor, currentColor);
                    }
                    currentColor = selectedColor;
                    foreach (ColorView colorView in Subviews)
                    {
                        colorView.IsSelected = colorView == view;
                        colorView.SetNeedsDisplay();
                    }
                };

                AddSubview(view);
            }
        }
Example #2
0
            public void Bind(ProjectsCollection.SuperProjectData projectData, bool showClient)
            {
                this.projectData = projectData;

                if (projectData.IsEmpty)
                {
                    var emptyColor = ColorView.Resources.GetColor(Resource.Color.dark_gray_text);
                    ColorView.SetBackgroundColor(emptyColor);
                    ProjectTextView.SetTextColor(emptyColor);
                    ClientTextView.SetTextColor(emptyColor);

                    ProjectTextView.SetText(Resource.String.ProjectsNoProject);
                    ClientTextView.Visibility = ViewStates.Gone;
                    TasksButton.Visibility    = ViewStates.Gone;
                    return;
                }

                var color = Color.ParseColor(ProjectModel.HexColors [projectData.Color % ProjectModel.HexColors.Length]);

                ColorView.SetBackgroundColor(color);
                ProjectTextView.SetTextColor(color);
                ClientTextView.SetTextColor(color);

                ProjectTextView.Text      = projectData.Name;
                ClientTextView.Text       = projectData.ClientName;
                ClientTextView.Visibility = showClient ? ViewStates.Visible : ViewStates.Gone;
                TasksButton.Visibility    = projectData.TaskNumber > 0 ? ViewStates.Visible : ViewStates.Gone;
                TasksButton.Selected      = false;
            }
Example #3
0
    public static ColorView Load()
    {
        ColorView view = UIView.Load("Views/ColorView", OverriddenViewController.Instance.transform) as ColorView;

        view.name = "ColorView";
        return(view);
    }
Example #4
0
 public WaitingView()
     : base("Loading Data...", new TextStyle("system", FontStyle.Italic | FontStyle.Bold, 40), ForeColor)
 {
     Margin     = SafetyViewMargin.TitleMargin;
     _indicator = new ColorView(ForeColor);
     Children.Add(_indicator);
 }
        private void Awake()
        {
            var verticalLayout = new VerticalLayout("box").AddTo(this);

            new SpaceView(4).AddTo(verticalLayout);

            new LabelView("名字").FontSize(15).AddTo(verticalLayout);

            string itemName = string.Empty;

            //加.BackgroundColor(Color.white)  的原因
            //因为按钮事件的时候 background 还是在被更改的期间
            //所以 需要一个颜色 来显示自己的颜色
            //不过后面用cmdQueue延迟加载了所以无所谓
            textAreaView = new TextAreaView(itemName, (s) => itemName = s)
                           .AddTo(verticalLayout);

            new LabelView("颜色").FontSize(15).AddTo(verticalLayout);

            Color itemColor = Color.black;

            colorView = new ColorView(itemColor, (c) => itemColor = c)
                        .AddTo(verticalLayout);

            changeButton = new ButtonView("添加", () => { }, true)
                           .AddTo(verticalLayout);

            new ButtonView("关闭", Close, true)
            .AddTo(verticalLayout);
        }
Example #6
0
            protected override void Rebind()
            {
                if (Model == null)
                {
                    ColorView.SetBackgroundColor(ColorView.Resources.GetColor(Resource.Color.dark_gray_text));
                    ProjectTextView.SetText(Resource.String.ProjectsNoProject);
                    ClientTextView.Visibility   = ViewStates.Gone;
                    TasksFrameLayout.Visibility = ViewStates.Gone;
                    return;
                }

                var color = Color.ParseColor(Model.GetHexColor());

                ColorView.SetBackgroundColor(color);
                ProjectTextView.Text = Model.Name;
                if (Model.Client != null)
                {
                    ClientTextView.Text       = Model.Client.Name;
                    ClientTextView.Visibility = ViewStates.Visible;
                }
                else
                {
                    ClientTextView.Visibility = ViewStates.Gone;
                }

                TasksFrameLayout.Visibility = DataSource.Tasks.Count == 0 ? ViewStates.Gone : ViewStates.Visible;
                var expanded = dataView.AreProjectTasksVisible(Model);

                TasksTextView.Visibility  = expanded ? ViewStates.Invisible : ViewStates.Visible;
                TasksImageView.Visibility = !expanded ? ViewStates.Invisible : ViewStates.Visible;
            }
Example #7
0
            protected override void Rebind()
            {
                var color = Color.ParseColor(Model.GetHexColor());

                ColorView.SetBackgroundColor(color);
                ProjectTextView.SetText(Resource.String.ProjectsNewProject);
            }
Example #8
0
            protected override View CreateSelector(int width, int height)
            {
                ColorView selector = new ColorView(System.Drawing.Color.Blue);

                selector.Bounds = new System.Drawing.Rectangle(0, 0, width, height);
                this.Children.Add(selector);
                return(selector);
            }
Example #9
0
        public override void OnApplicationStart(HmeApplicationStartArgs e)
        {
            e.Application.ApplicationParametersReceived += new EventHandler <ApplicationParametersReceivedArgs>(Application_ApplicationParametersReceived);
            e.Application.KeyPress += new EventHandler <KeyEventArgs>(Application_KeyPress);
            e.Application.ApplicationErrorOccurred += new EventHandler <ApplicationErrorArgs>(Application_ApplicationErrorOccurred);

            _root = e.Application.Root;

            int x = SafetyViewMargin.HorizontalActionMargin;
            int w = _root.Bounds.Width - 2 * x;

            _titleView        = new TextView("HME Transition Test", DefaultRegular30, Color.White);
            _titleView.Bounds = new Rectangle(x, SafetyViewMargin.VerticalActionMargin, w, 40);
            _root.Children.Add(_titleView);

            _depthView        = new TextView(string.Empty, DefaultRegular20, Color.White);
            _depthView.Bounds = new Rectangle(x, 70, w, 40);
            _root.Children.Add(_depthView);

            _entryView        = new TextView(string.Empty, DefaultRegular20, Color.White);
            _entryView.Bounds = new Rectangle(x, 100, w / 2 - 10, 40);
            _root.Children.Add(_entryView);

            _returnView        = new TextView(string.Empty, DefaultRegular20, Color.White);
            _returnView.Bounds = new Rectangle(x + w / 2 + 20, 100, w / 2 - 10, 40);
            _root.Children.Add(_returnView);

            _colorView        = new TextView(string.Empty, DefaultRegular20, Color.White);
            _colorView.Bounds = new Rectangle(x, 130, w, 40);
            _root.Children.Add(_colorView);

            _hilightView        = new ColorView(Color.White);
            _hilightView.Bounds = new Rectangle(0, 0, 0, 0);
            _root.Children.Add(_hilightView);
            UpdateHilight(e.Application);

            _colorViews = new View[colors.Length];
            for (int i = 0; i < colors.Length; ++i)
            {
                x = SafetyViewMargin.HorizontalActionMargin + 80;
                w = _root.Bounds.Width - 2 * x;
                int y = 180 + i * 50;
                int h = 40;
                _colorViews[i]        = new ColorView(colors[i]);
                _colorViews[i].Bounds = new Rectangle(x, y, w, h);
                _root.Children.Add(_colorViews[i]);
            }

            _hintsView = new TextView("Move up and down to select a color.  " +
                                      "Move left to go back, right to go forward.",
                                      DefaultRegular14, Color.White);
            _hintsView.Bounds = new Rectangle(x, 400, w, 40);
            _root.Children.Add(_hintsView);

            _errorView        = new TextView(string.Empty, DefaultRegular18, Color.Red);
            _errorView.Bounds = new Rectangle(x, 440, w, 40);
            _root.Children.Add(_errorView);
        }
Example #10
0
            public void application_TextStyleCreated(object sender, TextStyleCreatedArgs e)
            {
                Update("Font Info:  default.ttf 36 Bold\n" +
                       "height:     " + e.Info.Height + "\n" +
                       "ascent:     " + e.Info.Ascent + "\n" +
                       "descent:    " + e.Info.Descent + "\n" +
                       "linegap:    " + e.Info.LineGap + "\n" +
                       "l advance:  " + e.Info.GlyphInfo['l'].AdvanceWidth + "\n" +
                       "M advance:  " + e.Info.GlyphInfo['M'].AdvanceWidth);

                // resize the view vertically to exactly fit the text
                int newHeight = (int)(e.Info.Height * 8);
                int newY      = 240 - newHeight / 2;

                Bounds = new System.Drawing.Rectangle(0, newY, 640, newHeight);

                // create a header view that is sized to the exact top area above the font info
                ColorView header = new ColorView(System.Drawing.Color.Gray);

                header.Bounds = new System.Drawing.Rectangle(0, 0, 640, newY);
                Parent.Children.Add(header);
                TextView headerText = new TextView("Header", Style, System.Drawing.Color.Blue);

                headerText.Bounds = new System.Drawing.Rectangle(0, 0, 640, newY);
                header.Children.Add(headerText);

                // create a footer view that is sized to the exact area below the font info
                ColorView footer = new ColorView(System.Drawing.Color.Gray);

                footer.Bounds = new System.Drawing.Rectangle(0, newY + newHeight, 640, newY);
                Parent.Children.Add(footer);

                // create a text resource and put in a view that is sized-to-fit the width
                string someText = "Program Your TV!\u00ae";

                System.Drawing.SizeF someTextSize = e.Info.MeasureText(someText);
                int someTextWidth = (int)Math.Ceiling(someTextSize.Width);

                // set the BG color behind the text
                ColorView textBackground = new ColorView(System.Drawing.Color.Red);

                textBackground.Bounds = new System.Drawing.Rectangle(0, 0, someTextWidth, newY);
                footer.Children.Add(textBackground);

                // create the view that contains the text
                TextView footerText = new TextView(someText, Style, System.Drawing.Color.Cyan);

                footerText.Bounds = textBackground.Bounds;
                footer.Children.Add(footerText);

                // position the footer to the right of the text
                TextView footerText2 = new TextView("Footer", Style, System.Drawing.Color.Blue);

                footerText2.Bounds = new System.Drawing.Rectangle(someTextWidth, 0, 640 - someTextWidth, newY);
                footer.Children.Add(footerText2);
            }
Example #11
0
 public static void CloseColorViewPage()
 {
     UiBlockerUtility.Unblock();
     if (_ColorView == null)
     {
         return;
     }
     ModalSheetUtility.Hide(_ColorView);
     _ColorView = null;
 }
Example #12
0
 public static void OpenColorViewPage()
 {
     if (_ColorView != null)
     {
         return;
     }
     _ColorView = new ColorView();
     UiBlockerUtility.BlockNavigation();
     ModalSheetUtility.Show(_ColorView);
     App.SupressBackEvent += HardwareButtonsOnBackPressedForColorViewPage;
 }
        public void Show(string msg, ColorView color = ColorView.Default)
        {
            if (msgQueue.Count == maxSize)
            {
                sb.Remove(0, msgQueue.Dequeue());
            }
            string nmsg = '\n' + AddColor(msg, color);

            msgQueue.Enqueue(nmsg.Length);
            sb.Append(nmsg);
            text.text = sb.ToString();
        }
        private void ChangeEditMode(ToolStripMenuItem newMode, bool CloseWindow = true)
        {
            if (newMode == colorPickerMenuItem)
            {
                if (colorView == null || colorView.IsDisposed)
                {
                    colorView = new ColorView();
                }
                colorView.Show();
            }
            else if (CloseWindow)
            {
                colorView.Close();
            }

            if (newMode == textRecognitionMenuItem)
            {
                if (textView == null || textView.IsDisposed)
                {
                    textView = new TextRecognitionView();
                }
                textView.Show();
            }
            else if (CloseWindow)
            {
                textView.Close();
            }

            if (newMode == chooseColorMenuItem)
            {
                var LeDialog = new ColorDialog
                {
                    AllowFullOpen = true,
                    AnyColor      = true,
                    Color         = config.Default.PrimaryColor
                };
                if (LeDialog.ShowDialog() == DialogResult.OK)
                {
                    config.Default.PrimaryColor = LeDialog.Color;
                }
            }

            foreach (ToolStripItem item in editMenuItem.DropDownItems)
            {
                if (item is ToolStripMenuItem)
                {
                    (item as ToolStripMenuItem).Checked = item == newMode;
                }
            }

            mode = newMode;
        }
Example #15
0
        private void ShowLegend(TextStyleInfo info)
        {
            View legendView = new ColorView(Color.AntiqueWhite);
            // round height
            int lineHeight = (int)(info.Height + 0.5);
            // height is enough for each line plus half a line padding plus line for total
            int   boxHeight    = lineHeight * (_legend.Count + 2);
            float longestLabel = 0;

            foreach (string label in _legend.Keys)
            {
                longestLabel = Math.Max(longestLabel, info.MeasureText(label).Width);
            }
            // width is long enough for the longest line + color palete + padding
            // using Height for width and height of color palete (shrunk a little for margin)
            int boxWidth = (int)(longestLabel + 0.5 + 2 * lineHeight);

            legendView.Bounds = new Rectangle(Bounds.Width - boxWidth, 0, boxWidth, boxHeight);
            Children.Add(legendView);

            // leave a half line space at the top (and bottom since the whole thing has an extra line height)
            int topText = lineHeight / 2;
            // small left margin for black border. actual color starts one more pixel in
            int leftColor = lineHeight / 4;
            // enough space for the color.  Subtract on since the black border gives too much margin
            int leftText = lineHeight / 2 + lineHeight - 1;
            // subtract three from color size to get 1 pixel margin between boxes plus a pixel for top and bottom black border
            int colorSize = lineHeight - 3;

            foreach (var legendEntry in _legend)
            {
                ColorView colorBorder = new ColorView(Color.Black);
                colorBorder.Bounds = new Rectangle(leftColor, topText, colorSize + 2, colorSize + 2);
                ColorView legendColor = new ColorView(legendEntry.Value);
                legendColor.Bounds = new Rectangle(1, 1, colorSize, colorSize);
                colorBorder.Children.Add(legendColor);
                legendView.Children.Add(colorBorder);
                TextView legendText = new TextView(legendEntry.Key, _legendStyle, Color.Black, TextLayout.HorizontalAlignLeft);
                legendText.Bounds = new Rectangle(leftText, topText, boxWidth - leftText, lineHeight);
                legendView.Children.Add(legendText);
                topText += lineHeight;
            }
            TextView diskSizeText = new TextView("Estimated Disk Size " + GetPrettySize(_estimatedDiskSize),
                                                 new TextStyle(_legendStyle.Name, _legendStyle.Style, _legendStyle.Weight * 3 / 4),
                                                 Color.Black, TextLayout.HorizontalAlignCenter);

            diskSizeText.Bounds = new Rectangle(0, topText + lineHeight / 4, boxWidth, lineHeight);
            legendView.Children.Add(diskSizeText);
            topText += lineHeight;
        }
        private string AddColor(string msg, ColorView color)
        {
            switch (color)
            {
            case ColorView.Default:
                return($"<color=#FF7EF8>{msg}</color>");

            case ColorView.Green:
                return($"<color=#00FF00>{msg}</color>");

            case ColorView.Red:
                return($"<color=#FF0000>{msg}</color>");
            }

            return(msg);
        }
Example #17
0
 public void ColorChange(ColorView colorView, float r, float g, float b)
 {
     if (colorView == cvHair)
     {
     }
     else if (colorView == cvEye)
     {
     }
     else if (colorView == cvMouth)
     {
     }
     else if (colorView == cvSkin)
     {
     }
     SetCharacterData();
 }
		void ChangeView(int newViewIndex)
		{
			if (newViewIndex >= (int)ColorView.MaxViews)
			{
				newViewIndex = 0;
			}
			else if (newViewIndex < 0)
			{
				newViewIndex = (int)ColorView.MaxViews - 1;
			}

			currentView = (ColorView)newViewIndex;

			currentViewText = string.Format("View: {0}", currentView);

			currentEffect = effects[newViewIndex];
		}
Example #19
0
    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        this.Build();

        colorViewHandler = new ColorView(colorView, DEFAULT_COLOR_CODE);
        colorCodeHandler = new ColorCode(colorCode);
        alphaColorCodeHandler = new AColorCode(aColorCode);
        colorScalesHandler = new ColorScales(redScale, greenScale,
                                             blueScale,
                                             alphaScale);
        clickEventHandler = new ClickEventHandler();

        base.Decorated = false;
        base.Resizable = false;
        base.Title = TITLE;
    }
Example #20
0
    public MainWindow() :
        base(Gtk.WindowType.Toplevel)
    {
        this.Build();

        colorViewHandler      = new ColorView(colorView, DEFAULT_COLOR_CODE);
        colorCodeHandler      = new ColorCode(colorCode);
        alphaColorCodeHandler = new AColorCode(aColorCode);
        colorScalesHandler    = new ColorScales(redScale, greenScale,
                                                blueScale,
                                                alphaScale);
        clickEventHandler = new ClickEventHandler();

        base.Decorated = false;
        base.Resizable = false;
        base.Title     = TITLE;
    }
Example #21
0
            protected async override void Rebind()
            {
                // Protect against Java side being GCed
                if (Handle == IntPtr.Zero)
                {
                    return;
                }

                model = null;
                if (DataSource != null)
                {
                    model = (ProjectModel)DataSource.Data;
                }

                if (model == null)
                {
                    ColorView.SetBackgroundColor(ColorView.Resources.GetColor(Resource.Color.dark_gray_text));
                    ProjectTextView.SetText(Resource.String.ProjectsNoProject);
                    ClientTextView.Visibility = ViewStates.Gone;
                    TasksButton.Visibility    = ViewStates.Gone;
                    return;
                }

                await model.LoadAsync();

                var color = Color.ParseColor(model.GetHexColor());

                ColorView.SetBackgroundColor(color);
                ProjectTextView.SetTextColor(color);
                ClientTextView.SetTextColor(color);

                ProjectTextView.Text = model.Name;
                if (model.Client != null)
                {
                    ClientTextView.Text       = model.Client.Name;
                    ClientTextView.Visibility = ViewStates.Visible;
                }
                else
                {
                    ClientTextView.Visibility = ViewStates.Gone;
                }

                TasksButton.Visibility = DataSource.Tasks.Count == 0 ? ViewStates.Gone : ViewStates.Visible;
                TasksButton.Selected   = false;
            }
Example #22
0
        private void GetSukColors()
        {
            try
            {
                string url     = "https://srv.sukazyo.cc/api/color?version=1";
                string GetJson = HttpUitls.Get(url, "DEFALT");

                JObject             obj    = JObject.Parse(GetJson);
                JArray              jList  = JArray.Parse(obj["colors"].ToString());
                List <colorInfoVer> colors = new List <colorInfoVer>();

                for (int i = 0; i < jList.Count; ++i)
                {
                    JObject colorInfo = JObject.Parse(jList[i].ToString());
                    colors.Add(new colorInfoVer(colorInfo["name"].ToString(), colorInfo["color"].ToString()));
                }

                Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate()
                {
                    foreach (colorInfoVer colorInfo in colors)
                    {
                        ColorView view = new ColorView(colorInfo.name, "#" + colorInfo.color)
                        {
                            Margin = new Thickness(5, 15, 10, 0)
                        };
                        sukColors.Children.Add(view);
                    }

                    sukLoading.Visibility  = Visibility.Collapsed;
                    sukColorsEx.IsExpanded = false;
                });
            }
            catch (Exception e)
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate()
                {
                    sukColorsEx.IsExpanded = true;
                    sukError.Visibility    = Visibility.Visible;
                    sukLoading.Visibility  = Visibility.Collapsed;
                    sukErrorText.Text      = e.Message;
                    Log.AddErr("ColorCard", e.ToString());
                });
            }
        }
Example #23
0
 public void ColorChange(ColorView colorView, float r, float g, float b)
 {
     if (colorView == colorSkin)
     {
         characterBodyCpt.SetSkin(colorSkin.GetColor());
     }
     else if (colorView == colorHair)
     {
         characterBodyCpt.SetHair(colorHair.GetColor());
     }
     else if (colorView == colorEye)
     {
         characterBodyCpt.SetEye(colorEye.GetColor());
     }
     else if (colorView == colorMouth)
     {
         characterBodyCpt.SetMouth(colorMouth.GetColor());
     }
 }
        void ReleaseDesignerOutlets()
        {
            if (ColorView != null)
            {
                ColorView.Dispose();
                ColorView = null;
            }

            if (NameLabel != null)
            {
                NameLabel.Dispose();
                NameLabel = null;
            }

            if (StateLabel != null)
            {
                StateLabel.Dispose();
                StateLabel = null;
            }
        }
Example #25
0
        private void SetupCurrentDisplay(FrameType display)
        {
            switch (display)
            {
            case FrameType.Infrared:
                break;

            case FrameType.Color:
                _rgbv = new ColorView(FrameDisplayImage, _renderer);
                _rgbv.SetProcessingStage(_processingStage);
                AddDisplay(_rgbv);
                break;

            case FrameType.BodyMask:
                break;

            default:
                Log.WriteLog("Display FrameType for Kinect not defined!");
                return;
            }
        }
            protected override void Rebind()
            {
                // Protect against Java side being GCed
                if (Handle == IntPtr.Zero)
                {
                    return;
                }

                ResetTrackedObservables();

                if (model == null)
                {
                    ColorView.SetBackgroundColor(ColorView.Resources.GetColor(Resource.Color.dark_gray_text));
                    ProjectTextView.SetText(Resource.String.ProjectsNoProject);
                    ClientTextView.Visibility   = ViewStates.Gone;
                    TasksFrameLayout.Visibility = ViewStates.Gone;
                    return;
                }

                var color = Color.ParseColor(model.GetHexColor());

                ColorView.SetBackgroundColor(color);
                ProjectTextView.Text = model.Name;
                if (model.Client != null)
                {
                    ClientTextView.Text       = model.Client.Name;
                    ClientTextView.Visibility = ViewStates.Visible;
                }
                else
                {
                    ClientTextView.Visibility = ViewStates.Gone;
                }

                TasksFrameLayout.Visibility = DataSource.Tasks.Count == 0 ? ViewStates.Gone : ViewStates.Visible;
                var expanded = dataView.AreProjectTasksVisible(model.Id);

                TasksTextView.Visibility  = expanded ? ViewStates.Invisible : ViewStates.Visible;
                TasksImageView.Visibility = !expanded ? ViewStates.Invisible : ViewStates.Visible;
            }
Example #27
0
        void ReleaseDesignerOutlets()
        {
            if (blueLabel != null)
            {
                blueLabel.Dispose();
                blueLabel = null;
            }

            if (ColorView != null)
            {
                ColorView.Dispose();
                ColorView = null;
            }

            if (convertButton != null)
            {
                convertButton.Dispose();
                convertButton = null;
            }

            if (greenLabel != null)
            {
                greenLabel.Dispose();
                greenLabel = null;
            }

            if (hexTextField != null)
            {
                hexTextField.Dispose();
                hexTextField = null;
            }

            if (redLabel != null)
            {
                redLabel.Dispose();
                redLabel = null;
            }
        }
		public SegmentControl (UIColor[] colors)
			: base(new RectangleF(0, 0, BUTTON_WIDTH * colors.Length, BUTTON_WIDTH))
		{
			_segmentCount = colors.Length;

			for (int i = 0; i < colors.Length; i++)
			{
				ColorView view = new ColorView(new RectangleF(BUTTON_WIDTH * i, 0, BUTTON_WIDTH, BUTTON_WIDTH))
					{ BackgroundColor = colors[i] };
				
				view.ColorSelected += delegate(UIColor selectedColor) {
					if (ColorSelected != null)
						ColorSelected(selectedColor, currentColor);
					currentColor = selectedColor;
					foreach (ColorView colorView in Subviews)
					{
						colorView.IsSelected = colorView == view;
						colorView.SetNeedsDisplay();
					}
				};
				
				AddSubview(view);
			}
		}
Example #29
0
 public void ShowDebug(string msg, ColorView color)
 {
     debug.Show(msg, color);
 }
Example #30
0
 private void Debug(string msg, ColorView color = ColorView.Default)
 {
     view.ShowDebug(msg, color);
 }
Example #31
0
 public void ClickBack()
 {
     UIViewController.DeactivateUIView("JobView");
     UIViewController.ActivateUIView(ColorView.Load());
 }
Example #32
0
 protected override void Rebind()
 {
     ColorView.SetBackgroundColor(ColorView.Resources.GetColor(Resource.Color.dark_gray_text));
     ProjectTextView.SetText(Resource.String.ProjectsNoProject);
 }
Example #33
0
        protected override void LoadContent()
        {
            string filename = System.Windows.Forms.Application.ExecutablePath;
            string path = System.IO.Path.GetDirectoryName(filename) + "\\Resources\\";

            // setup the render target for picking objects
            PresentationParameters presentation = GraphicsDevice.PresentationParameters;
            colorPickerTarget = new RenderTarget2D(GraphicsDevice, presentation.BackBufferWidth, presentation.BackBufferHeight, false, presentation.BackBufferFormat, presentation.DepthStencilFormat);
            colorPickerData = new Color[presentation.BackBufferWidth * presentation.BackBufferHeight];

            RasterizerState rasterizerState = new RasterizerState();
            rasterizerState.CullMode = CullMode.None;
            rasterizerState.MultiSampleAntiAlias = true;
            XNA.GraphicsDevice.RasterizerState = rasterizerState;
            BlendState bs = BlendState.NonPremultiplied;
            //BlendState bs1 = BlendState.Additive;
            blendState = new BlendState();
            blendState.AlphaBlendFunction = BlendFunction.Add;
            blendState.ColorBlendFunction = BlendFunction.Add;
            blendState.AlphaDestinationBlend = Blend.InverseSourceAlpha;
            blendState.AlphaSourceBlend = Blend.SourceAlpha;
            blendState.ColorDestinationBlend = Blend.InverseSourceAlpha;
            blendState.ColorSourceBlend = Blend.SourceAlpha;
            blendState = BlendState.AlphaBlend;

            // this creates an origin at screen coordinates 0, 0 and makes the Y axis increase as you move down the screen
            Matrix world = Matrix.CreateTranslation(-presentation.BackBufferWidth / 2, -presentation.BackBufferHeight / 2, 0) * Matrix.CreateScale(1, -1, 1);
            Matrix view = Matrix.CreateLookAt(new Vector3(0, 0, 30), new Vector3(0, 0, 0), new Vector3(0, 1, 0));
            //projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45), 800f / 480f, 0.01f, 100f);//graphics.GraphicsDevice.DrawPrimitives(PrimitiveType.LineList, 0, 1);
            Matrix projection = Matrix.CreateOrthographic(Program.WindowSize.Width, Program.WindowSize.Height, 0.01f, 100.0f);

            // initialize the global effect with the world, view, and projection matricies and several drawing flags
            XNA.Effect.World = world;
            XNA.Effect.View = view;
            XNA.Effect.Projection = projection;
            XNA.VertexColor = true;
            XNA.Texturing = false;
            XNA.ApplyEffect();

            // this creates two lines that form a crosshair to show where the user is touching. this crosshair should be scaled to the size of the touchpoint
            touchCrosshair = new VertexPositionColorTexture[4];
            touchCrosshair[0] = new VertexPositionColorTexture(new Vector3(-2, 0, 0), Color.Red, Vector2.Zero);
            touchCrosshair[1] = new VertexPositionColorTexture(new Vector3(2, 0, 0), Color.Green, Vector2.Zero);
            touchCrosshair[2] = new VertexPositionColorTexture(new Vector3(0, -2, 0), Color.Blue, Vector2.Zero);
            touchCrosshair[3] = new VertexPositionColorTexture(new Vector3(0, 2, 0), Color.Yellow, Vector2.Zero);

            // initialize the graphics device for all selectable objects
            SelectableObject.SetGraphicsDevice(GraphicsDevice);
            // initialize the graphics device for SelectableText elements
            SelectableText.Initialize();
            // and load our fonts
            spriteFont = Content.Load<SpriteFont>("Arial");
            XNA.Font = spriteFont;

            globalTextColor = new Color(0.7f, 0.7f, 0.7f, 1);

            // create the selectable object manager which will issue colors to all objects that need hit testing
            selectableObjects = new SelectableObjectManager();

            // load the book library
            //library = new ArtifactLibrary("small_sample.xml");
            library = new ArtifactLibrary("large_sample_sorted_colors.xml");
            Console.WriteLine("loaded library");

            // create the visualization objects
            // we are using the screen width for the x and y calculation, so the max y value is 9/16 (0.5625f)
            float viewPadding = 0.025f;

            float languageSize = 0.04f;
            float languageLeft = 0.002f;
            float languageTop = 0.002f;

            float materialSize = 0.3f;
            float materialLeft = viewPadding;
            float materialTop = viewPadding;

            float colorSize = materialSize;
            float colorLeft = materialLeft + materialSize + viewPadding;
            float colorTop = viewPadding;

            float keywordSize = materialSize;
            float keywordLeft = colorLeft + materialSize + viewPadding;
            float keywordTop = viewPadding;
            float infoSize = materialSize;
            float infoLeft = viewPadding;
            float infoTop = materialTop + materialSize + viewPadding;
            float timelineSize = 0.6f; // timeline is only 0.3 * size in height (e.g. 0.15)
            float timelineLeft = infoLeft + infoSize + viewPadding;
            float timelineTop = keywordTop + keywordSize + viewPadding;

            float detailsWidth = 0.3f;
            float detailsHeight = 0.2f;
            float detailsLeft = viewPadding;
            float detailsTop = keywordTop + keywordSize + viewPadding;

            //float timelineTop = 1 - timelineSize * 0.3f - viewPadding;
            languageView = new LanguageView(this, new Vector3(languageLeft * presentation.BackBufferWidth, languageTop * presentation.BackBufferWidth, 0), new Vector3(languageSize * presentation.BackBufferWidth, languageSize * presentation.BackBufferWidth, 1));
            materialView = new MaterialsView(this, new Vector3(materialLeft * presentation.BackBufferWidth, materialTop * presentation.BackBufferWidth, 0), new Vector3(materialSize * presentation.BackBufferWidth, materialSize * presentation.BackBufferWidth, 1));
            colorView = new ColorView(this, new Vector3(colorLeft * presentation.BackBufferWidth, colorTop * presentation.BackBufferWidth, 0), new Vector3(colorSize * presentation.BackBufferWidth, colorSize * presentation.BackBufferWidth, 1));
            keywordView = new KeywordView(this, new Vector3(keywordLeft * presentation.BackBufferWidth, keywordTop * presentation.BackBufferWidth, 0), new Vector3(keywordSize * presentation.BackBufferWidth, keywordSize * presentation.BackBufferWidth, 1));
            timelineView = new TimelineView(this, new Vector3(timelineLeft * presentation.BackBufferWidth, timelineTop * presentation.BackBufferWidth, 0), new Vector3(timelineSize * presentation.BackBufferWidth, timelineSize * presentation.BackBufferWidth, 1));
            detailsView = new DetailsView(this, new Vector3(detailsLeft * presentation.BackBufferWidth, detailsTop * presentation.BackBufferWidth, 0), new Vector3(detailsWidth * presentation.BackBufferWidth, detailsHeight * presentation.BackBufferWidth, 1));
            //timelineView = new TimelineView(this, new Vector3(400, 400, 0), new Vector3(1500, 1500, 1));

            // select a random artifact
            int numArtifacts = library.Artifacts.Count;
            int artifactIndex = random.Next(numArtifacts);
            artifactIndex = 0;
            library.SelectArtifact(library.Artifacts[artifactIndex]);

            FileStream file = new FileStream("texture\\material\\metal_2.jpg", FileMode.Open);
            Texture2D texture = Texture2D.FromStream(GraphicsDevice, file);
            file.Close();
            blobTest1 = new SelectableBlob(new Vector2(100, 1000), new Vector2(300, 1200), -10, 20, 10, Color.LightGray, Color.LightGray, Color.White, ref blob1Angle);
            //blobTest2 = new SelectableBlob(new Vector2(1000, 500), 80, Color.White, texture);
            blobTest2 = new SelectableBlob(new Vector2(1000, 500), 0*(float)Math.PI / 4, 0, 0, 10, Color.Red, Color.Blue, Color.Green, texture);
            blobTest2.CircleRadius = 40;
            blobTest2.MiddleRadius = 0;
            timer = new Timer(1);
            selectableObjects.AddObject(blobTest2);

            Color c1 = Color.Navy;
            //c1.A = 127;
            Color c2 = new Color(0.0f, 1.0f, 0.0f, 1.0f);
            //c2.A = 127;
            rectTest1 = new SelectableQuad(new Vector3(100, 100, -10), new Vector3(400, 100, -10), new Vector3(400, 800, -10), new Vector3(100, 800, -10), c1);
            rectTest2 = new SelectableQuad(new Vector3(200, 200, 0), new Vector3(600, 200, 0), new Vector3(600, 600, 0), new Vector3(200, 600, 0), c2);
            rectTest2.Points[0].Color = Color.Transparent;
            rectTest2.Points[3].Color.A = 0;
            /* test the Selectable objects
            lineTest = new SelectableLine(new Vector3(50, 50, 0), new Vector3(2000, 1000, 0), Color.Red, 20);
            rectTest1 = new SelectableQuad(new Vector3(100, 100, 0), new Vector3(400, 100, 0), new Vector3(400, 800, 0), new Vector3(100, 800, 0), Color.Navy);
            rectTest2 = new SelectableQuad(new Vector3(700, 100, 0), new Vector3(1000, 100, 0), new Vector3(1000, 800, 0), new Vector3(700, 800, 0), Color.Green);
            textTest = new SelectableText(kootenayFont, "Kootenay", new Vector3(980, 780, 0), Color.Red, Color.Orange);

            //textTest.SetQuadColor(new Color(1, 0.7f, 0, 0.1f));
            //textTest.Rotation = 1;
            //textTest.Recompute();

            selectableObjects.AddObject(lineTest);
            selectableObjects.AddObject(rectTest1);
            selectableObjects.AddObject(rectTest2);
            selectableObjects.AddObject(textTest);
            //*/

            /* this is to test rendering triangles and lines with user defined primary objects
            verts = new VertexPositionColor[5];
            verts[0] = new VertexPositionColor(new Vector3(0, 0, 0), Color.Red);
            verts[1] = new VertexPositionColor(new Vector3(2000, 0, 0), Color.Green);
            verts[2] = new VertexPositionColor(new Vector3(1000, 2000, 0), Color.Blue);

            verts[3] = new VertexPositionColor(new Vector3(0, 0, 0), Color.Yellow);
            verts[4] = new VertexPositionColor(new Vector3(500, 100, 0), Color.Yellow);

            // this is to test loading of the screen with a grid of many many vertical and horizontal lines
            int pixelsPerLine = 2;
            hLines = new VertexPositionColor[2 * GraphicsDevice.DisplayMode.Width / pixelsPerLine];
            vLines = new VertexPositionColor[2 * GraphicsDevice.DisplayMode.Height / pixelsPerLine];
            for (int i = 0; i < 2 * GraphicsDevice.DisplayMode.Width / pixelsPerLine; i += 2)
            {
                hLines[i] = new VertexPositionColor(new Vector3(i * pixelsPerLine / 2, 0, 0), Color.White);
                hLines[i + 1] = new VertexPositionColor(new Vector3(i * pixelsPerLine / 2, GraphicsDevice.DisplayMode.Height, 0), Color.Gray);
            }
            for (int i = 0; i < 2 * GraphicsDevice.DisplayMode.Height / pixelsPerLine; i += 2)
            {
                vLines[i] = new VertexPositionColor(new Vector3(0, i * pixelsPerLine / 2, 0), Color.White);
                vLines[i + 1] = new VertexPositionColor(new Vector3(GraphicsDevice.DisplayMode.Width, i * pixelsPerLine / 2, 0), Color.Gray);
            }
            //*/

            // test drawing text to the screen, including a background color behind the text (eventually for hit testing)
            //spriteBatch = new SpriteBatch(graphics.GraphicsDevice);
            //Vector2 textSize = spriteFont.MeasureString("Testing");
            //spriteTexture = new Texture2D(GraphicsDevice, (int)textSize.X, (int)textSize.Y);
            //Color[] textureColor = new Color[(int)textSize.X * (int)textSize.Y];
            //for (int i = 0; i < textureColor.Length; i++)
            //{
            //    textureColor[i] = Color.Salmon;
            //    textureColor[i].A = 200;
            //}
            //spriteTexture.SetData<Color>(textureColor);

            // test the backbuffer renderer
            /*
            GraphicsDevice.SetRenderTarget(colorPickerTarget);
            Draw(new GameTime());
            GraphicsDevice.SetRenderTarget(null);
            FileStream pngFile = new FileStream("pickerTarget.png", FileMode.Create);
            colorPickerTarget.SaveAsPng(pngFile, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            //*/
        }