Exemple #1
0
        /// Generates data for organisations based on the data
        /// of the persons
        /// </summary>
        public void GenerateDataForOrganisations()
        {
            InitRepo();

            //Get items
            IEnumerable <Item> items = new ItemManager().GetAllOrganisations();

            if (items == null || items.Count() == 0)
            {
                return;
            }

            //Get widgets
            IEnumerable <Widget> widgets = widgetRepo.ReadWidgetsForItemtype(ItemType.Organisation);

            if (widgets == null || widgets.Count() == 0)
            {
                return;
            }

            //Extract data form persons to fill organisations
            DataManager dataManager = new DataManager();

            for (int i = 0; i < items.Count(); i++)
            {
                //Get widgetdata for organisation
                WidgetData organisationData = dataManager.GetOrganisationData(items.ElementAt(i).ItemId, "dd-MM");
                organisationData.Widget = widgets.ElementAt(i);
                widgetRepo.CreateWidgetData(organisationData);
            }
        }
 private void PictureBox_Clicked(object sender, EventArgs e)
 {
     try
     {
         var         item        = (PictureBox)sender;
         ColorDialog colorDialog = new ColorDialog()
         {
             AllowFullOpen = true
         };
         if (colorDialog.ShowDialog() == DialogResult.OK)
         {
             item.BackColor = colorDialog.Color;
             if (Form1.chromeBrowser.CanExecuteJavascriptInMainFrame)
             {
                 Form1.chromeBrowser.ExecuteScriptAsync("livelyPropertyListener", item.Name, ToHexValue(colorDialog.Color));
                 WidgetData.liveyPropertiesData[item.Name]["value"] = ToHexValue(colorDialog.Color);
                 WidgetData.SaveLivelyProperties(propertyFilePath, WidgetData.liveyPropertiesData);
             }
         }
     }
     catch (Exception ex) //saving error
     {
         MessageBox.Show(ex.Message);
     }
 }
    public void DropPrefabArea(WidgetData uiData)
    {
        Event evt = Event.current;

        GUI.color = Color.green;
        Rect drop_area = GUILayoutUtility.GetRect(0.0f, 50.0f, GUILayout.ExpandWidth(true));

        GUI.Box(drop_area, "Drag Widget Here");
        GUI.color = Color.white;
        switch (evt.type)
        {
        case EventType.DragUpdated:
        case EventType.DragPerform:
            if (!drop_area.Contains(evt.mousePosition))
            {
                return;
            }

            DragAndDrop.visualMode = DragAndDropVisualMode.Copy;

            if (evt.type == EventType.DragPerform)
            {
                DragAndDrop.AcceptDrag();

                foreach (string dragged_object in DragAndDrop.paths)
                {
                    int    offset          = dragged_object.IndexOf("Resources/");
                    string processedString = (dragged_object.Split('.')[0]).Remove(0, offset + "Resources/".Length);
                    uiData.perfabPath = processedString;
                }
            }
            break;
        }
    }
Exemple #4
0
        public Form1()
        {
            InitializeComponent();
            this.StartPosition = FormStartPosition.Manual;
            this.Left          = -99999;

            mainForm = this;
            ListenToParent(); //stdin listen pipe.

            CommandLine.Parser.Default.ParseArguments <Options>(args)
            .WithParsed(RunOptions)
            .WithNotParsed(HandleParseError);

            if (enableCSCore)
            {
                CSCoreInit();        //audio analyser
                //timer, audio sends audio data etc
                timer.Interval = 33; //30fps
                timer.Tick    += Timer_Tick1;
                timer.Start();
            }

            try
            {
                WidgetData.LoadLivelyProperties(livelyPropertyPath);
            }
            catch
            {
                //can be non-customisable wp, file missing/corrupt error: skip.
            }
            InitializeChromium();
        }
Exemple #5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            var res  = context.Response;
            var name = context.Request.Form["name"] ?? string.Empty;
            var db   = DB.Current;
            var u    = Membership.GetUser();
            var wd   = new WidgetData {
                Color = ColorClasses.Rand, ControlName = name
            };

            try
            {
                var obj  = db.core_UserPages.First(x => x.UserName == u.UserName);
                var page = obj.Page();
                page.AddWidget(wd);
                obj.Layout = page.ToJson();
                db.SubmitChanges();
                res.Write(1);
            }
            catch (Exception)
            {
                res.Write(0);
            }
        }
Exemple #6
0
        public void ReplaceChild(Gtk.Widget oldWidget, Gtk.Widget newWidget)
        {
            WidgetData r = children [oldWidget];

            Remove(oldWidget);
            Add(newWidget);
            children [newWidget] = r;
        }
Exemple #7
0
        private static RouteValueDictionary GetValues(WidgetData data)
        {
            var values = new RouteValueDictionary();

            foreach (MetaDataProperty property in data.Properties)
            {
                values.Add(property.Name, data.GetValue <string>(property.Name));
            }
            return(values);
        }
Exemple #8
0
		public void should_initialize_properties()
		{
			//arrange
			var expectedWidget = Substitute.For<IWidget>();
			var expectedData = new Data();
			//act
			var target = new WidgetData<Data>(expectedWidget, expectedData);
			//assert
			Assert.AreEqual(expectedWidget, target.Widget);
			Assert.AreEqual(expectedData, target.Data);
		}
Exemple #9
0
        /// <summary>
        /// Gives back a map with the number of metntions
        /// mapped to a specific day or week
        ///
        /// NOTE
        /// This method is not the same as getNumberInfo
        /// This method will be used for widgets.
        /// </summary>
        public WidgetData GetNumberOfMentionsForItem(int itemId, int widgetId, string dateFormat, DateTime?startDate = null)
        {
            //Create widgetdata
            WidgetData widgetData = new WidgetData()
            {
                KeyValue    = "Number of mentions",
                GraphValues = new List <GraphValue>()
            };

            //Get Widget
            Widget widget = new WidgetManager(uowManager).GetWidget(widgetId);

            if (widget == null)
            {
                return(widgetData);
            }

            //Map informations to datetime and add them to the list
            IEnumerable <Information> informations = GetInformationsWithAllInfoForItem(itemId);

            if (informations == null || informations.Count() == 0)
            {
                return(widgetData);
            }

            //Determine startdata
            DateTime timestamp = widget.Timestamp.Value;

            if (startDate == null)
            {
                startDate = DateTime.Now;
            }
            else if (startDate < timestamp)
            {
                return(widgetData);
            }

            //Extract information
            while (timestamp <= startDate)
            {
                //Each grapvalue represents a total number of mentions mapped
                //To a specific data
                int couny = informations.Count(i => i.CreationDate.Value.Day == startDate.Value.Day);
                widgetData.GraphValues.Add(new GraphValue()
                {
                    Value         = startDate.Value.ToString(dateFormat),
                    NumberOfTimes = informations.Count(i => i.CreationDate.Value.Day == startDate.Value.Day)
                });
                startDate = startDate.Value.AddDays(-1);
            }

            return(widgetData);
        }
 internal void sapApp_WidgetEvent(ref WidgetData pWidgetData, out bool BubbleEvent)
 {
     BubbleEvent = true;
     foreach (var e in widgetEvents)
     {
         ((_IApplicationEvents_WidgetEventEventHandler)e)(ref pWidgetData, out BubbleEvent);
         if (!BubbleEvent)
         {
             break;
         }
     }
 }
 private void SettingsWidget_Load(object sender, EventArgs e)
 {
     try
     {
         WidgetData.LoadLivelyProperties(Form1.livelyPropertyPath);
         GenerateLivelyWidgetUIElements();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "Lively:Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         this.Close();
     }
 }
Exemple #12
0
 private void SettingsWidget_Load(object sender, EventArgs e)
 {
     try
     {
         WidgetData.LoadLivelyProperties(Path.Combine(Path.GetDirectoryName(Form1.htmlPath), "LivelyProperties.json"));
         GenerateLivelyWidgetUIElements();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Something went wrong..", MessageBoxButtons.OK, MessageBoxIcon.Error);
         this.Close();
     }
 }
        private void DefaultBtn_Click(object sender, EventArgs e)
        {
            try
            {
                WidgetData.LoadLivelyProperties(Path.Combine(Path.GetDirectoryName(Form1.htmlPath), "LivelyProperties.json"));
                WidgetData.SaveLivelyProperties(Form1.livelyPropertyPath, WidgetData.liveyPropertiesData);

                LivelyPropertiesDataReload();
                Form1.SettingsWidgetReload();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Lively:Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #14
0
        /// <summary>
        /// Gives back all the widgetdata for monitoring the
        /// registerd users per day
        /// </summary>
        public WidgetData GetUserActivitiesData(ActivityType type, DateTime?timestamp = null)
        {
            InitRepo();

            //Create widgetdata
            WidgetData widgetData = new WidgetData()
            {
                GraphValues = new List <GraphValue>(),
                KeyValue    = "activity"
            };

            //Check timestamp
            if (timestamp == null)
            {
                timestamp = DateTime.Now.AddDays(-30);
            }

            //Get actitivies
            IEnumerable <UserActivity> activities = new SubplatformManager().GetUserActivities(type, timestamp);

            if (activities == null || activities.Count() == 0)
            {
                return(widgetData);
            }
            int count = activities.Count();

            //Query data
            DateTime     startdate = DateTime.Now;
            UserActivity activity;

            while (timestamp <= startdate)
            {
                GraphValue graphValue = new GraphValue()
                {
                    NumberOfTimes = 0,
                    Value         = startdate.ToString("dd-MM")
                };
                activity = activities.Where(act => act.TimeStamp.ToString("dd-MM-yy").Equals(startdate.ToString("dd-MM-yy"))).SingleOrDefault();
                if (activity != null)
                {
                    graphValue.NumberOfTimes = activity.NumberOfTimes;
                }
                startdate = startdate.AddDays(-1);
                widgetData.GraphValues.Add(graphValue);
            }

            return(widgetData);
        }
Exemple #15
0
        /// <summary>
        /// Gives back the geoloactionData of all the items
        /// </summary>
        public WidgetData GetGeoLocationData(DateTime?timestamp = null)
        {
            //Create Widgetdata
            WidgetData geoData = new WidgetData()
            {
                KeyValue    = "geo",
                GraphValues = new List <GraphValue>()
            };

            //Get all persons
            IEnumerable <Person> persons = new ItemManager().GetAllItemsWithInformations();

            if (persons == null || persons.Count() == 0)
            {
                return(geoData);
            }

            //Determine timestamp
            if (timestamp == null)
            {
                timestamp = DateTime.Now.AddDays(-30);
            }

            //Fill geoData
            foreach (Person item in persons)
            {
                //Check is district already exsists
                GraphValue graphValue;
                graphValue = geoData.GraphValues.Where(value => value.Value.ToLower().Equals(item.District.ToLower())).SingleOrDefault();
                int numberOfInfos = item.Informations.Where(info => info.CreationDate >= timestamp).Count();

                if (graphValue == null)
                {
                    graphValue = new GraphValue()
                    {
                        Value         = item.District,
                        NumberOfTimes = numberOfInfos
                    };
                    geoData.GraphValues.Add(graphValue);
                }
                else
                {
                    graphValue.NumberOfTimes += numberOfInfos;
                }
            }

            return(geoData);
        }
    public TransformController(SkillBarLogic root)
    {
        m_TransStep     = TransStep.None;
        m_SkillBarLogic = root;

//         m_BeginDataPVE = new TransformerBeginData();
//         m_BeginDataPVE.m_vSpriteBeginPos_Local = root.m_SpritePVE.transform.localPosition;
//         m_BeginDataPVE.m_vBeginPos_Local = root.m_PVEBtn.transform.localPosition;
//         m_BeginDataPVE.m_vAnchorPos_Local = root.m_PVEBtn.transform.parent.localPosition;
//         m_BeginDataPVE.m_vLblPos_Local = root.m_LblPvE.transform.localPosition;
//         m_BeginDataPVE.m_nBeginWidth = root.m_SpritePVEBG.width;
//
//         m_BeginDataPVP = new TransformerBeginData();
//         m_BeginDataPVP.m_vSpriteBeginPos_Local = root.m_SpritePVP.transform.localPosition;
//         m_BeginDataPVP.m_vBeginPos_Local = root.m_PVPBtn.transform.localPosition;
//         m_BeginDataPVP.m_vAnchorPos_Local = root.m_PVPBtn.transform.parent.localPosition;
//         m_BeginDataPVP.m_vLblPos_Local = root.m_LblPvP.transform.localPosition;
//         m_BeginDataPVP.m_nBeginWidth = root.m_SpritePVPBG.width;

        m_listPVEWidgetData = new List <WidgetData>();
        m_listPVPWidgetData = new List <WidgetData>();

        //PVE
        m_listPVEWidgetData.Add(GenWidgetDataFromObj(root.m_PVEBtn.transform.parent.gameObject));
        m_listPVEWidgetData.Add(GenWidgetDataFromObj(root.m_PVEBtn.gameObject));
        for (int i = 0; i < root.m_PVEBtn.transform.childCount; i++)
        {
            GameObject obj = root.m_PVEBtn.transform.GetChild(i).gameObject;
            WidgetData wd  = GenWidgetDataFromObj(obj);
            if (wd != null)
            {
                m_listPVEWidgetData.Add(wd);
            }
        }

        //PVP
        m_listPVEWidgetData.Add(GenWidgetDataFromObj(root.m_PVPBtn.transform.parent.gameObject));
        m_listPVPWidgetData.Add(GenWidgetDataFromObj(root.m_PVPBtn.gameObject));
        for (int i = 0; i < root.m_PVPBtn.transform.childCount; i++)
        {
            GameObject obj = root.m_PVPBtn.transform.GetChild(i).gameObject;
            WidgetData wd  = GenWidgetDataFromObj(obj);
            if (wd != null)
            {
                m_listPVPWidgetData.Add(wd);
            }
        }
    }
    void DisplayListArea()
    {
        EditorGUILayout.BeginVertical(GUILayout.Width(250));
        EditorGUILayout.Space();

        m_scrollPos = EditorGUILayout.BeginScrollView(m_scrollPos, "box", GUILayout.ExpandHeight(true));

        for (int cnt = 0; cnt < m_gameWidgets.COUNT; cnt++)
        {
            EditorGUILayout.BeginHorizontal();
            GUI.color = Color.red;
            if (GUILayout.Button("X", GUILayout.Width(25)))
            {
                m_gameWidgets.RemoveAt(cnt);
                m_gameWidgets.SortAlphabeticallyAtoZ();
                EditorUtility.SetDirty(m_gameWidgets);
                m_state = State.BLANK;
                return;
            }
            GUI.color = Color.white;

            GUI.color = Color.green;
            if (GUILayout.Button(m_gameWidgets.GameUI(cnt).Id.ToString(), "box", GUILayout.ExpandWidth(true)))
            {
//                m_selectedUI = cnt;
                m_state = State.EDIT;
                m_newUI = m_gameWidgets.GameUI(cnt);
            }
            GUI.color = Color.white;
            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.EndScrollView();

        EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
        EditorGUILayout.LabelField("Widgets: " + m_gameWidgets.COUNT, GUILayout.Width(100));

        if (GUILayout.Button("New Widget"))
        {
            m_newUI = new WidgetData();
            m_state = State.ADD;
        }


        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space();
        EditorGUILayout.EndVertical();
    }
        public MainWindowViewModel()
        {
            Widgets = new ObservableCollection <Widget>(WidgetData.GetAllWidgets());

            if (Widgets.Any())
            {
                SelectedWidget = Widgets[0];
            }

            ButtonSellCommand   = new RelayCommand(new Action <object>(SellWidgets));
            ButtonBuyCommand    = new RelayCommand(new Action <object>(BuyWidgets));
            ButtonAddCommand    = new RelayCommand(new Action <object>(AddWidget));
            ButtonEditCommand   = new RelayCommand(new Action <object>(EditWidget));
            ButtonDeleteCommand = new RelayCommand(new Action <object>(DeleteWidget));
            ButtonQuitCommand   = new RelayCommand(new Action <object>(QuitWidget));
        }
Exemple #19
0
        public void AddWidget(WidgetData data)
        {
            Widget widget;

            if (data is CheckboxData)
            {
                widget = new Checkbox(data as CheckboxData);
            }
            else
            {
                throw new Exception("Unhandled widget: " + data.GetType().Name);
            }

            widget.ShowAll();
            Add(widget);
        }
Exemple #20
0
        /// <summary>
        /// Forces an update for the activity widgets
        /// </summary>
        public IEnumerable <Widget> ChangeWidgetActities(IEnumerable <Widget> widgets, int platformId)
        {
            //** Create new widgetDatas **//
            DataManager dataManager = new DataManager();

            //1st widget
            WidgetData loginData   = dataManager.GetUserActivitiesData(ActivityType.LoginActivity, DateTime.Now.AddDays(-30));
            Widget     loginWidget = widgets.Where(widget => widget.PropertyTags.All(tag => tag.Name.ToLower().Contains("login"))).SingleOrDefault();

            loginWidget.WidgetDatas = new List <WidgetData>
            {
                loginData
            };
            loginData.Widget = loginWidget;
            widgetRepo.CreateWidgetData(loginData);

            //2nd widget
            WidgetData registerData   = dataManager.GetUserActivitiesData(ActivityType.RegisterActivity, DateTime.Now.AddDays(-30));
            Widget     registerWidget = widgets.Where(widget => widget.PropertyTags.All(tag => tag.Name.ToLower().Contains("register"))).SingleOrDefault();

            loginWidget.WidgetDatas = new List <WidgetData>
            {
                loginData
            };
            registerData.Widget = registerWidget;
            widgetRepo.CreateWidgetData(registerData);

            //3rd widget
            WidgetData visitData   = dataManager.GetUserActivitiesData(ActivityType.VisitActitiy, DateTime.Now.AddDays(-30));
            Widget     visitWidget = widgets.Where(widget => widget.PropertyTags.All(tag => tag.Name.ToLower().Contains("visit"))).SingleOrDefault();

            loginWidget.WidgetDatas = new List <WidgetData>
            {
                loginData
            };
            visitData.Widget = visitWidget;
            widgetRepo.CreateWidgetData(visitData);

            //Get last updated
            SubplatformManager platformManager = new SubplatformManager();
            SubPlatform        platform        = platformManager.GetSubPlatform(platformId);

            platform.LastUpdatedActivities = DateTime.Now;
            platformManager.ChangeSubplatform(platform);

            return(widgets);
        }
        public void ConfigureServices(IServiceCollection services, IWebHostEnvironment env)
        {
            services
            .AddControllers()
            .AddFluentValidation();

            services.AddApiVersioning(o =>
            {
                // returns the headers "api-supported-versions" and "api-deprecated-versions"
                o.ReportApiVersions = true;
            });

            services.AddVersionedApiExplorer(o =>
            {
                o.GroupNameFormat           = "'v'VVV";
                o.SubstituteApiVersionInUrl = true;
            });


            var cn = Configuration.GetConnectionString("DefaultConnection");

            if (env.IsDevelopment())
            {
                services
                .AddDbContext <WidgetContext>(o => o
                                              .UseSqlite(cn));

                var context = services
                              .BuildServiceProvider()
                              .GetService <WidgetContext>();

                WidgetData.Seed(context);
            }
            else
            {
                services
                .AddDbContext <WidgetContext>(o => o
                                              .UseSqlServer(cn));
            }

            // register validators
            services.AddTransient <IValidator <V1.DTO.WidgetDTO>, V1.Validators.WidgetDTOValidatorCollection>();
            services.AddTransient <IValidator <V2.DTO.WidgetDTO>, V2.Validators.WidgetDTOValidatorCollection>();

            services.AddSwaggerService();
        }
Exemple #22
0
 private void Textbox_TextChanged(object sender, EventArgs e)
 {
     try
     {
         var item = (TextBox)sender;
         //Debug.WriteLine(item.Name + " "+item.Text);
         if (Form1.chromeBrowser.CanExecuteJavascriptInMainFrame)
         {
             Form1.chromeBrowser.ExecuteScriptAsync("livelyPropertyListener", item.Name, item.Text);
             WidgetData.liveyPropertiesData[item.Name]["value"] = item.Text;
             WidgetData.SaveLivelyProperties(propertyFilePath, WidgetData.liveyPropertiesData);
         }
     }
     catch (Exception ex) //saving error
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemple #23
0
        /**
         * @brief get the weather of location
         *
         * @return a Widget Data class
         */
        public WidgetData GetWeatherWidget()
        {
            WidgetData res = new WidgetData
            {
                Descrition = "Display the current weather from a city location",
                Name       = "current_weather",
                Params     = new List <ParamData>
                {
                    new ParamData
                    {
                        Name = "city",
                        Type = "string"
                    }
                }
            };

            return(res);
        }
Exemple #24
0
        /**
         * @brief get the channel of a widget
         *
         * @return a Widget Data class
         */
        public WidgetData GetChannelWidget()
        {
            WidgetData res = new WidgetData
            {
                Descrition = "Display a youtube channel with his number of subscribers",
                Name       = "channel",
                Params     = new List <ParamData>
                {
                    new ParamData
                    {
                        Name = "channelId",
                        Type = "string"
                    }
                }
            };

            return(res);
        }
Exemple #25
0
        /**
         * @brief get the video of a widget
         *
         * @return a Widget Data class
         */
        public WidgetData GetVideoWidget()
        {
            WidgetData res = new WidgetData
            {
                Descrition = "Display a youtube video with his number of likes, dislikes, views and the video",
                Name       = "video",
                Params     = new List <ParamData>
                {
                    new ParamData
                    {
                        Name = "videoId",
                        Type = "string"
                    }
                }
            };

            return(res);
        }
 private void CmbBox_SelectedValueChanged(object sender, EventArgs e)
 {
     try
     {
         var item = (ComboBox)sender;
         //Debug.WriteLine(item.Name + item.SelectedIndex);
         if (Form1.chromeBrowser.CanExecuteJavascriptInMainFrame)
         {
             Form1.chromeBrowser.ExecuteScriptAsync("livelyPropertyListener", item.Name, item.SelectedIndex);
             WidgetData.liveyPropertiesData[item.Name]["value"] = item.SelectedIndex;
             WidgetData.SaveLivelyProperties(Form1.livelyPropertyPath, WidgetData.liveyPropertiesData);
         }
     }
     catch (Exception ex) //saving error
     {
         MessageBox.Show(ex.Message);
     }
 }
 private void Button_Click(object sender, EventArgs e)
 {
     try
     {
         var item = (Button)sender;
         //Debug.WriteLine(item.Name);
         if (Form1.chromeBrowser.CanExecuteJavascriptInMainFrame)
         {
             Form1.chromeBrowser.ExecuteScriptAsync("livelyPropertyListener", item.Name, true);
             WidgetData.liveyPropertiesData[item.Name]["value"] = true;
             WidgetData.SaveLivelyProperties(Form1.livelyPropertyPath, WidgetData.liveyPropertiesData);
         }
     }
     catch (Exception ex) //saving error
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemple #28
0
        /**
         * @brief get the current number of player of a game
         *
         * @return a Widget Data class
         */
        public WidgetData GetPlayersWidget()
        {
            WidgetData res = new WidgetData
            {
                Descrition = "Display the number of current players playing in a game",
                Name       = "players_game",
                Params     = new List <ParamData>
                {
                    new ParamData
                    {
                        Name = "appId",
                        Type = "string"
                    }
                }
            };

            return(res);
        }
Exemple #29
0
        /**
         * @brief get the achivements of a game
         *
         * @return a Widget Data class
         */
        public WidgetData GetAchievementWidget()
        {
            WidgetData res = new WidgetData
            {
                Descrition = "Display a game's list of achievement with their global progression",
                Name       = "achievements",
                Params     = new List <ParamData>
                {
                    new ParamData
                    {
                        Name = "appId",
                        Type = "string"
                    }
                }
            };

            return(res);
        }
 void IWidgetView.New(WidgetData widget)
 {
     (this as IWidgetView).View(widget);
     if (HostCreate != null)
         HostCreate();
 }
    protected void Page_Init(object sender, EventArgs e)
    {
        var m_refMsg = new ContentAPI().EkMsgRef;

        CancelLabel.Text = m_refMsg.GetMessage("generic Cancel");
        SaveLabel.Text = m_refMsg.GetMessage("btn Save");

        //If initial load, reset pagebuilder page to clean slate.
        if (!IsPostBack && Request.UrlReferrer != null && Request.UrlReferrer.ToString().ToLower().Contains("targetcontentlist.aspx"))
        {
            Session["EkWidgetDirty"] = null;
            Session["EkWidgetBag"] = null;
            (Page as PageBuilder).Pagedata = null;
            (Page as PageBuilder).ClearView();
        }

        _msgHelper = new EkMessageHelper(_contentApi.RequestInformationRef);

        Utilities.ValidateUserLogin();
        if (_contentApi.RequestInformationRef.IsMembershipUser == 1 || (_contentApi.RequestInformationRef.UserId != 999999999 && !_contentApi.IsARoleMember(Ektron.Cms.Common.EkEnumeration.CmsRoleIds.AdminPersonalize)))
        {
            Response.Redirect(_contentApi.ApplicationPath + "reterror.aspx?info=" + _contentApi.EkMsgRef.GetMessage("msg login cms user"), true);
            return;
        }

        txtName.Attributes.Add("onkeypress", "return CheckKeyValue(event, '34,13, 60, 62');");
        //Register CSS
        Ektron.Cms.API.Css.RegisterCss(this, Ektron.Cms.API.Css.ManagedStyleSheet.EktronWorkareaCss);
        Ektron.Cms.API.Css.RegisterCss(this, Ektron.Cms.API.Css.ManagedStyleSheet.EktronWorkareaIeCss);
        Ektron.Cms.API.Css.RegisterCss(this, Ektron.Cms.API.Css.ManagedStyleSheet.EktronFixedPositionToolbarCss);

        string cssFilePath =
            ResolveUrl(String.Format("{0}/{1}", new SiteAPI().SitePath,
                                 "Workarea/csslib/ektron.workarea.personalization.ie.7.css"));

        Ektron.Cms.API.Css.RegisterCss(this, cssFilePath, "ie-targetcontent", Css.BrowserTarget.IE8);

        Ektron.Cms.API.JS.RegisterJS(this, Ektron.Cms.API.JS.ManagedScript.EktronJFunctJS);
        ltrlStyleSheetJS.Text = _styleHelper.GetClientScript();

        //ViewAllToolbar
        txtTitleBar.InnerHtml = _styleHelper.GetTitleBar(_msgHelper.GetMessage("lbl targeted content"));
        lblName.Text = _msgHelper.GetMessage("generic title");
        ltrTitleEmpty.Text = _msgHelper.GetMessage("js: alert title required");
        image_link_100.Attributes.Add("onclick", "verifyTitle(event);");

        PageBuilder pb = this as PageBuilder;

        if (Request["targetcontentid"] != null)
        {
            long.TryParse(Request["targetcontentid"], out _targetContentId);
        }

        //Add the Target Content Widget to Page
        if (pb.Pagedata.Widgets == null || pb.Pagedata.Widgets.Count == 0)
        {
            if (_targetContentId == 0)
            {
                _columnGuid = Guid.NewGuid();
                _targetContentWidgetXml = string.Format(@"<ArrayOfDataStore xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""><dataStore><Property>RulesetNames</Property><TypeName>System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]</TypeName><AssemblyAndType>System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</AssemblyAndType></dataStore><dataStore><Property>Rulesets</Property><TypeName>System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]</TypeName><AssemblyAndType>System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</AssemblyAndType></dataStore><dataStore><Property>SelectedZone</Property><Value xsi:type=""xsd:int"">0</Value><TypeName>System.Int32</TypeName><AssemblyAndType>System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</AssemblyAndType></dataStore><dataStore><Property>TargetConfigurationId</Property><Value xsi:type=""xsd:long"">{0}</Value><TypeName>System.Int64</TypeName><AssemblyAndType>System.Int64, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</AssemblyAndType></dataStore><dataStore><Property>TargetedContent</Property><Value xsi:type=""TargetedContentData""><Id>0</Id><IsGlobal>false</IsGlobal><Segments><SegmentData><Id>0</Id><Name>Default</Name><Rules /><IsGlobal>false</IsGlobal></SegmentData></Segments><PageData><IsMasterLayout xmlns=""PB"">false</IsMasterLayout><masterID xmlns=""PB"">0</masterID><pageID xmlns=""PB"">0</pageID><languageID xmlns=""PB"">0</languageID><Zones xmlns=""PB""><DropZoneData><isMasterZone>false</isMasterZone><Columns><ColumnDataSerialize><Guid>{1}</Guid><Display>false</Display><columnID>-1</columnID><width>100</width><unit>percent</unit></ColumnDataSerialize></Columns></DropZoneData></Zones><Widgets xmlns=""PB"" /></PageData></Value><TypeName>Ektron.Cms.Content.Targeting.TargetedContentData</TypeName><AssemblyAndType>Ektron.Cms.Content.Targeting.TargetedContentData, Ektron.Cms.ObjectFactory, Version=8.5.0.297, Culture=neutral, PublicKeyToken=559a2c4fa21e63be</AssemblyAndType></dataStore></ArrayOfDataStore>", "{0}", _columnGuid);
            }

            pb.ClearView(layoutVersion.Staged, false);
            pb.Status = Mode.Editing;
            pb.viewType = layoutVersion.Staged;

            WidgetData targetContentWidget = new WidgetData()
            {
                ID = 999,
                ControlURL = "TargetedContent.ascx",
                ColumnID = 0,
                DropID = "targetContentZone",
                Settings = string.Format(_targetContentWidgetXml, _targetContentId)
            };

            pb.Pagedata.Widgets = new List<WidgetData>();
            pb.Pagedata.Widgets.Add(targetContentWidget);

            //(Page as PageBuilder).View(pb.Pagedata);

            LoadTargetContentConfiguration(targetContentWidget);

            pb.View(pb.Pagedata);
        }

        if (!IsPostBack)
        {
            Bind();
        }
    }
    private void LoadTargetContentConfiguration(WidgetData targetContentWidget)
    {
        TargetedContent tcManager = new TargetedContent(_contentApi.RequestInformationRef);
        TargetedContentData targetContentData =
            (_targetContentId > 0 ? tcManager.GetItem(_targetContentId) : new TargetedContentData());

        if (_targetContentId == 0)
        {
            targetContentData.PageData = PageData.Restore(string.Format("<PageData xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"PB\"><IsMasterLayout>false</IsMasterLayout><masterID>0</masterID><pageID>0</pageID><languageID>0</languageID><Zones><DropZoneData><isMasterZone>false</isMasterZone><Columns><ColumnData><Guid>{0}</Guid><Display>false</Display><columnID>-1</columnID><width>100</width><unit>percent</unit></ColumnData></Columns></DropZoneData></Zones><Widgets /></PageData>", _columnGuid));
            targetContentData.Segments.Add(new SegmentData());
        }

        if (targetContentData != null)
        {

            txtName.Text = targetContentData.Name;
            PageBuilder pb = Page as PageBuilder;

            pb.Pagedata.Widgets.AddRange(targetContentData.PageData.Widgets);
            pb.Pagedata.Zones[0].Columns.AddRange(targetContentData.PageData.Zones[0].Columns);

            targetContentWidget.ChildColumns = targetContentData.PageData.Zones[0].Columns;

            pb.ClearView(layoutVersion.Staged, false);
            pb.Status = Mode.Editing;
            pb.viewType = layoutVersion.Staged;
            pb.View(pb.Pagedata);
        }
    }
 void IWidgetListView.ViewWidget(WidgetData widget)
 {
     CreateWidget(widget);
 }
 void LoadWidget(WidgetData widget)
 {
     WidgetControls_widget ctrl = LoadControl(WidgetPath) as WidgetControls_widget;
     ctrl.Editable = Editable;
     ctrl.ID = "widget_" + widget.ID.ToString();
     phWidgets.Controls.Add(ctrl as Control);
     (ctrl as IWidgetView).View(widget);
 }
Exemple #35
0
 internal void sapApp_WidgetEvent(ref WidgetData pWidgetData, out bool BubbleEvent)
 {
     BubbleEvent = true;
     foreach (var e in widgetEvents)
     {
         ((_IApplicationEvents_WidgetEventEventHandler)e)(ref pWidgetData, out BubbleEvent);
         if (!BubbleEvent)
             break;
     }
 }
Exemple #36
0
        void broadcasthook(Message message, Widget widget, object[] args)
        {
            switch (message)
            {
                case Message.WidgetMouseDown:

                    if (ActiveWidget == widget) return;

                    ActiveWidget = widget;

                    if (ActiveWidget.data != null)
                    {
                        widgetData = ActiveWidget.data;
                    }
                    else
                    {
                        widgetData = widget.ToWidgetData();
                        ActiveWidget.data = widgetData;
                    }

                    propertzGrid1.SelectedObject = this.widgetData;

                    break;
                case Message.WidgetMouseMove:
                    var e = args[0] as MouseMoveEventArgs;
                    widget.location.X += stonevox.Scale.hSizeScale(e.XDelta * 2f);
                    widget.location.Y += stonevox.Scale.vSizeScale(e.YDelta * -2f);
                    widgetData.Location.X += e.XDelta;
                    widgetData.Location.Y -= e.YDelta;
                    break;
            }
        }
Exemple #37
0
        private void GUIEditor_Load(object sender, EventArgs e)
        {
            broadcasthandler = broadcasthook;
            Singleton<Broadcaster>.INSTANCE.handlers.Add(broadcasthandler);
            CollectionEditorHook.FormClosed += CollectionEditor_FormClosed;

            Type[] Types = Assembly.GetExecutingAssembly().GetTypes();

            foreach (var Type in Types)
            {
                GUIAppearenceNameAttribute appearenceName = Type.GetCustomAttribute<GUIAppearenceNameAttribute>();
                GUIWidgetNameAttribute widgetName = Type.GetCustomAttribute<GUIWidgetNameAttribute>();

                if (appearenceName != null)
                {
                    GUIAppearenceDataTypeAttribute dataType = Type.GetCustomAttribute<GUIAppearenceDataTypeAttribute>();

                    ToolStripMenuItem appearenceToolStrip = new ToolStripMenuItem();

                    //var appearence = Activator.CreateInstance(Type) as Appearence;


                    appearenceToolStrip.Text = appearenceName.DisplayName;

                    appearenceToolStrip.Click += (g, o) =>
                    {
                        if (ActiveWidget != null)
                        {
                            var appData = Activator.CreateInstance(dataType.Type) as AppearenceData;
                            appData.Name = ActiveWidget.appearence.Count.ToString();
                            widgetData.appearenceData.Add(appData);
                            ActiveWidget.FromWidgetData(widgetData);

                            //propertzGrid1.SelectedObject = appData;
                            //ActiveWidget.appearence.AddAppearence(ActiveWidget.appearence.Count.ToString(), Activator.CreateInstance(Type) as Appearence);
                        }
                    };

                    addToolStripMenuItem.DropDownItems.Add(appearenceToolStrip);
                }

                if (widgetName != null)
                {
                    GUIWidgetDataType data = Type.GetCustomAttribute<GUIWidgetDataType>();

                    ToolStripMenuItem widgetToolStrip = new ToolStripMenuItem();

                    widgetToolStrip.Text = widgetName.DisplayName;

                    widgetToolStrip.Click += (g, o) =>
                    {
                        Widget widget = Activator.CreateInstance(Type) as Widget;
                        widget.SetBounds(0, 0, 100, 100);

                        ActiveWidget = widget;

                        widgetData = Activator.CreateInstance(data.Type) as WidgetData;
                        widgetData.Size = new Vector2(100, 100);

                        ActiveWidget.data = widgetData;

                        propertzGrid1.SelectedObject = this.widgetData;

                        Singleton<GUI>.INSTANCE.widgets.Add(widget);
                    };
                    
                    this.toolStripDropDownButton1.DropDownItems.Add(widgetToolStrip);
                }
            }
        }
    void IWidgetView.View(WidgetData widget)
    {
        _widget = widget;
        try
        {
            bool isInWorkarea = (HttpContext.Current.Request.FilePath.ToLower().IndexOf("/workarea/") > -1);
            //string widgetsDirectoryPath = isInWorkarea ? "/Workarea/Widgets/" : "/Widgets/";
            string widgetsDirectoryPath = (isInWorkarea ? _contentApi.ApplicationPath : _contentApi.SitePath)
                                + "/Widgets/";

            _userWidget = LoadControl(/*HttpContext.Current.Request.ApplicationPath + */widgetsDirectoryPath + widget.ControlURL) as UserControl;
            (this as IWidgetHost).LoadWidgetDataMembers();
            phWidgetContent.Controls.Clear();
            phWidgetContent.Controls.Add(_userWidget);

            lbCloseWidget.Visible = Editable;
            lbEdit.Visible = Editable && HostEdit != null && !_widget.Minimized;
            lbMinimize.Visible = Editable && HostMinimize != null && !_widget.Minimized;
            lbRestore.Visible = Editable && HostMaximize != null && _widget.Minimized;

            if (_widget.Minimized == true && HostMinimize != null)
            {
                HostMinimize();
                if (HostClose != null)
                {
                    //DO nothing
                }
            }
        }
        catch (HttpException ex)
        {
            lbCloseWidget.Visible = true;
            lbEdit.Visible = false;
            lbMinimize.Visible = false;
            lbRestore.Visible = false;
            phWidgetContent.Controls.Clear();
            Literal lblWarning = new Literal();
            lblWarning.Text = ex.Message.ToString();
            phWidgetContent.Controls.Add(lblWarning);
        }
        catch (Exception ex)
        {
            EkException.WriteToEventLog("Failed to load " + widget.ControlURL, System.Diagnostics.EventLogEntryType.Error);
            EkException.LogException(ex, System.Diagnostics.EventLogEntryType.Error);
        }
    }
Exemple #39
0
        static void Main(string[] args)
        {
            string currentDir = Directory.GetCurrentDirectory();
            string widgetsDir = currentDir + @"\Widgets";
            //FileSystemContext context = new FileSystemContext(widgetsDir);
            //Widget widget =  context.Find("Data");

            //Widget newWidget = new Widget();
            //newWidget.Id = currentDir + @"\Widgets" + @"\HelloMy";
            //newWidget.Name = "HelloMy";
            //newWidget.Guid = new Guid();
            //newWidget.Data = new List<IWidgetData>();
            //WidgetData wdata = new WidgetData();
            //wdata.Name = "Mycontent.txt";
            //wdata.Id = currentDir + @"\Widgets" + @"\HelloMy" + @"\Mycontent.txt";
            //wdata.Data = "Installation";
            //newWidget.Data.Add(wdata);
            //context.Insert(newWidget);

            //Widget widgetDel =  context.Find("HelloMy");
            //context.Delete(widgetDel);

            //string currentDir = Directory.GetCurrentDirectory();
            //FileQuery fq = new FileQuery(currentDir);

            //FileData data = new FileData();
            //data.Name = "test.text";
            //data.Data = "insidetext23253";

            //fq.GetAll();

            WidgetDataContext wdc = new WidgetDataContext(widgetsDir);
            List<Widget> widgets = wdc.Widgets;

            Widget newWid1 = new Widget(null, "Hapukurk1");
            WidgetData wdata1 = new WidgetData(null, "Add1.txt", "Data");
            newWid1.Data.Add(wdata1);
            WidgetData wdata2 = new WidgetData(null, "Add2.txt", "Data");
            newWid1.Data.Add(wdata2);

            Widget newWid2 = new Widget(null, "Hapukurk2");
            WidgetData wdata11 = new WidgetData(null, "Add1.txt", "Data");
            newWid2.Data.Add(wdata11);
            WidgetData wdata22 = new WidgetData(null, "Add2.txt", "Data");
            newWid2.Data.Add(wdata22);

            Widget newWid3 = new Widget(null, "Hapukurk3");
            WidgetData wdata111 = new WidgetData(null, "Add1.txt", "Data");
            newWid3.Data.Add(wdata111);
            WidgetData wdata222 = new WidgetData(null, "Add2.txt", "Data");
            newWid3.Data.Add(wdata222);

            wdc.Add(newWid1);
            wdc.Add(newWid2);
            wdc.Add(newWid3);

            List<Widget> widgets1 = wdc.Widgets;
            Widget removeWid = widgets1[14];
            removeWid.Name = "Hernes";
            wdc.Update(removeWid);
            Widget removeSaveWid = widgets1[2];
            wdc.Delete(removeSaveWid);
            Widget chan = widgets1[1];
            chan.Name = "OHOO";
            chan.Data.Add(new WidgetData(null, "TESTq1.rrt", "DATA TEST"));
            wdc.Update(chan);

            Console.WriteLine();
            Console.ReadLine();
        }