Exemplo n.º 1
0
        private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            this.Close();
            TagWindow tagw = ((MainWindow)Application.Current.MainWindow).CreateTagWindow();

            ((MainWindow)Application.Current.MainWindow).CreateAndAddTag(NowText.Text, "", tagw);
        }
Exemplo n.º 2
0
 public void DeleteTagWindow(TagWindow closedtag)
 {
     for (int i = 0; i < tagwinlist.Count; i++)
     {
         if (tagwinlist[i] == closedtag)
         {
             tagwinlist[i].Close();
             tagwinlist.RemoveAt(i);
             break;
         }
     }
 }
Exemplo n.º 3
0
        public TagWindow CreateTagWindow(int posx = -1, int posy = -1)
        {
            Console.WriteLine("CreateTagWin");
            TagWindow tagw = new TagWindow(posx, posy);

            byte[][] theme = MyColorThemes[ColorThemeIndex];
            tagw.SetColorTheme(theme[0], theme[4], theme[2]);
            tagw.Show();
            tagw.Focus();
            tagwinlist.Add(tagw);
            return(tagw);
        }
Exemplo n.º 4
0
        public TagBase CreateAndAddTag(string type, string data, TagWindow tagw)
        {
            Type   tagtype = TagWindow.functions[type];
            object tag     = Activator.CreateInstance(tagtype, new object[] { tagw });

            if (data != "")
            {
                ((TagBase)tag).OnLoad(data);
            }
            tagw.AddTag((TagBase)tag);
            return((TagBase)tag);
        }
Exemplo n.º 5
0
        public void SplitTag(TagBase tag)
        {
            CtrlButtonRemoveData(tag, false);
            POINT pt = new POINT();

            GetCursorPos(out pt);
            TagWindow tagw = ((MainWindow)Application.Current.MainWindow).CreateTagWindow(pt.X - tag.Width / 2, pt.Y - tag.Height / 2);

            tag.OnTransfer(tagw);
            tagw.AddTag(tag, false);

            tagw.Window_MouseLeftButtonDown(null, null);
        }
Exemplo n.º 6
0
 private void CreateTagFromFile()
 {
     if (!File.Exists("data.dat"))
     {
         return;
     }
     using (StreamReader sr = new StreamReader("data.dat"))
     {
         ColorThemeIndex = Convert.ToInt32(sr.ReadLine());
         ApplyColorTheme();
         string strLine = string.Empty;
         Regex  rex     = new Regex(@"^\d+$");
         while (true)
         {
             strLine = sr.ReadLine();
             if (strLine == null)
             {
                 break;
             }
             if (rex.IsMatch(strLine))
             {
                 int num = Convert.ToInt32(strLine);
                 strLine = sr.ReadLine();
                 var       pms = strLine.Split(' ');
                 TagWindow t   = CreateTagWindow(Convert.ToInt32(pms[0]), Convert.ToInt32(pms[1]));
                 t.FullLoaded = false;
                 int     focustagindex = Convert.ToInt32(pms[2]);
                 TagBase savedtag      = null;
                 for (int i = 0; i < num; ++i)
                 {
                     strLine = sr.ReadLine();
                     var     name_data = strLine.Split(new char[] { ' ' }, 2);
                     var     datastr   = Regex.Unescape(name_data[1]);
                     TagBase tag       = CreateAndAddTag(name_data[0], datastr, t);
                     if (i == focustagindex)
                     {
                         savedtag = tag;
                     }
                 }
                 if (pms[3] == "True")
                 {
                     t.NeedHide             = true;
                     t.tw_border.Visibility = Visibility.Collapsed;
                 }
                 t.FullLoaded = true;
                 t.UpdateWindow(savedtag);
             }
         }
     }
 }
Exemplo n.º 7
0
        public void TagWindowDragOver(TagWindow dragwin)
        {
            TagWindow.POINT p = new TagWindow.POINT();
            TagWindow.GetCursorPos(out p);
            bool flag = false;

            for (int i = 0; i < tagwinlist.Count; i++)
            {
                TagWindow temp = tagwinlist[i];
                if (temp != dragwin && new Rect(temp.Left, temp.Top, temp.ActualWidth, temp.ActualHeight).Contains(p.X, p.Y) && dragwin.CanMerge(temp))
                {
                    flag = true;
                    break;
                }
            }
            dragwin.OnDragOver(flag);
        }
Exemplo n.º 8
0
        public void MergeTagWindow(TagWindow dragwin)
        {
            if (!dragwin.FoldFlag)
            {
                return;
            }
            double x1 = dragwin.Left, y1 = dragwin.Top, w1 = dragwin.Width, h1 = dragwin.Height;

            for (int i = 0; i < tagwinlist.Count; i++)
            {
                TagWindow temp = tagwinlist[i];
                if (temp != dragwin && isCollsionWithRect(x1, y1, w1, h1, temp.Left, temp.Top, temp.Width, temp.Height))
                {
                    temp.MergeTag(dragwin);
                    break;
                }
            }
        }
Exemplo n.º 9
0
 public bool CanMerge(TagWindow another)
 {
     foreach (var item in data)
     {
         var collidelist = item.CollideWith;
         foreach (var item2 in another.data)
         {
             foreach (var t in collidelist)
             {
                 if (t == item2.GetType())
                 {
                     return(false);
                 }
             }
         }
     }
     return(true);
 }
Exemplo n.º 10
0
        public void MergeTag(TagWindow another)
        {
            int precount = data.Count;

            another.ClearContent();
            data.AddRange(another.data);
            for (int i = precount; i < data.Count; ++i)
            {
                data[i].OnTransfer(this);
            }
            if (!IsCtrlBtnFolded)
            {
                WinHeight = Height + (data.Count - precount) * CtrlButtonSize;
                for (int i = precount; i < data.Count; ++i)
                {
                    GridAddButton(data[i]);
                }
            }
            UpdateCtrlBtnContent();
            ((MainWindow)Application.Current.MainWindow).DeleteTagWindow(another);
        }
Exemplo n.º 11
0
 public void StartSplitBgWorker(TagWindow t, TagBase tag, int tagindex)
 {
     if (splitbgworker == null)
     {
         double top = t.Top, left = t.Left;
         splitbgworker = new BackgroundWorker();
         splitbgworker.WorkerSupportsCancellation = true;
         splitbgworker.DoWork             += t.Check_MouseLeaveButton;
         splitbgworker.RunWorkerCompleted += (s1, e1) =>
         {
             if (!FinishSplit)
             {
                 FinishSplit = true;
                 if (Mouse.LeftButton == MouseButtonState.Pressed)
                 {
                     t.SplitTag(tag);
                 }
             }
         };
         Rect arg = new Rect(left, top + TagWindow.CtrlButtonSize * (tagindex + 1), TagWindow.CtrlButtonSize, TagWindow.CtrlButtonSize);
         splitbgworker.RunWorkerAsync(arg);
     }
 }
Exemplo n.º 12
0
 public TagBase(ref TagWindow host)
 {
     window = host;
 }
Exemplo n.º 13
0
 public virtual void OnTransfer(TagWindow new_window)
 {
     window = new_window;
 }
Exemplo n.º 14
0
 public override void OnTransfer(TagWindow new_window)
 {
     base.OnTransfer(new_window);
 }
Exemplo n.º 15
0
 public TagText(ref TagWindow host) : base(ref host)
 {
     _text_data  = "";
     _line_count = -1;
 }
Exemplo n.º 16
0
 public override void OnTransfer(TagWindow new_window)
 {
     window.WarningCancel();
     base.OnTransfer(new_window);
     BuildTimer();
 }
Exemplo n.º 17
0
 public TagTimer(ref TagWindow host) : base(ref host)
 {
 }
Exemplo n.º 18
0
 public TagImage(ref TagWindow host) : base(ref host)
 {
 }