예제 #1
0
        private async Task EditImage()
        {
            try
            {
                var path       = GetSpriteInfo().Source;
                var stringPath = path?.ToString().Replace('/', '\\') ?? "";
                if (!File.Exists(stringPath))
                {
                    await ServiceProvider.Get <IDialogService>().MessageBox(Tr._p("Message", "Couldn't find the file"), MessageBoxButton.OK, MessageBoxImage.Information);

                    return;
                }

                var process = new Process {
                    StartInfo = new ProcessStartInfo(stringPath)
                    {
                        UseShellExecute = true
                    }
                };
                process.StartInfo.Verb = process.StartInfo.Verbs.FirstOrDefault(x => x.ToLowerInvariant() == "edit");
                process.Start();
            }
            catch (Exception ex)
            {
                var message = string.Format(Tr._p("Message", "There was a problem while editing the image.{0}"), ex.FormatSummary(true));
                await ServiceProvider.Get <IDialogService>().MessageBox(message, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
예제 #2
0
        public void Empty_collections()
        {
            Tr.SetTypes(typeof(RowDefinitionCollection), typeof(ColumnDefinitionCollection));

            var grid = new Grid
            {
                ColumnDefinitions = new ColumnDefinitionCollection(),
                RowDefinitions    = new RowDefinitionCollection()
            };

            var page = new ContentPage
            {
                Content = grid
            };

            var ctx = new XenMessageContext();

            ctx.SetRequest <GetWidgetPropertiesRequest>(r =>
            {
                r.WidgetId = grid.Id.ToString();
            });

            XamarinFormsReaction.Register <GetWidgetPropertiesRequest, GetWidgetPropertiesReaction <VisualElement> >(page);
            Reaction.Execute(ctx);

            var response = ctx.Get <GetWidgetPropertiesResponse>();

            foreach (var p in response.Properties)
            {
                var pv = p.XenType.PossibleValues;
                CollectionAssert.IsNotEmpty(pv);
                Assert.AreEqual("0", pv[0]);
            }
        }
예제 #3
0
        private async Task ResetAllLayouts()
        {
            var assets = assetEditorsManager.OpenedAssets.Select(x => x.Id).ToList();

            if (assets.Count > 0)
            {
                var message = Tr._p("Message", "To reset the layout, Game Studio needs to close and re-open all asset and document editors. You won't lose unsaved changes.");
                var buttons = DialogHelper.CreateButtons(new[] { "Reset layout", "Cancel" }, 1, 2);
                var result  = await Editor.ServiceProvider.Get <IEditorDialogService>().MessageBox(message, buttons);

                if (result != 1)
                {
                    return;
                }
            }

            // Close all editors
            assetEditorsManager.CloseAllEditorWindows(null);

            // Check if user cancelled closing some of the editors.
            if (assetEditorsManager.OpenedAssets.Any())
            {
                return;
            }

            // Safely reset layout
            dockingLayout.ResetAllLayouts();

            // Reopen editors
            await ReopenAssetEditors(assets);
        }
예제 #4
0
        private async Task Explore()
        {
            try
            {
                var path       = GetSpriteInfo().Source;
                var stringPath = path?.ToString().Replace('/', '\\') ?? "";
                if (!File.Exists(stringPath))
                {
                    await ServiceProvider.Get <IDialogService>().MessageBox(Tr._p("Message", "Couldn't find the file"), MessageBoxButton.OK, MessageBoxImage.Information);

                    return;
                }

                var startInfo = new ProcessStartInfo("explorer.exe", "/select," + stringPath)
                {
                    UseShellExecute = true
                };
                var explorer = new Process {
                    StartInfo = startInfo
                };
                explorer.Start();
            }
            catch (Exception ex)
            {
                var message = string.Format(Tr._p("Message", "There was a problem opening Explorer.{0}"), ex.FormatSummary(true));
                await ServiceProvider.Get <IDialogService>().MessageBox(message, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        public void Should_return_properties_for_ContentPage()
        {
            Tr.SetTypes(typeof(String));

            var page = new ContentPage
            {
                Title   = "Important",
                Content = new Label {
                    Text = "Does Nothing"
                }
            };

            var ctx = new XenMessageContext();

            ctx.SetRequest <GetWidgetPropertiesRequest>(r =>
            {
                r.WidgetId = page.Id.ToString();
            });

            XamarinFormsReaction.Register <GetWidgetPropertiesRequest, GetWidgetPropertiesReaction <VisualElement> >(page);
            Reaction.Execute(ctx);

            var response = ctx.Get <GetWidgetPropertiesResponse>();
            var property = response?.Properties.FirstOrDefault(p => p.PropertyName.Equals("Title"));

            Assert.IsNotNull(property, "Title property should have been found.");
            Assert.AreEqual(property.XenType.FullName, typeof(String).FullName);
            Assert.IsNotNull(property.Value, "Value should have been set.");
        }
예제 #6
0
        public async Task <bool> StartDebug(EditorViewModel editor, ProjectViewModel currentProject, LoggerResult logger)
        {
            if (currentProject == null)
            {
                await editor.Session.Dialogs.MessageBox(Tr._p("Message", "An executable project must be set as current project in the session explorer in order to process build."),
                                                        MessageBoxButton.OK, MessageBoxImage.Information);

                return(false);
            }

            try
            {
                var projectWatcher = new ProjectWatcher(currentProject.Session, false);
                await projectWatcher.Initialize();

                var executableOutputPath = Path.GetDirectoryName(projectWatcher.CurrentGameExecutable.OutputFilePath);

                var debuggerProcess = await GetDebuggerProcess(editor);

                var projectCouldFirstCompile = new TaskCompletionSource <bool>();
                Task.Run(() => StartDebugHost(executableOutputPath, projectWatcher, projectCouldFirstCompile, RecompilationDelay, debuggerProcess, logger)).Forget();

                return(await projectCouldFirstCompile.Task);
            }
            catch
            {
                return(false);
            }
        }
예제 #7
0
        void SetupPage()
        {
            StackLayout.Children.Clear();

            AddTitleRow("Title");

            if (!ServiceNodeManager.Current.HadUnlockedServiceNode)
            {
                AddInfoRow("Auth", Tr.Get("App.FullName"));

                ServiceNodesPage.AddAuthorizeSection(ServiceNodeManager.Current.NewDefaultServiceNode, this, false);
            }
            else
            {
                if (UIAppSettings.AppReady)
                {
                    IsBusy = true;
                    if (ServiceNodeManager.Current.Ready)
                    {
                        UpdateChats();
                    }
                }
                else
                {
                    ShowInfo();
                }
            }

            UpdateSuspendedLayout();
        }
예제 #8
0
        public static async Task TaskAction(ExtContentPage page, TodoTask todoTask, TodoList todoList)
        {
            var submitAccount = TodoApp.Current.GetLastUsedSubmitAccount <SubmitAccount>(todoList.ListId.ToString());

            if (submitAccount == null || !todoList.IsLastUsedSecretKey(submitAccount) || todoTask.Status != TodoTaskStatusTypes.Open)
            {
                await page.Navigation.PushAsync(new TodoTaskPage(todoList, todoTask));
            }
            else
            {
                var editItem = Tr.Get("TodoListView.EditItem");
                var markDone = Tr.Get("TodoListView.MarkDone");

                var result = await page.DisplayActionSheet(Tr.Get("TodoListView.ItemTitle"), Tr.Get("Common.Cancel"), null, markDone, editItem);

                if (result == markDone)
                {
                    if (await page.ConfirmTextAsync(Tr.Get("TodoListView.ConfirmStatus")))
                    {
                        page.IsBusy = true;
                        UIApp.Run(() => TodoApp.Current.UpdateTodoItemStatus(submitAccount, TodoTaskStatusTypes.Closed, todoList, todoTask));
                    }
                }
                else if (result == editItem)
                {
                    await page.Navigation.PushAsync(new TodoTaskPage(todoList, todoTask));
                }
            }
        }
예제 #9
0
        public void Update(VerifyFileJson verifyItem)
        {
            if (verifyItem == null)
            {
                Reset();
                return;
            }

            _filename.Text = verifyItem.name;
            _hash.Text     = verifyItem.hash;
            _hashtype.Text = Tr.Get($"HashTypes.{verifyItem.hashtype}");
            _size.Text     = Tr.Get("VerifyFileView.SizeInfo", verifyItem.length);

            if (_link != null)
            {
                if (string.IsNullOrEmpty(verifyItem.link))
                {
                    _link.Text = "-";
                }
                else
                {
                    _link.Text = verifyItem.link;
                }
            }
        }
예제 #10
0
 static ThemesSettings()
 {
     ThemeName = new SettingsKey <ThemeType>("Themes/ThemeName", EditorSettings.SettingsContainer, ThemeType.ExpressionDark)
     {
         DisplayName = $"{Themes}/{Tr._p("Settings", "Theme Name")}"
     };
 }
예제 #11
0
        /// <summary>
        /// Metodo utilizado para excluir um cliente na base de dados e seu respectivo endereco
        /// </summary>
        /// <param name="Id">Int Id (Código da entidade Cliente)</param>
        public void Delete(int Id)
        {
            try
            {
                OpenConnection();

                Tr = Con.BeginTransaction();

                string queryEndereco = "delete from Endereco where IdCliente = @Id";

                Cmd = new SqlCommand(queryEndereco, Con, Tr);
                Cmd.Parameters.AddWithValue("@Id", Id);
                Cmd.ExecuteNonQuery();

                string queryCliente = "delete from Cliente where IdCliente = @Id";

                Cmd = new SqlCommand(queryCliente, Con, Tr);
                Cmd.Parameters.AddWithValue("@Id", Id);
                Cmd.ExecuteNonQuery();

                Tr.Commit();
            }
            catch (Exception ex)
            {
                throw new Exception("Erro ao excluir cliente. \n" + ex.Message);
            }
            finally
            {
                CloseConnection();
            }
        }
예제 #12
0
        protected virtual void Update()
        {
            (var text, var link) = GetMessage();
            _link = link;

            text = text ?? Tr.Get("Common.MessageMissing");

            var message = new Span
            {
                Text = text
            };

            message.SetStyle(Theme.TextFont, Theme.TextColor);

            var formattedString = new FormattedString
            {
                Spans =
                {
                    message
                }
            };

            if (HasAllAttachements)
            {
                var date = new Span
                {
                    Text = (_link != null) ? $"\n {Time.DateTimeString(Transaction.Transaction.Timestamp)}, {_link}" : $"\n {Time.DateTimeString(Transaction.Transaction.Timestamp)}"
                };
                date.SetStyle(Theme.DetailFont, Theme.TextColor);

                formattedString.Spans.Add(date);
            }

            TextLabel.FormattedText = formattedString;
        }
예제 #13
0
파일: Runtime.cs 프로젝트: MarkoBL/Rosi
        Assembly AssemblyResolve(object sender, ResolveEventArgs args)
        {
            if (Config.AssemblyResolveInfo)
            {
                Log.Warn(Tr.Get("Runtime.AssemblyResolve", args.Name, args.RequestingAssembly));
            }

            try
            {
                var assemblyName = args.Name.Split(',')[0];
                foreach (var di in _assemblyDirectories)
                {
                    var assemblyPath = $"{di.FullName}/{assemblyName}.dll";
                    if (File.Exists(assemblyPath))
                    {
                        return(Assembly.LoadFrom(assemblyPath));
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(Tr.Get("Runtime.AssemblyResolveException", args.Name, args.RequestingAssembly, ex.Message));
                return(null);
            }

            Log.Error(Tr.Get("Runtime.AssemblyResolveFailed", args.Name, args.RequestingAssembly));
            return(null);
        }
예제 #14
0
        void SetupPage()
        {
            _more     = null;
            _listView = null;

            StackLayout.Children.Clear();

            var title = AddTitleRow("Title");

            if (!ServiceNodeManager.Current.HadUnlockedServiceNode)
            {
                AddInfoRow("Info", Tr.Get("App.FullName"));
                AddSubmitRow("Add", Add);
            }
            else
            {
                if (!UIAppSettings.AppReady)
                {
                    AddInfoRow("Info", Tr.Get("App.FullName"));
                    AddSubmitRow("Add", Add);
                }

                _listView = new NoteListView(this, title);

                ToolbarItems.Add(new ExtToolbarItem(Tr.Get("Common.Refresh"), null, async() =>
                {
                    IsBusy = true;
                    await NoteApp.Current.DownloadNoteData(false);
                }));

                AddFooterRow();

                IsBusy = true;
            }
        }
예제 #15
0
        public ReportEmail()
        {
            HtmlBody = new Body().Add <Class>("Body");

            var oTbl = new Table().Add <Class>("Header");

            HtmlBody.Append(oTbl);

            var oImgLogo = new Img()
                           .Add <Class>("Logo")
                           .Add <Src>("http://www.ezbob.com/app/themes/ezbob/images/header/ezbob_logo.png");

            var oLogoLink = new A()
                            .Add <Href>("http://www.ezbob.com/")
                            .Add <Class>("logo_ezbob")
                            .Add <Class>("indent_text")
                            .Add <ID>("ezbob_logo")
                            .Add <Title>("Fast business loans for Ebay and Amazon merchants")
                            .Add <Alt>("Fast business loans for Ebay and Amazon merchants")
                            .Append(oImgLogo);

            var oTr = new Tr();

            oTbl.Append(oTr);

            oTr.Append(new Td().Append(oLogoLink));

            Title = new H1();

            oTr.Append(new Td().Append(Title));

            ReportBody = new P().Add <Class>("Body");

            HtmlBody.Append(ReportBody);
        }         // constructor
예제 #16
0
        private void OnDestroy()
        {
            _dPong.Save.WriteCaches();
            _dPong.Dispose();

            Tr.UnloadLocale();
        }
예제 #17
0
        private static bool CheckOptions([NotNull] Options options, [NotNull] out StringBuilder message)
        {
            message = new StringBuilder();
            try
            {
                if (options.InputFiles.Count == 0)
                {
                    // Add all supported formats
                    options.InputFiles.Add("*.cs");
                    options.InputFiles.Add("*.xaml");
                }
                if (options.InputDirs.Count == 0)
                {
                    options.InputDirs.Add(Environment.CurrentDirectory);
                }

                foreach (var dir in options.InputDirs)
                {
                    if (!Directory.Exists(dir))
                    {
                        message.AppendLine(string.Format(Tr._("Input directory '{0}' not found"), dir));
                        return(false);
                    }
                }
            }
            catch (Exception e)
            {
                message.Append(e.Message);
                return(false);
            }

            return(true);
        }
예제 #18
0
        private async void ButtonOk(object sender, RoutedEventArgs e)
        {
            if (!SelectedPlatforms.Any())
            {
                await services.Get <IDialogService>().MessageBox(Tr._p("Message", "You must select at least one platform."), MessageBoxButton.OK, MessageBoxImage.Information);

                return;
            }

            if (AvailablePlatforms.Any(x => x.MarkedToRemove))
            {
                var buttons = DialogHelper.CreateButtons(new[]
                {
                    Tr._p("Button", "Remove"),
                    Tr._p("Button", "Cancel")
                }, 1, 2);
                var msg    = string.Format(Tr._p("Message", "Are you sure you want to remove these {0} platform(s) from the package?"), AvailablePlatforms.Count(x => x.MarkedToRemove));
                var result = await services.Get <IDialogService>().MessageBox(msg, buttons, MessageBoxImage.Question);

                if (result != 1)
                {
                    return;
                }

                Result = Stride.Core.Presentation.Services.DialogResult.Ok;
                Close();
                return;
            }

            Result = Stride.Core.Presentation.Services.DialogResult.Ok;
            Close();
        }
예제 #19
0
        public void Should_not_repeat_attached_properties_when_theyre_nested()
        {
            Dr.Add(typeof(ValueType), new StaticGenerator());
            Dr.Add(typeof(Enum), new EnumGenerator());
            Tr.SetTypes(typeof(BindableProperty));

            var label  = new Label();
            var first  = new Grid();
            var second = new Grid();
            var id     = label.Id.ToString();

            first.Children.Add(second);
            second.Children.Add(label);
            Grid.SetRow(label, 5);

            var page = new ContentPage
            {
                Content = first
            };

            var ctx = new XenMessageContext();

            ctx.SetRequest <GetAttachedPropertiesRequest>(req =>
            {
                req.WidgetId = id;
            });

            XamarinFormsReaction.Register <GetAttachedPropertiesRequest, GetAttachedPropertiesReaction>(page);
            Reaction.Execute(ctx);

            var res = ctx.Get <GetAttachedPropertiesResponse>();
            var row = res.Widget.AttachedProperties.First(f => f.XamlPropertyName == "Grid.Row");

            Assert.AreEqual(5, row.Value);
        }
예제 #20
0
        public void Should_return_parents_attached_properties()
        {
            Dr.Add(typeof(ValueType), new StaticGenerator());
            Dr.Add(typeof(Enum), new EnumGenerator());
            Tr.SetTypes(typeof(BindableProperty));

            var label1 = new Label();
            var label2 = new Label();
            var grid   = new Grid();

            grid.ColumnDefinitions = new ColumnDefinitionCollection
            {
                new ColumnDefinition {
                    Width = new GridLength(10, GridUnitType.Absolute)
                },
                new ColumnDefinition {
                    Width = new GridLength(20, GridUnitType.Absolute)
                },
            };

            grid.RowDefinitions = new RowDefinitionCollection
            {
                new RowDefinition {
                    Height = new GridLength(30, GridUnitType.Absolute)
                },
                new RowDefinition {
                    Height = new GridLength(40, GridUnitType.Absolute)
                },
            };

            grid.Children.Add(label1);
            grid.Children.Add(label2);

            Grid.SetRow(label1, 5);
            Grid.SetColumn(label1, 6);

            var page = new ContentPage
            {
                Content = grid
            };

            var id  = label1.Id.ToString();
            var ctx = new XenMessageContext();

            ctx.SetRequest <GetAttachedPropertiesRequest>(req =>
            {
                req.WidgetId = id;
            });

            XamarinFormsReaction.Register <GetAttachedPropertiesRequest, GetAttachedPropertiesReaction>(page);
            Reaction.Execute(ctx);

            var res = ctx.Get <GetAttachedPropertiesResponse>();
            var ap1 = res.Widget.AttachedProperties.First(p => p.Path[0] == "RowProperty");
            var ap2 = res.Widget.AttachedProperties.First(p => p.Path[0] == "ColumnProperty");

            Assert.AreEqual(4, res.Widget.AttachedProperties.Count);
            Assert.AreEqual(5, ap1.Value);
            Assert.AreEqual(6, ap2.Value);
        }
예제 #21
0
        public async Task OpenFile(string filePath, bool tryEdit)
        {
            try
            {
                filePath = filePath.Replace('/', '\\');
                if (!File.Exists(filePath))
                {
                    await ServiceProvider.Get <IDialogService>().MessageBox(Tr._p("Message", "You need to save the file before you can open it."), MessageBoxButton.OK, MessageBoxImage.Information);

                    return;
                }

                var process = new Process {
                    StartInfo = new ProcessStartInfo(filePath)
                    {
                        UseShellExecute = true
                    }
                };
                if (tryEdit)
                {
                    process.StartInfo.Verb = process.StartInfo.Verbs.FirstOrDefault(x => x.ToLowerInvariant() == "edit");
                }
                process.Start();
            }
            catch (Exception ex)
            {
                var message = $"{Tr._p("Message", "An error occurred while opening the file.")}{ex.FormatSummary(true)}";
                await ServiceProvider.Get <IDialogService>().MessageBox(message, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
예제 #22
0
        private async void ButtonOk(object sender, RoutedEventArgs e)
        {
            if (Orientation == DisplayOrientation.Default)
            {
                await services.Get <IDialogService>().MessageBox(Tr._p("Message", "Select an orientation."), MessageBoxButton.OK, MessageBoxImage.Information);

                return;
            }
            if (!SelectedPlatforms.Any())
            {
                await services.Get <IDialogService>().MessageBox(Tr._p("Message", "Select at least one platform."), MessageBoxButton.OK, MessageBoxImage.Information);

                return;
            }

            string error;

            if (!NamingHelper.IsValidNamespace(Namespace, out error))
            {
                await services.Get <IDialogService>().MessageBox(string.Format(Tr._p("Message", "Type a valid namespace name. Error with {0}"), error), MessageBoxButton.OK, MessageBoxImage.Information);

                return;
            }

            Result = Stride.Core.Presentation.Services.DialogResult.Ok;
            Close();
        }
예제 #23
0
        void SetupPage()
        {
            StackLayout.Children.Clear();

            AddTitleRow("Title");

            var profileData = ProfileManager.Current.GetCachedProfileData(WalletApp.CurrentAccountId);

            ProfilePageSections.AddProfileSections(this, profileData, "Profile");

            AddHeaderRow("Profiles");

            if (WalletApp.IsCoreAccountUnlocked)
            {
                if (UIAppSettings.JoinedProfile)
                {
                    AddButtonRow("Edit", EditProfile);
                }
                else
                {
                    AddTextRow("JoinInfo").Label.ColorStyle = Theme.InfoColor;
                    AddLinkRow("Common.LearnMore", Tr.Get("Link.Profile"));
                    AddSubmitRow("Join", Join, false);
                }
            }
            else
            {
                AddTextRow("Common.Unlock").Label.ColorStyle = Theme.InfoColor;
            }

            AddButtonRow("ViewProfile", ViewProfile);
            AddFooterRow();

            UpdateSuspendedLayout();
        }
예제 #24
0
        private void btnExit_Click(object sender, EventArgs e)
        {
            if (!Convert.ToBoolean(this.bView))
            {
                if ((this.dsPR.Tables[0].Rows.Count > 0) || (this.groupPR.Enabled == false))
                {
                    if (NP.MSGB("The PO list will be cancel , Do you agree with this ?") == DialogResult.Yes)
                    {
                        // Cancel
                        oConn = new SqlConnection(NP.ReadFileDB(Application.StartupPath + @"\DB\DB.ini"));
                        if (oConn.State == ConnectionState.Open)
                        {
                            oConn.Close();
                        }
                        oConn.Open(); SqlTransaction Tr;
                        Tr = oConn.BeginTransaction();

                        try
                        {
                            SqlCommand cmd = new SqlCommand();
                            NP_Cls.SqlDel = "DELETE FROM t_PO WHERE (PONumber = @DocNumber)";
                            cmd.Parameters.Add("@DocNumber", SqlDbType.NVarChar, 12).Value = this.txtPR.Text.Trim();
                            cmd.CommandText = NP_Cls.SqlDel; cmd.Connection = oConn; cmd.Transaction = Tr;
                            cmd.ExecuteNonQuery();

                            NP_Cls.SqlDel   = "DELETE FROM t_PODetail WHERE (PONumber = @DocNumber)";
                            cmd.CommandText = NP_Cls.SqlDel; cmd.Connection = oConn; cmd.Transaction = Tr;
                            cmd.ExecuteNonQuery();

                            Tr.Commit();
                        }
                        catch (Exception ex)
                        {
                            NP.MSGB(NP_Cls.NPMgsStyle.ErrorType, "Del : " + ex.Message);
                        }
                        finally
                        {
                            if (oConn.State == ConnectionState.Open)
                            {
                                oConn.Close();
                            }
                        }
                        this.Close(); return;
                    }
                    else
                    {
                        return;
                    }
                }
            }

            if (NP.MSGB("Do you want to exit this screen ?") == DialogResult.Yes)
            {
                this.Close();
            }
            else
            {
                return;
            }
        }
예제 #25
0
        public void Private_setters_should_return_struct_as_readonly()
        {
            Tr.SetTypes(typeof(Rectangle));

            var label = new Label();
            var page  = new ContentPage
            {
                Content = label
            };

            var ctx = new UIMessageContext();

            ctx.SetRequest <GetObjectRequest>(req =>
            {
                req.Path     = new [] { "Bounds" };
                req.WidgetId = label.Id.ToString();
            });

            InspectorReaction.Register <GetObjectRequest, GetObjectReaction>(page);
            Reaction.Execute(ctx);
            var res = ctx.Get <ObjectResponse>();

            var prop = res.Property;

            Assert.AreEqual(prop.PropertyName, "Bounds");

            Assert.IsFalse(prop.CanWrite);
            Assert.IsTrue(prop.UIType.Descriptor.HasFlag(UIPropertyDescriptors.ValueType));
        }
예제 #26
0
        public void Should_return_Guid_as_string()
        {
            Dr.Add(typeof(ValueType), new StaticGenerator());
            Dr.Add(typeof(Enum), new EnumGenerator());
            Tr.SetTypes(typeof(Guid));

            var label = new Label();
            var page  = new ContentPage
            {
                Content = label
            };

            var ctx = new UIMessageContext();

            ctx.SetRequest <GetWidgetPropertiesRequest>(req =>
            {
                req.WidgetId = label.Id.ToString();
            });

            InspectorReaction.Register <GetWidgetPropertiesRequest, GetWidgetPropertiesReaction>(page);
            Reaction.Execute(ctx);

            var res  = ctx.Get <GetWidgetPropertiesResponse>();
            var prop = res.Properties[0];

            Assert.IsFalse(prop.UIType.IsNullable);
            Assert.IsNotNull(prop.Value);
        }
예제 #27
0
        public void Should_return_public_properties_of_Bounds_type()
        {
            Tr.SetTypes(typeof(Rectangle));

            var label = new Label();
            var page  = new ContentPage
            {
                Content = label
            };

            var ctx = new UIMessageContext();

            ctx.SetRequest <GetObjectRequest>(req =>
            {
                req.Path     = new [] { "Bounds" };
                req.WidgetId = label.Id.ToString();
            });

            InspectorReaction.Register <GetObjectRequest, GetObjectReaction>(page);
            Reaction.Execute(ctx);

            var res = ctx.Get <ObjectResponse>();

            var prop = res.Property;

            Assert.AreEqual(prop.PropertyName, "Bounds");

            Assert.IsAssignableFrom <UIProperty[]>(prop.Value);

            var boundProps = (UIProperty[])prop.Value;
            var xProp      = boundProps.FirstOrDefault(b => b.PropertyName == "X");

            Assert.IsNotNull(xProp);
            Assert.AreEqual(xProp.UIType.FullName, typeof(double).FullName);
        }
예제 #28
0
        public void Should_return_LayoutOption_property_and_possible_values()
        {
            Tr.SetTypes(typeof(LayoutOptions));
            Dr.Add(typeof(ValueType), new StaticGenerator());
            Dr.Add(typeof(Enum), new EnumGenerator());

            var label = new Label();
            var page  = new ContentPage {
                Content = label
            };

            var ctx = new UIMessageContext();

            ctx.SetRequest <GetObjectRequest>(req =>
            {
                req.Path     = new [] { "HorizontalOptions" };
                req.WidgetId = label.Id.ToString();
            });

            InspectorReaction.Register <GetObjectRequest, GetObjectReaction>(page);
            Reaction.Execute(ctx);

            var res = ctx.Get <ObjectResponse>();
            var p   = res.Property;

            Assert.AreEqual(p.PropertyName, "HorizontalOptions");
            Assert.IsTrue(p.UIType.Descriptor.HasFlag(UIPropertyDescriptors.ValueType | UIPropertyDescriptors.Literals));
            Assert.AreEqual(8, p.UIType.PossibleValues.Length);
            Assert.IsAssignableFrom <UIProperty[]>(p.Value);

            var alignmentProp = (p.Value as UIProperty[])?[0];

            Assert.AreEqual(alignmentProp?.Value, "Fill");
            CollectionAssert.IsNotEmpty(alignmentProp?.UIType.PossibleValues);
        }
예제 #29
0
        public void Color_test()
        {
            Tr.SetTypes(typeof(Color));

            var label = new Label
            {
                BackgroundColor = Color.Red
            };

            var page = new ContentPage
            {
                Content = label
            };

            var ctx = new UIMessageContext();

            ctx.SetRequest <GetWidgetPropertiesRequest>(req =>
            {
                req.WidgetId      = label.Id.ToString();
                req.IncludeValues = true;
            });

            InspectorReaction.Register <GetWidgetPropertiesRequest, GetWidgetPropertiesReaction>(page);
            Reaction.Execute(ctx);

            var res = ctx.Get <GetWidgetPropertiesResponse>();
            var p   = res.Properties.First(f => f.PropertyName == "BackgroundColor");
        }
예제 #30
0
        private bool CanUpdateName([CanBeNull] string newName)
        {
            // empty names are not allowed
            if (string.IsNullOrWhiteSpace(newName))
            {
                return(false);
            }

            // folder separator is not allowed
            if (newName.Contains(FolderSeparator))
            {
                return(false);
            }

            // check for name collision
            if (Parent == null)
            {
                throw new InvalidOperationException($"{nameof(Parent)} cannot be null");
            }
            var canRename = Parent.Folders.All(x => x == this || !string.Equals(x.Name, newName, FolderCase));

            if (!canRename)
            {
                ServiceProvider.Get <IDialogService>()
                .BlockingMessageBox(string.Format(Tr._p("Message", "Unable to rename the folder '{0}' to '{1}'. A folder with the same name already exists."), name, newName), MessageBoxButton.OK,
                                    MessageBoxImage.Information);
            }
            return(canRename);
        }
예제 #31
0
 private void MkTbBody(List<List<Info>> infos)
 {
     for (int i = 1; i <= infos.Count; ++i)
     {
         Tr tr = new Tr(infos[i - 1], i);
         tr.ID = "row" + i;
         TableBody.Controls.Add(tr);
     }
 }
    public void Start2()
    {

        if (mf == null)
            mf = GetComponent<MeshFilter>();
        elements.Clear();
        //mf.gameObject.AddComponent<MeshCollider>();
        //mf.gameObject.layer = Layer.car;
        lab = new Dictionary<int, List<Tr>>();
        //triangles = mf.mesh.triangles.ToList();
        vertices = mf.mesh.vertices;
        oldVertices = (Vector3[])vertices.Clone();
        normals = mf.mesh.normals;
        tangents = mf.mesh.tangents;
        uvs = mf.mesh.uv;
        //crs = new Color32[mf.mesh.colors32.Length];
        for (int x = 0; x < mf.mesh.subMeshCount; x++)
        {
            var trs = mf.mesh.GetIndices(x);
            for (int i = 0; i < trs.Length; i += 3)
            {
                var tr = new Tr() { ind = new[] { trs[i], trs[i + 1], trs[i + 2] }, pointers = new[] { i, i + 1, i + 2 }, group = x };
                flat.Add(tr);
                for (int j = 0; j < 3; j++)
                {
                    List<Tr> lt;
                    if (!lab.TryGetValue(trs[i + j], out lt))
                        lab[trs[i + j]] = lt = new List<Tr>();

                    lt.Add(tr);
                }
            }
        }


        foreach (Tr t in flat)
        {
            if (!t.went)
            {
                Element element = new Element();
                element.MeshTest = this;
                elements.Add(element);
                var color32 = new Color32((byte)(Random.value * 255), (byte)(Random.value * 255), (byte)(Random.value * 255), 255);
                Go(t, color32, element);
            }

        }
        //mf.mesh.colors32 = crs;
    }
예제 #33
0
        internal static object tr_trans(object str, Frame caller, Proc block, object src, object repl, bool sflag)
        {

            Tr trSrc, trRepl;
            bool cflag = false;
            int[] trans = new int[256];
            int i, c;
            bool modify = false;
            int s, send;
            System.Text.StringBuilder t = new System.Text.StringBuilder();

            string sString = StringValue(str, caller);
            string srcString = StringValue(src, caller);
            string replString = StringValue(repl, caller);

            if (((String)str).value == null || ((String)str).value.Length == 0)
            {
                return null;
            }
            trSrc = new Tr(srcString);
            if (srcString.Length >= 2 && srcString[0] == '^')
            {
                cflag = true;
                trSrc.MoveNext();
            }
            if (replString.Length == 0)
            {
                return Ruby.Methods.rb_str_delete_bang.singleton.Call(null, str, caller, block, new Array(src));
            }
            trRepl = new Tr(replString);

            if (cflag)
            {
                for (i = 0; i < 256; i++)
                {
                    trans[i] = 1;
                }
                while (trSrc.HasMore())
                {
                    c = trSrc.Next();
                    trans[c] = -1;
                }
                while (trRepl.HasMore())
                {
                    /* retrieve last replacer */
                    c = trRepl.Next();
                }
                for (i = 0; i < 256; i++)
                {
                    if (trans[i] >= 0)
                    {
                        trans[i] = trRepl.Now;
                    }
                }
            }
            else
            {
                int r;

                for (i = 0; i < 256; i++)
                {
                    trans[i] = -1;
                }
                while (trSrc.HasMore())
                {
                    c = trSrc.Next();
                    r = trRepl.Next();
                    if (r == -1)
                    {
                        r = trRepl.Now;
                    }
                    trans[c] = r;
                }
            }

            s = 0;
            send = s + sString.Length;
            if (sflag)
            {
                int c0, last = -1;
                while (s < send)
                {
                    c0 = sString[s++];
                    if ((c = trans[c0]) >= 0)
                    {
                        if (last == c) continue;
                        last = c;
                        t.Append((char)c);
                        modify = true;
                    }
                    else
                    {
                        last = -1;
                        t.Append((char)c0);
                    }
                }
            }
            else
            {
                while (s < send)
                {
                    if ((c = trans[(int)sString[s]]) >= 0)
                    {
                        t.Append((char)c);
                        modify = true;
                    }
                    else
                    {
                        t.Append((char)sString[s]);
                    }
                    s++;
                }
            }

            if (modify)
            {
                ((String)str).value = t.ToString();
                return str;
            }
            else
            {
                return null;
            }
        }
    private void Go(Tr tr, Color32 color, Element element)
    {
        if (tr.went) return;
        tr.went = true;
        element.materialGroup = tr.group;
        element.pointers.AddRange(tr.pointers);
        element.list.AddRange(tr.ind);
        foreach (int a in tr.ind)
        {
            element.b.Encapsulate(vertices[a]);
            //crs[a] = color;
        }

        foreach(var i in tr.ind)
        {
            List<Tr> lt;
            if (lab.TryGetValue(i, out lt))
                foreach (Tr t in lt)
                    Go(t, color, element);
        }
    }
예제 #35
0
        // tr_setup_table
        internal static void SetupTable(string str, char[] table, bool init)
        {

            char[] buf = new char[256];
            Tr tr = new Tr(str);
            int i, c;
            int cflag = 0;

            if (str.Length > 1 && str[0] == '^')
            {
                cflag = 1;
                tr.MoveNext();
            }

            if (init)
            {
                for (i = 0; i < 256; i++)
                {
                    table[i] = (char)1;
                }
            }

            for (i = 0; i < 256; i++)
            {
                buf[i] = (char)cflag;
            }

            while (tr.HasMore())
            {
                c = tr.Next();
                if (cflag == 1)
                {
                    buf[c] = (char)0;
                }
                else
                {
                    buf[c] = (char)1;
                }
            }
            for (i = 0; i < 256; i++)
            {
                char test = (char)(table[i] & buf[i]);
                table[i] = (char)(table[i] & buf[i]);
            }
        }
 public void Start2()
 {
     if (mf == null)
         mf = GetComponent<MeshFilter>();
     if (meshList.Count > 0)
     {
         var list = new List<CombineInstance>();
         var r = mf.GetComponent<MeshRenderer>();
         var enumerable = new[] { mf.renderer }.Concat(meshList);
         r.sharedMaterials = enumerable.SelectMany(a => a.sharedMaterials).ToArray();
         foreach (var a in enumerable)
         {
             var sharedMesh = a.GetComponent<MeshFilter>().sharedMesh;
             for (int i = 0; i < sharedMesh.subMeshCount; i++)
             {
                 var ci = new CombineInstance();
                 ci.transform = tr.worldToLocalMatrix * a.transform.localToWorldMatrix;
                 ci.mesh = sharedMesh;
                 ci.subMeshIndex = i;
                 list.Add(ci);
             }
         }
         mf.mesh.CombineMeshes(list.ToArray(), false);
         foreach (var a in meshList)
             Destroy(a.gameObject);
     }
     lossyScale = mf.transform.lossyScale;
     elements.Clear();
     lab = new Dictionary<int, List<Tr>>();
     vertices = mf.mesh.vertices;
     oldVertices = (Vector3[])vertices.Clone();
     normals = mf.mesh.normals;
     tangents = mf.mesh.tangents;
     uvs = mf.mesh.uv;
     for (int x = 0; x < mf.mesh.subMeshCount; x++)
     {
         var trs = mf.mesh.GetIndices(x);
         for (int i = 0; i < trs.Length; i += 3)
         {
             var tr = new Tr() { ind = new[] { trs[i], trs[i + 1], trs[i + 2] }, pointers = new[] { i, i + 1, i + 2 }, group = x };
             flat.Add(tr);
             for (int j = 0; j < 3; j++)
             {
                 List<Tr> lt;
                 if (!lab.TryGetValue(trs[i + j], out lt))
                     lab[trs[i + j]] = lt = new List<Tr>();
                 lt.Add(tr);
             }
         }
     }
     foreach (Tr t in flat)
     {
         if (!t.went)
         {
             Element element = new Element();
             element.MeshTest = this;
             elements.Add(element);
             var color32 = new Color32((byte)(Random.value * 255), (byte)(Random.value * 255), (byte)(Random.value * 255), 255);
             Go(t, color32, element, 0);
         }
     }
 }