Ejemplo n.º 1
0
 private GestureFrame MakeNewGestureFrame()
 {
     GestureFrame newFrame = new GestureFrame();
       for (int i = 0; i < 400; i++)
       {
     newFrame.FrontCells[i] = new GestureFrameCell() { IndexInFrame = i, IsHotspot = false };
     newFrame.SideCells[i] = new GestureFrameCell() { IndexInFrame = i, IsHotspot = false };
       }
       return newFrame;
 }
Ejemplo n.º 2
0
 private GestureFrame DeepCopyGestureFrame(GestureFrame sourceFrame)
 {
     GestureFrame targetFrame = new GestureFrame();
       for (int i = 0; i < 400; i++)
       {
     targetFrame.FrontCells[i] = new GestureFrameCell()
     {
       IndexInFrame = sourceFrame.FrontCells[i].IndexInFrame,
       IsHotspot = sourceFrame.FrontCells[i].IsHotspot
     };
     targetFrame.SideCells[i] = new GestureFrameCell()
     {
       IndexInFrame = sourceFrame.SideCells[i].IndexInFrame,
       IsHotspot = sourceFrame.SideCells[i].IsHotspot
     };
       }
       return targetFrame;
 }
Ejemplo n.º 3
0
    public void DeleteFrame(GestureFrame f)
    {
      if (f == null) return;

      Gesture g = (Gesture)TheWorkspace.DataContext;
      if (g == null) return;

      g.Frames.Remove(f);

      if (g.Frames.Count == 0)
        g.Frames.Add(MakeNewGestureFrame()); // Do not let a gesture have 0 frames //TODO: having 0-framed gestures could be useful for creating named libraries of keyboard shortcuts as templates (say one library for PowerPoint, one for Media Player etc.) to which a user can then fill-in the gesture frames (would need the Visualizer to be aware of that and also maybe show the respective gestures colored as red - to signify they're not yet complete)

      if (FramesListBox.SelectedItem == null)
        FramesListBox.SelectedIndex = FramesListBox.Items.Count - 1;

      SyncEditorGrids();
    }
Ejemplo n.º 4
0
    public void MoveFrameBackwards(GestureFrame f)
    {
      if (f == null) return;

      Gesture g = (Gesture)TheWorkspace.DataContext;
      if (g == null) return;

      int fIndex = g.Frames.IndexOf(f);
      if (fIndex == 0)
        g.Frames.Move(fIndex, g.Frames.Count - 1);
      else
        g.Frames.Move(fIndex, fIndex - 1);

      SyncEditorGrids();
    }
        public void LoadGestureCollection(string filename)
        {
            string json = File.ReadAllText(filename);
              // DeserializeObject() does not appear to correctly deserialize Gesture objects
              // Below is a kinda-dirty solution around that
              List<Gesture> sourceList = JsonConvert.DeserializeObject<List<Gesture>>(json);
              GestureCollection.Clear();

              foreach (Gesture sourceGesture in sourceList)
              {
            RemoveNoneKeys(sourceGesture.Command); //Seems somewhere at the serialization or deserialization Key.None creeps in, so remove it

            //copy sourceGesture to targetGesture //TODO: check why this copying is needed
            Gesture targetGesture = new Gesture()
            {
              Name = sourceGesture.Name,
              Command = new ObservableCollection<Key>(sourceGesture.Command),
              Hold = sourceGesture.Hold,
              Joint = sourceGesture.Joint
            };
            //copy the frames too (note: this is not the same as DeepCopyGestureFrame)
            foreach (GestureFrame sourceFrame in sourceGesture.Frames)
            {
              GestureFrame targetFrame = new GestureFrame();
              for (int i = 0; i < 400; i++)
              {
            targetFrame.FrontCells[i] = sourceFrame.FrontCells[i];
            targetFrame.SideCells[i] = sourceFrame.SideCells[i];
              }
              targetGesture.Frames.Add(targetFrame);
            }

            GestureCollection.Add(targetGesture);

            if (GestureCollectionLoaded != null)
              GestureCollectionLoaded(this, EventArgs.Empty);
              }
        }