Esempio n. 1
0
        private void ProcessInsertDesignIdea(int id)
        {
            TableTopDataClassesDataContext db = Configurations.GetTableTopDB();
            var designideas = from d in db.Contributions
                              where d.id == id
                              select d;

            if (designideas.Count() == 1)
            {
                Contribution di = designideas.Single <Contribution>();
                User         u  = find_user_of_contribution(di);
                Activity     a  = find_activity_of_contribution(di);
                if (u == null || a == null)
                {
                    return;
                }
                string   cid = a.technical_info.Split(new char[] { ';' })[0];
                SContext c   = server_api.GetContext(cid);
                if (c == null)
                {
                    return;
                }
                SNote note = server_api.CreateNote(u.name, "DesignIdea", di.note, c.name, di.status.ToString());
                if (note == null)
                {
                    return;
                }
                di.technical_info = note.id.ToString();
                db.SubmitChanges();
                if (RESTService.Last_Exception != null)
                {
                    this.errors.Add(RESTService.Last_Exception);
                }
            }
        }
        /*
         * public void MoveGridTargets(List<TargetGridMoveIntent> intents) {
         *      var action = new NRActionGridMoveNotes();
         *      action.targetGridMoveIntents = intents.Select(intent => new TargetGridMoveIntent(intent)).ToList();
         *      Tools.undoRedoManager.AddAction(action);
         * }
         *
         * public void MoveTimelineTargets(List<TargetTimelineMoveIntent> intents) {
         *      SortOrderedList();
         *      var action = new NRActionTimelineMoveNotes();
         *      action.targetTimelineMoveIntents = intents.Select(intent => new TargetTimelineMoveIntent(intent)).ToList();
         *      Tools.undoRedoManager.AddAction(action);
         * }
         *
         * public void PasteCues(List<SNoteData> cues, float pasteBeatTime) {
         *      // paste new targets in the original locations
         *      var targetDataList = cues.Select(copyData => {
         *              var data = new SNoteData(copyData);
         *
         *              if (data.behavior == TargetBehavior.NR_Pathbuilder) {
         *                      data.pathBuilderData = new PathBuilderData();
         *                      var note = FindNote(copyData);
         *                      if (note != null) {
         *                              data.pathBuilderData.Copy(note.data.pathBuilderData);
         *                      }
         *              }
         *
         *              return data;
         *      }).ToList();
         *
         *      // find the soonest target in the selection
         *      float earliestTargetBeatTime = Mathf.Infinity;
         *      foreach (SNoteData data in targetDataList) {
         *              float time = data.beatTime;
         *              if (time < earliestTargetBeatTime) {
         *                      earliestTargetBeatTime = time;
         *              }
         *      }
         *
         *      // shift all by the amount needed to move the earliest note to now
         *      float diff = pasteBeatTime - earliestTargetBeatTime;
         *      foreach (SNoteData data in targetDataList) {
         *              data.beatTime += diff;
         *      }
         *
         *      var action = new NRActionMultiAddNote();
         *      action.affectedTargets = targetDataList;
         *      Tools.undoRedoManager.AddAction(action);
         *
         *      DeselectAllTargets();
         *      FindNotes(targetDataList).ForEach(target => SelectTarget(target));
         * }
         *
         * // Invert the selected targets' colour
         * public void SwapTargets(List<SNote> targets) {
         *      var action = new NRActionSwapNoteColors();
         *      action.affectedTargets = targets.Select(target => target.data).ToList();
         *      Tools.undoRedoManager.AddAction(action);
         * }
         *
         * // Flip the selected targets on the grid about the X
         * public void FlipTargetsHorizontal(List<SNote> targets) {
         *      var action = new NRActionHFlipNotes();
         *      action.affectedTargets = targets.Select(target => target.data).ToList();
         *      Tools.undoRedoManager.AddAction(action);
         * }
         *
         * // Flip the selected targets on the grid about the Y
         * public void FlipTargetsVertical(List<SNote> targets) {
         *      var action = new NRActionVFlipNotes();
         *      action.affectedTargets = targets.Select(target => target.data).ToList();
         *      Tools.undoRedoManager.AddAction(action);
         * }
         *
         * public void SetTargetHitsounds(List<TargetSetHitsoundIntent> intents) {
         *      var action = new NRActionSetTargetHitsound();
         *      action.targetSetHitsoundIntents = intents.Select(intent => new TargetSetHitsoundIntent(intent)).ToList();
         *      Tools.undoRedoManager.AddAction(action);
         * }
         *
         */

        public void DeleteTarget(SNote target)
        {
            var action = new NSActionRemoveNote {
                noteData = target.data
            };

            _actionManager.AddAction(action);
        }
 public void SelectTarget(SNote note)
 {
     if (!selectedNotes.Contains(note))
     {
         selectedNotes.Add(note);
         note.Select();
     }
 }
Esempio n. 4
0
 public bool IsNoteInSelectionRectangle(SNote note, float key)
 {
     if (SelectionRectangle == null)
     {
         return(false);
     }
     return(IsNoteInRectangle(note, key, SelectionRectangle ?? new Rectangle()));
 }
Esempio n. 5
0
    // Window constructor.
    public Vidmot()
        : base("Dagateljari")
    {
        total = new VBox();
        tns = new TNS();
        sna = new SNA();
        hbButtons = new HBox();
        btnL = new Button("New Sticky Note");
        btnR = new Button("Close Application");
        // Bound to 100 SNotes.
        snote = new SNote[100];
        // Initially 0 SNotes stored in each run.
        snCount = 0;
        messagePass = new SNote(this);
        // Delete function widgets.
        extraR = new Button("Delete this note");
        extraL = new Label("");
        extraBox = new HBox();

        // Load stored SNotes from previous run.
        Loader.readSNotes(this);
        snote = Loader.getSNotes();
        snCount = Loader.getSnCount();
        int n=0;
        while(snote[n] is SNote)
        {
            tns.addSNote(snote[n], snote[n].getStatus());
            n++;
        }

        hbButtons.Homogeneous = true;
        hbButtons.Add(btnL);
        hbButtons.Add(btnR);

        extraBox.Homogeneous = true;
        extraBox.Add(extraL);
        extraBox.Add(extraR);

        // Set functions.
        btnL.Clicked += onBtnTnsLClicked;
        btnR.Clicked += onBtnTnsRClicked;
        extraR.Clicked += onBtnExtraRClicked;

        DeleteEvent += delegate
        {
            Loader.writeSNotes(snote, snCount);
            Application.Quit();
        };

        total.PackStart(tns, true, true, 0);
        total.PackStart(hbButtons, false, false, 10);

        Add(total);

        // Set initial window size.
        SetDefaultSize(400,500);
        ShowAll();
    }
Esempio n. 6
0
        private void ProcessDeleteDesignIdea(string note_id)
        {
            SNote note = server_api.DeleteNote(note_id);

            if (RESTService.Last_Exception != null)
            {
                this.errors.Add(RESTService.Last_Exception);
            }
        }
Esempio n. 7
0
        private bool create_contribution(SNote note, SMedia media, DateTime note_date, DateTime note_mod_date, string content, string note_id, bool is_design_idea, int collection_id, string status, TableTopDataClassesDataContext db)
        {
            Contribution c = new Contribution();

            c.date          = note_date;
            c.modified_date = note_mod_date;
            c.location_id   = find_location_id(note);
            string note_content = content;

            if (media != null)
            {
                c.media_url = media.link;
            }
            else
            {
                c.media_url = "";
            }

            c.note   = note_content;
            c.status = status;
            if (is_design_idea)
            {
                c.tags = "Design Idea";
            }
            else
            {
                if (media != null)
                {
                    c.tags = media.kind;
                }
                else
                {
                    c.tags = note.kind;
                }
            }
            c.technical_info = note_id;
            c.web_username   = note.webusername;
            db.Contributions.InsertOnSubmit(c);
            if (!SubmitChangesToLocalDB(db))
            {
                return(false);
            }
            //
            Collection_Contribution_Mapping map = new Collection_Contribution_Mapping();

            map.collection_id   = collection_id;
            map.contribution_id = c.id;
            map.date            = note_date;
            db.Collection_Contribution_Mappings.InsertOnSubmit(map);
            if (!SubmitChangesToLocalDB(db))
            {
                return(false);
            }
            return(true);
        }
        public void DeselectTarget(SNote target, bool resettingAll = false)
        {
            if (selectedNotes.Contains(target))
            {
                target.Deselect();

                if (!resettingAll)
                {
                    selectedNotes.Remove(target);
                }
            }
        }
Esempio n. 9
0
 // Before: parent is a class with a SNote array.
 // After:  SNotes with values from filename
 //         have been set up and the SNotes are
 //         loaded to snote. SNotes have a pointer
 //         to parent.
 public static void readSNotes(Vidmot parent)
 {
     snote = new SNote[100];
     try
     {
         table = Value.LoadFile(filename);
     }
     catch(Exception)
     {
         table = null;
     }
     // If nothing loaded from filename
     // then snote is initialized, empty
     // and correct.
     if(table==null)
     {
         snCount=0;
         return;
     }
     // Data invariant:
     // * i is an index to table values.
     // * n is an index to snote values.
     int i=0,
         n=0;
     // After: Values have been loaded from
     // table (from filename) into n SNotes
     // and the SNotes stored in snote.
     while(table[i.ToString()] != null)
     {
         string[] info = new string[4];
         info[0] = (string) table[i.ToString()];
         i++;
         info[1] = (string) table[i.ToString()];
         i++;
         info[2] = (string) table[i.ToString()];
         i++;
         info[3] = (string) table[i.ToString()];
         i++;
         int status = (int) table[i.ToString()];
         i++;
         snote[n] = new SNote(parent);
         snote[n].updateInfo(
                 info[0],
                 info[1],
                 info[2],
                 info[3],
                 status);
         n++;
     }
     snCount = n;
 }
Esempio n. 10
0
        private string get_note_info(SNote n)
        {
            string status = "";

            if (n.status != null)
            {
                status = n.status;
            }
            string r = n.id + "," + n.kind + "," + n.content + "," + n.created_at + "," +
                       n.modified_at + "," + status + "," + n.longitude + "," + n.latitude + "," +
                       n.account.id + "," + n.context.id;

            return(r);
        }
Esempio n. 11
0
 private string find_landmark(SNote note)
 {
     if (note.feedbacks.Count > 0)
     {
         for (int counter = 0; counter < note.feedbacks.Count; counter++)
         {
             if (note.feedbacks[counter].kind == "Landmark")
             {
                 return(note.feedbacks[counter].content);
             }
         }
     }
     return("");
 }
Esempio n. 12
0
        public static bool IsNoteInRectangle(SNote note, float key, Rectangle rect)
        {
            if (rect.Left > note.End || rect.Right < note.Start)
            {
                return(false);
            }


            if (rect.Top > key + 1 || rect.Bottom < key)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 13
0
        private int find_location_id(SNote note)
        {
            int    location_id = 0;
            string landmark    = find_landmark(note);

            if (landmark != "")
            {
                try { location_id = Convert.ToInt32(landmark.Substring(Configurations.GetSiteNameForServer().Length + "landmark".Length + 1)); }
                catch (Exception) { location_id = Configurations.FindLocationID(note.latitude, note.longitude); }
            }
            else
            {
                location_id = Configurations.FindLocationID(note.latitude, note.longitude);
            }
            return(location_id);
        }
        public void DeleteTargetFromAction(SNoteData noteData)
        {
            SNote note = FindNote(noteData);

            if (note == null)
            {
                return;
            }

            notes.Remove(note);
            orderedNotes.Remove(note);
            selectedNotes.Remove(note);

            note.Destroy(this);
            note = null;
        }
Esempio n. 15
0
        private void ProcessUpdateDesignIdea(int id)
        {
            TableTopDataClassesDataContext db = Configurations.GetTableTopDB();
            var designideas = from d in db.Design_Ideas
                              where d.id == id
                              select d;

            if (designideas.Count() == 1)
            {
                Design_Idea di   = designideas.Single <Design_Idea>();
                SNote       note = server_api.UpdateNote(di.technical_info, di.status.ToString());
                if (RESTService.Last_Exception != null)
                {
                    this.errors.Add(RESTService.Last_Exception);
                }
            }
        }
        public SNote FindNote(SNoteData data)
        {
            int idx = BinarySearchOrderedNotes(data.beatTime);

            if (idx == -1)
            {
                Debug.LogWarning("Couldn't find note with time " + data.beatTime);
                return(null);
            }

            for (int i = idx; i < orderedNotes.Count; ++i)
            {
                SNote t = orderedNotes[i];
                if (t.data.ID == data.ID)
                {
                    return(t);
                }
            }

            Debug.LogWarning("Couldn't find note with time " + data.beatTime + " and index " + idx);
            return(null);
        }
        public SNoteData FindNoteData(float beatTime, SNoteType noteType)
        {
            int idx = BinarySearchOrderedNotes(beatTime);

            if (idx == -1)
            {
                Debug.LogWarning("Couldn't find note with time " + beatTime);
                return(null);
            }

            for (int i = idx; i < orderedNotes.Count; ++i)
            {
                SNote t = orderedNotes[i];
                if (FastApproximately(t.data.beatTime, beatTime) &&
                    t.data.noteType == noteType)
                {
                    return(t.data);
                }
            }

            Debug.LogWarning("Couldn't find note with time " + beatTime + " and index " + idx);
            return(null);
        }
        //Adds a target directly to the timeline. targetData is kept as a reference NOT copied
        public SNote AddNoteFromAction(SNoteData data)
        {
            var timelineTargetIcon = Instantiate(_timelineNotePF, _timelineNotesTrans);
            //timelineTargetIcon.location = TargetIconLocation.Timeline;
            //var transform1 = timelineTargetIcon.transform;
            //transform1.localPosition = new Vector3(targetData.beatTime, 0, 0);

            //Vector3 noteScale = transform1.localScale;
            //noteScale.x = targetScale;
            //transform1.localScale = noteScale;

            //TODO: add timeline notes

            var gridNote = Instantiate(_gridNotePF, _gridNotesTrans);

            gridNote.transform.localPosition = new Vector3(data.x, data.y, data.beatTime);

            SNote note = new SNote(data, gridNote.GetComponent <SNoteBehavior>());

            notes.Add(note);
            orderedNotes = notes.OrderBy(v => v.data.beatTime).ToList();

            //TODO: MORE EVENTS
            //Subscribe to the delete note event so we can delete it if the user wants. And other events.
            //note.DeleteNoteEvent += DeleteTarget;

            //target.TargetSelectEvent += SelectTarget;
            //target.TargetDeselectEvent += DeselectTarget;


            //Trigger all callbacks on the note
            data.Copy(data);


            return(note);
        }
Esempio n. 19
0
        public void DeselectNote(SNote note)
        {
            var selected = new SelectedSNote(note, -1);

            DeselectNote(selected);
        }
Esempio n. 20
0
 public bool IsNoteSelected(SNote note)
 {
     return(IsNoteSelected(new SelectedSNote(note, -1)));
 }
Esempio n. 21
0
 public void SelectNote(SNote note, int key)
 {
     SelectNote(new SelectedSNote(note, key));
 }
Esempio n. 22
0
 // state is !(1||2) for todo, 1 doing 2 done.
 // After: snote has been added to TNS in column
 // according to state.
 public void addSNote(SNote snote, int state)
 {
     switch(state)
     {
         case 1:
             doing.PackStart(snote, false, false, 10);
             break;
         case 2:
             done.PackStart(snote, false, false, 10);
             break;
         default:
             todo.PackStart(snote, false, false, 10);
             break;
     }
 }
Esempio n. 23
0
 // After: snote has been removed from column defined
 // by snote.getStatus().
 public void removeSNote(SNote snote)
 {
     switch(snote.getStatus())
     {
         case 1:
             doing.Remove(snote);
             break;
         case 2:
             done.Remove(snote);
             break;
         default:
             todo.Remove(snote);
             break;
     }
 }
Esempio n. 24
0
 // Before: View is TNS.
 // After:  View is SNA.
 private void onBtnSnaLClicked(
         object source,
         EventArgs args)
 {
     // Demand title for each SNote.
     if(sna.getTitle() != "")
     {
     snote[snCount] = new SNote(this);
     snote[snCount] = createSNote();
     // Stuck at adding to todo.
     tns.addSNote(snote[snCount++], sna.getStatus());
     }
     btnL.Clicked -= onBtnSnaLClicked;
     btnR.Clicked -= onBtnSnaRClicked;
     btnL.Clicked += onBtnTnsLClicked;
     btnR.Clicked += onBtnTnsRClicked;
     btnL.Label = "New Sticky Note";
     btnR.Label = "Close Application";
     updateView(tns, sna, false);
     ShowAll();
 }
Esempio n. 25
0
 // Usage:  snote = Vidmot.createSNote();
 // Before: The view is SNA.
 // After:  snote is a new SNote with values
 //         from SNA fields.
 private SNote createSNote()
 {
     SNote snote = new SNote(this);
     snote.updateInfo(
             sna.getTitle(),
             sna.getComment(),
             sna.getDate(),
             sna.getPrio(),
             sna.getStatus());
     return snote;
 }
Esempio n. 26
0
    // Usage:  Vidmot.changeSNote(snote);
    // Before: View is TNS, snote exists.
    // After:  View is SNA where fields
    //         are set to snote values.
    public void changeSNote(SNote snote)
    {
        btnL.Clicked -= onBtnTnsLClicked;
        btnR.Clicked -= onBtnTnsRClicked;
        btnL.Clicked += onBtnSnaCLClicked;
        btnR.Clicked += onBtnSnaCRClicked;
        btnL.Label = "Save & Return";
        btnR.Label = "Return";
        updateView(sna, tns, true);
        ShowAll();

        string[] info = snote.getInfo();
        sna.setTitle(info[0]);
        sna.setComment(info[1]);
        sna.setDate(info[2]);
        sna.setPrio(info[3]);
        sna.setStatus(snote.getStatus());
        this.messagePass = snote;
    }
Esempio n. 27
0
 // Before: snote is an array of SNotes and snCount points
 // is the upper bound of the number of SNotes in the array.
 // After:  SNotes of snote have been stored in filename.
 public static void writeSNotes(SNote[] snote, int snCount)
 {
     // Data invariant:
     // * i is an index for table values.
     // * n is an index for snote values.
     table = Value.MakeTable();
     int i=0;
     int n=0;
     // Iterate over all possible places with
     // SNotes in snote.
     while(n!=snCount)
     {
         // If SNote in snote has title,
         // write that SNote to file,
         // if not then move on to next
         // possible SNote in snote.
         if(snote[n].getInfo()[0] != "")
         {
             string[] info = snote[n].getInfo();
             int status = snote[n].getStatus();
             table[i.ToString()] = info[0];
             i++;
             table[i.ToString()] = info[1];
             i++;
             table[i.ToString()] = info[2];
             i++;
             table[i.ToString()] = info[3];
             i++;
             table[i.ToString()] = status;
             i++;
             n++;
         }
         else
         {
             n++;
         }
     }
     Value.SaveFile(table, filename);
 }