コード例 #1
0
 public NoteWindow(CampaignSave state, BaseNote note, decimal timestamp = 0, Dictionary <Guid, Topic> topics = null)
 {
     this.valid          = false;
     this.state          = state;
     this.note           = note.copy();
     this.topic_rows     = new List <TopicRow>();
     this.topics_by_name = new Dictionary <string, Guid>();
     if (topics is null)
     {
         this.topics_by_guid = new Dictionary <Guid, Topic>();
         foreach (Guid guid in state.domain.topics.Keys)
         {
             this.topics_by_guid[guid] = state.domain.topics[guid];
             this.topics_by_name[state.domain.topics[guid].name] = guid;
         }
     }
     else
     {
         this.topics_by_guid = topics;
         foreach (Guid guid in topics.Keys)
         {
             this.topics_by_name[topics[guid].name] = guid;
         }
     }
     this.populate_topic_rows();
     InitializeComponent();
     if (note is Note internal_note)
     {
         foreach (Entry entry in this.state.domain.entries)
         {
             if (entry.guid == internal_note.entry_guid)
             {
                 timestamp = entry.timestamp;
                 break;
             }
         }
         this.timestamp_box.Text = state.calendar.format_timestamp(timestamp);
     }
     if (note is ExternalNote external_note)
     {
         this.timestamp_box.Text = external_note.timestamp.ToString();
     }
     this.contents_box.Text      = note.contents;
     this.topic_list.ItemsSource = this.topic_rows;
 }
コード例 #2
0
        public ItemAddWindow(CampaignSave save_state, CampaignState state, Guid?guid = null, InventoryItemIdent selected = null, InventoryEntry entry = null)
        {
            this.valid               = false;
            this.need_refresh        = false;
            this.state               = save_state;
            this.entry               = entry;
            this.item                = entry?.item;
            this.inventory_rows      = new ObservableCollection <InventoryItemBaseRow>();
            this.inventory_row_index = new Dictionary <InventoryItemIdent, InventoryItemRow>();
            this.inventory_capacity  = new Dictionary <InventoryItemIdent, decimal>();
            this.populate_inventories(state, guid, selected);
            InitializeComponent();
            Visibility item_visibility = (guid is null ? Visibility.Collapsed : Visibility.Visible);

            this.item_label.Visibility         = item_visibility;
            this.item_box.Visibility           = item_visibility;
            this.item_set_but.Visibility       = item_visibility;
            this.count_label.Visibility        = item_visibility;
            this.count_box.Visibility          = item_visibility;
            this.unidentified_label.Visibility = item_visibility;
            this.unidentified_box.Visibility   = item_visibility;
            this.inventory_list.ItemsSource    = this.inventory_rows;
        }
コード例 #3
0
 public TaskWindow(CampaignSave save_state, CampaignState state, Calendar calendar, decimal now, Guid?entry_guid = null, Guid?guid = null)
 {
     this.valid      = false;
     this.save_state = save_state;
     this.state      = state.copy();
     this.now        = now;
     this.actions    = new List <EntryAction>();
     if (guid is null)
     {
         if (entry_guid is null)
         {
             throw new ArgumentNullException(nameof(entry_guid));
         }
         this.guid = Guid.NewGuid();
         ActionTaskCreate add_action = new ActionTaskCreate(this.guid, new Task(entry_guid.Value, ""));
         this.actions.Add(add_action);
         this.task = add_action.task;
     }
     else
     {
         this.guid = guid.Value;
         this.task = this.state.tasks.tasks[this.guid];
     }
     InitializeComponent();
     this.name_box.Text              = this.task.name;
     this.description_box.Text       = this.task.description;
     this.current_timestamp_box.Text = calendar.format_timestamp(now);
     if (this.task.completed_guid is null)
     {
         FrameworkElement due_box = calendar.timestamp_control();
         Grid.SetRow(due_box, 2);
         Grid.SetColumn(due_box, 1);
         this.main_grid.Children.Add(due_box);
         this.due_box = due_box as ICalendarControl;
         if (this.due_box is null)
         {
             throw new InvalidOperationException();
         }
         FrameworkElement due_diff_box = calendar.interval_control();
         Grid.SetRow(due_diff_box, 2);
         Grid.SetColumn(due_diff_box, 3);
         this.main_grid.Children.Add(due_diff_box);
         this.due_diff_box = due_diff_box as ICalendarControl;
         if (this.due_diff_box is null)
         {
             throw new InvalidOperationException();
         }
         if (this.task.due is null)
         {
             this.due_checkbox.IsChecked      = false;
             this.due_box.calendar_value      = now;
             this.due_box.IsReadOnly          = true;
             this.due_diff_box.calendar_value = 0;
             this.due_diff_box.IsReadOnly     = true;
         }
         else
         {
             this.due_checkbox.IsChecked = true;
             this.due_box.calendar_value = this.task.due.Value;
             this.due_box.IsReadOnly     = false;
             decimal due_diff = this.task.due.Value - now;
             if (due_diff < 0)
             {
                 this.timestamp_diff_label.Content = "before";
                 due_diff = -due_diff;
             }
             else
             {
                 this.timestamp_diff_label.Content = "after";
             }
             this.due_diff_box.calendar_value = due_diff;
             this.due_diff_box.IsReadOnly     = false;
         }
         this.due_box.value_changed      = this.due_changed;
         this.due_diff_box.value_changed = this.due_diff_changed;
     }
     else
     {
         decimal?completed_timestamp = null;
         if (task.completed_guid == entry_guid)
         {
             completed_timestamp = now;
         }
         else
         {
             foreach (Entry entry in this.save_state.domain.entries)
             {
                 if (entry.guid == task.completed_guid)
                 {
                     completed_timestamp = entry.timestamp;
                     break;
                 }
             }
         }
         if (completed_timestamp is null)
         {
             throw new InvalidOperationException();
         }
         if (this.task.failed)
         {
             this.status_label.Content = "Failed:";
         }
         else
         {
             this.status_label.Content = "Completed:";
         }
         this.status_label.Visibility  = Visibility.Visible;
         this.due_checkbox.Visibility  = Visibility.Collapsed;
         this.timestamp_box.Text       = calendar.format_timestamp(completed_timestamp.Value);
         this.timestamp_box.Visibility = Visibility.Visible;
         decimal timestamp_diff = completed_timestamp.Value - now;
         if (timestamp_diff < 0)
         {
             this.timestamp_diff_label.Content = "before";
             timestamp_diff = -timestamp_diff;
         }
         else
         {
             this.timestamp_diff_label.Content = "after";
         }
         this.timestamp_diff_box.Text       = calendar.format_interval(timestamp_diff);
         this.timestamp_diff_box.Visibility = Visibility.Visible;
     }
 }
コード例 #4
0
        public EntryWindow(CampaignSave save_state, int entry = -1, List <EntryAction> actions = null)
        {
            this.valid      = false;
            this.save_state = save_state;
            this.entry      = entry;
            this.entries    = new List <Entry>();
            for (int i = 0; i < save_state.domain.entries.Count; i++)
            {
                if (i != entry)
                {
                    this.entries.Add(save_state.domain.entries[i]);
                }
            }
            if ((entry >= 0) && (entry < save_state.domain.valid_entries))
            {
                this.state = save_state.domain.get_entry_state(entry);
            }
            else
            {
                this.state = save_state.domain.state.copy();
            }
            Entry previous_entry = null, current_entry;

            if ((entry >= 0) && (entry < save_state.domain.entries.Count))
            {
                current_entry = save_state.domain.entries[entry];
                if (entry > 0)
                {
                    this.previous_entry_idx = entry - 1;
                    previous_entry          = this.entries[entry - 1];
                }
            }
            else
            {
                decimal timestamp;
                int     session;
                if (save_state.domain.valid_entries > 0)
                {
                    this.previous_entry_idx = save_state.domain.valid_entries - 1;
                    previous_entry          = this.entries[this.previous_entry_idx];
                    timestamp = previous_entry.timestamp + 1;
                }
                else
                {
                    timestamp = save_state.calendar.default_timestamp;
                }
                session = previous_entry?.session ?? 1;
                if ((previous_entry is not null) && ((DateTime.Now - previous_entry.created) >= SESSION_DOWNTIME_THRESHOLD))
                {
                    session += 1;
                }
                current_entry = new Entry(timestamp, DateTime.Now, "", session, actions);
                if (actions is not null)
                {
                    foreach (EntryAction action in actions)
                    {
                        action.apply(this.state, current_entry);
                    }
                }
            }
            this.actions = new List <EntryAction>();
            this.add_actions(current_entry.actions, false);
            InitializeComponent();
            this.session_box.textBox.VerticalContentAlignment = VerticalAlignment.Center;
            this.session_box.Value = current_entry.session ?? 0;
            this.created_time_box.textBox.VerticalContentAlignment = VerticalAlignment.Center;
            this.created_time_box.Pattern      = CultureInfo.CurrentCulture.DateTimeFormat.LongTimePattern;
            this.created_date_box.SelectedDate = current_entry.created.Date;
            this.created_time_box.Value        = current_entry.created.TimeOfDay.TotalSeconds;
            FrameworkElement timestamp_box = save_state.calendar.timestamp_control();

            Grid.SetRow(timestamp_box, 0);
            Grid.SetColumn(timestamp_box, 6);
            this.header_grid.Children.Add(timestamp_box);
            this.timestamp_box = timestamp_box as ICalendarControl;
            if (this.timestamp_box is null)
            {
                throw new InvalidOperationException();
            }
            this.timestamp_box.calendar_value = current_entry.timestamp;
            FrameworkElement timestamp_diff_box = save_state.calendar.interval_control();

            Grid.SetRow(timestamp_diff_box, 0);
            Grid.SetColumn(timestamp_diff_box, 8);
            this.header_grid.Children.Add(timestamp_diff_box);
            this.timestamp_diff_box = timestamp_diff_box as ICalendarControl;
            if (this.timestamp_diff_box is null)
            {
                throw new InvalidOperationException();
            }
            this.timestamp_diff_box.calendar_value = (previous_entry is null ? 0 : current_entry.timestamp - previous_entry.timestamp);
            this.timestamp_box.value_changed       = this.timestamp_changed;
            this.timestamp_diff_box.value_changed  = this.timestamp_diff_changed;
            this.previous_entry_box.Text           = (previous_entry is null ? "n/a" : save_state.calendar.format_timestamp(previous_entry.timestamp));
            this.description_box.Text    = current_entry.description;
            this.action_list.ItemsSource = this.actions;
            this.event_list = new CalendarEventListControl(this.entry_action_callback, current_entry.guid);
            this.event_list.set_calendar(this.save_state.calendar);
            this.event_list.set_state(this.state, current_entry.timestamp);
            this.event_group.Content = this.event_list;
            this.character_list      = new CharacterListControl(this.entry_action_callback);
            this.character_list.set_char_sheet(this.save_state.character_sheet);
            this.character_list.set_state(this.state);
            this.character_group.Content = this.character_list;
            this.inventory_list          = new InventoryListControl(this.entry_action_callback);
            this.inventory_list.set_state(this.save_state, this.state);
            this.inventory_group.Content = this.inventory_list;
            this.topic_list = new TopicListControl(this.entry_action_callback, current_entry.guid);
            this.topic_list.set_state(this.save_state, this.state, current_entry.timestamp);
            this.topic_group.Content = this.topic_list;
            this.task_list           = new TaskListControl(this.entry_action_callback, current_entry.guid);
            this.task_list.set_calendar(this.save_state.calendar);
            this.task_list.set_state(this.save_state, this.state, current_entry.timestamp);
            this.task_group.Content = this.task_list;
        }