Brush getBrush(EntryObjectDTO entry)
        {
            Type type = entry.GetType();

            if (type == typeof(StrengthTrainingEntryDTO))
            {
                return(EntryObjectColors.StrengthTraining);
            }
            else if (type == typeof(SuplementsEntryDTO))
            {
                return(EntryObjectColors.Supplements);
            }
            if (type == typeof(BlogEntryDTO))
            {
                return(EntryObjectColors.Blog);
            }
            if (type == typeof(GPSTrackerEntryDTO))
            {
                return(EntryObjectColors.GPSTracker);
            }
            if (type == typeof(A6WEntryDTO))
            {
                return(EntryObjectColors.A6W);
            }
            if (type == typeof(SizeEntryDTO))
            {
                return(EntryObjectColors.Measurements);
            }
            return(null);
        }
        string getImage(EntryObjectDTO entry)
        {
            Type type = entry.GetType();

            if (type == typeof(StrengthTrainingEntryDTO))
            {
                return("/Images/strengthTrainingTile.jpg");
            }
            else if (type == typeof(SuplementsEntryDTO))
            {
                return("/Images/suppleTile.jpg");
            }
            if (type == typeof(BlogEntryDTO))
            {
                return("/Images/blogTile.jpg");
            }
            if (type == typeof(GPSTrackerEntryDTO))
            {
                return("/Images/gpsTile.jpg");
            }
            if (type == typeof(SizeEntryDTO))
            {
                return("/Images/sizesTile.jpg");
            }
            return(null);
        }
Example #3
0
        public bool SaveTrainingDay(bool isWindowClosing)
        {
            if (!validateControls())
            {
                return(false);
            }
            foreach (XtraTabPage tabPage in xtraTabControl1.TabPages)
            {
                IEntryObjectControl entryControl = (IEntryObjectControl)tabPage.Controls[0];
                entryControl.UpdateEntryObject();
            }

            if (day.Id == Constants.UnsavedObjectId && day.IsEmpty)
            {
                return(true);
            }

            day = ServiceManager.SaveTrainingDay(day);

            foreach (var module in PluginsManager.Instance.Modules)
            {
                module.AfterSave(UserContext.SessionData, day);
            }

            if (isWindowClosing)
            {//optimalization - we are closing window so we don't need to refresh the tabs (code below)
                return(true);
            }
            for (int index = xtraTabControl1.TabPages.Count - 1; index >= 0; index--)
            {
                XtraTabPage         tabPage      = xtraTabControl1.TabPages[index];
                IEntryObjectControl entryControl = tabPage.Controls[0] as IEntryObjectControl;
                if (entryControl != null)
                {
                    ParentWindow.SynchronizationContext.Send(delegate
                    {
                        entryControl.AfterSave(isWindowClosing);
                        EntryObjectDTO entry =
                            (EntryObjectDTO)tabPage.Controls[0].Tag;
                        //here we assume that training day contains only one instance of the specific entry type
                        var newEntry =
                            day.GetSpecifiedEntries(entry.GetType());
                        if (newEntry != null)
                        {
                            tabPage.Controls[0].Tag = newEntry;
                            entryControl.Fill(newEntry);
                        }
                        else
                        {
                            xtraTabControl1.TabPages.Remove(tabPage);
                        }
                    }, null);
                }
            }

            return(true);
        }
Example #4
0
        public bool PostEntryObject(EntryObjectDTO entry)
        {
            var provider = PluginsManager.Instance.GetEntryObjectProvider(entry.GetType());

            if (provider != null)
            {
                var content = provider.ShareToSocial(entry);
                if (content != null)
                {
                    PostNote(content);
                    return(true);
                }
            }
            return(false);
        }
Example #5
0
        private bool createNewEntryControl(EntryObjectDTO entry, bool select)
        {
            if (entry.IsLoaded)
            {
                try
                {
                    PluginsManager.Instance.GetEntryObjectProvider(entry.GetType()).PrepareNewEntryObject(UserContext.SessionData, entry, day);

                    Control     ctrl    = (Control)Activator.CreateInstance(EntryObjectControlManager.Instance.Controls[entry.GetType()]);
                    XtraTabPage tabPage = new XtraTabPage();
                    tabPage.Text            = getEntryTabText(entry);
                    ctrl.Dock               = DockStyle.Fill;
                    tabPage.ShowCloseButton = ReadOnly ? DefaultBoolean.False : DefaultBoolean.True;
                    ctrl.Tag = tabPage.Tag = entry;
                    tabPage.Controls.Add(ctrl);
                    xtraTabControl1.TabPages.Add(tabPage);
                    xtraTabControl1.SelectedTabPage = tabPage;

                    var entryCtrl = (IEntryObjectControl)ctrl;
                    entryCtrl.ReadOnly = ReadOnly;
                    entryCtrl.Fill(entry);
                    updateButtons();
                }
                catch (TrainingIntegrationException ex)
                {
                    ExceptionHandler.Default.Process(ex, ApplicationStrings.ErrorTrainingIntegrity, ErrorWindow.MessageBox);
                    return(false);
                }
                catch (Exception ex)
                {
                    ExceptionHandler.Default.Process(ex, ApplicationStrings.ErrorUnhandledException, ErrorWindow.EMailReport);
                    return(false);
                }
            }
            return(true);
        }
Example #6
0
 public static string GetEntryObjectText(this EntryObjectDTO entry)
 {
     return(string.IsNullOrWhiteSpace(entry.Name) ? EntryObjectLocalizationManager.Instance.GetString(entry.GetType(), EnumLocalizer.EntryObjectName) : entry.Name);
 }
Example #7
0
        private bool createNewEntryControl(EntryObjectDTO entry, bool @select, SaveTrainingDayResult saveResult)
        {
            if (entry.IsLoaded)
            {
                try
                {
                    var ctrl = (Control)Activator.CreateInstance(EntryObjectControlManager.Instance.Controls[entry.GetType()]);
                    // var tabPage = new TabItem();
                    string text = entry.GetEntryObjectText();

                    ctrl.Tag = entry;
                    var entryCtrl = (IEntryObjectControl)ctrl;
                    entryCtrl.ReadOnly = ReadOnly || entry.Status == EntryObjectStatus.System;

                    TabItemViewModel tabItem = new TabItemViewModel();
                    tabItem.CloseButtonVisible = !ReadOnly;
                    tabItem.Header             = text;
                    tabItem.Content            = ctrl;
                    tabItem.IsFromReservation  = entry.ReservationId.HasValue;
                    tabItem.EntryObject        = entry;
                    tabs.Add(tabItem);
                    xtraTabControl1.SelectedItem = tabItem;

                    //EntryObjectDTO originalEntry = null;
                    //if(originalDay!=null)
                    //{
                    //    originalEntry=originalDay.Objects.Where(x => x.GlobalId == entry.GlobalId).SingleOrDefault();
                    //    if(originalEntry==null)
                    //    {//when originalDay is not null then we now that this is a Saving mode. So we imitate empty instance to have a comparison
                    //        originalEntry = (EntryObjectDTO)Activator.CreateInstance(entry.GetType());
                    //    }
                    //}

                    entryCtrl.Fill(entry, saveResult);
                    updateButtons();
                }
                catch (TrainingIntegrationException ex)
                {
                    ExceptionHandler.Default.Process(ex, Strings.ErrorTrainingIntegrity, ErrorWindow.MessageBox);
                    return(false);
                }
                catch (Exception ex)
                {
                    ExceptionHandler.Default.Process(ex, Strings.ErrorUnhandledException, ErrorWindow.EMailReport);
                    return(false);
                }
            }
            return(true);
        }
Example #8
0
 private HyperlinkButton addButton(EntryObjectDTO existingObject)
 {
     return(addButton(existingObject.GetType(), existingObject));
 }
Example #9
0
 private string getEntryTabText(EntryObjectDTO entry)
 {
     return(string.IsNullOrWhiteSpace(entry.Name) ? EntryObjectLocalizationManager.Instance.GetString(entry.GetType(), LocalizationConstants.EntryObjectName) : entry.Name);
 }