Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        void RunSample(ExampleInfo e)
        {
            if (null != example)
            {
                example.Unload();
                //example.Dispose();
                //example = null;

                toolStripStatusLabel.Tag         = toolStripStatusLabel.Text = string.Empty;
                toolStripStatusLabel.LinkVisited = false;
            }

            Application.Idle -= Application_Idle;

            example = (Example)Activator.CreateInstance(e.Example);
            if (null != example)
            {
                example.Load(this.glControl);

                toolStripStatusLabel.Text = e.Example.Name.Replace("_", " - ");
                toolStripStatusLabel.Tag  = e.Example.Name;

                // Ensure that the viewport and projection matrix are set correctly.
                example.Resize(glControl.ClientSize);

                Application.Idle += Application_Idle;
            }
        }
 public void SetExample(ExampleInfo example)
 {
     this.Window.Title   = example.Title;
     plotView.Model      = example.PlotModel;
     plotView.Controller = example.PlotController;
     plotView.InvalidatePlot(true);
 }
 public GraphViewController(ExampleInfo exampleInfo)
 {
     this.exampleInfo = exampleInfo;
     this.plotView    = new PlotView {
         Model = exampleInfo.PlotModel
     };
 }
Example #4
0
        public HttpResponseMessage UpdateExample(ExampleInfo example)
        {
            try
            {
                var originalExample  = ExampleDataAccess.GetItem(example.ExampleId, example.ModuleId);
                var updatesToProcess = ExampleHasUpdates(ref originalExample, ref example);

                if (updatesToProcess)
                {
                    originalExample.LastUpdatedOnDate   = DateTime.Now;
                    originalExample.LastUpdatedByUserId = UserInfo.UserID;

                    var security = new PortalSecurity();

                    originalExample.Title       = security.InputFilter(originalExample.Title.Trim(), PortalSecurity.FilterFlag.NoMarkup);
                    originalExample.Description = security.InputFilter(originalExample.Description.Trim(), PortalSecurity.FilterFlag.NoMarkup);

                    ExampleDataAccess.UpdateItem(originalExample);
                }

                var savedExample = ExampleDataAccess.GetItem(originalExample.ExampleId, originalExample.ModuleId);

                var response = new ServiceResponse <ExampleInfo> {
                    Content = savedExample
                };

                return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson()));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE));
            }
        }
Example #5
0
        private View GetViewFromExampleInfo(ExampleInfo exampleInfo)
        {
            var navigationService = DependencyService.Get <INavigationService>();
            var viewType          = navigationService.GetExampleViewType(exampleInfo);

            return((View)Activator.CreateInstance(viewType));
        }
Example #6
0
        public HttpResponseMessage CreateExample(ExampleInfo newExample)
        {
            try
            {
                newExample.CreatedOnDate       = DateTime.Now;
                newExample.CreatedByUserId     = UserInfo.UserID;
                newExample.LastUpdatedOnDate   = DateTime.Now;
                newExample.LastUpdatedByUserId = UserInfo.UserID;
                newExample.ModuleId            = ActiveModule.ModuleID;

                var security = new PortalSecurity();

                newExample.Title       = security.InputFilter(newExample.Title.Trim(), PortalSecurity.FilterFlag.NoMarkup);
                newExample.Description = security.InputFilter(newExample.Description.Trim(), PortalSecurity.FilterFlag.NoMarkup);

                ExampleDataAccess.CreateItem(newExample);

                var response = new ServiceResponse <string> {
                    Content = Globals.RESPONSE_SUCCESS
                };

                return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson()));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE));
            }
        }
Example #7
0
        //public static IDictionary<string, string> GetCodeForAllExampleFiles(ISubExample example)
        //{
        //    // K: filename ("Chart.FirstLook.Example.xaml.cs")
        //    // V: code text for filename
        //    Dictionary<string, string> codeTextForFiles = new Dictionary<string, string>();

        //    List<CodeFileInfo> codeFilesList = new List<CodeFileInfo>();

        //    var exampleInfo = example as ISubExample;
        //    if (exampleInfo == null)
        //    {
        //        throw new ArgumentException("Something went wrong. Example should be an ExampleInfo.");
        //    }
        //    else
        //    {
        //        var controlAssembly = GetControlAssembly(exampleInfo);
        //        string[] resourceNamesInAssembly = controlAssembly.GetManifestResourceNames();
        //        var textToMatch = exampleInfo.Name.Substring(0, exampleInfo.Name.LastIndexOf('.') + 1);
        //        var resourcesWithCode = resourceNamesInAssembly.Where(r => !r.Contains("AssemblyInfo.cs") && r.StartsWith(textToMatch) && !IsDataFile(r));

        //        foreach (var resourceName in resourcesWithCode)
        //        {
        //            using (var stream = controlAssembly.GetManifestResourceStream(resourceName))
        //            {
        //                using (StreamReader streamReader = new StreamReader(stream))
        //                {
        //                    var codeText = streamReader.ReadToEnd();
        //                    codeTextForFiles.Add(resourceName, codeText);
        //                    codeFilesList.Add(new CodeFileInfo { FileName = resourceName, CodeContent = codeText });
        //                }
        //            }
        //        }
        //    }

        //    return codeTextForFiles;
        //}

        private static System.Reflection.Assembly GetControlAssembly(ExampleInfo exampleInfo)
        {
            var controlName     = string.IsNullOrEmpty(exampleInfo.PackageName) ? exampleInfo.ControlName : exampleInfo.PackageName;
            var controlAssembly = AssemblyCache.GetInstance()[controlName];

            return(controlAssembly);
        }
Example #8
0
 public void CreateItem(ExampleInfo i)
 {
     using (IDataContext ctx = DataContext.Instance())
     {
         var rep = ctx.GetRepository <ExampleInfo>();
         rep.Insert(i);
     }
 }
Example #9
0
 public void UpdateItem(ExampleInfo t)
 {
     using (IDataContext ctx = DataContext.Instance())
     {
         var rep = ctx.GetRepository <ExampleInfo>();
         rep.Update(t);
     }
 }
        public Type GetExampleViewModelType(ExampleInfo exampleInfo)
        {
            var assemblyName = this.GetAssemblyName();
            var typeName     = string.Format("{0}.Examples.{1}Control.{2}Example.{3}ViewModel", assemblyName.Name, exampleInfo.ControlName, exampleInfo.ExampleName, exampleInfo.ExampleName);
            var type         = GetTypeFromTypeName(assemblyName, typeName);

            return(type);
        }
        public ServiceResponse <string> UpdateExample(ExampleInfo example)
        {
            var result = new ServiceResponse <string>();

            result = ServiceHelper.PostRequest <ServiceResponse <string> >(fullApiUri + "UpdateExample", example.ObjectToJson());

            return(result);
        }
Example #12
0
    public static ExampleInfo CreateAttachedValue(Example ex)
    {
        ExampleInfo info = new ExampleInfo();

        info.Name       = ex.ToString();
        info.Methods    = ex.GetType().GetMethods(flags).Length;
        info.Properties = ex.GetType().GetProperties(flags).Length;
        return(info);
    }
        public void NavigateToExample(string examplePath)
        {
            var examplePahtParts = examplePath.Split('.');

            INavigationService navigationService = DependencyService.Get <INavigationService>();
            ExampleInfo        exampleInfo       = new ExampleInfo(examplePahtParts[0], examplePahtParts[1]);

            navigationService.NavigateToExampleAsync(exampleInfo);
        }
Example #14
0
        public ExampleInfo GetItem(int itemId, int moduleId)
        {
            ExampleInfo i = null;

            using (IDataContext ctx = DataContext.Instance())
            {
                var rep = ctx.GetRepository <ExampleInfo>();
                i = rep.GetById(itemId, moduleId);
            }
            return(i);
        }
Example #15
0
 public AllModel()
 {
     Info = new ApiActionInfo();
     EnvironmentResources   = new List <EnvironmentResource>();
     RequestPathParameters  = new List <ParameterInfo>();
     RequestBodyParameters  = new List <ParameterInfo>();
     RequestQueryParameters = new List <ParameterInfo>();
     Responses   = new List <ResponseInfo>();
     Definitions = new List <DefinitionInfo>();
     Example     = new ExampleInfo();
 }
Example #16
0
        void NodeSelected(Base control)
        {
            ExampleInfo ei = control.Tag as ExampleInfo;

            if (ei == null)
            {
                return;
            }

            vm.SelectedExample = ei;
            InitPlot();
        }
        public Type GetExampleViewType(ExampleInfo exampleInfo)
        {
            AssemblyName assemblyName = this.GetAssemblyName();
            var          typeName     = string.Format("{0}.Examples.{1}Control.{2}Example.{3}View", assemblyName.Name, exampleInfo.ControlName, exampleInfo.ExampleName, exampleInfo.ExampleName);
            Type         type         = GetTypeFromTypeName(assemblyName, typeName);

            if (type == null)
            {
                throw new ArgumentException(string.Format("Missing view {0}", typeName));
            }

            return(type);
        }
Example #18
0
        public static void TraceNavigateToExample(ExampleInfo exampleInfo)
        {
            var exampleName = exampleInfo.ExampleName;

            if (string.IsNullOrEmpty(exampleName))
            {
                exampleName = "NoExample";
            }

            Analytics.TrackEvent(NavigateToExampleKey, new Dictionary <string, string> {
                { ControlName, exampleInfo.ControlName },
                { ExampleName, string.Format("{0}.{1}", exampleInfo.ControlName, exampleInfo.ExampleName) }
            });
        }
        public Type GetExampleViewType(ExampleInfo exampleInfo)
        {
            var type             = this.GetType();
            var assemblyName     = type.GetTypeInfo().Assembly.GetName();
            var viewTypeName     = string.Format("{0}.Examples.{1}Control.{2}Example.{3}View", assemblyName.Name, exampleInfo.ControlName, exampleInfo.ExampleName, exampleInfo.ExampleName);
            var fullViewTypeName = string.Format(CultureInfo.InvariantCulture, "{0}, {1}", viewTypeName, assemblyName.FullName);
            var viewType         = Type.GetType(fullViewTypeName);

            if (viewType == null)
            {
                throw new ArgumentException(string.Format("Missing view {0}", viewTypeName));
            }

            return(viewType);
        }
Example #20
0
    public static void Main()
    {
        Example ex1 = new Example("ex1");
        Example ex2 = new Example("ex2");
        Example ex3 = new Example("ex3");

        ExampleInfo exInfo1 = new ExampleInfo();

        exInfo1.Name       = ex1.ToString();
        exInfo1.Methods    = ex1.GetType().GetMethods(flags).Length;
        exInfo1.Properties = ex1.GetType().GetProperties(flags).Length;

        ExampleInfo exInfo3 = new ExampleInfo();

        exInfo3.Name       = ex3.ToString();
        exInfo3.Methods    = ex3.GetType().GetMethods(flags).Length;
        exInfo3.Properties = ex3.GetType().GetProperties(flags).Length;

        var         attached = new ConditionalWeakTable <Example, ExampleInfo>();
        ExampleInfo value    = null;

        // Attach a property to ex1 using the Add method, then retrieve it.
        attached.Add(ex1, exInfo1);
        if (attached.TryGetValue(ex1, out value))
        {
            Console.WriteLine("{0}, {1}", ex1, value);
        }
        else
        {
            Console.WriteLine("{0} does not have an attached property.", ex1);
        }

        // Attempt to retrieve the value attached to ex2.
        value = attached.GetValue(ex2, ExampleTest.CreateAttachedValue);
        if (attached.TryGetValue(ex2, out value))
        {
            Console.WriteLine("{0}, {1}", ex2, value);
        }
        else
        {
            Console.WriteLine("{0} does not have an attached property.", ex2);
        }

        // Attempt to retrieve the value attached to ex3.
        value = attached.GetOrCreateValue(ex3);
        Console.WriteLine("{0}, {1}", ex3, value);
    }
Example #21
0
        private void InitPlot()
        {
            if (this.vm.SelectedExample == null)
            {
                this.plot1.Model      = null;
                this.plot1.Controller = null;
            }
            else
            {
                var flags = ExampleInfo.PrepareFlags(
                    this.transposedCheck.Enabled && this.transposedCheck.Checked,
                    this.reversedCheck.Enabled && this.reversedCheck.Checked);

                this.plot1.Model      = this.vm.SelectedExample.GetModel(flags);
                this.plot1.Controller = this.vm.SelectedExample.GetController(flags);
            }
        }
        public Task NavigateToExampleAsync(ExampleInfo exampleInfo)
        {
            AnalyticsHelper.TraceNavigateToExample(exampleInfo);

            var viewModelType = typeof(ExampleViewModel);

            var page = this.CreatePage(viewModelType);

            var exampleViewModelType = this.GetExampleViewModelType(exampleInfo);

            if (exampleViewModelType != null)
            {
                viewModelType = exampleViewModelType;
            }

            return(InternalNavigateToAsync(page, viewModelType, null, exampleInfo));
        }
Example #23
0
        private void GraphView(ExampleInfo exampleInfo)
        {
            RectangleF plotFrame = UIScreen.MainScreen.Bounds;

            if (UIApplication.SharedApplication.StatusBarOrientation == UIInterfaceOrientation.LandscapeLeft || UIApplication.SharedApplication.StatusBarOrientation == UIInterfaceOrientation.LandscapeRight)
            {
                plotFrame = new RectangleF(0f, 0f, UIScreen.MainScreen.ApplicationFrame.Height, UIScreen.MainScreen.ApplicationFrame.Width - navigation.NavigationBar.Bounds.Height);
            }
            else
            {
                plotFrame = new RectangleF(0f, 0f, UIScreen.MainScreen.ApplicationFrame.Width, UIScreen.MainScreen.ApplicationFrame.Height - navigation.NavigationBar.Bounds.Height);
            }


            var graph_controller = new GraphViewController(exampleInfo.PlotModel, plotFrame);

            navigation.PushViewController(graph_controller, true);
        }
Example #24
0
        private static IExampleInfo CreateExampleInfo(IExampleGroupInfo exampleGroup, XElement element)
        {
            ExampleInfo info = new ExampleInfo();

            System.Diagnostics.Debug.Assert(element != null, "Ported from old code, element purposedly should not be null.");
            info.ExampleGroup = exampleGroup;
            var status = element.GetAttribute("status", null);

            info.Status = string.IsNullOrEmpty(status) ? Enums.StatusMode.Normal : (Enums.StatusMode)Enum.Parse(typeof(Enums.StatusMode), status, true);

            var platform = element.GetAttribute("platform", null);

            info.Platform = string.IsNullOrEmpty(platform) ? ModelFactory.PLATFORM : (Enums.PlatformType)Enum.Parse(typeof(Enums.PlatformType), platform, true);

            info.Text = element.GetAttribute("text", null);
            info.Name = element.GetAttribute("name", null);
            //info.Description = element.GetAttribute("description", null);
            info.IsDefault = element.GetAttribute("isDefault", false);
            var type = element.GetAttribute("type", null);

            info.Type                = string.IsNullOrEmpty(type) ? Enums.ExampleType.Normal : (Enums.ExampleType)Enum.Parse(typeof(Enums.ExampleType), type, true);
            info.PackageName         = element.GetAttribute("packageName", null);
            info.Keywords            = element.GetAttribute("keywords", null);
            info.IsExampleFullScreen = element.GetAttribute("isExampleFullScreen", false);
            info.CommonFolders       = new List <string>(element.GetAttribute("commonFolders", null).Split(';'));
            info.ControlName         = exampleGroup.Control.Name;
            info.HeaderText          = element.GetAttribute("headerText", null);
            info.Highlights          = element.Elements("Highlight").Select(e => ModelFactory.CreateExampleHighlightInfo(e));
            if (!string.IsNullOrEmpty(info.PackageName))
            {
                info.ShortName = info.Name.GetTextAfterLastOccurence(info.PackageName, true).Replace(".Example", string.Empty);
            }
            else
            {
                info.ShortName = info.Name.GetTextAfterLastOccurence(info.ControlName, true).Replace(".Example", string.Empty);
            }

            info.IsFavourite     = FavouritesHelper.IsExampleFavourite(info);
            info.CanPinToDesktop = element.GetAttribute("canPinToDesktop", true);

            return(info);
        }
Example #25
0
        public GraphScrollView(ExampleInfo exampleInfo, RectangleF rect)
            : base(rect)
        {
            ShowsVerticalScrollIndicator   = true;
            ShowsHorizontalScrollIndicator = true;
            BouncesZoom      = true;
            PagingEnabled    = false;
            DecelerationRate = UIScrollView.DecelerationRateNormal;
            BackgroundColor  = UIColor.DarkGray;
            MaximumZoomScale = 5f;
            MinimumZoomScale = 1f;
            ContentSize      = new SizeF(rect.Size.Width * 5, rect.Size.Height * 5);

            var image = new UIImageView(new GraphView(exampleInfo).GetImage(rect));

            AddSubview(image);

            this.ViewForZoomingInScrollView = delegate(UIScrollView scrollView) {
                return(image);
            };
        }
Example #26
0
    IEnumerator Start()
    {
        KGameSettings.Instance.InitAction += OnGameSettingsInit;

        var engine = KEngine.AppEngine.New(
            gameObject,
            new IModule[]
        {
            //KGameSettings.Instance,
            KUIModule.Instance,
        },
            null,
            null);

        while (!engine.IsInited)
        {
            yield return(null);
        }

        var uiName = "DemoHome";

        KUIModule.Instance.OpenWindow(uiName);

        KUIModule.Instance.CallUI(uiName, (ui, args) =>
        {
            // Do some UI stuff
        });

        Debug.Log("[SettingModule]Table: " + ExampleInfo.TabFilePath);
        var exampleInfoTable = SettingModule.Get(ExampleInfo.TabFilePath);

        foreach (var info in exampleInfoTable.GetAll())
        {
            var exampleInfo = ExampleInfo.Wrap(info);
            Debug.Log(string.Format("Name: {0}", exampleInfo.Name));
        }
    }
Example #27
0
        private bool ExampleHasUpdates(ref ExampleInfo originalExample, ref ExampleInfo newExample)
        {
            var updatesToProcess = false;

            if (!string.Equals(newExample.Title, originalExample.Title))
            {
                originalExample.Title = newExample.Title;
                updatesToProcess      = true;
            }

            if (!string.Equals(newExample.Description, originalExample.Description))
            {
                originalExample.Description = newExample.Description;
                updatesToProcess            = true;
            }

            if (newExample.ModuleId != originalExample.ModuleId)
            {
                originalExample.ModuleId = newExample.ModuleId;
                updatesToProcess         = true;
            }

            return(updatesToProcess);
        }
Example #28
0
        public ActionResult Edit(ExampleInfo item)
        {
            if (item.ExampleId == -1)
            {
                item.CreatedByUserId     = User.UserID;
                item.CreatedOnDate       = DateTime.UtcNow;
                item.LastUpdatedByUserId = User.UserID;
                item.LastUpdatedOnDate   = DateTime.UtcNow;

                ExampleInfoRepository.Instance.CreateItem(item);
            }
            else
            {
                var existingItem = ExampleInfoRepository.Instance.GetItem(item.ExampleId, item.ModuleId);
                existingItem.LastUpdatedByUserId = User.UserID;
                existingItem.LastUpdatedOnDate   = DateTime.UtcNow;
                existingItem.Title       = item.Title;
                existingItem.Description = item.Description;

                ExampleInfoRepository.Instance.UpdateItem(existingItem);
            }

            return(RedirectToDefaultRoute());
        }
Example #29
0
        private void InitializeComponent()
        {
            this.plotView1 = new OxyPlot.GtkSharp.PlotView();
            this.plotView1.SetSizeRequest(625, 554);

            this.treeView1 = new TreeView();
            this.treeView1.SetSizeRequest(314, 554);
            this.treeView1.Visible = true;

            var    treeModel = new TreeStore(typeof(string), typeof(string));
            var    iter      = new TreeIter();
            string last      = null;

            foreach (var ex in this.Examples)
            {
                if (last == null || last != ex.Category)
                {
                    iter = treeModel.AppendValues(ex.Category);
                    last = ex.Category;
                }

                treeModel.AppendValues(iter, ex.Title);
            }

            this.treeView1.Model = treeModel;
            var exampleNameColumn = new TreeViewColumn {
                Title = "Example"
            };
            var exampleNameCell = new CellRendererText();

            exampleNameColumn.PackStart(exampleNameCell, true);
            this.treeView1.AppendColumn(exampleNameColumn);
            exampleNameColumn.AddAttribute(exampleNameCell, "text", 0);

            this.treeView1.Selection.Changed += (s, e) =>
            {
                TreeIter  selectedNode;
                TreeModel selectedModel;
                if (treeView1.Selection.GetSelected(out selectedModel, out selectedNode))
                {
                    string val1 = (string)selectedModel.GetValue(selectedNode, 0);
                    string val2 = (string)selectedModel.GetValue(selectedNode, 1);

                    var info = this.Examples.FirstOrDefault(ex => ex.Title == val1);
                    if (info != null)
                    {
                        this.SelectedExample = info;
                    }
                }
            };

            this.hbox1 = new HBox(false, 6);
            this.hbox1.SetSizeRequest(943, 554);

            this.hbox1.PackStart(this.treeView1, false, false, 6);
            this.hbox1.PackStart(this.plotView1, false, false, 6);

            this.Add(this.hbox1);

            //this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            //this.AutoScaleMode = Gtk.AutoScaleMode.Font;
            //this.ClientSize = new System.Drawing.Size(943, 554);
            this.Title        = "OxyPlot.GtkSharp Example Browser";
            this.DeleteEvent += (s, a) =>
            {
                Application.Quit();
                a.RetVal = true;
            };
        }
        public Task NavigateToExampleAsync(ExampleInfo exampleInfo)
        {
            var viewModelType = typeof(ExampleViewModel);

            return(InternalNavigateToAsync(viewModelType, exampleInfo));
        }