April 22, 2025, 04:02:09 AM

See more Support incidents in our old archived forum.

Author Topic: FGWorkingHoursBar with labeling  (Read 13395 times)

michael.fried

  • Customers
  • Newbie
  • *
  • Posts: 23
FGWorkingHoursBar with labeling
« on: October 14, 2014, 08:11:16 AM »
Hi,

Is there a possibility to add labeling to each seperate part of a FGWorkingHoursBar?

At the moment I just draw a text box with a higher Z-index over the full bar which enables me to label the bar in the left, middle or right corner. The desired behaviour is outlined below:


http://imgur.com/Z3Q8wvb

Kind regards,
Michael

Rajagopal

  • RQ Members
  • Full Member
  • *
  • Posts: 182
Re: FGWorkingHoursBar with labeling
« Reply #1 on: October 14, 2014, 04:44:35 PM »
Michael,

Can you tell us where the data for this label comes from?


Regards,
-Raja.

michael.fried

  • Customers
  • Newbie
  • *
  • Posts: 23
Re: FGWorkingHoursBar with labeling
« Reply #2 on: October 15, 2014, 02:45:27 PM »
Hi Raja,

The data will come from a dynamic data binding in the xaml file. At the moment im drawing a border over the whole bar and show the label only in the middle of the bar in textblock.


<view:FGWorkingHoursBar HorizontalAlignment="Stretch"
                                    TaskBrush="{StaticResource WorkingBarFill}"
                                    TaskStrokeBrush="Blue"
                                    NonWorkingTimeTaskBrush="{StaticResource NonWorkingBarFill}"
                                    NonWorkingTimeTaskStrokeBrush="Black"
                                    NonWorkingBarHeightProportion="10"
                                    TasksDontStartAndEndInNonWorkingTime="False"
                                    SchedulePropertyName="Schedule">
            </view:FGWorkingHoursBar>

<Border
                Canvas.ZIndex="2"
                Background="{Binding Styling.Background}"
                CornerRadius="{Binding Styling.BorderCornerRadius}"
                BorderBrush="{Binding Styling.BorderBrush}"
                BorderThickness="{Binding Styling.BorderThickness}"
                Effect="{Binding Styling.BorderEffect}"
                Opacity="0.9">
                <TextBlock Margin="1"
                           Foreground="{Binding Styling.Foreground}"
                           VerticalAlignment="Center"
                           HorizontalAlignment="Stretch"
                           TextAlignment="Center"
                           Text="{Binding Text}" />
            </Border>


The mockup in the post above only shows the desired behaviour.

Regards,
Michael

ForumAdmin

  • Administrator
  • Jr. Member
  • *****
  • Posts: 96
Re: FGWorkingHoursBar with labeling
« Reply #3 on: October 15, 2014, 09:38:07 PM »
Ok, we are working on this, we will update you soon.

Thanks
RadiantQ Support

ForumAdmin

  • Administrator
  • Jr. Member
  • *****
  • Posts: 96
Re: FGWorkingHoursBar with labeling
« Reply #4 on: October 16, 2014, 06:42:50 PM »
Michael,

We are planning on providing you a way to specify a "DataTemplate" in XAML which we will render within each "working hour bar". What would you need in the data context of this template that you will define?

- You will probably need the underlying "task" data object.
- Do you also need the start and end time of this "working hour bar"?
- Anything else?

Thanks
RadiantQ Support

michael.fried

  • Customers
  • Newbie
  • *
  • Posts: 23
Re: FGWorkingHoursBar with labeling
« Reply #5 on: October 23, 2014, 06:53:12 AM »
Hi,

Sorry for the late answer.

- You will probably need the underlying "task" data object.
yes

- Do you also need the start and end time of this "working hour bar"?
not necessarily but it wouldn't harm

- Anything else?
Tooltips but I do not necessarily need them for each working bar seperately.

Thanks a lot,
Michael

Rajagopal

  • RQ Members
  • Full Member
  • *
  • Posts: 182
Re: FGWorkingHoursBar with labeling
« Reply #6 on: October 24, 2014, 02:36:49 PM »
Michael,

We are looking on this, we will update you soon.


Regards,
-Raja.

ForumAdmin

  • Administrator
  • Jr. Member
  • *****
  • Posts: 96
Re: FGWorkingHoursBar with labeling
« Reply #7 on: October 27, 2014, 07:40:41 PM »
Michael,

We have now added support for adding some custom UI elements on top of the "working hours bar". We will send you an assembly by email shortly.

With that new assembly, you can create a custom class like below and use it in XAML to get a label (TextBlock) rendered on top of the working hours bar.

Code: [Select]
    public class MyFGWorkingHoursBar : FGWorkingHoursBar
    {
        protected override void OnAfterWorkingHoursBarCreated(Rectangle rectangle)
        {
            Task task = this.DataContext as Task;

            // Create a TextBlock with the same dim as rectangle.
            TextBlock tb = new TextBlock() { Margin = rectangle.Margin, Width = rectangle.Width, Height = rectangle.Height, HorizontalAlignment = System.Windows.HorizontalAlignment.Left, TextAlignment = TextAlignment.Center, VerticalAlignment = System.Windows.VerticalAlignment.Center };
            Canvas.SetZIndex(tb, 10); // To ensure that this render over the Rectangle.
            tb.Text = task.TaskName;
            this.Children.Add(tb);
        }
    }

You can then use the above in your XAML:
Code: [Select]
            <fxgantt:FlexyGantt.TaskItemTemplate>
                <DataTemplate>
                    <Grid Height="18" AllowDrop="True"
                          ToolTipService.ToolTip="{Binding StartTime}">

                        <local:MyFGWorkingHoursBar HorizontalAlignment="Stretch" TaskBrush="{StaticResource WorkingBarFill}" TaskStrokeBrush="Blue"
                                                 NonWorkingTimeTaskBrush="{StaticResource NonWorkingBarFill}" NonWorkingTimeTaskStrokeBrush="Black" NonWorkingBarHeightProportion="25"
                                                 SchedulePropertyName="Schedule"   >
                            </local:MyFGWorkingHoursBar>
                        ...........
                       
                    </Grid>
                   
                </DataTemplate>

Thanks
RadiantQ Support

michael.fried

  • Customers
  • Newbie
  • *
  • Posts: 23
Re: FGWorkingHoursBar with labeling
« Reply #8 on: October 28, 2014, 10:02:46 AM »
Awesome, your solution works like a charm.

Many thanks for the quick fix.

Best,
Michael

michael.fried

  • Customers
  • Newbie
  • *
  • Posts: 23
Re: FGWorkingHoursBar with labeling
« Reply #9 on: November 04, 2014, 08:54:34 AM »
Hello again,

The labeling works perfectly, however I'm still facing some rendering issues with the WorkingHour Bars. After rescheduling a task by dragging it (and in some cases even on startup) they do not align any more (i.e. Working hours do not visually match). Please see the following example using example FGTemplatizedForWorkingHours4.5 and the compiled 4.5_v6.5.4.1 you sent me.





Kind regards,
Michael

ForumAdmin

  • Administrator
  • Jr. Member
  • *****
  • Posts: 96
Re: FGWorkingHoursBar with labeling
« Reply #10 on: November 04, 2014, 08:18:59 PM »
Michael,

We seem to have trouble reproducing this issue. Just so we are both looking at the same data, could you replace this line in the sample:

// In GetSampleData method
            DateTime dtS = TimeComputingUtils.ToUtcKind(DateTime.Today - TimeSpan.FromDays(3));

with a concrete date (instead of based on Today), make sure you can reproduce the issue and then update us?

If you changed anything else in the sample, please do send the whole project to us.

Thanks
RQ Support

michael.fried

  • Customers
  • Newbie
  • *
  • Posts: 23
Re: FGWorkingHoursBar with labeling
« Reply #11 on: November 05, 2014, 08:40:11 AM »
Hi,

I tried with a concrete date which delivers the same error. But thanks to your hint I found the source.

The only line I changed in the sample project was TasksDontStartAndEndInNonWorkingTime= in xaml which is not included any more in the custom version 6.5.4.1 you sent me via email on 27.10.2014, thus leading to a compilation error if I hadn't deleted it. If you set the TasksDontStartAndEndInNonWorkingTime="True" the error will occur in your sample file too.

The error is visible if you shift Team1 - Resource2 just ever so slightly to the right or left. Also for Team3 - Resource2 you see that the bar is rendered improperly already on startup where the working hour Bar renders in the gray SAT/SUN area of Nov 8.-9.

Please also refer to my previous thread which addresses this issue.

http://newforum.radiantq.com/index.php?topic=15.0

In the custom version you sent me the presented solution is not applicaple since the inclusion of TasksDontStartAndEndInNonWorkingTime in the xaml leads to a compilation error but apparently in the background this defaults to true.

Kind regards,
Michael

ForumAdmin

  • Administrator
  • Jr. Member
  • *****
  • Posts: 96
Re: FGWorkingHoursBar with labeling
« Reply #12 on: November 06, 2014, 07:27:02 PM »
Michael,

Yes, there is no TasksDontStartAndEndInNonWorkingTime in the latest version.

We are however not seeing this issue in Team1-Resource 2 or Team3-Resource2. So, can you please do the below we requested in our previous update:

>>>>>>>>>>
Just so we are both looking at the same data, could you replace this line in the sample:

// In GetSampleData method
            DateTime dtS = TimeComputingUtils.ToUtcKind(DateTime.Today - TimeSpan.FromDays(3));

with a concrete date (instead of based on Today), make sure you can reproduce the issue and then update us?

>>>>>>>>>>

Thanks
RadiantQ Support

michael.fried

  • Customers
  • Newbie
  • *
  • Posts: 23
Re: FGWorkingHoursBar with labeling
« Reply #13 on: November 10, 2014, 12:14:03 PM »
Hi,

Very strange :)

I tested it with an actual date and am still facing the issue. I just sent you an email with src together with the FlexyGannt version I am using as well as two current screenshots. I hope it is easier to reconstruct the error that way.

Thanks for your time and effort,
Michael

ForumAdmin

  • Administrator
  • Jr. Member
  • *****
  • Posts: 96
Re: FGWorkingHoursBar with labeling
« Reply #14 on: November 11, 2014, 09:21:08 PM »
Michael,

In the MainPage constructor we had requested you to make these changes, once you do that bars render much better. Could you confirm:

Code: [Select]
            // Don't set WorkTimeSchedule anymore on the gantt.
            //this.fxgantt.WorkTimeSchedule = WorkTimeSchedule.Schedule8X5;
            // This will force the entire bar to be rendered, even the portions that are not visible.
            this.fxgantt.ApplyBarWidthOptimization = false;

Thanks
Support